Skip to content

Commit

Permalink
Added option to change sidebar width and font size.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcadeRenegade committed Jan 22, 2016
1 parent 5a676c8 commit 26ec8e8
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 55 deletions.
12 changes: 12 additions & 0 deletions SidebarDiagnostics/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@
<setting name="ClickThrough" serializeAs="String">
<value>False</value>
</setting>
<setting name="SidebarWidth" serializeAs="String">
<value>180</value>
</setting>
<setting name="FontSize" serializeAs="String">
<value>14</value>
</setting>
<setting name="TitleFontSize" serializeAs="String">
<value>16</value>
</setting>
<setting name="IconSize" serializeAs="String">
<value>24</value>
</setting>
</SidebarDiagnostics.Properties.Settings>
</userSettings>
</configuration>
25 changes: 11 additions & 14 deletions SidebarDiagnostics/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,34 @@
</Style>

<Style x:Key="AppIcon" TargetType="{x:Type Path}">
<Setter Property="Width" Value="24" />
<Setter Property="Height" Value="24" />
<Setter Property="Width" Value="{Binding Source={x:Static prop:Settings.Default}, Path=IconSize}" />
<Setter Property="Height" Value="{Binding Source={x:Static prop:Settings.Default}, Path=IconSize}" />
<Setter Property="Margin" Value="0,0,10,0" />
<Setter Property="Stretch" Value="Uniform" />
<Setter Property="Fill" Value="{Binding Source={x:Static prop:Settings.Default}, Path=TextColor}" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>

<Style x:Key="AppText" TargetType="{x:Type Label}">
<Style x:Key="AppTitle" TargetType="{x:Type Label}">
<Setter Property="Foreground" Value="{Binding Source={x:Static prop:Settings.Default}, Path=TextColor}" />
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0" />
</Style>

<Style x:Key="AppLabel" TargetType="{x:Type Label}" BasedOn="{StaticResource AppText}">
<Setter Property="FontSize" Value="14px" />
</Style>

<Style x:Key="AppTitle" TargetType="{x:Type Label}" BasedOn="{StaticResource AppText}">
<Setter Property="FontSize" Value="16px" />
<Setter Property="FontSize" Value="{Binding Source={x:Static prop:Settings.Default}, Path=TitleFontSize}" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>

<Style x:Key="AppSubtitle" TargetType="{x:Type TextBlock}">
<Style x:Key="HardwareText" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="{Binding Source={x:Static prop:Settings.Default}, Path=TextColor}" />
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0,0,0,6" />
<Setter Property="FontSize" Value="14px" />
<Setter Property="FontSize" Value="{Binding Source={x:Static prop:Settings.Default}, Path=FontSize}" />
<Setter Property="TextWrapping" Value="WrapWithOverflow" />
</Style>

<Style x:Key="SensorText" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource HardwareText}">
<Setter Property="Margin" Value="0" />
</Style>

<Style x:Key="HardwarePanel" TargetType="{x:Type StackPanel}">
<Setter Property="Margin" Value="0,0,0,10" />
</Style>
Expand Down
3 changes: 2 additions & 1 deletion SidebarDiagnostics/AppBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
MouseEnter="Window_MouseEnter"
MouseLeave="Window_MouseLeave"
Title="Sidebar"
Height="680" Width="180"
Width="{Binding Source={x:Static prop:Settings.Default}, Path=SidebarWidth}"
Height="800"
AllowsTransparency="True"
ShowInTaskbar="False"
ResizeMode="NoResize"
Expand Down
2 changes: 0 additions & 2 deletions SidebarDiagnostics/AppBar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public AppBar()

private void InitAppBar()
{
AppBarFunctions.SetAppBar(this, ABEdge.None);

Monitor _monitor = Utilities.GetMonitorFromIndex(Properties.Settings.Default.ScreenIndex);

Top = _monitor.WorkingArea.Top;
Expand Down
16 changes: 8 additions & 8 deletions SidebarDiagnostics/HWMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public HWPanel(IHardware board, HWType type, IHardware hardware, StackPanel pare
StackPanel.Style = (Style)Application.Current.FindResource("HardwarePanel");
parent.Children.Add(StackPanel);

TextBlock _subtitle = new TextBlock();
_subtitle.Style = (Style)Application.Current.FindResource("AppSubtitle");
_subtitle.Text = hardware.Name;
StackPanel.Children.Add(_subtitle);
TextBlock _hardwareName = new TextBlock();
_hardwareName.Style = (Style)Application.Current.FindResource("HardwareText");
_hardwareName.Text = hardware.Name;
StackPanel.Children.Add(_hardwareName);

UpdateHardware();

Expand Down Expand Up @@ -315,21 +315,21 @@ public HWSensor(ISensor sensor, string text, string append, StackPanel stackPane

Append = append;

Control = new Label();
Control.Style = (Style)Application.Current.FindResource("AppLabel");
Control = new TextBlock();
Control.Style = (Style)Application.Current.FindResource("SensorText");

stackPanel.Children.Add(Control);
}

public void UpdateLabel()
{
Control.Content = string.Format("{0}: {1:0.##}{2}", Text, Sensor.Value, Append);
Control.Text = string.Format("{0}: {1:0.##}{2}", Text, Sensor.Value, Append);
}

public ISensor Sensor { get; private set; }
public string Text { get; set; }
public string Append { get; set; }
public Label Control { get; private set; }
public TextBlock Control { get; private set; }
}

public enum HWType : byte
Expand Down
33 changes: 33 additions & 0 deletions SidebarDiagnostics/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
Expand Down Expand Up @@ -164,4 +165,36 @@ public bool Callback(IntPtr monitor, IntPtr hdc,
}
}
}

