diff --git a/HashingTool/HashingTool.csproj b/HashingTool/HashingTool.csproj index 71e94f496e6d25630e56baecf68df633dd2892af..a0025fd3cf177c0a40b07f7d200d49079d39dd8f 100644 --- a/HashingTool/HashingTool.csproj +++ b/HashingTool/HashingTool.csproj @@ -77,9 +77,11 @@ <Compile Include="ViewModel\ObservableObject.cs" /> <Compile Include="ViewModel\RelayCommand.cs" /> <Compile Include="ViewModel\HashComponentDataViewModel.cs" /> - <Compile Include="ViewModel\VerifyInputDataViewModel.cs" /> + <Compile Include="ViewModel\VerifyJobInputDataViewModel.cs" /> + <Compile Include="ViewModel\VerifyComponentInputDataViewModel.cs" /> <Compile Include="ViewModel\UserControl\XMLFile.cs" /> <Compile Include="Util\XMLValidator.cs" /> + <Compile Include="ViewModel\VerifyResultDataViewModel.cs" /> <Compile Include="Views\HashComponentData.xaml.cs"> <DependentUpon>HashComponentData.xaml</DependentUpon> </Compile> @@ -89,12 +91,15 @@ <Compile Include="Views\UserControl\VectoXMLFileSelector.xaml.cs"> <DependentUpon>VectoXMLFileSelector.xaml</DependentUpon> </Compile> - <Compile Include="Views\VerifyInputData.xaml.cs"> - <DependentUpon>VerifyInputData.xaml</DependentUpon> + <Compile Include="Views\VerifyComponentInputData.xaml.cs"> + <DependentUpon>VerifyComponentInputData.xaml</DependentUpon> </Compile> <Compile Include="Views\Dialog\XMLValidationErrorsDialog.xaml.cs"> <DependentUpon>XMLValidationErrorsDialog.xaml</DependentUpon> </Compile> + <Compile Include="Views\VerifyJobInputData.xaml.cs"> + <DependentUpon>VerifyJobInputData.xaml</DependentUpon> + </Compile> <Page Include="MainWindow.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -139,7 +144,7 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="Views\VerifyInputData.xaml"> + <Page Include="Views\VerifyComponentInputData.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> @@ -147,6 +152,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\VerifyJobInputData.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> </ItemGroup> <ItemGroup> <Compile Include="Properties\AssemblyInfo.cs"> diff --git a/HashingTool/Helper/IOService.cs b/HashingTool/Helper/IOService.cs index b6880184f26aec06c6e66950c0ba45efe4aeabfc..5f3a1c3dfe5afc132dc797d92743813d4d22eab0 100644 --- a/HashingTool/Helper/IOService.cs +++ b/HashingTool/Helper/IOService.cs @@ -1,4 +1,5 @@ using System.IO; +using System.Windows; using Microsoft.Win32; namespace HashingTool.Helper @@ -8,6 +9,7 @@ namespace HashingTool.Helper Stream OpenFileDialog(string defaultPath, string defaultExt, string filter, out string location); Stream SaveData(string defaultPath, string defaultExt, string filter, out string location); + MessageBoxResult Messagebox(string msg, string caption, MessageBoxButton buttons); } public class WPFIoService : IOService @@ -41,5 +43,10 @@ namespace HashingTool.Helper location = dlg.FileName; return new FileStream(dlg.FileName, FileMode.Create); } + + public MessageBoxResult Messagebox(string msg, string caption, MessageBoxButton buttons) + { + return MessageBox.Show(msg, caption, buttons); + } } } diff --git a/HashingTool/MainWindow.xaml b/HashingTool/MainWindow.xaml index 135c5b28ba7294b86427dbf4f353668098c6b268..e3e0ac4a0e9a2c16207f0b04899bfaed8b0e79a7 100644 --- a/HashingTool/MainWindow.xaml +++ b/HashingTool/MainWindow.xaml @@ -15,10 +15,12 @@ <DataTemplate DataType="{x:Type viewModel:HashComponentDataViewModel}"> <views:HashComponentData /> </DataTemplate> - <DataTemplate DataType="{x:Type viewModel:VerifyInputDataViewModel}"> - <views:VerifyInputData /> + <DataTemplate DataType="{x:Type viewModel:VerifyComponentInputDataViewModel}"> + <views:VerifyComponentInputData /> + </DataTemplate> + <DataTemplate DataType="{x:Type viewModel:VerifyJobInputDataViewModel}"> + <views:VerifyJobInputData /> </DataTemplate> - </Window.Resources> <Grid Margin="10"> diff --git a/HashingTool/Resources/Icon_NOK.xaml b/HashingTool/Resources/Icon_NOK.xaml index f9774db2bf9d348ecbf140f6f660bb680ce6b2b1..c0565ef3a5e2aad6b9c66fdabeba13327a98f43b 100644 --- a/HashingTool/Resources/Icon_NOK.xaml +++ b/HashingTool/Resources/Icon_NOK.xaml @@ -1,14 +1,15 @@ <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - <Canvas x:Key="Icon_NOK" Name="layer1"> - <Canvas.RenderTransform> - <TranslateTransform X="-66.503906" Y="-580.23275" /> - </Canvas.RenderTransform> - <Canvas Name="flowRoot4806" Opacity="1"> - <Path Name="path4841" Fill="#FFEB0000" StrokeThickness="1" StrokeLineJoin="Miter" StrokeStartLineCap="Flat" - StrokeEndLineCap="Flat" - Data="m 87.37793 608.62141 -1.098633 1.40625 q -8.217774 10.76661 -12.788086 10.76661 -3.427734 0 -6.987305 -5.625 1.230469 0.26367 1.889649 0.26367 5.756836 0 13.095703 -9.44824 l 1.713867 -2.15332 -1.230469 -1.49415 q -8.876953 -10.32714 -8.876953 -14.50195 0 -2.98828 4.833984 -7.60254 2.021485 9.05274 8.4375 17.09473 l 0.966797 1.23047 1.845703 -2.24121 q 9.052735 -11.20606 14.414063 -11.20606 2.63672 0 4.35059 2.59278 0.30761 0.43945 0.8789 1.23046 -6.81152 3.07618 -15.249021 12.43653 l -1.801758 2.02148 1.318359 1.4502 q 7.99805 8.78906 14.76563 8.78906 1.97753 0 3.6914 -0.43945 -2.19726 4.57031 -3.6914 5.97656 -1.4502 1.40625 -3.99903 1.40625 -5.537108 0 -14.414061 -9.71191 l -2.065429 -2.24122 z" /> + <DataTemplate x:Key="Icon_NOK"> + <Canvas Name="layer1"> + <Canvas.RenderTransform> + <TranslateTransform X="-66.503906" Y="-580.23275" /> + </Canvas.RenderTransform> + <Canvas Name="flowRoot4806" Opacity="1"> + <Path Name="path4841" Fill="#FFEB0000" StrokeThickness="1" StrokeLineJoin="Miter" StrokeStartLineCap="Flat" + StrokeEndLineCap="Flat" + Data="m 87.37793 608.62141 -1.098633 1.40625 q -8.217774 10.76661 -12.788086 10.76661 -3.427734 0 -6.987305 -5.625 1.230469 0.26367 1.889649 0.26367 5.756836 0 13.095703 -9.44824 l 1.713867 -2.15332 -1.230469 -1.49415 q -8.876953 -10.32714 -8.876953 -14.50195 0 -2.98828 4.833984 -7.60254 2.021485 9.05274 8.4375 17.09473 l 0.966797 1.23047 1.845703 -2.24121 q 9.052735 -11.20606 14.414063 -11.20606 2.63672 0 4.35059 2.59278 0.30761 0.43945 0.8789 1.23046 -6.81152 3.07618 -15.249021 12.43653 l -1.801758 2.02148 1.318359 1.4502 q 7.99805 8.78906 14.76563 8.78906 1.97753 0 3.6914 -0.43945 -2.19726 4.57031 -3.6914 5.97656 -1.4502 1.40625 -3.99903 1.40625 -5.537108 0 -14.414061 -9.71191 l -2.065429 -2.24122 z" /> + </Canvas> </Canvas> - - </Canvas> + </DataTemplate> </ResourceDictionary> \ No newline at end of file diff --git a/HashingTool/Resources/Icon_OK.xaml b/HashingTool/Resources/Icon_OK.xaml index 731e0a8151c14b0a6b21671914b77d4b2f21bf89..b60c1ec8f127da5b2c025c968ad9af26daa4b452 100644 --- a/HashingTool/Resources/Icon_OK.xaml +++ b/HashingTool/Resources/Icon_OK.xaml @@ -1,17 +1,18 @@ <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - <Canvas x:Key="Icon_OK" Name="layer1"> - <Canvas.RenderTransform> - <TranslateTransform X="-55.706613" Y="-712.36918" /> - </Canvas.RenderTransform> - - <Canvas Name="flowRoot48069" Opacity="1"> + <DataTemplate x:Key="Icon_OK"> + <Canvas Name="layer1"> <Canvas.RenderTransform> - <TranslateTransform X="-5.7972934" Y="86.067101" /> + <TranslateTransform X="-55.706613" Y="-712.36918" /> </Canvas.RenderTransform> - <Path Name="path4844" Fill="#FF00A500" StrokeThickness="1" - StrokeLineJoin="Miter" StrokeStartLineCap="Flat" StrokeEndLineCap="Flat" - Data="m 119.33594 626.30208 1.31836 2.28515 q -12.87598 9.09668 -23.862308 23.02735 -10.986328 13.93066 -15.864258 27.29004 l -1.933593 1.27441 q -2.504883 1.62598 -4.306641 3.25195 -0.307617 -1.58203 -1.713867 -5.09765 l -1.010742 -2.50488 q -3.295899 -8.12989 -5.581055 -11.33789 -2.241211 -3.25196 -4.87793 -3.51563 3.559571 -3.25195 6.196289 -3.25195 3.647461 0 7.998047 9.7998 l 1.582031 3.51563 q 7.778321 -13.93067 18.764649 -25.66407 11.030278 -11.73339 23.291018 -19.07226 z" /> + <Canvas Name="flowRoot48069" Opacity="1"> + <Canvas.RenderTransform> + <TranslateTransform X="-5.7972934" Y="86.067101" /> + </Canvas.RenderTransform> + <Path Name="path4844" Fill="#FF00A500" StrokeThickness="1" + StrokeLineJoin="Miter" StrokeStartLineCap="Flat" StrokeEndLineCap="Flat" + Data="m 119.33594 626.30208 1.31836 2.28515 q -12.87598 9.09668 -23.862308 23.02735 -10.986328 13.93066 -15.864258 27.29004 l -1.933593 1.27441 q -2.504883 1.62598 -4.306641 3.25195 -0.307617 -1.58203 -1.713867 -5.09765 l -1.010742 -2.50488 q -3.295899 -8.12989 -5.581055 -11.33789 -2.241211 -3.25196 -4.87793 -3.51563 3.559571 -3.25195 6.196289 -3.25195 3.647461 0 7.998047 9.7998 l 1.582031 3.51563 q 7.778321 -13.93067 18.764649 -25.66407 11.030278 -11.73339 23.291018 -19.07226 z" /> + </Canvas> </Canvas> - </Canvas> + </DataTemplate> </ResourceDictionary> \ No newline at end of file diff --git a/HashingTool/Resources/Icon_XML_NOK.xaml b/HashingTool/Resources/Icon_XML_NOK.xaml index ae1f9ee1e764e5690f908630c1eb32e4d44e0112..103ee9b4a9d230adbed55e204087e59f60422c38 100644 --- a/HashingTool/Resources/Icon_XML_NOK.xaml +++ b/HashingTool/Resources/Icon_XML_NOK.xaml @@ -1,20 +1,21 @@ <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - - <Canvas x:Key="Icon_XML_NOK"> - <Canvas.RenderTransform> - <TranslateTransform X="-59.285156" Y="-215.2361" /> - </Canvas.RenderTransform> - <Canvas Name="flowRoot4136" Opacity="1"> - <Path Name="path4145" Fill="#FFFF0000" StrokeThickness="1" StrokeLineJoin="Miter" StrokeStartLineCap="Flat" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> + <DataTemplate x:Key="Icon_XML_NOK"> + <Canvas> + <Canvas.RenderTransform> + <TranslateTransform X="-59.285156" Y="-215.2361" /> + </Canvas.RenderTransform> + <Canvas Name="flowRoot4136" Opacity="1"> + <Path Name="path4145" Fill="#FFFF0000" StrokeThickness="1" StrokeLineJoin="Miter" StrokeStartLineCap="Flat" StrokeEndLineCap="Flat" Data="m 59.285156 243.86892 9.785156 -14.94141 -8.867187 -13.69141 6.757812 0 5.742188 9.19922 5.625 -9.19922 6.699219 0 -8.90625 13.90625 9.785156 14.72657 -6.972656 0 -6.347657 -9.90235 -6.367187 9.90235 -6.933594 0 z" /> - <Path Name="path4147" Fill="#FFFF0000" StrokeThickness="1" StrokeLineJoin="Miter" StrokeStartLineCap="Flat" + <Path Name="path4147" Fill="#FFFF0000" StrokeThickness="1" StrokeLineJoin="Miter" StrokeStartLineCap="Flat" StrokeEndLineCap="Flat" Data="m 88.835937 243.86892 0 -28.63282 8.652344 0 5.195309 19.53125 5.13672 -19.53125 8.67188 0 0 28.63282 -5.3711 0 0 -22.53907 -5.68359 22.53907 -5.566406 0 -5.664063 -22.53907 0 22.53907 -5.371094 0 z" /> - <Path Name="path4149" Fill="#FFFF0000" StrokeThickness="1" StrokeLineJoin="Miter" StrokeStartLineCap="Flat" + <Path Name="path4149" Fill="#FFFF0000" StrokeThickness="1" StrokeLineJoin="Miter" StrokeStartLineCap="Flat" StrokeEndLineCap="Flat" Data="m 122.42969 243.86892 0 -28.39844 5.78125 0 0 23.57422 14.375 0 0 4.82422 -20.15625 0 z" /> + </Canvas> </Canvas> - </Canvas> + </DataTemplate> </ResourceDictionary> \ No newline at end of file diff --git a/HashingTool/Resources/Icon_XML_OK.xaml b/HashingTool/Resources/Icon_XML_OK.xaml index c863cfa188d1904dd95881654014b8e9418b0697..6b66741637c3a75748f849b16132c5be7b3744f2 100644 --- a/HashingTool/Resources/Icon_XML_OK.xaml +++ b/HashingTool/Resources/Icon_XML_OK.xaml @@ -1,7 +1,7 @@ <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - - <Canvas x:Key="Icon_XML_OK"> +<DataTemplate x:Key="Icon_XML_OK"> + <Canvas> <Canvas.RenderTransform> <TranslateTransform X="-59.285156" Y="-215.2361" /> </Canvas.RenderTransform> @@ -17,4 +17,5 @@ Data="m 122.42969 243.86892 0 -28.39844 5.78125 0 0 23.57422 14.375 0 0 4.82422 -20.15625 0 z" /> </Canvas> </Canvas> +</DataTemplate> </ResourceDictionary> \ No newline at end of file diff --git a/HashingTool/Resources/Icon_XML_unknown.xaml b/HashingTool/Resources/Icon_XML_unknown.xaml index 92d81c29df32d7224872ff4d6a4aa15045a2893a..b19d923d72d032843a4eea134cd4cf73efd304bd 100644 --- a/HashingTool/Resources/Icon_XML_unknown.xaml +++ b/HashingTool/Resources/Icon_XML_unknown.xaml @@ -1,6 +1,7 @@ <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - <Canvas x:Key="ICON_XML_unknown" Name="layer1"> + <DataTemplate x:Key="ICON_XML_unknown"> + <Canvas Name="layer1"> <Canvas.RenderTransform> <TranslateTransform X="-59.285156" Y="-215.2361" /> </Canvas.RenderTransform> @@ -16,4 +17,5 @@ Data="m 122.42969 243.86892 0 -28.39844 5.78125 0 0 23.57422 14.375 0 0 4.82422 -20.15625 0 z" /> </Canvas> </Canvas> + </DataTemplate> </ResourceDictionary> \ No newline at end of file diff --git a/HashingTool/ViewModel/ApplicationViewModel.cs b/HashingTool/ViewModel/ApplicationViewModel.cs index 01dae9915c8d99e37d6f3ad3b6a9f31a47c202a8..601fac71b7d249baadc68ad4eff523d888476fca 100644 --- a/HashingTool/ViewModel/ApplicationViewModel.cs +++ b/HashingTool/ViewModel/ApplicationViewModel.cs @@ -21,7 +21,8 @@ namespace HashingTool.ViewModel var homeView = new HomeViewModel(this); AvailableViews = new List<IMainView> { new HashComponentDataViewModel(this), - new VerifyInputDataViewModel(this) + new VerifyComponentInputDataViewModel(this), + new VerifyJobInputDataViewModel(this), }; CurrentViewModel = homeView; diff --git a/HashingTool/ViewModel/HashComponentDataViewModel.cs b/HashingTool/ViewModel/HashComponentDataViewModel.cs index da4ea95c71ecb2dd4b6515c56208b78d312cd80d..e7850a7f4080a6a78f3b258b5e85086cc4c3f676 100644 --- a/HashingTool/ViewModel/HashComponentDataViewModel.cs +++ b/HashingTool/ViewModel/HashComponentDataViewModel.cs @@ -25,7 +25,6 @@ namespace HashingTool.ViewModel private XDocument _result; - private readonly IOService _ioService = new WPFIoService(); private readonly RelayCommand _saveCommand; private bool _busy; private XMLFile _sourceFile; @@ -40,19 +39,13 @@ namespace HashingTool.ViewModel () => !_busy && ComponentDataValid != null && ComponentDataValid.Value && _result != null); _busy = false; + // TODO! CanonicalizaitionMethods = new ObservableCollection<string>() { "urn:vecto:xml:2017:canonicalization", "http://www.w3.org/2001/10/xml-exc-c14n#" }; } - private void SourceChanged(object sender, PropertyChangedEventArgs e) - { - if (e.PropertyName == "Document") { - DoComputeHash(); - } - } - public HashComponentDataViewModel(ApplicationViewModel applicationViewModel) : this() { _applicationViewModel = applicationViewModel; @@ -71,7 +64,6 @@ namespace HashingTool.ViewModel public XMLFile ComponentFile { get { return _sourceFile; } - private set { _sourceFile = value; } } @@ -95,6 +87,13 @@ namespace HashingTool.ViewModel get { return _saveCommand; } } + private void SourceChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == "Document") { + DoComputeHash(); + } + } + private void SaveDocument() { string filename; @@ -138,6 +137,7 @@ namespace HashingTool.ViewModel _result = h.AddHash(); + // validate generated component file using (MemoryStream ms = new MemoryStream()) { using (XmlWriter xw = XmlWriter.Create(ms, new XmlWriterSettings { Indent = true })) { _result.WriteTo(xw); diff --git a/HashingTool/ViewModel/ObservableObject.cs b/HashingTool/ViewModel/ObservableObject.cs index ea33d8b53b417206c0843673f5950333319dd5bc..6189ab66e2d250ee58467119ce3ca8f8e868d1f3 100644 --- a/HashingTool/ViewModel/ObservableObject.cs +++ b/HashingTool/ViewModel/ObservableObject.cs @@ -1,9 +1,12 @@ using System.ComponentModel; +using HashingTool.Helper; namespace HashingTool.ViewModel { public abstract class ObservableObject : INotifyPropertyChanged { + protected IOService _ioService = new WPFIoService(); + public event PropertyChangedEventHandler PropertyChanged; protected void RaisePropertyChanged(string propertyName) diff --git a/HashingTool/ViewModel/UserControl/XMLFile.cs b/HashingTool/ViewModel/UserControl/XMLFile.cs index d8dbc70fc9d55982642c6b536c5028e9a89f1a41..501cff67911672b34ae6073d9dab8124418c05b0 100644 --- a/HashingTool/ViewModel/UserControl/XMLFile.cs +++ b/HashingTool/ViewModel/UserControl/XMLFile.cs @@ -1,5 +1,6 @@ using System; using System.Collections.ObjectModel; +using System.IO; using System.Windows; using System.Windows.Input; using System.Xml; @@ -16,7 +17,6 @@ namespace HashingTool.ViewModel.UserControl private bool _busy; - private readonly IOService _ioService; private readonly bool _validate; private XmlDocument _document; @@ -78,7 +78,7 @@ namespace HashingTool.ViewModel.UserControl } - private void ReadXMLFile() + private async void ReadXMLFile() { string filename; @@ -91,12 +91,17 @@ namespace HashingTool.ViewModel.UserControl IsValid = null; XMLValidationErrors.Clear(); Source = filename; - var reader = XmlReader.Create(stream); - var document = new XmlDocument(); - document.Load(reader); + if (_validate) { - Validate(reader); + var ms = new MemoryStream(); + await stream.CopyToAsync(ms); + ms.Seek(0, SeekOrigin.Begin); + stream.Seek(0, SeekOrigin.Begin); + Validate(XmlReader.Create(ms)); } + var document = new XmlDocument(); + var reader = XmlReader.Create(stream); + document.Load(reader); Document = document; _busy = false; } diff --git a/HashingTool/ViewModel/VerifyComponentInputDataViewModel.cs b/HashingTool/ViewModel/VerifyComponentInputDataViewModel.cs new file mode 100644 index 0000000000000000000000000000000000000000..8ddfcfd1327fcaa429f95a6bb1d28e2c5f1bf602 --- /dev/null +++ b/HashingTool/ViewModel/VerifyComponentInputDataViewModel.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Windows; +using System.Windows.Input; +using HashingTool.ViewModel.UserControl; +using TUGraz.VectoHashing; + +namespace HashingTool.ViewModel +{ + public class VerifyComponentInputDataViewModel : ObservableObject, IMainView + { + private readonly ApplicationViewModel _applicationViewModel; + private string _digestValueComputed; + private string _digestValueRead; + private bool _componentDataValid; + private string _componentType; + private XMLFile _componentFile; + + + public VerifyComponentInputDataViewModel() + { + _componentFile = new XMLFile(_ioService, true); + _componentFile.PropertyChanged += ComponentFilechanged; + + // TODO! + CanonicalizaitionMethods = new ObservableCollection<string>() { + "urn:vecto:xml:2017:canonicalization", + "http://www.w3.org/2001/10/xml-exc-c14n#" + }; + } + + public VerifyComponentInputDataViewModel(ApplicationViewModel applicationViewModel) : this() + { + _applicationViewModel = applicationViewModel; + } + + public string Name + { + get { return "Verify Input Data"; } + } + + public ICommand ShowHomeViewCommand + { + get { return ApplicationViewModel.HomeView; } + } + + public XMLFile ComponentFile + { + get { return _componentFile; } + } + + public string Component + { + get { return _componentType; } + set { + if (_componentType == value) { + return; + } + _componentType = value; + RaisePropertyChanged("Component"); + } + } + + public ObservableCollection<string> CanonicalizaitionMethods { get; private set; } + + public string DigestValueComputed + { + get { return _digestValueComputed; } + set { + if (_digestValueComputed == value) { + return; + } + _digestValueComputed = value; + RaisePropertyChanged("DigestValueComputed"); + } + } + + public string DigestValueRead + { + get { return _digestValueRead; } + set { + if (_digestValueRead == value) { + return; + } + _digestValueRead = value; + RaisePropertyChanged("DigestValueRead"); + } + } + + public bool ComponentDataValid + { + get { return _componentDataValid; } + set { + if (_componentDataValid == value) { + return; + } + _componentDataValid = value; + RaisePropertyChanged("ComponentDataValid"); + } + } + + private void ComponentFilechanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == "Document") { + DoValidateHash(); + } + } + + private void DoValidateHash() + { + try { + var h = VectoHash.Load(_componentFile.Document); + + if (h.GetContainigComponents().Count != 1) { + _ioService.Messagebox("Selected file is not a component file!", "Error reading XML File", MessageBoxButton.OK); + throw new InvalidDataException(); + } + Component = h.GetContainigComponents().First().XMLElementName(); + + DigestValueRead = h.ReadHash(); + DigestValueComputed = h.ComputeHash(); + ComponentDataValid = h.ValidateHash(); + } catch (Exception e) { + ComponentDataValid = false; + DigestValueComputed = ""; + DigestValueRead = ""; + Component = ""; + } + } + } +} diff --git a/HashingTool/ViewModel/VerifyInputDataViewModel.cs b/HashingTool/ViewModel/VerifyInputDataViewModel.cs deleted file mode 100644 index eea31d03f7cac4fdd3b1eb913fa9781e9af4b409..0000000000000000000000000000000000000000 --- a/HashingTool/ViewModel/VerifyInputDataViewModel.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Windows.Input; - -namespace HashingTool.ViewModel -{ - public class VerifyInputDataViewModel : ObservableObject, IMainView - { - private readonly ApplicationViewModel _applicationViewModel; - public VerifyInputDataViewModel() {} - - public VerifyInputDataViewModel(ApplicationViewModel applicationViewModel) - { - _applicationViewModel = applicationViewModel; - } - - public string Name - { - get { return "Verify Input Data"; } - } - - public ICommand ShowHomeViewCommand - { - get { return ApplicationViewModel.HomeView; } - } - } -} diff --git a/HashingTool/ViewModel/VerifyJobInputDataViewModel.cs b/HashingTool/ViewModel/VerifyJobInputDataViewModel.cs new file mode 100644 index 0000000000000000000000000000000000000000..998903e30a834f2564b11ffc01fcb5528ce1eb3d --- /dev/null +++ b/HashingTool/ViewModel/VerifyJobInputDataViewModel.cs @@ -0,0 +1,137 @@ +using System; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Windows; +using System.Windows.Input; +using HashingTool.ViewModel.UserControl; +using TUGraz.VectoHashing; + +namespace HashingTool.ViewModel +{ + public class VerifyJobInputDataViewModel : ObservableObject, IMainView + { + private readonly ApplicationViewModel _applicationViewModel; + private string _digestValueComputed; + private bool _componentDataValid; + private readonly XMLFile _jobFile; + + + public VerifyJobInputDataViewModel() + { + _jobFile = new XMLFile(_ioService, true); + _jobFile.PropertyChanged += JobFilechanged; + + // TODO! + CanonicalizaitionMethods = new ObservableCollection<string>() { + "urn:vecto:xml:2017:canonicalization", + "http://www.w3.org/2001/10/xml-exc-c14n#" + }; + Components = new ObservableCollection<ComponentEntry>(); + } + + public VerifyJobInputDataViewModel(ApplicationViewModel applicationViewModel) + : this() + { + _applicationViewModel = applicationViewModel; + } + + public string Name + { + get { return "Verify Job"; } + } + + public ICommand ShowHomeViewCommand + { + get { return ApplicationViewModel.HomeView; } + } + + public XMLFile JobFile + { + get { return _jobFile; } + } + + public ObservableCollection<ComponentEntry> Components { get; private set; } + + public ObservableCollection<string> CanonicalizaitionMethods { get; private set; } + + public string DigestValueComputed + { + get { return _digestValueComputed; } + set { + if (_digestValueComputed == value) { + return; + } + _digestValueComputed = value; + RaisePropertyChanged("DigestValueComputed"); + } + } + + public bool JobDataValid + { + get { return _componentDataValid; } + set { + if (_componentDataValid == value) { + return; + } + _componentDataValid = value; + RaisePropertyChanged("JobDataValid"); + } + } + + private void JobFilechanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == "Document") { + DoValidateHash(); + } + } + + private void DoValidateHash() + { + try { + Components.Clear(); + var h = VectoHash.Load(_jobFile.Document); + var allValid = true; + var components = h.GetContainigComponents().GroupBy(s => s) + .Select(g => new { Entry = g.Key, Count = g.Count() }); + foreach (var component in components) { + if (component.Entry == VectoComponents.Vehicle) { + continue; + } + for (var i = 0; i < component.Count; i++) { + var entry = new ComponentEntry(); + entry.Component = component.Count == 1 + ? component.Entry.XMLElementName() + : string.Format("{0} ({1})", component.Entry.XMLElementName(), i + 1); + entry.Valid = h.ValidateHash(component.Entry, i); + entry.CanonicalizationMethod = new[] { + "urn:vecto:xml:2017:canonicalization", + "http://www.w3.org/2001/10/xml-exc-c14n#" + }; + entry.DigestValueRead = h.ReadHash(component.Entry, i); + entry.DigestValueComputed = h.ComputeHash(component.Entry, i); + Components.Add(entry); + allValid &= entry.Valid; + } + } + + DigestValueComputed = h.ComputeHash(); + JobDataValid = allValid; + } catch (Exception e) { + DigestValueComputed = ""; + JobDataValid = false; + } + } + } + + public class ComponentEntry + { + public string Component { get; set; } + public string DigestValueRead { get; set; } + public string DigestValueComputed { get; set; } + public string[] CanonicalizationMethod { get; set; } + public bool Valid { get; set; } + public bool InValid { get { return !Valid; } } + } +} diff --git a/HashingTool/ViewModel/VerifyResultDataViewModel.cs b/HashingTool/ViewModel/VerifyResultDataViewModel.cs new file mode 100644 index 0000000000000000000000000000000000000000..9e271ba036185ce3f0e907d224a4eb3f787c1f98 --- /dev/null +++ b/HashingTool/ViewModel/VerifyResultDataViewModel.cs @@ -0,0 +1,192 @@ +using System.Windows.Input; +using HashingTool.ViewModel.UserControl; + +namespace HashingTool.ViewModel +{ + public class VerifyResultDataViewModel : ObservableObject, IMainView + { + private ApplicationViewModel _applicationViewModel; + private XMLFile _jobFile; + private XMLFile _manufacturerReport; + private XMLFile _customerReport; + private string _jobDigestValue; + private string _manufacturerDigestComputed; + private string _manufacturerDigestRead; + private string _customerDigestComputed; + private string _customerDigestRead; + private bool? _manufacturerReportValid; + private bool? _customerReportValid; + private string _manufacturerReportJobDigest; + private string _customerReportJobDigest; + private bool _manufacturerReportJobDigestValid; + private bool _customerReportJobDigestValid; + + public VerifyResultDataViewModel() {} + + public VerifyResultDataViewModel(ApplicationViewModel applicationViewModel) : this() + { + _applicationViewModel = applicationViewModel; + _jobFile = new XMLFile(_ioService, true); + _manufacturerReport = new XMLFile(_ioService, true); + _customerReport = new XMLFile(_ioService, true); + } + + public string Name + { + get { return "Verify Result Data"; } + } + + public ICommand ShowHomeViewCommand + { + get { return ApplicationViewModel.HomeView; } + } + + public XMLFile JobFile + { + get { return _jobFile; } + } + + public XMLFile ManufacturerReport + { + get { return _manufacturerReport; } + } + + public XMLFile CustomerReport + { + get { return _customerReport; } + } + + public string JobDigestValueComputed + { + get { return _jobDigestValue; } + private set { + if (_jobDigestValue == value) { + return; + } + _jobDigestValue = value; + RaisePropertyChanged("JobDigestValueComputed"); + } + } + + public string ManufacturerReportDigestValueComputed + { + get { return _manufacturerDigestComputed; } + private set { + if (_manufacturerDigestComputed == value) { + return; + } + _manufacturerDigestComputed = value; + RaisePropertyChanged("ManufacturerReportDigestValueComputed"); + } + } + + public string ManufacturerReportDigestValueRead + { + get { return _manufacturerDigestRead; } + private set { + if (_manufacturerDigestRead == value) { + return; + } + _manufacturerDigestRead = value; + RaisePropertyChanged("ManufacturerReportDigestValueRead"); + } + } + + public bool? ManufacturerReportValid + { + get { return _manufacturerReportValid; } + private set { + if (_manufacturerReportValid == value) { + return; + } + _manufacturerReportValid = value; + RaisePropertyChanged("ManufacturerReportValid"); + } + } + + public string CustomerReportDigestValueComputed + { + get { return _customerDigestComputed; } + private set { + if (_customerDigestComputed == value) { + return; + } + _customerDigestComputed = value; + RaisePropertyChanged("CustomerReportDigestValueComputed"); + } + } + + public string CustomerReportDigestValueRead + { + get { return _customerDigestRead; } + private set { + if (_customerDigestRead == value) { + return; + } + _customerDigestRead = value; + RaisePropertyChanged("CustomerReportDigestValueRead"); + } + } + + public bool? CustomerReportValid + { + get { return _customerReportValid; } + private set { + if (_customerReportValid == value) { + return; + } + _customerReportValid = value; + RaisePropertyChanged("CustomerReportValid"); + } + } + + public string ManufacturerReportJobDigestValue + { + get { return _manufacturerReportJobDigest; } + private set { + if (_manufacturerReportJobDigest == value) { + return; + } + _manufacturerReportJobDigest = value; + RaisePropertyChanged("ManufacturerReportJobDigestValue"); + } + } + + public string CustomerReportJobDigestValue + { + get { return _customerReportJobDigest; } + private set { + if (_customerReportJobDigest == value) { + return; + } + _customerReportJobDigest = value; + RaisePropertyChanged("CustomerReportJobDigestValue"); + } + } + + + public bool ManufacturerReportJobDigestValid + { + get { return _manufacturerReportJobDigestValid; } + private set { + if (_manufacturerReportJobDigestValid == value) { + return; + } + _manufacturerReportJobDigestValid = value; + RaisePropertyChanged("ManufacturerReportJobDigestValid"); + } + } + + public bool CustomerReportJobDigestValid + { + get { return _customerReportJobDigestValid; } + private set { + if (_customerReportJobDigestValid == value) { + return; + } + _customerReportJobDigestValid = value; + RaisePropertyChanged("CustomerReportJobDigestValid"); + } + } + } +} diff --git a/HashingTool/Views/HashComponentData.xaml b/HashingTool/Views/HashComponentData.xaml index 9f4978d2ae63e8be495ded73f4c8615549684936..32e5b50b4fea2362db857ce6afd84e729dad374d 100644 --- a/HashingTool/Views/HashComponentData.xaml +++ b/HashingTool/Views/HashComponentData.xaml @@ -94,14 +94,14 @@ <ContentControl.Style> <Style TargetType="ContentControl"> <Setter Property="Content" Value="" /> - <Setter Property="ToolTip" Value=""/> + <Setter Property="ToolTip" Value="X"/> <Style.Triggers> <DataTrigger Binding="{Binding ComponentDataValid}" Value="True"> - <Setter Property="Content" Value="{StaticResource Icon_OK}" /> + <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="Content" Value="{StaticResource Icon_NOK}" /> + <Setter Property="ContentTemplate" Value="{StaticResource Icon_NOK}" /> <Setter Property="ToolTip" Value="Component data does NOT validat against schema"/> </DataTrigger> </Style.Triggers> diff --git a/HashingTool/Views/HashComponentData.xaml.cs b/HashingTool/Views/HashComponentData.xaml.cs index db2a94c7055bc829657c33bccefd93037cf795aa..9728536fc0c6d1e2d3ff0d3ccd9ae4c3ac01fba1 100644 --- a/HashingTool/Views/HashComponentData.xaml.cs +++ b/HashingTool/Views/HashComponentData.xaml.cs @@ -12,7 +12,7 @@ namespace HashingTool.Views /// <summary> /// Interaction logic for HashComponentData.xaml /// </summary> - public partial class HashComponentData : UserControl + public partial class HashComponentData { public HashComponentData() { diff --git a/HashingTool/Views/HomeView.xaml.cs b/HashingTool/Views/HomeView.xaml.cs index 2ee77da4fc6f91d96691cff0f12cdf312a0384d5..8f79dc15da7f5fcd03afbfd1a59ec8739581a134 100644 --- a/HashingTool/Views/HomeView.xaml.cs +++ b/HashingTool/Views/HomeView.xaml.cs @@ -5,7 +5,7 @@ namespace HashingTool.Views /// <summary> /// Interaction logic for HomeView.xaml /// </summary> - public partial class HomeView : UserControl + public partial class HomeView { public HomeView() { diff --git a/HashingTool/Views/UserControl/VectoXMLFileSelector.xaml b/HashingTool/Views/UserControl/VectoXMLFileSelector.xaml index e216cb6acfed54b347846f9c140d2b87a16e7cc9..5a6786c0e88834a30381f83a2f11bdea84b135de 100644 --- a/HashingTool/Views/UserControl/VectoXMLFileSelector.xaml +++ b/HashingTool/Views/UserControl/VectoXMLFileSelector.xaml @@ -6,7 +6,7 @@ xmlns:views="clr-namespace:HashingTool.Views" x:Class="HashingTool.Views.VectoXMLFileSelector" mc:Ignorable="d" d:DesignWidth="456" MinHeight="43" - d:DataContext="{d:DesignInstance views:VectoXMLFileSelector}" Height="34"> + d:DataContext="{d:DesignInstance views:VectoXMLFileSelector}" Height="81"> <UserControl.Resources> <BooleanToVisibilityConverter x:Key="BoolToVis" /> </UserControl.Resources> @@ -21,17 +21,49 @@ </ContentControl.RenderTransform> <ContentControl.Style> <Style TargetType="ContentControl"> - <Setter Property="Content" Value="{StaticResource ICON_XML_unknown}" /> + <Setter Property="ContentTemplate" Value="{StaticResource ICON_XML_unknown}" /> <Style.Triggers> <DataTrigger Binding="{Binding XMLFile.IsValid}" Value="True"> - <Setter Property="Content" Value="{StaticResource Icon_XML_OK}" /> + <Setter Property="ContentTemplate" Value="{StaticResource Icon_XML_OK}" /> </DataTrigger> <DataTrigger Binding="{Binding XMLFile.IsValid}" Value="False"> - <Setter Property="Content" Value="{StaticResource Icon_XML_NOK}" /> + <Setter Property="ContentTemplate" Value="{StaticResource Icon_XML_NOK}" /> </DataTrigger> </Style.Triggers> </Style> </ContentControl.Style> </ContentControl> + + <StackPanel Orientation="Horizontal" Margin="10,44,0,10"> + <StackPanel.Style> + <Style TargetType="StackPanel"> + <Setter Property="Visibility" Value="{Binding XMLFile.ValidateInput, Converter={StaticResource BoolToVis}}"/> + </Style> + </StackPanel.Style> + <Label Content="{Binding XMLFile.XMLValidationErrors.Count}" ContentStringFormat="{}{0} Warnings/Errors" MinWidth="80"> + <Label.Style> + <Style TargetType="Label"> + <Setter Property="Foreground" Value="Red" /> + <Style.Triggers> + <DataTrigger Binding="{Binding XMLFile.XMLValidationErrors.Count}" Value="0"> + <Setter Property="Foreground" Value="Black" /> + </DataTrigger> + </Style.Triggers> + </Style> + </Label.Style> + </Label> + <Button x:Name="btnDetails" Margin="10,0,0,0" Content="Details..." HorizontalAlignment="Left" Width="91" Click="btnDetails_Click"> + <Button.Style> + <Style TargetType="Button"> + <Setter Property="IsEnabled" Value="True" /> + <Style.Triggers> + <DataTrigger Binding="{Binding XMLFile.XMLValidationErrors.Count}" Value="0"> + <Setter Property="IsEnabled" Value="False" /> + </DataTrigger> + </Style.Triggers> + </Style> + </Button.Style> + </Button> + </StackPanel> </Grid> </UserControl> \ No newline at end of file diff --git a/HashingTool/Views/UserControl/VectoXMLFileSelector.xaml.cs b/HashingTool/Views/UserControl/VectoXMLFileSelector.xaml.cs index 887cb6c676a91a41e563ad5e71c31e664fac8dfa..06743ce975c016beeb9713541f2658b455ce83a1 100644 --- a/HashingTool/Views/UserControl/VectoXMLFileSelector.xaml.cs +++ b/HashingTool/Views/UserControl/VectoXMLFileSelector.xaml.cs @@ -1,18 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using HashingTool.ViewModel; +using System.Windows; using HashingTool.ViewModel.UserControl; namespace HashingTool.Views @@ -20,7 +6,7 @@ namespace HashingTool.Views /// <summary> /// Interaction logic for VectoXMLFileSelector.xaml /// </summary> - public partial class VectoXMLFileSelector : UserControl + public partial class VectoXMLFileSelector { public static readonly DependencyProperty XMLFileProperty = DependencyProperty.Register("XMLFile", typeof(XMLFile), typeof(VectoXMLFileSelector)); @@ -37,5 +23,13 @@ namespace HashingTool.Views get { return (XMLFile)GetValue(XMLFileProperty); } set { SetValue(XMLFileProperty, value); } } + + private void btnDetails_Click(object sender, RoutedEventArgs e) + { + var dialog = new XMLValidationErrorsDialog(); + dialog.XMLErrors = XMLFile.XMLValidationErrors; + + dialog.ShowDialog(); + } } } diff --git a/HashingTool/Views/VerifyComponentInputData.xaml b/HashingTool/Views/VerifyComponentInputData.xaml new file mode 100644 index 0000000000000000000000000000000000000000..cbee72fe342d2283afb45ec73f29be2359391204 --- /dev/null +++ b/HashingTool/Views/VerifyComponentInputData.xaml @@ -0,0 +1,79 @@ +<UserControl + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:ViewModel="clr-namespace:HashingTool.ViewModel" + xmlns:views="clr-namespace:HashingTool.Views" + xmlns:helper="clr-namespace:HashingTool.Helper" + x:Class="HashingTool.Views.VerifyComponentInputData" + mc:Ignorable="d" + d:DesignHeight="422" d:DesignWidth="534"> + <UserControl.Resources> + <helper:CollectionConverter x:Key="CollectionConverter" /> + </UserControl.Resources> + <UserControl.DataContext> + <ViewModel:VerifyComponentInputDataViewModel/> + </UserControl.DataContext> + <Grid> + <Label x:Name="lblFileSelect" Content="Component data:" HorizontalAlignment="Left" Margin="10,75,0,0" + VerticalAlignment="Top" /> + <Label Name="lblHeader" HorizontalAlignment="Center" Margin="10,10,0,0" VerticalAlignment="Top" + Content="{Binding Name}" FontWeight="Bold" FontSize="18" /> + <Button Name="btnBack" Content="Back" Command="{Binding ShowHomeViewCommand}" Margin="0,0,10,10" + HorizontalAlignment="Right" + Width="75" Height="22" VerticalAlignment="Bottom" /> + <views:VectoXMLFileSelector Margin="0,93,0,0" VerticalAlignment="Top" XMLFile="{Binding ComponentFile}" Height="80"/> + <Grid Margin="0,178,0,0"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + </Grid.RowDefinitions> + <Grid Grid.Row="0" Margin="0,5"> + <Label Content="Component:"/> + <TextBox Text="{Binding Component}" Margin="155,0,10,0" IsReadOnly="True"/> + </Grid> + <Grid Grid.Row="1" Margin="0,5"> + <Label Content="Canonicalization methods:"/> + <TextBox Text="{Binding CanonicalizaitionMethods , Converter={StaticResource CollectionConverter}}" Margin="155,0,10,0" IsReadOnly="True"/> + </Grid> + <Grid Grid.Row="2" Margin="0,5"> + <Label Content="Digest Value read:"/> + <TextBox Text="{Binding DigestValueRead}" Margin="155,0,10,0" IsReadOnly="True"/> + </Grid> + <Grid Grid.Row="3" Margin="0,5"> + <Label Content="Digest Value computed:"/> + <TextBox Text="{Binding DigestValueComputed}" Margin="155,0,10,0" IsReadOnly="True"/> + </Grid> + <Grid Grid.Row="4" Margin="0,10,0,0"> + <ContentControl HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Top" Width="66" Height="64"> + <ContentControl.RenderTransform> + <ScaleTransform ScaleX="1.5" ScaleY="1.5" /> + </ContentControl.RenderTransform> + <ContentControl.Style> + <Style TargetType="ContentControl"> + <Setter Property="Content" Value="" /> + <Setter Property="ToolTip" Value=""/> + <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> + </Grid> + + + </Grid> +</UserControl> \ No newline at end of file diff --git a/HashingTool/Views/VerifyComponentInputData.xaml.cs b/HashingTool/Views/VerifyComponentInputData.xaml.cs new file mode 100644 index 0000000000000000000000000000000000000000..cc579aee24d8af2d48723fa69c86f57a8d3f0b0e --- /dev/null +++ b/HashingTool/Views/VerifyComponentInputData.xaml.cs @@ -0,0 +1,13 @@ +namespace HashingTool.Views +{ + /// <summary> + /// Interaction logic for VerifyComponentInputData.xaml + /// </summary> + public partial class VerifyComponentInputData + { + public VerifyComponentInputData() + { + InitializeComponent(); + } + } +} diff --git a/HashingTool/Views/VerifyInputData.xaml b/HashingTool/Views/VerifyInputData.xaml deleted file mode 100644 index c72f2784a28012ca156977b16bdb4b25be6f6b77..0000000000000000000000000000000000000000 --- a/HashingTool/Views/VerifyInputData.xaml +++ /dev/null @@ -1,18 +0,0 @@ -<UserControl - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:ViewModel="clr-namespace:HashingTool.ViewModel" x:Class="HashingTool.Views.VerifyInputData" - mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300"> - <Grid> - <Grid.DataContext> - <ViewModel:VerifyInputDataViewModel /> - </Grid.DataContext> - <Label Content="{Binding Name}" HorizontalAlignment="Left" Margin="131,115,0,0" VerticalAlignment="Top" /> - <Button Content="Home" Command="{Binding ShowHomeViewCommand}" HorizontalAlignment="Left" Margin="150,201,0,0" - VerticalAlignment="Top" Width="75" /> - - </Grid> -</UserControl> \ No newline at end of file diff --git a/HashingTool/Views/VerifyJobInputData.xaml b/HashingTool/Views/VerifyJobInputData.xaml new file mode 100644 index 0000000000000000000000000000000000000000..72b8d075e2d18061ce3cd66983350fa8831679b5 --- /dev/null +++ b/HashingTool/Views/VerifyJobInputData.xaml @@ -0,0 +1,141 @@ +<UserControl + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:ViewModel="clr-namespace:HashingTool.ViewModel" + xmlns:views="clr-namespace:HashingTool.Views" + xmlns:helper="clr-namespace:HashingTool.Helper" + x:Class="HashingTool.Views.VerifyJobInputData" + mc:Ignorable="d" + d:DesignHeight="555" d:DesignWidth="534"> + <UserControl.Resources> + <helper:CollectionConverter x:Key="CollectionConverter" /> + <BooleanToVisibilityConverter x:Key="Bool2Vis" /> + </UserControl.Resources> + <UserControl.DataContext> + <ViewModel:VerifyJobInputDataViewModel /> + </UserControl.DataContext> + <Grid> + <Label x:Name="lblFileSelect" Content="Job data:" HorizontalAlignment="Left" Margin="10,75,0,0" + VerticalAlignment="Top" /> + <Label Name="lblHeader" HorizontalAlignment="Center" Margin="10,10,0,0" VerticalAlignment="Top" + Content="{Binding Name}" FontWeight="Bold" FontSize="18" /> + <Button Name="btnBack" Content="Back" Command="{Binding ShowHomeViewCommand}" Margin="0,0,10,10" + HorizontalAlignment="Right" + Width="75" Height="22" VerticalAlignment="Bottom" /> + <views:VectoXMLFileSelector Margin="0,93,0,0" VerticalAlignment="Top" XMLFile="{Binding JobFile}" Height="80" /> + <Grid Margin="0,178,0,0"> + <Grid.RowDefinitions> + <RowDefinition Height="*" MaxHeight="300" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + </Grid.RowDefinitions> + <Grid Grid.Row="1" Margin="0,5"> + <Label Content="Canonicalization methods:" /> + <TextBox Text="{Binding CanonicalizaitionMethods , Converter={StaticResource CollectionConverter}}" + Margin="155,0,10,0" IsReadOnly="True" /> + </Grid> + <Grid Grid.Row="2" Margin="0,5"> + <Label Content="Digest Value computed:" /> + <TextBox Text="{Binding DigestValueComputed}" Margin="155,0,10,0" + IsReadOnly="True" /> + </Grid> + <Grid Grid.Row="3" Margin="0,10,0,0"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="29*" /> + <ColumnDefinition Width="60*" /> + </Grid.ColumnDefinitions> + <ContentControl HorizontalAlignment="Center" Margin="60,0,234,0" VerticalAlignment="Top" Width="66" Height="64" + Grid.Column="1"> + <ContentControl.RenderTransform> + <ScaleTransform ScaleX="1.5" ScaleY="1.5" /> + </ContentControl.RenderTransform> + <ContentControl.Style> + <Style TargetType="ContentControl"> + <Setter Property="Content" Value="" /> + <Setter Property="ToolTip" Value="" /> + <Style.Triggers> + <DataTrigger Binding="{Binding JobDataValid}" Value="True"> + <Setter Property="ContentTemplate" Value="{StaticResource Icon_OK}" /> + <Setter Property="ToolTip" Value="Component data validates against schema" /> + </DataTrigger> + <DataTrigger Binding="{Binding JobDataValid}" 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> + <ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Auto" Background="{x:Static SystemColors.ControlLightBrush}" + Margin="10,0"> + <ItemsControl Margin="0,0,0,20" x:Name="ComponentListing" ItemsSource="{Binding Components}"> + <ItemsControl.ItemTemplate> + <DataTemplate> + <Expander Margin="4" Header="{Binding}"> + <Expander.HeaderTemplate> + <DataTemplate> + <Grid + HorizontalAlignment="{Binding Path=HorizontalAlignment, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContentPresenter}}, Mode=OneWayToSource}"> + <Grid.ColumnDefinitions> + <ColumnDefinition MinWidth="150" /> + <ColumnDefinition Width="100" /> + </Grid.ColumnDefinitions> + <TextBlock Grid.Column="0" Text="{Binding Component}" Margin="4,0" /> + <StackPanel Grid.Column="1" VerticalAlignment="Top" Width="16" Height="16" HorizontalAlignment="Left"> + <ContentControl ContentTemplate="{StaticResource Icon_OK}" Visibility="{Binding Valid, Converter={StaticResource Bool2Vis}}"> + <ContentControl.RenderTransform> + <ScaleTransform ScaleX=".4" ScaleY=".4" /> + </ContentControl.RenderTransform> + </ContentControl> + <ContentControl ContentTemplate="{StaticResource Icon_NOK}" Visibility="{Binding Path=InValid, Converter={StaticResource Bool2Vis}}"> + <ContentControl.RenderTransform> + <ScaleTransform ScaleX=".4" ScaleY=".4" /> + </ContentControl.RenderTransform> + </ContentControl> + </StackPanel> + </Grid> + </DataTemplate> + </Expander.HeaderTemplate> + <Expander.Content> + <Border BorderBrush="{x:Static SystemColors.ControlDarkDarkBrush}" BorderThickness="0,0,0,1" Margin="0,0,0,3"> + <Grid> + <Grid.RowDefinitions> + <RowDefinition /> + <RowDefinition /> + <RowDefinition /> + </Grid.RowDefinitions> + <Grid Row="0" Margin="10,13,0,3"> + <Label Content="Canonicalization methods:" /> + <TextBox Text="{Binding CanonicalizationMethod , Converter={StaticResource CollectionConverter}}" + Margin="155,0,10,0" IsReadOnly="True" /> + </Grid> + <Grid Row="1" Margin="10,2,0,3"> + <Label Content="Digest Value read:" /> + <TextBox Text="{Binding DigestValueRead}" + Margin="155,0,10,0" IsReadOnly="True" /> + </Grid> + <Grid Row="2" Margin="10,2,0,3"> + <Label Content="Digest Value computed:" /> + <TextBox Text="{Binding DigestValueComputed}" + Margin="155,0,10,0" IsReadOnly="True" /> + </Grid> + </Grid> + </Border> + </Expander.Content> + </Expander> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> + </ScrollViewer> + + </Grid> + + + </Grid> +</UserControl> \ No newline at end of file diff --git a/HashingTool/Views/VerifyInputData.xaml.cs b/HashingTool/Views/VerifyJobInputData.xaml.cs similarity index 75% rename from HashingTool/Views/VerifyInputData.xaml.cs rename to HashingTool/Views/VerifyJobInputData.xaml.cs index 7dec5dc8943ea77f7d4b17aa61e5a3f7e0a47af7..5403d5d214509fd86ef668ef55aa98258b90d0e9 100644 --- a/HashingTool/Views/VerifyInputData.xaml.cs +++ b/HashingTool/Views/VerifyJobInputData.xaml.cs @@ -16,11 +16,11 @@ using System.Windows.Shapes; namespace HashingTool.Views { /// <summary> - /// Interaction logic for VerifyInputData.xaml + /// Interaction logic for VerifyJobInputData.xaml /// </summary> - public partial class VerifyInputData : UserControl + public partial class VerifyJobInputData : System.Windows.Controls.UserControl { - public VerifyInputData() + public VerifyJobInputData() { InitializeComponent(); }