diff --git a/MiToolz/App.xaml b/MiToolz/App.xaml
index ebfabcb..24e3522 100644
--- a/MiToolz/App.xaml
+++ b/MiToolz/App.xaml
@@ -1,8 +1,10 @@
-
-
+ MiToolz v2.7.0
+ Build Date : 07-05-2020
diff --git a/MiToolz/ConfigManager.cs b/MiToolz/ConfigManager.cs
new file mode 100644
index 0000000..5f7749d
--- /dev/null
+++ b/MiToolz/ConfigManager.cs
@@ -0,0 +1,93 @@
+using Microsoft.Win32;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Xml.Linq;
+
+namespace MiToolz
+{
+ class ConfigManager
+ {
+ readonly string Path;
+ readonly string EXE = Assembly.GetExecutingAssembly().GetName().Name;
+
+ [DllImport("kernel32", CharSet = CharSet.Unicode)]
+ static extern long WritePrivateProfileString(string Section, string Key, string Value, string FilePath);
+
+ [DllImport("kernel32", CharSet = CharSet.Unicode)]
+ static extern int GetPrivateProfileString(string Section, string Key, string Default, StringBuilder RetVal, int Size, string FilePath);
+
+ //ini file management >
+ public ConfigManager(string IniPath = null)
+ {
+ Path = new FileInfo(IniPath ?? EXE + ".ini").FullName;
+ }
+
+ public string IniRead(string Key, string Section = null)
+ {
+ var RetVal = new StringBuilder(255);
+ GetPrivateProfileString(Section ?? EXE, Key, "", RetVal, 255, Path);
+ return RetVal.ToString();
+ }
+
+ public void IniWrite(string Key, string Value, string Section = null)
+ {
+ WritePrivateProfileString(Section ?? EXE, Key, Value, Path);
+ }
+
+ public void IniDeleteKey(string Key, string Section = null)
+ {
+ IniWrite(Key, null, Section ?? EXE);
+ }
+
+ public void IniDeleteSection(string Section = null)
+ {
+ IniWrite(null, null, Section ?? EXE);
+ }
+
+ public bool IniKeyExists(string Key, string Section = null)
+ {
+ return IniRead(Key, Section).Length > 0;
+ }
+
+ //registry key management >
+ public string RegReadKeyValue(string subKey, string key)
+
+ {
+ string str = string.Empty;
+
+ using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(subKey))
+
+ {
+ if (registryKey != null)
+ {
+ str = registryKey.GetValue(key).ToString();
+ registryKey.Close();
+ }
+ }
+ return str;
+ }
+
+ //xml file management >
+ public string XmlRead(string FullXmlFilePath)
+ {
+ string str = string.Empty;
+
+ //read xml entry for 'profile_name' in xml located in 'FullXmlFilePath' return profile name value
+
+ XDocument doc = XDocument.Load(FullXmlFilePath);
+ var selectors = from elements in doc.Elements("profile").Elements("info")
+ select elements;
+
+ foreach (var element in selectors)
+ {
+ str = element.Element("profile_name").Value;
+ //MessageBox.Show(element.Element("profile_name").Value);
+ }
+
+ return str;
+ }
+ }
+}
diff --git a/MiToolz/IniFile.cs b/MiToolz/IniFile.cs
deleted file mode 100644
index 5a393a2..0000000
--- a/MiToolz/IniFile.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System.IO;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Text;
-
-namespace MiToolz
-{
- class IniFile
- {
- readonly string Path;
- readonly string EXE = Assembly.GetExecutingAssembly().GetName().Name;
-
- [DllImport("kernel32", CharSet = CharSet.Unicode)]
- static extern long WritePrivateProfileString(string Section, string Key, string Value, string FilePath);
-
- [DllImport("kernel32", CharSet = CharSet.Unicode)]
- static extern int GetPrivateProfileString(string Section, string Key, string Default, StringBuilder RetVal, int Size, string FilePath);
-
- public IniFile(string IniPath = null)
- {
- Path = new FileInfo(IniPath ?? EXE + ".ini").FullName;
- }
-
- public string Read(string Key, string Section = null)
- {
- var RetVal = new StringBuilder(255);
- GetPrivateProfileString(Section ?? EXE, Key, "", RetVal, 255, Path);
- return RetVal.ToString();
- }
-
- public void Write(string Key, string Value, string Section = null)
- {
- WritePrivateProfileString(Section ?? EXE, Key, Value, Path);
- }
-
- public void DeleteKey(string Key, string Section = null)
- {
- Write(Key, null, Section ?? EXE);
- }
-
- public void DeleteSection(string Section = null)
- {
- Write(null, null, Section ?? EXE);
- }
-
- public bool KeyExists(string Key, string Section = null)
- {
- return Read(Key, Section).Length > 0;
- }
- }
-}
diff --git a/MiToolz/MainWindow.xaml b/MiToolz/MainWindow.xaml
index 131e639..88eafd4 100644
--- a/MiToolz/MainWindow.xaml
+++ b/MiToolz/MainWindow.xaml
@@ -4,7 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
- Title="MiToolz" Height="260" Width="394" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
+ Title="MiToolz" Height="260" Width="394" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Activated="Window_Activated">
-
+
@@ -84,7 +84,7 @@
-
-
+
+
diff --git a/MiToolz/MainWindow.xaml.cs b/MiToolz/MainWindow.xaml.cs
index fa67bb3..43ab434 100644
--- a/MiToolz/MainWindow.xaml.cs
+++ b/MiToolz/MainWindow.xaml.cs
@@ -22,10 +22,11 @@ public partial class MainWindow : Window
private static string StockProfile;
private static string OCProfile;
private static string SBControl_File;
+ static string SBControl_ActiveProfile;
private static string MSIAB_File;
private static string IsMonitoringEnabled;
private static bool NeedRestart = false;
- private static readonly IniFile MyIni = new IniFile();
+ private static readonly ConfigManager ConfigManager = new ConfigManager();
private static readonly Brush IndicatorReady = Brushes.Green;
private static readonly Brush IndicatorBusy = Brushes.Orange;
private static readonly int DelayS = 250;
@@ -33,9 +34,13 @@ public partial class MainWindow : Window
public MainWindow()
{
- StartupSetup();
InitializeComponent();
+
+ //run startup checks, read all config settings and show on UI elements
+ StartupSetup();
SetComboLists();
+ ShowActiveSoundProfile();
+ ShowActiveMSIabProfile();
Indicator.Background = IndicatorReady;
//add MainWindow close event handler
@@ -47,9 +52,6 @@ public MainWindow()
GPUEnabled = true
};
- //show which profile is currently active
- ShowActiveProfile();
- //check and start frequency monitoring if enabled
CheckStartMonitor();
}
@@ -63,20 +65,20 @@ private void StartupSetup()
}
//check for ini file, if not found then create new file and write default values to it
- string MyIniFile = Properties.Resources.MyIniFile;
+ string MyConfigManager = Properties.Resources.MyConfigManager;
string SBControl_FilePath = Properties.Resources.SBControl_FilePath;
string MSIAB_FilePath = Properties.Resources.MSIAB_FilePath;
string DefaultStockProfile = Properties.Resources.DefaultStockProfile;
string DefaultOCProfile = Properties.Resources.DefaultOCProfile;
IsMonitoringEnabled = "1";
- if (!File.Exists(MyIniFile))
+ if (!File.Exists(MyConfigManager))
{
- MyIni.Write("StockProfile", DefaultStockProfile);
- MyIni.Write("OCProfile", DefaultOCProfile);
- MyIni.Write("SBControl_File", SBControl_FilePath);
- MyIni.Write("MSIAB_File", MSIAB_FilePath);
- MyIni.Write("IsMonitoringEnabled", IsMonitoringEnabled);
+ ConfigManager.IniWrite("StockProfile", DefaultStockProfile);
+ ConfigManager.IniWrite("OCProfile", DefaultOCProfile);
+ ConfigManager.IniWrite("SBControl_File", SBControl_FilePath);
+ ConfigManager.IniWrite("MSIAB_File", MSIAB_FilePath);
+ ConfigManager.IniWrite("IsMonitoringEnabled", IsMonitoringEnabled);
ReadSettings();
}
else
@@ -88,11 +90,32 @@ private void StartupSetup()
//read in values from ini file
private void ReadSettings()
{
- StockProfile = MyIni.Read("StockProfile");
- OCProfile = MyIni.Read("OCProfile");
- SBControl_File = MyIni.Read("SBControl_File");
- MSIAB_File = MyIni.Read("MSIAB_File");
- IsMonitoringEnabled = MyIni.Read("IsMonitoringEnabled");
+ StockProfile = ConfigManager.IniRead("StockProfile");
+ OCProfile = ConfigManager.IniRead("OCProfile");
+ SBControl_File = ConfigManager.IniRead("SBControl_File");
+ MSIAB_File = ConfigManager.IniRead("MSIAB_File");
+ IsMonitoringEnabled = ConfigManager.IniRead("IsMonitoringEnabled");
+
+ string SBControl_ProfileFilePath = Properties.Resources.SBControl_ProfileFilePath;
+ string SBControl_ProfileRegPath = Properties.Resources.SBControl_ProfileRegPath;
+
+ //full path to profile folder
+ string WinUname = Environment.UserName;
+ string SBPAth = @"C:\Users\" + WinUname + @"\" + SBControl_ProfileFilePath;
+
+ //get folder name of subfolder (HDAUDIO_VEN_10EC_DEV_0899_SUBSYS_11020041 etc)
+ string[] SBGetIDDir = Directory.GetDirectories(SBPAth, "HDAUDIO*", SearchOption.TopDirectoryOnly);
+ string SBDeviceIDPath = string.Join("", SBGetIDDir);
+ string SBDeviceID = SBDeviceIDPath.Substring(SBDeviceIDPath.LastIndexOf(@"\") + 1);
+
+ //get registry key value for active profile
+ string SBRegKeyName = SBControl_ProfileRegPath + SBDeviceID;
+ string SBGetValue = ConfigManager.RegReadKeyValue(SBRegKeyName, "Profile");
+ string SBRegKeyValue = SBGetValue.Substring(SBGetValue.LastIndexOf(@"\") + 1);
+
+ //read profile xml and extract profile_name value
+ string FullXmlFilePath = SBDeviceIDPath + @"\" + SBRegKeyValue;
+ SBControl_ActiveProfile = ConfigManager.XmlRead(FullXmlFilePath);
}
//set if frequency monitoring is enabled and show if true
@@ -116,8 +139,14 @@ private void SetComboLists()
Combo_OC.SelectedIndex = int.Parse(OCProfile) - 1;
}
+ //show which Audio profile is active
+ private void ShowActiveSoundProfile()
+ {
+ TextBlock_Sound.Text = SBControl_ActiveProfile;
+ }
+
//determin which profile is active by checking if power.limit is greater than defaul_power.limit
- private void ShowActiveProfile()
+ private void ShowActiveMSIabProfile()
{
Process ShowProfile_Process = new Process
{
@@ -276,7 +305,7 @@ private void ApplyProfile(string Profile)
{
//change indicator elements on the UI thread.
Indicator.Background = IndicatorReady;
- ShowActiveProfile();
+ ShowActiveMSIabProfile();
});
});
}
@@ -359,16 +388,16 @@ private void Button_SaveProfiles_Click(object sender, RoutedEventArgs e)
var GetComboStockValue = Combo_Stock.SelectedIndex + 1;
var GetComboOCValue = Combo_OC.SelectedIndex + 1;
- MyIni.Write("StockProfile", GetComboStockValue.ToString());
- MyIni.Write("OCProfile", GetComboOCValue.ToString());
+ ConfigManager.IniWrite("StockProfile", GetComboStockValue.ToString());
+ ConfigManager.IniWrite("OCProfile", GetComboOCValue.ToString());
if (Checkbox_EnableMonitor.IsChecked == false)
{
- MyIni.Write("IsMonitoringEnabled", "0");
+ ConfigManager.IniWrite("IsMonitoringEnabled", "0");
}
if (Checkbox_EnableMonitor.IsChecked == true)
{
- MyIni.Write("IsMonitoringEnabled", "1");
+ ConfigManager.IniWrite("IsMonitoringEnabled", "1");
}
if (NeedRestart == false)
@@ -410,6 +439,12 @@ private void Button_OpenMSIAB_Click(object sender, RoutedEventArgs e)
MSIAB_Process.Start();
}
+ //set restart app flag when checkbox has been clicked/changed
+ private void Checkbox_EnableMonitor_Clicked(object sender, RoutedEventArgs e)
+ {
+ NeedRestart = true;
+ }
+
//MainWindow close application event handler
void MainWindow_Closed(object sender, EventArgs e)
{
@@ -418,10 +453,12 @@ void MainWindow_Closed(object sender, EventArgs e)
Close();
}
- //set restart app flag when checkbox has been clicked/changed
- private void Checkbox_EnableMonitor_Clicked(object sender, RoutedEventArgs e)
+ //reflect updated settings in UI when window is re-focused
+ private void Window_Activated(object sender, EventArgs e)
{
- NeedRestart = true;
+ ReadSettings();
+ SetComboLists();
+ ShowActiveSoundProfile();
}
}
}
diff --git a/MiToolz/MiToolz.csproj b/MiToolz/MiToolz.csproj
index a61602f..2fac412 100644
--- a/MiToolz/MiToolz.csproj
+++ b/MiToolz/MiToolz.csproj
@@ -123,7 +123,7 @@
App.xaml
Code
-
+
MainWindow.xaml
Code
diff --git a/MiToolz/Properties/AssemblyInfo.cs b/MiToolz/Properties/AssemblyInfo.cs
index 18c5ba5..d2de35b 100644
--- a/MiToolz/Properties/AssemblyInfo.cs
+++ b/MiToolz/Properties/AssemblyInfo.cs
@@ -50,4 +50,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("2.6.1.0")]
+[assembly: AssemblyFileVersion("2.7.0.0")]
diff --git a/MiToolz/Properties/Resources.Designer.cs b/MiToolz/Properties/Resources.Designer.cs
index c7f04fe..f208df9 100644
--- a/MiToolz/Properties/Resources.Designer.cs
+++ b/MiToolz/Properties/Resources.Designer.cs
@@ -160,9 +160,9 @@ internal static string MSIAB_FilePath {
///
/// Looks up a localized string similar to MiToolz.ini.
///
- internal static string MyIniFile {
+ internal static string MyConfigManager {
get {
- return ResourceManager.GetString("MyIniFile", resourceCulture);
+ return ResourceManager.GetString("MyConfigManager", resourceCulture);
}
}
@@ -174,5 +174,23 @@ internal static string SBControl_FilePath {
return ResourceManager.GetString("SBControl_FilePath", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to AppData\Local\Creative\Sound Blaster Audigy Fx Control Panel\profile\.
+ ///
+ internal static string SBControl_ProfileFilePath {
+ get {
+ return ResourceManager.GetString("SBControl_ProfileFilePath", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Software\Creative Tech\Sound Blaster Audigy Fx Control Panel\Settings\.
+ ///
+ internal static string SBControl_ProfileRegPath {
+ get {
+ return ResourceManager.GetString("SBControl_ProfileRegPath", resourceCulture);
+ }
+ }
}
}
diff --git a/MiToolz/Properties/Resources.resx b/MiToolz/Properties/Resources.resx
index 4a38304..927cff5 100644
--- a/MiToolz/Properties/Resources.resx
+++ b/MiToolz/Properties/Resources.resx
@@ -148,10 +148,16 @@
C:\Program Files (x86)\MSI Afterburner\MSIAfterburner.exe
-
+
MiToolz.ini
C:\Program Files (x86)\Creative\Sound Blaster Audigy Fx\Sound Blaster Audigy Fx Control Panel\SBAdgyFx.exe
+
+ AppData\Local\Creative\Sound Blaster Audigy Fx Control Panel\profile\
+
+
+ Software\Creative Tech\Sound Blaster Audigy Fx Control Panel\Settings\
+
\ No newline at end of file
diff --git a/MiToolz/obj/Release/MiToolz.csproj.FileListAbsolute.txt b/MiToolz/obj/Release/MiToolz.csproj.FileListAbsolute.txt
new file mode 100644
index 0000000..e69de29