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

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

started to implement vecto gui for completed xml

parent cf6266f1
No related branches found
No related tags found
No related merge requests found
Showing
with 566 additions and 153 deletions
......@@ -9,6 +9,10 @@
<assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.4.0" newVersion="3.3.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
\ No newline at end of file
......@@ -33,6 +33,19 @@
</Style.Triggers>
</Style>
</ResourceDictionary>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<!-- Accent and AppTheme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/steel.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/baselight.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.WindowsAPICodePack.Dialogs;
using OpenFileDialog = System.Windows.Forms.OpenFileDialog;
using SaveFileDialog = Microsoft.Win32.SaveFileDialog;
namespace VECTO3GUI.Helper
{
public static class FileDialogHelper
{
public static string[] ShowSelectFilesDialog(bool multiselect, string initialDirectory = null)
{
using (var openFileDialog = new OpenFileDialog())
{
openFileDialog.InitialDirectory = initialDirectory;
openFileDialog.Multiselect = multiselect;
var result = openFileDialog.ShowDialog();
if (result == DialogResult.OK)
{
return openFileDialog.FileNames;
}
}
return null;
}
public static string ShowSelectDirectoryDialog(string initialDirectory = null)
{
using (var dialog = new CommonOpenFileDialog())
{
dialog.InitialDirectory = initialDirectory;
dialog.IsFolderPicker = true;
var result = dialog.ShowDialog();
if (result == CommonFileDialogResult.Ok)
{
return dialog.FileName;
}
}
return null;
}
}
}
<Window x:Class="VECTO3GUI.MainWindow"
<mah:MetroWindow x:Class="VECTO3GUI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:VECTO3GUI"
xmlns:interfaces="clr-namespace:VECTO3GUI.ViewModel.Interfaces"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:impl="clr-namespace:VECTO3GUI.ViewModel.Impl"
mc:Ignorable="d"
Title="VECTO 3" Height="515.36" Width="972.48" >
<!--<d:MainWindow.DataContext>
<x:Type Type="interfaces:IMainWindowViewModel"/>
</d:MainWindow.DataContext>-->
Title="VECTO 3" Height="515.36" Width="972.48"
d:DataContext="{d:DesignInstance Type=impl:MainWindowViewModel, IsDesignTimeCreatable=False}">
<Grid>
<Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition/>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<StackPanel Orientation="Vertical">
<Menu IsMainMenu="True" Style="{DynamicResource MetroMenu}">
<MenuItem Header="File">
<MenuItem Header="New" Style="{DynamicResource MetroMenuItem}" Margin="0"/>
<MenuItem Header="Edit" Style="{DynamicResource MetroMenuItem}" Margin="0" Command="{Binding CurrentViewModel.EditJob}"/>
<Separator HorizontalAlignment="Stretch" Background="Gray"/>
<MenuItem Header="Open" Command="{Binding CurrentViewModel.CreateNewJob}"/>
<MenuItem Header="Open Folder"/>
<Separator HorizontalAlignment="Stretch" Background="Gray"/>
<MenuItem Header="Exit"/>
</MenuItem>
<MenuItem Header="Settings">
<!--<MenuItem Header="New"/>-->
</MenuItem>
<MenuItem Header="Help">
<MenuItem Header="User Manual"/>
<MenuItem Header="About Vecto"/>
<MenuItem Header="Relase Notes"/>
</MenuItem>
</Menu>
<Separator HorizontalAlignment="Stretch" Background="Gray"/>
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<ContentControl x:Name="bu" Content="{Binding CurrentViewModel}" />
</Grid>
<Grid Grid.Row="2">
<StatusBar/>
</Grid>
<!--<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Background="Gray" Grid.Column="0">
<Button Name="BtnHome" Background="Gray" Foreground="White" FontSize="16pt" Margin="0,20,0,0" BorderBrush="Gray" Width="150" Padding="10,0,0,0">Home</Button>
<Button mah:ControlsHelper.ContentCharacterCasing="Normal" Name="BtnHome" Background="Gray" Foreground="White" FontSize="16pt" Margin="0,20,0,0" BorderBrush="Gray" Width="150" Padding="10,0,0,0">Home</Button>
<Button Name="BtnSettings" Width="150" Background="Gray" Foreground="White" FontSize="16pt" Margin="0,5,0,0" BorderBrush="Gray" HorizontalAlignment="Left" Padding="10,0,0,0">Settings</Button>
<Button Name="BtnHelp" Width="150" Background="Gray" Foreground="White" FontSize="16pt" Margin="0,5,0,0" BorderBrush="Gray" HorizontalAlignment="Left" Padding="10,0,0,0">Help</Button>
</StackPanel>
<ContentControl Content="{Binding CurrentViewModel}" Grid.Column="1"/>
</StackPanel>-->
</Grid>
</Window>
</mah:MetroWindow>
......@@ -12,6 +12,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MahApps.Metro.Controls;
using VECTO3GUI.ViewModel.Interfaces;
namespace VECTO3GUI
......@@ -19,7 +20,7 @@ namespace VECTO3GUI
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
public partial class MainWindow : MetroWindow
{
public MainWindow()
......
......@@ -9,9 +9,18 @@
<DataTemplate DataType="{x:Type impl:JoblistViewModel}">
<views:JoblistView />
</DataTemplate>
<DataTemplate DataType="{x:Type impl:DeclarationJobViewModel}">
<views:JobEditView/>
</DataTemplate>
<DataTemplate DataType="{x:Type impl:EngineOnlyJobViewModel}">
<views:JobEditView/>
</DataTemplate>
......@@ -26,10 +35,23 @@
<views:JobEditView/>
</DataTemplate>
<DataTemplate DataType="{x:Type impl:CompleteVehicleBusJobViewModel}">
<!--<DataTemplate DataType="{x:Type impl:CompleteVehicleBusJobViewModel}">
<views:JobEditView/>
</DataTemplate>-->
<!--some test-->
<DataTemplate DataType="{x:Type impl:CompleteVehicleBusJobViewModel}">
<views:JoblistTabView/>
</DataTemplate>
<!--end test-->
<DataTemplate DataType="{x:Type impl:PrimaryVehicleBusViewModel}">
<declaration:PrimaryVehicleBusView/>
</DataTemplate>
......
......@@ -39,6 +39,87 @@
<HintPath>..\packages\Castle.Core.4.2.0\lib\net45\Castle.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ControlzEx, Version=3.0.2.4, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ControlzEx.3.0.2.4\lib\net45\ControlzEx.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro, Version=1.6.5.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.6.5\lib\net45\MahApps.Metro.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.BoxIcons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.BoxIcons.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.Core.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.Entypo, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.Entypo.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.EvaIcons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.EvaIcons.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.FeatherIcons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.FeatherIcons.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.FontAwesome, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.FontAwesome.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.Ionicons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.Ionicons.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.JamIcons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.JamIcons.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.Material, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.Material.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.MaterialDesign, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.MaterialDesign.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.MaterialLight, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.MaterialLight.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.Microns, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.Microns.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.Modern, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.Modern.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.Octicons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.Octicons.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.PicolIcons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.PicolIcons.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.RPGAwesome, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.RPGAwesome.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.SimpleIcons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.SimpleIcons.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.Typicons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.Typicons.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.Unicons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.Unicons.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.WeatherIcons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.WeatherIcons.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro.IconPacks.Zondicons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.IconPacks.3.7.0\lib\net45\MahApps.Metro.IconPacks.Zondicons.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\Microsoft.Expression.Interactions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAPICodePack-Core.1.1.2\lib\Microsoft.WindowsAPICodePack.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
</Reference>
<Reference Include="Ninject, Version=3.3.4.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<HintPath>..\packages\Ninject.3.3.4\lib\net45\Ninject.dll</HintPath>
<Private>True</Private>
......@@ -51,6 +132,10 @@
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\ControlzEx.3.0.2.4\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
......@@ -69,6 +154,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Helper\FileDialogHelper.cs" />
<Compile Include="Model\InterfacesImpl.cs" />
<Compile Include="Util\AllowedEntry.cs" />
<Compile Include="Util\Component.cs" />
......@@ -254,6 +340,9 @@
<Compile Include="Views\JobEditView.xaml.cs">
<DependentUpon>JobEditView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\JoblistTabView.xaml.cs">
<DependentUpon>JoblistTabView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\JoblistView.xaml.cs">
<DependentUpon>JoblistView.xaml</DependentUpon>
</Compile>
......@@ -422,6 +511,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\JoblistTabView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\JoblistView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -469,6 +562,7 @@
<Name>VectoCore</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
......@@ -217,7 +217,7 @@ namespace VECTO3GUI.ViewModel.Impl
// .If<IDeclarationInputDataProvider>(d => SetValues(d.JobInputData.Vehicle.Components.AuxiliaryInputData()))
// .If<IEngineeringInputDataProvider>(e => SetValues(e.JobInputData.Vehicle.Components.AuxiliaryInputData()));
if (inputData.JobInputData.Vehicle.Components.BusAuxiliaries != null)
if (inputData?.JobInputData?.Vehicle?.Components?.BusAuxiliaries != null)
SetValues(inputData.JobInputData.Vehicle.Components.BusAuxiliaries);
ConnectAxleViewModel();
......
......@@ -155,6 +155,9 @@ namespace VECTO3GUI.ViewModel.Impl
private void SetVehicleData(IVehicleDeclarationInputData vehicle)
{
if (vehicle == null)
return;
Manufacturer = vehicle.Manufacturer;
ManufacturerAddress = vehicle.ManufacturerAddress;
Model = vehicle.Model;
......
......@@ -19,18 +19,49 @@ using TUGraz.VectoCore.InputData.FileIO.XML.Engineering;
using TUGraz.VectoCore.Utils;
using VECTO3GUI.Util;
using VECTO3GUI.ViewModel.Interfaces;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Linq;
using TUGraz.VectoCommon.Resources;
using VECTO3GUI.ViewModel.Impl;
namespace VECTO3GUI.ViewModel.Impl
{
public class JoblistViewModel : ObservableObject, IJoblistViewModel
{
#region Members
protected readonly ObservableCollection<JobEntry> _jobs = new ObservableCollection<JobEntry>();
private JobEntry _selectedJobEntry;
#endregion
#region Commands
private ICommand _newJobCommand;
private ICommand _editJobCommand;
private ICommand _removeJobCommand;
#endregion
#region Properties
public JobEntry SelectedJobEntry
{
get { return _selectedJobEntry; }
set { SetProperty(ref _selectedJobEntry, value); }
}
public ObservableCollection<JobEntry> Jobs
{
get { return _jobs; }
}
#endregion
public JoblistViewModel()
{
......@@ -46,130 +77,105 @@ namespace VECTO3GUI.ViewModel.Impl
private void AddJobEntry(string jobFile)
{
_jobs.Add(new JobEntry() {
_jobs.Add(new JobEntry()
{
Filename = jobFile,
Selected = false,
Sorting = _jobs.Count
});
}
public ObservableCollection<JobEntry> Jobs
{
get { return _jobs; }
}
public ICommand AddJob { get { return new RelayCommand(() => {}, () => false); } }
public ICommand RemoveJob { get { return new RelayCommand<object>(DoRemoveJob, CanRemoveJob);} }
#region Implementation IJoblistViewModel
public ICommand RemoveJob { get { return _removeJobCommand ?? new RelayCommand(DoRemoveJob, CanRemoveJob); } }
private void DoRemoveJob(object selected)
private void DoRemoveJob()
{
var jobEntry = selected as JobEntry;
if(jobEntry == null)
return;
_jobs.Remove(jobEntry);
_jobs.Remove(SelectedJobEntry);
SelectedJobEntry = null;
}
private bool CanRemoveJob(object selected)
private bool CanRemoveJob()
{
var jobEntry = selected as JobEntry;
return jobEntry != null;
return SelectedJobEntry != null;
}
public ICommand MoveJobUp { get { return new RelayCommand(() => { }, () => false); } }
public ICommand MoveJobDown { get { return new RelayCommand(() => { }, () => false); } }
public ICommand StartSimulation { get { return new RelayCommand(DoStartSimulation, CanStartSimulation); } }
public ICommand EditJob { get { return _editJobCommand ?? new RelayCommand(DoEditJob, CanEditJob); } }
private void DoStartSimulation()
private void DoEditJob()
{
var entry = SelectedJobEntry;
try
{
var jobEditView = ReadJob(entry.Filename); //Kernel.Get<IJobEditViewModel>();
var wnd = new Window { Content = jobEditView };
wnd.Show();
}
catch (Exception e)
{
MessageBox.Show(
"Failed to read selected job: " + Environment.NewLine + Environment.NewLine + e.Message, "Failed reading Job",
MessageBoxButton.OK);
}
}
private bool CanStartSimulation()
private bool CanEditJob()
{
return false;
return SelectedJobEntry != null;
}
public ICommand EditJob { get { return new RelayCommand<object>(DoEditJob, CanEditJob);} }
public ICommand CreateNewJob { get { return _newJobCommand ?? new RelayCommand(DoNewJobCommand); } }
public ICommand JobEntrySetActive { get {return new RelayCommand<object>(DoJobEntrySetActive);} }
private void DoJobEntrySetActive(object obj)
private void DoNewJobCommand()
{
var jobEntry = (JobEntry)((ListViewItem)obj).Content;
jobEntry.Selected = !jobEntry.Selected;
var jobEditView = new CompleteVehicleBusJobViewModel(Kernel, null);
var wnd = new Window { Content = jobEditView };
wnd.Show();
}
private void DoEditJob(object selected)
{
var entry = selected as JobEntry;
if (entry == null) {
return;
}
try {
var jobEditView = ReadJob(entry.Filename); //Kernel.Get<IJobEditViewModel>();
var wnd = new Window { Content = jobEditView };
wnd.Show();
} catch (Exception e) {
MessageBox.Show(
"Failed to read selected job: " + Environment.NewLine + Environment.NewLine + e.Message, "Failed reading Job",
MessageBoxButton.OK);
}
}
public ICommand AddJob { get { return new RelayCommand(() => {}, () => false); } }
public ICommand MoveJobUp { get { return new RelayCommand(() => {}, () => false); } }
public ICommand MoveJobDown { get { return new RelayCommand(() => {}, () => false); } }
public ICommand StartSimulation { get { return new RelayCommand(() => {}, () => false); } }
public ICommand JobEntrySetActive { get { return new RelayCommand(() => {}, () => false); } }
#endregion
private IJobEditViewModel ReadJob(string jobFile)
{
if (jobFile == null)
return null;
var ext = Path.GetExtension(jobFile);
if (ext == Constants.FileExtensions.VectoXMLDeclarationFile) {
if (ext == Constants.FileExtensions.VectoXMLDeclarationFile)
{
var localName = GetLocalName(jobFile);
var xmlInputReader = Kernel.Get<IXMLInputDataReader>();
using (var reader = XmlReader.Create(jobFile)) {
if (localName == XMLNames.VectoPrimaryVehicleReport) {
using (var reader = XmlReader.Create(jobFile))
{
if (localName == XMLNames.VectoPrimaryVehicleReport)
{
return CreatePrimaryBusVehicleViewModel(xmlInputReader.Create(reader));
}
if (localName == XMLNames.VectoInputDeclaration) {
if (localName == XMLNames.VectoInputDeclaration)
{
return CreateCompleteBusVehicleViewModel(xmlInputReader.CreateDeclaration(reader));
}
}
}
return null;
//IInputDataProvider inputData = null;
//var ext = Path.GetExtension(jobFile);
//switch (ext) {
// case Constants.FileExtensions.VectoJobFile:
// inputData = JSONInputDataFactory.ReadJsonJob(jobFile);
// break;
// case Constants.FileExtensions.VectoXMLDeclarationFile:
// //ToDo
// //case Constants.FileExtensions.VectoXMLJobFile:
// inputData = Kernel.Get<IXMLInputDataReader>().CreateDeclaration(jobFile);
// break;
// default:
// throw new UnsupportedFileVersionException(jobFile);
//}
//var retVal = CreateJobEditViewModel(inputData);
//if (retVal == null) {
// throw new Exception("Unsupported job type");
//}
//return retVal;
}
private string GetLocalName(string jobFilePath)
......@@ -178,12 +184,14 @@ namespace VECTO3GUI.ViewModel.Impl
return doc.Root?.Name.LocalName;
}
//ToDo FJ
//Start from here!!
private IJobEditViewModel CreateCompleteBusVehicleViewModel(IInputDataProvider inputDataProvider)
{
var dataProvider = inputDataProvider as IDeclarationInputDataProvider;
return dataProvider == null ? null : new CompleteVehicleBusJobViewModel(Kernel, dataProvider);
}
private IJobEditViewModel CreatePrimaryBusVehicleViewModel(IInputDataProvider inputData)
{
......@@ -191,33 +199,64 @@ namespace VECTO3GUI.ViewModel.Impl
return dataProvider == null ? null : new PrimaryVehicleBusJobViewModel(Kernel, dataProvider);
}
//private IJobEditViewModel CreateJobEditViewModel(IInputDataProvider inputData)
//{
// IJobEditViewModel retVal = null;
// if (inputData is JSONInputDataV2) {
// var jsoninputData = inputData as JSONInputDataV2;
// if (jsoninputData.SavedInDeclarationMode) {
// retVal = new DeclarationJobViewModel(Kernel, jsoninputData);
// } else {
// if (jsoninputData.EngineOnlyMode) {
// retVal = new EngineOnlyJobViewModel(Kernel, jsoninputData);
// } else {
// // TODO!
// }
// }
// }
// //ToDo
// //if (inputData is XMLDeclarationInputDataProvider) {
// // var declInput = inputData as IDeclarationInputDataProvider;
// // retVal = new DeclarationJobViewModel(Kernel, declInput);
// //}
// return retVal;
//}
private bool CanEditJob(object selected)
{
var jobEntry = selected as JobEntry;
return jobEntry != null;
}
}
#region Legacy
//IInputDataProvider inputData = null;
//var ext = Path.GetExtension(jobFile);
//switch (ext) {
// case Constants.FileExtensions.VectoJobFile:
// inputData = JSONInputDataFactory.ReadJsonJob(jobFile);
// break;
// case Constants.FileExtensions.VectoXMLDeclarationFile:
// //ToDo
// //case Constants.FileExtensions.VectoXMLJobFile:
// inputData = Kernel.Get<IXMLInputDataReader>().CreateDeclaration(jobFile);
// break;
// default:
// throw new UnsupportedFileVersionException(jobFile);
//}
//var retVal = CreateJobEditViewModel(inputData);
//if (retVal == null) {
// throw new Exception("Unsupported job type");
//}
//return retVal;
//private IJobEditViewModel CreateJobEditViewModel(IInputDataProvider inputData)
//{
// IJobEditViewModel retVal = null;
// if (inputData is JSONInputDataV2) {
// var jsoninputData = inputData as JSONInputDataV2;
// if (jsoninputData.SavedInDeclarationMode) {
// retVal = new DeclarationJobViewModel(Kernel, jsoninputData);
// } else {
// if (jsoninputData.EngineOnlyMode) {
// retVal = new EngineOnlyJobViewModel(Kernel, jsoninputData);
// } else {
// // TODO!
// }
// }
// }
// //ToDo
// //if (inputData is XMLDeclarationInputDataProvider) {
// // var declInput = inputData as IDeclarationInputDataProvider;
// // retVal = new DeclarationJobViewModel(Kernel, declInput);
// //}
// return retVal;
//}
#endregion
}
using Ninject;
using System.Windows.Input;
using Ninject;
using VECTO3GUI.Util;
using VECTO3GUI.ViewModel.Interfaces;
using VECTO3GUI.Views;
namespace VECTO3GUI.ViewModel.Impl
{
public class MainWindowViewModel : ObservableObject, IMainWindowViewModel
{
{
private IMainView _currentViewModel;
public MainWindowViewModel(IKernel kernel)
......@@ -14,7 +15,6 @@ namespace VECTO3GUI.ViewModel.Impl
Kernel = kernel;
CurrentViewModel = Kernel.Get<IJoblistViewModel>();
}
public IMainView CurrentViewModel
......@@ -22,7 +22,5 @@ namespace VECTO3GUI.ViewModel.Impl
get { return _currentViewModel; }
set { SetProperty(ref _currentViewModel, value); }
}
}
}
......@@ -14,5 +14,6 @@ namespace VECTO3GUI.ViewModel.Interfaces
ICommand StartSimulation { get; }
ICommand EditJob { get; }
ICommand JobEntrySetActive { get; }
ICommand CreateNewJob { get; }
}
}
<UserControl x:Class="VECTO3GUI.Views.JoblistTabView"
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:local="clr-namespace:VECTO3GUI.Views"
xmlns:interfaces="clr-namespace:VECTO3GUI.ViewModel.Interfaces"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:impl="clr-namespace:VECTO3GUI.ViewModel.Impl"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<!--<d:JoblistTabView.DataContext>
<x:Type Type="interfaces:IJobEditViewModel"/>
</d:JoblistTabView.DataContext>-->
<TabControl ItemsSource="{Binding Components}" x:Name="ComponentsTab" SelectedIndex="0">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding EditComponent}"
CommandParameter="{Binding ElementName=ComponentsTab, Path=SelectedItem}">
</i:InvokeCommandAction>
</i:EventTrigger>
</i:Interaction.Triggers>
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"/>
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate>
<ScrollViewer DockPanel.Dock="Top">
<ContentControl Content="{Binding DataContext.CurrentComponent,
RelativeSource={RelativeSource AncestorType=local:JoblistTabView}}" MinHeight="100"/>
</ScrollViewer>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
</UserControl>
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 VECTO3GUI.ViewModel.Interfaces;
namespace VECTO3GUI.Views
{
/// <summary>
/// Interaction logic for JoblistTabView.xaml
/// </summary>
public partial class JoblistTabView : UserControl
{
public JoblistTabView()
{
InitializeComponent();
}
public JoblistTabView(IJobEditViewModel viewModel)
{
InitializeComponent();
DataContext = viewModel;
}
}
}
......@@ -7,16 +7,64 @@
xmlns:helper="clr-namespace:VECTO3GUI.Helper"
xmlns:impl="clr-namespace:VECTO3GUI.ViewModel.Impl"
xmlns:interfaces="clr-namespace:VECTO3GUI.ViewModel.Interfaces"
xmlns:views="clr-namespace:VECTO3GUI.Views"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="600">
d:DesignHeight="300" d:DesignWidth="600"
d:DataContext="{d:DesignInstance Type=impl:JoblistViewModel, IsDesignTimeCreatable=False}">
<d:JoblistView.DataContext>
<x:Type Type="interfaces:IJoblistViewModel"/>
</d:JoblistView.DataContext>
<UserControl.Resources>
<!--<UserControl.Resources>
<helper:JobEntrySelectedConverter x:Key="JobEntrySelectedConverter" />
</UserControl.Resources>-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition/>
<ColumnDefinition Width="80"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid Grid.Row="1" Grid.Column="1" Margin="10">
<DataGrid ItemsSource="{Binding Jobs}" mah:ControlsHelper.ContentCharacterCasing="Normal"
SelectedValue="{Binding DataContext.SelectedJobEntry, RelativeSource={RelativeSource AncestorType=views:JoblistView}}"
Style="{DynamicResource AzureDataGrid}" BorderThickness="1" CanUserAddRows="False" AutoGenerateColumns="False" SelectionUnit="FullRow"
IsReadOnly="True" HeadersVisibility="All" RowHeaderWidth="5" ColumnWidth="*" >
<DataGrid.Columns>
<DataGridTextColumn Header="File Path" Binding="{Binding Filename}" MinWidth="150"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</UserControl.Resources>
<Grid Margin="0,0,10,0">
<Grid Grid.Row="1" Grid.Column="2" Margin="0,0,10,0">
<StackPanel Orientation="Vertical" Margin="0,30,0,0">
<Button Margin="0,5,0,0" Command="{Binding EditJob}" Content="Edit" mah:ControlsHelper.ContentCharacterCasing="Normal"/>
<Button Margin="0,5,0,0" Command="{Binding CreateNewJob}" Content="New File" mah:ControlsHelper.ContentCharacterCasing="Normal" />
<Button Margin="0,5,0,0" Command="{Binding RemoveJob}" Content="Remove File" mah:ControlsHelper.ContentCharacterCasing="Normal" />
</StackPanel>
</Grid>
</Grid>
<!--<Grid Margin="0,0,10,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="70"/>
......@@ -40,11 +88,11 @@
</ListView>
<StackPanel Grid.Column="1">
<Button Margin="0,20,0,0" Command="{Binding EditJob}" CommandParameter="{Binding ElementName=Joblisting, Path=SelectedItem}">Edit</Button>
<Button Margin="0,15,0,0" Command="{Binding AddJob}">Add</Button>
<Button Margin="0,15,0,0" Command="{Binding AddJob}">New File</Button>
<Button Margin="0,5,0,0" Command="{Binding RemoveJob}" CommandParameter="{Binding ElementName=Joblisting, Path=SelectedItem}">Remove</Button>
<Button Margin="0,5,0,0" Command="{Binding MoveJobUp}">Up</Button>
<Button Margin="0,5,0,0" Command="{Binding MoveJobDown}">Down</Button>
<Button Margin="0,20,0,0" Command="{Binding StartSimulation}">Start</Button>
--><!--<Button Margin="0,5,0,0" Command="{Binding MoveJobUp}">Up</Button>-->
<!--<Button Margin="0,5,0,0" Command="{Binding MoveJobDown}">Down</Button>-->
<!--<Button Margin="0,20,0,0" Command="{Binding StartSimulation}">Start</Button>--><!--
</StackPanel>
</Grid>
</Grid>-->
</UserControl>
......@@ -29,21 +29,21 @@ namespace VECTO3GUI.Views
InitializeComponent();
}
public JoblistView(IJoblistViewModel viewModel)
{
InitializeComponent();
DataContext = viewModel;
}
//public JoblistView(IJoblistViewModel viewModel)
//{
// InitializeComponent();
// DataContext = viewModel;
//}
private void Joblisting_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var listView = (ListView)sender;
if (listView.SelectedItems.Count == 0) {
return;
}
//private void Joblisting_MouseDoubleClick(object sender, MouseButtonEventArgs e)
//{
// var listView = (ListView)sender;
// if (listView.SelectedItems.Count == 0) {
// return;
// }
var model = (IJoblistViewModel)DataContext;
model.EditJob.Execute(listView.SelectedItem);
}
// var model = (IJoblistViewModel)DataContext;
// model.EditJob.Execute(listView.SelectedItem);
//}
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="4.2.0" targetFramework="net452" />
<package id="ControlzEx" version="3.0.2.4" targetFramework="net452" />
<package id="MahApps.Metro" version="1.6.5" targetFramework="net452" />
<package id="MahApps.Metro.IconPacks" version="3.7.0" targetFramework="net452" />
<package id="Ninject" version="3.3.4" targetFramework="net452" />
<package id="Ninject.Extensions.Factory" version="3.3.2" targetFramework="net452" />
<package id="System.Windows.Interactivity.WPF" version="2.0.20525" targetFramework="net452" />
<package id="WindowsAPICodePack-Core" version="1.1.2" targetFramework="net452" />
<package id="WindowsAPICodePack-Shell" version="1.1.1" targetFramework="net452" />
</packages>
\ No newline at end of file
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