Skip to content

Commit

Permalink
added settings, made profiles to the point where they will work (not …
Browse files Browse the repository at this point in the history
…yet finished), added date/time to the QAM, adjustable QAM size in settings
  • Loading branch information
project-sbc committed Aug 6, 2022
1 parent cb29c07 commit a49e8fc
Show file tree
Hide file tree
Showing 12 changed files with 196 additions and 54 deletions.
12 changes: 12 additions & 0 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public static class GlobalVariables
public static string ActiveProfile = "None";
public static string DefaultProfile = "None";
public static string ActiveApp = "None";
public static string powerStatus = "";

//display settings
public static string resolution = "";
Expand Down Expand Up @@ -194,6 +195,17 @@ private void timerTick(object sender, EventArgs e)
setTheme();
theme = Properties.Settings.Default.systemTheme;
}



//Profile or power status change updater
string Power = SystemParameters.PowerLineStatus.ToString();
if (Power != GlobalVariables.powerStatus & GlobalVariables.powerStatus != "" & GlobalVariables.ActiveProfile != "None")
{
MessageBox.Show("run change profile here");

}

}
private void OSKEvent(object sender, EventArgs e)
{
Expand Down
10 changes: 9 additions & 1 deletion PowerControlPanel/Classes/ChangeTDP/ChangeTDP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ChangeTDP
string RWDelay = "800"; //legacy value, RW.exe is not used anymore
private Object objLock = new Object();
private string processorName = "";
//public string BaseDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

public string BaseDir = AppDomain.CurrentDomain.BaseDirectory;

//Read TDP routines
Expand Down Expand Up @@ -88,6 +88,14 @@ public void changeTDP(int pl1TDP, int pl2TDP)
//StreamWriterLog.startStreamWriter("Start TDP change");
determineCPU();
//StreamWriterLog.startStreamWriter("CPU type is " + cpuType);

//check to make sure input TDP is not above maximum set and minimum 5
if (pl1TDP < 5) { pl1TDP = 5; }
if (pl2TDP < 5) { pl2TDP = 5; }
if (pl1TDP > Properties.Settings.Default.maxTDP) { pl1TDP = Properties.Settings.Default.maxTDP; }
if (pl2TDP > Properties.Settings.Default.maxTDP) { pl2TDP = Properties.Settings.Default.maxTDP; }


if (cpuType == "Intel")
{
if (Properties.Settings.Default.IntelMMIOMSR.Contains("MMIO"))
Expand Down
57 changes: 56 additions & 1 deletion PowerControlPanel/Classes/ManageXML/ManageXML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,36 @@ public void changeProfileParameter(string powerStatus, string parameter, string

}

public void updateProfile(string address)
public void changeProfileName(string oldName, string newName)
{

System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
xmlDocument.Load(GlobalVariables.xmlFile);
XmlNode xmlNode = xmlDocument.SelectSingleNode("//Configuration/Profiles");
XmlNodeList xmlSelectedNodes = xmlNode.SelectNodes("Profile/ProfileName[text()='" + oldName + "']");
if (xmlSelectedNodes != null)
{
foreach (XmlNode xmlNode1 in xmlSelectedNodes)
{
XmlNode nameNode = xmlNode1.SelectSingleNode("ProfileName");
if (nameNode != null)
{
if (nameNode.InnerText == oldName) { nameNode.InnerText = newName; }

}

}


}

xmlDocument.Save(GlobalVariables.xmlFile);

xmlDocument = null;

}


public void applyProfile()
{

Expand All @@ -219,6 +244,36 @@ public DataTable appList()


}

public void changeProfileNameInApps(string oldName, string newName)
{

System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
xmlDocument.Load(GlobalVariables.xmlFile);
XmlNode xmlNode = xmlDocument.SelectSingleNode("//Configuration/Applications");
XmlNodeList xmlSelectedNodes = xmlNode.SelectNodes("App/Profile[text()='" + oldName + "']");
if (xmlSelectedNodes != null)
{
foreach (XmlNode xmlNode1 in xmlSelectedNodes)
{
XmlNode nameNode = xmlNode1.SelectSingleNode("Profile");
if (nameNode != null)
{
if (nameNode.InnerText == oldName) { nameNode.InnerText = newName; }

}

}


}

xmlDocument.Save(GlobalVariables.xmlFile);

xmlDocument = null;

}

public void createApp()
{
System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
Expand Down
2 changes: 1 addition & 1 deletion PowerControlPanel/Classes/StartUp/StartUp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void runStartUp()
{
TaskScheduler.TaskScheduler.startScheduler();
GlobalVariables.tdp.readTDP();
if (GlobalVariables.readPL1 > 4000) { Properties.Settings.Default.IntelMMIOMSR = "MSR"; Properties.Settings.Default.Save(); GlobalVariables.tdp.readTDP(); }


ChangeDisplaySettings.ChangeDisplaySettings.generateDisplayResolutionAndRateList();
ChangeDisplaySettings.ChangeDisplaySettings.getCurrentDisplaySettings();
Expand Down
19 changes: 8 additions & 11 deletions PowerControlPanel/Classes/WriteLog/StreamWriterLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,30 @@

namespace Power_Control_Panel.PowerControlPanel.Classes
{
public class StreamWriterLog
public static class StreamWriterLog
{
//public static string BaseDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

public static string BaseDir = AppDomain.CurrentDomain.BaseDirectory;
public static Object objLock = new Object();
public static void startStreamWriter(string newLog)
{
try
{
if (!File.Exists(BaseDir + "\\PowerControlPanel\\Logs\\application_log.txt")) { createLogFile(); }
using (StreamWriter w = File.AppendText("PowerControlPanel/Logs/application_log.txt"))
lock (objLock)
{
lock(objLock)
if (!File.Exists(BaseDir + "\\PowerControlPanel\\Logs\\application_log.txt")) { createLogFile(); }
using (StreamWriter w = File.AppendText(BaseDir + "\\PowerControlPanel\\Logs\\application_log.txt"))
{
Log(newLog, w);

}

}




}

catch (Exception ex)
{
MessageBox.Show(ex.Message);

}


Expand Down
1 change: 1 addition & 0 deletions PowerControlPanel/Pages/ProfilesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontSize" Value="22"/>
<Setter Property="Width" Value="240"/>
<Setter Property="Background" Value="DarkGray" />
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
Expand Down
58 changes: 45 additions & 13 deletions PowerControlPanel/Pages/ProfilesPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,33 @@ namespace Power_Control_Panel.PowerControlPanel.Pages
public partial class ProfilesPage : Page
{
private Classes.ManageXML.ManageXML_Profiles xmlP;
private Classes.ManageXML.ManageXML_Apps xmlA;
private string ProfileName = "";
public ProfilesPage()
{
InitializeComponent();

//initialize xml management class
xmlP = new Classes.ManageXML.ManageXML_Profiles();
xmlA = new Classes.ManageXML.ManageXML_Apps();
//populate profile list
loadListView();

//change theme to match general theme
ThemeManager.Current.ChangeTheme(this, Properties.Settings.Default.systemTheme);


//hide AMD specific stuff if cpu is intel
if (GlobalVariables.cpuType =="Intel")
{
online_GPUCLK_DP.Visibility = Visibility.Collapsed;
offline_GPUCLK_DP.Visibility = Visibility.Collapsed;
}


//set max tdp on sliders
offline_sliderTDP1.Maximum = Properties.Settings.Default.maxTDP;
offline_sliderTDP2.Maximum = Properties.Settings.Default.maxTDP;
online_sliderTDP1.Maximum = Properties.Settings.Default.maxTDP;
online_sliderTDP2.Maximum = Properties.Settings.Default.maxTDP;
}

private void loadListView()
Expand All @@ -55,19 +66,32 @@ private void btnAddProfile_Click(object sender, System.Windows.RoutedEventArgs e

private void btnDeleteProfile_Click(object sender, System.Windows.RoutedEventArgs e)
{

bool deleteProfile = true;


xmlP.deleteProfile(ProfileName);
loadListView();
clearProfile();

if (GlobalVariables.ActiveProfile == ProfileName)
{
GlobalVariables.ActiveProfile = "None";

if (ProfileName == "Default")
{
if (System.Windows.Forms.MessageBox.Show("Deleting the Default profile will disable having a default. Do you still want to delete it?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.No)
{
deleteProfile = false;
}


}

if (deleteProfile == true)
{
xmlP.deleteProfile(ProfileName);
loadListView();
clearProfile();
if (GlobalVariables.ActiveProfile == ProfileName)
{
GlobalVariables.ActiveProfile = "None";

}
}

}
private void saveProfile()
{
Expand Down Expand Up @@ -130,10 +154,18 @@ private void saveProfile()
//check if profile name has changed! if yes, update any applications or active profiles with new name
if (ProfileName != txtbxProfileName.Text)
{
//if not match, then name was changed
System.Windows.MessageBox.Show("ADD PROFILE NAME CHANGE CODE HERE");
//if not match, then name was changed. Update profile name in profiles section of XML. Update all apps with profilename
xmlP.changeProfileName(ProfileName, txtbxProfileName.Text);
xmlA.changeProfileNameInApps(ProfileName, txtbxProfileName.Text);

if (GlobalVariables.ActiveProfile == ProfileName) { GlobalVariables.ActiveProfile = txtbxProfileName.Text; }
loadListView();

//if active profile name is the one changed, then update profile
if (GlobalVariables.ActiveProfile == ProfileName)
{
GlobalVariables.ActiveProfile = txtbxProfileName.Text;
System.Windows.MessageBox.Show("MAKE CODE TO RUN PROFILE AFTER PROFILE UPDATE");
}
}

System.Windows.MessageBox.Show("Profile Saved");
Expand Down
46 changes: 43 additions & 3 deletions PowerControlPanel/Pages/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<Border Grid.Row="0" BorderBrush="Gray" BorderThickness="0,0,0,0" />
<Border Grid.Row="1" BorderBrush="Gray" BorderThickness="0,1,0,0" />
<Border Grid.Row="2" BorderBrush="Gray" BorderThickness="0,1,0,0" />

<Border Grid.Row="3" BorderBrush="Gray" BorderThickness="0,1,0,0" />


<DockPanel >
Expand Down Expand Up @@ -105,13 +105,14 @@
</DockPanel>
<DockPanel Grid.Row="3" >

<Label Content="Quick Access Menu Size (%)" VerticalContentAlignment="Center" DockPanel.Dock="Left" HorizontalAlignment="Left" FontSize="20">
<Label Content="Quick Access Menu Width (%)" VerticalContentAlignment="Center" DockPanel.Dock="Left" HorizontalAlignment="Left" FontSize="20">

</Label>
<ComboBox x:Name="cboQAMSize" Width="200" HorizontalAlignment="Right" IsEditable="False" DockPanel.Dock="Right" >
<ComboBoxItem Content="25" />
<ComboBoxItem Content="33" />
<ComboBoxItem Content="40" />
<ComboBoxItem Content="45" />
</ComboBox>


Expand All @@ -124,7 +125,46 @@

</GroupBox>


<GroupBox Name="GB_INTEL_TDP" Margin="0,0,0,10">
<GroupBox.Header >
<DockPanel Height="30">
<Label Content="INTEL TDP SETTINGS" VerticalAlignment="Center" Foreground="White" FontSize="16" DockPanel.Dock="Left" Height="19" Padding="0,0,0,0" />


</DockPanel>
</GroupBox.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />

</Grid.RowDefinitions>
<Border Grid.Row="0" BorderBrush="Gray" BorderThickness="0,0,0,0" />





<DockPanel Grid.Row="0" >

<Label Content="TDP Set Type" VerticalContentAlignment="Center" DockPanel.Dock="Left" HorizontalAlignment="Left" FontSize="20">

</Label>
<ComboBox x:Name="cboTDPTypeIntel" Width="200" HorizontalAlignment="Right" IsEditable="False" DockPanel.Dock="Right" >
<ComboBoxItem Content="MMIO" />
<ComboBoxItem Content="MSR" />
<ComboBoxItem Content="MMIO + MSR" />

</ComboBox>


</DockPanel>
</Grid>





</GroupBox>
</StackPanel>
</ScrollViewer>
</Page>
15 changes: 15 additions & 0 deletions PowerControlPanel/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ public SettingsPage()
loadSettings();

ThemeManager.Current.ChangeTheme(this, Properties.Settings.Default.systemTheme);

hideSettings();
}

private void hideSettings()
{
if (GlobalVariables.cpuType == "AMD")
{
GB_INTEL_TDP.Visibility = Visibility.Collapsed;
}

}

private void btnSave_Click(object sender, RoutedEventArgs e)
Expand All @@ -49,6 +60,8 @@ private void btnSave_Click(object sender, RoutedEventArgs e)

Properties.Settings.Default.sizeQAM = cboQAMSize.Text;

Properties.Settings.Default.IntelMMIOMSR = cboTDPTypeIntel.Text;


//Save
Properties.Settings.Default.Save();
Expand All @@ -73,6 +86,8 @@ private void loadSettings()
cboQAMSize.Text = Properties.Settings.Default.sizeQAM;

cboAutoStart.Text = Properties.Settings.Default.systemAutoStart;

cboTDPTypeIntel.Text = Properties.Settings.Default.IntelMMIOMSR;
}
private void changeTaskService(string systemAutoStart)
{
Expand Down
Loading

0 comments on commit a49e8fc

Please sign in to comment.