public class FontSetting
{
private FontSetting() { }

public override bool Equals(object obj)
{
FontSetting _fontSetting = obj as FontSetting;

if (_fontSetting == null)
{
return false;
}

return this.FontSize == _fontSetting.FontSize;
}

public override int GetHashCode()
{
return base.GetHashCode();
}

public static readonly FontSetting x10 = new FontSetting() { IconSize = 18, TitleFontSize = 12, FontSize = 10 };
public static readonly FontSetting x12 = new FontSetting() { IconSize = 22, TitleFontSize = 14, FontSize = 12 };
public static readonly FontSetting x14 = new FontSetting() { IconSize = 24, TitleFontSize = 16, FontSize = 14 };
public static readonly FontSetting x16 = new FontSetting() { IconSize = 28, TitleFontSize = 18, FontSize = 16 };
public static readonly FontSetting x18 = new FontSetting() { IconSize = 32, TitleFontSize = 20, FontSize = 18 };

public int IconSize { get; set; }
public int TitleFontSize { get; set; }
public int FontSize { get; set; }
}
}
48 changes: 48 additions & 0 deletions SidebarDiagnostics/Properties/Settings.Designer.cs

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

12 changes: 12 additions & 0 deletions SidebarDiagnostics/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,17 @@
<Setting Name="ClickThrough" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="SidebarWidth" Type="System.Int32" Scope="User">
<Value Profile="(Default)">180</Value>
</Setting>
<Setting Name="FontSize" Type="System.Int32" Scope="User">
<Value Profile="(Default)">14</Value>
</Setting>
<Setting Name="TitleFontSize" Type="System.Int32" Scope="User">
<Value Profile="(Default)">16</Value>
</Setting>
<Setting Name="IconSize" Type="System.Int32" Scope="User">
<Value Profile="(Default)">24</Value>
</Setting>
</Settings>
</SettingsFile>
70 changes: 40 additions & 30 deletions SidebarDiagnostics/Settings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="38px"></RowDefinition>
<RowDefinition Height="38px"></RowDefinition>
<RowDefinition Height="38px"></RowDefinition>
<RowDefinition Height="38px"></RowDefinition>
<RowDefinition Height="38px"></RowDefinition>
<RowDefinition Height="38px"></RowDefinition>
<RowDefinition Height="38px"></RowDefinition>
<RowDefinition Height="38px"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
Expand All @@ -37,46 +39,54 @@
</Grid.Resources>

<Label Grid.Column="0" Grid.Row="0" Content="Dock" VerticalAlignment="Center" />
<ComboBox x:Name="DockEdgeComboBox" Grid.Column="1" Grid.Row="0" VerticalAlignment="Center">
</ComboBox>

<ComboBox x:Name="DockEdgeComboBox" Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" />

<Label Grid.Column="0" Grid.Row="1" Content="Screen" VerticalAlignment="Center" />
<ComboBox x:Name="ScreenComboBox" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" />

<Label Grid.Column="0" Grid.Row="2" Content="Background Color" VerticalAlignment="Center" />
<TextBox x:Name="BGColorTextBox" Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" LostFocus="ColorTextBox_LostFocus" />
<Label Grid.Column="0" Grid.Row="2" Content="Sidebar Width" VerticalAlignment="Center" />
<DockPanel Grid.Column="1" Grid.Row="2" VerticalAlignment="Center">
<TextBox Text="{Binding ElementName=SidebarWidthSlider, Path=Value, UpdateSourceTrigger=PropertyChanged}" DockPanel.Dock="Right" Width="40" Margin="5,0,0,0" IsReadOnly="True" VerticalAlignment="Center" />
<Slider x:Name="SidebarWidthSlider" Minimum="100" Maximum="300" TickFrequency="5" TickPlacement="None" LargeChange="100" IsSnapToTickEnabled="True" VerticalAlignment="Center" />
</DockPanel>

