From 79cb4e08a7c26ecb9fe5e5200c6b71402afacf60 Mon Sep 17 00:00:00 2001 From: Kouji Matsui Date: Mon, 27 May 2024 19:39:14 +0900 Subject: [PATCH] WIP --- .../ViewModels/MainWindowViewModel.cs | 17 ++ .../EpoxyHello.Wpf/EpoxyHello.Wpf.csproj | 3 +- .../ViewModels/MainWindowViewModel.cs | 35 +++- .../EpoxyHello.Wpf/Views/MainWindow.xaml | 7 +- src/Epoxy.Build/ViewModelInjector.cs | 167 ++++++++++++++++-- 5 files changed, 199 insertions(+), 30 deletions(-) diff --git a/playground/EpoxyHello.Avalonia11/ViewModels/MainWindowViewModel.cs b/playground/EpoxyHello.Avalonia11/ViewModels/MainWindowViewModel.cs index 7cbe7188..8504537b 100644 --- a/playground/EpoxyHello.Avalonia11/ViewModels/MainWindowViewModel.cs +++ b/playground/EpoxyHello.Avalonia11/ViewModels/MainWindowViewModel.cs @@ -48,6 +48,23 @@ public sealed class MainWindowViewModel public MainWindowViewModel() { // A handler for window opened + //this.MainWindowWell.Add( + // //Window.WindowOpenedEvent, + // "Opened", + // () => + // { + // this.IsEnabled = true; + // return default; + // }, + // (window, obj, ptr) => { + // var dlg = new EventHandler(obj, ptr); + // window.Opened += dlg; + // }, + // (window, obj, ptr) => { + // var dlg = new EventHandler(obj, ptr); + // window.Opened -= dlg; + // }); + this.MainWindowWell.Add( Window.WindowOpenedEvent, () => diff --git a/playground/EpoxyHello.Wpf/EpoxyHello.Wpf.csproj b/playground/EpoxyHello.Wpf/EpoxyHello.Wpf.csproj index 8d1eade7..693119ff 100644 --- a/playground/EpoxyHello.Wpf/EpoxyHello.Wpf.csproj +++ b/playground/EpoxyHello.Wpf/EpoxyHello.Wpf.csproj @@ -4,8 +4,9 @@ WinExe - net461;netcoreapp3.1;net5.0-windows;net6.0-windows;net7.0-windows + net461;netcoreapp3.1;net5.0-windows;net6.0-windows;net7.0-windows;net8.0-windows true + false diff --git a/playground/EpoxyHello.Wpf/ViewModels/MainWindowViewModel.cs b/playground/EpoxyHello.Wpf/ViewModels/MainWindowViewModel.cs index 3e356c54..86c52d2d 100644 --- a/playground/EpoxyHello.Wpf/ViewModels/MainWindowViewModel.cs +++ b/playground/EpoxyHello.Wpf/ViewModels/MainWindowViewModel.cs @@ -24,6 +24,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; +using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; @@ -36,7 +37,7 @@ namespace EpoxyHello.Wpf.ViewModels; [ViewModel] public sealed class MainWindowViewModel { - public Command Ready { get; } + public Well MainWindowWell { get; } = Well.Factory.Create(); public bool IsEnabled { get; set; } @@ -48,12 +49,32 @@ public sealed class MainWindowViewModel public MainWindowViewModel() { - // A handler for window loaded - this.Ready = Command.Factory.Create(() => - { - this.IsEnabled = true; - return default; - }); + // A handler for window opened + //this.MainWindowWell.Add( + // //FrameworkElement.LoadedEvent, + // "Loaded", + // () => + // { + // this.IsEnabled = true; + // return default; + // }, + // (window, obj, ptr) => { + // var dlg = new EventHandler(obj, ptr); + // window.Opened += dlg; + // }, + // (window, obj, ptr) => { + // var dlg = new EventHandler(obj, ptr); + // window.Opened -= dlg; + // }); + + this.MainWindowWell.Add( + //FrameworkElement.LoadedEvent, + "Loaded", + () => + { + this.IsEnabled = true; + return default; + }); // A handler for fetch button this.Fetch = Command.Factory.Create(async () => diff --git a/playground/EpoxyHello.Wpf/Views/MainWindow.xaml b/playground/EpoxyHello.Wpf/Views/MainWindow.xaml index b39a8110..e092455b 100644 --- a/playground/EpoxyHello.Wpf/Views/MainWindow.xaml +++ b/playground/EpoxyHello.Wpf/Views/MainWindow.xaml @@ -27,15 +27,12 @@ xmlns:viewmodels="clr-namespace:EpoxyHello.Wpf.ViewModels" xmlns:converters="clr-namespace:EpoxyHello.Wpf.Views.Converters" mc:Ignorable="d" - Title="EpoxyHello.Wpf" Height="450" Width="800"> + Title="EpoxyHello.Wpf" Height="450" Width="800" + epoxy:Fountain.Well="{Binding MainWindowWell}"> - - - -