diff --git a/HashingTool/Properties/AssemblyInfo.cs b/HashingTool/Properties/AssemblyInfo.cs index 71bc3b073460d082586a7b0e2ba810a6fed97c5f..f62a3905040fb9ed6e62659c7576db4c568190a7 100644 --- a/HashingTool/Properties/AssemblyInfo.cs +++ b/HashingTool/Properties/AssemblyInfo.cs @@ -30,55 +30,55 @@ */ using System.Reflection; -using System.Runtime.InteropServices; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("HashingTool")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("HashingTool")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -//In order to begin building localizable applications, set -//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file -//inside a <PropertyGroup>. For example, if you are using US english -//in your source files, set the <UICulture> to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) - )] - - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyTitle("HashingTool")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("HashingTool")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. + +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file +//inside a <PropertyGroup>. For example, if you are using US english +//in your source files, set the <UICulture> to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) + )] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] \ No newline at end of file diff --git a/VECTO3GUI/MainWindow.xaml.cs b/VECTO3GUI/MainWindow.xaml.cs index 7d38b7a9a3169d964fe19537a688d7983e12cb9b..3847c9e6026396eb51d41d83bb4e00b983e17189 100644 --- a/VECTO3GUI/MainWindow.xaml.cs +++ b/VECTO3GUI/MainWindow.xaml.cs @@ -33,6 +33,7 @@ namespace VECTO3GUI { InitializeComponent(); DataContext = viewModel; + Closing += viewModel.CurrentViewModel.Closing; } } } diff --git a/VECTO3GUI/Model/SettingsModel.cs b/VECTO3GUI/Model/SettingsModel.cs index a4925d5647d5ff4ecf2b80fe73e3eee827e169ed..f9b906284a046b459ffe2fd0a0888db6e502ca20 100644 --- a/VECTO3GUI/Model/SettingsModel.cs +++ b/VECTO3GUI/Model/SettingsModel.cs @@ -40,9 +40,8 @@ namespace VECTO3GUI.Model if (XmlFilePathFolder == string.Empty) { var location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - var defaultPath = - location + - @"\..\..\..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersion2.6_Buses"; + var defaultPath = location; //+ + //@"\..\..\..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersion2.6_Buses"; XmlFilePathFolder = Path.GetFullPath(new Uri(defaultPath).LocalPath); } diff --git a/VECTO3GUI/ViewModel/Impl/JoblistViewModel.cs b/VECTO3GUI/ViewModel/Impl/JoblistViewModel.cs index cb3db9a735ef3cde080f82cda8750f2db6559185..e417cd2e511cd4ef7c23c4ef20f8cf1aa7aef4c3 100644 --- a/VECTO3GUI/ViewModel/Impl/JoblistViewModel.cs +++ b/VECTO3GUI/ViewModel/Impl/JoblistViewModel.cs @@ -15,6 +15,8 @@ using System.Windows.Input; using System.Xml; using System.Xml.Linq; using Castle.Core.Internal; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Ninject; using NLog; using NLog.Targets; @@ -42,6 +44,8 @@ namespace VECTO3GUI.ViewModel.Impl { public class JoblistViewModel : ObservableObject, IJoblistViewModel { + protected const string SETTINGS_FILE = "Config/Settings3.json"; + #region Members protected ObservableCollectionEx<JobEntry> _jobs; @@ -148,6 +152,7 @@ namespace VECTO3GUI.ViewModel.Impl public JoblistViewModel() { _settings = new SettingsModel(); + LoadOptions(); SetJobEntries(); SimulationWorker = new BackgroundWorker(); @@ -161,6 +166,45 @@ namespace VECTO3GUI.ViewModel.Impl NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target); } + private void LoadOptions() + { + if (!File.Exists(SETTINGS_FILE)) { + WriteModData = true; + ValidateData = true; + return; + } + using (var reader = File.OpenText(SETTINGS_FILE)) { + var content = JToken.ReadFrom(new JsonTextReader(reader)); + var body = content["Body"]; + if (body == null) { + return; + } + + WriteModData = body.GetValueOrDefault<bool>("WriteModData") ?? true; + ValidateData = body.GetValueOrDefault<bool>("ValidateRunData") ?? true; + WriteModData1Hz = body.GetValueOrDefault<bool>("WriteModData1Hz") ?? false; + WriteActualModData = body.GetValueOrDefault<bool>("WriteActualModData") ?? false; + OutputDirectory = body["OutputDirectory"] == null ? "" : body["OutputDirectory"].Value<string>(); + } + } + + private void SaveOptions() + { + var header = new Dictionary<string, object>(); + header.Add("Date", DateTime.Now.ToUniversalTime().ToString("o")); + header.Add("AppVersion", "4"); + header.Add("FileVersion", "4"); + + var body = new Dictionary<string, object>(); + body.Add("WriteModData", WriteModData); + body.Add("ValidateRunData", ValidateData); + body.Add("WriteModData1Hz", WriteModData1Hz); + body.Add("WriteActualModData", WriteActualModData); + body.Add("OutputDirectory", OutputDirectory); + + JSONFileWriter.WriteFile(new Dictionary<string, object>() { { "Header", header }, { "Body", body } }, SETTINGS_FILE); + } + private void LogMethod(LogEventInfo evtInfo, object[] objects) { if (!SimulationWorker.IsBusy || SimulationWorker.CancellationPending) { @@ -596,7 +640,6 @@ namespace VECTO3GUI.ViewModel.Impl } } - #endregion private object GetBusJobViewModel(JobType jobType, JobEntry jobEntry = null) @@ -801,6 +844,7 @@ namespace VECTO3GUI.ViewModel.Impl private void RunVectoSimulation(object theSender, DoWorkEventArgs e) { + SaveOptions(); var sender = theSender as BackgroundWorker; if (sender == null) { return; @@ -1100,6 +1144,14 @@ namespace VECTO3GUI.ViewModel.Impl #endregion + #region Implementation of IMainView + + public void Closing(object sender, CancelEventArgs e) + { + SaveOptions(); + } + + #endregion } public static class MsgTypeExtensions { diff --git a/VECTO3GUI/ViewModel/Interfaces/IMainView.cs b/VECTO3GUI/ViewModel/Interfaces/IMainView.cs index 4d93aaa2caa1796b8ae88a52abf391874b0bd50c..5fced290bfa93a3f8d516e04549e12dd29a1bfac 100644 --- a/VECTO3GUI/ViewModel/Interfaces/IMainView.cs +++ b/VECTO3GUI/ViewModel/Interfaces/IMainView.cs @@ -1,4 +1,8 @@ -namespace VECTO3GUI.ViewModel.Interfaces { +using System.ComponentModel; + +namespace VECTO3GUI.ViewModel.Interfaces { public interface IMainView - { } + { + void Closing(object sender, CancelEventArgs e); + } } \ No newline at end of file diff --git a/VECTO3GUI/Views/JoblistView.xaml b/VECTO3GUI/Views/JoblistView.xaml index 5801e5900ef30abef806b66bdf240905e2cf6e25..ab57a6c936fa576c98203194c5dd6700b74dd671 100644 --- a/VECTO3GUI/Views/JoblistView.xaml +++ b/VECTO3GUI/Views/JoblistView.xaml @@ -11,7 +11,8 @@ xmlns:vecto3Gui="clr-namespace:VECTO3GUI" mc:Ignorable="d" d:DesignHeight="400" d:DesignWidth="600" - d:DataContext="{d:DesignInstance Type=impl:JoblistViewModel, IsDesignTimeCreatable=False}"> + d:DataContext="{d:DesignInstance Type=impl:JoblistViewModel, IsDesignTimeCreatable=False}" + > <d:JoblistView.DataContext> <x:Type Type="interfaces:IJoblistViewModel"/>