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

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

extended vecto gui code

parent a40e204a
No related branches found
No related tags found
No related merge requests found
Showing
with 272 additions and 75 deletions
......@@ -44,7 +44,7 @@
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/baselight.xaml" />
<ResourceDictionary Source="Resources/GlobalStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
......
......@@ -13,6 +13,8 @@ namespace VECTO3GUI.Helper
{
public static class FileDialogHelper
{
private const string XMLFilter = "XML Files (*.xml)|*.xml|All Files (*.*)|*.*";
public static string[] ShowSelectFilesDialog(bool multiselect, string initialDirectory = null)
{
......@@ -20,6 +22,7 @@ namespace VECTO3GUI.Helper
{
openFileDialog.InitialDirectory = initialDirectory;
openFileDialog.Multiselect = multiselect;
openFileDialog.Filter = XMLFilter;
var result = openFileDialog.ShowDialog();
if (result == DialogResult.OK)
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ninject;
using VECTO3GUI.ViewModel.Impl;
using VECTO3GUI.Views;
namespace VECTO3GUI.Helper
{
public static class OutputWindowHelper
{
public static OutputWindow CreateOutputWindow(IKernel kernel, object viewModel,
double width = default(double), double height= default(double))
{
var window = new OutputWindow {
DataContext = new OutputWindowViewModel(kernel, viewModel)
};
if (Math.Abs(width - default(double)) > 0 )
window.Width = width;
if (Math.Abs(height - default(double)) > 0)
window.Height = height;
return window;
}
}
}
......@@ -8,7 +8,7 @@
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"
Title="VECTO 3" Height="515.36" Width="972.48" WindowStartupLocation="CenterScreen"
d:DataContext="{d:DesignInstance Type=impl:MainWindowViewModel, IsDesignTimeCreatable=False}">
<Grid>
......
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:VECTO3GUI.Resources"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls">
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MetroDataGridColumnHeader}">
<Setter Property="mah:ControlsHelper.ContentCharacterCasing" Value="Normal"/>
</Style>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource MetroButton}">
<Setter Property="mah:ControlsHelper.ContentCharacterCasing" Value="Normal"/>
</Style>
</ResourceDictionary>
\ No newline at end of file
......@@ -155,6 +155,7 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Helper\FileDialogHelper.cs" />
<Compile Include="Helper\OutputWindowHelper.cs" />
<Compile Include="Model\InterfacesImpl.cs" />
<Compile Include="Util\AllowedEntry.cs" />
<Compile Include="Util\Component.cs" />
......@@ -198,6 +199,7 @@
<Compile Include="ViewModel\Impl\MainWindowViewModel.cs" />
<Compile Include="ViewModel\Impl\NoneViewModel.cs" />
<Compile Include="ViewModel\Impl\ObservableObject.cs" />
<Compile Include="ViewModel\Impl\OutputWindowViewModel.cs" />
<Compile Include="ViewModel\Impl\PrimaryVehicleBusJobViewModel.cs" />
<Compile Include="ViewModel\Impl\PrimaryVehicleBusViewModel.cs" />
<Compile Include="ViewModel\Impl\RetarderViewModel.cs" />
......@@ -349,6 +351,9 @@
<Compile Include="Views\JobView.xaml.cs">
<DependentUpon>JobView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\OutputWindow.xaml.cs">
<DependentUpon>OutputWindow.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -367,6 +372,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Resources\GlobalStyles.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Resources\ViewModelMappings.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -523,6 +532,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\OutputWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
......
......@@ -3,6 +3,7 @@ using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using TUGraz.VectoCommon.InputData;
using VECTO3GUI.ViewModel.Interfaces;
using Component = VECTO3GUI.Util.Component;
......@@ -63,6 +64,12 @@ namespace VECTO3GUI.ViewModel.Impl
return null;
}
public virtual bool AnyDataChanges()
{
return true;
}
#region Submodule Handling
protected IEnumerable<Component> GetSubmodels()
{
......
......@@ -13,6 +13,7 @@ namespace VECTO3GUI.ViewModel.Impl
private SquareMeter _declaredCdxA;
private bool _useStandardValues;
private string _appVersion;
private IAirdragDeclarationInputData _airdragData;
#region Implementation of IAirdragViewModel
......@@ -74,5 +75,20 @@ namespace VECTO3GUI.ViewModel.Impl
AppVersion = airdrag.AppVersion;
DeclaredCdxA = airdrag.AirDragArea;
}
public override bool AnyDataChanges()
{
if(_airdragData == null)
return base.AnyDataChanges();
var changed = _airdragData.Model != Model ||
_airdragData.Manufacturer != Manufacturer ||
_airdragData.CertificationNumber != CertificationNumber ||
_airdragData.Date != Date ||
_airdragData.AppVersion != AppVersion ||
_airdragData.AirDragArea != DeclaredCdxA;
return changed;
}
}
}
......@@ -32,6 +32,7 @@ namespace VECTO3GUI.ViewModel.Impl
private string _hvacTechnology;
private readonly ObservableCollection<SteeringPumpEntry> _steeringPumpTechnologies = new ObservableCollection<SteeringPumpEntry>();
private IAxlesViewModel axlesViewModel;
private IBusAuxiliariesDeclarationData _busAuxiliaries;
private ObservableCollection<string> _alternatorTechnologies;
private bool _dayRunningLightsLED;
......@@ -217,9 +218,11 @@ 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);
_busAuxiliaries = inputData.JobInputData.Vehicle.Components.BusAuxiliaries;
}
ConnectAxleViewModel();
}
......@@ -284,7 +287,7 @@ namespace VECTO3GUI.ViewModel.Impl
{
if (!busAux.ElectricSupply.Alternators.IsNullOrEmpty()) {
AlternatorTechnologies = new ObservableCollection<string>();
for (int i = 0; i < busAux.ElectricSupply.Alternators.Count; i++) {
AlternatorTechnologies.Add(busAux.ElectricSupply.Alternators[i].Technology);
}
......@@ -323,5 +326,36 @@ namespace VECTO3GUI.ViewModel.Impl
AllowedConsumerTechnologies = Enum.GetValues(typeof(ConsumerTechnology)).Cast<ConsumerTechnology>()
.Select(sc => AllowedEntry.Create(sc, sc.GetLabel())).ToArray();
}
public override bool AnyDataChanges()
{
if(_busAuxiliaries == null)
return base.AnyDataChanges();
bool changed;
if (!_busAuxiliaries.ElectricSupply.Alternators.IsNullOrEmpty()) {
//ToDo
//Changed Event?!
}
changed = _busAuxiliaries.ElectricConsumers.DayrunninglightsLED != DayrunninglightsLED ||
_busAuxiliaries.ElectricConsumers.HeadlightsLED != HeadlightsLED ||
_busAuxiliaries.ElectricConsumers.PositionlightsLED != PositionlightsLED ||
_busAuxiliaries.ElectricConsumers.BrakelightsLED != BrakelightsLED ||
_busAuxiliaries.ElectricConsumers.InteriorLightsLED != InteriorLightsLED ||
_busAuxiliaries.PneumaticConsumers.DoorDriveTechnology != DoorDriveTechnology ||
_busAuxiliaries.HVACAux.SystemConfiguration != SystemConfiguration ||
_busAuxiliaries.HVACAux.CompressorTypeDriver != CompressorTypeDriver ||
_busAuxiliaries.HVACAux.CompressorTypePassenger != CompressorTypePassenger ||
_busAuxiliaries.HVACAux.AuxHeaterPower != AuxHeaterPower ||
_busAuxiliaries.HVACAux.DoubleGlasing != DoubleGlasing ||
_busAuxiliaries.HVACAux.HeatPump != HeatPump ||
_busAuxiliaries.HVACAux.AdjustableAuxiliaryHeater != AdjustableAuxiliaryHeater ||
_busAuxiliaries.HVACAux.SeparateAirDistributionDucts != SeparateAirDistributionDucts;
return changed;
}
}
}
\ No newline at end of file
......@@ -19,6 +19,8 @@ namespace VECTO3GUI.ViewModel.Impl
#region Members
private IVehicleDeclarationInputData _vehicle;
private string _manufacturer;
private string _manufacturerAddress;
private string _model;
......@@ -142,14 +144,14 @@ namespace VECTO3GUI.ViewModel.Impl
#endregion
#region Set XML Data
protected override void InputDataChanged()
{
var inputData = JobViewModel.InputDataProvider as IDeclarationInputDataProvider;
SetVehicleData(inputData?.JobInputData.Vehicle);
_vehicle = inputData?.JobInputData.Vehicle;
SetVehicleData(_vehicle);
SetAllowedEntries();
}
......@@ -196,5 +198,32 @@ namespace VECTO3GUI.ViewModel.Impl
#endregion
public override bool AnyDataChanges()
{
if(_vehicle == null)
return base.AnyDataChanges();
var changed = _vehicle.Manufacturer != Manufacturer ||
_vehicle.ManufacturerAddress != ManufacturerAddress ||
_vehicle.Model != Model ||
_vehicle.VIN != VIN ||
_vehicle.Date != Date ||
_vehicle.LegislativeClass != LegislativeClass ||
_vehicle.RegisteredClass != RegisteredClass ||
_vehicle.VehicleCode != VehicleCode ||
_vehicle.CurbMassChassis != CurbMassChassis ||
_vehicle.GrossVehicleMassRating != TechnicalPermissibleMaximumLadenMass ||
_vehicle.NumberOfPassengersLowerDeck != NumberOfPassengersLowerDeck ||
_vehicle.NuberOfPassengersUpperDeck != NumberOfPassengersUpperDeck ||
_vehicle.FloorType != FloorType ||
_vehicle.Height != HeightIntegratedBody ||
_vehicle.Length != VehicleLength ||
_vehicle.Width != VehicleWidth ||
_vehicle.EntranceHeight != EntranceHeight||
((XMLDeclarationCompletedBusDataProviderV26)_vehicle).DoorDriveTechnology != DoorDriveTechnology;
return changed;
}
}
}
......@@ -22,6 +22,8 @@ using VECTO3GUI.ViewModel.Interfaces;
using System.Xml;
using System.Xml.Linq;
using TUGraz.VectoCommon.Resources;
using VECTO3GUI.Helper;
using VECTO3GUI.Views;
namespace VECTO3GUI.ViewModel.Impl
......@@ -42,6 +44,7 @@ namespace VECTO3GUI.ViewModel.Impl
private ICommand _newJobCommand;
private ICommand _editJobCommand;
private ICommand _removeJobCommand;
private ICommand _addJobCommand;
#endregion
......@@ -109,8 +112,13 @@ namespace VECTO3GUI.ViewModel.Impl
try
{
var jobEditView = ReadJob(entry.Filename); //Kernel.Get<IJobEditViewModel>();
var wnd = new Window { Content = jobEditView };
wnd.Show();
if(jobEditView == null)
return;
var window = OutputWindowHelper.CreateOutputWindow(Kernel, jobEditView);
window.Show();
}
catch (Exception e)
{
......@@ -136,7 +144,22 @@ namespace VECTO3GUI.ViewModel.Impl
public ICommand AddJob { get { return new RelayCommand(() => {}, () => false); } }
public ICommand AddJob { get { return _addJobCommand ?? new RelayCommand(DoAddJob); } }
private void DoAddJob()
{
var filePath = FileDialogHelper.ShowSelectFilesDialog(false, @"F:\VECTO\VECTO\bin");
if (filePath != null) {
_jobs.Add(new JobEntry()
{
Filename = filePath.First(),
Selected = false,
Sorting = _jobs.Count
});
}
}
public ICommand MoveJobUp { get { return new RelayCommand(() => {}, () => false); } }
public ICommand MoveJobDown { get { return new RelayCommand(() => {}, () => false); } }
public ICommand StartSimulation { get { return new RelayCommand(() => {}, () => false); } }
......
using Ninject;
namespace VECTO3GUI.ViewModel.Impl
{
public class OutputWindowViewModel : ValidatingViewModel
{
private object _viewModel;
public object ViewModel
{
get { return _viewModel; }
set { SetProperty(ref _viewModel, value); }
}
public OutputWindowViewModel(IKernel kernel, object viewModel)
{
Kernel = kernel;
_viewModel = viewModel;
}
}
}
......@@ -15,5 +15,7 @@ namespace VECTO3GUI.ViewModel.Interfaces {
IComponentViewModel ParentViewModel { get; set; }
IComponentViewModel GetComponentViewModel(Component component);
bool AnyDataChanges();
}
}
\ No newline at end of file
......@@ -13,16 +13,9 @@
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>
<helper:JobEntrySelectedConverter x:Key="JobEntrySelectedConverter" />
</UserControl.Resources>-->
<Grid>
<Grid.ColumnDefinitions>
......@@ -36,25 +29,39 @@
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid Grid.Row="1" Grid.Column="1" Margin="10">
<DataGrid ItemsSource="{Binding Jobs}" mah:ControlsHelper.ContentCharacterCasing="Normal"
<DataGrid ItemsSource="{Binding Jobs}"
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.Resources>
<ContextMenu x:Key="RowMenu">
<MenuItem Header="Remove" Command="{Binding DataContext.RemoveJob, RelativeSource={RelativeSource AncestorType=views:JoblistView}}"/>
<MenuItem Header="Edit" Command="{Binding DataContext.EditJob, RelativeSource={RelativeSource AncestorType=views:JoblistView}}"/>
<MenuItem Header="Add File" Command="{Binding DataContext.AddJob, RelativeSource={RelativeSource AncestorType=views:JoblistView}}"/>
</ContextMenu>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Header="File Path" Binding="{Binding Filename}" MinWidth="150"/>
<DataGridTextColumn Header="File Path" Binding="{Binding Filename}">
<DataGridTextColumn.CellStyle>
<Style TargetType= "{x:Type DataGridCell}" BasedOn="{StaticResource MetroDataGridCell}" >
<Setter Property="ContextMenu" Value="{StaticResource RowMenu}"/>
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
<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" />
<Button Margin="0,5,0,0" Command="{Binding EditJob}" Content="Edit" />
<Button Margin="0,5,0,0" Command="{Binding CreateNewJob}" Content="New File" />
<Button Margin="0,5,0,0" Command="{Binding RemoveJob}" Content="Remove File" />
</StackPanel>
</Grid>
......@@ -64,35 +71,5 @@
<!--<Grid Margin="0,0,10,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="70"/>
</Grid.ColumnDefinitions>
<ListView x:Name="Joblisting" Height="156" Margin="10,10,10,0" VerticalAlignment="Top" Grid.Column="0"
ItemsSource="{Binding Jobs}" MouseDoubleClick="Joblisting_MouseDoubleClick">
<ListView.View>
<GridView>
<GridViewColumn Width="30">
<GridViewColumn.CellTemplate>
<DataTemplate DataType="impl:JobEntry">
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding Path=Selected}"/>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Filepath" Width="auto" DisplayMemberBinding="{Binding Filename}"/>
</GridView>
</ListView.View>
</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}">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>--><!--
</StackPanel>
</Grid>-->
</UserControl>
......@@ -28,22 +28,5 @@ namespace VECTO3GUI.Views
{
InitializeComponent();
}
//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;
// }
// var model = (IJoblistViewModel)DataContext;
// model.EditJob.Execute(listView.SelectedItem);
//}
}
}
<mah:MetroWindow x:Class="VECTO3GUI.Views.OutputWindow"
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.Views"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:impl="clr-namespace:VECTO3GUI.ViewModel.Impl"
xmlns:interfaces="clr-namespace:VECTO3GUI.ViewModel.Interfaces"
mc:Ignorable="d"
Title="OutputWindow" Height="450" Width="800" WindowStartupLocation="CenterScreen"
d:DataContext="{d:DesignInstance Type=impl:OutputWindowViewModel, IsDesignTimeCreatable=False}">
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<ContentControl Content="{Binding ViewModel}" />
</Grid>
</mah:MetroWindow>
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.Shapes;
using MahApps.Metro.Controls;
namespace VECTO3GUI.Views
{
/// <summary>
/// Interaction logic for OutputWindow.xaml
/// </summary>
public partial class OutputWindow : MetroWindow
{
public OutputWindow()
{
InitializeComponent();
}
}
}
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