From 82a9f110aaffa378ce1603bac3574ad81c94611e Mon Sep 17 00:00:00 2001 From: Dongmin Jang Date: Tue, 11 Jun 2024 13:09:17 +0900 Subject: [PATCH] Edit widget entry point --- Corathing.sln | 23 +++++++ src/Apps/Corathing.Organizer/App.xaml | 2 - src/Apps/Corathing.Organizer/App.xaml.cs | 2 - .../Corathing.Organizer/MainWindow.xaml.cs | 45 ++++++++++-- .../Services/PackageService.cs | 32 +++++---- .../ViewModels/DashboardViewModel.cs | 7 +- .../ViewModels/MainViewModel.cs | 51 ++++++++++++++ .../Attributes/WidgetContextEntryAttribute.cs | 40 ----------- .../Entries/CoraWidgetGenerationInfo.cs | 15 ++++ .../CoraWidgetGenerator.cs} | 43 ++++++------ .../Entries/CoraWidgetMenuInfo.cs | 14 ++++ .../Entries/EntryCoraDataSourceAttribute.cs | 11 +++ .../Entries/EntryCoraPackageAttribute.cs | 11 +++ .../Entries/EntryCoraWidgetAttribute.cs | 54 +++++++++++++++ .../Services/IPackageService.cs | 6 +- .../Widgets/EmptyWidget.xaml | 12 ---- .../Widgets/EmptyWidget.xaml.cs | 60 ---------------- .../Corathing.UI.WPF/Corathing.UI.WPF.csproj | 4 ++ .../Corathing.Widget.Templates/Class1.cs | 7 ++ .../Corathing.Widget.Templates.csproj | 9 +++ .../Widgets/Calendars/CalendarWidget.xaml | 11 +++ .../Widgets/Calendars/CalendarWidget.xaml.cs | 69 +++++++++++++++++++ .../Widgets/Calendars/DataTemplates.xaml | 7 ++ .../Commanders/CommanderWidget.xaml.cs | 11 +-- .../Widgets/Commanders/DataTemplates.xaml | 7 ++ .../Widgets/DataTemplates.xaml | 49 ------------- .../Widgets/FileOpeners/DataTemplates.xaml | 7 ++ .../FileOpeners/FileOpenerWidget.xaml.cs | 13 ++-- .../Widgets/LinkOpeners/DataTemplates.xaml | 7 ++ .../LinkOpeners/LinkOpenerWidget.xaml.cs | 11 +-- .../Widgets/Monacos/DataTemplates.xaml | 7 ++ .../Widgets/Monacos/MonacoWidget.xaml.cs | 10 +-- .../Widgets/Notes/DataTemplates.xaml | 7 ++ .../Widgets/Notes/NoteWidget.xaml.cs | 11 +-- .../Widgets/Timers/DataTemplates.xaml} | 8 +-- .../Widgets/Timers/TimerWidget.xaml.cs | 10 +-- .../Widgets/ToDoLists/DataTemplates.xaml | 7 ++ .../Widgets/ToDoLists/ToDoListWidget.xaml.cs | 10 +-- .../Widgets/WebPages/DataTemplates.xaml | 7 ++ .../Widgets/WebPages/WebPageWidget.xaml.cs | 10 +-- .../Widgets/WebQueries/DataTemplates.xaml | 7 ++ .../Widgets/WebQueries/WebQueryWidget.xaml.cs | 10 +-- 42 files changed, 492 insertions(+), 252 deletions(-) rename src/{Shared/Corathing.Dashboards => Apps/Corathing.Organizer}/Services/PackageService.cs (63%) create mode 100644 src/Apps/Corathing.Organizer/ViewModels/MainViewModel.cs delete mode 100644 src/Shared/Corathing.Contracts/Attributes/WidgetContextEntryAttribute.cs create mode 100644 src/Shared/Corathing.Contracts/Entries/CoraWidgetGenerationInfo.cs rename src/Shared/Corathing.Contracts/{Bases/WidgetGenerator.cs => Entries/CoraWidgetGenerator.cs} (64%) create mode 100644 src/Shared/Corathing.Contracts/Entries/CoraWidgetMenuInfo.cs create mode 100644 src/Shared/Corathing.Contracts/Entries/EntryCoraDataSourceAttribute.cs create mode 100644 src/Shared/Corathing.Contracts/Entries/EntryCoraPackageAttribute.cs create mode 100644 src/Shared/Corathing.Contracts/Entries/EntryCoraWidgetAttribute.cs delete mode 100644 src/Shared/Corathing.Dashboards.WPF/Widgets/EmptyWidget.xaml delete mode 100644 src/Shared/Corathing.Dashboards.WPF/Widgets/EmptyWidget.xaml.cs create mode 100644 src/Widgets/Corathing.Widget.Templates/Class1.cs create mode 100644 src/Widgets/Corathing.Widget.Templates/Corathing.Widget.Templates.csproj create mode 100644 src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/CalendarWidget.xaml create mode 100644 src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/CalendarWidget.xaml.cs create mode 100644 src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/DataTemplates.xaml create mode 100644 src/Widgets/Corathing.Widgets.Basics/Widgets/Commanders/DataTemplates.xaml delete mode 100644 src/Widgets/Corathing.Widgets.Basics/Widgets/DataTemplates.xaml create mode 100644 src/Widgets/Corathing.Widgets.Basics/Widgets/FileOpeners/DataTemplates.xaml create mode 100644 src/Widgets/Corathing.Widgets.Basics/Widgets/LinkOpeners/DataTemplates.xaml create mode 100644 src/Widgets/Corathing.Widgets.Basics/Widgets/Monacos/DataTemplates.xaml create mode 100644 src/Widgets/Corathing.Widgets.Basics/Widgets/Notes/DataTemplates.xaml rename src/{Shared/Corathing.Dashboards.WPF/Widgets/WidgetDataTemplates.xaml => Widgets/Corathing.Widgets.Basics/Widgets/Timers/DataTemplates.xaml} (53%) create mode 100644 src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/DataTemplates.xaml create mode 100644 src/Widgets/Corathing.Widgets.Basics/Widgets/WebPages/DataTemplates.xaml create mode 100644 src/Widgets/Corathing.Widgets.Basics/Widgets/WebQueries/DataTemplates.xaml diff --git a/Corathing.sln b/Corathing.sln index d6733d1..301083d 100644 --- a/Corathing.sln +++ b/Corathing.sln @@ -37,6 +37,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Corathing.Widgets.Basics", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Corathing.UI.WPF", "src\Shared\Corathing.UI.WPF\Corathing.UI.WPF.csproj", "{F0AF90D5-5E28-4FC1-8DBD-8B3F68A285DB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Corathing.Widget.Templates", "src\Widgets\Corathing.Widget.Templates\Corathing.Widget.Templates.csproj", "{3CED3EA9-D293-44BD-9838-FC1AF1FFC626}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -221,6 +223,26 @@ Global {F0AF90D5-5E28-4FC1-8DBD-8B3F68A285DB}.Release|x64.Build.0 = Release|Any CPU {F0AF90D5-5E28-4FC1-8DBD-8B3F68A285DB}.Release|x86.ActiveCfg = Release|Any CPU {F0AF90D5-5E28-4FC1-8DBD-8B3F68A285DB}.Release|x86.Build.0 = Release|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Debug|ARM.ActiveCfg = Debug|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Debug|ARM.Build.0 = Debug|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Debug|ARM64.Build.0 = Debug|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Debug|x64.ActiveCfg = Debug|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Debug|x64.Build.0 = Debug|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Debug|x86.ActiveCfg = Debug|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Debug|x86.Build.0 = Debug|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Release|Any CPU.Build.0 = Release|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Release|ARM.ActiveCfg = Release|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Release|ARM.Build.0 = Release|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Release|ARM64.ActiveCfg = Release|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Release|ARM64.Build.0 = Release|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Release|x64.ActiveCfg = Release|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Release|x64.Build.0 = Release|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Release|x86.ActiveCfg = Release|Any CPU + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -234,6 +256,7 @@ Global {B07D1162-D70E-4CCB-8F13-2E21611B9214} = {89CC8AAB-466A-47B6-98B9-93EB379F55A7} {8BB7B29E-4684-4F2F-9932-698FDAD2FCDA} = {B32F5E62-3357-4FE1-BEB3-7CDED236BA66} {F0AF90D5-5E28-4FC1-8DBD-8B3F68A285DB} = {89CC8AAB-466A-47B6-98B9-93EB379F55A7} + {3CED3EA9-D293-44BD-9838-FC1AF1FFC626} = {B32F5E62-3357-4FE1-BEB3-7CDED236BA66} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {FC027A8C-0C58-494B-BE76-F403F0336A74} diff --git a/src/Apps/Corathing.Organizer/App.xaml b/src/Apps/Corathing.Organizer/App.xaml index 477944a..4c31e18 100644 --- a/src/Apps/Corathing.Organizer/App.xaml +++ b/src/Apps/Corathing.Organizer/App.xaml @@ -15,8 +15,6 @@ - - diff --git a/src/Apps/Corathing.Organizer/App.xaml.cs b/src/Apps/Corathing.Organizer/App.xaml.cs index 6591e37..9aa5866 100644 --- a/src/Apps/Corathing.Organizer/App.xaml.cs +++ b/src/Apps/Corathing.Organizer/App.xaml.cs @@ -6,7 +6,6 @@ using System.Windows; using Corathing.Contracts.Services; -using Corathing.Dashboards.Services; using Corathing.Dashboards.WPF.Services; using Corathing.Organizer.Resources; using Corathing.Organizer.Services; @@ -109,7 +108,6 @@ protected override void OnStartup(StartupEventArgs e) // Available Widgets // -------------------------------------------------------------------------- IPackageService widgetService = Services.GetService(); - widgetService.LoadWidgetsFromDLL("Corathing.Dashboards.WPF.dll"); widgetService.LoadWidgetsFromDLL("Corathing.Widgets.Basics.dll"); //widgetService.LoadWidgetsFromDLL("DDT.Core.WidgetSystems.DefaultWidgets.dll"); //widgetService.RegisterWidgets(new List { new WidgetGenerator() }); diff --git a/src/Apps/Corathing.Organizer/MainWindow.xaml.cs b/src/Apps/Corathing.Organizer/MainWindow.xaml.cs index 980a14c..0b32927 100644 --- a/src/Apps/Corathing.Organizer/MainWindow.xaml.cs +++ b/src/Apps/Corathing.Organizer/MainWindow.xaml.cs @@ -9,20 +9,51 @@ using System.Windows.Navigation; using System.Windows.Shapes; +using Corathing.Organizer.ViewModels; + using MahApps.Metro.Controls; using Wpf.Ui.Controls; -namespace Corathing.Organizer +namespace Corathing.Organizer; + +/// +/// Interaction logic for MainWindow.xaml +/// +public partial class MainWindow : MetroWindow { - /// - /// Interaction logic for MainWindow.xaml - /// - public partial class MainWindow : MetroWindow + public MainViewModel ViewModel; + + public MainWindow() { - public MainWindow() + InitializeComponent(); + + DataContext = ViewModel = new MainViewModel(); + + MouseDown += Window_MouseDown; + MouseDoubleClick += Window_MouseDoubleClick; + } + + private void Window_MouseDoubleClick(object sender, MouseButtonEventArgs e) + { + if (e.GetPosition(this).Y >= 64) + return; + + if (e.ChangedButton == MouseButton.Left) { - InitializeComponent(); + if (WindowState == WindowState.Normal) + WindowState = WindowState.Maximized; + else + WindowState = WindowState.Normal; } } + + private void Window_MouseDown(object sender, MouseButtonEventArgs e) + { + if (e.GetPosition(this).Y >= 64) + return; + + if (e.ChangedButton == MouseButton.Left) + this.DragMove(); + } } diff --git a/src/Shared/Corathing.Dashboards/Services/PackageService.cs b/src/Apps/Corathing.Organizer/Services/PackageService.cs similarity index 63% rename from src/Shared/Corathing.Dashboards/Services/PackageService.cs rename to src/Apps/Corathing.Organizer/Services/PackageService.cs index f618dfc..61dd509 100644 --- a/src/Shared/Corathing.Dashboards/Services/PackageService.cs +++ b/src/Apps/Corathing.Organizer/Services/PackageService.cs @@ -4,12 +4,15 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; +using System.Windows; -using Corathing.Contracts.Attributes; using Corathing.Contracts.Bases; +using Corathing.Contracts.Entries; + using Corathing.Contracts.Services; -namespace Corathing.Dashboards.Services; +namespace Corathing.Organizer.Services; + public class ProxyDomain : MarshalByRefObject { @@ -31,7 +34,7 @@ public class PackageService : IPackageService /// Gets or sets the available widgets. /// /// The available widgets. - private readonly List _availableWidgets = new List(); + private readonly List _availableWidgets = new List(); private readonly IServiceProvider _services; public PackageService(IServiceProvider services) @@ -40,11 +43,11 @@ public PackageService(IServiceProvider services) } - public void RegisterWidgets(List widgets) + public void RegisterWidgets(List widgets) { _availableWidgets.AddRange(widgets); } - public List GetAvailableWidgets() + public List GetAvailableWidgets() { return _availableWidgets; } @@ -53,7 +56,6 @@ public void LoadWidgetsFromDLL(string pathDLL) { Assembly a = Assembly.LoadFrom(pathDLL); var types = a.GetTypes().Where(t => typeof(WidgetContext).IsAssignableFrom(t)); - List widgets = new List(); // TODO: // 도메인 프록시 문제 해결 필요 //var setup = new AppDomainSetup @@ -61,6 +63,7 @@ public void LoadWidgetsFromDLL(string pathDLL) // ApplicationBase = AppDomain.CurrentDomain.BaseDirectory, // PrivateBinPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) //}; + foreach (var type in types) { System.Reflection.MemberInfo info = type; @@ -68,15 +71,20 @@ public void LoadWidgetsFromDLL(string pathDLL) for (int i = 0; i < attributes.Length; i++) { - if (attributes[i] is WidgetContextEntryAttribute) + if (attributes[i] is EntryCoraWidgetAttribute) { - var attribute = ((WidgetContextEntryAttribute)attributes[i]); - attribute.RegisterServices(_services); - widgets.Add(attribute.WidgetGenerator); + var attribute = ((EntryCoraWidgetAttribute)attributes[i]); + attribute.Configure(_services); + _availableWidgets.Add(attribute.Generator); + + App.Current.Resources.MergedDictionaries.Add( + new ResourceDictionary() + { + Source = new Uri($"pack://application:,,,/{attribute.Generator.ViewType.Assembly.GetName().Name};component/{attribute.Generator.DataTemplateSource}", UriKind.Absolute) + } + ); } } } - - RegisterWidgets(widgets); } } diff --git a/src/Apps/Corathing.Organizer/ViewModels/DashboardViewModel.cs b/src/Apps/Corathing.Organizer/ViewModels/DashboardViewModel.cs index dc75125..3264074 100644 --- a/src/Apps/Corathing.Organizer/ViewModels/DashboardViewModel.cs +++ b/src/Apps/Corathing.Organizer/ViewModels/DashboardViewModel.cs @@ -13,7 +13,9 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; + using Corathing.Contracts.Bases; +using Corathing.Contracts.Entries; using Corathing.Contracts.Services; using Corathing.Dashboards.WPF.Controls; @@ -21,6 +23,7 @@ using Corathing.Organizer.Extensions; using Corathing.Organizer.Models; using Corathing.Organizer.Views; + using Microsoft.Extensions.DependencyInjection; using Wpf.Ui; @@ -81,7 +84,7 @@ protected override void OnPropertyChanged(PropertyChangedEventArgs e) } [RelayCommand] - public void AddWidget(WidgetGenerator generator) + public void AddWidget(CoraWidgetGenerator generator) { if (SelectedProject == null) return; @@ -290,7 +293,7 @@ public Task Start(IServiceProvider services) IPackageService packageService = services.GetService(); foreach (var widget in packageService.GetAvailableWidgets()) { - var fullMenuHeader = widget.MenuPath; + var fullMenuHeader = widget.MenuInfo.MenuPath; if (string.IsNullOrEmpty(fullMenuHeader)) continue; diff --git a/src/Apps/Corathing.Organizer/ViewModels/MainViewModel.cs b/src/Apps/Corathing.Organizer/ViewModels/MainViewModel.cs new file mode 100644 index 0000000..713cfdf --- /dev/null +++ b/src/Apps/Corathing.Organizer/ViewModels/MainViewModel.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +using CommunityToolkit.Mvvm.ComponentModel; + +using Wpf.Ui.Controls; + +namespace Corathing.Organizer.ViewModels; + +/// +/// Extended with properties. +/// +public class MenuItem : System.Windows.Controls.MenuItem +{ + static MenuItem() + { + IconProperty.OverrideMetadata(typeof(MenuItem), new FrameworkPropertyMetadata(null)); + } + + /// + /// Gets or sets displayed . + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage( + "WpfAnalyzers.DependencyProperty", + "WPF0012:CLR property type should match registered type", + Justification = "seems harmless" + )] + public new IconElement Icon + { + get => (IconElement)GetValue(IconProperty); + set => SetValue(IconProperty, value); + } +} + +public partial class MainViewModel : ObservableObject +{ + + [ObservableProperty] + private ObservableCollection _trayMenuItems = []; + + public MainViewModel() + { + + TrayMenuItems = [new() { Header = "Home", Tag = "tray_home" }]; + } +} diff --git a/src/Shared/Corathing.Contracts/Attributes/WidgetContextEntryAttribute.cs b/src/Shared/Corathing.Contracts/Attributes/WidgetContextEntryAttribute.cs deleted file mode 100644 index 51e5a6b..0000000 --- a/src/Shared/Corathing.Contracts/Attributes/WidgetContextEntryAttribute.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using Corathing.Contracts.Bases; - -namespace Corathing.Contracts.Attributes; - -[AttributeUsage(AttributeTargets.Class)] -public class WidgetContextEntryAttribute : Attribute -{ - public IServiceProvider Services { get; set; } - - public WidgetGenerator WidgetGenerator { get; private set; } - - public WidgetContextEntryAttribute(string name, - string description, - string menuPath, - int menuOrder, - Type targetType, - Type optionType = null) - { - WidgetGenerator = new WidgetGenerator( - name: name, - description: description, - menuPath: menuPath, - menuOrder: menuOrder, - targetType: targetType - ); - } - - public void RegisterServices(IServiceProvider services) - { - Services = services; - WidgetGenerator.CreateWidgetInternal = () => - (WidgetContext)Activator.CreateInstance(WidgetGenerator.TargetType, Services); - } -} diff --git a/src/Shared/Corathing.Contracts/Entries/CoraWidgetGenerationInfo.cs b/src/Shared/Corathing.Contracts/Entries/CoraWidgetGenerationInfo.cs new file mode 100644 index 0000000..afea399 --- /dev/null +++ b/src/Shared/Corathing.Contracts/Entries/CoraWidgetGenerationInfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Corathing.Contracts.Entries; + +public class CoraWidgetGenerationInfo +{ + public string Name { get; set; } + public string Description { get; set; } + public string MenuPath { get; set; } + public int MenuOrder { get; set; } +} diff --git a/src/Shared/Corathing.Contracts/Bases/WidgetGenerator.cs b/src/Shared/Corathing.Contracts/Entries/CoraWidgetGenerator.cs similarity index 64% rename from src/Shared/Corathing.Contracts/Bases/WidgetGenerator.cs rename to src/Shared/Corathing.Contracts/Entries/CoraWidgetGenerator.cs index c294f92..36c47f1 100644 --- a/src/Shared/Corathing.Contracts/Bases/WidgetGenerator.cs +++ b/src/Shared/Corathing.Contracts/Entries/CoraWidgetGenerator.cs @@ -1,15 +1,20 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection.Emit; using System.Text; using System.Threading.Tasks; -namespace Corathing.Contracts.Bases; +using Corathing.Contracts.Bases; -public class WidgetGenerator +namespace Corathing.Contracts.Entries; + +public class CoraWidgetGenerator { #region Private Fields + public IServiceProvider Services { get; set; } + public Func CreateWidgetInternal; // FIXME: @@ -33,14 +38,13 @@ public class WidgetGenerator /// The name. public string Name { get; } - /// - /// Gets the MenuPath - /// - public string MenuPath { get; } + public CoraWidgetMenuInfo MenuInfo { get; set; } + + public Type ViewType { get; } - public int MenuOrder { get; } + public Type ContextType { get; } - public Type TargetType { get; } + public string DataTemplateSource { get; } public Type OptionType { get; } @@ -54,18 +58,17 @@ public class WidgetGenerator /// The name. /// The description. /// The create widget. - public WidgetGenerator( - string name, - string description, - string menuPath, - int menuOrder, - Type targetType) + public CoraWidgetGenerator( + Type viewType, + Type contextType, + string dataTemplateSource, + Type optionType + ) { - Name = name; - MenuPath = menuPath; - Description = description; - MenuOrder = menuOrder; - TargetType = targetType; + ViewType = viewType; + ContextType = contextType; + DataTemplateSource = dataTemplateSource; + OptionType = optionType; } #endregion Public Constructors @@ -78,7 +81,7 @@ public WidgetGenerator( /// WidgetBase. public WidgetContext CreateWidget() { - return CreateWidgetInternal.Invoke(); + return (WidgetContext)Activator.CreateInstance(ContextType, Services); } #endregion Public Methods diff --git a/src/Shared/Corathing.Contracts/Entries/CoraWidgetMenuInfo.cs b/src/Shared/Corathing.Contracts/Entries/CoraWidgetMenuInfo.cs new file mode 100644 index 0000000..cef10f9 --- /dev/null +++ b/src/Shared/Corathing.Contracts/Entries/CoraWidgetMenuInfo.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Corathing.Contracts.Entries; + +public class CoraWidgetMenuInfo +{ + public string MenuPath { get; set; } + public int MenuOrder { get; set; } + public string MenuTooltip { get; set; } +} diff --git a/src/Shared/Corathing.Contracts/Entries/EntryCoraDataSourceAttribute.cs b/src/Shared/Corathing.Contracts/Entries/EntryCoraDataSourceAttribute.cs new file mode 100644 index 0000000..3828dad --- /dev/null +++ b/src/Shared/Corathing.Contracts/Entries/EntryCoraDataSourceAttribute.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Corathing.Contracts.Entries; + +public class EntryCoraDataSourceAttribute : Attribute +{ +} diff --git a/src/Shared/Corathing.Contracts/Entries/EntryCoraPackageAttribute.cs b/src/Shared/Corathing.Contracts/Entries/EntryCoraPackageAttribute.cs new file mode 100644 index 0000000..4d67938 --- /dev/null +++ b/src/Shared/Corathing.Contracts/Entries/EntryCoraPackageAttribute.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Corathing.Contracts.Entries; + +public class EntryCoraPackageAttribute +{ +} diff --git a/src/Shared/Corathing.Contracts/Entries/EntryCoraWidgetAttribute.cs b/src/Shared/Corathing.Contracts/Entries/EntryCoraWidgetAttribute.cs new file mode 100644 index 0000000..9273ba5 --- /dev/null +++ b/src/Shared/Corathing.Contracts/Entries/EntryCoraWidgetAttribute.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Corathing.Contracts.Bases; + +namespace Corathing.Contracts.Entries; + +[AttributeUsage(AttributeTargets.Class)] +public class EntryCoraWidgetAttribute : Attribute +{ + public IServiceProvider Services { get; set; } + + public CoraWidgetGenerator Generator { get; private set; } + + public EntryCoraWidgetAttribute( + Type viewType, + Type contextType, + string? dataTemplateSource = null, + Type? optionType = null, + // Specific + string? name = null, + string? description = null, + // MenuInfo + string? menuPath = null, + int menuOrder = 0 + ) + { + var menuInfo = new CoraWidgetMenuInfo() + { + MenuPath = menuPath, + MenuOrder = menuOrder, + MenuTooltip = description, + }; + + Generator = new CoraWidgetGenerator( + viewType: viewType, + contextType: contextType, + dataTemplateSource: dataTemplateSource, + optionType: optionType + ) + { + MenuInfo = menuInfo, + }; + + } + + public void Configure(IServiceProvider services) + { + Generator.Services = services; + } +} diff --git a/src/Shared/Corathing.Contracts/Services/IPackageService.cs b/src/Shared/Corathing.Contracts/Services/IPackageService.cs index 95ed77a..f440ed5 100644 --- a/src/Shared/Corathing.Contracts/Services/IPackageService.cs +++ b/src/Shared/Corathing.Contracts/Services/IPackageService.cs @@ -4,13 +4,13 @@ using System.Text; using System.Threading.Tasks; -using Corathing.Contracts.Bases; +using Corathing.Contracts.Entries; namespace Corathing.Contracts.Services; public interface IPackageService { - void RegisterWidgets(List widgets); - List GetAvailableWidgets(); + void RegisterWidgets(List widgets); + List GetAvailableWidgets(); void LoadWidgetsFromDLL(string pathDLL); } diff --git a/src/Shared/Corathing.Dashboards.WPF/Widgets/EmptyWidget.xaml b/src/Shared/Corathing.Dashboards.WPF/Widgets/EmptyWidget.xaml deleted file mode 100644 index 79df86d..0000000 --- a/src/Shared/Corathing.Dashboards.WPF/Widgets/EmptyWidget.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - diff --git a/src/Shared/Corathing.Dashboards.WPF/Widgets/EmptyWidget.xaml.cs b/src/Shared/Corathing.Dashboards.WPF/Widgets/EmptyWidget.xaml.cs deleted file mode 100644 index 091460a..0000000 --- a/src/Shared/Corathing.Dashboards.WPF/Widgets/EmptyWidget.xaml.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -using CommunityToolkit.Mvvm.ComponentModel; - -using Corathing.Contracts.Attributes; -using Corathing.Contracts.Bases; - -namespace Corathing.Dashboards.WPF.Widgets -{ - public class EmptyWidgetOption - { - - } - - public partial class EmptyWidgetState : WidgetState - { - - } - - [WidgetContextEntry( - name: "Create Empty", - description: "Empty Widget.", - menuPath: "Empty", - menuOrder: 0, - targetType: typeof(EmptyWidgetContext) - )] - public partial class EmptyWidgetContext : WidgetContext - { - [ObservableProperty] - private EmptyWidgetState _emptyWidgetState; - - public EmptyWidgetContext(IServiceProvider services) : base(services) - { - } - } - - /// - /// Interaction logic for EmptyWidget.xaml - /// - public partial class EmptyWidget - { - public EmptyWidget() - { - InitializeComponent(); - } - } -} diff --git a/src/Shared/Corathing.UI.WPF/Corathing.UI.WPF.csproj b/src/Shared/Corathing.UI.WPF/Corathing.UI.WPF.csproj index b69b49c..c871897 100644 --- a/src/Shared/Corathing.UI.WPF/Corathing.UI.WPF.csproj +++ b/src/Shared/Corathing.UI.WPF/Corathing.UI.WPF.csproj @@ -12,4 +12,8 @@ + + + + diff --git a/src/Widgets/Corathing.Widget.Templates/Class1.cs b/src/Widgets/Corathing.Widget.Templates/Class1.cs new file mode 100644 index 0000000..1553b0a --- /dev/null +++ b/src/Widgets/Corathing.Widget.Templates/Class1.cs @@ -0,0 +1,7 @@ +namespace Corathing.Widget.Templates +{ + public class Class1 + { + + } +} diff --git a/src/Widgets/Corathing.Widget.Templates/Corathing.Widget.Templates.csproj b/src/Widgets/Corathing.Widget.Templates/Corathing.Widget.Templates.csproj new file mode 100644 index 0000000..fa71b7a --- /dev/null +++ b/src/Widgets/Corathing.Widget.Templates/Corathing.Widget.Templates.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/CalendarWidget.xaml b/src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/CalendarWidget.xaml new file mode 100644 index 0000000..a82e4d7 --- /dev/null +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/CalendarWidget.xaml @@ -0,0 +1,11 @@ + + + diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/CalendarWidget.xaml.cs b/src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/CalendarWidget.xaml.cs new file mode 100644 index 0000000..0bd9b1f --- /dev/null +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/CalendarWidget.xaml.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +using CommunityToolkit.Mvvm.ComponentModel; +using Corathing.Contracts.Bases; +using Corathing.Contracts.Entries; +using Corathing.Widgets.Basics.Widgets.FileOpeners; + +using Wpf.Ui.Controls; + +namespace Corathing.Widgets.Basics.Widgets.Calendars; + +[EntryCoraWidget( + viewType: typeof(CalendarWidget), + contextType: typeof(CalendarWidgetViewModel), + dataTemplateSource: "Widgets/Calendars/DataTemplates.xaml", + description: "Provides a calendar widget.", + name: "Create Calendar", + menuPath: "Default/Calendar", + menuOrder: 0 + )] +public partial class CalendarWidgetViewModel : WidgetContext +{ + [ObservableProperty] + private string? _filePath; + + [ObservableProperty] + private string? _fileType; + + /// + /// Initializes a new instance of the class. + /// + public CalendarWidgetViewModel( + IServiceProvider services) + : base(services) + { + WidgetTitle = $"Calendar"; + VisibleTitle = false; + + var x = new DataTemplate() + { + DataType = typeof(CalendarWidgetViewModel), + VisualTree = new FrameworkElementFactory(typeof(CalendarWidget)) + }; + } +} + +/// +/// Interaction logic for CalendarWidget.xaml +/// +public partial class CalendarWidget +{ + public CalendarWidget() + { + InitializeComponent(); + } +} diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/DataTemplates.xaml b/src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/DataTemplates.xaml new file mode 100644 index 0000000..4cea05e --- /dev/null +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/DataTemplates.xaml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/Commanders/CommanderWidget.xaml.cs b/src/Widgets/Corathing.Widgets.Basics/Widgets/Commanders/CommanderWidget.xaml.cs index 2044481..c9a3b8a 100644 --- a/src/Widgets/Corathing.Widgets.Basics/Widgets/Commanders/CommanderWidget.xaml.cs +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Commanders/CommanderWidget.xaml.cs @@ -14,17 +14,20 @@ using System.Windows.Shapes; using CommunityToolkit.Mvvm.ComponentModel; -using Corathing.Contracts.Attributes; using Corathing.Contracts.Bases; +using Corathing.Contracts.Entries; +using Corathing.Widgets.Basics.Widgets.Monacos; namespace Corathing.Widgets.Basics.Widgets.Commanders { - [WidgetContextEntry( + [EntryCoraWidget( + viewType: typeof(CommanderWidget), + contextType: typeof(CommanderWidgetViewModel), + dataTemplateSource: "Widgets/Commanders/DataTemplates.xaml", name: "Create Commander", description: "Provides a one by one square widget.", menuPath: "Default/Commander", - menuOrder: 0, - targetType: typeof(CommanderWidgetViewModel) + menuOrder: 0 )] public partial class CommanderWidgetViewModel : WidgetContext { diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/Commanders/DataTemplates.xaml b/src/Widgets/Corathing.Widgets.Basics/Widgets/Commanders/DataTemplates.xaml new file mode 100644 index 0000000..8af94c1 --- /dev/null +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Commanders/DataTemplates.xaml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/DataTemplates.xaml b/src/Widgets/Corathing.Widgets.Basics/Widgets/DataTemplates.xaml deleted file mode 100644 index e136cd3..0000000 --- a/src/Widgets/Corathing.Widgets.Basics/Widgets/DataTemplates.xaml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/FileOpeners/DataTemplates.xaml b/src/Widgets/Corathing.Widgets.Basics/Widgets/FileOpeners/DataTemplates.xaml new file mode 100644 index 0000000..3759e9d --- /dev/null +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/FileOpeners/DataTemplates.xaml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/FileOpeners/FileOpenerWidget.xaml.cs b/src/Widgets/Corathing.Widgets.Basics/Widgets/FileOpeners/FileOpenerWidget.xaml.cs index b9ae7af..27ac219 100644 --- a/src/Widgets/Corathing.Widgets.Basics/Widgets/FileOpeners/FileOpenerWidget.xaml.cs +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/FileOpeners/FileOpenerWidget.xaml.cs @@ -14,8 +14,8 @@ using System.Windows.Shapes; using CommunityToolkit.Mvvm.ComponentModel; -using Corathing.Contracts.Attributes; using Corathing.Contracts.Bases; +using Corathing.Contracts.Entries; using Corathing.Widgets.Basics.Widgets.Commanders; namespace Corathing.Widgets.Basics.Widgets.FileOpeners; @@ -25,14 +25,15 @@ public class FileOpenerOption public string FilePath { get; set; } } - -[WidgetContextEntry( +[EntryCoraWidget( + viewType: typeof(FileOpenerWidget), + contextType: typeof(FileOpenerWidgetViewModel), + dataTemplateSource: "Widgets/FileOpeners/DataTemplates.xaml", + optionType: typeof(FileOpenerOption), name: "Create File Opener", description: "Provides a one by one square widget.", menuPath: "Default/File Opener", - menuOrder: 0, - targetType: typeof(FileOpenerWidgetViewModel), - optionType: typeof(FileOpenerOption) + menuOrder: 0 )] public partial class FileOpenerWidgetViewModel : WidgetContext { diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/LinkOpeners/DataTemplates.xaml b/src/Widgets/Corathing.Widgets.Basics/Widgets/LinkOpeners/DataTemplates.xaml new file mode 100644 index 0000000..d075e62 --- /dev/null +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/LinkOpeners/DataTemplates.xaml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/LinkOpeners/LinkOpenerWidget.xaml.cs b/src/Widgets/Corathing.Widgets.Basics/Widgets/LinkOpeners/LinkOpenerWidget.xaml.cs index b6df943..6fdc840 100644 --- a/src/Widgets/Corathing.Widgets.Basics/Widgets/LinkOpeners/LinkOpenerWidget.xaml.cs +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/LinkOpeners/LinkOpenerWidget.xaml.cs @@ -13,18 +13,21 @@ using System.Windows.Navigation; using System.Windows.Shapes; -using Corathing.Contracts.Attributes; using Corathing.Contracts.Bases; +using Corathing.Contracts.Entries; using Corathing.Widgets.Basics.Widgets.Commanders; +using Corathing.Widgets.Basics.Widgets.FileOpeners; namespace Corathing.Widgets.Basics.Widgets.LinkOpeners; -[WidgetContextEntry( +[EntryCoraWidget( + viewType: typeof(LinkOpenerWidget), + contextType: typeof(LinkOpenerWidgetViewModel), + dataTemplateSource: "Widgets/LinkOpeners/DataTemplates.xaml", name: "Create Linke Opener", description: "Provides a one by one square widget.", menuPath: "Default/Link Opener", - menuOrder: 0, - targetType: typeof(LinkOpenerWidgetViewModel) + menuOrder: 0 )] public partial class LinkOpenerWidgetViewModel : WidgetContext { diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/Monacos/DataTemplates.xaml b/src/Widgets/Corathing.Widgets.Basics/Widgets/Monacos/DataTemplates.xaml new file mode 100644 index 0000000..6c5d448 --- /dev/null +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Monacos/DataTemplates.xaml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/Monacos/MonacoWidget.xaml.cs b/src/Widgets/Corathing.Widgets.Basics/Widgets/Monacos/MonacoWidget.xaml.cs index 19d6099..daa14be 100644 --- a/src/Widgets/Corathing.Widgets.Basics/Widgets/Monacos/MonacoWidget.xaml.cs +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Monacos/MonacoWidget.xaml.cs @@ -19,18 +19,20 @@ using CommunityToolkit.Mvvm.Input; using Corathing.Contracts.Bases; using Corathing.Widgets.Basics.Widgets.LinkOpeners; -using Corathing.Contracts.Attributes; using Corathing.Contracts.Services; using Microsoft.Extensions.DependencyInjection; +using Corathing.Contracts.Entries; namespace Corathing.Widgets.Basics.Widgets.Monacos; -[WidgetContextEntry( +[EntryCoraWidget( + viewType: typeof(MonacoWidget), + contextType: typeof(MonacoWidgetViewModel), + dataTemplateSource: "Widgets/Monacos/DataTemplates.xaml", name: "Create Monaco", description: "Provides a one by one square widget.", menuPath: "Default/Monaco", - menuOrder: 0, - targetType: typeof(MonacoWidgetViewModel) + menuOrder: 0 )] public partial class MonacoWidgetViewModel : WidgetContext { diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/Notes/DataTemplates.xaml b/src/Widgets/Corathing.Widgets.Basics/Widgets/Notes/DataTemplates.xaml new file mode 100644 index 0000000..d5cd78f --- /dev/null +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Notes/DataTemplates.xaml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/Notes/NoteWidget.xaml.cs b/src/Widgets/Corathing.Widgets.Basics/Widgets/Notes/NoteWidget.xaml.cs index 3d095d5..eeebf8d 100644 --- a/src/Widgets/Corathing.Widgets.Basics/Widgets/Notes/NoteWidget.xaml.cs +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Notes/NoteWidget.xaml.cs @@ -13,18 +13,21 @@ using System.Windows.Navigation; using System.Windows.Shapes; -using Corathing.Contracts.Attributes; using Corathing.Contracts.Bases; +using Corathing.Contracts.Entries; +using Corathing.Widgets.Basics.Widgets.LinkOpeners; using Corathing.Widgets.Basics.Widgets.Monacos; namespace Corathing.Widgets.Basics.Widgets.Notes; -[WidgetContextEntry( +[EntryCoraWidget( + viewType: typeof(NoteWidget), + contextType: typeof(NoteWidgetViewModel), + dataTemplateSource: "Widgets/Notes/DataTemplates.xaml", name: "Create Note", description: "Provides a one by one square widget.", menuPath: "Default/Note", - menuOrder: 0, - targetType: typeof(NoteWidgetViewModel) + menuOrder: 0 )] public partial class NoteWidgetViewModel : WidgetContext { diff --git a/src/Shared/Corathing.Dashboards.WPF/Widgets/WidgetDataTemplates.xaml b/src/Widgets/Corathing.Widgets.Basics/Widgets/Timers/DataTemplates.xaml similarity index 53% rename from src/Shared/Corathing.Dashboards.WPF/Widgets/WidgetDataTemplates.xaml rename to src/Widgets/Corathing.Widgets.Basics/Widgets/Timers/DataTemplates.xaml index 14b19cd..9d19e35 100644 --- a/src/Shared/Corathing.Dashboards.WPF/Widgets/WidgetDataTemplates.xaml +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Timers/DataTemplates.xaml @@ -1,9 +1,7 @@  - - - + xmlns:local="clr-namespace:Corathing.Widgets.Basics.Widgets.Timers"> + + - \ No newline at end of file diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/Timers/TimerWidget.xaml.cs b/src/Widgets/Corathing.Widgets.Basics/Widgets/Timers/TimerWidget.xaml.cs index 803b51a..d629885 100644 --- a/src/Widgets/Corathing.Widgets.Basics/Widgets/Timers/TimerWidget.xaml.cs +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Timers/TimerWidget.xaml.cs @@ -13,18 +13,20 @@ using System.Windows.Navigation; using System.Windows.Shapes; -using Corathing.Contracts.Attributes; using Corathing.Contracts.Bases; +using Corathing.Contracts.Entries; using Corathing.Widgets.Basics.Widgets.Notes; namespace Corathing.Widgets.Basics.Widgets.Timers; -[WidgetContextEntry( +[EntryCoraWidget( + viewType: typeof(TimerWidget), + contextType: typeof(TimerWidgetViewModel), + dataTemplateSource: "Widgets/Timers/DataTemplates.xaml", name: "Create Timer", description: "Provides a one by one square widget.", menuPath: "Default/Timer", - menuOrder: 0, - targetType: typeof(TimerWidgetViewModel) + menuOrder: 0 )] public partial class TimerWidgetViewModel : WidgetContext { diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/DataTemplates.xaml b/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/DataTemplates.xaml new file mode 100644 index 0000000..aaaa761 --- /dev/null +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/DataTemplates.xaml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/ToDoListWidget.xaml.cs b/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/ToDoListWidget.xaml.cs index bebf7e4..1e8fefc 100644 --- a/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/ToDoListWidget.xaml.cs +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/ToDoListWidget.xaml.cs @@ -13,18 +13,20 @@ using System.Windows.Navigation; using System.Windows.Shapes; -using Corathing.Contracts.Attributes; using Corathing.Contracts.Bases; +using Corathing.Contracts.Entries; using Corathing.Widgets.Basics.Widgets.Timers; namespace Corathing.Widgets.Basics.Widgets.ToDoLists; -[WidgetContextEntry( +[EntryCoraWidget( + viewType: typeof(ToDoListWidget), + contextType: typeof(ToDoListViewModel), + dataTemplateSource: "Widgets/ToDoLists/DataTemplates.xaml", name: "Create To Do List", description: "Provides a one by one square widget.", menuPath: "Default/To Do List", - menuOrder: 0, - targetType: typeof(ToDoListViewModel) + menuOrder: 0 )] public partial class ToDoListViewModel : WidgetContext { diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/WebPages/DataTemplates.xaml b/src/Widgets/Corathing.Widgets.Basics/Widgets/WebPages/DataTemplates.xaml new file mode 100644 index 0000000..2e1e8cb --- /dev/null +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/WebPages/DataTemplates.xaml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/WebPages/WebPageWidget.xaml.cs b/src/Widgets/Corathing.Widgets.Basics/Widgets/WebPages/WebPageWidget.xaml.cs index 555659c..9e39c33 100644 --- a/src/Widgets/Corathing.Widgets.Basics/Widgets/WebPages/WebPageWidget.xaml.cs +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/WebPages/WebPageWidget.xaml.cs @@ -17,8 +17,8 @@ using CommunityToolkit.Mvvm.ComponentModel; using Corathing.Contracts.Services; using Microsoft.Web.WebView2.Wpf; -using Corathing.Contracts.Attributes; using Microsoft.Extensions.DependencyInjection; +using Corathing.Contracts.Entries; namespace Corathing.Widgets.Basics.Widgets.WebPages; @@ -60,12 +60,14 @@ public partial class WebPageOption : ObservableObject private int? autoReloadSeconds; } -[WidgetContextEntry( +[EntryCoraWidget( + viewType: typeof(WebPageWidget), + contextType: typeof(WebPageViewModel), + dataTemplateSource: "Widgets/WebPages/DataTemplates.xaml", name: "Create Web Page", description: "Provides a one by one square widget.", menuPath: "Default/Web Page", - menuOrder: 0, - targetType: typeof(WebPageViewModel) + menuOrder: 0 )] public partial class WebPageViewModel : WidgetContext { diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/WebQueries/DataTemplates.xaml b/src/Widgets/Corathing.Widgets.Basics/Widgets/WebQueries/DataTemplates.xaml new file mode 100644 index 0000000..ad4127f --- /dev/null +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/WebQueries/DataTemplates.xaml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/WebQueries/WebQueryWidget.xaml.cs b/src/Widgets/Corathing.Widgets.Basics/Widgets/WebQueries/WebQueryWidget.xaml.cs index 5d6ea36..15a5748 100644 --- a/src/Widgets/Corathing.Widgets.Basics/Widgets/WebQueries/WebQueryWidget.xaml.cs +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/WebQueries/WebQueryWidget.xaml.cs @@ -13,18 +13,20 @@ using System.Windows.Navigation; using System.Windows.Shapes; -using Corathing.Contracts.Attributes; using Corathing.Contracts.Bases; +using Corathing.Contracts.Entries; using Corathing.Widgets.Basics.Widgets.WebPages; namespace Corathing.Widgets.Basics.Widgets.WebQueries; -[WidgetContextEntry( +[EntryCoraWidget( + viewType: typeof(WebQueryWidget), + contextType: typeof(WebQueryViewModel), + dataTemplateSource: "Widgets/WebQueries/DataTemplates.xaml", name: "Create Web Query", description: "Provides a one by one square widget.", menuPath: "Default/Web Query", - menuOrder: 0, - targetType: typeof(WebQueryViewModel) + menuOrder: 0 )] public partial class WebQueryViewModel : WidgetContext {