Skip to content

Commit

Permalink
Added double-click ColorZone to set optimal width
Browse files Browse the repository at this point in the history
  • Loading branch information
Timthreetwelve committed Sep 12, 2022
1 parent 521e939 commit 9e5ab57
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 132 deletions.
228 changes: 96 additions & 132 deletions HWiNFOVSBViewer/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,35 @@
<Window
x:Class="HWiNFOVSBViewer.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:local="clr-namespace:HWiNFOVSBViewer"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
Width="800"
Height="450"
MinWidth="300"
MinHeight="300"
Background="{DynamicResource MaterialDesignPaper}"
Closing="Window_Closing"
FontSize="14"
KeyDown="Window_KeyDown"
MouseWheel="Window_MouseWheel"
Style="{StaticResource MaterialDesignWindow}"
TextElement.FontWeight="Regular"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
mc:Ignorable="d">
<Window x:Class="HWiNFOVSBViewer.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:local="clr-namespace:HWiNFOVSBViewer"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" Title="MainWindow"
Width="800" Height="450"
MinWidth="300" MinHeight="300"
Background="{DynamicResource MaterialDesignPaper}"
Closing="Window_Closing" FontSize="14"
KeyDown="Window_KeyDown"
MouseWheel="Window_MouseWheel"
Style="{StaticResource MaterialDesignWindow}"
TextElement.FontWeight="Regular"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto">
<!--#region Window resources-->
<Window.Resources>
<Style
BasedOn="{StaticResource {x:Type materialDesign:SnackbarMessage}}"
TargetType="{x:Type materialDesign:SnackbarMessage}">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Style TargetType="{x:Type materialDesign:SnackbarMessage}"
BasedOn="{StaticResource {x:Type materialDesign:SnackbarMessage}}">
<Setter Property="FontSize" Value="30" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
</Window.Resources>
<!--#endregion-->

<materialDesign:DialogHost
CloseOnClickAway="True"
DialogTheme="Inherit"
Identifier="MainDialogHost">
<materialDesign:DialogHost CloseOnClickAway="True"
DialogTheme="Inherit"
Identifier="MainDialogHost">
<Grid x:Name="MainGrid">
<!--#region Row definitions-->
<Grid.RowDefinitions>
Expand All @@ -46,143 +39,116 @@
<!--#endregion-->


<materialDesign:DrawerHost
x:Name="NavDrawer"
Grid.Row="1"
LeftDrawerBackground="{DynamicResource MaterialDesignPaper}">
<materialDesign:DrawerHost x:Name="NavDrawer"
Grid.Row="1"
LeftDrawerBackground="{DynamicResource MaterialDesignPaper}">

<!--#region Navigation Drawer Content-->
<materialDesign:DrawerHost.LeftDrawerContent>
<ListBox
x:Name="NavListBox"
Width="200"
Margin="0,16,0,16"
HorizontalAlignment="Left"
FontSize="16"
SelectionChanged="NavListBox_SelectionChanged"
Style="{StaticResource MaterialDesignNavigationPrimaryListBox}">
<ListBox x:Name="NavListBox"
Width="200" Margin="0,16,0,16"
HorizontalAlignment="Left" FontSize="16"
SelectionChanged="NavListBox_SelectionChanged"
Style="{StaticResource MaterialDesignNavigationPrimaryListBox}">
<ListBoxItem>
<ListBoxItem.Content>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon
Width="24"
Height="24"
Kind="Binoculars" />
<TextBlock
Margin="10,0"
VerticalAlignment="Center"
Text="Viewer" />
<materialDesign:PackIcon Width="24" Height="24"
Kind="Binoculars" />
<TextBlock Margin="10,0" VerticalAlignment="Center"
Text="Viewer" />
</StackPanel>
</ListBoxItem.Content>
</ListBoxItem>
<ListBoxItem>
<ListBoxItem.Content>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon
Width="24"
Height="24"
Kind="Cog" />
<TextBlock
Margin="10,0"
VerticalAlignment="Center"
Text="Settings" />
<materialDesign:PackIcon Width="24" Height="24"
Kind="Cog" />
<TextBlock Margin="10,0" VerticalAlignment="Center"
Text="Settings" />
</StackPanel>
</ListBoxItem.Content>
</ListBoxItem>
<ListBoxItem>
<ListBoxItem.Content>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon
Width="24"
Height="24"
Kind="AboutOutline" />
<TextBlock
Margin="10,0"
VerticalAlignment="Center"
Text="About" />
<materialDesign:PackIcon Width="24" Height="24"
Kind="AboutOutline" />
<TextBlock Margin="10,0" VerticalAlignment="Center"
Text="About" />
</StackPanel>
</ListBoxItem.Content>
</ListBoxItem>
<ListBoxItem>
<ListBoxItem.Content>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon
Width="24"
Height="24"
Kind="ExitRun" />
<TextBlock
Margin="10,0"
VerticalAlignment="Center"
Text="Exit" />
<materialDesign:PackIcon Width="24" Height="24"
Kind="ExitRun" />
<TextBlock Margin="10,0" VerticalAlignment="Center"
Text="Exit" />
</StackPanel>
</ListBoxItem.Content>
</ListBoxItem>
<ListBox.Resources>
<Style
BasedOn="{StaticResource MaterialDesignScrollBarMinimal}"
TargetType="ScrollBar" />
<Style TargetType="ScrollBar"
BasedOn="{StaticResource MaterialDesignScrollBarMinimal}" />
</ListBox.Resources>
</ListBox>
</materialDesign:DrawerHost.LeftDrawerContent>
<!--#endregion-->

