Skip to content

Commit

Permalink
fixed QAM sizing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
project-sbc committed Aug 5, 2022
1 parent d00f2dd commit cb29c07
Show file tree
Hide file tree
Showing 8 changed files with 231 additions and 7 deletions.
2 changes: 1 addition & 1 deletion OSK.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,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 Down
170 changes: 170 additions & 0 deletions PowerControlPanel/Classes/ManageXML/ManageXML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,177 @@ public void applyProfile()
}
public class ManageXML_Apps
{
public DataTable appList()
{
DataTable dt = new DataTable();
System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
xmlDocument.Load(GlobalVariables.xmlFile);
XmlNode xmlNode = xmlDocument.SelectSingleNode("//Configuration/Applications");

dt.Columns.Add("DisplayName");

foreach (XmlNode node in xmlNode.ChildNodes)
{

dt.Rows.Add(node.SelectSingleNode("DisplayName").InnerText);
}
xmlDocument = null;
return dt;


}
public void createApp()
{
System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
xmlDocument.Load(GlobalVariables.xmlFile);
XmlNode xmlNodeTemplate = xmlDocument.SelectSingleNode("//Configuration/AppTemplate/App");
XmlNode xmlNodeProfiles = xmlDocument.SelectSingleNode("//Configuration/Applications");


string newAppName = "NewApp";


XmlNode newNode = xmlDocument.CreateNode(XmlNodeType.Element, "App", "");
newNode.InnerXml = xmlNodeTemplate.InnerXml;
newNode.SelectSingleNode("DisplayName").InnerText = newAppName;
xmlNodeProfiles.AppendChild(newNode);



xmlDocument.Save(GlobalVariables.xmlFile);

xmlDocument = null;

}
public void deleteApp(string appName)
{
System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
xmlDocument.Load(GlobalVariables.xmlFile);
XmlNode xmlNodeProfiles = xmlDocument.SelectSingleNode("//Configuration/Applications");

foreach (XmlNode node in xmlNodeProfiles.ChildNodes)
{
if (node.SelectSingleNode("DisplayName").InnerText == appName)
{
xmlNodeProfiles.RemoveChild(node);
break;
}

}

xmlDocument.Save(GlobalVariables.xmlFile);
xmlDocument = null;
}


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

if (parentNode != null)
{

foreach (XmlNode node in parentNode.ChildNodes)
{
if (node.Name == "DisplayName") { node.InnerText = result[0]; }
if (node.Name == "Exe") { node.InnerText = result[1]; }
if (node.Name == "Path") { node.InnerText = result[2]; }
if (node.Name == "AppType") { node.InnerText = result[3]; }
if (node.Name == "GameType") { node.InnerText = result[4]; }
if (node.Name == "Image") { node.InnerText = result[5]; }
if (node.Name == "Profile") { node.InnerText = result[6]; }
if (node.Name == "Order") { node.InnerText = result[7]; }
}


}


}
xmlDocument.Save(GlobalVariables.xmlFile);

xmlDocument = null;


}
public string[] loadAppArray(string appName)
{
string[] result = new string[8];
System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
xmlDocument.Load(GlobalVariables.xmlFile);
XmlNode xmlNode = xmlDocument.SelectSingleNode("//Configuration/Applications");
XmlNode xmlSelectedNode = xmlNode.SelectSingleNode("App/DisplayName[text()='" + appName + "']");
if (xmlSelectedNode != null)
{
XmlNode parentNode = xmlSelectedNode.ParentNode;

if (parentNode != null)
{

foreach (XmlNode node in parentNode.ChildNodes)
{
if (node.Name == "DisplayName") { result[0] = node.InnerText; }
if (node.Name == "Exe") { result[1] = node.InnerText; }
if (node.Name == "Path") { result[2] = node.InnerText; }
if (node.Name == "AppType") { result[3] = node.InnerText; }
if (node.Name == "GameType") { result[4] = node.InnerText; }
if (node.Name == "Image") { result[5] = node.InnerText; }
if (node.Name == "Profile") { result[6] = node.InnerText; }
if (node.Name == "Order") { result[7] = node.InnerText; }

}



}


}

xmlDocument = null;
return result;
}

