SlunkCrypt/gui/SlunkCryptGUI.xaml

188 lines
17 KiB
Plaintext
Raw Permalink Normal View History

<Window x:Class="com.muldersoft.slunkcrypt.gui.SlunkCryptGUI"
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:local="clr-namespace:com.muldersoft.slunkcrypt.gui"
xmlns:utils="clr-namespace:com.muldersoft.slunkcrypt.gui.utils"
xmlns:ctrls="clr-namespace:com.muldersoft.slunkcrypt.gui.ctrls"
mc:Ignorable="d"
Title="SlunkCrypt GUI"
Icon="pack://application:,,,/slunkcrypt-gui;component/Resources/Application.ico"
SizeToContent="WidthAndHeight"
WindowStartupLocation="CenterScreen"
ResizeMode="NoResize"
WindowStyle="ThreeDBorderWindow"
UseLayoutRounding="True"
AllowDrop="True"
Loaded="Window_Loaded" Closing="Window_Closing"
PreviewDragEnter="Window_PreviewDragEnter" PreviewDragOver="Window_PreviewDragEnter" PreviewDragLeave="Window_PreviewDragLeave" PreviewDrop="Window_PreviewDrop"
PreviewKeyDown="Window_PreviewKeyDown">
<Window.Resources>
<BitmapImage x:Key="ImageSource_Banner" UriSource="Resources/Banner.png"/>
<BitmapImage x:Key="ImageSource_Browse" UriSource="Resources/Browse.png"/>
<BitmapImage x:Key="ImageSource_Cancel" UriSource="Resources/Cancel.png"/>
<BitmapImage x:Key="ImageSource_Exit" UriSource="Resources/Exit.png"/>
<BitmapImage x:Key="ImageSource_Eye1" UriSource="Resources/Eye_1.png"/>
<BitmapImage x:Key="ImageSource_Eye2" UriSource="Resources/Eye_2.png"/>
<BitmapImage x:Key="ImageSource_Info" UriSource="Resources/Info.png"/>
<BitmapImage x:Key="ImageSource_Die" UriSource="Resources/Die.png"/>
<BitmapImage x:Key="ImageSource_Start" UriSource="Resources/Start.png"/>
<BitmapImage x:Key="ImageSource_TabHd1" UriSource="Resources/Tab_Encrypt.png"/>
<BitmapImage x:Key="ImageSource_TabHd2" UriSource="Resources/Tab_Decrypt.png"/>
<BitmapImage x:Key="ImageSource_TabHd3" UriSource="Resources/Tab_LogFile.png"/>
<FontFamily x:Key="Monospace">pack://application:,,,/Resources/Fonts/#Hack</FontFamily>
<utils:FontSizeConverter x:Key="SlightlySmallFont" Ratio="0.875"/>
<utils:FontSizeConverter x:Key="SlightlyLargerFont" Ratio="1.125"/>
<utils:VisibilityConverter x:Key="VisibilityConverter" Collapse="False"/>
</Window.Resources>
<Window.TaskbarItemInfo>
<TaskbarItemInfo/>
</Window.TaskbarItemInfo>
<StackPanel Style="{StaticResource WaitCursorWhileBusy}" Background="Transparent">
<Grid>
<Image Source="{StaticResource ImageSource_Banner}" Stretch="None" MouseLeftButtonDown="Image_MouseLeftButtonDown" Name="Banner"/>
<Canvas x:Name="Canvas" IsHitTestVisible="False" Visibility="{Binding IsBusyIndicatorVisible, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}, Converter={StaticResource VisibilityConverter}}" Opacity="0.8"/>
</Grid>
<Separator Margin="0"/>
<StackPanel>
<StackPanel Margin="12,16,12,12">
<TextBlock FontWeight="SemiBold" Text="Process has not been started yet. Please click the &quot;Start&quot; button to begin!" FontSize="{Binding FontSize, Converter={StaticResource SlightlyLargerFont}, RelativeSource={RelativeSource FindAncestor, AncestorType=Control}}" Margin="0,0,0,5" Name="Label_Status"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<ProgressBar Grid.Column="0" Height="25" Name="ProgressBar" Value="0.0" Maximum="1.0"/>
<TextBlock Grid.Column="0" Text="" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" Name="Label_Progress"/>
<Button Grid.Column="1" Style="{StaticResource EnableWhileBusy}" Margin="2,0,0,0" Click="Button_AbortProcess_Click" Name="Button_Abort" ToolTip="Abort!" Focusable="False" IsTabStop="False">
<Image Source="{StaticResource ImageSource_Cancel}" Margin="4,0,4,0" Style="{StaticResource GrayOutIfDisabled}"/>
</Button>
</Grid>
<TabControl x:Name="TabControl" Margin="0,18,0,0" Style="{StaticResource HitInvisibleWhileBusy}" SelectionChanged="TabControl_SelectionChanged">
<TabItem Name="TabItem_Encrypt" Tag="{x:Static local:ModeOfOperation.Encrypt}">
<TabItem.Header>
<StackPanel Orientation="Horizontal" Margin="10,0,10,0">
<Image Source="{StaticResource ImageSource_TabHd1}" Stretch="None"/>
<TextBlock Text="Encrypt" FontWeight="Bold" Style="{StaticResource HighlightIfSelected}" Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</StackPanel>
</TabItem.Header>
<StackPanel Margin="12,4,12,12">
<TextBlock FontWeight="SemiBold" Text="Input Plaintext File:" Margin="0,10,0,0"/>
<DockPanel Margin="0,5,0,0">
<Button DockPanel.Dock="Right" Padding="7,0,7,0" Margin="3,0,0,0" Click="Button_Encrypt_InputFile_Click">
<StackPanel Orientation="Horizontal">
<Image Source="{StaticResource ImageSource_Browse}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,3,0" Style="{StaticResource GrayOutIfDisabled}" Stretch="None"/>
<TextBlock Text="Browse..." VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center"/>
</StackPanel>
</Button>
<TextBox DockPanel.Dock="Left" Padding="3" Name="Edit_Encrypt_InputFile" Tag="{Binding ElementName=Edit_Encrypt_OutputFile}" KeyDown="Edit_FileName_KeyDown" LostFocus="Edit_FileName_LostFocus" MaxLength="{x:Static local:SlunkCryptGUI.MAX_PATH}"/>
</DockPanel>
<TextBlock FontWeight="SemiBold" Text="Output Ciphertext File:" Margin="0,10,0,0"/>
<DockPanel Margin="0,5,0,0">
<Button DockPanel.Dock="Right" Padding="7,0,7,0" Margin="3,0,0,0" Click="Button_Encrypt_OutputFile_Click">
<StackPanel Orientation="Horizontal">
<Image Source="{StaticResource ImageSource_Browse}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,3,0" Style="{StaticResource GrayOutIfDisabled}" Stretch="None"/>
<TextBlock Text="Browse..." VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center"/>
</StackPanel>
</Button>
<TextBox DockPanel.Dock="Left" Padding="3" Name="Edit_Encrypt_OutputFile" Tag="{Binding ElementName=Edit_Encrypt_Password}" KeyDown="Edit_FileName_KeyDown" LostFocus="Edit_FileName_LostFocus" MaxLength="{x:Static local:SlunkCryptGUI.MAX_PATH}"/>
</DockPanel>
<TextBlock FontWeight="SemiBold" Text="Passphrase:" Margin="0,10,0,0"/>
<DockPanel Margin="0,5,0,0">
<ctrls:ImageToggleButton DockPanel.Dock="Right" Margin="3,0,0,0" x:Name="Button_Encrypt_Toggle" ImageSourceDefault="{StaticResource ImageSource_Eye1}" ImageSourceChecked="{StaticResource ImageSource_Eye2}" ToolTipDefault="Show password" ToolTipChecked="Hide password"/>
<ctrls:ImageButton DockPanel.Dock="Right" Margin="3,0,0,0" Clicked="Button_GeneratePasswd_Click" ImageSource="{StaticResource ImageSource_Die}" ButtonToolTip="Generate random password"/>
<ctrls:PasswordToggleBox DockPanel.Dock="Left" EditPadding="3,5,3,5" x:Name="Edit_Encrypt_Password" EditFontFamily="{StaticResource Monospace}" IsRevealed="{Binding IsChecked, ElementName=Button_Encrypt_Toggle}" PasswordChar="*" MaxLength="{x:Static local:SlunkCryptGUI.MAX_PASSWD_LENGTH}" Entered="Edit_Password_Entered"/>
</DockPanel>
</StackPanel>
</TabItem>
<TabItem Name="TabItem_Decrypt" Tag="{x:Static local:ModeOfOperation.Decrypt}">
<TabItem.Header>
<StackPanel Orientation="Horizontal" Margin="10,0,10,0">
<Image Source="{StaticResource ImageSource_TabHd2}" Stretch="None"/>
<TextBlock Text="Decrypt" FontWeight="Bold" Style="{StaticResource HighlightIfSelected}" Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</StackPanel>
</TabItem.Header>
<StackPanel Margin="12,4,12,12">
<TextBlock FontWeight="SemiBold" Text="Input Ciphertext File:" Margin="0,10,0,0"/>
<DockPanel Margin="0,5,0,0">
<Button DockPanel.Dock="Right" Padding="7,0,7,0" Margin="3,0,0,0" Click="Button_Decrypt_InputFile_Click">
<StackPanel Orientation="Horizontal">
<Image Source="{StaticResource ImageSource_Browse}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,3,0" Style="{StaticResource GrayOutIfDisabled}" Stretch="None"/>
<TextBlock Text="Browse..." VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center"/>
</StackPanel>
</Button>
<TextBox DockPanel.Dock="Left" Padding="3" Name="Edit_Decrypt_InputFile" Tag="{Binding ElementName=Edit_Decrypt_OutputFile}" KeyDown="Edit_FileName_KeyDown" LostFocus="Edit_FileName_LostFocus" MaxLength="{x:Static local:SlunkCryptGUI.MAX_PATH}"/>
</DockPanel>
<TextBlock FontWeight="SemiBold" Text="Output Plaintext File:" Margin="0,10,0,0"/>
<DockPanel Margin="0,5,0,0">
<Button DockPanel.Dock="Right" Padding="7,0,7,0" Margin="3,0,0,0" Click="Button_Decrypt_OutputFile_Click">
<StackPanel Orientation="Horizontal">
<Image Source="{StaticResource ImageSource_Browse}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,3,0" Style="{StaticResource GrayOutIfDisabled}" Stretch="None"/>
<TextBlock Text="Browse..." VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center"/>
</StackPanel>
</Button>
<TextBox DockPanel.Dock="Left" Padding="3" Name="Edit_Decrypt_OutputFile" Tag="{Binding ElementName=Edit_Decrypt_Password}" KeyDown="Edit_FileName_KeyDown" LostFocus="Edit_FileName_LostFocus" MaxLength="{x:Static local:SlunkCryptGUI.MAX_PATH}"/>
</DockPanel>
<TextBlock FontWeight="SemiBold" Text="Passphrase:" Margin="0,10,0,0"/>
<DockPanel Margin="0,5,0,0">
<ctrls:ImageToggleButton DockPanel.Dock="Right" Margin="3,0,0,0" x:Name="Button_Decrypt_Toggle" ImageSourceDefault="{StaticResource ImageSource_Eye1}" ImageSourceChecked="{StaticResource ImageSource_Eye2}" ToolTipDefault="Show password" ToolTipChecked="Hide password"/>
<ctrls:PasswordToggleBox DockPanel.Dock="Left" EditPadding="3,5,3,5" x:Name="Edit_Decrypt_Password" EditFontFamily="{StaticResource Monospace}" IsRevealed="{Binding IsChecked, ElementName=Button_Decrypt_Toggle}" PasswordChar="*" MaxLength="{x:Static local:SlunkCryptGUI.MAX_PASSWD_LENGTH}" Entered="Edit_Password_Entered"/>
</DockPanel>
</StackPanel>
</TabItem>
<TabItem Name="TabItem_LogFile">
<TabItem.Header>
<StackPanel Orientation="Horizontal" Margin="10,0,10,0">
<Image Source="{StaticResource ImageSource_TabHd3}" Stretch="None"/>
<TextBlock Text="Logfile" FontWeight="Bold" Style="{StaticResource HighlightIfSelected}" Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</StackPanel>
</TabItem.Header>
<DockPanel Margin="12">
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal">
<ctrls:Hyperlink LinkText="Copy to Clipboard" Margin="0,3,0,0" Click="Link_CopyToClipboard_Click"/>
<ctrls:Hyperlink LinkText="Clear" Margin="7,3,0,0" Click="Link_ClearLog_Click"/>
</StackPanel>
<Grid>
<ListView DockPanel.Dock="Top" VerticalAlignment="Stretch" FontFamily="Courier New" FontSize="{Binding FontSize, Converter={StaticResource SlightlySmallFont}, RelativeSource={RelativeSource FindAncestor, AncestorType=Control}}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding LogFile, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}" ItemContainerStyle="{StaticResource ItemToolTips}"/>
<TextBlock Text="The log file is empty. Please check back later!" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" Foreground="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" DataContext="{Binding LogFile, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}" Style="{StaticResource HideIfNotEmpty}"/>
</Grid>
</DockPanel>
</TabItem>
</TabControl>
</StackPanel>
<Separator Margin="0,5,0,5"/>
<Grid Name="Grid_ButtonBar" Margin="12" Style="{StaticResource DisableWhileBusy}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Padding="25,4,25,4" Name="Button_Start" MinWidth="125" Click="Button_Start_Click">
<StackPanel Orientation="Horizontal">
<Image Source="{StaticResource ImageSource_Start}" Margin="0,0,5,0" Style="{StaticResource GrayOutIfDisabled}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock FontWeight="Bold" Text="Start" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center"/>
</StackPanel>
</Button>
<Button Grid.Column="2" Padding="25,4,25,4" Name="Button_About" Margin="10,0,0,0" MinWidth="125" Click="Button_About_Click">
<StackPanel Orientation="Horizontal">
<Image Source="{StaticResource ImageSource_Info}" Margin="0,0,5,0" Style="{StaticResource GrayOutIfDisabled}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock FontWeight="Bold" Text="About..." VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center"/>
</StackPanel>
</Button>
<Button Grid.Column="4" Padding="25,4,25,4" Name="Button_Exit" MinWidth="125" Click="Button_Exit_Click">
<StackPanel Orientation="Horizontal">
<Image Source="{StaticResource ImageSource_Exit}" Margin="0,0,5,0" Style="{StaticResource GrayOutIfDisabled}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock FontWeight="Bold" Text="Exit" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center"/>
</StackPanel>
</Button>
</Grid>
</StackPanel>
</StackPanel>
</Window>