Skip to content

Commit

Permalink
continued working on profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
project-sbc committed Aug 4, 2022
1 parent a426502 commit d00f2dd
Show file tree
Hide file tree
Showing 6 changed files with 294 additions and 33 deletions.
4 changes: 3 additions & 1 deletion OSK.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
ResizeMode="NoResize"
Background="Transparent"
AllowsTransparency="True"
Focusable="False"
Title="OnScreenKeyboard" Height="450" Width="{Binding Source={x:Static SystemParameters.FullPrimaryScreenWidth}}" x:Name="Keyboard" ShowInTaskbar="False" Closing="Keyboard_Closing" >

<Window.Resources>
Expand All @@ -21,7 +22,7 @@

<DropShadowEffect x:Key="DropShadowEffect" ShadowDepth="1" Direction="-90" BlurRadius="3" />
<Style TargetType="TextBlock">

<EventSetter Event="MouseDown" Handler="button_Click" />
<EventSetter Event="TouchDown" Handler="button_Click" />
<Setter Property="Margin" Value="4"/>

Expand All @@ -40,6 +41,7 @@
<Style TargetType="Rectangle">

<EventSetter Event="TouchDown" Handler="button_Click" />
<EventSetter Event="MouseDown" Handler="button_Click" />
<Setter Property="Margin" Value="4"/>
<Setter Property="Grid.ColumnSpan" Value="2"/>
<Setter Property="Fill" Value="WhiteSmoke"/>
Expand Down
80 changes: 80 additions & 0 deletions PowerControlPanel/Classes/ManageXML/ManageXML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,86 @@ public void deleteProfile(string profileName)
xmlDocument.Save(GlobalVariables.xmlFile);
xmlDocument = null;
}


public void saveProfileArray(string[] result, string profileName)
{
System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
xmlDocument.Load(GlobalVariables.xmlFile);
XmlNode xmlNode = xmlDocument.SelectSingleNode("//Configuration/Profiles");
XmlNode xmlSelectedNode = xmlNode.SelectSingleNode("Profile/ProfileName[text()='" + profileName + "']");
if (xmlSelectedNode != null)
{
XmlNode parentNode = xmlSelectedNode.ParentNode;

if (parentNode != null)
{
XmlNode onlineNode = parentNode.SelectSingleNode("Online");
foreach (XmlNode node in onlineNode.ChildNodes)
{
if (node.Name == "TDP1") { node.InnerText = result[0]; }
if (node.Name == "TDP2") { node.InnerText = result[1]; }
if (node.Name == "GPUCLK") { node.InnerText = result[2]; }
}



XmlNode offlineNode = parentNode.SelectSingleNode("Offline");
foreach (XmlNode node in offlineNode.ChildNodes)
{
if (node.Name == "TDP1") { node.InnerText = result[3]; }
if (node.Name == "TDP2") { node.InnerText = result[4]; }
if (node.Name == "GPUCLK") { node.InnerText = result[5]; }
}
}


}
xmlDocument.Save(GlobalVariables.xmlFile);

xmlDocument = null;


}
public string[] loadProfileArray(string profileName)
{
string[] result = new string [6];
System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
xmlDocument.Load(GlobalVariables.xmlFile);
XmlNode xmlNode = xmlDocument.SelectSingleNode("//Configuration/Profiles");
XmlNode xmlSelectedNode = xmlNode.SelectSingleNode("Profile/ProfileName[text()='" + profileName + "']");
if (xmlSelectedNode != null)
{
XmlNode parentNode = xmlSelectedNode.ParentNode;

if (parentNode != null)
{
XmlNode onlineNode = parentNode.SelectSingleNode("Online");
foreach (XmlNode node in onlineNode.ChildNodes)
{
if (node.Name == "TDP1") { result[0] = node.InnerText; }
if (node.Name == "TDP2") { result[1] = node.InnerText; }
if (node.Name == "GPUCLK") { result[2] = node.InnerText; }
}



XmlNode offlineNode = parentNode.SelectSingleNode("Offline");
foreach (XmlNode node in offlineNode.ChildNodes)
{
if (node.Name == "TDP1") { result[3] = node.InnerText; }
if (node.Name == "TDP2") { result[4] = node.InnerText; }
if (node.Name == "GPUCLK") { result[5] = node.InnerText; }
}
}


}

xmlDocument = null;
return result;
}

