diff --git a/VECTO3GUI2020/Behaviours/PopUpHorizontalAlignmentBehavior.cs b/VECTO3GUI2020/Behaviours/PopUpHorizontalAlignmentBehavior.cs index c24414e79c2f6b5f12bf0ae034033a5c3338078b..16d62fcbc82100bcb8ca463a8ae9b9fd10fcadd0 100644 --- a/VECTO3GUI2020/Behaviours/PopUpHorizontalAlignmentBehavior.cs +++ b/VECTO3GUI2020/Behaviours/PopUpHorizontalAlignmentBehavior.cs @@ -12,12 +12,6 @@ namespace VECTO3GUI2020.Behaviours private double _popUpWidth; - private void _placementTarget_SizeChanged(object sender, SizeChangedEventArgs e) - { - if (e.WidthChanged) { - SetHorizontalAlignment(e.NewSize.Width, this.AssociatedObject.ActualWidth); - } - } private void SetHorizontalAlignment(double placeMentTargetActualWidth, double popUpActualWidth) { @@ -25,6 +19,17 @@ namespace VECTO3GUI2020.Behaviours this.AssociatedObject.HorizontalOffset = placeMentTargetActualWidth - popUpActualWidth; } } + private void AssociatedObject_Opened(object sender, System.EventArgs e) + { + + var popUpWidth = this.AssociatedObject.ActualWidth; + if (this.AssociatedObject.ActualWidth == 0 && this.AssociatedObject.IsMeasureValid) { + popUpWidth = this.AssociatedObject.DesiredSize.Width; + } + + //SetHorizontalAlignment(_placementTarget.ActualWidth, this.AssociatedObject.ActualWidth != 0 ? : this.AssociatedObject.ActualWidth); + } + #region Overrides of Behavior @@ -33,22 +38,14 @@ namespace VECTO3GUI2020.Behaviours { _placementTarget = this.AssociatedObject.PlacementTarget as FrameworkElement; _popUpWidth = this.AssociatedObject.MinWidth; - _initialHorizontalOffset = this.AssociatedObject.HorizontalOffset; - _placementTarget.SizeChanged += _placementTarget_SizeChanged; - this.AssociatedObject.SizeChanged += AssociatedObject_SizeChanged; - SetHorizontalAlignment(_placementTarget.ActualWidth, this.AssociatedObject.ActualWidth); + this.AssociatedObject.Opened += AssociatedObject_Opened; base.OnAttached(); } - private void AssociatedObject_SizeChanged(object sender, SizeChangedEventArgs e) - { - _popUpWidth = e.NewSize.Width; - SetHorizontalAlignment(_placementTarget.ActualWidth, e.NewSize.Width); - } - protected override void OnDetaching() + + protected override void OnDetaching() { - _placementTarget.SizeChanged -= _placementTarget_SizeChanged; this.AssociatedObject.HorizontalOffset = _initialHorizontalOffset; base.OnDetaching(); } diff --git a/VECTO3GUI2020/Resources/Converter.xaml b/VECTO3GUI2020/Resources/Converter.xaml index ee924cdf0baa31fbe9a8b27f15c5c77b939709f5..fcffe93fcd59a80d687a400816e90f70713bbf0f 100644 --- a/VECTO3GUI2020/Resources/Converter.xaml +++ b/VECTO3GUI2020/Resources/Converter.xaml @@ -1,7 +1,7 @@ <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:converter="clr-namespace:VECTO3GUI2020.Helper.Converter" - xmlns:helper="clr-namespace:VECTO3GUI2020.Helper"> + xmlns:converter="clr-namespace:VECTO3GUI2020.Helper.Converter"> + <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> <converter:SIToUnitString x:Shared="False" x:Key="SIToUnitStringConverter"/> @@ -19,6 +19,8 @@ <converter:BoolToIntConverter x:Key="BoolToIntConverter"></converter:BoolToIntConverter> + + </ResourceDictionary> diff --git a/VECTO3GUI2020/ViewModel/Implementation/CreateVifViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/CreateVifViewModel.cs index c2977f2112fe9ffe8a8570692ce68703dd479120..13fa7f41f94fed51b88a798a8ffecc56ad736b77 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/CreateVifViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/CreateVifViewModel.cs @@ -99,6 +99,12 @@ namespace VECTO3GUI2020.ViewModel.Implementation set => throw new NotImplementedException(); } + public bool CanBeSimulated + { + get => throw new NotImplementedException(); + set => throw new NotImplementedException(); + } + #endregion #region Implementation of IEditViewModel diff --git a/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationJobViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationJobViewModel.cs index 578aaf2543b6370b68f1e184a693ff654f360e02..73c78aa2a21cb3495f545401f5d9683094de197d 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationJobViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationJobViewModel.cs @@ -32,6 +32,11 @@ namespace VECTO3GUI2020.ViewModel.Implementation.Document set => SetProperty(ref _selected, value); } + public bool CanBeSimulated + { + get => throw new System.NotImplementedException(); + set => throw new System.NotImplementedException(); + } #endregion #region Members diff --git a/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationTrailerJobDocumentViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationTrailerJobDocumentViewModel.cs index 435206562afabef6c00c34e48c96a561974247fd..e683225046e19e593e04590977d3bb78d7ac6ae0 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationTrailerJobDocumentViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationTrailerJobDocumentViewModel.cs @@ -26,6 +26,12 @@ namespace VECTO3GUI2020.ViewModel.Implementation.Document set => throw new System.NotImplementedException(); } + public bool CanBeSimulated + { + get => throw new System.NotImplementedException(); + set => throw new System.NotImplementedException(); + } + IEditViewModel IDocumentViewModel.EditViewModel => throw new System.NotImplementedException(); private IXMLInputDataReader _xMLInputDataReader; diff --git a/VECTO3GUI2020/ViewModel/Implementation/Document/SimulationOnlyDeclarationJob.cs b/VECTO3GUI2020/ViewModel/Implementation/Document/SimulationOnlyDeclarationJob.cs index b43ba9ae6f4affd361566e2de17a90138e313e9b..f41a42d55bbb3d3832580378690378785828e287 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/Document/SimulationOnlyDeclarationJob.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/Document/SimulationOnlyDeclarationJob.cs @@ -1,4 +1,5 @@ -using System.Configuration; +using System; +using System.Configuration; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCore.Utils; using VECTO3GUI2020.ViewModel.Implementation.Common; @@ -42,6 +43,12 @@ namespace VECTO3GUI2020.ViewModel.Implementation.Document set => SetProperty(ref _selected, value); } + public bool CanBeSimulated + { + get => true; + set => throw new NotImplementedException(); + } + #endregion public SimulationOnlyDeclarationJob(DataSource dataSource, string name, XmlDocumentType documentType) diff --git a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs index 678aaf675999dbd98285ff493f12da4f04f853d6..dcb1fc98c0a429131d26653cab6cfcf1e706f1f4 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs @@ -621,7 +621,10 @@ namespace VECTO3GUI2020.ViewModel.Implementation { get => _openNewFilePopUpCommand ?? (_openNewFilePopUpCommand = new RelayCommand(() => { - NewFilePopUpIsOpen = true; + if (NewFilePopUpIsOpen == false) { + NewFilePopUpIsOpen = true; + } + })); } diff --git a/VECTO3GUI2020/ViewModel/Interfaces/Document/IDocumentViewModel.cs b/VECTO3GUI2020/ViewModel/Interfaces/Document/IDocumentViewModel.cs index 0216c11ef66ca39761a2a4d71f30f1cf1cccbb74..2824842b4e1565918661196c3add284b97c4431d 100644 --- a/VECTO3GUI2020/ViewModel/Interfaces/Document/IDocumentViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Interfaces/Document/IDocumentViewModel.cs @@ -11,5 +11,7 @@ namespace VECTO3GUI2020.ViewModel.Interfaces.Document DataSource DataSource { get; } IEditViewModel EditViewModel { get; } bool Selected { get; set; } + + bool CanBeSimulated { get; set; } } } diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs index 9d5226e40241048a619711be0ef8d0cf825b364c..ba3b4bce842bf14e80a4e4f01fb6935328344a0b 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs @@ -273,6 +273,15 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation set => SetProperty(ref _selected, value); } + public bool CanBeSimulated + { + get + { + throw new NotImplementedException(); + } + set => throw new NotImplementedException(); + } + #endregion #region Implementation of IMultistageVIFInputData diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/StageInputViewModel.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/StageInputViewModel.cs index 51f2ff8f33f5265e599492ca788647d588e7840a..098b23d75d3e29c3c9c7949cb7afe2a0627cd399 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/StageInputViewModel.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/StageInputViewModel.cs @@ -73,6 +73,12 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation set => SetProperty(ref _selected, value); } + public bool CanBeSimulated + { + get => false; + set => throw new System.NotImplementedException(); + } + #endregion #region Implementation of IEditViewModel diff --git a/VECTO3GUI2020/Views/JoblistView.xaml b/VECTO3GUI2020/Views/JoblistView.xaml index 6da05e9e0ffb49f39b180ba86fcd19c22740a8c2..a43520f22220053a3e9b0db4a1cbab23ddb1bd8b 100644 --- a/VECTO3GUI2020/Views/JoblistView.xaml +++ b/VECTO3GUI2020/Views/JoblistView.xaml @@ -120,11 +120,7 @@ Margin="{Binding ElementName=newFileButton, Path=Margin}" MinWidth="{Binding ElementName=newFileButton, Path=ActualWidth}" IsOpen="{Binding NewFilePopUpIsOpen, Mode=TwoWay}" - StaysOpen="False"> - - <!--<i:Interaction.Behaviors> - <behavior:PopUpHorizontalAlignmentBehavior/> - </i:Interaction.Behaviors>--> + StaysOpen="False" PreviewMouseLeftButtonUp="NewFilePopup_OnPreviewMouseLeftButtonDown"> <Border BorderThickness="1px" BorderBrush="{StaticResource AccentColorButton}"> <StackPanel Background="White"> <Button Style="{StaticResource MultiStageButtonStyle1}" Command="{Binding NewManufacturingStageFileCommand}">New Manufacturing Stage</Button> diff --git a/VECTO3GUI2020/Views/JoblistView.xaml.cs b/VECTO3GUI2020/Views/JoblistView.xaml.cs index 99cca39297e9963e13f3f4ffdb75a9e8d89f23c1..9139145be8a73722253f095b3036fc8de24a2562 100644 --- a/VECTO3GUI2020/Views/JoblistView.xaml.cs +++ b/VECTO3GUI2020/Views/JoblistView.xaml.cs @@ -53,5 +53,20 @@ namespace VECTO3GUI2020.Views { CommandManager.InvalidateRequerySuggested(); } + + private void NewFilePopup_OnMouseLeave(object sender, MouseEventArgs e) + { + + } + + private void NewFilePopup_OnMouseDown(object sender, MouseButtonEventArgs e) + { + newFilePopup.IsOpen = false; + } + + private void NewFilePopup_OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + newFilePopup.IsOpen = false; + } } } diff --git a/Vecto3GUI2020Test/ViewModelTests/JobListViewModelTests.cs b/Vecto3GUI2020Test/ViewModelTests/JobListViewModelTests.cs index ac682750c3e04c4838ce2ad28d08fa333f415a51..7c9a1421011b8929bd51cebb49361780d22a1406 100644 --- a/Vecto3GUI2020Test/ViewModelTests/JobListViewModelTests.cs +++ b/Vecto3GUI2020Test/ViewModelTests/JobListViewModelTests.cs @@ -16,7 +16,16 @@ namespace Vecto3GUI2020Test.ViewModelTests { private string finalVIF = "final.VIF_Report_4.xml"; - + + [Test] + public async Task LoadPrimaryFile() + { + var jobListViewModel = _kernel.Get<IJobListViewModel>() as JobListViewModel; + Write("Trying to load {}"); + + + } + [Test] public async Task CancelSimulationWhileLoadingFiles()