diff --git a/HashingTool/HashingTool.csproj b/HashingTool/HashingTool.csproj index 02f6adcf81b46ad658db11460f30f2a4a0bbef55..7be85b019d8fb2236d23b1fdf10f38b8ee95356a 100644 --- a/HashingTool/HashingTool.csproj +++ b/HashingTool/HashingTool.csproj @@ -43,6 +43,10 @@ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <Prefer32Bit>true</Prefer32Bit> </PropertyGroup> + <PropertyGroup> + <ApplicationIcon> + </ApplicationIcon> + </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Data" /> @@ -217,6 +221,13 @@ <Name>VectoCore</Name> </ProjectReference> </ItemGroup> + <ItemGroup> + <Resource Include="Resources\HashingIcon.ico" /> + <Resource Include="Resources\IVT_91x44.png" /> + <Resource Include="Resources\JRC-About.png" /> + <Resource Include="Resources\TUG_91x34.png" /> + <Resource Include="Resources\VECTO_Hashing.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. diff --git a/HashingTool/MainWindow.xaml b/HashingTool/MainWindow.xaml index 5478344d3a339948e183eab9295ddda400c90613..fe0aed3a1ff5e59db5873bf93745472362e57460 100644 --- a/HashingTool/MainWindow.xaml +++ b/HashingTool/MainWindow.xaml @@ -4,7 +4,7 @@ xmlns:viewModel="clr-namespace:HashingTool.ViewModel" xmlns:views="clr-namespace:HashingTool.Views" x:Class="HashingTool.MainWindow" - Title="VECTO Hashing Tool" Height="534" Width="665" MinWidth="600" MinHeight="500"> + Title="VECTO Hashing Tool" Height="590" Width="800" MinWidth="800" MinHeight="600" Icon="Resources/HashingIcon.ico"> <Window.DataContext> <viewModel:ApplicationViewModel /> </Window.DataContext> @@ -25,9 +25,37 @@ <views:VerifyResults /> </DataTemplate> </Window.Resources> - <Grid Margin="10"> - - <ContentControl Content="{Binding CurrentViewModel}" /> - - </Grid> + <DockPanel> + <Grid DockPanel.Dock="Top" Height="100"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="256"/> + <ColumnDefinition Width="*"/> + </Grid.ColumnDefinitions> + <Grid.Background> + <ImageBrush ImageSource="Resources/VECTO_Hashing.png" Stretch="None" AlignmentX="Left" AlignmentY="Center"/> + </Grid.Background> + <TextBlock Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Text="VECTO Hashing Tool" FontSize="38" FontWeight="Bold" Margin="30,20,0,0"/> + </Grid> + <Border DockPanel.Dock="Bottom" BorderThickness="0,1,0,0" BorderBrush="{x:Static SystemColors.ControlDarkDarkBrush}" + Margin="2,0"> + <Grid Background="White" Margin="0,10"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="*" /> + <ColumnDefinition Width="*" /> + <ColumnDefinition Width="*" /> + </Grid.ColumnDefinitions> + <Image Grid.Column="0" HorizontalAlignment="Center" Height="44" VerticalAlignment="Center" Width="auto" + Source="Resources/IVT_91x44.png" /> + <Image Grid.Column="1" HorizontalAlignment="Center" Height="34" VerticalAlignment="Center" Width="auto" + Source="Resources/TUG_91x34.png" /> + <Image Grid.Column="2" HorizontalAlignment="Center" Height="44" VerticalAlignment="Center" Width="auto" + Source="Resources/JRC-About.png" /> + </Grid> + </Border> + <!--<ScrollViewer VerticalScrollBarVisibility="Auto">--> + <Grid Margin="10"> + <ContentControl Content="{Binding CurrentViewModel}" /> + </Grid> + <!--</ScrollViewer>--> + </DockPanel> </Window> \ No newline at end of file diff --git a/HashingTool/ViewModel/HashComponentDataViewModel.cs b/HashingTool/ViewModel/HashComponentDataViewModel.cs index 0f18bcda4e204c3166e1a34693ad71cfeba6d6cd..7fee6dd53bab979f9e8acc7231a4abe47a8ddc07 100644 --- a/HashingTool/ViewModel/HashComponentDataViewModel.cs +++ b/HashingTool/ViewModel/HashComponentDataViewModel.cs @@ -1,26 +1,21 @@ using System; -using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.IO; using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Xml; using System.Xml.Linq; using System.Xml.Schema; -using HashingTool.Helper; using HashingTool.Util; using HashingTool.ViewModel.UserControl; -using TUGraz.VectoCore.Utils; using TUGraz.VectoHashing; namespace HashingTool.ViewModel { public class HashComponentDataViewModel : ObservableObject, IMainView { - private readonly ApplicationViewModel _applicationViewModel; private string _digestValue; private XDocument _result; @@ -46,7 +41,7 @@ namespace HashingTool.ViewModel }; } - + public string Name { get { return "Hash Component Data"; } diff --git a/HashingTool/ViewModel/HashedXMLFile.cs b/HashingTool/ViewModel/HashedXMLFile.cs index 2241b46d90bc9eb9d9997295004dc679829fd803..4101bbf71112348216995883290d087534345ddb 100644 --- a/HashingTool/ViewModel/HashedXMLFile.cs +++ b/HashingTool/ViewModel/HashedXMLFile.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Xml; using HashingTool.Helper; @@ -14,12 +15,12 @@ namespace HashingTool.ViewModel protected bool? _valid; protected string _name; protected string _tooltip; - protected readonly Func<XmlDocument, bool?> _contentCheck; + protected readonly Func<XmlDocument, Collection<string>, bool?> _contentCheck; protected string _componentType; protected readonly Action<XmlDocument, VectoXMLFile> _validateHashes; - public VectoXMLFile(IOService ioService, string name, Func<XmlDocument, bool?> contentCheck, + public VectoXMLFile(IOService ioService, string name, Func<XmlDocument, Collection<string>, bool?> contentCheck, Action<XmlDocument, VectoXMLFile> hashValidation = null) { IoService = ioService; @@ -34,36 +35,25 @@ namespace HashingTool.ViewModel "http://www.w3.org/2001/10/xml-exc-c14n#" }; Valid = null; - ValidTooltip = VerifyResultDataViewModel.ToolTip_None; + ValidTooltip = VerifyResultDataViewModel.ToolTipNone; } protected virtual void FileChanged(object sender, PropertyChangedEventArgs e) { if (_xmlFile.IsValid != null && XMLFile.IsValid.HasValue && _xmlFile.IsValid.Value) { - Valid = _contentCheck(_xmlFile.Document); + Valid = _contentCheck(_xmlFile.Document, XMLFile.XMLValidationErrors); if (Valid != null && Valid.Value) { - ValidTooltip = VerifyResultDataViewModel.ToolTip_OK; + ValidTooltip = VerifyResultDataViewModel.ToolTipOk; } else { - ValidTooltip = VerifyResultDataViewModel.ToolTip_InvalidFileType; + ValidTooltip = VerifyResultDataViewModel.ToolTipInvalidFileType; } } else { Valid = false; - ValidTooltip = VerifyResultDataViewModel.ToolTip_XMLValidationFailed; + ValidTooltip = VerifyResultDataViewModel.ToolTipXMLValidationFailed; } if (Valid != null && Valid.Value && _validateHashes != null) { _validateHashes(_xmlFile.Document, this); - //try { - // _validateHashes(_xmlFile.Document, this); - // Valid = result.Valid; - // ValidTooltip = result.Valid ? VerifyResultDataViewModel.ToolTip_OK : VerifyResultDataViewModel.ToolTip_HashInvalid; - // DigestValueComputed = result.DigestComputed; - // DigestValueRead = result.DigestRead; - //} catch (Exception ex) { - // Valid = false; - // DigestValueComputed = ""; - // DigestValueRead = ""; - //} } } @@ -142,7 +132,7 @@ namespace HashingTool.ViewModel { protected string _manufacturerDigestRead; - public HashedXMLFile(IOService ioService, string name, Func<XmlDocument, bool?> contentCheck, + public HashedXMLFile(IOService ioService, string name, Func<XmlDocument, Collection<string>, bool?> contentCheck, Action<XmlDocument, VectoXMLFile> hashValidation = null) : base(ioService, name, contentCheck, hashValidation) {} public string DigestValueRead @@ -162,7 +152,7 @@ namespace HashingTool.ViewModel { private string _jobDigestRead; - public ReportXMLFile(IOService ioService, string name, Func<XmlDocument, bool?> contentCheck, + public ReportXMLFile(IOService ioService, string name, Func<XmlDocument, Collection<string>, bool?> contentCheck, Action<XmlDocument, VectoXMLFile> hashValidation = null) : base(ioService, name, contentCheck, hashValidation) { diff --git a/HashingTool/ViewModel/ObservableObject.cs b/HashingTool/ViewModel/ObservableObject.cs index dfd7fdf018a912637ae68907710ed165c65b6b74..a11fd5f37eddfd148c7a34d6215334bfa00c102b 100644 --- a/HashingTool/ViewModel/ObservableObject.cs +++ b/HashingTool/ViewModel/ObservableObject.cs @@ -1,4 +1,5 @@ -using System.ComponentModel; +using System.Collections.ObjectModel; +using System.ComponentModel; using System.Linq; using System.Xml; using HashingTool.Helper; @@ -21,35 +22,57 @@ namespace HashingTool.ViewModel } } - protected bool? IsManufacturerReport(XmlDocument x) + protected bool? IsManufacturerReport(XmlDocument x, Collection<string> errorLog) { - if (x == null || x.DocumentElement == null) + if (x == null || x.DocumentElement == null) { return null; - return x.DocumentElement.LocalName == XMLNames.VectoManufacturerReport; + } + var valid = x.DocumentElement.LocalName == XMLNames.VectoManufacturerReport; + if (!valid) { + errorLog.Add(string.Format("Invalid XML file given ({0}). Expected Manufacturer Report XML ({1})!", + x.DocumentElement.LocalName, XMLNames.VectoManufacturerReport)); + } + return valid; } - protected bool? IsCustomerReport(XmlDocument x) + protected bool? IsCustomerReport(XmlDocument x, Collection<string> errorLog) { - if (x == null || x.DocumentElement == null) + if (x == null || x.DocumentElement == null) { return null; - return x.DocumentElement != null && x.DocumentElement.LocalName == XMLNames.VectoCustomerReport; + } + var valid = x.DocumentElement != null && x.DocumentElement.LocalName == XMLNames.VectoCustomerReport; + if (!valid) { + errorLog.Add(string.Format("Invalid XML file given ({0}). Expected Customer Report XML ({1})!", + x.DocumentElement.LocalName, XMLNames.VectoCustomerReport)); + } + return valid; } - protected static bool? IsJobFile(XmlDocument x) + protected static bool? IsJobFile(XmlDocument x, Collection<string> errorLog) { - if (x == null) + if (x == null || x.DocumentElement == null) { return null; - return x.DocumentElement != null && x.DocumentElement.LocalName == XMLNames.VectoInputDeclaration && - x.DocumentElement.FirstChild.LocalName == XMLNames.Component_Vehicle; + } + var valid = x.DocumentElement.LocalName == XMLNames.VectoInputDeclaration && + x.DocumentElement.FirstChild.LocalName == XMLNames.Component_Vehicle; + if (!valid) { + errorLog.Add(string.Format("Invalid XML file given ({0}/{1}). Expected Vehicle XML ({2}/{3})!", + x.DocumentElement.LocalName, x.DocumentElement.FirstChild.LocalName, XMLNames.VectoInputDeclaration, + XMLNames.Component_Vehicle)); + } + return valid; } - protected static bool? IsComponentFile(XmlDocument x) + protected static bool? IsComponentFile(XmlDocument x, Collection<string> errorLog) { if (x.DocumentElement == null) { return null; } if (x.DocumentElement.LocalName != XMLNames.VectoInputDeclaration) { + errorLog.Add(string.Format("Invalid XML file given ({0}). Expected Component XML ({1})!", + x.DocumentElement.LocalName, XMLNames.VectoInputDeclaration)); + return false; } @@ -58,7 +81,12 @@ namespace HashingTool.ViewModel VectoComponents.Engine, VectoComponents.Airdrag, VectoComponents.Angledrive, VectoComponents.Axlegear, VectoComponents.Gearbox, VectoComponents.Retarder, VectoComponents.TorqueConverter, VectoComponents.Tyre }; - return components.Where(c => c.XMLElementName() == localName).Any(); + var valid = components.Where(c => c.XMLElementName() == localName).Any(); + if (!valid) { + errorLog.Add(string.Format("Invalid XML file given ({0}). Expected Component XML ({1})!", + localName, string.Join(", ", components.Select(c => c.XMLElementName())))); + } + return valid; } } } diff --git a/HashingTool/ViewModel/UserControl/XMLFile.cs b/HashingTool/ViewModel/UserControl/XMLFile.cs index 7e36aa6830a2e46631691bcc720e8804b17a3a35..56b46ad72f4ee011b05c2569af345f9c046ab691 100644 --- a/HashingTool/ViewModel/UserControl/XMLFile.cs +++ b/HashingTool/ViewModel/UserControl/XMLFile.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Xml; -using System.Xml.Linq; using System.Xml.Schema; using HashingTool.Helper; using HashingTool.Util; @@ -21,17 +20,16 @@ namespace HashingTool.ViewModel.UserControl private readonly bool _validate; private XmlDocument _document; - private readonly Func<XmlDocument, bool?> _postVerification; + private readonly Func<XmlDocument, Collection<string>, bool?> _postVerification; private bool? _contentValid; - private bool _hasContentValidation; - public XMLFile(IOService ioservice, bool validate = false, Func<XmlDocument, bool?> contentCheck = null) + public XMLFile(IOService ioservice, bool validate = false, Func<XmlDocument, Collection<string>, bool?> contentCheck = null) { IoService = ioservice; _validate = validate; XMLValidationErrors = new ObservableCollection<string>(); HasContentValidation = contentCheck != null; - _postVerification = contentCheck ?? (x => null); + _postVerification = contentCheck ?? ((x,c) => null); Source = ""; RaisePropertyChanged("ValidateInput"); RaisePropertyChanged("HasContentValidation"); @@ -88,7 +86,7 @@ namespace HashingTool.ViewModel.UserControl public ICommand SetXMLFileCommnd { - get { return new RelayCommand<string>(SetXMLFile, (f) => !_busy); } + get { return new RelayCommand<string>(SetXMLFile, f => !_busy); } } private async void SetXMLFile(string fileName) @@ -138,7 +136,7 @@ namespace HashingTool.ViewModel.UserControl var document = new XmlDocument(); var reader = XmlReader.Create(stream); document.Load(reader); - ContentValid = _postVerification(document); + ContentValid = _postVerification(document, XMLValidationErrors); Document = document; _busy = false; } diff --git a/HashingTool/ViewModel/VerifyComponentInputDataViewModel.cs b/HashingTool/ViewModel/VerifyComponentInputDataViewModel.cs index b51ae126ff6b0aefb9a48d528689894a3964ed5c..cc19810259890bef0133e2cc37a8534bf59efa96 100644 --- a/HashingTool/ViewModel/VerifyComponentInputDataViewModel.cs +++ b/HashingTool/ViewModel/VerifyComponentInputDataViewModel.cs @@ -33,7 +33,7 @@ namespace HashingTool.ViewModel public string Name { - get { return "Verify Input Data"; } + get { return "Verify Component Data"; } } public ICommand ShowHomeViewCommand diff --git a/HashingTool/ViewModel/VerifyJobInputDataViewModel.cs b/HashingTool/ViewModel/VerifyJobInputDataViewModel.cs index a53f9fcc44589224076a4484ab40f2385c9ebd2f..8eb83f3bf2e43c61845752127f0e11ae589512d4 100644 --- a/HashingTool/ViewModel/VerifyJobInputDataViewModel.cs +++ b/HashingTool/ViewModel/VerifyJobInputDataViewModel.cs @@ -31,7 +31,7 @@ namespace HashingTool.ViewModel public string Name { - get { return "Verify Job"; } + get { return "Verify VECTO Job"; } } public ICommand ShowHomeViewCommand diff --git a/HashingTool/ViewModel/VerifyResultDataViewModel.cs b/HashingTool/ViewModel/VerifyResultDataViewModel.cs index 978abcde85466c086b4e41c1927629b25123b627..4e9c83a6b8e627bc42dcfdc64fb7415e72626eb7 100644 --- a/HashingTool/ViewModel/VerifyResultDataViewModel.cs +++ b/HashingTool/ViewModel/VerifyResultDataViewModel.cs @@ -1,31 +1,23 @@ using System; -using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; -using System.IO; -using System.Linq; -using System.Windows; using System.Windows.Input; using System.Xml; -using System.Xml.Linq; -using HashingTool.ViewModel.UserControl; -using TUGraz.VectoCommon.Resources; using TUGraz.VectoHashing; namespace HashingTool.ViewModel { public class VerifyResultDataViewModel : ObservableObject, IMainView { - private ApplicationViewModel _applicationViewModel; - private VectoXMLFile _jobFile; - private ReportXMLFile _customerReport; - private ReportXMLFile _manufacturerReport; + private readonly VectoXMLFile _jobFile; + private readonly ReportXMLFile _customerReport; + private readonly ReportXMLFile _manufacturerReport; - public const string ToolTip_InvalidFileType = "Invalid File type!"; - public const string ToolTip_XMLValidationFailed = "XML validation failed!"; - public const string ToolTip_OK = "Correct file selected"; - public const string ToolTip_HashInvalid = "Incorrect digest value!"; - public const string ToolTip_None = ""; + public const string ToolTipInvalidFileType = "Invalid File type!"; + public const string ToolTipXMLValidationFailed = "XML validation failed!"; + public const string ToolTipOk = "Correct file selected"; + public const string ToolTipHashInvalid = "Incorrect digest value!"; + public const string ToolTipNone = ""; public VerifyResultDataViewModel() @@ -35,7 +27,6 @@ namespace HashingTool.ViewModel _customerReport = new ReportXMLFile(IoService, "Customer Report", IsCustomerReport, ValidateDocumentHash); Files = new ObservableCollection<VectoXMLFile> { _jobFile, _manufacturerReport, _customerReport }; - CanonicalizationMethods = new ObservableCollection<string>() { "urn:vecto:xml:2017:canonicalization" }; RaisePropertyChanged("CanonicalizationMethods"); _customerReport.PropertyChanged += Update; _manufacturerReport.PropertyChanged += Update; @@ -48,8 +39,6 @@ namespace HashingTool.ViewModel } - public ObservableCollection<string> CanonicalizationMethods { get; private set; } - public string Name { get { return "Verify Result Data"; } @@ -100,6 +89,7 @@ namespace HashingTool.ViewModel var h = VectoHash.Load(xml); xmlViewModel.DigestValueComputed = h.ComputeHash(); } catch (Exception e) { + xmlViewModel.XMLFile.XMLValidationErrors.Add(e.Message); xmlViewModel.DigestValueComputed = ""; } } @@ -122,8 +112,11 @@ namespace HashingTool.ViewModel } catch { report.DigestValueComputed = ""; } - report.Valid = h.ValidateHash(); + var valid = h.ValidateHash(); + report.ValidTooltip = valid ? ToolTipOk : ToolTipHashInvalid; + report.Valid = valid; } catch (Exception e) { + report.XMLFile.XMLValidationErrors.Add(e.Message); report.Valid = false; } } diff --git a/HashingTool/Views/Dialog/XMLValidationErrorsDialog.xaml b/HashingTool/Views/Dialog/XMLValidationErrorsDialog.xaml index d972aef493c523339ace7ac2de41a56c24f2f554..3f160c64f8168231087a452710e7e5ccfa38ab5b 100644 --- a/HashingTool/Views/Dialog/XMLValidationErrorsDialog.xaml +++ b/HashingTool/Views/Dialog/XMLValidationErrorsDialog.xaml @@ -6,7 +6,7 @@ mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:views="clr-namespace:HashingTool.Views" - d:DataContext="{d:DesignInstance views:XMLValidationErrorsDialog}"> + d:DataContext="{d:DesignInstance views:XMLValidationErrorsDialog}" Icon="/HashingTool;component/Resources/HashingIcon.ico"> <Grid> <ListBox x:Name="lbErrors" Margin="10,10,10,62" ItemsSource="{Binding XMLErrors}" /> <Button IsCancel="True" x:Name="btnClose" Content="Close" Margin="0,0,10,10" Height="22" VerticalAlignment="Bottom" diff --git a/HashingTool/Views/HashComponentData.xaml b/HashingTool/Views/HashComponentData.xaml index b74ceb993b5c8dda1bbf55a98a3a740e7d7fe2a0..a4258a4fb05969398f3d4a0dde4f418c4258e497 100644 --- a/HashingTool/Views/HashComponentData.xaml +++ b/HashingTool/Views/HashComponentData.xaml @@ -16,16 +16,9 @@ <ViewModel:HashComponentDataViewModel /> </UserControl.DataContext> <DockPanel> - <Label DockPanel.Dock="Top" Name="lblHeader" HorizontalAlignment="Center" Margin="10,10,0,0" VerticalAlignment="Top" + <Label DockPanel.Dock="Top" Name="lblHeader" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Top" Content="{Binding Name}" FontWeight="Bold" FontSize="18" /> - - <Label DockPanel.Dock="Top" x:Name="lblFileSelect" Content="Component data:" HorizontalAlignment="Left" Margin="10,0" - VerticalAlignment="Top" /> - - <local:VectoXMLFileSelector DockPanel.Dock="Top" Margin="10,0" VerticalAlignment="Top" - XMLFile="{Binding ComponentFile}" /> - - <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right"> + <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0"> <Button Content="Save Component Data" HorizontalAlignment="Right" Margin="0,0,15,10" Width="143" Height="22" VerticalAlignment="Bottom" Command="{Binding SaveHashedDocument, Mode=OneWay}" /> <Button Name="btnBack" Content="Back" Command="{Binding ShowHomeViewCommand}" Margin="0,0,10,10" @@ -33,95 +26,104 @@ Width="75" Height="22" VerticalAlignment="Bottom" /> </StackPanel> - <Grid DockPanel.Dock="Top" Margin="10,0,1,0"> - <Grid.RowDefinitions> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - </Grid.RowDefinitions> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="Auto" /> - <ColumnDefinition Width="*" /> - <ColumnDefinition Width="Auto" /> - </Grid.ColumnDefinitions> - <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,0,0,5"> - <Label> - <Label.Content> - <TextBlock Text="{Binding XMLValidationErrors.Count, StringFormat='{}{0} Warnings/Errors'}" /> - </Label.Content> - <Label.Style> - <Style TargetType="Label"> - <Setter Property="Foreground" Value="Red" /> - <Style.Triggers> - <DataTrigger Binding="{Binding XMLValidationErrors.Count}" Value="0"> - <Setter Property="Foreground" Value="Black" /> - </DataTrigger> - </Style.Triggers> - </Style> - </Label.Style> - </Label> - <Button Margin="10,0,0,0" Content="Details..." HorizontalAlignment="Left" Width="91" Click="Button_Click"> + <DockPanel DockPanel.Dock="Bottom"> + <Label DockPanel.Dock="Top" x:Name="lblFileSelect" Content="Component data:" HorizontalAlignment="Left" + Margin="10,0" + VerticalAlignment="Top" /> + + <local:VectoXMLFileSelector DockPanel.Dock="Top" Margin="10,0" VerticalAlignment="Top" + XMLFile="{Binding ComponentFile}" /> + + + <Grid DockPanel.Dock="Top" Margin="10,0,1,0"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + </Grid.RowDefinitions> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="Auto" /> + <ColumnDefinition Width="*" /> + <ColumnDefinition Width="Auto" /> + </Grid.ColumnDefinitions> + <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,0,0,5"> + <Label> + <Label.Content> + <TextBlock Text="{Binding XMLValidationErrors.Count, StringFormat='{}{0} Warnings/Errors'}" /> + </Label.Content> + <Label.Style> + <Style TargetType="Label"> + <Setter Property="Foreground" Value="Red" /> + <Style.Triggers> + <DataTrigger Binding="{Binding XMLValidationErrors.Count}" Value="0"> + <Setter Property="Foreground" Value="Black" /> + </DataTrigger> + </Style.Triggers> + </Style> + </Label.Style> + </Label> + <Button Margin="10,0,0,0" Content="Details..." HorizontalAlignment="Left" Width="91" Click="Button_Click"> + <Button.Style> + <Style TargetType="Button"> + <Setter Property="IsEnabled" Value="True" /> + <Style.Triggers> + <DataTrigger Binding="{Binding XMLValidationErrors.Count}" Value="0"> + <Setter Property="IsEnabled" Value="False" /> + </DataTrigger> + </Style.Triggers> + </Style> + </Button.Style> + </Button> + </StackPanel> + + <Label Grid.Row="1" Grid.Column="0" Name="lblC14N" Content="Canonicalization:" HorizontalAlignment="Left" + Margin="0" /> + <TextBox Grid.Row="1" Grid.Column="1" Name="lblC14NList" + Text="{Binding CanonicalizaitionMethods, Converter={StaticResource CollectionConverter}}" + Margin="10,2" /> + <Button Grid.Row="1" Grid.Column="2" Content="Copy" Margin="10,2,0,2" HorizontalAlignment="Right" Width="75" + Click="Button_Click_1"> <Button.Style> <Style TargetType="Button"> - <Setter Property="IsEnabled" Value="True" /> + <Setter Property="IsEnabled" Value="false" /> <Style.Triggers> - <DataTrigger Binding="{Binding XMLValidationErrors.Count}" Value="0"> - <Setter Property="IsEnabled" Value="False" /> + <DataTrigger Binding="{Binding ComponentDataValid}" Value="True"> + <Setter Property="IsEnabled" Value="True" /> </DataTrigger> </Style.Triggers> </Style> </Button.Style> </Button> - </StackPanel> - - <Label Grid.Row="1" Grid.Column="0" Name="lblC14N" Content="Canonicalization:" HorizontalAlignment="Left" - Margin="0" /> - <TextBox Grid.Row="1" Grid.Column="1" Name="lblC14NList" - Text="{Binding CanonicalizaitionMethods, Converter={StaticResource CollectionConverter}}" - Margin="10,2" /> - <Button Grid.Row="1" Grid.Column="2" Content="Copy" Margin="10,2,0,2" HorizontalAlignment="Right" Width="75" - Click="Button_Click_1"> - <Button.Style> - <Style TargetType="Button"> - <Setter Property="IsEnabled" Value="false" /> - <Style.Triggers> - <DataTrigger Binding="{Binding ComponentDataValid}" Value="True"> - <Setter Property="IsEnabled" Value="True" /> - </DataTrigger> - </Style.Triggers> - </Style> - </Button.Style> - </Button> - <Label Grid.Row="2" Grid.Column="0" x:Name="lblDigestValue" Content="Digest Value:" HorizontalAlignment="Left" - Margin="0" Style="{StaticResource DigestValueLabelStyle}" /> - <TextBox Grid.Row="2" Grid.Column="1" x:Name="tbDigestValue" Text="{Binding DigestValue}" Margin="10,2" - VerticalAlignment="Top" RenderTransformOrigin="4.1,-2.1" Style="{StaticResource DigestValueTextboxStyle}" - Foreground="{StaticResource Color.SuccessGreen}" /> - <ContentControl Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Center" Margin="0,0,0,0" - VerticalAlignment="Top" Width="66" Height="64"> - <ContentControl.LayoutTransform> - <ScaleTransform ScaleX="1.5" ScaleY="1.5" /> - </ContentControl.LayoutTransform> - <ContentControl.Style> - <Style TargetType="ContentControl"> - <Setter Property="Content" Value="" /> - <Setter Property="ToolTip" Value="X" /> - <Style.Triggers> - <DataTrigger Binding="{Binding ComponentDataValid}" Value="True"> - <Setter Property="ContentTemplate" Value="{StaticResource Icon_OK}" /> - <Setter Property="ToolTip" Value="Component data validates against schema" /> - </DataTrigger> - <DataTrigger Binding="{Binding ComponentDataValid}" Value="False"> - <Setter Property="ContentTemplate" Value="{StaticResource Icon_NOK}" /> - <Setter Property="ToolTip" Value="Component data does NOT validat against schema" /> - </DataTrigger> - </Style.Triggers> - </Style> - </ContentControl.Style> - </ContentControl> - - </Grid> + <Label Grid.Row="2" Grid.Column="0" x:Name="lblDigestValue" Content="Digest Value:" HorizontalAlignment="Left" + Margin="0" Style="{StaticResource DigestValueLabelStyle}" /> + <TextBox Grid.Row="2" Grid.Column="1" x:Name="tbDigestValue" Text="{Binding DigestValue}" Margin="10,2" + VerticalAlignment="Top" RenderTransformOrigin="4.1,-2.1" Style="{StaticResource DigestValueTextboxStyle}" + Foreground="{StaticResource Color.SuccessGreen}" /> + <ContentControl Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Center" Margin="0,0,0,0" + VerticalAlignment="Top" Width="66" Height="64"> + <ContentControl.LayoutTransform> + <ScaleTransform ScaleX="1.5" ScaleY="1.5" /> + </ContentControl.LayoutTransform> + <ContentControl.Style> + <Style TargetType="ContentControl"> + <Setter Property="Content" Value="" /> + <Setter Property="ToolTip" Value="X" /> + <Style.Triggers> + <DataTrigger Binding="{Binding ComponentDataValid}" Value="True"> + <Setter Property="ContentTemplate" Value="{StaticResource Icon_OK}" /> + <Setter Property="ToolTip" Value="Component data validates against schema" /> + </DataTrigger> + <DataTrigger Binding="{Binding ComponentDataValid}" Value="False"> + <Setter Property="ContentTemplate" Value="{StaticResource Icon_NOK}" /> + <Setter Property="ToolTip" Value="Component data does NOT validat against schema" /> + </DataTrigger> + </Style.Triggers> + </Style> + </ContentControl.Style> + </ContentControl> + </Grid> + </DockPanel> </DockPanel> </UserControl> \ No newline at end of file diff --git a/HashingTool/Views/HomeView.xaml b/HashingTool/Views/HomeView.xaml index 5cee0b6c9380c24557f6fc165841dae65a05c4de..4b04b6f9adf9d6e87160a51234fe43df8deaef4b 100644 --- a/HashingTool/Views/HomeView.xaml +++ b/HashingTool/Views/HomeView.xaml @@ -5,26 +5,36 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:viewModel="clr-namespace:HashingTool.ViewModel" x:Class="HashingTool.Views.HomeView" mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300"> + d:DesignHeight="382" d:DesignWidth="532"> - <Grid x:Name="MainGrid"> + <Grid x:Name="MainGrid" Margin="0,0,0,0"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" MinWidth="30" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="*"/> + <RowDefinition Height="Auto"/> + <RowDefinition Height="*"/> + </Grid.RowDefinitions> <Grid.DataContext> <viewModel:HomeViewModel /> </Grid.DataContext> <ItemsControl x:Name="ViewSelectionPanel" ItemsSource="{Binding MainViewModels}" - Grid.Column="1"> + Grid.Row="1" Grid.Column="1"> + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <UniformGrid Rows="2" Columns="2" Height="300" Width="500"/> + </ItemsPanelTemplate> + </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> - <Grid Margin="0,30,0,5"> - <Button Content="{Binding Name}" Margin="2,5" Padding="15,10" + <Grid Margin="0"> + <Button Content="{Binding Name}" Margin="10" Padding="15,10" Command="{Binding DataContext.ChangeViewCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" - CommandParameter="{Binding ''}" /> + CommandParameter="{Binding ''}" FontWeight="bold" FontSize="18" /> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> diff --git a/HashingTool/Views/VerifyComponentInputData.xaml b/HashingTool/Views/VerifyComponentInputData.xaml index 8f9f1d2f4893813b0e41871099fbff22c9e532df..21c7c173e3b9403425c5f7e908c3dc1044594d03 100644 --- a/HashingTool/Views/VerifyComponentInputData.xaml +++ b/HashingTool/Views/VerifyComponentInputData.xaml @@ -8,7 +8,7 @@ xmlns:helper="clr-namespace:HashingTool.Helper" x:Class="HashingTool.Views.VerifyComponentInputData" mc:Ignorable="d" - d:DesignHeight="422" d:DesignWidth="534"> + d:DesignHeight="380" d:DesignWidth="534"> <UserControl.Resources> <helper:CollectionConverter x:Key="CollectionConverter" /> @@ -18,12 +18,13 @@ </UserControl.DataContext> <DockPanel> - <Label DockPanel.Dock="Top" Name="lblHeader" HorizontalAlignment="Center" Margin="10,10,0,0" VerticalAlignment="Top" + <Label DockPanel.Dock="Top" Name="lblHeader" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Top" Content="{Binding Name}" FontWeight="Bold" FontSize="18" /> <Button DockPanel.Dock="Bottom" Name="btnBack" Content="Back" Command="{Binding ShowHomeViewCommand}" - Margin="0,0,10,10" + Margin="0,10,10,5" HorizontalAlignment="Right" Width="75" Height="22" VerticalAlignment="Bottom" /> + <ScrollViewer VerticalScrollBarVisibility="Auto"> <DockPanel> <Label DockPanel.Dock="Top" x:Name="lblFileSelect" Content="Component data:" HorizontalAlignment="Left" Margin="10,2,0,2" @@ -40,7 +41,7 @@ <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> + <RowDefinition Height="*" /> </Grid.RowDefinitions> <Label Grid.Row="0" Grid.Column="0" Content="Component:" /> @@ -82,7 +83,7 @@ </TextBox.Style> </TextBox> - <ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="0,40,0,0" VerticalAlignment="Top" Width="66" Height="64"> + <ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="0,20,0,0" VerticalAlignment="Top" Width="66" Height="30"> <ContentControl.LayoutTransform> <ScaleTransform ScaleX="1.5" ScaleY="1.5" /> </ContentControl.LayoutTransform> @@ -107,5 +108,6 @@ </DockPanel> + </ScrollViewer> </DockPanel> </UserControl> \ No newline at end of file diff --git a/HashingTool/Views/VerifyJobInputData.xaml b/HashingTool/Views/VerifyJobInputData.xaml index a3afacbf4079346140988d8b04dcd3713db932c5..1aaaf6186e97ce2814cf77b870e6d02fd0f857f0 100644 --- a/HashingTool/Views/VerifyJobInputData.xaml +++ b/HashingTool/Views/VerifyJobInputData.xaml @@ -15,14 +15,17 @@ <UserControl.DataContext> <viewModel:VerifyJobInputDataViewModel /> </UserControl.DataContext> + <DockPanel> - <Label DockPanel.Dock="Top" Name="lblHeader" HorizontalAlignment="Center" Margin="0,10" VerticalAlignment="Top" + <Label DockPanel.Dock="Top" Name="lblHeader" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Top" Content="{Binding Name}" FontWeight="Bold" FontSize="18" /> <Button DockPanel.Dock="Bottom" Name="btnBack" Content="Back" Command="{Binding ShowHomeViewCommand}" - Margin="0,0,10,10" + Margin="0,10,10,5" HorizontalAlignment="Right" Width="75" Height="22" VerticalAlignment="Bottom" /> + <ScrollViewer> + <DockPanel> <Label x:Name="lblFileSelect" DockPanel.Dock="Top" Content="Job data:" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top" /> <views:VectoXMLFileSelector Margin="0,0,0,0" DockPanel.Dock="Top" VerticalAlignment="Top" XMLFile="{Binding JobFile}" @@ -75,7 +78,7 @@ <ScrollViewer Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" VerticalScrollBarVisibility="Auto" Background="{x:Static SystemColors.ControlLightBrush}" Margin="10,0,10,10"> - <ItemsControl Margin="3" x:Name="ComponentListing" ItemsSource="{Binding Components}"> + <ItemsControl Margin="3" x:Name="ComponentListing" ItemsSource="{Binding Components}" MinHeight="300"> <ItemsControl.ItemContainerStyle> <Style> <Setter Property="FrameworkElement.Margin" Value="0,2" /> @@ -171,6 +174,7 @@ </ScrollViewer> </Grid> - + </DockPanel> + </ScrollViewer> </DockPanel> </UserControl> \ No newline at end of file diff --git a/HashingTool/Views/VerifyResults.xaml b/HashingTool/Views/VerifyResults.xaml index 559d25fcd8ddf09536be32269f7794caa1bb4cf9..7849baa3b12af4fca18f6a2964cfdc2dfe2ef717 100644 --- a/HashingTool/Views/VerifyResults.xaml +++ b/HashingTool/Views/VerifyResults.xaml @@ -190,7 +190,7 @@ Margin="0,0,10,10" HorizontalAlignment="Right" Width="75" Height="22" VerticalAlignment="Bottom" /> - <Label DockPanel.Dock="Top" x:Name="lblHeader" HorizontalAlignment="Center" Margin="10,10,0,0" + <Label DockPanel.Dock="Top" x:Name="lblHeader" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Top" Content="{Binding Name}" FontWeight="Bold" FontSize="18" /> <Grid Margin="0,0,0,0" HorizontalAlignment="Stretch"> diff --git a/HashingTool/Views/VerifyResults.xaml.cs b/HashingTool/Views/VerifyResults.xaml.cs index b4f3fefed6c52541d6222b1f1479030fcf017dc2..557207dd44d45e05c902c590e09efb02ee501fa1 100644 --- a/HashingTool/Views/VerifyResults.xaml.cs +++ b/HashingTool/Views/VerifyResults.xaml.cs @@ -8,9 +8,6 @@ namespace HashingTool.Views /// Interaction logic for VerifyResults.xaml /// </summary> /// - - - public partial class VerifyResults : UserControl { public VerifyResults() @@ -21,17 +18,17 @@ namespace HashingTool.Views private void Button_Click(object sender, RoutedEventArgs e) { var ui = sender as FrameworkElement; - if (ui == null) + if (ui == null) { return; - var context = ui.DataContext as HashedXMLFile; - if (context == null) + } + var context = ui.DataContext as VectoXMLFile; + if (context == null) { return; + } var dialog = new XMLValidationErrorsDialog(); dialog.XMLErrors = context.XMLFile.XMLValidationErrors; dialog.ShowDialog(); - - //MessageBox.Show("Hello World", "test", MessageBoxButton.OK); } } }