Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit f1d362fc authored by Markus QUARITSCH's avatar Markus QUARITSCH
Browse files

setting xml directory to path for non-development environment

adding load/saving of options in options tab
parent 022652d9
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -33,6 +33,7 @@ namespace VECTO3GUI
{
InitializeComponent();
DataContext = viewModel;
Closing += viewModel.CurrentViewModel.Closing;
}
}
}
......@@ -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);
}
......
......@@ -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
{
......
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
......@@ -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"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment