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

Skip to content
Snippets Groups Projects
Commit 5e327974 authored by Harald MARTINI's avatar Harald MARTINI
Browse files

Adding VIF to joblist after saving

parent 24dedb39
No related branches found
No related tags found
No related merge requests found
using System.Windows;
using Microsoft.Xaml.Behaviors;
namespace VECTO3GUI2020.Behaviours
{
public class HideOnMainWindowBehavior : Behavior<FrameworkElement>
{
#region Overrides of Behavior
private Visibility savedState;
protected override void OnAttached()
{
base.OnAttached();
var window = Window.GetWindow(this.AssociatedObject);
if (window == Application.Current.MainWindow) {
savedState = AssociatedObject.Visibility;
this.AssociatedObject.Visibility = Visibility.Hidden;
}
}
protected override void OnDetaching()
{
if (savedState != null) {
this.AssociatedObject.Visibility = savedState;
}
base.OnDetaching();
}
#endregion
}
}
\ No newline at end of file
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Microsoft.Xaml.Behaviors;
namespace VECTO3GUI2020.Behaviours
{
public class MinSizeBehavior : Behavior<Window>
{
#region Overrides of Behavior
private double _initialMinWidth;
private double _initialMinHeight;
protected override void OnAttached()
{
this.AssociatedObject.Activated += OnWindowActivated;
_initialMinHeight = this.AssociatedObject.MinHeight;
_initialMinWidth = this.AssociatedObject.MinWidth;
base.OnAttached();
}
private void OnWindowActivated(object sender, EventArgs e)
{
for(var i = 0; i < VisualTreeHelper.GetChildrenCount((Window)sender); i++)
{
var child = VisualTreeHelper.GetChild((Window)sender, 0) as FrameworkElement;
if (child.MinHeight != 0 && this.AssociatedObject.MinHeight == 0) {
this.AssociatedObject.MinHeight = child.MinHeight;
}
if (child.MinWidth != 0 && this.AssociatedObject.MinWidth == 0)
{
this.AssociatedObject.MinWidth = child.MinWidth;
}
}
}
private void OnWindowInitialized(object sender, EventArgs e)
{
}
protected override void OnDetaching()
{
this.AssociatedObject.Initialized -= OnWindowActivated;
base.OnDetaching();
}
#endregion
}
}
\ No newline at end of file
......@@ -38,11 +38,14 @@
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
<ContentPresenter VerticalAlignment="Center" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
</ContentPresenter>
</Border>
</ControlTemplate>
</Setter.Value>
......
......@@ -15,7 +15,7 @@ namespace VECTO3GUI2020.Ninject
public override void Load()
{
Bind<IJobListViewModel>().To<JobListViewModel>();
Bind<IJobListViewModel>().To<JobListViewModel>().InSingletonScope();
Bind<IMainWindowViewModel>().To<MainWindowViewModel>();
Bind<IMainViewModel>().To<JobListViewModel>();
Bind<ISettingsViewModel>().To<SettingsViewModel>();
......
......@@ -155,6 +155,8 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Behaviours\AutoScrollDataGridBehaviour.cs" />
<Compile Include="Behaviours\HideOnMainWindowBehavior.cs" />
<Compile Include="Behaviours\MinSizeBehavior.cs" />
<Compile Include="Helper\ConvertedSIDummyCreator.cs" />
<Compile Include="Helper\Converter\AlwaysVisibleConverter.cs" />
<Compile Include="Helper\Converter\BoolToVisibilityConverter.cs" />
......
......@@ -63,11 +63,12 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
set => SetProperty(ref _manufacturingStageViewModel, value);
}
public MultiStageJobViewModel_v0_1(IMultistageBusInputDataProvider inputData, IMultiStageViewModelFactory vmFactory, IMultistageDependencies multistageDependencies, IXMLInputDataReader inputDataReader)
public MultiStageJobViewModel_v0_1(IMultistageBusInputDataProvider inputData, IMultiStageViewModelFactory vmFactory, IMultistageDependencies multistageDependencies, IXMLInputDataReader inputDataReader, IJobListViewModel jobListViewModel)
{
Title = "Edit Multistage Job";
_dataSource = inputData.DataSource;
_jobInputData = inputData.JobInputData;
_jobListViewModel = jobListViewModel;
_inputData = inputData;
_vmFactory = vmFactory;
_consolidateManufacturingStage = _jobInputData.ConsolidateManufacturingStage;
......@@ -154,12 +155,12 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
SaveVif(vifData:this, outputFile:outputFile, dialogHelper:_dialogHelper.Value);
}
public static void SaveVif(IMultistageVIFInputData vifData, FileOutputVIFWriter writer, IDialogHelper dialogHelper = null)
public void SaveVif(IMultistageVIFInputData vifData, FileOutputVIFWriter writer, IDialogHelper dialogHelper = null)
{
SaveVif(vifData, null, writer, dialogHelper);
}
public static void SaveVif(IMultistageVIFInputData vifData, string outputFile,
private void SaveVif(IMultistageVIFInputData vifData, string outputFile,
FileOutputVIFWriter writer = null, IDialogHelper dialogHelper = null)
{
try {
......@@ -197,7 +198,9 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
} else {
dialogHelper?.ShowMessageBox($"Written to {writer.XMLMultistageReportFileName}", "Info",
MessageBoxButton.OK, MessageBoxImage.Information);
_jobListViewModel.AddJobAsync(writer.XMLMultistageReportFileName);
Debug.WriteLine($"Written to {writer.XMLMultistageReportFileName}");
}
}
......@@ -308,6 +311,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
private readonly IMultistageBusInputDataProvider _inputData;
private bool _selected;
private readonly bool _exempted;
private readonly IJobListViewModel _jobListViewModel;
public ICommand LoadVehicleDataCommand
{
......
using System.Windows;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using VECTO3GUI2020.ViewModel.Implementation;
......@@ -19,7 +20,7 @@ namespace VECTO3GUI2020.Views
}
private void JobDataGrid_OnDrop(object sender, DragEventArgs e)
private async void JobDataGrid_OnDrop(object sender, DragEventArgs e)
{
var success = true;
if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
......@@ -28,7 +29,7 @@ namespace VECTO3GUI2020.Views
var fileNames = e.Data.GetData(DataFormats.FileDrop, true) as string[];
if (fileNames != null) {
foreach (var fileName in fileNames) {
((JobListViewModel)this.DataContext).AddJobAsync(fileName);
await ((JobListViewModel)this.DataContext).AddJobAsync(fileName);
}
}
......
......@@ -6,7 +6,10 @@
xmlns:local="clr-namespace:VECTO3GUI2020.Views"
xmlns:customControls="clr-namespace:VECTO3GUI2020.Views.Multistage.CustomControls"
xmlns:implementation="clr-namespace:VECTO3GUI2020.ViewModel.Implementation"
mc:Ignorable="d" d:DataContext="{d:DesignInstance implementation:SettingsViewModel }">
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:behaviour="clr-namespace:VECTO3GUI2020.Behaviours"
mc:Ignorable="d" d:DataContext="{d:DesignInstance implementation:SettingsViewModel }"
MinHeight="200" MinWidth="400">
<UserControl.Resources>
<Style TargetType="Label">
<Setter Property="Margin" Value="4 4 4 4"></Setter>
......@@ -96,6 +99,9 @@
<!--</Grid>-->
<DockPanel DockPanel.Dock="Bottom" LastChildFill="False">
<i:Interaction.Behaviors>
<behaviour:HideOnMainWindowBehavior></behaviour:HideOnMainWindowBehavior>
</i:Interaction.Behaviors>
<Button DockPanel.Dock="Right"
Width="100"
Command="{Binding CloseWindowCommand}"
......
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