<!--#region Frame-->
<Frame
x:Name="MainFrame"
Grid.Row="1"
NavigationUIVisibility="Hidden" />
<Frame x:Name="MainFrame"
Grid.Row="1"
NavigationUIVisibility="Hidden" />
<!--#endregion-->

</materialDesign:DrawerHost>

<!--#region ColorZone-->
<DockPanel LastChildFill="True">
<materialDesign:ColorZone
Height="33"
Margin="10"
Padding="0,0,0,3"
materialDesign:ShadowAssist.ShadowDepth="Depth2"
CornerRadius="4"
Mode="PrimaryMid">
<materialDesign:ColorZone Height="33" Margin="10"
Padding="0,0,0,3"
materialDesign:ShadowAssist.ShadowDepth="Depth2"
CornerRadius="4" Mode="PrimaryMid"
MouseDoubleClick="ColorZone_MouseDoubleClick">
<Grid>
<StackPanel Orientation="Horizontal">
<ToggleButton
Width="30"
Height="30"
Margin="5,2"
IsChecked="{Binding IsLeftDrawerOpen, ElementName=NavDrawer}"
Style="{DynamicResource MaterialDesignHamburgerToggleButton}"
ToolTip="Click to navigate" />
<ToggleButton Width="30" Height="30"
Margin="5,2"
IsChecked="{Binding IsLeftDrawerOpen,
ElementName=NavDrawer}"
Style="{DynamicResource MaterialDesignHamburgerToggleButton}"
ToolTip="Click to navigate" />

<TextBlock
x:Name="PageTitle"
Margin="6,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="20"
FontWeight="DemiBold"
Text="Cool Title" />
<TextBlock x:Name="PageTitle"
Margin="6,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center" FontSize="20"
FontWeight="DemiBold" Text="Cool Title" />

</StackPanel>

<materialDesign:PopupBox
Margin="10,4,0,0"
HorizontalAlignment="Right"
PlacementMode="LeftAndAlignTopEdges">
<Grid
Width="150"
Margin="0">
<StackPanel Orientation="Vertical">
<Button
Click="BtnLog_Click"
Content="View Log File"
Style="{StaticResource MaterialDesignFlatLightButton}" />
<Button
Click="BtnReadme_Click"
Content="View ReadMe"
Style="{StaticResource MaterialDesignFlatLightButton}" />
</StackPanel>
</Grid>
<materialDesign:PopupBox Margin="10,4,0,0" Padding="0"
HorizontalAlignment="Right"
PlacementMode="LeftAndAlignTopEdges">
<Border Padding="3"
BorderBrush="{DynamicResource PrimaryHueMidBrush}"
BorderThickness="2">
<Grid Width="150" Margin="0">
<StackPanel Orientation="Vertical">
<Button Click="BtnLog_Click"
Content="View Log File" />
<Button Click="BtnReadme_Click"
Content="View ReadMe" />
<Separator Margin="0" Padding="1"
Background="{DynamicResource PrimaryHueMidBrush}" />
<Button HorizontalContentAlignment="Left"
Content="Cancel" FontSize="14" />
</StackPanel>
</Grid>
</Border>
</materialDesign:PopupBox>

</Grid>
Expand All @@ -191,15 +157,13 @@
<!--#endregion-->

<!--#region SnackBar-->
<materialDesign:Snackbar
x:Name="SnackBar1"
Grid.Row="1"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
Background="#FF202020"
FontWeight="DemiBold"
Foreground="White"
MessageQueue="{materialDesign:MessageQueue}" />
<materialDesign:Snackbar x:Name="SnackBar1"
Grid.Row="1"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
Background="#FF202020"
FontWeight="DemiBold" Foreground="White"
MessageQueue="{materialDesign:MessageQueue}" />
<!--#endregion-->
</Grid>
</materialDesign:DialogHost>
Expand Down
16 changes: 16 additions & 0 deletions HWiNFOVSBViewer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,4 +475,20 @@ private static void CurrentDomain_UnhandledException(object sender, UnhandledExc
// "DailyDocuments Error", ButtonType.Ok).ShowDialog();
}
#endregion Unhandled Exception Handler

#region Double click ColorZone
/// <summary>
/// Double click the ColorZone to set optimal width
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ColorZone_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
SizeToContent = SizeToContent.Width;
double width = ActualWidth;
Thread.Sleep(50);
SizeToContent = SizeToContent.Manual;
Width = width + 1;
}
#endregion Double click ColorZone
}

0 comments on commit 9e5ab57

Please sign in to comment.