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

Skip to content
Snippets Groups Projects
Commit 606c12a4 authored by Franz KOBER josef's avatar Franz KOBER josef
Browse files

added double click, changes correct folder at job edit

parent 6366298e
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ namespace VECTO3GUI.Helper
public static class FileDialogHelper
{
public const string XMLFilter = "XML Files (*.xml)|*.xml|All Files (*.*)|*.*";
public const string JobFilter = "Job Files (*.vectojob|*.vectojob|All Files (*.*)|*.*";
public const string JobFilter = "Vecto Files (*.vecto|*.vecto|All Files (*.*)|*.*";
public static string[] ShowSelectFilesDialog(bool multiselect)
{
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
......@@ -23,7 +23,7 @@ namespace VECTO3GUI.ViewModel.Impl
{
CompletedBusFile,
PrimaryBusFile,
PIFBusFile
PIFBusFile,
}
public static class JobFileTypeHelper
......@@ -67,6 +67,7 @@ namespace VECTO3GUI.ViewModel.Impl
protected SettingsModel Settings { get; private set; }
protected JobType JobType;
protected JobEntry JobEntry;
private readonly bool _editJob;
#endregion
......@@ -147,6 +148,8 @@ namespace VECTO3GUI.ViewModel.Impl
private void SetJobEntryData(JobEntry jobEntry)
{
JobEntry = jobEntry;
FirstFilePath = jobEntry.Header.JobType == JobType.SingleBusJob
? jobEntry.Body.PrimaryVehicle
: jobEntry.Body.PrimaryVehicleResults;
......@@ -167,7 +170,7 @@ namespace VECTO3GUI.ViewModel.Impl
}
private void DoSelectFirstFileCommand(JobFileType jobFileType)
{
FirstFilePath = OpenFileSelector(jobFileType, nameof(FirstFilePath));
FirstFilePath = OpenFileSelector(jobFileType, nameof(FirstFilePath), FirstFilePath);
}
public ICommand SelectSecondFileCommand
......@@ -180,7 +183,7 @@ namespace VECTO3GUI.ViewModel.Impl
}
private void DoSelectSecondFileCommand(JobFileType jobFileType)
{
SecondFilePath = OpenFileSelector(jobFileType, nameof(SecondFilePath));
SecondFilePath = OpenFileSelector(jobFileType, nameof(SecondFilePath), SecondFilePath);
}
public ICommand CancelCommand
......@@ -253,23 +256,46 @@ namespace VECTO3GUI.ViewModel.Impl
}
private string OpenFileSelector(JobFileType jobFileType, string textPropertyName)
private string OpenFileSelector(JobFileType jobFileType, string textPropertyName, string filePath)
{
var dialogResult = FileDialogHelper.ShowSelectFilesDialog(false, FileDialogHelper.XMLFilter, Settings.XmlFilePathFolder);
if (dialogResult == null)
return null;
var folderPath = GetFolderPath(filePath);
var filePath = dialogResult.FirstOrDefault();
var validationResult = IsValideXml(jobFileType, filePath);
var dialogResult = FileDialogHelper.ShowSelectFilesDialog(false, FileDialogHelper.XMLFilter, folderPath);
if (dialogResult != null) {
if (!validationResult)
AddPropertyError(textPropertyName, $"Selected XML-File is not a valid {jobFileType.GetLable()}!");
else
RemovePropertyError(textPropertyName);
filePath = dialogResult.FirstOrDefault();
var validationResult = IsValideXml(jobFileType, filePath);
if (!validationResult)
AddPropertyError(textPropertyName, $"Selected XML-File is not a valid {jobFileType.GetLable()}!");
else
RemovePropertyError(textPropertyName);
return !validationResult ? null : filePath;
return !validationResult ? null : filePath;
}
return filePath;
}
private string GetFolderPath(string filePath)
{
if (!_editJob || filePath.IsNullOrEmpty())
return Settings.XmlFilePathFolder;
if (IsFileName(filePath)) {
return !JobEntry.JobEntryFilePath.IsNullOrEmpty()
? Path.GetDirectoryName(JobEntry.JobEntryFilePath)
: Path.GetDirectoryName(Settings.XmlFilePathFolder);
}
return filePath;
}
private bool IsFileName( string filePath)
{
return !Directory.Exists(filePath);
}
private bool IsValideXml(JobFileType jobFileType, string filePath)
{
if (filePath.IsNullOrEmpty())
......
......@@ -48,6 +48,7 @@ namespace VECTO3GUI.ViewModel.Impl
private ICommand _moveJobDownCommand;
private ICommand _startSimulationCommand;
private ICommand _openInFolderCommand;
private ICommand _doubleClickCommand;
#endregion
......@@ -125,6 +126,19 @@ namespace VECTO3GUI.ViewModel.Impl
#region Commands
public ICommand DoubleClickCommand
{
get { return _doubleClickCommand ?? (_doubleClickCommand = new RelayCommand<JobEntry>(DoDoubleClick)); }
}
private void DoDoubleClick(JobEntry jobEntry)
{
if (!CanEditCompletdFile(jobEntry))
return;
DoEditJob(jobEntry);
}
public ICommand RemoveJob
{
get
......
......@@ -23,5 +23,7 @@ namespace VECTO3GUI.ViewModel.Interfaces
ICommand OpenSettings { get; }
ICommand ExitMainCommand { get; }
ICommand OpenInFolder { get; }
ICommand DoubleClickCommand { get; }
}
}
......@@ -34,7 +34,7 @@
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
<MenuItem Header="Save to" Command="{Binding SaveToJob}"/>
<Separator HorizontalAlignment="Stretch" Background="Gray"/>
<MenuItem Header="Exit"
<MenuItem Header="Close"
Command="{Binding CloseJob}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
</MenuItem>
......
......@@ -64,7 +64,16 @@
<DataGrid x:Name="JobList" ItemsSource="{Binding Jobs}"
SelectedValue="{Binding DataContext.SelectedJobEntry, RelativeSource={RelativeSource AncestorType=views:JoblistView}}"
Style="{DynamicResource AzureDataGrid}" BorderThickness="1" CanUserAddRows="False" AutoGenerateColumns="False" SelectionUnit="FullRow"
IsReadOnly="False" HeadersVisibility="All" RowHeaderWidth="5" >
IsReadOnly="False" HeadersVisibility="All" RowHeaderWidth="5" IsSynchronizedWithCurrentItem="True" >
<DataGrid.InputBindings>
<MouseBinding
MouseAction="LeftDoubleClick"
Command="{Binding DoubleClickCommand}"
CommandParameter="{Binding Jobs/}"/>
</DataGrid.InputBindings>
<DataGrid.Resources>
<ContextMenu x:Key="RowMenu">
......
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