Skip to content

Commit

Permalink
Improve main window design + XAML refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
hirschmann committed Nov 17, 2015
1 parent 1365c75 commit a8468b0
Showing 1 changed file with 158 additions and 125 deletions.
283 changes: 158 additions & 125 deletions Windows/NbfcClient/Windows/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,139 +1,168 @@
<Window x:Class="NbfcClient.Windows.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:vm="clr-namespace:NbfcClient.ViewModels"
xmlns:uc="clr-namespace:NbfcClient.UserControls"
mc:Ignorable="d"
<Window
x:Class="NbfcClient.Windows.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:vm="clr-namespace:NbfcClient.ViewModels"
xmlns:uc="clr-namespace:NbfcClient.UserControls"
mc:Ignorable="d"

Title="NoteBook FanControl"
Height="345"
Width="390"
MinWidth="350"
MinHeight="200"
Foreground="#FF2E2E2E"
Icon="/NoteBookFanControl;component/fan.ico"
WindowStartupLocation="CenterScreen"
StateChanged="window_StateChanged"
Closing="Window_Closing"
d:DataContext="{d:DesignData Source=../DesignData/MainWindowViewModelData.xaml}">
Title="NoteBook FanControl"
Height="345"
Width="390"
MinWidth="350"
MinHeight="200"
Foreground="#FF2E2E2E"
Icon="/NoteBookFanControl;component/fan.ico"
WindowStartupLocation="CenterScreen"
StateChanged="window_StateChanged"
Closing="Window_Closing"
d:DataContext="{d:DesignData Source=../DesignData/MainWindowViewModelData.xaml}">

<Window.Resources>
<SolidColorBrush x:Key="HeaderBrush" Color="#FF191919"/>
<SolidColorBrush x:Key="BorderBrush" Color="#FF999999"/>
</Window.Resources>

<Grid>
<!--Background-->
<Grid.Background>
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ControlColorKey}}"/>
</Grid.Background>

<Rectangle Fill="White"
Margin="0,38,0,0"/>
<Border
BorderBrush="{DynamicResource BorderBrush}"
BorderThickness="0,1"
Height="38"
VerticalAlignment="Top" />

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

<!--Config selector-->
<DockPanel Margin="0,0,38,0"
Height="38"
VerticalAlignment="Top">

<TextBlock Text="Selected config:"
DockPanel.Dock="Left"
VerticalAlignment="Center"
FontWeight="Bold"
Margin="10,0,6,0"/>

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

<TextBlock
Text="Selected config:"
DockPanel.Dock="Left"
VerticalAlignment="Center"
Margin="10,0,6,0"
Foreground="{StaticResource HeaderBrush}"/>

<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"/>
<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,38,10,0"
VerticalAlignment="Top"
Foreground="{DynamicResource {x:Static SystemColors.ScrollBarBrushKey}}"
HorizontalAlignment="Right"
FontFamily="Segoe UI Light"/>
<Label
Content="{Binding Version}"
Margin="0,43,10,0"
VerticalAlignment="Top"
Foreground="{StaticResource BorderBrush}"
HorizontalAlignment="Right"
FontFamily="Segoe UI Light"/>

<!--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">
<TextBlock
x:Name="wbcd"
Margin="0,66,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}">
<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"/>
<TextBlock
Text="Fan control service status:"
HorizontalAlignment="Left"
Margin="18,48,0,0"
VerticalAlignment="Top"
FontWeight="Medium"
Foreground="{StaticResource HeaderBrush}"/>

<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
Orientation="Horizontal"
Height="18"
Margin="18,98,48,0"
VerticalAlignment="Top">

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

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

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

<ItemsControl ItemsSource="{Binding}">
<ItemsControl ItemsSource="{Binding}" Foreground="{StaticResource HeaderBrush}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0,5,10,5">
Expand All @@ -145,35 +174,39 @@
</ScrollViewer>

<!--Settings-->
<Button x:Name="settings"
Margin="0,0,10,10"
VerticalAlignment="Bottom"
Height="20"
HorizontalAlignment="Right"
Width="20"
Click="settings_Click"
Padding="2"
ToolTip="Settings">
<Button
x:Name="settings"
Margin="0,0,10,10"
VerticalAlignment="Bottom"
Height="20"
HorizontalAlignment="Right"
Width="20"
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">
<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">

<Hyperlink NavigateUri="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=HUALCC9HY9MKC"
RequestNavigate="donationLink_RequestNavigate">
<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 :)
</Hyperlink>
</TextBlock>

<!--Notify icon-->
<tb:TaskbarIcon x:Name="notifyIcon"
IconSource="/NoteBookFanControl;component/fan.ico"
TrayLeftMouseDown="notifyIcon_TrayLeftMouseDown">
<tb:TaskbarIcon
x:Name="notifyIcon"
IconSource="/NoteBookFanControl;component/fan.ico"
TrayLeftMouseDown="notifyIcon_TrayLeftMouseDown">

<tb:TaskbarIcon.ContextMenu>
<ContextMenu>
Expand Down

0 comments on commit a8468b0

Please sign in to comment.