Skip to content

Instantly share code, notes, and snippets.

@macxfadz
Created February 23, 2018 10:04
Show Gist options
  • Save macxfadz/f61c9c70bd04d3c15e8e00aff597ea18 to your computer and use it in GitHub Desktop.
Save macxfadz/f61c9c70bd04d3c15e8e00aff597ea18 to your computer and use it in GitHub Desktop.
<Controls:MetroWindow
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:DatGen_FrontEnd"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:loadin="clr-namespace:LoadingIndicators.WPF;assembly=LoadingIndicators.WPF"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:System="clr-namespace:System;assembly=mscorlib" x:Name="DatGen_MainWindow" x:Class="DatGen_FrontEnd.MainWindow"
mc:Ignorable="d"
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
Background="{DynamicResource MaterialDesignPaper}"
TextElement.FontWeight="Medium"
TextElement.FontSize="14"
BorderThickness="0"
GlowBrush="LightSlateGray"
Title="DatGen_Alpha_Rel" Cursor="Hand" WindowTitleBrush="Transparent" OpacityMask="#FF1B1919" ResizeMode="CanMinimize" ShowMinButton="True" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight" d:DesignWidth="449.042" d:DesignHeight="315.163" Width="800" Height="640" Foreground="#FFB6A6A6" ShowIconOnTitleBar="True" Icon="..\zbra_logo_white.ico">
<StackPanel HorizontalAlignment="Left" Height="612" VerticalAlignment="Top" Width="800" Margin="0,0,-6,-1">
<Menu Height="35" Margin="0,0,10,0">
<MenuItem Header="File" Height="35" Width="85" Foreground="#FF53EA0B">
<MenuItem x:Name="FileMenu_Open" Header="Open" HorizontalAlignment="Left" Height="35" Width="135" Margin="0,0,-4,0" Icon="{iconPacks:PackIcon {x:Static iconPacks:PackIconMaterialKind.FolderOpen}, Height=15, Width=15}" Command="{Binding BtnCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Name}" />
<MenuItem x:Name="FileMenu_SaveAs" Header="SaveAs" HorizontalAlignment="Left" Height="35" Width="135" Icon="{iconPacks:PackIcon {x:Static iconPacks:PackIconMaterialKind.ContentSaveSettings}, Height=15, Width=15}" Command="{Binding BtnCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Name}"/>
<Separator HorizontalAlignment="Left" Width="148" Background="#FF7F7FE0"/>
<MenuItem x:Name="FileMenu_Exit" Header="Exit" HorizontalAlignment="Left" Height="35" Width="135" Icon="{iconPacks:PackIcon {x:Static iconPacks:PackIconMaterialKind.ExitToApp}, Height=15, Width=15}" Command="{Binding BtnCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Name}" />
</MenuItem>
<MenuItem x:Name="Menu_Help" Header="Help" Height="35" Width="100" Foreground="#FF65E80E">
<MenuItem x:Name="HelpMenu_About" Header="About" HorizontalAlignment="Left" Height="35" Width="135" Background="#00000000" Command="{Binding BtnCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Name}" />
</MenuItem>
</Menu>
<Separator Margin="0" OpacityMask="#FF2D3581" Background="#FF7F7FE0" Height="2" BorderBrush="DeepSkyBlue" BorderThickness="1"/>
<StackPanel Height="540" Margin="0,0,10,0">
<Grid Height="125">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="9*"/>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="382*"/>
</Grid.ColumnDefinitions>
<Label Content="DAT-Version&#xA;" HorizontalAlignment="Left" Margin="10,20,0,0" VerticalAlignment="Top" Width="96" Height="36" Foreground="DeepSkyBlue" Grid.ColumnSpan="3">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<Label Content="Number of SC&#xA;" HorizontalAlignment="Left" Margin="10,79,0,0" VerticalAlignment="Top" Width="106" Height="36" Foreground="DeepSkyBlue" Grid.ColumnSpan="3">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<Label Content="ProductID-Name&#xA;" HorizontalAlignment="Left" Margin="223,20,0,0" VerticalAlignment="Top" Width="119" Height="36" Foreground="DeepSkyBlue" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<Label Content="EcLevel&#xA;" HorizontalAlignment="Left" Margin="223,79,0,0" VerticalAlignment="Top" Width="96" Height="36" Foreground="DeepSkyBlue" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<Label Content="Packet Size&#xA;" HorizontalAlignment="Left" Margin="561,20,0,0" VerticalAlignment="Top" Width="96" Height="36" Foreground="DeepSkyBlue" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<Controls:SplitButton x:Name="SplitBtn_DatVersion" HorizontalContentAlignment="Left" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="114" Height="30" SelectedIndex="0"
ItemsSource="{Binding DATVersions}" DisplayMemberPath="" VerticalAlignment="Center" Foreground="LightSkyBlue" Margin="90,20,560,75" Grid.Column="2">
<Controls:SplitButton.ListBoxStyle>
<Style>
<Setter Property="TextBlock.Foreground" Value="DeepSkyBlue"/>
</Style>
</Controls:SplitButton.ListBoxStyle>
</Controls:SplitButton>
<TextBox Text="{Binding Path=ECLevel, Mode = TwoWay,NotifyOnTargetUpdated=True, UpdateSourceTrigger=PropertyChanged}" Style="{DynamicResource MetroButtonTextBox}" Controls:TextBoxHelper.ClearTextButton="True" x:Name="TxtBox_EcLvl" HorizontalContentAlignment="Left" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="115" Height="30"
VerticalAlignment="Center" Foreground="SkyBlue" Margin="347,79,302,16" Grid.Column="2" />
<Controls:SplitButton x:Name="SplitBtn_NoOfSc" HorizontalContentAlignment="Left" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="114" Height="30" SelectedIndex="0"
ItemsSource="{Binding NoOfSc}" DisplayMemberPath="" VerticalAlignment="Center" Foreground="SkyBlue" Margin="90,79,560,16" Grid.Column="2" >
<Controls:SplitButton.ListBoxStyle>
<Style>
<Setter Property="TextBlock.Foreground" Value="DeepSkyBlue"/>
</Style>
</Controls:SplitButton.ListBoxStyle>
</Controls:SplitButton>
<Controls:SplitButton x:Name="SplitBtn_PrdID" HorizontalContentAlignment="Left" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="191" Height="30" SelectedIndex="0"
ItemsSource="{Binding PrdIDNames}" DisplayMemberPath="" VerticalAlignment="Center" Foreground="SkyBlue" Margin="347,20,226,75" Grid.Column="2" >
<Controls:SplitButton.ListBoxStyle>
<Style>
<Setter Property="TextBlock.Foreground" Value="DeepSkyBlue"/>
</Style>
</Controls:SplitButton.ListBoxStyle>
</Controls:SplitButton>
<TextBox x:Name="TxtBox_PacketSize" Text="{Binding Path=PacketSize, Mode = TwoWay,NotifyOnTargetUpdated=True, UpdateSourceTrigger=PropertyChanged}" Style="{DynamicResource MetroButtonTextBox}" Controls:TextBoxHelper.ClearTextButton="True" HorizontalContentAlignment="Left" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="85" Height="30"
VerticalAlignment="Center" Margin="657,20,22,75" Foreground="SkyBlue" Grid.Column="2"/>
<Label Content="No&#xA;" HorizontalAlignment="Left" Margin="4,142,0,-42" VerticalAlignment="Top" Width="40" Height="25" Foreground="DeepSkyBlue" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<Label Content="Type&#xA;" HorizontalAlignment="Left" Margin="54,142,0,-42" VerticalAlignment="Top" Width="80" Height="25" Foreground="DeepSkyBlue" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<Label Content="DV-Name&#xA;" HorizontalAlignment="Left" Margin="134,142,0,-42" VerticalAlignment="Top" Width="96" Height="25" Foreground="DeepSkyBlue" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<Label Content="HC-Name&#xA;" HorizontalAlignment="Left" Margin="259,142,0,-42" VerticalAlignment="Top" Width="96" Height="25" Foreground="DeepSkyBlue" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<Label Content="SC-Name&#xA;" HorizontalAlignment="Left" Margin="389,142,0,-42" VerticalAlignment="Top" Width="96" Height="25" Foreground="DeepSkyBlue" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<TextBox Text="{Binding Path=No, Mode = OneWay, UpdateSourceTrigger=PropertyChanged}" Style="{DynamicResource MetroTextBox}" Controls:TextBoxHelper.Watermark="1" IsReadOnly="True" x:Name="TxtBox_No" HorizontalContentAlignment="Left" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="46" Height="30"
VerticalAlignment="Center" Foreground="SkyBlue" Margin="4,167,714,-72" Grid.Column="2" />
<Controls:SplitButton x:Name="SplitBtn_Type" SelectedItem="{Binding SelectedType,NotifyOnTargetUpdated=True ,UpdateSourceTrigger=PropertyChanged}" HorizontalContentAlignment="Left" Controls:TextBoxHelper.Watermark="Select" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="70" Height="30" SelectedIndex="0"
ItemsSource="{Binding Types}" DisplayMemberPath="" VerticalAlignment="Center" Foreground="LightSkyBlue" Margin="54,167,640,-72" Grid.Column="2">
<Controls:SplitButton.ListBoxStyle>
<Style>
<Setter Property="TextBlock.Foreground" Value="DeepSkyBlue"/>
</Style>
</Controls:SplitButton.ListBoxStyle>
</Controls:SplitButton>
<Controls:SplitButton x:Name="SplitBtn_DVName" SelectedItem="{Binding SelectedDVName,NotifyOnTargetUpdated=True}" Controls:TextBoxHelper.Watermark="Select" HorizontalContentAlignment="Left" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="120" Height="30" SelectedIndex="0"
ItemsSource="{Binding DVNames}" DisplayMemberPath="" VerticalAlignment="Center" Foreground="LightSkyBlue" Margin="134,167,510,-72" Grid.Column="2" >
<Controls:SplitButton.ListBoxStyle>
<Style>
<Setter Property="TextBlock.Foreground" Value="DeepSkyBlue"/>
</Style>
</Controls:SplitButton.ListBoxStyle>
</Controls:SplitButton>
<Controls:SplitButton x:Name="SplitBtn_HCName" SelectedItem="{Binding SelectedHCName,NotifyOnTargetUpdated=True}" HorizontalContentAlignment="Left" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="125" Height="30" SelectedIndex="0"
ItemsSource="{Binding HCNames}" DisplayMemberPath="" VerticalAlignment="Center" Foreground="SkyBlue" Margin="259,167,380,-72" Grid.Column="2" >
<Controls:SplitButton.ListBoxStyle>
<Style>
<Setter Property="TextBlock.Foreground" Value="DeepSkyBlue"/>
</Style>
</Controls:SplitButton.ListBoxStyle>
</Controls:SplitButton>
<Controls:SplitButton x:Name="SplitBtn_SCName" SelectedItem="{Binding SelectedSCName,NotifyOnTargetUpdated=True}" HorizontalContentAlignment="Left" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="125" Height="30" SelectedIndex="0"
ItemsSource="{Binding SCNames}" DisplayMemberPath="" VerticalAlignment="Center" Foreground="SkyBlue" Margin="389,167,250,-72" Grid.Column="2" >
<Controls:SplitButton.ListBoxStyle>
<Style>
<Setter Property="TextBlock.Foreground" Value="DeepSkyBlue"/>
</Style>
</Controls:SplitButton.ListBoxStyle>
</Controls:SplitButton>
<Label Content="SC-Release&#xA;" HorizontalAlignment="Left" Margin="514,142,0,-42" VerticalAlignment="Top" Width="100" Height="25" Foreground="DeepSkyBlue" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<TextBox x:Name="TxtBox_SCRelease" Text="{Binding Path=SCRelease, Mode = TwoWay,NotifyOnTargetUpdated=True, UpdateSourceTrigger=PropertyChanged}" Style="{DynamicResource MetroTextBox}" Controls:TextBoxHelper.Watermark="SC Release" IsReadOnly="False" HorizontalContentAlignment="Left" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="95" Height="30"
VerticalAlignment="Center" Foreground="SkyBlue" Margin="519,167,150,-72" Grid.Column="2"/>
<Label Content="DAL-Name&#xA;" HorizontalAlignment="Left" Margin="4,214,0,-114" VerticalAlignment="Top" Width="80" Height="25" Foreground="DeepSkyBlue" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<TextBox x:Name="TxtBox_DALName" Text="{Binding Path=OpenDalFilename, Mode = OneWay,NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" Style="{DynamicResource MetroTextBox}" Controls:TextBoxHelper.Watermark="Select a file" IsReadOnly="True" HorizontalContentAlignment="Left" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="254" Height="30"
VerticalAlignment="Center" Foreground="SkyBlue" Margin="139,214,371,-119" Grid.Column="2" />
<TextBox x:Name="TxtBox_SCRelName" Text="{Binding Path=SCReleaseName, Mode = OneWay, UpdateSourceTrigger=PropertyChanged}" Style="{DynamicResource MetroTextBox}" Controls:TextBoxHelper.Watermark="SC-Release Name" IsReadOnly="True" HorizontalContentAlignment="Left" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="254" Height="30"
VerticalAlignment="Center" Foreground="SkyBlue" Margin="139,258,371,-163" Grid.Column="2" />
<Label Content="SC-Release Name&#xA;" HorizontalAlignment="Left" Margin="4,258,0,-158" VerticalAlignment="Top" Width="130" Height="25" Foreground="DeepSkyBlue" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<TextBox x:Name="TxtBox_TopLvlRelName" Text="{Binding Path=TopLvlReleaseName, Mode = OneWay, UpdateSourceTrigger=PropertyChanged}" Style="{DynamicResource MetroTextBox}" Controls:TextBoxHelper.Watermark="Top Level Release Name" IsReadOnly="True" HorizontalContentAlignment="Left" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="254" Height="30"
VerticalAlignment="Center" Foreground="SkyBlue" Margin="139,300,371,-205" Grid.Column="2" />
<Label Content="TOP-Level &#xA;Release Name&#xA;" HorizontalAlignment="Left" Margin="4,288,0,-205" VerticalAlignment="Top" Width="120" Height="42" Foreground="DeepSkyBlue" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<Label Content="Ignore Signature&#xA;" HorizontalAlignment="Left" Margin="446,214,0,-119" VerticalAlignment="Top" Width="121" Height="30" Foreground="DeepSkyBlue" FontSize="14" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<Controls:ToggleSwitch x:Name="toggleSwitch_IgnoreSig" OnLabel="Y" OffLabel="N" Margin="572,210,0,-115" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="2" Height="30" Width="85">
<Controls:ToggleSwitch.IsChecked>
<Binding Path="IgnoreSignature" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" />
</Controls:ToggleSwitch.IsChecked>
</Controls:ToggleSwitch>
<Label Content="Ignore Rel String" HorizontalAlignment="Left" Margin="446,244,0,-149" VerticalAlignment="Top" Width="121" Height="30" Foreground="DeepSkyBlue" FontSize="14" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<Controls:ToggleSwitch x:Name="toggleSwitch_IgnoreRelStr" OnLabel="Y" OffLabel="N" Margin="572,240,0,-145" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="2" Height="30" Width="85">
<Controls:ToggleSwitch.IsChecked>
<Binding Path="IgnoreRelString" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" />
</Controls:ToggleSwitch.IsChecked>
</Controls:ToggleSwitch>
<Label Content="Direct DL&#xA;" HorizontalAlignment="Left" Margin="446,274,0,-179" VerticalAlignment="Top" Width="121" Height="30" Foreground="DeepSkyBlue" FontSize="14" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<Controls:ToggleSwitch x:Name="toggleSwitch_DirectDL" OnLabel="Y" OffLabel="N" Margin="572,270,0,-175" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="2" Height="30" Width="85">
<Controls:ToggleSwitch.IsChecked>
<Binding Path="DirectDL" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" />
</Controls:ToggleSwitch.IsChecked>
</Controls:ToggleSwitch>
<Label Content="Legacy_SC" HorizontalAlignment="Left" Margin="446,304,0,-209" VerticalAlignment="Top" Width="121" Height="30" Foreground="DeepSkyBlue" FontSize="14" Grid.Column="2">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
<Controls:ToggleSwitch x:Name="toggleSwitch_LegacySC" OnLabel="Y" OffLabel="N" Margin="572,300,0,-205" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="2" Height="30" Width="85">
<Controls:ToggleSwitch.IsChecked>
<Binding Path="LegacySC" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" />
</Controls:ToggleSwitch.IsChecked>
</Controls:ToggleSwitch>
<Label Content="No Type 1 2 3 4 DV-Name HC-Name SC-Name SC-Release DAL-Name&#x9;" HorizontalAlignment="Left" Margin="10,347,0,-247" VerticalAlignment="Top" Width="758" Height="25" Foreground="DeepSkyBlue" Grid.ColumnSpan="3">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="0" Opacity="1" Color="LightSkyBlue"/>
</Label.Effect>
</Label>
</Grid>
<Separator Height="14" Margin="0">
<Separator.Effect>
<BlurEffect/>
</Separator.Effect>
<Separator.Background>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FF6ECB2E" Offset="1"/>
</RadialGradientBrush>
</Separator.Background>
</Separator>
<Grid Height="400" Margin="10,0,0,0">
<Button x:Name="button_Next" ToolTip="Next" Command="{Binding BtnCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Name}" Width="55" Height="55" VerticalAlignment="Top" Style="{DynamicResource MetroCircleButtonStyle}" Margin="725,3,0,0">
<Rectangle ToolTip="Next" Width="20" Height="20" Fill="{Binding Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_navigate_next}" />
</Rectangle.OpacityMask>
</Rectangle>
</Button>
<Button x:Name="button_Previous" ToolTip="Previous" Command="{Binding BtnCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Name}" Width="55" Height="55" VerticalAlignment="Top" Style="{DynamicResource MetroCircleButtonStyle}" Margin="665,3,60,0">
<Rectangle ToolTip="Previous" Width="20" Height="20" Fill="{Binding Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_navigate_previous}" />
</Rectangle.OpacityMask>
</Rectangle>
</Button>
<TextBox x:Name="TxtBox_CommandInfo" IsReadOnly="True" Style="{DynamicResource MetroTextBox}" Controls:TextBoxHelper.Watermark="This is a textbox" HorizontalAlignment="Left" Margin="0,236,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="154" Width="780" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
<TextBox.Text>
<MultiBinding StringFormat="{}{0}{12,6}{1}{12,8}{2}{12,1}{3}{12,1}{4}{12,1}{5}{12,4}{6}{12,8}{7}{12,8}{8}{12,8}{9}{12,10}{10}&#x0a;{11}{13}" Mode="TwoWay" NotifyOnTargetUpdated="True">
<Binding Path="No" />
<Binding Path="SelectedType"/>
<Binding Path="IgnoreSignature"/>
<Binding Path="IgnoreRelString"/>
<Binding Path="DirectDL"/>
<Binding Path="LegacySC" />
<Binding Path="SelectedDVName"/>
<Binding Path="SelectedHCName"/>
<Binding Path="SelectedSCName"/>
<Binding Path="SCRelease"/>
<Binding Path="OpenDalFilename"/>
<Binding Path="PreviousLogs"/>
<Binding Path="Space" FallbackValue=" "/>
<Binding Path="CommandInfoLog" Mode="OneWayToSource"/>
</MultiBinding>
</TextBox.Text>
</TextBox>
<Button x:Name="button_DALOpen" ToolTip="Open DAL" Width="45" Height="30" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}" Margin="410,75,325,0" BorderBrush="#00000000" Background="#00000000" Command="{Binding BtnCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Name}">
<Rectangle ToolTip="Open DAL" Width="25" Height="20" Fill="{Binding Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_folder_open}" />
</Rectangle.OpacityMask>
</Rectangle>
</Button>
<Separator HorizontalAlignment="Left" Height="22" Margin="394,129,0,0" VerticalAlignment="Top" Width="126" RenderTransformOrigin="0.5,0.5" Background="#FF69A2DC">
<Separator.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="90"/>
<TranslateTransform/>
</TransformGroup>
</Separator.RenderTransform>
</Separator>
</Grid>
</StackPanel>
<StatusBar Height="35" Width="790" Background="Transparent" Foreground="SlateGray">
<Image Height="35" Width="35" Source="../Resc/Zbrafull.png"/>
<Separator />
<System:String xml:space="preserve">Loading... </System:String>
<Separator />
<Controls:MetroProgressBar Width="100" Height="15" Value="67" />
<Separator />
<loadin:LoadingIndicator Height="24" SpeedRatio="{Binding SpeedRatio}" IsActive="{Binding IsThreeDotsActive}" Style="{DynamicResource LoadingIndicatorThreeDotsStyle}"/>
</StatusBar>
</StackPanel>
<!--=xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"-->
</Controls:MetroWindow>
using System;
using System.Collections.Generic;
using System.Windows.Input;
using System.Diagnostics;
using System.Collections.ObjectModel;
using System.IO;
using System.ComponentModel;
using System.Text.RegularExpressions;
using DatGenBridge;
using DatGen_FrontEnd.Command;
namespace DatGen_FrontEnd.ViewModel
{
public class DatGenViewModel : INotifyPropertyChanged
{
private Mediator m_mediator;
private ButtonCommand m_btnCommand;
/*
* Menu items reflection
*/
private String m_openDatFileName;
private String m_saveDatFileName;
private String m_openDalFileName;
/*
* Section 01 cockpit
*/
private ICollection<float> m_datVersionCollection;
private ObservableCollection<String> m_DatVersions;
private ICollection<string> m_prdIDNamesCollection;
private ObservableCollection<String> m_PrdIDNames;
private ICollection<int> m_noOfScCollection;
private ObservableCollection<String> m_noOfSc;
private int m_ECLvl;
private ulong m_packetSize;
/*
* Section 02 cockpit
*/
private int m_no;
private int m_scRelease;
private ICollection<string> m_typesCollection;
private ObservableCollection<String> m_Types;
private String m_selectedType;
private ICollection<string> m_dvNamesCollection;
private ObservableCollection<String> m_DVNames;
private String m_selectedDVName;
private ICollection<string> m_hcNamesCollection;
private ObservableCollection<String> m_HCNames;
private String m_selectedHCName;
private ICollection<string> m_scNamesCollection;
private ObservableCollection<String> m_SCNames;
private String m_selectedSCName;
private String m_scReleaseName;
private String m_topLvlReleaseName;
private String m_commandInfo;
private String m_prevLog;
private bool m_igSignature;
private bool m_igRelStr;
private bool m_directDL;
private bool m_legacySC;
public DatGenViewModel()
{
m_mediator = new Mediator();
gedAllDataFromBackEnd();
updateAllCollections();
m_btnCommand = new ButtonCommand(this);
}
public ICommand BtnCommand
{
get
{
return m_btnCommand;
}
}
public Mediator Mediator
{
get
{
return m_mediator;
}
}
/*
* Menu items reflect Members
*/
public String OpenDatFileName
{
get
{
return m_openDatFileName;
}
set
{
m_openDatFileName = value;
}
}
public String SaveDatFileName
{
get
{
return m_saveDatFileName;
}
set
{
m_saveDatFileName = value;
}
}
public String OpenDalFilename
{
get
{
return m_openDalFileName;
}
set
{
m_openDalFileName = value;
NotifyPropertyChanged("OpenDalFilename");
OnPropertyChanged("CommandInfoLog");
}
}
/*
* Section 1 Members
*/
private bool eclvlTxtEmpty = false;
public String ECLevel
{
get
{
return eclvlTxtEmpty?"":m_ECLvl.ToString();
}
set
{
if (value != "")
{
Regex regex = new Regex("^[0-9]+$");
if (regex.IsMatch(value))
{
m_ECLvl = int.Parse(value);
eclvlTxtEmpty = false;
}
}
else
{
eclvlTxtEmpty = true;
}
}
}
private bool pktSzTxtEmpty = false;
public String PacketSize
{
get
{
return pktSzTxtEmpty?"": m_packetSize.ToString();
}
set
{
if (value != "")
{
Regex regex = new Regex("^[0-9]+$");
if (regex.IsMatch(value))
{
m_packetSize = ulong.Parse(value);
pktSzTxtEmpty = false;
}
}
else
{
pktSzTxtEmpty = true;
}
}
}
public ObservableCollection<String> DATVersions
{
get
{
return m_DatVersions;
}
}
public ObservableCollection<String> PrdIDNames
{
get
{
return m_PrdIDNames;
}
}
public ObservableCollection<String> NoOfSc
{
get
{
return m_noOfSc;
}
}
/*
* Section 02 Member functions
*/
public string PreviousLogs
{
get
{
return m_prevLog;
}
set
{
m_prevLog += value + '\n';
NotifyPropertyChanged("PreviousLogs");
}
}
public int No
{
get
{
return m_no;
}
set
{
NotifyPropertyChanged("No");
}
}
public int SCRelease
{
get
{
return m_scRelease;
}
set
{
m_scRelease = value;
NotifyPropertyChanged("SCRelease");
}
}
public ObservableCollection<String> Types
{
get
{
return m_Types;
}
}
public string SelectedType
{
get
{
return m_selectedType;
}
set
{
m_selectedType = value;
// OnPropertyChanged("SelectedType");
// OnPropertyChanged("CommandInfo");
NotifyPropertyChanged("SelectedType");
NotifyPropertyChanged("CommandInfo");
}
}
public ObservableCollection<String> DVNames
{
get
{
return m_DVNames;
}
}
public string SelectedDVName
{
get
{
return m_selectedDVName;
}
set
{
m_selectedDVName = value;
NotifyPropertyChanged("SelectedDVName");
}
}
public ObservableCollection<String> HCNames
{
get
{
return m_HCNames;
}
}
public string SelectedHCName
{
get
{
return m_selectedHCName;
}
set
{
m_selectedHCName = value;
NotifyPropertyChanged("SelectedHCName");
}
}
public ObservableCollection<String> SCNames
{
get
{
return m_SCNames;
}
}
public string SelectedSCName
{
get
{
return m_selectedSCName;
}
set
{
m_selectedSCName = value;
NotifyPropertyChanged("SelectedSCName");
}
}
public string SCReleaseName
{
get
{
return m_scReleaseName;
}
}
public string TopLvlReleaseName
{
get
{
return m_topLvlReleaseName;
}
}
public string CommandInfoLog
{
get
{
return m_commandInfo;
}
set
{
m_commandInfo =value;
//OnPropertyChanged("CommandInfo");
NotifyPropertyChanged("CommandInfo");
}
}
/*
* Section 02 ToggleSwithces
*/
public string IgnoreSignature
{
get { return m_igSignature?"Y":"N"; }
set
{
if (value == m_igSignature.ToString())
return;
m_igSignature = bool.Parse(value);
NotifyPropertyChanged("IgnoreSignature");
m_mediator.setIgnore_Signature(m_igSignature);
}
}
public string IgnoreRelString
{
get { return m_igRelStr ? "Y" : "N"; }
set
{
if (value.ToUpper() == m_igRelStr.ToString().ToUpper())
return;
m_igRelStr = bool.Parse(value); ;
NotifyPropertyChanged("IgnoreRelString");
m_mediator.setIgnoreRelString(m_igRelStr);
}
}
public string DirectDL
{
get { return m_directDL ? "Y" : "N"; }
set
{
if (value.ToUpper() == m_directDL.ToString().ToUpper())
return;
m_directDL = bool.Parse(value); ;
NotifyPropertyChanged("DirectDL");
m_mediator.setDirectDL(m_directDL);
}
}
public string LegacySC
{
get { return m_legacySC ? "Y" : "N"; }
set
{
if (value.ToUpper() == m_legacySC.ToString().ToUpper())
return;
m_legacySC = bool.Parse(value); ;
NotifyPropertyChanged("LegacySC");
m_mediator.setLegacy_SC(m_legacySC);
}
}
/*
* Button and Menu click Events
*/
public void buttonNext_ClickEvent()
{
string s = CommandInfoLog;
PreviousLogs = CommandInfoLog;
}
public void buttonPrevious_ClickEvent()
{
Debug.Assert(false, String.Format("{0} was updated.", Mediator.name));
}
public void fileMenuOpen_ClickEvent()
{
// Create OpenFileDialog
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
// Set filter for file extension and default file extension
//dlg.InitialDirectory = Environment.CurrentDirectory;
dlg.DefaultExt = ".dat";
dlg.Filter = "DAT Files (*.dat)|*.dat";
dlg.Title = "Browse DAT files";
dlg.CheckFileExists = true;
dlg.CheckPathExists = true;
dlg.RestoreDirectory = true;
// Display OpenFileDialog by calling ShowDialog method
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
// Open document
OpenDatFileName = dlg.FileName;
}
}
public void fileMenuSaveAs_ClickEvent()
{
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.InitialDirectory = Environment.CurrentDirectory;
dlg.FileName = "MP7"; // Default file name
dlg.DefaultExt = ".dat"; // Default file extension
dlg.Filter = "DAT Files (.dat)|*.dat"; // Filter files by extension
// Show save file dialog box
Nullable<bool> result = dlg.ShowDialog();
// Process save file dialog box results
if (result == true)
{
// Save document
SaveDatFileName = dlg.FileName;
File.WriteAllText(dlg.FileName, "dg");
}
}
public void fileMenuExit_ClickEvent()
{
System.Windows.Application.Current.Shutdown();
}
public void helpMenuAbout_ClickEvent()
{
DatGenAboutBox about = new DatGenAboutBox();
about.ShowDialog();
}
public void buttonDALOpen_ClickEvent()
{
//Stream myStream = null;
// Create OpenFileDialog
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
// Set filter for file extension and default file extension
//dlg.InitialDirectory = Environment.CurrentDirectory;
dlg.DefaultExt = ".dal";
dlg.Filter = "DAL (*.dal)|*.dal|BIN (*.bin) | *.bin | SET (*.set) | *.set";
dlg.Title = "Browse DAT files";
dlg.CheckFileExists = true;
dlg.CheckPathExists = true;
dlg.RestoreDirectory = true;
// Display OpenFileDialog by calling ShowDialog method
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
// Open document
OpenDalFilename = dlg.FileName;
}
}
/*
* Member utility functions
*/
private void gedAllDataFromBackEnd()
{
/*
* Section 1 data
*/
m_datVersionCollection = m_mediator.getDatVersions();
m_prdIDNamesCollection = m_mediator.getPrdIDNames();
m_ECLvl = m_mediator.getEcLevel();
m_packetSize = m_mediator.getPacketSize();
m_noOfScCollection = m_mediator.getNumbersOfSC();
/*
* Section 2 data
*/
m_no = m_mediator.getNo();
m_scRelease = m_mediator.getSCRelease();
m_typesCollection = m_mediator.getTypes();
m_dvNamesCollection = m_mediator.getDVNames();
m_hcNamesCollection = m_mediator.getHCNames();
m_scNamesCollection = m_mediator.getSCNames();
m_scReleaseName = m_mediator.getSCReleaseName();
m_topLvlReleaseName = m_mediator.getTopLevelReleaseName();
//m_commandInfo = m_mediator.getCommandInfo();
}
private void updateAllCollections()
{
/*
* Section 1 collection
*/
m_DatVersions = loadData<float>(ref m_datVersionCollection);
m_PrdIDNames = loadData<string>(ref m_prdIDNamesCollection);
m_noOfSc = loadData<int>(ref m_noOfScCollection);
/*
* Section 2 collection
*/
m_Types = loadData<string>(ref m_typesCollection);
m_DVNames = loadData<string>(ref m_dvNamesCollection);
m_HCNames = loadData<string>(ref m_hcNamesCollection);
m_SCNames = loadData<string>(ref m_scNamesCollection);
}
private ObservableCollection<String> loadData<ElementType>(ref ICollection<ElementType> in_Collection)
{
ObservableCollection<String> storage = new ObservableCollection<String>();
foreach (ElementType element in in_Collection)
{
storage.Add(element.ToString());
}
return storage;
}
private bool commandInfoTextValidation()
{
string pattern = @"^[\d]+\s{6}[\d]+\s{7}(\s(Y|-)){4}\s{4}\w+(\s{8}\w+){4}$";
Regex regex = new Regex(pattern, RegexOptions.IgnoreCase);
//Match count = regex.Match(m_commandInfo);
return regex.IsMatch(m_commandInfo);
}
/*
* Overriden implementations
*/
public bool CanUpdate(object parameter)
{
if (Mediator == null) return false;
return !String.IsNullOrWhiteSpace(parameter.ToString());
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(String propertyName)
{
if (this.PropertyChanged != null)
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
public void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment