diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index 2da31e33d..1f46218a3 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -120,6 +120,10 @@ AnimatedBeWoWindow.xaml + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/BeWo/Styles/ControlStyles/PopupStyles.xaml b/BeWo/Styles/ControlStyles/PopupStyles.xaml new file mode 100644 index 000000000..bf1997c31 --- /dev/null +++ b/BeWo/Styles/ControlStyles/PopupStyles.xaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/BeWo/Styles/ModernOrangeBlack.xaml b/BeWo/Styles/ModernOrangeBlack.xaml index fc4ec3142..7bf2bb3ed 100644 --- a/BeWo/Styles/ModernOrangeBlack.xaml +++ b/BeWo/Styles/ModernOrangeBlack.xaml @@ -20,6 +20,7 @@ + diff --git a/BeWo/View/Core/WaitLayer3.xaml b/BeWo/View/Core/WaitLayer3.xaml index b796ba4ea..2f6d68d35 100644 --- a/BeWo/View/Core/WaitLayer3.xaml +++ b/BeWo/View/Core/WaitLayer3.xaml @@ -5,6 +5,9 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:BeWo.View.Core" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:view="clr-namespace:BeWo.ViewModel.View" + d:DataContext="{d:DesignInstance Type=view:WindowViewModel, + IsDesignTimeCreatable=True}" mc:Ignorable="d"> @@ -41,14 +44,23 @@ + + + + + + + Margin="4"> diff --git a/BeWo/View/Windows/AnimatedBeWoWindow.xaml b/BeWo/View/Windows/AnimatedBeWoWindow.xaml index 174c1238f..678b5b1f4 100644 --- a/BeWo/View/Windows/AnimatedBeWoWindow.xaml +++ b/BeWo/View/Windows/AnimatedBeWoWindow.xaml @@ -3,6 +3,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:core="clr-namespace:BeWo.View.Core" + xmlns:view="clr-namespace:BeWo.ViewModel.View" Title="BeWoPlaner" MinWidth="300" MinHeight="300" @@ -15,6 +16,9 @@ TextOptions.TextFormattingMode="Display" WindowStartupLocation="CenterOwner" WindowStyle="None"> + + + @@ -38,12 +42,11 @@ HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Panel.ZIndex="1000" + Background="#40FFFFFF" Focusable="True" IsHitTestVisible="True" KeyboardNavigation.IsTabStop="True" - Visibility="{Binding IsWaiting, Converter={StaticResource BoolVisibilityConverter}}" - Background="#80000000"> - + Visibility="{Binding IsWaiting, Converter={StaticResource BoolVisibilityConverter}}"> diff --git a/BeWo/View/Windows/AnimatedBeWoWindow.xaml.cs b/BeWo/View/Windows/AnimatedBeWoWindow.xaml.cs index 15f09da7e..0e3ab0a9c 100644 --- a/BeWo/View/Windows/AnimatedBeWoWindow.xaml.cs +++ b/BeWo/View/Windows/AnimatedBeWoWindow.xaml.cs @@ -1,9 +1,11 @@ using BeWo.ViewModel.View; +using DevExpress.Web.Internal.XmlProcessor; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; @@ -24,8 +26,9 @@ namespace BeWo.View.Windows /// public partial class AnimatedBeWoWindow : Window { - private bool closeStoryBoardCompleted = false; + private bool closePopupStoryBoardCompleted = false; + private bool openPopupStoryBoardCompleted = false; private bool isClosing = false; private WaitLayer2 _WaitLayer; @@ -50,8 +53,6 @@ namespace BeWo.View.Windows public AnimatedBeWoWindow() { - ViewModel = new WindowViewModel(); - InitializeComponent(); CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => Close())); @@ -161,7 +162,33 @@ namespace BeWo.View.Windows public void StartWaiting() { - Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)StartWaitingImmediately); + if (openPopupStoryBoardCompleted) + return; + + Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)delegate + { + if (FindResource("PopupLoadedAnimation") is Storyboard storyboard) + { + openPopupStoryBoardCompleted = true; + StartWaitingImmediately(); + storyboard.Completed += openPopupStoryBoard_Completed; + Storyboard.SetTarget(storyboard.Children[0], _WaitingLayer); + Storyboard.SetTarget(storyboard.Children[1], _WaitingLayer); + storyboard.Begin(); + } + else + { + throw new InvalidOperationException("PopupLoadedAnimation not found"); + } + }); + } + + private void openPopupStoryBoard_Completed(object sender, EventArgs e) + { + if (!openPopupStoryBoardCompleted) + return; + + openPopupStoryBoardCompleted = false; } public void StartWaitingImmediately() @@ -173,12 +200,38 @@ namespace BeWo.View.Windows public void EndWaiting() { - Dispatcher.BeginInvoke( - DispatcherPriority.Render, - (Action)delegate + if (closePopupStoryBoardCompleted) + return; + + Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate + { + if (FindResource("PopupClosingAnimation") is Storyboard storyboard) { - ViewModel.IsWaiting = false; - }); + closePopupStoryBoardCompleted = true; + storyboard.Completed += closePopupStoryBoard_Completed; + Storyboard.SetTarget(storyboard.Children[0], _WaitingLayer); + Storyboard.SetTarget(storyboard.Children[1], _WaitingLayer); + storyboard.Begin(); + } + else + { + throw new InvalidOperationException("PopupClosingAnimation not found"); + } + }); + } + + private void closePopupStoryBoard_Completed(object sender, EventArgs e) + { + if (!closePopupStoryBoardCompleted) + return; + + closePopupStoryBoardCompleted = false; + Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)EndWaitingImmediately); + } + + public void EndWaitingImmediately() + { + ViewModel.IsWaiting = false; } } } diff --git a/BeWo/ViewModel/View/WindowViewModel.cs b/BeWo/ViewModel/View/WindowViewModel.cs index e5378eb3d..6b098af8e 100644 --- a/BeWo/ViewModel/View/WindowViewModel.cs +++ b/BeWo/ViewModel/View/WindowViewModel.cs @@ -14,6 +14,9 @@ namespace BeWo.ViewModel.View public WindowViewModel() { WaitingText = "Bitte warten..."; + + if(BeWoApp.IsInDesignMode) + IsWaiting = true; } public bool IsWaiting