public string loadProfileParameter(string powerStatus, string parameter, string profileName)
{
string result = "";
Expand Down
38 changes: 19 additions & 19 deletions PowerControlPanel/Pages/ProfilesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@
<DockPanel Height="30">
<Label Content="PROFILE DETAILS" VerticalAlignment="Center" Foreground="White" FontSize="16" DockPanel.Dock="Left" Height="19" Padding="0,0,0,0" />

<Button x:Name="btnSave" Content="Save Profile" HorizontalAlignment="Right" DockPanel.Dock="Right" ></Button>
<Button x:Name="btnSave" Content="Save Profile" HorizontalAlignment="Right" DockPanel.Dock="Right" Click="btnSave_Click" ></Button>

</DockPanel>
</GroupBox.Header>
<StackPanel>
<DockPanel Height="40">
<Label Content="Profile Name" DockPanel.Dock="Left" FontSize="22" />
<TextBox x:Name="txtbxProfileName" Width="200" DockPanel.Dock="Right" HorizontalAlignment="Right" />
<TextBox x:Name="txtbxProfileName" FontSize="20" Width="200" DockPanel.Dock="Right" HorizontalAlignment="Right" />
</DockPanel>


Expand All @@ -113,24 +113,24 @@
<StackPanel>
<DockPanel Height="40" >
<Label Content="TDP Sustained (W)" DockPanel.Dock="Left" FontSize="22" />
<mah:ToggleSwitch Foreground="Black" Toggled="ToggleSwitch_Toggled" DockPanel.Dock="Right" CommandParameter="Online_TDP1" IsOn="False" OffContent="Disable" OnContent="Enable" MaxHeight="35" HorizontalContentAlignment="Right" Width="110" HorizontalAlignment="Right" MinWidth="90" MinHeight="1" />
<Label x:Name="online_txtTDP1" DockPanel.Dock="Right" Width="40" FontSize="17" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="{Binding ElementName=online_sliderTDP2, Path=Value}"/>
<Slider x:Name="online_sliderTDP1" DockPanel.Dock="Right" Height="25" Width="230" Minimum="5" IsSnapToTickEnabled="True" Maximum="35" Value="{Binding ElementName=txtsliderTDP2, Path=Content}" SmallChange="1" TickPlacement="None" HorizontalAlignment="Right" AutoToolTipPlacement="TopLeft" />
<mah:ToggleSwitch Foreground="Black" x:Name="toggle_Online_TDP1" Toggled="ToggleSwitch_Toggled" DockPanel.Dock="Right" CommandParameter="Online_TDP1" IsOn="True" OffContent="Disable" OnContent="Enable" MaxHeight="35" HorizontalContentAlignment="Right" Width="110" HorizontalAlignment="Right" MinWidth="90" MinHeight="1" />
<Label x:Name="online_txtTDP1" DockPanel.Dock="Right" Width="40" FontSize="17" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="{Binding ElementName=online_sliderTDP1, Path=Value}"/>
<Slider x:Name="online_sliderTDP1" DockPanel.Dock="Right" Height="25" Width="230" Minimum="5" IsSnapToTickEnabled="True" Maximum="35" SmallChange="1" TickPlacement="None" HorizontalAlignment="Right" AutoToolTipPlacement="TopLeft" />
</DockPanel>
<DockPanel Height="40">

<Label Content="TDP Boost (W)" DockPanel.Dock="Left" FontSize="22" />
<mah:ToggleSwitch Foreground="Black" Toggled="ToggleSwitch_Toggled" DockPanel.Dock="Right" CommandParameter="Online_TDP2" IsOn="False" OffContent="Disable" OnContent="Enable" MaxHeight="35" HorizontalContentAlignment="Right" Width="110" HorizontalAlignment="Right" MinWidth="90" MinHeight="1" />
<mah:ToggleSwitch Foreground="Black" x:Name="toggle_Online_TDP2" Toggled="ToggleSwitch_Toggled" DockPanel.Dock="Right" CommandParameter="Online_TDP2" IsOn="True" OffContent="Disable" OnContent="Enable" MaxHeight="35" HorizontalContentAlignment="Right" Width="110" HorizontalAlignment="Right" MinWidth="90" MinHeight="1" />
<Label x:Name="online_txtTDP2" DockPanel.Dock="Right" Width="40" FontSize="17" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="{Binding ElementName=online_sliderTDP2, Path=Value}"/>
<Slider x:Name="online_sliderTDP2" DockPanel.Dock="Right" Height="25" Width="230" Minimum="5" IsSnapToTickEnabled="True" Maximum="35" Value="{Binding ElementName=txtsliderTDP2, Path=Content}" SmallChange="1" TickPlacement="None" HorizontalAlignment="Right" AutoToolTipPlacement="TopLeft" />
<Slider x:Name="online_sliderTDP2" DockPanel.Dock="Right" Height="25" Width="230" Minimum="5" IsSnapToTickEnabled="True" Maximum="35" SmallChange="1" TickPlacement="None" HorizontalAlignment="Right" AutoToolTipPlacement="TopLeft" />

</DockPanel>
<DockPanel Height="40">
<DockPanel x:Name="online_GPUCLK_DP" Height="40">

<Label Content="GPU Clock (MHz)" DockPanel.Dock="Left" FontSize="22" />
<mah:ToggleSwitch Foreground="Black" Toggled="ToggleSwitch_Toggled" DockPanel.Dock="Right" CommandParameter="Online_GPUCLK" IsOn="False" OffContent="Disable" OnContent="Enable" MaxHeight="35" HorizontalContentAlignment="Right" Width="110" HorizontalAlignment="Right" MinWidth="90" MinHeight="1" />
<mah:ToggleSwitch Foreground="Black" x:Name="toggle_Online_GPUCLK" Toggled="ToggleSwitch_Toggled" DockPanel.Dock="Right" CommandParameter="Online_GPUCLK" IsOn="True" OffContent="Disable" OnContent="Enable" MaxHeight="35" HorizontalContentAlignment="Right" Width="110" HorizontalAlignment="Right" MinWidth="90" MinHeight="1" />
<Label x:Name="online_txtGPUCLK" DockPanel.Dock="Right" Width="40" FontSize="17" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="{Binding ElementName=online_sliderGPUCLK, Path=Value}"/>
<Slider x:Name="online_sliderGPUCLK" DockPanel.Dock="Right" Height="25" Width="230" Minimum="5" IsSnapToTickEnabled="True" Maximum="35" SmallChange="1" TickPlacement="None" HorizontalAlignment="Right" AutoToolTipPlacement="TopLeft" />
<Slider x:Name="online_sliderGPUCLK" DockPanel.Dock="Right" Height="25" Width="230" Minimum="5" IsSnapToTickEnabled="True" Maximum="35" SmallChange="1" TickPlacement="None" HorizontalAlignment="Right" AutoToolTipPlacement="TopLeft" />

</DockPanel>

Expand All @@ -154,23 +154,23 @@
<StackPanel>
<DockPanel Height="40">
<Label Content="TDP Sustained (W)" DockPanel.Dock="Left" FontSize="22" />
<mah:ToggleSwitch Foreground="Black" Toggled="ToggleSwitch_Toggled" DockPanel.Dock="Right" CommandParameter="Offline_TDP1" IsOn="False" OffContent="Disable" OnContent="Enable" MaxHeight="35" HorizontalContentAlignment="Right" Width="110" HorizontalAlignment="Right" MinWidth="90" MinHeight="1" />
<Label x:Name="offline_txtTDP1" DockPanel.Dock="Right" Width="40" FontSize="17" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="{Binding ElementName=online_sliderTDP2, Path=Value}"/>
<Slider x:Name="offline_sliderTDP1" DockPanel.Dock="Right" Height="25" Width="230" Minimum="5" IsSnapToTickEnabled="True" Maximum="35" Value="{Binding ElementName=txtsliderTDP2, Path=Content}" SmallChange="1" TickPlacement="None" HorizontalAlignment="Right" AutoToolTipPlacement="TopLeft" />
<mah:ToggleSwitch Foreground="Black" x:Name="toggle_Offline_TDP1" Toggled="ToggleSwitch_Toggled" DockPanel.Dock="Right" CommandParameter="Offline_TDP1" IsOn="True" OffContent="Disable" OnContent="Enable" MaxHeight="35" HorizontalContentAlignment="Right" Width="110" HorizontalAlignment="Right" MinWidth="90" MinHeight="1" />
<Label x:Name="offline_txtTDP1" DockPanel.Dock="Right" Width="40" FontSize="17" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="{Binding ElementName=offline_sliderTDP1, Path=Value}"/>
<Slider x:Name="offline_sliderTDP1" DockPanel.Dock="Right" Height="25" Width="230" Minimum="5" IsSnapToTickEnabled="True" Maximum="35" SmallChange="1" TickPlacement="None" HorizontalAlignment="Right" AutoToolTipPlacement="TopLeft" />
</DockPanel>
<DockPanel Height="40">

<Label Content="TDP Boost (W)" DockPanel.Dock="Left" FontSize="22" />
<mah:ToggleSwitch Foreground="Black" Toggled="ToggleSwitch_Toggled" DockPanel.Dock="Right" CommandParameter="Offline_TDP2" IsOn="False" OffContent="Disable" OnContent="Enable" MaxHeight="35" HorizontalContentAlignment="Right" Width="110" HorizontalAlignment="Right" MinWidth="90" MinHeight="1" />
<Label x:Name="offline_txtTDP2" DockPanel.Dock="Right" Width="40" FontSize="17" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="{Binding ElementName=online_sliderTDP2, Path=Value}"/>
<Slider x:Name="offline_sliderTDP2" DockPanel.Dock="Right" Height="25" Width="230" Minimum="5" IsSnapToTickEnabled="True" Maximum="35" Value="{Binding ElementName=txtsliderTDP2, Path=Content}" SmallChange="1" TickPlacement="None" HorizontalAlignment="Right" AutoToolTipPlacement="TopLeft" />
<mah:ToggleSwitch Foreground="Black" x:Name="toggle_Offline_TDP2" Toggled="ToggleSwitch_Toggled" DockPanel.Dock="Right" CommandParameter="Offline_TDP2" IsOn="True" OffContent="Disable" OnContent="Enable" MaxHeight="35" HorizontalContentAlignment="Right" Width="110" HorizontalAlignment="Right" MinWidth="90" MinHeight="1" />
<Label x:Name="offline_txtTDP2" DockPanel.Dock="Right" Width="40" FontSize="17" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="{Binding ElementName=offline_sliderTDP2, Path=Value}"/>
<Slider x:Name="offline_sliderTDP2" DockPanel.Dock="Right" Height="25" Width="230" Minimum="5" IsSnapToTickEnabled="True" Maximum="35" SmallChange="1" TickPlacement="None" HorizontalAlignment="Right" AutoToolTipPlacement="TopLeft" />

</DockPanel>
<DockPanel Height="40">
<DockPanel x:Name="offline_GPUCLK_DP" Height="40">

<Label Content="GPU Clock (MHz)" DockPanel.Dock="Left" FontSize="22" />
<mah:ToggleSwitch Foreground="Black" Toggled="ToggleSwitch_Toggled" DockPanel.Dock="Right" CommandParameter="Offline_GPUCLK" IsOn="False" OffContent="Disable" OnContent="Enable" MaxHeight="35" HorizontalContentAlignment="Right" Width="110" HorizontalAlignment="Right" MinWidth="90" MinHeight="1" />
<Label x:Name="offline_txtGPUCLK" DockPanel.Dock="Right" Width="40" FontSize="17" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="{Binding ElementName=online_sliderGPUCLK, Path=Value}"/>
<mah:ToggleSwitch Foreground="Black" x:Name="toggle_Offline_GPUCLK" Toggled="ToggleSwitch_Toggled" DockPanel.Dock="Right" CommandParameter="Offline_GPUCLK" IsOn="True" OffContent="Disable" OnContent="Enable" MaxHeight="35" HorizontalContentAlignment="Right" Width="110" HorizontalAlignment="Right" MinWidth="90" MinHeight="1" />
<Label x:Name="offline_txtGPUCLK" DockPanel.Dock="Right" Width="40" FontSize="17" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="{Binding ElementName=offline_sliderGPUCLK, Path=Value}"/>
<Slider x:Name="offline_sliderGPUCLK" DockPanel.Dock="Right" Height="25" Width="230" Minimum="5" IsSnapToTickEnabled="True" Maximum="35" SmallChange="1" TickPlacement="None" HorizontalAlignment="Right" AutoToolTipPlacement="TopLeft" />

</DockPanel>
Expand Down
Loading

0 comments on commit d00f2dd

Please sign in to comment.