Skip to content

Commit

Permalink
Added the option to rename hardware.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcadeRenegade committed Feb 9, 2016
1 parent d22e206 commit c478daa
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 44 deletions.
12 changes: 10 additions & 2 deletions SidebarDiagnostics/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xmlns:local="clr-namespace:SidebarDiagnostics"
xmlns:prop="clr-namespace:SidebarDiagnostics.Properties"
xmlns:command="clr-namespace:SidebarDiagnostics.Commands"
xmlns:conv="clr-namespace:SidebarDiagnostics.Converters"
ShutdownMode="OnExplicitShutdown">
<Application.Resources>
<ResourceDictionary>
Expand Down Expand Up @@ -33,6 +34,8 @@
</tb:TaskbarIcon.ContextMenu>
</tb:TaskbarIcon>

<conv:DriveNameLengthConverter x:Key="DriveNameConverter" />

<Style x:Key="LoadingPanel" TargetType="{x:Type StackPanel}">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
Expand Down Expand Up @@ -354,14 +357,19 @@
</Style>

<Style x:Key="MonitorHardwareCheckbox" TargetType="{x:Type CheckBox}">
<Setter Property="Margin" Value="0,2" />
<Setter Property="Margin" Value="0,2,0,0" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>

<Style x:Key="MonitorHardwareText" TargetType="{x:Type TextBlock}">
<Style x:Key="MonitorHardwareText" TargetType="{x:Type TextBox}">
<Setter Property="Margin" Value="0,2,0,0" />
<Setter Property="Padding" Value="0" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="#000000" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
</Style>

<Style x:Key="MonitorParams" TargetType="{x:Type ItemsControl}">
Expand Down
20 changes: 20 additions & 0 deletions SidebarDiagnostics/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,24 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
return null;
}
}

public class DriveNameLengthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
string _name = (string)value;

if (_name == null)
{
return true;
}

return _name.Length <= 2;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}
77 changes: 41 additions & 36 deletions SidebarDiagnostics/Monitoring.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions SidebarDiagnostics/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.4.6.0")]
[assembly: AssemblyFileVersion("2.4.6.0")]
[assembly: AssemblyVersion("2.4.7.0")]
[assembly: AssemblyFileVersion("2.4.7.0")]
4 changes: 2 additions & 2 deletions SidebarDiagnostics/Settings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
</DockPanel>

<Label Grid.Column="0" Grid.Row="3" Content="Font Size" />
<ComboBox Grid.Column="1" Grid.Row="3" ItemsSource="{Binding Path=FontSettingItems}" DisplayMemberPath="FontSize" SelectedValue="{Binding Path=FontSetting, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ToolTip="Size of text and icons in the sidebar." />
<ComboBox Grid.Column="1" Grid.Row="3" ItemsSource="{Binding Path=FontSettingItems}" DisplayMemberPath="FontSize" SelectedValue="{Binding Path=FontSetting, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ToolTip="Size of text and icons." />

<Label Grid.Column="0" Grid.Row="4" Content="Font Color" />
<xctk:ColorPicker Grid.Column="1" Grid.Row="4" SelectedColor="{Binding Path=FontColor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ToolTip="Color of text and icons."/>
Expand Down Expand Up @@ -232,7 +232,7 @@
<GridViewColumn Header="Hardware" HeaderContainerStyle="{StaticResource MonitorHardwareHeader}" Width="210">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name, Mode=OneWay}" Style="{StaticResource MonitorHardwareText}" />
<TextBox Text="{Binding Path=Name, Mode=TwoWay}" Style="{StaticResource MonitorHardwareText}" ToolTip="Edit the name of this hardware." />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
Expand Down
24 changes: 22 additions & 2 deletions SidebarDiagnostics/Sidebar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@
<ContentControl.Style>
<Style TargetType="{x:Type ContentControl}">
<Style.Triggers>
<DataTrigger Binding="{Binding ShowDetails, Mode=OneWay}" Value="False">
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ShowDetails, Mode=OneWay}" Value="False" />
<Condition Binding="{Binding Path=Label, Mode=OneWay, Converter={StaticResource DriveNameConverter}}" Value="True" />
</MultiDataTrigger.Conditions>
<Setter Property="Content">
<Setter.Value>
<Grid>
Expand All @@ -172,7 +176,23 @@
</Grid>
</Setter.Value>
</Setter>
</DataTrigger>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ShowDetails, Mode=OneWay}" Value="False" />
<Condition Binding="{Binding Path=Label, Mode=OneWay, Converter={StaticResource DriveNameConverter}}" Value="False" />
</MultiDataTrigger.Conditions>
<Setter Property="Content">
<Setter.Value>
<Grid>
<StackPanel Style="{StaticResource VerticalPanel}">
<TextBlock Text="{Binding Path=Label, Mode=OneWay}" Style="{StaticResource SensorText}" />
<ProgressBar Value="{Binding Path=Value, Mode=OneWay}" Margin="0,4" Width="{Binding Source={x:Static prop:Settings.Default}, Path=FontSetting.BarWidthWide, Mode=OneWay}" Style="{StaticResource DriveProgress}" />
</StackPanel>
</Grid>
</Setter.Value>
</Setter>
</MultiDataTrigger>
<DataTrigger Binding="{Binding ShowDetails, Mode=OneWay}" Value="True">
<Setter Property="Content">
<Setter.Value>
Expand Down

0 comments on commit c478daa

Please sign in to comment.