diff --git a/POC/WpfApp1.sln b/POC/WpfApp1.sln new file mode 100644 index 0000000..cc8fa16 --- /dev/null +++ b/POC/WpfApp1.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34031.279 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfApp1", "WpfApp1\WpfApp1.csproj", "{5E84BEC0-370F-4F3E-8B59-E37EFD3E4438}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5E84BEC0-370F-4F3E-8B59-E37EFD3E4438}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5E84BEC0-370F-4F3E-8B59-E37EFD3E4438}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5E84BEC0-370F-4F3E-8B59-E37EFD3E4438}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5E84BEC0-370F-4F3E-8B59-E37EFD3E4438}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C7CDF771-EEA9-421B-854E-7D1CC90BA16A} + EndGlobalSection +EndGlobal diff --git a/POC/WpfApp1/App.config b/POC/WpfApp1/App.config new file mode 100644 index 0000000..7c4b745 --- /dev/null +++ b/POC/WpfApp1/App.config @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/POC/WpfApp1/App.xaml b/POC/WpfApp1/App.xaml new file mode 100644 index 0000000..b84951b --- /dev/null +++ b/POC/WpfApp1/App.xaml @@ -0,0 +1,10 @@ + + + + + diff --git a/POC/WpfApp1/App.xaml.cs b/POC/WpfApp1/App.xaml.cs new file mode 100644 index 0000000..38f5edd --- /dev/null +++ b/POC/WpfApp1/App.xaml.cs @@ -0,0 +1,9 @@ +namespace WpfApp1 +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App + { + } +} diff --git a/POC/WpfApp1/DialogFrame.xaml b/POC/WpfApp1/DialogFrame.xaml new file mode 100644 index 0000000..fa2ba95 --- /dev/null +++ b/POC/WpfApp1/DialogFrame.xaml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/POC/WpfApp1/DialogFrame.xaml.cs b/POC/WpfApp1/DialogFrame.xaml.cs new file mode 100644 index 0000000..99a3dda --- /dev/null +++ b/POC/WpfApp1/DialogFrame.xaml.cs @@ -0,0 +1,76 @@ +using System.Windows.Controls; +using System.Windows.Input; + +namespace WpfApp1 +{ + using System.Windows; + + /// + /// Interaction logic for DialogFrame.xaml + /// + public partial class DialogFrame + { + private Point? _mousePointOnClick; + + public DialogFrame(string title, string message) + { + InitializeComponent(); + this.TitleBlock.Text = title; + this.MessageBlock.Text = message; + SetMouseStatus(); + } + + private void CloseDialog_OnClick(object sender, RoutedEventArgs e) + { + DialogService.Instance.Remove(this); + } + + private void NewDialog_OnClick(object sender, RoutedEventArgs e) + { + DialogService.Instance.Add( + new DialogFrame("Child", $"Child dialog {DialogService.Instance.Dialogs.Count}") + ); + } + + private void Border_OnMouseDown(object sender, MouseButtonEventArgs e) + { + var thisPosition = e.GetPosition(this); + _mousePointOnClick = new Point( + thisPosition.X - BorderTransform.X, + thisPosition.Y - BorderTransform.Y + ); + SetMouseStatus(); + } + + private void Border_OnMouseMove(object sender, MouseEventArgs e) + { + if (e.LeftButton == MouseButtonState.Pressed && _mousePointOnClick is { } pointOnClick) + { + var pos = e.GetPosition(this); + BorderTransform.X = pos.X - pointOnClick.X; + BorderTransform.Y = pos.Y - pointOnClick.Y; + } + SetMouseStatus(); + } + + private void Border_OnMouseUp(object sender, MouseButtonEventArgs e) + { + _mousePointOnClick = null; + SetMouseStatus(); + } + + private void SetMouseStatus() + { + MouseStatus.Text = + $"""PointOnClick:"{(_mousePointOnClick?.ToString() ?? "")}", BorderTransform:"{BorderTransform.X:F1}:{BorderTransform.Y:F1}" """; + } + + private void DialogFrame_OnKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Escape) + { + DialogService.Instance.Remove(this); + } + } + } +} diff --git a/POC/WpfApp1/DialogService.cs b/POC/WpfApp1/DialogService.cs new file mode 100644 index 0000000..ae81a66 --- /dev/null +++ b/POC/WpfApp1/DialogService.cs @@ -0,0 +1,31 @@ +namespace WpfApp1 +{ + using System; + using System.Collections.ObjectModel; + using System.Windows.Controls; + + public class DialogService + { + private static readonly Lazy LazyInstance = new(() => new DialogService()); + private readonly ObservableCollection _dialogs = new(); + + public DialogService() + { + Dialogs = new ReadOnlyObservableCollection(_dialogs); + } + + public static DialogService Instance => LazyInstance.Value; + + public ReadOnlyObservableCollection Dialogs { get; } + + public void Add(UserControl userControl) + { + _dialogs.Add(userControl); + } + + public void Remove(UserControl userControl) + { + _dialogs.Remove(userControl); + } + } +} diff --git a/POC/WpfApp1/MainWindow.xaml b/POC/WpfApp1/MainWindow.xaml new file mode 100644 index 0000000..aea147c --- /dev/null +++ b/POC/WpfApp1/MainWindow.xaml @@ -0,0 +1,40 @@ + + + + + + + + + + +