diff --git a/Corathing.sln b/Corathing.sln
index d6733d1..1dcda14 100644
--- a/Corathing.sln
+++ b/Corathing.sln
@@ -35,7 +35,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Corathing.Dashboards", "src
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Corathing.Widgets.Basics", "src\Widgets\Corathing.Widgets.Basics\Corathing.Widgets.Basics.csproj", "{8BB7B29E-4684-4F2F-9932-698FDAD2FCDA}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Corathing.UI.WPF", "src\Shared\Corathing.UI.WPF\Corathing.UI.WPF.csproj", "{F0AF90D5-5E28-4FC1-8DBD-8B3F68A285DB}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "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.Dashboards.Sample", "src\Apps\Corathing.Dashboards.Sample\Corathing.Dashboards.Sample.csproj", "{D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -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
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Debug|ARM.Build.0 = Debug|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Debug|ARM64.Build.0 = Debug|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Debug|x64.Build.0 = Debug|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Debug|x86.Build.0 = Debug|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Release|ARM.ActiveCfg = Release|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Release|ARM.Build.0 = Release|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Release|ARM64.Build.0 = Release|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Release|x64.ActiveCfg = Release|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Release|x64.Build.0 = Release|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.Release|x86.ActiveCfg = Release|Any CPU
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD}.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}
+ {D56E1CDF-FCC6-476C-BEC3-C13239A3BEFD} = {5BF1289A-1427-4306-B2E1-51E0770B6B75}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FC027A8C-0C58-494B-BE76-F403F0336A74}
diff --git a/src/Apps/Corathing.Dashboards.Sample/App.xaml b/src/Apps/Corathing.Dashboards.Sample/App.xaml
new file mode 100644
index 0000000..2d6dc3c
--- /dev/null
+++ b/src/Apps/Corathing.Dashboards.Sample/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/src/Apps/Corathing.Dashboards.Sample/App.xaml.cs b/src/Apps/Corathing.Dashboards.Sample/App.xaml.cs
new file mode 100644
index 0000000..c1a2e5e
--- /dev/null
+++ b/src/Apps/Corathing.Dashboards.Sample/App.xaml.cs
@@ -0,0 +1,14 @@
+using System.Configuration;
+using System.Data;
+using System.Windows;
+
+namespace Corathing.Dashboards.Sample
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+
+}
diff --git a/src/Apps/Corathing.Dashboards.Sample/AssemblyInfo.cs b/src/Apps/Corathing.Dashboards.Sample/AssemblyInfo.cs
new file mode 100644
index 0000000..b0ec827
--- /dev/null
+++ b/src/Apps/Corathing.Dashboards.Sample/AssemblyInfo.cs
@@ -0,0 +1,10 @@
+using System.Windows;
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
diff --git a/src/Apps/Corathing.Dashboards.Sample/Corathing.Dashboards.Sample.csproj b/src/Apps/Corathing.Dashboards.Sample/Corathing.Dashboards.Sample.csproj
new file mode 100644
index 0000000..ce62306
--- /dev/null
+++ b/src/Apps/Corathing.Dashboards.Sample/Corathing.Dashboards.Sample.csproj
@@ -0,0 +1,17 @@
+
+
+
+ WinExe
+ net8.0-windows
+ enable
+ enable
+ true
+
+
+
+
+
+
+
+
+
diff --git a/src/Apps/Corathing.Dashboards.Sample/MainWindow.xaml b/src/Apps/Corathing.Dashboards.Sample/MainWindow.xaml
new file mode 100644
index 0000000..af90f0b
--- /dev/null
+++ b/src/Apps/Corathing.Dashboards.Sample/MainWindow.xaml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/src/Apps/Corathing.Dashboards.Sample/MainWindow.xaml.cs b/src/Apps/Corathing.Dashboards.Sample/MainWindow.xaml.cs
new file mode 100644
index 0000000..37b59ae
--- /dev/null
+++ b/src/Apps/Corathing.Dashboards.Sample/MainWindow.xaml.cs
@@ -0,0 +1,24 @@
+using System.Text;
+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;
+
+namespace Corathing.Dashboards.Sample
+{
+ ///
+ /// Interaction logic for MainWindow.xaml
+ ///
+ public partial class MainWindow : Window
+ {
+ public MainWindow()
+ {
+ InitializeComponent();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Apps/Corathing.Dashboards.Sample/ViewModels/DashboardViewModel.cs b/src/Apps/Corathing.Dashboards.Sample/ViewModels/DashboardViewModel.cs
new file mode 100644
index 0000000..6c181ee
--- /dev/null
+++ b/src/Apps/Corathing.Dashboards.Sample/ViewModels/DashboardViewModel.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+
+using Corathing.Contracts.Bases;
+using Corathing.Dashboards.Sample.Widgets;
+using Corathing.Dashboards.WPF.Controls;
+
+namespace Corathing.Dashboards.Sample.ViewModels;
+
+public partial class DashboardViewModel : ObservableObject
+{
+ [ObservableProperty]
+ private ObservableCollection _widgets;
+ [ObservableProperty]
+ private bool? _editMode;
+
+ [RelayCommand]
+ public void ToggleEditMode()
+ {
+ EditMode = !EditMode;
+ }
+
+ [RelayCommand]
+ public void AddWidget()
+ {
+ Widgets.Add(new EmptyWidgetContext());
+ }
+
+ [RelayCommand]
+ public void RemoveWidget(WidgetHost host)
+ {
+ var context = host.DataContext as WidgetContext;
+ Widgets.Remove(context);
+ }
+
+ [RelayCommand]
+ public void ConfigureWidget(WidgetHost host)
+ {
+ var context = host.DataContext as WidgetContext;
+ // Do Something
+ }
+
+ public DashboardViewModel()
+ {
+ Widgets = new ObservableCollection();
+ EditMode = false;
+ }
+
+ protected override void OnPropertyChanged(PropertyChangedEventArgs e)
+ {
+ base.OnPropertyChanged(e);
+
+ foreach (var widget in Widgets)
+ {
+ widget.EditMode = EditMode;
+ }
+ }
+}
diff --git a/src/Apps/Corathing.Dashboards.Sample/Views/DashboardView.xaml b/src/Apps/Corathing.Dashboards.Sample/Views/DashboardView.xaml
new file mode 100644
index 0000000..9dff272
--- /dev/null
+++ b/src/Apps/Corathing.Dashboards.Sample/Views/DashboardView.xaml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Apps/Corathing.Dashboards.Sample/Views/DashboardView.xaml.cs b/src/Apps/Corathing.Dashboards.Sample/Views/DashboardView.xaml.cs
new file mode 100644
index 0000000..8ebdeaf
--- /dev/null
+++ b/src/Apps/Corathing.Dashboards.Sample/Views/DashboardView.xaml.cs
@@ -0,0 +1,33 @@
+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 Corathing.Dashboards.Sample.ViewModels;
+
+namespace Corathing.Dashboards.Sample.Views
+{
+ ///
+ /// Interaction logic for DashboardView.xaml
+ ///
+ public partial class DashboardView : Page
+ {
+ public DashboardViewModel ViewModel;
+ public DashboardView()
+ {
+ InitializeComponent();
+
+ DataContext = ViewModel = new DashboardViewModel();
+ }
+ }
+}
diff --git a/src/Apps/Corathing.Dashboards.Sample/Widgets/EmptyWidget.xaml b/src/Apps/Corathing.Dashboards.Sample/Widgets/EmptyWidget.xaml
new file mode 100644
index 0000000..7e36732
--- /dev/null
+++ b/src/Apps/Corathing.Dashboards.Sample/Widgets/EmptyWidget.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
diff --git a/src/Apps/Corathing.Dashboards.Sample/Widgets/EmptyWidget.xaml.cs b/src/Apps/Corathing.Dashboards.Sample/Widgets/EmptyWidget.xaml.cs
new file mode 100644
index 0000000..c5b64e4
--- /dev/null
+++ b/src/Apps/Corathing.Dashboards.Sample/Widgets/EmptyWidget.xaml.cs
@@ -0,0 +1,38 @@
+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 Corathing.Contracts.Bases;
+
+namespace Corathing.Dashboards.Sample.Widgets
+{
+ public partial class EmptyWidgetContext : WidgetContext
+ {
+ public EmptyWidgetContext()
+ {
+ WidgetTitle = "Empty Widget";
+ }
+ }
+
+ ///
+ /// Interaction logic for WidgetFromContext.xaml
+ ///
+ public partial class EmptyWidget
+ {
+ public EmptyWidget()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/src/Apps/Corathing.Organizer/App.xaml.cs b/src/Apps/Corathing.Organizer/App.xaml.cs
index 9fae813..4aa7755 100644
--- a/src/Apps/Corathing.Organizer/App.xaml.cs
+++ b/src/Apps/Corathing.Organizer/App.xaml.cs
@@ -12,6 +12,7 @@
using Corathing.Organizer.Utils;
using Corathing.Organizer.ViewModels;
using Corathing.Organizer.Views;
+using Corathing.Widgets.Basics.Resources;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -76,13 +77,18 @@ protected override async void OnStartup(StartupEventArgs e)
{
themeService.Register(
"Corathing.Dashboards.WPF",
- @"pack://application:,,,/Corathing.Dashboards.WPF;component/Themes/Light.xaml",
- @"pack://application:,,,/Corathing.Dashboards.WPF;component/Themes/Dark.xaml"
+ "pack://application:,,,/Corathing.Dashboards.WPF;component/Themes/Light.xaml",
+ "pack://application:,,,/Corathing.Dashboards.WPF;component/Themes/Dark.xaml"
);
themeService.Register(
"MaterialDesignThemes.Wpf",
- @"pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml",
- @"pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Dark.xaml"
+ "pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml",
+ "pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Dark.xaml"
+ );
+ themeService.Register(
+ "MahApps.Metro",
+ "pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml",
+ "pack://application:,,,/MahApps.Metro;component/Styles/Themes/Dark.Cyan.xaml"
);
if (appPreferences.UseSystemTheme)
@@ -100,6 +106,11 @@ protected override async void OnStartup(StartupEventArgs e)
//widgetService.LoadWidgetsFromDLL("DDT.Core.WidgetSystems.DefaultWidgets.dll");
//widgetService.RegisterWidgets(new List { new WidgetGenerator() });
+ LocalizationService.Instance.RegisterStringResourceManager("Corathing.Organizer",
+ CorathingOrganizerLocalizationStringResources.ResourceManager);
+
+ LocalizationService.Instance.RegisterStringResourceManager("Corathing.Widgets.Basics",
+ BasicWidgetStringResources.ResourceManager);
IAuthService authService = App.Current.Services.GetService();
if (authService != null && authService.UseAuthService)
@@ -153,16 +164,12 @@ private static IServiceProvider ConfigureServices(string[] args)
serviceCollection.AddSingleton();
serviceCollection.AddSingleton(LocalizationService.Instance);
- LocalizationService.Instance.RegisterStringResourceManager("Corathing.Organizer",
- CorathingOrganizerLocalizationStringResources.ResourceManager);
-
// Register viewmodels
serviceCollection.AddScoped();
serviceCollection.AddScoped();
serviceCollection.AddScoped();
//Logger.Configure(configuration);
- //serviceCollection.AddSingleton();
//Localizer.Configure(configuration);
return serviceCollection.BuildServiceProvider();
diff --git a/src/Apps/Corathing.Organizer/Bindings/HotKeyBinding.cs b/src/Apps/Corathing.Organizer/Bindings/HotKeyBinding.cs
new file mode 100644
index 0000000..2965a2b
--- /dev/null
+++ b/src/Apps/Corathing.Organizer/Bindings/HotKeyBinding.cs
@@ -0,0 +1,120 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Input;
+using System.Windows.Interop;
+
+using Corathing.Organizer.Managers;
+
+namespace Corathing.Organizer.Bindings;
+
+///
+///
+///
+///
+///
+///
+///
+///
+public class HotKeyBinding
+{
+ #region Attached property for KeyBindings
+
+ [AttachedPropertyBrowsableForType(typeof(KeyBinding))]
+ public static bool GetRegisterGlobalHotkey(KeyBinding binding)
+ {
+ return (bool)binding.GetValue(RegisterGlobalHotkeyProperty);
+ }
+
+ public static void SetRegisterGlobalHotkey(KeyBinding binding, bool value)
+ {
+ binding.SetValue(RegisterGlobalHotkeyProperty, value);
+ }
+
+ public static readonly DependencyProperty RegisterGlobalHotkeyProperty =
+ DependencyProperty.RegisterAttached(
+ "RegisterGlobalHotkey",
+ typeof(bool),
+ typeof(HotKeyBinding),
+ new PropertyMetadata(
+ false,
+ RegisterGlobalHotkeyPropertyChanged));
+
+ private static void RegisterGlobalHotkeyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var keyBinding = d as KeyBinding;
+ if (keyBinding == null)
+ return;
+
+ bool oldValue = (bool)e.OldValue;
+ bool newValue = (bool)e.NewValue;
+
+ if (DesignerProperties.GetIsInDesignMode(d))
+ return;
+
+ if (oldValue && !newValue)
+ {
+ RemoveKeyBinding(keyBinding);
+ }
+ else if (newValue && !oldValue)
+ {
+ AddKeyBinding(keyBinding);
+ }
+ }
+ #endregion
+
+ public static event EventHandler HotkeyAlreadyRegistered;
+
+ private static void OnHotkeyAlreadyRegistered(string name)
+ {
+ var handler = HotkeyAlreadyRegistered;
+ if (handler != null)
+ handler(null, new HotKeyEventArgs(name));
+ }
+
+
+ #region Key Binding
+ private static readonly Lazy _gestureConverter
+ = new(() => new KeyGestureConverter());
+ public static KeyGestureConverter KeyGestureConverter
+ {
+ get => _gestureConverter.Value;
+ }
+
+ private static string GetNameForKeyBinding(KeyGesture gesture)
+ {
+ string name = gesture.DisplayString;
+ if (string.IsNullOrEmpty(name))
+ name = KeyGestureConverter.ConvertToString(gesture);
+ return name;
+ }
+ public static void AddKeyBinding(KeyBinding keyBinding)
+ {
+ var gesture = (KeyGesture)keyBinding.Gesture;
+ string name = GetNameForKeyBinding(gesture);
+ try
+ {
+ GlobalHotKeyManager.Instance.AddOrReplace(name, gesture.Key, gesture.Modifiers, null);
+ GlobalHotKeyManager.KeyBindings.Add(keyBinding);
+ }
+ catch (HotkeyAlreadyRegisteredException)
+ {
+ OnHotkeyAlreadyRegistered(name);
+ }
+ }
+
+ public static void RemoveKeyBinding(KeyBinding keyBinding)
+ {
+ var gesture = (KeyGesture)keyBinding.Gesture;
+ string name = GetNameForKeyBinding(gesture);
+ GlobalHotKeyManager.Remove(name);
+ GlobalHotKeyManager.KeyBindings.Remove(keyBinding);
+ }
+ #endregion
+}
diff --git a/src/Apps/Corathing.Organizer/Corathing.Organizer.csproj b/src/Apps/Corathing.Organizer/Corathing.Organizer.csproj
index ad6ba50..161c82e 100644
--- a/src/Apps/Corathing.Organizer/Corathing.Organizer.csproj
+++ b/src/Apps/Corathing.Organizer/Corathing.Organizer.csproj
@@ -29,6 +29,7 @@
+
diff --git a/src/Apps/Corathing.Organizer/Managers/GlobalHotKeyManager.cs b/src/Apps/Corathing.Organizer/Managers/GlobalHotKeyManager.cs
new file mode 100644
index 0000000..1ad7de6
--- /dev/null
+++ b/src/Apps/Corathing.Organizer/Managers/GlobalHotKeyManager.cs
@@ -0,0 +1,334 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+using System.Windows.Interop;
+using System.Xml.Linq;
+
+using MahApps.Metro.Controls;
+
+namespace Corathing.Organizer.Managers;
+
+public class WeakReferenceCollection : IEnumerable
+ where T : class
+{
+ private readonly List _references = new List();
+
+ public IEnumerator GetEnumerator()
+ {
+ var references = _references.ToList();
+ foreach (var reference in references)
+ {
+ var target = reference.Target;
+ if (target != null)
+ yield return (T)target;
+ }
+ Trim();
+ }
+
+ public void Add(T item)
+ {
+ _references.Add(new WeakReference(item));
+ }
+
+ public void Remove(T item)
+ {
+ _references.RemoveAll(r => (r.Target ?? item) == item);
+ }
+
+ public void Trim()
+ {
+ _references.RemoveAll(r => !r.IsAlive);
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+}
+
+public class HotKeyEventArgs : EventArgs
+{
+ public string Name { get; }
+ public bool Handled { get; set; }
+ public bool Succeeded { get; set; }
+ public bool AlreadyRegistered { get; set; } = false;
+
+ public HotKeyEventArgs(string name)
+ {
+ Name = name;
+ }
+}
+[Serializable]
+public class HotkeyAlreadyRegisteredException : Exception
+{
+ private readonly string _name;
+
+ public HotkeyAlreadyRegisteredException(string name, Exception inner) : base(inner.Message, inner)
+ {
+ _name = name;
+ HResult = Marshal.GetHRForException(inner);
+ }
+
+ protected HotkeyAlreadyRegisteredException(
+ SerializationInfo info,
+ StreamingContext context) : base(info, context)
+ {
+ _name = (string)info.GetValue("_name", typeof(string));
+ }
+
+ public override void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ base.GetObjectData(info, context);
+ info.AddValue("_name", _name);
+ }
+
+ public string Name
+ {
+ get { return _name; }
+ }
+}
+
+public class HotKey
+{
+ //핫키등록
+ [DllImport("user32.dll", SetLastError = true)]
+ private static extern bool RegisterHotKey(IntPtr hWnd, int id, ModifierKeys fsModifiers, uint vk);
+
+ //핫키제거
+ [DllImport("user32.dll", SetLastError = true)]
+ internal static extern bool UnregisterHotKey(IntPtr hWnd, int id);
+
+ private static int _nextId;
+
+ public int Id { get; }
+
+ public uint VirtualKey { get; }
+
+ public ModifierKeys Flags { get; }
+
+ public EventHandler Handler { get; }
+
+ private IntPtr _hwnd;
+
+ public HotKey(uint virtualKey, ModifierKeys flags, EventHandler handler)
+ {
+ Id = ++_nextId;
+ VirtualKey = virtualKey;
+ Flags = flags;
+ Handler = handler;
+ }
+
+ public void Register(IntPtr hwnd, string name)
+ {
+ if (!RegisterHotKey(hwnd, Id, Flags, VirtualKey))
+ {
+ var hr = Marshal.GetHRForLastWin32Error();
+ var ex = Marshal.GetExceptionForHR(hr);
+ if ((uint)hr == 0x80070581)
+ throw new HotkeyAlreadyRegisteredException(name, ex);
+ throw ex;
+ }
+ _hwnd = hwnd;
+
+ }
+
+ public void Unregister()
+ {
+ if (_hwnd != IntPtr.Zero)
+ {
+ if (!UnregisterHotKey(_hwnd, Id))
+ {
+ var hr = Marshal.GetHRForLastWin32Error();
+ throw Marshal.GetExceptionForHR(hr);
+ }
+ _hwnd = IntPtr.Zero;
+ }
+ }
+
+}
+
+public class GlobalHotKeyManager
+{
+ private readonly Lazy> _keyBindings
+ = new(() => []);
+ public static WeakReferenceCollection KeyBindings
+ {
+ get => Instance._keyBindings.Value;
+ }
+
+ public readonly static new GlobalHotKeyManager Instance = new GlobalHotKeyManager();
+ private readonly Dictionary _hotkeyNames = new Dictionary();
+ private readonly Dictionary _hotkeys = new Dictionary();
+
+ private static readonly IntPtr HwndMessage = (IntPtr)(-3);
+ private const int WmHotkey = 0x0312;
+
+ private IntPtr _hwnd;
+ private readonly HwndSource _source;
+
+ public bool IsEnabled { get; set; } = true;
+
+ private void SetHwnd(IntPtr hwnd)
+ {
+ _hwnd = hwnd;
+ }
+
+ public static void AddOrReplace(string name, uint virtualKey, ModifierKeys flags, EventHandler handler)
+ {
+ var hotkey = new HotKey(virtualKey, flags, handler);
+ lock (Instance._hotkeys)
+ {
+ Remove(name);
+ Instance._hotkeys.Add(name, hotkey);
+ Instance._hotkeyNames.Add(hotkey.Id, name);
+ if (Instance._hwnd != IntPtr.Zero)
+ hotkey.Register(Instance._hwnd, name);
+ }
+ }
+
+ public static void Remove(string name)
+ {
+ lock (Instance._hotkeys)
+ {
+ HotKey hotkey;
+ if (Instance._hotkeys.TryGetValue(name, out hotkey))
+ {
+ Instance._hotkeys.Remove(name);
+ Instance._hotkeyNames.Remove(hotkey.Id);
+ if (Instance._hwnd != IntPtr.Zero)
+ hotkey.Unregister();
+ }
+ }
+ }
+
+ public void RemoveAll()
+ {
+ lock (_hotkeys)
+ {
+ if (_hwnd != IntPtr.Zero)
+ {
+ foreach (var hotkeyPair in Instance._hotkeys)
+ {
+ hotkeyPair.Value.Unregister();
+ }
+ }
+ _hotkeys.Clear();
+ }
+ }
+
+ private GlobalHotKeyManager()
+ {
+ var parameters = new HwndSourceParameters("Hotkey sink")
+ {
+ HwndSourceHook = HandleMessage,
+ ParentWindow = HwndMessage
+ };
+ _source = new HwndSource(parameters);
+ SetHwnd(_source.Handle);
+ App.Current.Exit += (s, e) => RemoveAll();
+ }
+
+ public static void AddOrReplace(string name, KeyGesture gesture, EventHandler handler)
+ {
+ AddOrReplace(name, gesture, handler);
+ }
+
+ public void AddOrReplace(string name, Key key, ModifierKeys modifiers, EventHandler handler)
+ {
+ var flags = modifiers;
+ var vk = (uint)KeyInterop.VirtualKeyFromKey(key);
+ AddOrReplace(name, vk, flags, handler);
+ }
+
+ public static IntPtr HandleHotkeyMessage(
+ IntPtr hwnd,
+ int msg,
+ IntPtr wParam,
+ IntPtr lParam,
+ ref bool handled,
+ out HotKey hotkey)
+ {
+ hotkey = null;
+ if (Instance.IsEnabled && msg == WmHotkey)
+ {
+ int id = wParam.ToInt32();
+ string name;
+ if (Instance._hotkeyNames.TryGetValue(id, out name))
+ {
+ hotkey = Instance._hotkeys[name];
+ var handler = hotkey.Handler;
+ if (handler != null)
+ {
+ var e = new HotKeyEventArgs(name);
+ handler(Instance, e);
+ handled = e.Handled;
+ }
+ }
+ }
+ return IntPtr.Zero;
+ }
+
+ private IntPtr HandleMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam, ref bool handled)
+ {
+ HotKey hotkey;
+ var result = HandleHotkeyMessage(hwnd, msg, wparam, lparam, ref handled, out hotkey);
+ if (handled)
+ return result;
+
+ if (hotkey != null)
+ handled = ExecuteBoundCommand(hotkey);
+ return result;
+ }
+
+ private bool ExecuteBoundCommand(HotKey hotkey)
+ {
+ var key = KeyInterop.KeyFromVirtualKey((int)hotkey.VirtualKey);
+ var modifiers = hotkey.Flags;
+ bool handled = false;
+ foreach (var binding in KeyBindings)
+ {
+ if (binding.Key == key && binding.Modifiers == modifiers)
+ {
+ handled |= ExecuteCommand(binding);
+ }
+ }
+ return handled;
+ }
+
+ private static bool ExecuteCommand(InputBinding binding)
+ {
+ var command = binding.Command;
+ var parameter = binding.CommandParameter;
+ var target = binding.CommandTarget;
+
+ if (command == null)
+ return false;
+
+ var routedCommand = command as RoutedCommand;
+ if (routedCommand != null)
+ {
+ if (routedCommand.CanExecute(parameter, target))
+ {
+ routedCommand.Execute(parameter, target);
+ return true;
+ }
+ }
+ else
+ {
+ if (command.CanExecute(parameter))
+ {
+ command.Execute(parameter);
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/Apps/Corathing.Organizer/Models/WorkflowContext.cs b/src/Apps/Corathing.Organizer/Models/WorkflowContext.cs
index 8302401..9cdba68 100644
--- a/src/Apps/Corathing.Organizer/Models/WorkflowContext.cs
+++ b/src/Apps/Corathing.Organizer/Models/WorkflowContext.cs
@@ -132,4 +132,16 @@ public WorkflowContext()
}
#endregion Public Properties
+ protected override void OnPropertyChanged(PropertyChangedEventArgs e)
+ {
+ base.OnPropertyChanged(e);
+
+ if (Widgets != null)
+ {
+ foreach (var widgetContext in Widgets)
+ {
+ widgetContext.EditMode = EditMode;
+ }
+ }
+ }
}
diff --git a/src/Apps/Corathing.Organizer/Natives/WIndowNativeMethods.cs b/src/Apps/Corathing.Organizer/Natives/WIndowNativeMethods.cs
index 7bac131..43708b4 100644
--- a/src/Apps/Corathing.Organizer/Natives/WIndowNativeMethods.cs
+++ b/src/Apps/Corathing.Organizer/Natives/WIndowNativeMethods.cs
@@ -8,6 +8,17 @@ namespace Corathing.Organizer.Natives;
public static class WindowNativeMethods
{
+ private static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
+ {
+ if (msg == 0x0312)
+ {
+ Console.WriteLine("resr");
+ }
+
+ return IntPtr.Zero;
+ }
+
+
[DllImport("user32.dll")]
public static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, MonitorEnumProc lpfnEnum, IntPtr dwData);
@@ -28,4 +39,6 @@ public struct MonitorInfo
public Rect Work;
public uint Flags;
}
+
+
}
diff --git a/src/Apps/Corathing.Organizer/Services/PackageService.cs b/src/Apps/Corathing.Organizer/Services/PackageService.cs
index c3202db..c15b534 100644
--- a/src/Apps/Corathing.Organizer/Services/PackageService.cs
+++ b/src/Apps/Corathing.Organizer/Services/PackageService.cs
@@ -17,6 +17,9 @@
using NuGet.Versioning;
using NuGet.Packaging.Core;
using NuGet.Packaging;
+using Microsoft.Extensions.DependencyInjection;
+using System.Resources;
+using Microsoft.Extensions.Localization;
namespace Corathing.Organizer.Services;
@@ -97,6 +100,23 @@ public void LoadAssembly(Assembly assembly)
);
}
}
+
+ // Localization
+ // TODO:
+ // Fix the assembly
+ //var localizationService = _services.GetService();
+ //if (localizationService != null)
+ //{
+ // var resources = assembly.GetTypes().Where(t => typeof(ResourceManager).IsAssignableFrom(t));
+
+ // foreach (var resource in resources)
+ // {
+ // if (resource.Name.Contains("StringResources"))
+ // {
+ // resource
+ // }
+ // }
+ //}
}
public void LoadWidgetsFromDLL(string pathDLL)
diff --git a/src/Apps/Corathing.Organizer/ViewModels/DashboardViewModel.cs b/src/Apps/Corathing.Organizer/ViewModels/DashboardViewModel.cs
index 3264074..9e4f363 100644
--- a/src/Apps/Corathing.Organizer/ViewModels/DashboardViewModel.cs
+++ b/src/Apps/Corathing.Organizer/ViewModels/DashboardViewModel.cs
@@ -127,31 +127,6 @@ public void ToggleEditDashboard()
EditMode = !EditMode;
}
- [RelayCommand]
- public void MouseDoubleClick(object e)
- {
- Console.WriteLine(e);
- //private void Window_MouseDoubleClick(object sender, MouseButtonEventArgs e)
- //{
- // if (sender is not MainWindow)
- // return;
-
- // if (e.ChangedButton == MouseButton.Left)
- // {
- // if (WindowState == WindowState.Normal)
- // WindowState = WindowState.Maximized;
- // else
- // WindowState = WindowState.Normal;
- // }
- //}
-
- //private void Window_MouseDown(object sender, MouseButtonEventArgs e)
- //{
- // if (e.ChangedButton == MouseButton.Left)
- // this.DragMove();
- //}
- }
-
[RelayCommand]
public async void ConfigureWidget(WidgetHost widgetHost)
{
@@ -182,31 +157,6 @@ public void RemoveWidget(object widgetHost)
SelectedProject.SelectedWorkflow.Widgets.Remove((widgetHost as WidgetHost).DataContext as WidgetContext);
}
-
- ///
- /// Gets the command configure widget.
- ///
- /// The command configure widget.
- public ICommand CommandConfigureWidget => new RelayCommand(async o =>
- {
- var widgetHost = (WidgetHost)o;
- var parentWindow = Window.GetWindow(widgetHost);
- var window = new BaseWindow();
- if (parentWindow != null)
- {
- window.Owner = parentWindow;
- parentWindow.Effect = new BlurEffect();
- window.CenterWindowToParent();
- }
- var view = new WidgetSettingsView(widgetHost);
- window.Content = view;
- window.ShowDialog();
- if (parentWindow != null)
- {
- parentWindow.Effect = null;
- }
- });
-
///
/// Gets the command done configuring widget.
///
diff --git a/src/Apps/Corathing.Organizer/Views/DashboardView.xaml b/src/Apps/Corathing.Organizer/Views/DashboardView.xaml
index 69b48b5..e0f31be 100644
--- a/src/Apps/Corathing.Organizer/Views/DashboardView.xaml
+++ b/src/Apps/Corathing.Organizer/Views/DashboardView.xaml
@@ -380,19 +380,6 @@
ContentTemplateSelector="{StaticResource contentTemplateSelector}"
SelectedItem="{Binding SelectedProject.SelectedWorkflow}"
ItemsSource="{Binding SelectedProject.Workflows}" />
-
-
diff --git a/src/Shared/Corathing.Contracts/Bases/WidgetContext.cs b/src/Shared/Corathing.Contracts/Bases/WidgetContext.cs
index dddc1c6..29438ed 100644
--- a/src/Shared/Corathing.Contracts/Bases/WidgetContext.cs
+++ b/src/Shared/Corathing.Contracts/Bases/WidgetContext.cs
@@ -13,10 +13,15 @@ public partial class WidgetContext : ObservableRecipient
{
private readonly IServiceProvider _services;
+ #region 확정된 프로퍼티
[ObservableProperty]
private string _widgetTitle;
[ObservableProperty]
private bool? _visibleTitle;
+ [ObservableProperty]
+ private bool? _editMode;
+ #endregion
+
[ObservableProperty]
private bool? _isSelecting;
[ObservableProperty]
@@ -30,12 +35,14 @@ public partial class WidgetContext : ObservableRecipient
public WidgetContext()
{
+ WidgetTitle = "Widget";
+ VisibleTitle = true;
+ EditMode = true;
+
IsSelecting = false;
IsDragging = false;
IsResizing = false;
IsEditing = false;
- VisibleTitle = true;
- WidgetTitle = "Widget";
}
public WidgetContext(IServiceProvider services) : this()
diff --git a/src/Shared/Corathing.Contracts/Services/ILocalizationService.cs b/src/Shared/Corathing.Contracts/Services/ILocalizationService.cs
index 98aa1d2..f4b3f94 100644
--- a/src/Shared/Corathing.Contracts/Services/ILocalizationService.cs
+++ b/src/Shared/Corathing.Contracts/Services/ILocalizationService.cs
@@ -21,4 +21,11 @@ public interface ILocalizationService
ApplicationLanguage GetAppLanguage();
CultureInfo GetAppCulture();
CultureInfo GetSystemCulture();
+ string GetString(string key);
+
+ ///
+ /// On LocalizationChanged
+ ///
+ ///
+ void Provide(string key, Action action);
}
diff --git a/src/Shared/Corathing.Dashboards.WPF/Controls/DashboardHost.xaml b/src/Shared/Corathing.Dashboards.WPF/Controls/DashboardHost.xaml
index 3f9d2ab..9d125dc 100644
--- a/src/Shared/Corathing.Dashboards.WPF/Controls/DashboardHost.xaml
+++ b/src/Shared/Corathing.Dashboards.WPF/Controls/DashboardHost.xaml
@@ -7,11 +7,13 @@
-
-
-
+
+
+
diff --git a/src/Shared/Corathing.Dashboards.WPF/Services/LocalizationService.cs b/src/Shared/Corathing.Dashboards.WPF/Services/LocalizationService.cs
index 1b2f10d..aef3912 100644
--- a/src/Shared/Corathing.Dashboards.WPF/Services/LocalizationService.cs
+++ b/src/Shared/Corathing.Dashboards.WPF/Services/LocalizationService.cs
@@ -8,6 +8,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
+using System.Windows.Input;
using Corathing.Contracts.Services;
@@ -38,6 +39,7 @@ public class LocalizationService : ILocalizationService, INotifyPropertyChanged
private CultureInfo? _cachedSystemCultureInfo = null;
private readonly Dictionary _stringResourceManagers = new Dictionary();
+ private readonly List _refreshProvideActions = new List();
public CultureInfo? CachedSystemCultureInfo
{
@@ -63,22 +65,24 @@ public ApplicationLanguage CachedApplicationLanguage
public string? this[string key]
{
- get
+ get => GetString(key);
+ }
+
+ public string GetString(string key)
+ {
+ foreach (var resManager in _stringResourceManagers.Values)
{
- foreach (var resManager in _stringResourceManagers.Values)
+ if (CachedApplicationCultureInfo == null)
+ {
+ ApplySystemLanguage();
+ }
+ string? resultString = resManager.GetString(key, CachedApplicationCultureInfo);
+ if (!string.IsNullOrEmpty(resultString))
{
- if (CachedApplicationCultureInfo == null)
- {
- ApplySystemLanguage();
- }
- string? resultString = resManager.GetString(key, CachedApplicationCultureInfo);
- if (!string.IsNullOrEmpty(resultString))
- {
- return resultString;
- }
+ return resultString;
}
- return "";
}
+ return "";
}
@@ -86,6 +90,7 @@ public string? this[string key]
private void RaisePropertyChanged(object sender, PropertyChangedEventArgs e)
{
PropertyChanged?.Invoke(sender, e);
+ _refreshProvideActions.ForEach(action => action.Invoke());
}
@@ -185,4 +190,13 @@ public void RegisterStringResourceManager(string namespaceName, ResourceManager
{
_stringResourceManagers.Add(namespaceName, resourceManager);
}
+
+ ///
+ ///
+ ///
+ public void Provide(string key, Action action)
+ {
+ action?.Invoke(GetString(key));
+ _refreshProvideActions.Add(() => action?.Invoke(GetString(key)));
+ }
}
diff --git a/src/Shared/Corathing.UI.WPF/Corathing.UI.WPF.csproj b/src/Shared/Corathing.UI.WPF/Corathing.UI.WPF.csproj
index c871897..b69b49c 100644
--- a/src/Shared/Corathing.UI.WPF/Corathing.UI.WPF.csproj
+++ b/src/Shared/Corathing.UI.WPF/Corathing.UI.WPF.csproj
@@ -12,8 +12,4 @@
-
-
-
-
diff --git a/src/Shared/Corathing.UI.WPF/Styles/CheckBoxOnlyIconAutoScale.xaml b/src/Shared/Corathing.UI.WPF/Styles/CheckBoxOnlyIconAutoScale.xaml
new file mode 100644
index 0000000..504a49c
--- /dev/null
+++ b/src/Shared/Corathing.UI.WPF/Styles/CheckBoxOnlyIconAutoScale.xaml
@@ -0,0 +1,144 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Widgets/Corathing.Widgets.Basics/Corathing.Widgets.Basics.csproj b/src/Widgets/Corathing.Widgets.Basics/Corathing.Widgets.Basics.csproj
index 3206334..e18a463 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Corathing.Widgets.Basics.csproj
+++ b/src/Widgets/Corathing.Widgets.Basics/Corathing.Widgets.Basics.csproj
@@ -59,7 +59,7 @@
- ResXFileCodeGenerator
+ PublicResXFileCodeGenerator
BasicWidgetStringResources.Designer.cs
diff --git a/src/Widgets/Corathing.Widgets.Basics/Resources/BasicWidgetStringResources.en-US.resx b/src/Widgets/Corathing.Widgets.Basics/Resources/BasicWidgetStringResources.en-US.resx
index 9b7715b..b35e591 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Resources/BasicWidgetStringResources.en-US.resx
+++ b/src/Widgets/Corathing.Widgets.Basics/Resources/BasicWidgetStringResources.en-US.resx
@@ -120,4 +120,31 @@
File Opener
+
+ Calendar
+
+
+ Commander
+
+
+ Link Opener
+
+
+ Text Editor
+
+
+ Note
+
+
+ Timer
+
+
+ To Do List
+
+
+ Web Page
+
+
+ Web Query
+
\ No newline at end of file
diff --git a/src/Widgets/Corathing.Widgets.Basics/Resources/BasicWidgetStringResources.ko-KR.resx b/src/Widgets/Corathing.Widgets.Basics/Resources/BasicWidgetStringResources.ko-KR.resx
index 04bfec8..ea7db99 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Resources/BasicWidgetStringResources.ko-KR.resx
+++ b/src/Widgets/Corathing.Widgets.Basics/Resources/BasicWidgetStringResources.ko-KR.resx
@@ -120,4 +120,31 @@
파일 열기
+
+ 캘린더
+
+
+ 콘솔 명령
+
+
+ 링크 열기
+
+
+ 텍스트 편집기
+
+
+ 노트
+
+
+ 타이머
+
+
+ 할일 목록
+
+
+ 웹페이지
+
+
+ 웹 쿼리
+
\ No newline at end of file
diff --git a/src/Widgets/Corathing.Widgets.Basics/Resources/BasicWidgetStringResources.resx b/src/Widgets/Corathing.Widgets.Basics/Resources/BasicWidgetStringResources.resx
index d21fc4a..dfa97cc 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Resources/BasicWidgetStringResources.resx
+++ b/src/Widgets/Corathing.Widgets.Basics/Resources/BasicWidgetStringResources.resx
@@ -100,4 +100,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/CalendarWidget.xaml.cs b/src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/CalendarWidget.xaml.cs
index 0bd9b1f..9484256 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/CalendarWidget.xaml.cs
+++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Calendars/CalendarWidget.xaml.cs
@@ -16,8 +16,11 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Corathing.Contracts.Bases;
using Corathing.Contracts.Entries;
+using Corathing.Contracts.Services;
using Corathing.Widgets.Basics.Widgets.FileOpeners;
+using Microsoft.Extensions.DependencyInjection;
+
using Wpf.Ui.Controls;
namespace Corathing.Widgets.Basics.Widgets.Calendars;
@@ -46,7 +49,8 @@ public CalendarWidgetViewModel(
IServiceProvider services)
: base(services)
{
- WidgetTitle = $"Calendar";
+ ILocalizationService localizationService = services.GetService();
+ localizationService.Provide("Corathing.Widgets.Basics.CalendarName", value => WidgetTitle = value);
VisibleTitle = false;
var x = new DataTemplate()
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 c9a3b8a..edf9b1f 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Widgets/Commanders/CommanderWidget.xaml.cs
+++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Commanders/CommanderWidget.xaml.cs
@@ -16,8 +16,11 @@
using Corathing.Contracts.Bases;
using Corathing.Contracts.Entries;
+using Corathing.Contracts.Services;
using Corathing.Widgets.Basics.Widgets.Monacos;
+using Microsoft.Extensions.DependencyInjection;
+
namespace Corathing.Widgets.Basics.Widgets.Commanders
{
[EntryCoraWidget(
@@ -36,9 +39,10 @@ public partial class CommanderWidgetViewModel : WidgetContext
///
/// Initializes a new instance of the class.
///
- public CommanderWidgetViewModel(IServiceProvider serivces) : base(serivces)
+ public CommanderWidgetViewModel(IServiceProvider services) : base(services)
{
- WidgetTitle = $"Commander";
+ ILocalizationService localizationService = services.GetService();
+ localizationService.Provide("Corathing.Widgets.Basics.CommanderName", value => WidgetTitle = value);
}
}
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 27ac219..ebb4faa 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Widgets/FileOpeners/FileOpenerWidget.xaml.cs
+++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/FileOpeners/FileOpenerWidget.xaml.cs
@@ -16,8 +16,11 @@
using Corathing.Contracts.Bases;
using Corathing.Contracts.Entries;
+using Corathing.Contracts.Services;
using Corathing.Widgets.Basics.Widgets.Commanders;
+using Microsoft.Extensions.DependencyInjection;
+
namespace Corathing.Widgets.Basics.Widgets.FileOpeners;
public class FileOpenerOption
@@ -50,7 +53,8 @@ public FileOpenerWidgetViewModel(
IServiceProvider services)
: base(services)
{
- WidgetTitle = $"FileOpener";
+ ILocalizationService localizationService = services.GetService();
+ localizationService.Provide("Corathing.Widgets.Basics.FileOpenerName", value => WidgetTitle = value);
VisibleTitle = true;
}
}
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 6fdc840..962888a 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Widgets/LinkOpeners/LinkOpenerWidget.xaml.cs
+++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/LinkOpeners/LinkOpenerWidget.xaml.cs
@@ -15,9 +15,12 @@
using Corathing.Contracts.Bases;
using Corathing.Contracts.Entries;
+using Corathing.Contracts.Services;
using Corathing.Widgets.Basics.Widgets.Commanders;
using Corathing.Widgets.Basics.Widgets.FileOpeners;
+using Microsoft.Extensions.DependencyInjection;
+
namespace Corathing.Widgets.Basics.Widgets.LinkOpeners;
[EntryCoraWidget(
@@ -36,8 +39,8 @@ public partial class LinkOpenerWidgetViewModel : WidgetContext
///
public LinkOpenerWidgetViewModel(IServiceProvider services) : base(services)
{
-
- WidgetTitle = $"Commander";
+ ILocalizationService localizationService = services.GetService();
+ localizationService.Provide("Corathing.Widgets.Basics.LinkOpenerName", value => WidgetTitle = value);
}
}
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 daa14be..5d316b0 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Widgets/Monacos/MonacoWidget.xaml.cs
+++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Monacos/MonacoWidget.xaml.cs
@@ -45,7 +45,8 @@ public partial class MonacoWidgetViewModel : WidgetContext
public MonacoWidgetViewModel(IServiceProvider services) : base(services)
{
- WidgetTitle = $"Monaco";
+ ILocalizationService localizationService = services.GetService();
+ localizationService.Provide("Corathing.Widgets.Basics.TextEditorName", value => WidgetTitle = value);
VisibleTitle = false;
_applicationService = services.GetService();
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 eeebf8d..a7211d6 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Widgets/Notes/NoteWidget.xaml.cs
+++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Notes/NoteWidget.xaml.cs
@@ -15,9 +15,12 @@
using Corathing.Contracts.Bases;
using Corathing.Contracts.Entries;
+using Corathing.Contracts.Services;
using Corathing.Widgets.Basics.Widgets.LinkOpeners;
using Corathing.Widgets.Basics.Widgets.Monacos;
+using Microsoft.Extensions.DependencyInjection;
+
namespace Corathing.Widgets.Basics.Widgets.Notes;
[EntryCoraWidget(
@@ -36,7 +39,8 @@ public partial class NoteWidgetViewModel : WidgetContext
///
public NoteWidgetViewModel(IServiceProvider services) : base(services)
{
- WidgetTitle = $"Commander";
+ ILocalizationService localizationService = services.GetService();
+ localizationService.Provide("Corathing.Widgets.Basics.NoteName", value => WidgetTitle = value);
}
}
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 d629885..b36a4c4 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Widgets/Timers/TimerWidget.xaml.cs
+++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Timers/TimerWidget.xaml.cs
@@ -15,8 +15,11 @@
using Corathing.Contracts.Bases;
using Corathing.Contracts.Entries;
+using Corathing.Contracts.Services;
using Corathing.Widgets.Basics.Widgets.Notes;
+using Microsoft.Extensions.DependencyInjection;
+
namespace Corathing.Widgets.Basics.Widgets.Timers;
[EntryCoraWidget(
@@ -35,7 +38,8 @@ public partial class TimerWidgetViewModel : WidgetContext
///
public TimerWidgetViewModel(IServiceProvider services) : base(services)
{
- WidgetTitle = $"Timer";
+ ILocalizationService localizationService = services.GetService();
+ localizationService.Provide("Corathing.Widgets.Basics.TimerName", value => WidgetTitle = value);
}
}
diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/JobTemplateSelector.cs b/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/JobTemplateSelector.cs
index e473f66..2ef7e59 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/JobTemplateSelector.cs
+++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/JobTemplateSelector.cs
@@ -20,10 +20,8 @@ public override DataTemplate SelectTemplate(object item, DependencyObject contai
return null;
if (item is ToDoJob)
- return element.FindResource("ToDoJobDataTemplate")
- as DataTemplate;
+ return element.FindResource("ToDoJobDataTemplate") as DataTemplate;
else
- return element.FindResource("AddingJobDataTemplate")
- as DataTemplate;
+ return element.FindResource("AddingJobDataTemplate") as DataTemplate;
}
}
diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/ToDoListWidget.xaml b/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/ToDoListWidget.xaml
index 54e3e30..66caec1 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/ToDoListWidget.xaml
+++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/ToDoListWidget.xaml
@@ -5,47 +5,157 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Corathing.Widgets.Basics.Widgets.ToDoLists"
xmlns:models="clr-namespace:Corathing.Widgets.Basics.Widgets.ToDoLists.Models"
+ xmlns:behaviors="clr-namespace:Corathing.UI.WPF.Behaviors;assembly=Corathing.UI.WPF"
+ xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
+ xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="400">
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
+ ItemTemplateSelector="{StaticResource JobTemplateSelector}" />
+
+
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 d3e77ec..d6fc907 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/ToDoListWidget.xaml.cs
+++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/ToDoLists/ToDoListWidget.xaml.cs
@@ -21,9 +21,12 @@
using Corathing.Contracts.Bases;
using Corathing.Contracts.Entries;
+using Corathing.Contracts.Services;
using Corathing.Widgets.Basics.Widgets.Timers;
using Corathing.Widgets.Basics.Widgets.ToDoLists.Models;
+using Microsoft.Extensions.DependencyInjection;
+
namespace Corathing.Widgets.Basics.Widgets.ToDoLists;
[EntryCoraWidget(
@@ -71,7 +74,9 @@ public void RemoveJob(ToDoJob job)
///
public ToDoListViewModel(IServiceProvider services) : base(services)
{
- WidgetTitle = $"ToDoList";
+ ILocalizationService localizationService = services.GetService();
+ localizationService.Provide("Corathing.Widgets.Basics.ToDoListName", value => WidgetTitle = value);
+
Jobs = new ObservableCollection();
}
}
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 9e39c33..a9526e5 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Widgets/WebPages/WebPageWidget.xaml.cs
+++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/WebPages/WebPageWidget.xaml.cs
@@ -82,6 +82,9 @@ public partial class WebPageViewModel : WidgetContext
///
public WebPageViewModel(IServiceProvider services) : base(services)
{
+ ILocalizationService localizationService = services.GetService();
+ localizationService.Provide("Corathing.Widgets.Basics.WebPageName", value => WidgetTitle = value);
+
var appStateService = services.GetService();
//if (!widgetSystemService.TryGetWidgetOption(Uid, out var option))
//WidgetTitle = option.Name;
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 15a5748..76a18ac 100644
--- a/src/Widgets/Corathing.Widgets.Basics/Widgets/WebQueries/WebQueryWidget.xaml.cs
+++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/WebQueries/WebQueryWidget.xaml.cs
@@ -15,8 +15,11 @@
using Corathing.Contracts.Bases;
using Corathing.Contracts.Entries;
+using Corathing.Contracts.Services;
using Corathing.Widgets.Basics.Widgets.WebPages;
+using Microsoft.Extensions.DependencyInjection;
+
namespace Corathing.Widgets.Basics.Widgets.WebQueries;
[EntryCoraWidget(
@@ -35,7 +38,8 @@ public partial class WebQueryViewModel : WidgetContext
///
public WebQueryViewModel(IServiceProvider services) : base(services)
{
- WidgetTitle = $"ToDoList";
+ ILocalizationService localizationService = services.GetService();
+ localizationService.Provide("Corathing.Widgets.Basics.WebQueryName", value => WidgetTitle = value);
}
}