Skip to content

Commit

Permalink
Merge branch 'chg/improve-winclient-ui' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
hirschmann committed Oct 14, 2015
2 parents 5b8f6f2 + 8224a7e commit 9dcf7a4
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 69 deletions.
1 change: 1 addition & 0 deletions Windows/NbfcClient/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<vc:TargetFanSpeedToTextConverter x:Key="fanSpeedConverter"/>
<vc:FanDisplayNameToTextConverter x:Key="displayNameConverter"/>
<vc:TemperatureToTextConverter x:Key="temperatureConverter"/>
<vc:BooleanToInverseConverter x:Key="boolToInverse"/>

<DrawingImage x:Key="settings">
<DrawingImage.Drawing>
Expand Down
2 changes: 1 addition & 1 deletion Windows/NbfcClient/DesignData/MainWindowViewModelData.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns:dd="clr-namespace:NbfcClient.DesignData"

Temperature="50"
TemperatureSourceName="CPU"
TemperatureSourceName="CPU/HDD"
IsServiceAvailable="True"
SelectedConfig="HP ProBook 6465b"
Version="1.1.11"/>
Expand Down
1 change: 1 addition & 0 deletions Windows/NbfcClient/NbfcClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<Compile Include="UserControls\TrayToolTip.xaml.cs">
<DependentUpon>TrayToolTip.xaml</DependentUpon>
</Compile>
<Compile Include="ValueConverters\BooleanToInverseConverter.cs" />
<Compile Include="ValueConverters\FanDisplayNameToTextConverter.cs" />
<Compile Include="ValueConverters\FanSpeedSliderValueToTextConverter.cs" />
<Compile Include="ValueConverters\TargetFanSpeedToTextConverter.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Windows/NbfcClient/UserControls/FanController.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
d:DesignWidth="343"
d:DataContext="{d:DesignData Source=../DesignData/FanControllerViewModelData.xaml}">

<GroupBox Background="{Binding}" FontWeight="Bold">
<GroupBox Background="{Binding}" FontWeight="SemiBold">
<GroupBox.Header>
<MultiBinding Converter="{StaticResource displayNameConverter}">
<Binding Path="FanDisplayName"/>
Expand Down
19 changes: 19 additions & 0 deletions Windows/NbfcClient/ValueConverters/BooleanToInverseConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Windows.Data;

namespace NbfcClient.ValueConverters
{
[ValueConversion(typeof(bool), typeof(bool))]
public class BooleanToInverseConverter:IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return !(bool)value;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return Convert(value, targetType, parameter, culture);
}
}
}
164 changes: 100 additions & 64 deletions Windows/NbfcClient/Windows/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
mc:Ignorable="d"

Title="NoteBook FanControl"
Height="350"
Width="430"
Height="345"
Width="390"
MinWidth="350"
MinHeight="355"
MinHeight="200"
Foreground="#FF2E2E2E"
Icon="/NoteBookFanControl;component/fan.ico"
WindowStartupLocation="CenterScreen"
StateChanged="window_StateChanged"
Expand All @@ -25,68 +26,113 @@
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ControlColorKey}}"/>
</Grid.Background>

<Rectangle Fill="White" Margin="0,40,0,0"/>
<Rectangle Fill="White"
Margin="0,38,0,0"/>

<!--Config selector-->
<Button x:Name="selectConfig"
Content="..."
Margin="0,7,10,0"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Width="30"
Height="23"
Click="selectConfig_Click"
ToolTip="Select a config"/>
<DockPanel Margin="0,0,38,0"
Height="38"
VerticalAlignment="Top">

<Label Content="Selected config:"
HorizontalAlignment="Left"
Margin="3,4,0,0"
VerticalAlignment="Top"
FontWeight="Bold"/>
<TextBlock Text="Selected config:"
DockPanel.Dock="Left"
VerticalAlignment="Center"
FontWeight="Bold"
Margin="10,0,6,0"/>

<TextBox Text="{Binding SelectedConfig}"
Height="23"
Margin="121,7,55,0"
TextWrapping="Wrap"
VerticalAlignment="Top"
IsReadOnly="True"/>
<TextBox Text="{Binding SelectedConfig}"
Height="23"
TextWrapping="Wrap"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsReadOnly="True"
VerticalContentAlignment="Center" />
</DockPanel>

<Button x:Name="selectConfig"
Content="..."
VerticalAlignment="Top"
Width="23"
Height="23"
Click="selectConfig_Click"
ToolTip="Select a config"
DockPanel.Dock="Left"
VerticalContentAlignment="Center"
Margin="0,8,10,0" HorizontalAlignment="Right"/>

<!--Version-->
<Label Content="{Binding Version}"
Margin="0,43,8,0"
Margin="0,38,10,0"
VerticalAlignment="Top"
Foreground="{DynamicResource {x:Static SystemColors.ScrollBarBrushKey}}"
HorizontalAlignment="Right"
FontFamily="Segoe UI Light"/>

<!--Service info-->
<CheckBox Content=" :Fan control service enabled"
HorizontalAlignment="Left"
Margin="12,53,0,0"
VerticalAlignment="Top"
FlowDirection="RightToLeft"
IsChecked="{Binding IsServiceAvailable}"
Click="CheckBox_Click">
<CheckBox.Resources>
<Style TargetType="{x:Type Path}">
<Setter Property="FlowDirection" Value="LeftToRight"/>
</Style>
</CheckBox.Resources>
</CheckBox>

