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

Skip to content
Snippets Groups Projects
Commit c1c5205d authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

Merge branch 'feature/VECTO_GUI' of git+ssh://129.27.107.191:2211/vecto-dev into feature/VECTO_GUI

parents 1c5e4a76 17b28e59
No related branches found
No related tags found
No related merge requests found
Showing
with 770 additions and 28 deletions
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<configSections> <configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="VECTO3GUI.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="VECTO3GUI.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup> </sectionGroup>
</configSections> </configSections>
......
...@@ -11,8 +11,9 @@ namespace VECTO3GUI.Helper.Converter ...@@ -11,8 +11,9 @@ namespace VECTO3GUI.Helper.Converter
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{ {
var jobEntry = (ViewModel.Impl.JobEntry)((ListViewItem)value)?.Content; //var jobEntry = (ViewModel.Impl.JobEntry)((ListViewItem)value)?.Content;
return jobEntry != null && jobEntry.Selected; //return jobEntry != null && jobEntry.Selected;
return value;
} }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
......
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Interactivity;
namespace VECTO3GUI.Helper
{
public class EventCommandExecuter : TriggerAction<DependencyObject>
{
#region Constructors
public EventCommandExecuter()
: this(CultureInfo.CurrentCulture)
{
}
public EventCommandExecuter(CultureInfo culture)
{
Culture = culture;
}
#endregion
#region Properties
#region Command
public ICommand Command
{
get { return (ICommand)GetValue(CommandProperty); }
set { SetValue(CommandProperty, value); }
}
public static readonly DependencyProperty CommandProperty =
DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(EventCommandExecuter), new PropertyMetadata(null));
#endregion
#region EventArgsConverterParameter
public object EventArgsConverterParameter
{
get { return (object)GetValue(EventArgsConverterParameterProperty); }
set { SetValue(EventArgsConverterParameterProperty, value); }
}
public static readonly DependencyProperty EventArgsConverterParameterProperty =
DependencyProperty.Register(nameof(EventArgsConverterParameter), typeof(object), typeof(EventCommandExecuter), new PropertyMetadata(null));
#endregion
public IValueConverter EventArgsConverter { get; set; }
public CultureInfo Culture { get; set; }
#endregion
protected override void Invoke(object parameter)
{
var cmd = Command;
if (cmd != null)
{
var param = parameter;
if (EventArgsConverter != null)
{
param = EventArgsConverter.Convert(parameter, typeof(object), EventArgsConverterParameter, CultureInfo.InvariantCulture);
}
if (cmd.CanExecute(param))
{
cmd.Execute(param);
}
}
}
}
}
...@@ -3,6 +3,8 @@ using System.Collections.Generic; ...@@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
namespace VECTO3GUI.Helper namespace VECTO3GUI.Helper
{ {
...@@ -29,5 +31,29 @@ namespace VECTO3GUI.Helper ...@@ -29,5 +31,29 @@ namespace VECTO3GUI.Helper
return currentObj; return currentObj;
} }
public static XmlDocument ToXmlDocument(this XDocument xDocument)
{
var xmlDocument = new XmlDocument();
using (var reader = xDocument.CreateReader())
{
xmlDocument.Load(reader);
}
var xDeclaration = xDocument.Declaration;
if (xDeclaration != null)
{
var xmlDeclaration = xmlDocument.CreateXmlDeclaration(
xDeclaration.Version,
xDeclaration.Encoding,
xDeclaration.Standalone);
xmlDocument.InsertBefore(xmlDeclaration, xmlDocument.FirstChild);
}
return xmlDocument;
}
} }
} }
...@@ -13,16 +13,21 @@ namespace VECTO3GUI.Helper ...@@ -13,16 +13,21 @@ namespace VECTO3GUI.Helper
{ {
public static class FileDialogHelper public static class FileDialogHelper
{ {
private const string XMLFilter = "XML Files (*.xml)|*.xml|All Files (*.*)|*.*"; public const string XMLFilter = "XML Files (*.xml)|*.xml|All Files (*.*)|*.*";
public const string JobFilter = "Job Files (*.vectojob|*.vectojob|All Files (*.*)|*.*";
public static string[] ShowSelectFilesDialog(bool multiselect)
public static string[] ShowSelectFilesDialog(bool multiselect, string initialDirectory = null) {
return ShowSelectFilesDialog(multiselect, XMLFilter);
}
public static string[] ShowSelectFilesDialog(bool multiselect, string filter = XMLFilter, string initialDirectory = null)
{ {
using (var openFileDialog = new OpenFileDialog()) using (var openFileDialog = new OpenFileDialog())
{ {
openFileDialog.InitialDirectory = initialDirectory; openFileDialog.InitialDirectory = initialDirectory;
openFileDialog.Multiselect = multiselect; openFileDialog.Multiselect = multiselect;
openFileDialog.Filter = XMLFilter; openFileDialog.Filter = filter;
var result = openFileDialog.ShowDialog(); var result = openFileDialog.ShowDialog();
if (result == DialogResult.OK) if (result == DialogResult.OK)
...@@ -33,8 +38,7 @@ namespace VECTO3GUI.Helper ...@@ -33,8 +38,7 @@ namespace VECTO3GUI.Helper
return null; return null;
} }
public static string ShowSelectDirectoryDialog(string initialDirectory = null) public static string ShowSelectDirectoryDialog(string initialDirectory = null)
{ {
using (var dialog = new CommonOpenFileDialog()) using (var dialog = new CommonOpenFileDialog())
...@@ -52,6 +56,27 @@ namespace VECTO3GUI.Helper ...@@ -52,6 +56,27 @@ namespace VECTO3GUI.Helper
return null; return null;
} }
public static string SaveXmlFileToDialog(string initialDirectory = null)
{
return SaveToDialog(initialDirectory, XMLFilter);
}
public static string SaveJobFileToDialog(string initialDirectory = null)
{
return SaveToDialog(initialDirectory, JobFilter);
}
private static string SaveToDialog(string initialDirectory, string filter)
{
var saveFileDialog = new SaveFileDialog
{
Filter = filter
};
if (initialDirectory != null)
saveFileDialog.InitialDirectory = initialDirectory;
return saveFileDialog.ShowDialog() == true ? saveFileDialog.FileName : null;
}
} }
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MahApps.Metro.Controls.Dialogs;
namespace VECTO3GUI.Helper
{
public static class MetroDialogHelper
{
public static MessageDialogResult GetModalDialogBox(object viewModel, string title, string message,
MetroDialogSettings settings)
{
return GetModalDialogBox(viewModel, title, message, MessageDialogStyle.AffirmativeAndNegative, settings);
}
public static MessageDialogResult GetModalDialogBox(object viewModel, string title, string message,
MessageDialogStyle style = MessageDialogStyle.AffirmativeAndNegative, MetroDialogSettings settings = null)
{
var coordinator = DialogCoordinator.Instance;
return coordinator.ShowModalMessageExternal(viewModel, title, message, style, settings);
}
}
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using Castle.Core.Internal;
namespace VECTO3GUI.Helper
{
public class ObservableCollectionEx<T> : ObservableCollection<T>
{
public event PropertyChangedEventHandler CollectionItemChanged;
public ObservableCollectionEx()
{
CollectionChanged += FullObservableCollectionCollectionChanged;
}
public ObservableCollectionEx(IEnumerable<T> items) : this()
{
if (items == null)
return;
foreach (var item in items) {
Add(item);
}
}
public ObservableCollectionEx(IList<T> items) : this()
{
if(items.IsNullOrEmpty())
return;
for (int i = 0; i < items.Count; i++) {
Add(items[i]);
}
}
private void FullObservableCollectionCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.NewItems != null)
{
foreach (object item in e.NewItems)
{
((INotifyPropertyChanged)item).PropertyChanged += ItemPropertyChanged;
}
}
if (e.OldItems != null)
{
foreach (object item in e.OldItems)
{
((INotifyPropertyChanged)item).PropertyChanged -= ItemPropertyChanged;
}
}
}
private void ItemPropertyChanged(object sender, PropertyChangedEventArgs e)
{
CollectionItemChanged?.Invoke(sender, e);
var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, sender, sender, IndexOf((T)sender));
OnCollectionChanged(args);
}
}
}
...@@ -19,7 +19,7 @@ namespace VECTO3GUI.Helper ...@@ -19,7 +19,7 @@ namespace VECTO3GUI.Helper
} }
public static OutputWindow CreateOutputWindow(IKernel kernel, object viewModel, public static OutputWindow CreateOutputWindow(IKernel kernel, object viewModel,
string windowName,double width = default(double), double height = default(double), string windowName, double width = default(double), double height = default(double),
ResizeMode resizeMode = ResizeMode.CanResize) ResizeMode resizeMode = ResizeMode.CanResize)
{ {
var window = CreateWindow(kernel, viewModel, windowName, width, height); var window = CreateWindow(kernel, viewModel, windowName, width, height);
......
using System;
using System.Collections.Generic;
using System.IO;
using Castle.Core.Internal;
using Newtonsoft.Json;
namespace VECTO3GUI.Helper
{
public static class SerializeHelper
{
public static void SerializeToFile<T>(string filePath, T file)
{
if (filePath.IsNullOrEmpty() || file == null)
return;
var serializedObject = JsonConvert.SerializeObject(file, Formatting.Indented);
File.WriteAllText(filePath, serializedObject);
}
public static T DeserializeToObject<T>(string filePath)
{
if (filePath.IsNullOrEmpty())
return default(T);
using (var file = File.OpenText(filePath)) {
var serializer = new JsonSerializer();
var result = serializer.Deserialize(file,typeof(T));
if (result == null)
return default(T);
return (T)result;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interactivity;
namespace VECTO3GUI.Helper
{
/// Taken from https://stackoverflow.com/a/17715402
/// <summary>
/// Regular expression for Textbox with properties:
/// <see cref="RegularExpression"/>,
/// <see cref="MaxLength"/>,
/// <see cref="EmptyValue"/>.
/// </summary>
public class TextBoxInputRegExBehaviour : Behavior<TextBox>
{
#region DependencyProperties
public static readonly DependencyProperty RegularExpressionProperty =
DependencyProperty.Register("RegularExpression", typeof(string), typeof(TextBoxInputRegExBehaviour), new FrameworkPropertyMetadata(".*"));
public string RegularExpression
{
get { return (string)GetValue(RegularExpressionProperty); }
set { SetValue(RegularExpressionProperty, value); }
}
public static readonly DependencyProperty MaxLengthProperty =
DependencyProperty.Register("MaxLength", typeof(int), typeof(TextBoxInputRegExBehaviour),
new FrameworkPropertyMetadata(int.MinValue));
public int MaxLength
{
get { return (int)GetValue(MaxLengthProperty); }
set { SetValue(MaxLengthProperty, value); }
}
public static readonly DependencyProperty EmptyValueProperty =
DependencyProperty.Register("EmptyValue", typeof(string), typeof(TextBoxInputRegExBehaviour), null);
public string EmptyValue
{
get { return (string)GetValue(EmptyValueProperty); }
set { SetValue(EmptyValueProperty, value); }
}
#endregion
/// <summary>
/// Attach our behaviour. Add event handlers
/// </summary>
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.PreviewTextInput += PreviewTextInputHandler;
AssociatedObject.PreviewKeyDown += PreviewKeyDownHandler;
DataObject.AddPastingHandler(AssociatedObject, PastingHandler);
}
/// <summary>
/// Deattach our behaviour. remove event handlers
/// </summary>
protected override void OnDetaching()
{
base.OnDetaching();
AssociatedObject.PreviewTextInput -= PreviewTextInputHandler;
AssociatedObject.PreviewKeyDown -= PreviewKeyDownHandler;
DataObject.RemovePastingHandler(AssociatedObject, PastingHandler);
}
#region Event handlers [PRIVATE] --------------------------------------
void PreviewTextInputHandler(object sender, TextCompositionEventArgs e)
{
string text;
if (this.AssociatedObject.Text.Length < this.AssociatedObject.CaretIndex)
text = this.AssociatedObject.Text;
else
{
// Remaining text after removing selected text.
string remainingTextAfterRemoveSelection;
text = TreatSelectedText(out remainingTextAfterRemoveSelection)
? remainingTextAfterRemoveSelection.Insert(AssociatedObject.SelectionStart, e.Text)
: AssociatedObject.Text.Insert(this.AssociatedObject.CaretIndex, e.Text);
}
e.Handled = !ValidateText(text);
}
/// <summary>
/// PreviewKeyDown event handler
/// </summary>
void PreviewKeyDownHandler(object sender, KeyEventArgs e)
{
if (string.IsNullOrEmpty(this.EmptyValue))
return;
string text = null;
// Handle the Backspace key
if (e.Key == Key.Back)
{
if (!this.TreatSelectedText(out text))
{
if (AssociatedObject.SelectionStart > 0)
text = this.AssociatedObject.Text.Remove(AssociatedObject.SelectionStart - 1, 1);
}
}
// Handle the Delete key
else if (e.Key == Key.Delete)
{
// If text was selected, delete it
if (!this.TreatSelectedText(out text) && this.AssociatedObject.Text.Length > AssociatedObject.SelectionStart)
{
// Otherwise delete next symbol
text = this.AssociatedObject.Text.Remove(AssociatedObject.SelectionStart, 1);
}
}
if (text == string.Empty)
{
this.AssociatedObject.Text = this.EmptyValue;
if (e.Key == Key.Back)
AssociatedObject.SelectionStart++;
e.Handled = true;
}
}
private void PastingHandler(object sender, DataObjectPastingEventArgs e)
{
if (e.DataObject.GetDataPresent(DataFormats.Text))
{
string text = Convert.ToString(e.DataObject.GetData(DataFormats.Text));
if (!ValidateText(text))
e.CancelCommand();
}
else
e.CancelCommand();
}
#endregion Event handlers [PRIVATE] -----------------------------------
#region Auxiliary methods [PRIVATE] -----------------------------------
/// <summary>
/// Validate certain text by our regular expression and text length conditions
/// </summary>
/// <param name="text"> Text for validation </param>
/// <returns> True - valid, False - invalid </returns>
private bool ValidateText(string text)
{
return (new Regex(this.RegularExpression, RegexOptions.IgnoreCase)).IsMatch(text) && (MaxLength == int.MinValue || text.Length <= MaxLength);
}
/// <summary>
/// Handle text selection
/// </summary>
/// <returns>true if the character was successfully removed; otherwise, false. </returns>
private bool TreatSelectedText(out string text)
{
text = null;
if (AssociatedObject.SelectionLength <= 0)
return false;
var length = this.AssociatedObject.Text.Length;
if (AssociatedObject.SelectionStart >= length)
return true;
if (AssociatedObject.SelectionStart + AssociatedObject.SelectionLength >= length)
AssociatedObject.SelectionLength = length - AssociatedObject.SelectionStart;
text = this.AssociatedObject.Text.Remove(AssociatedObject.SelectionStart, AssociatedObject.SelectionLength);
return true;
}
#endregion Auxiliary methods [PRIVATE] --------------------------------
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using Castle.Core.Internal;
using VECTO3GUI.ViewModel.Impl;
namespace VECTO3GUI.Helper
{
public class ViewModelBase : ObservableObject, INotifyDataErrorInfo
{
private readonly Dictionary<string, List<string>> _errors = new Dictionary<string, List<string>>();
public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;
public IEnumerable GetErrors(string propertyName)
{
if (propertyName.IsNullOrEmpty())
return null;
return _errors.ContainsKey(propertyName) ? _errors[propertyName] : null;
}
public bool HasErrors
{
get
{
return _errors.Count > 0;
}
}
public bool IsValid
{
get
{
return !HasErrors;
}
}
public void AddPropertyError(string propertyName, string error)
{
if (_errors.ContainsKey(propertyName))
_errors[propertyName].Add(error);
else
_errors[propertyName] = new List<string>() { error };
NotifyErrorsChanged(propertyName);
}
public void RemovePropertyError(string propertyName)
{
if (_errors.ContainsKey(propertyName))
_errors.Remove(propertyName);
NotifyErrorsChanged(propertyName);
}
public void NotifyErrorsChanged(string propertyName)
{
ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(propertyName));
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Resources;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.InputData.FileIO.XML.Common;
using VECTO3GUI.Model.TempDataObject;
namespace VECTO3GUI.Helper
{
public class XmlComponentReaderHelper : AbstractXMLType
{
public XmlComponentReaderHelper(XmlNode node) : base(node) { }
public AirdragComponentData GetAirdragComponentData()
{
if (!ElementExists(XMLNames.Component_AirDrag))
return null;
return new AirdragComponentData {
Manufacturer = GetString(XMLNames.Component_Manufacturer),
Model = GetString(XMLNames.Component_Model),
CertificationNumber = GetString(XMLNames.Component_CertificationNumber),
Date = DateTime.Parse(GetString(XMLNames.Component_Date)).ToUniversalTime(),
AppVersion = GetString(XMLNames.Component_AppVersion),
CdxA_0 = GetDouble("CdxA_0").SI<SquareMeter>(),
TransferredCdxA = GetDouble("TransferredCdxA").SI<SquareMeter>(),
DeclaredCdxA = GetDouble(XMLNames.AirDrag_DeclaredCdxA).SI<SquareMeter>(),
DigestValue = new DigestData(GetNode(XMLNames.DI_Signature))
};
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using Castle.Core.Internal;
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Resources;
using TUGraz.VectoCore.Utils;
namespace VECTO3GUI.Helper
{
public static class XmlHelper
{
public static XmlDocument ReadXmlDocument(string filePath)
{
if (filePath.IsNullOrEmpty())
return null;
var xmlDocument = new XmlDocument();
using (var reader = new XmlTextReader(filePath)) {
xmlDocument.Load(reader);
}
return xmlDocument;
}
public static XmlNodeList GetComponentNodes(XmlDocument xmlDocument, string parentNode, string nodeName)
{
if (xmlDocument == null || parentNode.IsNullOrEmpty() || nodeName.IsNullOrEmpty())
return null;
return xmlDocument.SelectNodes($"//*[local-name()='{parentNode}']//*[local-name()='{nodeName}']");
}
public static bool ValidateXDocument(XDocument xDocument)
{
var xmlDocument = xDocument.ToXmlDocument();
if (xmlDocument == null)
return false;
var documentType = XMLHelper.GetDocumentType(xmlDocument.DocumentElement.LocalName);
if (documentType == null)
{
throw new VectoException("unknown xml file! {0}", xmlDocument.DocumentElement.LocalName);
}
var validator = new XMLValidator(xmlDocument, null, XMLValidator.CallBackExceptionOnError);
return validator.ValidateXML(documentType.Value); ;
}
}
}
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
xmlns:interfaces="clr-namespace:VECTO3GUI.ViewModel.Interfaces" xmlns:interfaces="clr-namespace:VECTO3GUI.ViewModel.Interfaces"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:impl="clr-namespace:VECTO3GUI.ViewModel.Impl" xmlns:impl="clr-namespace:VECTO3GUI.ViewModel.Impl"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:views="clr-namespace:VECTO3GUI.Views"
mc:Ignorable="d" mc:Ignorable="d"
Title="VECTO 3" Height="515.36" Width="972.48" WindowStartupLocation="CenterScreen" Title="{Binding Version}" Height="515.36" Width="972.48" WindowStartupLocation="CenterScreen"
d:DataContext="{d:DesignInstance Type=impl:MainWindowViewModel, IsDesignTimeCreatable=False}"> d:DataContext="{d:DesignInstance Type=impl:MainWindowViewModel, IsDesignTimeCreatable=False}">
<Grid> <Grid>
...@@ -22,28 +24,40 @@ ...@@ -22,28 +24,40 @@
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<Menu IsMainMenu="True" Style="{DynamicResource MetroMenu}"> <Menu IsMainMenu="True" Style="{DynamicResource MetroMenu}">
<MenuItem Header="File"> <MenuItem Header="File" VerticalAlignment="Center">
<MenuItem Header="New" Style="{DynamicResource MetroMenuItem}" Margin="0"
Command="{Binding CurrentViewModel.CreateNewJob}"/> <MenuItem Header="Add Job" Command="{Binding CurrentViewModel.AddJob}"/>
<MenuItem Header="Edit" Style="{DynamicResource MetroMenuItem}" Margin="0" <MenuItem Header="Edit Job"
Command="{Binding CurrentViewModel.EditJob}"/> Command="{Binding CurrentViewModel.EditJob}"
<Separator HorizontalAlignment="Stretch" Background="Gray"/> CommandParameter="{Binding CurrentViewModel.SelectedJobEntry}"/>
<MenuItem Header="Open" Command="{Binding CurrentViewModel.AddJob}"/> <MenuItem Header="Remove Job"
<MenuItem Header="Open Folder"/> Command="{Binding CurrentViewModel.RemoveJob}"
CommandParameter="{Binding CurrentViewModel.SelectedJobEntry}"/>
<Separator HorizontalAlignment="Stretch" Background="Gray"/> <Separator HorizontalAlignment="Stretch" Background="Gray"/>
<MenuItem Header="Exit" Command="{Binding CurrentViewModel.ExitMainCommand}" <MenuItem Header="Exit" Command="{Binding CurrentViewModel.ExitMainCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/> CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
</MenuItem> </MenuItem>
<MenuItem Header="Settings">
<MenuItem Header="Default Settings"
<MenuItem Header="Tools" VerticalAlignment="Center">
<!--<MenuItem.Icon>
<iconPacks:PackIconModern Width="15" Height="15" Kind="Tools" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Green" />
</MenuItem.Icon>-->
<MenuItem Header="Create Single Bus Job"
Command="{Binding CurrentViewModel.AddBusJob}" CommandParameter="{Binding Source={x:Static impl:JobType.SingleBusJob}}"/>
<MenuItem Header="Create Completed Bus Job"
Command="{Binding CurrentViewModel.AddBusJob}" CommandParameter="{Binding Source={x:Static impl:JobType.CompletedBusJob}}"/>
<MenuItem Header="Create Completed XML"
Command="{Binding CurrentViewModel.CreateNewJob}"/>
<Separator HorizontalAlignment="Stretch" Background="Gray"/>
<MenuItem Header="Settings"
Command="{Binding CurrentViewModel.OpenSettings}"/> Command="{Binding CurrentViewModel.OpenSettings}"/>
</MenuItem> </MenuItem>
<MenuItem Header="Help">
<MenuItem Header="User Manual"/> <MenuItem Header="Help" VerticalAlignment="Center">
<MenuItem Header="About Vecto"/> <MenuItem Header="About Vecto"/>
<MenuItem Header="Relase Notes"/>
</MenuItem> </MenuItem>
</Menu> </Menu>
......
using System;
using System.Collections.Generic;
using System.IO;
using Castle.Core.Internal;
using VECTO3GUI.Helper;
using VECTO3GUI.ViewModel.Impl;
namespace VECTO3GUI.Model
{
public class JobListEntry
{
public bool IsSelected { get; set; }
public string JobFilePath { get; set; }
}
public class JobListModel
{
private const string ConfigFolderName = "Config";
private const string JobListFileName = "JobList.txt";
private string _jobListFilePath = Path.Combine(".", ConfigFolderName, JobListFileName);
public List<JobListEntry> JobList { get; set; }
public JobListModel()
{
SetConfigFolder();
LoadJobList();
}
private void SetConfigFolder()
{
if (!Directory.Exists($"./{ConfigFolderName}")) {
Directory.CreateDirectory($"{ConfigFolderName}");
}
}
private void LoadJobList()
{
var jobList = new List<JobListEntry>();
if (File.Exists(_jobListFilePath))
jobList = SerializeHelper.DeserializeToObject<List<JobListEntry>>(_jobListFilePath);
JobList = jobList;
}
public void SaveJobList(IList<JobEntry> jobEntries)
{
SetJobList(jobEntries);
SerializeHelper.SerializeToFile(_jobListFilePath, JobList);
}
private void SetJobList(IList<JobEntry> jobEntries)
{
if (jobEntries == null)
return;
JobList = new List<JobListEntry>();
for (int i = 0; i < jobEntries.Count; i++) {
JobList.Add
(
new JobListEntry
{
IsSelected = jobEntries[i].Selected,
JobFilePath = jobEntries[i].JobEntryFilePath
}
);
}
}
public IList<JobEntry> GetJobEntries()
{
var jobEntries = new List<JobEntry>();
if (JobList.IsNullOrEmpty())
return jobEntries;
for (int i = 0; i < JobList.Count; i++) {
var jobEntry = SerializeHelper.DeserializeToObject<JobEntry>(JobList[i].JobFilePath);
if(jobEntry != null)
jobEntries.Add(jobEntry);
}
return jobEntries;
}
}
}
...@@ -27,6 +27,7 @@ namespace VECTO3GUI.Model.TempDataObject ...@@ -27,6 +27,7 @@ namespace VECTO3GUI.Model.TempDataObject
#endregion #endregion
public AirdragComponentData(){}
public AirdragComponentData(IAirdragViewModel viewModel , bool defaultValues) public AirdragComponentData(IAirdragViewModel viewModel , bool defaultValues)
{ {
......
...@@ -28,6 +28,7 @@ namespace VECTO3GUI.Model.TempDataObject ...@@ -28,6 +28,7 @@ namespace VECTO3GUI.Model.TempDataObject
public bool HeatPump { get; set; } public bool HeatPump { get; set; }
public bool AdjustableAuxiliaryHeater { get; set; } public bool AdjustableAuxiliaryHeater { get; set; }
public bool SeparateAirDistributionDucts { get; set; } public bool SeparateAirDistributionDucts { get; set; }
public ConsumerTechnology DoorDriveTechnology { get; set; }
#endregion #endregion
...@@ -63,6 +64,7 @@ namespace VECTO3GUI.Model.TempDataObject ...@@ -63,6 +64,7 @@ namespace VECTO3GUI.Model.TempDataObject
viewModel.HeatPump = HeatPump; viewModel.HeatPump = HeatPump;
viewModel.AdjustableAuxiliaryHeater = AdjustableAuxiliaryHeater; viewModel.AdjustableAuxiliaryHeater = AdjustableAuxiliaryHeater;
viewModel.SeparateAirDistributionDucts = SeparateAirDistributionDucts; viewModel.SeparateAirDistributionDucts = SeparateAirDistributionDucts;
viewModel.DoorDriveTechnology = viewModel.DoorDriveTechnology;
} }
public void ClearValues(IAuxiliariesViewModel viewModel) public void ClearValues(IAuxiliariesViewModel viewModel)
...@@ -81,6 +83,7 @@ namespace VECTO3GUI.Model.TempDataObject ...@@ -81,6 +83,7 @@ namespace VECTO3GUI.Model.TempDataObject
viewModel.HeatPump = default(bool); viewModel.HeatPump = default(bool);
viewModel.AdjustableAuxiliaryHeater = default(bool); viewModel.AdjustableAuxiliaryHeater = default(bool);
viewModel.SeparateAirDistributionDucts = default(bool); viewModel.SeparateAirDistributionDucts = default(bool);
viewModel.DoorDriveTechnology = ConsumerTechnology.Pneumatically;
} }
private void SetValues(IAuxiliariesViewModel auxiliaries) private void SetValues(IAuxiliariesViewModel auxiliaries)
...@@ -99,6 +102,7 @@ namespace VECTO3GUI.Model.TempDataObject ...@@ -99,6 +102,7 @@ namespace VECTO3GUI.Model.TempDataObject
HeatPump = auxiliaries.HeatPump; HeatPump = auxiliaries.HeatPump;
AdjustableAuxiliaryHeater = auxiliaries.AdjustableAuxiliaryHeater; AdjustableAuxiliaryHeater = auxiliaries.AdjustableAuxiliaryHeater;
SeparateAirDistributionDucts = auxiliaries.SeparateAirDistributionDucts; SeparateAirDistributionDucts = auxiliaries.SeparateAirDistributionDucts;
DoorDriveTechnology = auxiliaries.DoorDriveTechnology;
} }
} }
......
<?xml version="1.0" encoding="utf-8"?>
<tns:VectoInputDeclaration xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" xmlns:tns="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v1.0" xmlns:di="http://www.w3.org/2000/09/xmldsig#" schemaVersion="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v1.0 https://webgate.ec.europa.eu/CITnet/svn/VECTO/trunk/Share/XML/XSD/VectoComponent.xsd">
<tns:AirDrag>
<Data id="TestAirDrag1234" xsi:type="AirDragDataDeclarationType">
<Manufacturer>Test AirDrag Manufacturer</Manufacturer>
<Model>Test AirDrag Model</Model>
<CertificationNumber>e12*0815/8051*2020/05E0000*66</CertificationNumber>
<Date>2020-04-28T09:16:15.1270795Z</Date>
<AppVersion>Vecto AirDrag Test Load</AppVersion>
<CdxA_0>6.12</CdxA_0>
<TransferredCdxA>7.12</TransferredCdxA>
<DeclaredCdxA>8.12</DeclaredCdxA>
</Data>
<Signature>
<di:Reference URI="#TestAirDrag1234">
<di:Transforms>
<di:Transform Algorithm="urn:vecto:xml:2017:canonicalization" />
<di:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</di:Transforms>
<di:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
<di:DigestValue>Yd3UDJ/zKPhsmPadJeC4Ez/q7o3G82Zbq3mX3tSqLDw=</di:DigestValue>
</di:Reference>
</Signature>
</tns:AirDrag>
</tns:VectoInputDeclaration>
\ No newline at end of file
...@@ -56,7 +56,13 @@ ...@@ -56,7 +56,13 @@
<Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/>
</Style> </Style>
<Style x:Key="textBoxInError" TargetType="{x:Type TextBox}" BasedOn="{StaticResource MetroTextBox}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary> </ResourceDictionary>
\ No newline at end of file
...@@ -23,7 +23,9 @@ ...@@ -23,7 +23,9 @@
<views:SettingsView/> <views:SettingsView/>
</DataTemplate> </DataTemplate>
<DataTemplate DataType="{x:Type impl:AbstractBusJobViewModel}">
<views:BusJobView/>
</DataTemplate>
<DataTemplate DataType="{x:Type impl:EngineOnlyJobViewModel}"> <DataTemplate DataType="{x:Type impl:EngineOnlyJobViewModel}">
<views:JobEditView/> <views:JobEditView/>
......
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