public string loadAppParameter(string parameter, string appName)
{
string result = "";
System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
xmlDocument.Load(GlobalVariables.xmlFile);
XmlNode xmlNode = xmlDocument.SelectSingleNode("//Configuration/Applications");
XmlNode xmlSelectedNode = xmlNode.SelectSingleNode("App/DisplayName[text()='" + appName + "']");
if (xmlSelectedNode != null)
{

XmlNode parameterNode = xmlSelectedNode.SelectSingleNode(parameter);
result = parameterNode.InnerText;
}

xmlDocument = null;
return result;
}
public void changeAppParameter(string parameter, string appName, string newValue)
{
string result = "";
System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
xmlDocument.Load(GlobalVariables.xmlFile);
XmlNode xmlNode = xmlDocument.SelectSingleNode("//Configuration/Applications");
XmlNode xmlSelectedNode = xmlNode.SelectSingleNode("App/DisplayName[text()='" + appName + "']");
if (xmlSelectedNode != null)
{

XmlNode parameterNode = xmlSelectedNode.SelectSingleNode(parameter);
parameterNode.InnerText = newValue;
}

xmlDocument = null;

}



Expand Down
16 changes: 14 additions & 2 deletions PowerControlPanel/Pages/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Power_Control_Panel.PowerControlPanel.Pages"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DesignHeight="500" d:DesignWidth="800"
MinWidth="450"
Title="SettingsPage">

Expand Down Expand Up @@ -37,7 +37,7 @@
<RowDefinition Height="50" />
<RowDefinition Height="50" />
<RowDefinition Height="50" />

<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderBrush="Gray" BorderThickness="0,0,0,0" />
<Border Grid.Row="1" BorderBrush="Gray" BorderThickness="0,1,0,0" />
Expand Down Expand Up @@ -103,7 +103,19 @@
<Slider x:Name="TDPMAX" DockPanel.Dock="Right" HorizontalAlignment="Right" Width="230" Height="40" Minimum="5" Maximum="60" Value="{Binding ElementName=txtsliderTDP1, Path=Content}" SmallChange="1" TickPlacement="None" IsSnapToTickEnabled="True" Loaded="TDPMAX_Loaded" />

</DockPanel>
<DockPanel Grid.Row="3" >

<Label Content="Quick Access Menu Size (%)" 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" />
</ComboBox>


</DockPanel>
</Grid>


Expand Down
5 changes: 5 additions & 0 deletions PowerControlPanel/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@ private void btnSave_Click(object sender, RoutedEventArgs e)

Properties.Settings.Default.maxTDP = (int)TDPMAX.Value;

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


//Save
Properties.Settings.Default.Save();

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

MessageBox.Show("Settings saved!");
}

private void loadSettings()
Expand All @@ -67,6 +70,8 @@ private void loadSettings()
cboLightDarkTheme.Text = Properties.Settings.Default.systemTheme.Substring(0, intPeriodLocation);
TDPMAX.Value = Properties.Settings.Default.maxTDP;

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

cboAutoStart.Text = Properties.Settings.Default.systemAutoStart;
}
private void changeTaskService(string systemAutoStart)
Expand Down
25 changes: 23 additions & 2 deletions PowerControlPanel/ProfileData/Profiles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@
</Profiles>

<Applications>
<App DisplayName="OSFE" Exe="OSFE.exe" Path="" AppType="Game" GameType="Steam" Image="" Profile="" Order=""/>
<App DisplayName="VS2022" Exe="Visualstudio.exe" Path="" AppType="App" GameType="" Image="" Profile="" Order=""/>
<App>
<DisplayName></DisplayName>
<Exe></Exe>
<Path></Path>
<AppType></AppType>
<GameType></GameType>
<Image></Image>
<Profile></Profile>
<Order></Order>
</App>

</Applications>
<ProfileTemplate>
<Profile >
Expand All @@ -48,5 +57,17 @@
</Online>
</Profile>
</ProfileTemplate>
<AppTemplate>
<App>
<DisplayName></DisplayName>
<Exe></Exe>
<Path></Path>
<AppType></AppType>
<GameType></GameType>
<Image></Image>
<Profile></Profile>
<Order></Order>
</App>
</AppTemplate>
</Configuration>

14 changes: 13 additions & 1 deletion Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,8 @@
<Setting Name="showDisplay" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="sizeQAM" Type="System.String" Scope="User">
<Value Profile="(Default)">40</Value>
</Setting>
</Settings>
</SettingsFile>
3 changes: 2 additions & 1 deletion QuickAccessMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEven

private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
{
this.Width = 0.33 * System.Windows.SystemParameters.PrimaryScreenWidth;
double width =(Convert.ToDouble(Properties.Settings.Default.sizeQAM) / 100);
this.Width = width * System.Windows.SystemParameters.PrimaryScreenWidth;
this.Left = System.Windows.SystemParameters.PrimaryScreenWidth - this.Width;
this.Top = 0;

Expand Down

0 comments on commit cb29c07

Please sign in to comment.