<Label HorizontalAlignment="Left" Margin="8,77,0,0" VerticalAlignment="Top">
<Label.Content>
<MultiBinding Converter="{StaticResource temperatureConverter}">
<Binding Path="Temperature"/>
<Binding Path="TemperatureSourceName"/>
</MultiBinding>
</Label.Content>
</Label>
<!--World Blood Cancer Day Link-->
<TextBlock x:Name="wbcd"
Margin="0,62,14,0"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Foreground="Red"
FontSize="18"
ToolTip="#wbcd - World Blood Cancer Day (28/05)" FontWeight="SemiBold">

<Hyperlink NavigateUri="https://twitter.com/hashtag/wbcd"
RequestNavigate="wbcd_RequestNavigate"
Foreground="Red" TextDecorations="{x:Null}">
&amp;
</Hyperlink>
</TextBlock>

<!--Service status-->
<TextBlock Text="Fan control service status:"
HorizontalAlignment="Left"
Margin="18,48,0,0"
VerticalAlignment="Top"
FontWeight="SemiBold"/>

<StackPanel Orientation="Horizontal"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Margin="26,69,48,0"
Height="18">

<RadioButton Content="Disabled"
HorizontalAlignment="Left"
VerticalAlignment="Top"
IsChecked="{Binding IsServiceAvailable, Mode=OneWay, Converter={StaticResource boolToInverse}}"
Margin="0,0,7,0"
Click="FanControlEnabled_StateChanged"/>

<RadioButton Content="Enabled"
HorizontalAlignment="Left"
VerticalAlignment="Top"
IsChecked="{Binding IsServiceAvailable}"
Click="FanControlEnabled_StateChanged"/>
</StackPanel>

<!--Temperature-->
<StackPanel Orientation="Horizontal"
Height="18"
Margin="18,94,48,0"
VerticalAlignment="Top">

<TextBlock HorizontalAlignment="Left"
Text="{Binding TemperatureSourceName, StringFormat=Temperature (\{0\}):}"
VerticalAlignment="Top"
FontWeight="SemiBold"
Margin="0,0,7,0"/>

<TextBlock HorizontalAlignment="Left"
Text="{Binding Temperature, StringFormat=\{0\}°C}"
VerticalAlignment="Top"/>
</StackPanel>

<!--Fan info-->
<ScrollViewer Margin="10,117,10,45"
<ScrollViewer Margin="10,122,10,45"
DataContext="{Binding FanControllers}"
d:DataContext="{d:DesignData /DesignData/FanControllerCollection.xaml}" >
d:DataContext="{d:DesignData /DesignData/FanControllerCollection.xaml}">

<ItemsControl ItemsSource="{Binding}">
<ItemsControl.ItemTemplate>
<DataTemplate>
Expand All @@ -108,14 +154,16 @@
Click="settings_Click"
Padding="2"
ToolTip="Settings">

<Image Source="{StaticResource settings}"/>
</Button>

<!--Donation-->
<TextBlock Margin="10,0,0,14"
VerticalAlignment="Bottom"
HorizontalAlignment="Left"
ToolTip="Please click here if you want to support me with a small donation via PayPal">
ToolTip="Please click here if you want to support me with a small donation via PayPal">

<Hyperlink NavigateUri="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=HUALCC9HY9MKC"
RequestNavigate="donationLink_RequestNavigate">
If you like my work, click here to buy me a beer :)
Expand All @@ -126,6 +174,7 @@
<tb:TaskbarIcon x:Name="notifyIcon"
IconSource="/NoteBookFanControl;component/fan.ico"
TrayLeftMouseDown="notifyIcon_TrayLeftMouseDown">

<tb:TaskbarIcon.ContextMenu>
<ContextMenu>
<MenuItem Header="Close" Click="close_Click"/>
Expand All @@ -135,18 +184,5 @@
<uc:TrayToolTip />
</tb:TaskbarIcon.TrayToolTip>
</tb:TaskbarIcon>
<TextBlock x:Name="wbcd"
Margin="0,74,10,0"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Foreground="#FFFF0000"
FontSize="18"
ToolTip="#wbcd - World Blood Cancer Day (28/05)" FontWeight="SemiBold" RenderTransformOrigin="0.215,2.13">
<Hyperlink NavigateUri="https://twitter.com/hashtag/wbcd"
RequestNavigate="wbcd_RequestNavigate"
Foreground="Red" TextDecorations="{x:Null}">
&amp;
</Hyperlink>
</TextBlock>
</Grid>
</Window>
7 changes: 4 additions & 3 deletions Windows/NbfcClient/Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ private void selectConfig_Click(object sender, RoutedEventArgs e)
window.ShowDialog();
}

private void CheckBox_Click(object sender, RoutedEventArgs e)
private void FanControlEnabled_StateChanged(object sender, RoutedEventArgs e)
{
try
try
{
Mouse.OverrideCursor = Cursors.Wait;

Expand Down Expand Up @@ -299,6 +299,7 @@ public void Dispose()
GC.SuppressFinalize(this);
}

#endregion
#endregion
}

}

0 comments on commit 9dcf7a4

Please sign in to comment.