<Label Grid.Column="0" Grid.Row="3" Content="Background Color" VerticalAlignment="Center" />
<TextBox x:Name="BGColorTextBox" Grid.Column="1" Grid.Row="3" VerticalAlignment="Center" LostFocus="ColorTextBox_LostFocus" />

<Label Grid.Column="0" Grid.Row="3" Content="Background Opacity" VerticalAlignment="Center" />
<DockPanel Grid.Column="1" Grid.Row="3" VerticalAlignment="Center">
<Label Grid.Column="0" Grid.Row="4" Content="Background Opacity" VerticalAlignment="Center" />
<DockPanel Grid.Column="1" Grid.Row="4" VerticalAlignment="Center">
<TextBox Text="{Binding ElementName=BGOpacitySlider, Path=Value, UpdateSourceTrigger=PropertyChanged}" DockPanel.Dock="Right" Width="40" Margin="5,0,0,0" IsReadOnly="True" VerticalAlignment="Center" />
<Slider x:Name="BGOpacitySlider" Minimum="0" Maximum="1.0" LargeChange="0.1" TickPlacement="BottomRight" TickFrequency="0.05" IsSnapToTickEnabled="True" VerticalAlignment="Center" />
<Slider x:Name="BGOpacitySlider" Minimum="0" Maximum="1.0" LargeChange="0.1" TickPlacement="None" TickFrequency="0.05" IsSnapToTickEnabled="True" VerticalAlignment="Center" />
</DockPanel>

<Label Grid.Column="0" Grid.Row="4" Content="Text Color" VerticalAlignment="Center" />
<TextBox x:Name="TextColorTextBox" Grid.Column="1" Grid.Row="4" VerticalAlignment="Center" LostFocus="ColorTextBox_LostFocus" />
<Label Grid.Column="0" Grid.Row="5" Content="Text Size" VerticalAlignment="Center" />
<ComboBox x:Name="FontSizeComboBox" Grid.Column="1" Grid.Row="5" VerticalAlignment="Center" />

<Label Grid.Column="0" Grid.Row="6" Content="Text Color" VerticalAlignment="Center" />
<TextBox x:Name="TextColorTextBox" Grid.Column="1" Grid.Row="6" VerticalAlignment="Center" LostFocus="ColorTextBox_LostFocus" />

<Label Grid.Column="0" Grid.Row="5" Content="Polling Interval (MS)" VerticalAlignment="Center" />
<DockPanel Grid.Column="1" Grid.Row="5" VerticalAlignment="Center">
<Label Grid.Column="0" Grid.Row="7" Content="Polling Interval (MS)" VerticalAlignment="Center" />
<DockPanel Grid.Column="1" Grid.Row="7" VerticalAlignment="Center">
<TextBox Text="{Binding ElementName=PollingIntervalSlider, Path=Value, UpdateSourceTrigger=PropertyChanged}" DockPanel.Dock="Right" Width="40" Margin="5,0,0,0" IsReadOnly="True" VerticalAlignment="Center" />
<Slider x:Name="PollingIntervalSlider" Minimum="100" Maximum="5000" TickFrequency="100" TickPlacement="BottomRight" LargeChange="1000" IsSnapToTickEnabled="True" VerticalAlignment="Center" />
<Slider x:Name="PollingIntervalSlider" Minimum="100" Maximum="5000" TickFrequency="100" TickPlacement="None" LargeChange="1000" IsSnapToTickEnabled="True" VerticalAlignment="Center" />
</DockPanel>

<Label Grid.Column="0" Grid.Row="6" Content="24 Hour Clock" VerticalAlignment="Center" />
<CheckBox x:Name="Clock24HRCheckBox" Grid.Column="1" Grid.Row="6" Margin="0,6,0,0" VerticalAlignment="Center" />
<Label Grid.Column="0" Grid.Row="8" Content="24 Hour Clock" VerticalAlignment="Center" />
<CheckBox x:Name="Clock24HRCheckBox" Grid.Column="1" Grid.Row="8" Margin="0,6,0,0" VerticalAlignment="Center" />

<Label Grid.Column="0" Grid.Row="7" Content="Use App Bar" VerticalAlignment="Center" />
<CheckBox x:Name="UseAppBarCheckBox" Grid.Column="1" Grid.Row="7" Margin="0,6,0,0" VerticalAlignment="Center" />
<Label Grid.Column="0" Grid.Row="9" Content="Use App Bar" VerticalAlignment="Center" />
<CheckBox x:Name="UseAppBarCheckBox" Grid.Column="1" Grid.Row="9" Margin="0,6,0,0" VerticalAlignment="Center" />

