Skip to content

Commit

Permalink
#38 enable wheel scrolling in toolstrip dropdownmenu & cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
Orbmu2k committed Jan 13, 2020
1 parent 57a8879 commit 9adc3b9
Show file tree
Hide file tree
Showing 41 changed files with 214 additions and 196 deletions.
2 changes: 1 addition & 1 deletion nspector/Common/Cache/CachedSettingValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace nspector.Common
internal class CachedSettingValue
{

internal CachedSettingValue() { }
internal CachedSettingValue() { }

internal CachedSettingValue(uint Value, string ProfileNames)
{
Expand Down
6 changes: 3 additions & 3 deletions nspector/Common/Cache/CachedSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ namespace nspector.Common
{
internal class CachedSettings
{
internal CachedSettings() { }
internal CachedSettings() { }

internal CachedSettings(uint settingId, NVDRS_SETTING_TYPE settingType)
{
SettingId = settingId;
SettingType = settingType;
}

internal uint SettingId;

internal List<CachedSettingValue> SettingValues = new List<CachedSettingValue>();

internal uint ProfileCount = 0;

internal NVDRS_SETTING_TYPE SettingType = NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE;

internal void AddDwordValue(uint valueDword, string Profile)
{
var setting = SettingValues.FirstOrDefault(s => s.Value == valueDword);
Expand Down
1 change: 0 additions & 1 deletion nspector/Common/CustomSettings/CustomSetting.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Xml.Serialization;

namespace nspector.Common.CustomSettings
Expand Down
1 change: 0 additions & 1 deletion nspector/Common/CustomSettings/CustomSettingValue.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Globalization;

namespace nspector.Common.CustomSettings
{
Expand Down
9 changes: 4 additions & 5 deletions nspector/Common/DrsImportService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using nspector.Common.Import;
using nspector.Native.NVAPI2;
Expand All @@ -18,8 +17,8 @@ internal class DrsImportService : DrsSettingsServiceBase
private readonly DrsDecrypterService _DecrypterService;

public DrsImportService(
DrsSettingsMetaService metaService,
DrsSettingsService settingService,
DrsSettingsMetaService metaService,
DrsSettingsService settingService,
DrsScannerService scannerService,
DrsDecrypterService decrypterService)
: base(metaService)
Expand Down Expand Up @@ -77,7 +76,7 @@ private Profile CreateProfileForExport(IntPtr hSession, string profileName, bool
{
result.Executeables.Add(app.appName);
}

var settings = GetProfileSettings(hSession, hProfile);
foreach (var setting in settings)
{
Expand Down Expand Up @@ -239,7 +238,7 @@ private void UpdateSettings(IntPtr hSession, IntPtr hProfile, Profile importProf
var decryptedSetting = setting;
_DecrypterService.DecryptSettingIfNeeded(profileName, ref decryptedSetting);

if (isPredefined && exitsValueInImport && ImportExportUitl.AreDrsSettingEqualToProfileSetting(decryptedSetting, importSetting))
if (isPredefined && exitsValueInImport && ImportExportUitl.AreDrsSettingEqualToProfileSetting(decryptedSetting, importSetting))
{
alreadySet.Add(setting.settingId);
}
Expand Down
4 changes: 2 additions & 2 deletions nspector/Common/DrsScannerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ await Task.Run(() =>

foreach (uint kpd in knownPredefines)
{
if (CheckCommonSetting(hSession, hProfile, profile,
ref checkedSettingsCount, kpd, !justModified, ref alreadyChecked))
if (CheckCommonSetting(hSession, hProfile, profile,
ref checkedSettingsCount, kpd, !justModified, ref alreadyChecked))
{
if (!foundModifiedProfile)
{
Expand Down
12 changes: 2 additions & 10 deletions nspector/Common/DrsServiceLocator.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.IO;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using nspector.Common.CustomSettings;

using nvw = nspector.Native.NVAPI2.NvapiDrsWrapper;

namespace nspector.Common
{
internal class DrsServiceLocator
Expand Down Expand Up @@ -53,6 +45,6 @@ private static CustomSettingNames LoadReferenceSettings()

return null;
}

}
}
2 changes: 1 addition & 1 deletion nspector/Common/DrsSessionScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static T DrsSession<T>(Func<IntPtr, T> action, bool forceNonGlobalSession

if (csRes != NvAPI_Status.NVAPI_OK)
throw new NvapiException("DRS_CreateSession", csRes);

if (!preventLoadSettings)
{
var nvRes = nvw.DRS_LoadSettings(GlobalSession);
Expand Down
57 changes: 27 additions & 30 deletions nspector/Common/DrsSettingsMetaService.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using nspector.Common.Meta;
using nspector.Common.CustomSettings;
using nspector.Native.NVAPI2;
using nspector.Native.NvApi.DriverSettings;

namespace nspector.Common
{
internal class DrsSettingsMetaService
{

private ISettingMetaService ConstantMeta;
private ISettingMetaService CustomMeta;
public ISettingMetaService DriverMeta;
Expand All @@ -38,7 +35,7 @@ public void ResetMetaCache(bool initOnly = false)
{
settingMetaCache = new Dictionary<uint, SettingMeta>();
MetaServices = new List<MetaServiceItem>();

CustomMeta = new CustomSettingMetaService(_customSettings);
MetaServices.Add(new MetaServiceItem() { ValueNamePrio = 1, Service = CustomMeta });

Expand All @@ -64,7 +61,7 @@ public void ResetMetaCache(bool initOnly = false)
}

}

private NVDRS_SETTING_TYPE? GetSettingValueType(uint settingId)
{
foreach (var service in MetaServices.OrderBy(x => x.Service.Source))
Expand All @@ -76,12 +73,12 @@ public void ResetMetaCache(bool initOnly = false)

return NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE;
}

private string GetSettingName(uint settingId)
{
string hexCandidate = null;

foreach (var service in MetaServices.OrderBy(x=>x.Service.Source))
foreach (var service in MetaServices.OrderBy(x => x.Service.Source))
{
var settingName = service.Service.GetSettingName(settingId);

Expand Down Expand Up @@ -129,7 +126,7 @@ private string GetStringDefaultValue(uint settingId)
if (settingDefault != null)
return settingDefault;
}

return null;
}

Expand Down Expand Up @@ -159,7 +156,7 @@ private List<SettingValue<T>> MergeSettingValues<T>(List<SettingValue<T>> a, Lis
else
{
var currentNonScannedValues = a.Where(xa => xa.ValueSource != SettingMetaSource.ScannedSettings).Select(xa => xa.Value).ToList();

var newNonScannedValues = b.Where(xb => !currentNonScannedValues.Contains(xb.Value)).ToList();
a.AddRange(newNonScannedValues);

Expand All @@ -177,7 +174,7 @@ private List<SettingValue<T>> MergeSettingValues<T>(List<SettingValue<T>> a, Lis

var atmp = a.FirstOrDefault();
if (atmp != null && atmp is IComparable)
return a.OrderBy(x=>x.Value).ToList();
return a.OrderBy(x => x.Value).ToList();
else
return a.ToList();
}
Expand All @@ -202,7 +199,7 @@ private List<SettingValue<string>> GetStringValues(uint settingId)
{
result = MergeSettingValues(result, service.Service.GetStringValues(settingId));
}

return result;
}

Expand All @@ -217,15 +214,15 @@ private List<SettingValue<uint>> GetDwordValues(uint settingId)

if (result != null)
{
result = (from v in result.Where(x=> 1==1
result = (from v in result.Where(x => 1 == 1
&& !x.ValueName.EndsWith("_NUM")
&& !x.ValueName.EndsWith("_MASK")
&& (!x.ValueName.EndsWith("_MIN") || x.ValueName.Equals("PREFERRED_PSTATE_PREFER_MIN"))
&& (!x.ValueName.EndsWith("_MAX") || x.ValueName.Equals("PREFERRED_PSTATE_PREFER_MAX"))
)
group v by v.ValueName into g
select g.First(t => t.ValueName == g.Key))

)
group v by v.ValueName into g
select g.First(t => t.ValueName == g.Key))
.OrderBy(v => v.ValueSource)
.ThenBy(v => v.ValuePos)
.ThenBy(v => v.ValueName).ToList();
Expand All @@ -234,7 +231,7 @@ select g.First(t => t.ValueName == g.Key))

return result;
}

public List<uint> GetSettingIds(SettingViewMode viewMode)
{
var settingIds = new List<uint>();
Expand All @@ -255,21 +252,21 @@ private SettingMetaSource[] GetAllowedSettingIdMetaSourcesForViewMode(SettingVie
switch (viewMode)
{
case SettingViewMode.CustomSettingsOnly:
return new [] {
SettingMetaSource.CustomSettings
return new[] {
SettingMetaSource.CustomSettings
};
case SettingViewMode.IncludeScannedSetttings:
return new [] {
return new[] {
SettingMetaSource.ConstantSettings,
SettingMetaSource.ScannedSettings,
SettingMetaSource.CustomSettings,
SettingMetaSource.ScannedSettings,
SettingMetaSource.CustomSettings,
SettingMetaSource.DriverSettings,
SettingMetaSource.ReferenceSettings,
};
default:
return new [] {
SettingMetaSource.CustomSettings,
SettingMetaSource.DriverSettings,
return new[] {
SettingMetaSource.CustomSettings,
SettingMetaSource.DriverSettings,
};
}
}
Expand Down Expand Up @@ -300,7 +297,7 @@ private SettingMeta CreateSettingMeta(uint settingId)
var settingType = GetSettingValueType(settingId);
var settingName = GetSettingName(settingId);
var groupName = GetGroupName(settingId);

if (groupName == null)
groupName = GetLegacyGroupName(settingId, settingName);

Expand All @@ -310,11 +307,11 @@ private SettingMeta CreateSettingMeta(uint settingId)
SettingName = settingName,
GroupName = groupName,

DefaultDwordValue =
settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE
DefaultDwordValue =
settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE
? GetDwordDefaultValue(settingId) : 0,

DefaultStringValue =
DefaultStringValue =
settingType == NVDRS_SETTING_TYPE.NVDRS_WSTRING_TYPE
? GetStringDefaultValue(settingId) : null,

Expand Down
Loading

0 comments on commit 9adc3b9

Please sign in to comment.