<Label Grid.Column="0" Grid.Row="8" Content="Allow Click Through" VerticalAlignment="Center" />
<CheckBox x:Name="ClickThroughCheckBox" Grid.Column="1" Grid.Row="8" Margin="0,6,0,0" VerticalAlignment="Center" />
<Label Grid.Column="0" Grid.Row="10" Content="Allow Click Through" VerticalAlignment="Center" />
<CheckBox x:Name="ClickThroughCheckBox" Grid.Column="1" Grid.Row="10" Margin="0,6,0,0" VerticalAlignment="Center" />

<Label Grid.Column="0" Grid.Row="9" Content="Always On Top" VerticalAlignment="Center" />
<CheckBox x:Name="AlwaysTopCheckBox" Grid.Column="1" Grid.Row="9" Margin="0,6,0,0" VerticalAlignment="Center" />
<Label Grid.Column="0" Grid.Row="11" Content="Always On Top" VerticalAlignment="Center" />
<CheckBox x:Name="AlwaysTopCheckBox" Grid.Column="1" Grid.Row="11" Margin="0,6,0,0" VerticalAlignment="Center" />

<Label Grid.Column="0" Grid.Row="10" Content="Run at startup" VerticalAlignment="Center" />
<CheckBox x:Name="StartupCheckBox" Grid.Column="1" Grid.Row="10" Margin="0,6,0,0" VerticalAlignment="Center" />
<Label Grid.Column="0" Grid.Row="12" Content="Run at startup" VerticalAlignment="Center" />
<CheckBox x:Name="StartupCheckBox" Grid.Column="1" Grid.Row="12" Margin="0,6,0,0" VerticalAlignment="Center" />

<StackPanel Grid.ColumnSpan="2" Grid.Row="11" Margin="0,20,0,0" HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Horizontal">
<StackPanel Grid.ColumnSpan="2" Grid.Row="13" Margin="0,20,0,0" HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Horizontal">
<Button x:Name="SaveBtn" Content="Save" Margin="0,0,10,0" Padding="16,8" Click="SaveBtn_Click"></Button>
<Button x:Name="CancelBtn" Content="Cancel" Padding="16,8" Click="CancelBtn_Click"></Button>
</StackPanel>
Expand Down
18 changes: 18 additions & 0 deletions SidebarDiagnostics/Settings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,21 @@ public Settings()
ScreenComboBox.SelectedValue = 0;
}

SidebarWidthSlider.Value = Properties.Settings.Default.SidebarWidth;

BGColorTextBox.Text = Properties.Settings.Default.BGColor;

BGOpacitySlider.Value = Properties.Settings.Default.BGOpacity;

FontSizeComboBox.Items.Add(FontSetting.x10);
FontSizeComboBox.Items.Add(FontSetting.x12);
FontSizeComboBox.Items.Add(FontSetting.x14);
FontSizeComboBox.Items.Add(FontSetting.x16);
FontSizeComboBox.Items.Add(FontSetting.x18);

FontSizeComboBox.DisplayMemberPath = FontSizeComboBox.SelectedValuePath = "FontSize";
FontSizeComboBox.SelectedValue = Properties.Settings.Default.FontSize;

TextColorTextBox.Text = Properties.Settings.Default.TextColor;

PollingIntervalSlider.Value = Properties.Settings.Default.PollingInterval;
Expand Down Expand Up @@ -72,8 +83,15 @@ private void SaveBtn_Click(object sender, RoutedEventArgs e)
{
Properties.Settings.Default.DockEdge = (ABEdge)DockEdgeComboBox.SelectedValue;
Properties.Settings.Default.ScreenIndex = (int)ScreenComboBox.SelectedValue;
Properties.Settings.Default.SidebarWidth = (int)SidebarWidthSlider.Value;
Properties.Settings.Default.BGColor = BGColorTextBox.Text;
Properties.Settings.Default.BGOpacity = BGOpacitySlider.Value;

FontSetting _fontSetting = (FontSetting)FontSizeComboBox.SelectedItem;
Properties.Settings.Default.FontSize = _fontSetting.FontSize;
Properties.Settings.Default.TitleFontSize = _fontSetting.TitleFontSize;
Properties.Settings.Default.IconSize = _fontSetting.IconSize;

Properties.Settings.Default.TextColor = TextColorTextBox.Text;
Properties.Settings.Default.PollingInterval = (int)PollingIntervalSlider.Value;
Properties.Settings.Default.Clock24HR = Clock24HRCheckBox.IsChecked.HasValue && Clock24HRCheckBox.IsChecked.Value;
Expand Down

0 comments on commit 26ec8e8

Please sign in to comment.