From 0c890acd7cd135d57e237a14364693aba82e9a1a Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 27 Jan 2020 16:03:34 +0000 Subject: [PATCH 01/52] Remove UWP support --- source/SylphyHorn/Interop/UwpBridge.cs | 35 -------------------- source/SylphyHorn/Startup.cs | 46 +++----------------------- source/SylphyHorn/SylphyHorn.csproj | 8 ++--- 3 files changed, 7 insertions(+), 82 deletions(-) delete mode 100644 source/SylphyHorn/Interop/UwpBridge.cs diff --git a/source/SylphyHorn/Interop/UwpBridge.cs b/source/SylphyHorn/Interop/UwpBridge.cs deleted file mode 100644 index 1539d55..0000000 --- a/source/SylphyHorn/Interop/UwpBridge.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using Windows.Foundation; - -namespace SylphyHorn.Interop -{ - public static class UwpBridge - { - public static Task ToTask(this IAsyncOperation operation) - { - var source = new TaskCompletionSource(); - - operation.Completed = (asyncInfo, asyncStatus) => - { - switch (asyncStatus) - { - case AsyncStatus.Completed: - source.SetResult(asyncInfo.GetResults()); - break; - - case AsyncStatus.Canceled: - source.SetCanceled(); - break; - - case AsyncStatus.Error: - source.SetException(asyncInfo.ErrorCode); - break; - } - }; - - return source.Task; - } - } -} diff --git a/source/SylphyHorn/Startup.cs b/source/SylphyHorn/Startup.cs index 3351418..94501b9 100644 --- a/source/SylphyHorn/Startup.cs +++ b/source/SylphyHorn/Startup.cs @@ -4,18 +4,14 @@ using MetroTrilithon.Desktop; using MetroTrilithon.Threading.Tasks; using SylphyHorn.Interop; -using Windows.ApplicationModel; namespace SylphyHorn { public class Startup { private readonly string _path; - private readonly StartupTask _task; - public bool IsExists => Platform.IsUwp - ? this._task.State == StartupTaskState.Enabled || this._task.State == StartupTaskState.DisabledByUser - : File.Exists(this._path); + public bool IsExists => File.Exists(this._path); public Startup() : this(GetExecutingAssemblyFileNameWithoutExtension()) @@ -24,46 +20,19 @@ public Startup() public Startup(string name) { - if (Platform.IsUwp) - { - this._task = GetStartupTask(); - } - else - { - this._path = GetStartupFilePath(name); - } + this._path = GetStartupFilePath(name); } public void Create() { - if (Platform.IsUwp) - { - if (this._task.State == StartupTaskState.Disabled) - { - this._task.RequestEnableAsync().ToTask().Forget(); - } - } - else - { - ShellLink.Create(this._path); - } + ShellLink.Create(this._path); } public void Remove() { - if (Platform.IsUwp) - { - if (this._task.State == StartupTaskState.Enabled || this._task.State == StartupTaskState.DisabledByUser) - { - this._task.Disable(); - } - } - else + if (this.IsExists) { - if (this.IsExists) - { - File.Delete(this._path); - } + File.Delete(this._path); } } @@ -77,10 +46,5 @@ private static string GetExecutingAssemblyFileNameWithoutExtension() { return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location); } - - private static StartupTask GetStartupTask() - { - return StartupTask.GetAsync("SylphyHornEngineStartupTask").ToTask().Result; - } } } diff --git a/source/SylphyHorn/SylphyHorn.csproj b/source/SylphyHorn/SylphyHorn.csproj index a2a7cce..e180264 100644 --- a/source/SylphyHorn/SylphyHorn.csproj +++ b/source/SylphyHorn/SylphyHorn.csproj @@ -213,9 +213,6 @@ 4.0 - - - @@ -281,7 +278,6 @@ SettingsWindow.xaml - Designer MSBuild:Compile @@ -304,10 +300,10 @@ Application.xaml Code - + Application.xaml - + Application.xaml From 4f968f42c4ae21b8fb8155240574e38cea4fce17 Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 27 Jan 2020 16:19:31 +0000 Subject: [PATCH 02/52] Designer language changes --- .../Properties/Resources.Designer.cs | 150 +++++++++--------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/source/SylphyHorn/Properties/Resources.Designer.cs b/source/SylphyHorn/Properties/Resources.Designer.cs index 5d5a7d5..88d6c46 100644 --- a/source/SylphyHorn/Properties/Resources.Designer.cs +++ b/source/SylphyHorn/Properties/Resources.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// このコードはツールによって生成されました。 -// ランタイム バージョン:4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 -// コードが再生成されるときに損失したりします。 +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -13,13 +13,13 @@ namespace SylphyHorn.Properties { /// - /// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。 + /// A strongly-typed resource class, for looking up localized strings, etc. /// - // このクラスは StronglyTypedResourceBuilder クラスが ResGen - // または Visual Studio のようなツールを使用して自動生成されました。 - // メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に - // ResGen を実行し直すか、または VS プロジェクトをビルドし直します。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { @@ -33,7 +33,7 @@ internal Resources() { } /// - /// このクラスで使用されているキャッシュされた ResourceManager インスタンスを返します。 + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Resources.ResourceManager ResourceManager { @@ -47,8 +47,8 @@ internal Resources() { } /// - /// 厳密に型指定されたこのリソース クラスを使用して、すべての検索リソースに対し、 - /// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。 + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Globalization.CultureInfo Culture { @@ -61,7 +61,7 @@ internal Resources() { } /// - /// provided by Windows に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to provided by Windows. /// public static string Common_ProvidedByWinows { get { @@ -70,7 +70,7 @@ public static string Common_ProvidedByWinows { } /// - /// Reference に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Reference. /// public static string Common_Reference { get { @@ -79,7 +79,7 @@ public static string Common_Reference { } /// - /// Background に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Background. /// public static string Settings_Background { get { @@ -88,7 +88,7 @@ public static string Settings_Background { } /// - /// Change the background for each desktop に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Change the background for each desktop. /// public static string Settings_Background_ChangeBackground { get { @@ -97,7 +97,7 @@ public static string Settings_Background_ChangeBackground { } /// - /// Desktop background に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Desktop background. /// public static string Settings_Background_Desktop { get { @@ -106,7 +106,7 @@ public static string Settings_Background_Desktop { } /// - /// Supported image formats: JPEG, PNG, BMP に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Supported image formats: JPEG, PNG, BMP. /// public static string Settings_Background_Note1 { get { @@ -115,7 +115,7 @@ public static string Settings_Background_Note1 { } /// - /// Note: Please prepare image files with the virtual desktop number as filename (e.g. "1.png", "2.png", ...). に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Note: Please prepare image files with the virtual desktop number as filename (e.g. "1.png", "2.png", ...).. /// public static string Settings_Background_Note2 { get { @@ -124,7 +124,7 @@ public static string Settings_Background_Note2 { } /// - /// Select Background Images Folder に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Select Background Images Folder. /// public static string Settings_Background_SelectionDialog { get { @@ -133,7 +133,7 @@ public static string Settings_Background_SelectionDialog { } /// - /// Source image folder path に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Source image folder path. /// public static string Settings_Background_SourceImageFolder { get { @@ -142,7 +142,7 @@ public static string Settings_Background_SourceImageFolder { } /// - /// Close desktop に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Close desktop. /// public static string Settings_CloseDesktop { get { @@ -151,7 +151,7 @@ public static string Settings_CloseDesktop { } /// - /// Close and switch left: に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Close and switch left:. /// public static string Settings_CloseDesktop_CloseAndSwitchLeft { get { @@ -160,7 +160,7 @@ public static string Settings_CloseDesktop_CloseAndSwitchLeft { } /// - /// Close and switch right: に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Close and switch right:. /// public static string Settings_CloseDesktop_CloseAndSwitchRight { get { @@ -169,7 +169,7 @@ public static string Settings_CloseDesktop_CloseAndSwitchRight { } /// - /// Desktop switching に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Desktop switching. /// public static string Settings_DesktopSwitching { get { @@ -178,7 +178,7 @@ public static string Settings_DesktopSwitching { } /// - /// Loop virtual desktops に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Loop virtual desktops. /// public static string Settings_DesktopSwitching_Loop { get { @@ -187,7 +187,7 @@ public static string Settings_DesktopSwitching_Loop { } /// - /// Override OS default key combination (Ctrl+Win+Left and Right) に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Override OS default key combination (Ctrl+Win+Left and Right). /// public static string Settings_DesktopSwitching_OverrideOS { get { @@ -196,7 +196,7 @@ public static string Settings_DesktopSwitching_OverrideOS { } /// - /// General に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to General. /// public static string Settings_General { get { @@ -205,7 +205,7 @@ public static string Settings_General { } /// - /// Language に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Language. /// public static string Settings_Language { get { @@ -214,7 +214,7 @@ public static string Settings_Language { } /// - /// You must restart app in order for the changes to take all effect. に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to You must restart app in order for the changes to take all effect.. /// public static string Settings_Language_RequireRestartMessage { get { @@ -223,7 +223,7 @@ public static string Settings_Language_RequireRestartMessage { } /// - /// App log に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to App log. /// public static string Settings_Log { get { @@ -232,7 +232,7 @@ public static string Settings_Log { } /// - /// Event viewer に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Event viewer. /// public static string Settings_LogViewer { get { @@ -241,7 +241,7 @@ public static string Settings_LogViewer { } /// - /// Events that occurred during execution are displayed here. に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Events that occurred during execution are displayed here.. /// public static string Settings_LogViewer_Description { get { @@ -250,7 +250,7 @@ public static string Settings_LogViewer_Description { } /// - /// Move active window to adjacent desktop に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Move active window to adjacent desktop. /// public static string Settings_MoveWindowToAdjacentDesktop { get { @@ -259,7 +259,7 @@ public static string Settings_MoveWindowToAdjacentDesktop { } /// - /// Left: に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Left:. /// public static string Settings_MoveWindowToAdjacentDesktop_Left { get { @@ -268,7 +268,7 @@ public static string Settings_MoveWindowToAdjacentDesktop_Left { } /// - /// Left (Switch): に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Left (Switch):. /// public static string Settings_MoveWindowToAdjacentDesktop_LeftAndSwitch { get { @@ -277,7 +277,7 @@ public static string Settings_MoveWindowToAdjacentDesktop_LeftAndSwitch { } /// - /// Right: に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Right:. /// public static string Settings_MoveWindowToAdjacentDesktop_Right { get { @@ -286,7 +286,7 @@ public static string Settings_MoveWindowToAdjacentDesktop_Right { } /// - /// Right (Switch): に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Right (Switch):. /// public static string Settings_MoveWindowToAdjacentDesktop_RightAndSwitch { get { @@ -295,7 +295,7 @@ public static string Settings_MoveWindowToAdjacentDesktop_RightAndSwitch { } /// - /// Move active window to created new desktop に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Move active window to created new desktop. /// public static string Settings_MoveWindowToCreatedDesktop { get { @@ -304,7 +304,7 @@ public static string Settings_MoveWindowToCreatedDesktop { } /// - /// Switch only に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Switch only. /// public static string Settings_MoveWindowToCreatedDesktop_CreateOnly { get { @@ -313,7 +313,7 @@ public static string Settings_MoveWindowToCreatedDesktop_CreateOnly { } /// - /// Move: に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Move:. /// public static string Settings_MoveWindowToCreatedDesktop_Move { get { @@ -322,7 +322,7 @@ public static string Settings_MoveWindowToCreatedDesktop_Move { } /// - /// Move (Switch): に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Move (Switch):. /// public static string Settings_MoveWindowToCreatedDesktop_MoveAndSwitch { get { @@ -331,7 +331,7 @@ public static string Settings_MoveWindowToCreatedDesktop_MoveAndSwitch { } /// - /// Destination displays に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Destination displays. /// public static string Settings_MultipleDisplays { get { @@ -340,7 +340,7 @@ public static string Settings_MultipleDisplays { } /// - /// All displays に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to All displays. /// public static string Settings_MultipleDisplays_AllDisplays { get { @@ -349,7 +349,7 @@ public static string Settings_MultipleDisplays_AllDisplays { } /// - /// Current display に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Current display. /// public static string Settings_MultipleDisplays_CurrentDisplay { get { @@ -358,7 +358,7 @@ public static string Settings_MultipleDisplays_CurrentDisplay { } /// - /// Display {0}: {1} に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Display {0}: {1}. /// public static string Settings_MultipleDisplays_EachDisplay { get { @@ -367,7 +367,7 @@ public static string Settings_MultipleDisplays_EachDisplay { } /// - /// Notification に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Notification. /// public static string Settings_Notification { get { @@ -376,7 +376,7 @@ public static string Settings_Notification { } /// - /// Display a notification when switched virtual desktop に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Display a notification when switched virtual desktop. /// public static string Settings_Notification_Display { get { @@ -385,7 +385,7 @@ public static string Settings_Notification_Display { } /// - /// Time Duration for Notification Messages: に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Time Duration for Notification Messages:. /// public static string Settings_Notification_Display_Duration { get { @@ -394,7 +394,7 @@ public static string Settings_Notification_Display_Duration { } /// - /// ms に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to ms. /// public static string Settings_Notification_Display_Duration_Milliseconds { get { @@ -403,7 +403,7 @@ public static string Settings_Notification_Display_Duration_Milliseconds { } /// - /// Notification window placement に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Notification window placement. /// public static string Settings_NotificationWindowPlacement { get { @@ -412,7 +412,7 @@ public static string Settings_NotificationWindowPlacement { } /// - /// Bottom center に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Bottom center. /// public static string Settings_NotificationWindowPlacement_BottomCenter { get { @@ -421,7 +421,7 @@ public static string Settings_NotificationWindowPlacement_BottomCenter { } /// - /// Bottom left に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Bottom left. /// public static string Settings_NotificationWindowPlacement_BottomLeft { get { @@ -430,7 +430,7 @@ public static string Settings_NotificationWindowPlacement_BottomLeft { } /// - /// Bottom right に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Bottom right. /// public static string Settings_NotificationWindowPlacement_BottomRight { get { @@ -439,7 +439,7 @@ public static string Settings_NotificationWindowPlacement_BottomRight { } /// - /// Center に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Center. /// public static string Settings_NotificationWindowPlacement_Center { get { @@ -448,7 +448,7 @@ public static string Settings_NotificationWindowPlacement_Center { } /// - /// Top center に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Top center. /// public static string Settings_NotificationWindowPlacement_TopCenter { get { @@ -457,7 +457,7 @@ public static string Settings_NotificationWindowPlacement_TopCenter { } /// - /// Top left に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Top left. /// public static string Settings_NotificationWindowPlacement_TopLeft { get { @@ -466,7 +466,7 @@ public static string Settings_NotificationWindowPlacement_TopLeft { } /// - /// Top right に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Top right. /// public static string Settings_NotificationWindowPlacement_TopRight { get { @@ -475,7 +475,7 @@ public static string Settings_NotificationWindowPlacement_TopRight { } /// - /// Pin window: に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Pin window:. /// public static string Settings_Pin { get { @@ -484,7 +484,7 @@ public static string Settings_Pin { } /// - /// Pin/Unpin toggle: に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Pin/Unpin toggle:. /// public static string Settings_PinToggle { get { @@ -493,7 +493,7 @@ public static string Settings_PinToggle { } /// - /// Pin window to all desktops に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Pin window to all desktops. /// public static string Settings_PinWindow { get { @@ -502,7 +502,7 @@ public static string Settings_PinWindow { } /// - /// Pin window from app to all desktops に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Pin window from app to all desktops. /// public static string Settings_PinWindowFromApp { get { @@ -511,7 +511,7 @@ public static string Settings_PinWindowFromApp { } /// - /// Placement に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Placement. /// public static string Settings_Placement { get { @@ -520,7 +520,7 @@ public static string Settings_Placement { } /// - /// Shortcut key に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Shortcut key. /// public static string Settings_ShortcutKey { get { @@ -529,7 +529,7 @@ public static string Settings_ShortcutKey { } /// - /// Startup に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Startup. /// public static string Settings_Startup { get { @@ -538,7 +538,7 @@ public static string Settings_Startup { } /// - /// Automaticaly start at logon に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Automaticaly start at logon. /// public static string Settings_Startup_Automaticaly { get { @@ -547,7 +547,7 @@ public static string Settings_Startup_Automaticaly { } /// - /// Settings に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Settings. /// public static string Settings_Title { get { @@ -556,7 +556,7 @@ public static string Settings_Title { } /// - /// Show current desktop info in tray に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Show current desktop info in tray. /// public static string Settings_ToggleTrayIconInfo { get { @@ -565,7 +565,7 @@ public static string Settings_ToggleTrayIconInfo { } /// - /// Tray Icon に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Tray Icon. /// public static string Settings_TrayIcon { get { @@ -574,7 +574,7 @@ public static string Settings_TrayIcon { } /// - /// Unpin window: に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Unpin window:. /// public static string Settings_Unpin { get { @@ -583,7 +583,7 @@ public static string Settings_Unpin { } /// - /// Version に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Version. /// public static string Settings_Version { get { @@ -592,7 +592,7 @@ public static string Settings_Version { } /// - /// Application is running in the background. に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to Application is running in the background.. /// public static string TaskTray_FirstTimeMessage { get { @@ -601,7 +601,7 @@ public static string TaskTray_FirstTimeMessage { } /// - /// E&xit (X) に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to E&xit (X). /// public static string TaskTray_Menu_Exit { get { @@ -610,7 +610,7 @@ public static string TaskTray_Menu_Exit { } /// - /// &Settings (S) に類似しているローカライズされた文字列を検索します。 + /// Looks up a localized string similar to &Settings (S). /// public static string TaskTray_Menu_Settings { get { From e376ecb5a708371ff714a744da7db9a248f39992 Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 27 Jan 2020 14:58:18 +0000 Subject: [PATCH 03/52] Add desktop reorder functionality --- .../Serialization/ShortcutKeySettings.cs | 18 +++++ source/SylphyHorn/ApplicationPreparation.cs | 8 ++ source/SylphyHorn/Interop/NativeMethods.cs | 6 ++ .../Properties/Resources.Designer.cs | 29 ++++++- source/SylphyHorn/Properties/Resources.resx | 9 +++ .../Services/VirtualDesktopMoveService.cs | 79 +++++++++++++++++++ source/SylphyHorn/SylphyHorn.csproj | 1 + source/SylphyHorn/UI/SettingsWindow.xaml | 20 +++++ 8 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 source/SylphyHorn/Services/VirtualDesktopMoveService.cs diff --git a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs index f20f53c..8adddbe 100644 --- a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs +++ b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs @@ -14,6 +14,10 @@ public ShortcutKeySettings(ISerializationProvider provider) { this._provider = provider; } + + public ShortcutkeyProperty MoveDesktopLeft => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveDesktopLeftDefaultValue)); + + public ShortcutkeyProperty MoveDesktopRight => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveDesktopRightDefaultValue)); public ShortcutkeyProperty MoveLeft => this.Cache(key => new ShortcutkeyProperty(key, this._provider)); @@ -49,6 +53,20 @@ public ShortcutKeySettings(ISerializationProvider provider) #region default values + private static int[] MoveDesktopLeftDefaultValue { get; } = + { + 037, // <= + 162, // Left Ctrl + 164, // Left Alt + }; + + private static int[] MoveDesktopRightDefaultValue { get; } = + { + 039, // => + 162, // Left Ctrl + 164, // Left Alt + }; + private static int[] SwitchToLeftDefaultValue { get; } = { 037, // <= diff --git a/source/SylphyHorn/ApplicationPreparation.cs b/source/SylphyHorn/ApplicationPreparation.cs index 830f1b6..bd103c3 100644 --- a/source/SylphyHorn/ApplicationPreparation.cs +++ b/source/SylphyHorn/ApplicationPreparation.cs @@ -38,6 +38,14 @@ public void RegisterActions() { var settings = Settings.ShortcutKey; + this._hookService + .Register(()=>settings.MoveDesktopLeft.ToShortcutKey(), hWnd => VirtualDesktopMoveService.MoveLeft()) + .AddTo(this._disposable); + + this._hookService + .Register(()=>settings.MoveDesktopRight.ToShortcutKey(), hWnd => VirtualDesktopMoveService.MoveRight()) + .AddTo(this._disposable); + this._hookService .Register(()=>settings.MoveLeft.ToShortcutKey(), hWnd => hWnd.MoveToLeft()) .AddTo(this._disposable); diff --git a/source/SylphyHorn/Interop/NativeMethods.cs b/source/SylphyHorn/Interop/NativeMethods.cs index b5d5c53..d1b48ac 100644 --- a/source/SylphyHorn/Interop/NativeMethods.cs +++ b/source/SylphyHorn/Interop/NativeMethods.cs @@ -50,6 +50,12 @@ public static class NativeMethods [DllImport("dxva2.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool DestroyPhysicalMonitors(uint dwPhysicalMonitorArraySize, PHYSICAL_MONITOR[] pPhysicalMonitorArray); + + public delegate bool Win32Callback(IntPtr hwnd, IntPtr lParam); + + [DllImport("user32.Dll")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool EnumChildWindows(IntPtr parentHandle, Win32Callback callback, IntPtr lParam); } public delegate bool EnumMonitorsDelegate(IntPtr hMonitor, IntPtr hdcMonitor, ref RECT lprcMonitor, IntPtr dwData); diff --git a/source/SylphyHorn/Properties/Resources.Designer.cs b/source/SylphyHorn/Properties/Resources.Designer.cs index 88d6c46..1e49e10 100644 --- a/source/SylphyHorn/Properties/Resources.Designer.cs +++ b/source/SylphyHorn/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace SylphyHorn.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { @@ -249,6 +249,33 @@ public static string Settings_LogViewer_Description { } } + /// + /// Looks up a localized string similar to Move desktop. + /// + public static string Settings_MoveDesktop { + get { + return ResourceManager.GetString("Settings_MoveDesktop", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Left:. + /// + public static string Settings_MoveDesktop_Left { + get { + return ResourceManager.GetString("Settings_MoveDesktop_Left", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Right:. + /// + public static string Settings_MoveDesktop_Right { + get { + return ResourceManager.GetString("Settings_MoveDesktop_Right", resourceCulture); + } + } + /// /// Looks up a localized string similar to Move active window to adjacent desktop. /// diff --git a/source/SylphyHorn/Properties/Resources.resx b/source/SylphyHorn/Properties/Resources.resx index c1c5467..7cc04dd 100644 --- a/source/SylphyHorn/Properties/Resources.resx +++ b/source/SylphyHorn/Properties/Resources.resx @@ -279,6 +279,15 @@ Automaticaly start at logon + + Move desktop + + + Left: + + + Right: + Settings diff --git a/source/SylphyHorn/Services/VirtualDesktopMoveService.cs b/source/SylphyHorn/Services/VirtualDesktopMoveService.cs new file mode 100644 index 0000000..dd39405 --- /dev/null +++ b/source/SylphyHorn/Services/VirtualDesktopMoveService.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using WindowsDesktop; +using SylphyHorn.Interop; + +namespace SylphyHorn.Services +{ + public static class VirtualDesktopMoveService + { + public static void MoveLeft() + { + var target = VirtualDesktop.Current.GetLeft(); + SwapDesktops(VirtualDesktop.Current, target); + target.Switch(); + } + + public static void MoveRight() + { + var target = VirtualDesktop.Current.GetRight(); + SwapDesktops(VirtualDesktop.Current, target); + target.Switch(); + } + + private static void SwapDesktops(VirtualDesktop source, VirtualDesktop target) + { + var srcWindows = new List(); + var dstWindows = new List(); + foreach (var window in GetAllWindows()) + { + var desktop = VirtualDesktop.FromHwnd(window); + if (desktop == source) + srcWindows.Add(window); + else if (desktop == target) + dstWindows.Add(window); + } + + foreach (var window in srcWindows) + VirtualDesktopHelper.MoveToDesktop(window, target); + foreach (var window in dstWindows) + VirtualDesktopHelper.MoveToDesktop(window, source); + } + + private static IEnumerable GetAllWindows() + { + return GetChildWindows(IntPtr.Zero).ToList(); + } + + private static IEnumerable GetChildWindows(IntPtr parent) + { + var result = new List(); + var listHandle = GCHandle.Alloc(result); + try + { + var childProc = new NativeMethods.Win32Callback(EnumWindow); + NativeMethods.EnumChildWindows(parent, childProc, GCHandle.ToIntPtr(listHandle)); + } + finally + { + if (listHandle.IsAllocated) + listHandle.Free(); + } + return result; + } + + private static bool EnumWindow(IntPtr handle, IntPtr pointer) + { + var gch = GCHandle.FromIntPtr(pointer); + if (!(gch.Target is List list)) + { + throw new InvalidCastException("GCHandle Target could not be cast as List"); + } + list.Add(handle); + // return null to cancel? + return true; + } + } +} diff --git a/source/SylphyHorn/SylphyHorn.csproj b/source/SylphyHorn/SylphyHorn.csproj index e180264..7550556 100644 --- a/source/SylphyHorn/SylphyHorn.csproj +++ b/source/SylphyHorn/SylphyHorn.csproj @@ -242,6 +242,7 @@ True Resources.resx + diff --git a/source/SylphyHorn/UI/SettingsWindow.xaml b/source/SylphyHorn/UI/SettingsWindow.xaml index 036c252..de6c5d9 100644 --- a/source/SylphyHorn/UI/SettingsWindow.xaml +++ b/source/SylphyHorn/UI/SettingsWindow.xaml @@ -540,6 +540,26 @@ + + + + + + + + + + + + + + + + From 708b6e1502e50f6bf4b9626f4756c413386ca85c Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 27 Jan 2020 17:16:38 +0000 Subject: [PATCH 04/52] Update README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index da5a4a7..40036e9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # SylphyHorn +> This is a fork of [SylphyHorn](https://github.com/Grabacr07/SylphyHorn) which adds desktop reordering functionality + SylphyHorn is Virtual Desktop Tools for Windows 10. Provides global hotkeys, switching notification, change background and several functions to virtual desktop. @@ -18,6 +20,9 @@ Please download from [Windows app store](https://www.microsoft.com/store/apps/9n ## Features +* __Reorder virtual desktops (move left and right)__ +(default key combination: Ctrl + Alt + <- or ->) + * Switching notification From 0cd9905eb8affea74384bfa67c46407b80e897eb Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 27 Jan 2020 18:07:02 +0000 Subject: [PATCH 05/52] Bump version --- source/SylphyHorn/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/SylphyHorn/Properties/AssemblyInfo.cs b/source/SylphyHorn/Properties/AssemblyInfo.cs index da9fcf7..c5b43f4 100644 --- a/source/SylphyHorn/Properties/AssemblyInfo.cs +++ b/source/SylphyHorn/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -[assembly: AssemblyVersion("3.1.0.0")] +[assembly: AssemblyVersion("4.0.0.0")] [assembly: ComVisible(false)] From 5a957adbdfde795ec053296d077d996b4ec24990 Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 27 Jan 2020 17:29:29 +0000 Subject: [PATCH 06/52] Add GitHub CI --- .github/workflows/main.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..9ebfc00 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,36 @@ +name: CI + +on: [push] + +jobs: + build: + + runs-on: [windows-2019] + + steps: + - name: Setup MSBuild.exe + uses: warrenbuckley/Setup-MSBuild@v1 + + - name: Setup Nuget.exe + uses: warrenbuckley/Setup-Nuget@v1 + + - uses: actions/checkout@v1 + - name: Build + run: | + cd source + git submodule update --init --recursive + nuget restore SylphyHorn.sln + msbuild SylphyHorn.sln /p:Configuration=Release /m /verbosity:normal /p:WarningLevel=0 + - name: Create ZIP + if: startsWith(github.ref, 'refs/tags/') + run: | + Rename-Item -Path "source/SylphyHorn/bin/Release" -NewName "SylphyHornEx" + Compress-Archive -Path "source/SylphyHorn/bin/SylphyHornEx" -DestinationPath SylphyHornEx.zip + + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: SylphyHornEx.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From b0e81a66a31faa60c6773cd24a9d2a82f2e4ebc2 Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 27 Jan 2020 18:12:23 +0000 Subject: [PATCH 07/52] Update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 40036e9..4339692 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# SylphyHorn +# SylphyHornEx > This is a fork of [SylphyHorn](https://github.com/Grabacr07/SylphyHorn) which adds desktop reordering functionality @@ -20,7 +20,7 @@ Please download from [Windows app store](https://www.microsoft.com/store/apps/9n ## Features -* __Reorder virtual desktops (move left and right)__ +* __Reorder virtual desktops__ (default key combination: Ctrl + Alt + <- or ->) * Switching notification From 124df1d02927233e9c5eba52d16e1fd5924e6b10 Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 27 Jan 2020 18:47:20 +0000 Subject: [PATCH 08/52] Prevent trying to use adjacent desktop if none --- source/SylphyHorn/Services/VirtualDesktopMoveService.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/SylphyHorn/Services/VirtualDesktopMoveService.cs b/source/SylphyHorn/Services/VirtualDesktopMoveService.cs index dd39405..14d41c5 100644 --- a/source/SylphyHorn/Services/VirtualDesktopMoveService.cs +++ b/source/SylphyHorn/Services/VirtualDesktopMoveService.cs @@ -12,6 +12,8 @@ public static class VirtualDesktopMoveService public static void MoveLeft() { var target = VirtualDesktop.Current.GetLeft(); + if (target == null) + return; SwapDesktops(VirtualDesktop.Current, target); target.Switch(); } @@ -19,6 +21,8 @@ public static void MoveLeft() public static void MoveRight() { var target = VirtualDesktop.Current.GetRight(); + if (target == null) + return; SwapDesktops(VirtualDesktop.Current, target); target.Switch(); } From 8b8024021f570bf253401ff2769f54abbe2cc25f Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 27 Jan 2020 18:48:29 +0000 Subject: [PATCH 09/52] Update move desktop default keybinds to avoid conflict --- README.md | 2 +- source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4339692..b345ef0 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Please download from [Windows app store](https://www.microsoft.com/store/apps/9n ## Features * __Reorder virtual desktops__ -(default key combination: Ctrl + Alt + <- or ->) +(default key combination: Win + Alt + <- or ->) * Switching notification diff --git a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs index 8adddbe..6276521 100644 --- a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs +++ b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs @@ -56,14 +56,14 @@ public ShortcutKeySettings(ISerializationProvider provider) private static int[] MoveDesktopLeftDefaultValue { get; } = { 037, // <= - 162, // Left Ctrl + 091, // Left Windows 164, // Left Alt }; private static int[] MoveDesktopRightDefaultValue { get; } = { 039, // => - 162, // Left Ctrl + 091, // Left Windows 164, // Left Alt }; From 5fb2606e72e6dc248dd2f965981aa290c1a7c971 Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 27 Jan 2020 18:47:28 +0000 Subject: [PATCH 10/52] Bump version --- source/SylphyHorn/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/SylphyHorn/Properties/AssemblyInfo.cs b/source/SylphyHorn/Properties/AssemblyInfo.cs index c5b43f4..b3ffefe 100644 --- a/source/SylphyHorn/Properties/AssemblyInfo.cs +++ b/source/SylphyHorn/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -[assembly: AssemblyVersion("4.0.0.0")] +[assembly: AssemblyVersion("4.0.1.0")] [assembly: ComVisible(false)] From 785378ee22d998a7300d5e7e50eb372daf59c6c8 Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 27 Jan 2020 19:14:22 +0000 Subject: [PATCH 11/52] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b345ef0..dff8e6a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This app is Windows Desktop application running on .NET Framework, however built ## Installations -Please download from [Windows app store](https://www.microsoft.com/store/apps/9nblggh58t01) and install. +Please download from [Releases](https://github.com/ViRb3/SylphyHornEx/releases). ## Requirements From 08d737db2f79b7c0e2703d254f4b3fbf93884a0b Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 28 Jan 2020 02:35:15 +0000 Subject: [PATCH 12/52] Rework notification windows --- .../Services/NotificationService.cs | 6 ++---- .../Bindings/NotificationWindowViewModel.cs | 19 ------------------- source/SylphyHorn/UI/PinWindow.xaml | 11 +++-------- source/SylphyHorn/UI/SwitchWindow.xaml | 11 +++-------- 4 files changed, 8 insertions(+), 39 deletions(-) diff --git a/source/SylphyHorn/Services/NotificationService.cs b/source/SylphyHorn/Services/NotificationService.cs index 2a58ba8..d3bab32 100644 --- a/source/SylphyHorn/Services/NotificationService.cs +++ b/source/SylphyHorn/Services/NotificationService.cs @@ -50,8 +50,7 @@ private static IDisposable ShowDesktopWindow(int index) var vmodel = new NotificationWindowViewModel { Title = ProductInfo.Title, - Header = "Virtual Desktop Switched", - Body = "Current Desktop: Desktop " + index, + Body = $"Desktop {index}", }; var source = new CancellationTokenSource(); @@ -94,8 +93,7 @@ private static IDisposable ShowPinWindow(IntPtr hWnd, PinOperations operation) var vmodel = new NotificationWindowViewModel { Title = ProductInfo.Title, - Header = "Virtual Desktop", - Body = $"{(operation.HasFlag(PinOperations.Pin) ? "Pinned" : "Unpinned")} this {(operation.HasFlag(PinOperations.Window) ? "window" : "application")}", + Body = $"{(operation.HasFlag(PinOperations.Window) ? "Window" : "Application")} {(operation.HasFlag(PinOperations.Pin) ? "Pinned" : "Unpinned")}", }; var source = new CancellationTokenSource(); var window = new PinWindow(hWnd) diff --git a/source/SylphyHorn/UI/Bindings/NotificationWindowViewModel.cs b/source/SylphyHorn/UI/Bindings/NotificationWindowViewModel.cs index 34d9c6a..8f2e948 100644 --- a/source/SylphyHorn/UI/Bindings/NotificationWindowViewModel.cs +++ b/source/SylphyHorn/UI/Bindings/NotificationWindowViewModel.cs @@ -4,25 +4,6 @@ namespace SylphyHorn.UI.Bindings { public class NotificationWindowViewModel : WindowViewModel { - #region Header 変更通知プロパティ - - private string _Header; - - public string Header - { - get { return this._Header; } - set - { - if (this._Header != value) - { - this._Header = value; - this.RaisePropertyChanged(); - } - } - } - - #endregion - #region Body 変更通知プロパティ private string _Body; diff --git a/source/SylphyHorn/UI/PinWindow.xaml b/source/SylphyHorn/UI/PinWindow.xaml index 739be89..2d93b6e 100644 --- a/source/SylphyHorn/UI/PinWindow.xaml +++ b/source/SylphyHorn/UI/PinWindow.xaml @@ -13,7 +13,7 @@ mc:Ignorable="d" d:DataContext="{d:DesignInstance bindings:NotificationWindowViewModel}" Title="{Binding Title}" - Width="400" + Width="355.462" Height="100" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" @@ -67,14 +67,9 @@ - - + FontSize="32" HorizontalAlignment="Center" /> diff --git a/source/SylphyHorn/UI/SwitchWindow.xaml b/source/SylphyHorn/UI/SwitchWindow.xaml index a2f7910..e50de09 100644 --- a/source/SylphyHorn/UI/SwitchWindow.xaml +++ b/source/SylphyHorn/UI/SwitchWindow.xaml @@ -13,7 +13,7 @@ mc:Ignorable="d" d:DataContext="{d:DesignInstance bindings:NotificationWindowViewModel}" Title="{Binding Title}" - Width="500" + Width="211.476" Height="100" ResizeMode="NoResize" Topmost="True" @@ -66,14 +66,9 @@ - - + FontSize="32" HorizontalAlignment="Center" /> From da280b85e48cddcf3ad49645b8e74b37ccce57de Mon Sep 17 00:00:00 2001 From: kuukunen Date: Tue, 5 May 2020 16:18:10 +0900 Subject: [PATCH 13/52] Add functionality to Move, Switch and Move&Switch to specific desktops. Combine shortcut settings menus to one. Bump version mumber. --- .../Serialization/ShortcutKeySettings.cs | 280 ++++++++++++++++++ source/SylphyHorn/ApplicationPreparation.cs | 121 ++++++++ source/SylphyHorn/Properties/AssemblyInfo.cs | 2 +- .../Properties/Resources.Designer.cs | 58 +++- source/SylphyHorn/Properties/Resources.resx | 20 +- .../Services/VirtualDesktopService.cs | 26 ++ source/SylphyHorn/UI/SettingsWindow.xaml | 126 ++++++-- 7 files changed, 612 insertions(+), 21 deletions(-) diff --git a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs index 6276521..0f59bf0 100644 --- a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs +++ b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs @@ -51,6 +51,66 @@ public ShortcutKeySettings(ISerializationProvider provider) public ShortcutkeyProperty TogglePinApp => this.Cache(key => new ShortcutkeyProperty(key, this._provider)); + public ShortcutkeyProperty SwitchTo1 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchTo1DefaultValue)); + + public ShortcutkeyProperty SwitchTo2 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchTo2DefaultValue)); + + public ShortcutkeyProperty SwitchTo3 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchTo3DefaultValue)); + + public ShortcutkeyProperty SwitchTo4 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchTo4DefaultValue)); + + public ShortcutkeyProperty SwitchTo5 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchTo5DefaultValue)); + + public ShortcutkeyProperty SwitchTo6 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchTo6DefaultValue)); + + public ShortcutkeyProperty SwitchTo7 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchTo7DefaultValue)); + + public ShortcutkeyProperty SwitchTo8 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchTo8DefaultValue)); + + public ShortcutkeyProperty SwitchTo9 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchTo9DefaultValue)); + + public ShortcutkeyProperty SwitchTo10 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchTo10DefaultValue)); + + public ShortcutkeyProperty MoveTo1 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveTo1DefaultValue)); + + public ShortcutkeyProperty MoveTo2 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveTo2DefaultValue)); + + public ShortcutkeyProperty MoveTo3 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveTo3DefaultValue)); + + public ShortcutkeyProperty MoveTo4 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveTo4DefaultValue)); + + public ShortcutkeyProperty MoveTo5 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveTo5DefaultValue)); + + public ShortcutkeyProperty MoveTo6 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveTo6DefaultValue)); + + public ShortcutkeyProperty MoveTo7 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveTo7DefaultValue)); + + public ShortcutkeyProperty MoveTo8 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveTo8DefaultValue)); + + public ShortcutkeyProperty MoveTo9 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveTo9DefaultValue)); + + public ShortcutkeyProperty MoveTo10 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveTo10DefaultValue)); + + public ShortcutkeyProperty MoveAndSwitchTo1 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveAndSwitchTo1DefaultValue)); + + public ShortcutkeyProperty MoveAndSwitchTo2 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveAndSwitchTo2DefaultValue)); + + public ShortcutkeyProperty MoveAndSwitchTo3 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveAndSwitchTo3DefaultValue)); + + public ShortcutkeyProperty MoveAndSwitchTo4 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveAndSwitchTo4DefaultValue)); + + public ShortcutkeyProperty MoveAndSwitchTo5 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveAndSwitchTo5DefaultValue)); + + public ShortcutkeyProperty MoveAndSwitchTo6 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveAndSwitchTo6DefaultValue)); + + public ShortcutkeyProperty MoveAndSwitchTo7 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveAndSwitchTo7DefaultValue)); + + public ShortcutkeyProperty MoveAndSwitchTo8 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveAndSwitchTo8DefaultValue)); + + public ShortcutkeyProperty MoveAndSwitchTo9 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveAndSwitchTo9DefaultValue)); + + public ShortcutkeyProperty MoveAndSwitchTo10 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveAndSwitchTo10DefaultValue)); + #region default values private static int[] MoveDesktopLeftDefaultValue { get; } = @@ -113,6 +173,226 @@ public ShortcutKeySettings(ISerializationProvider provider) 091, // Left Windows }; + private static int[] SwitchTo1DefaultValue { get; } = + { + 049, // 1 + 162, // Left Ctrl + 091, // Left Windows + }; + + private static int[] SwitchTo2DefaultValue { get; } = + { + 050, // 2 + 162, // Left Ctrl + 091, // Left Windows + }; + + private static int[] SwitchTo3DefaultValue { get; } = + { + 051, // 3 + 162, // Left Ctrl + 091, // Left Windows + }; + + private static int[] SwitchTo4DefaultValue { get; } = + { + 052, // 4 + 162, // Left Ctrl + 091, // Left Windows + }; + + private static int[] SwitchTo5DefaultValue { get; } = + { + 053, // 5 + 162, // Left Ctrl + 091, // Left Windows + }; + + private static int[] SwitchTo6DefaultValue { get; } = + { + 054, // 6 + 162, // Left Ctrl + 091, // Left Windows + }; + + private static int[] SwitchTo7DefaultValue { get; } = + { + 055, // 7 + 162, // Left Ctrl + 091, // Left Windows + }; + + private static int[] SwitchTo8DefaultValue { get; } = + { + 056, // 8 + 162, // Left Ctrl + 091, // Left Windows + }; + + private static int[] SwitchTo9DefaultValue { get; } = + { + 057, // 9 + 162, // Left Ctrl + 091, // Left Windows + }; + + private static int[] SwitchTo10DefaultValue { get; } = + { + 048, // 0 + 162, // Left Ctrl + 091, // Left Windows + }; + + private static int[] MoveTo1DefaultValue { get; } = + { + 049, // 1 + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveTo2DefaultValue { get; } = + { + 050, // 2 + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveTo3DefaultValue { get; } = + { + 051, // 3 + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveTo4DefaultValue { get; } = + { + 052, // 4 + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveTo5DefaultValue { get; } = + { + 053, // 5 + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveTo6DefaultValue { get; } = + { + 054, // 6 + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveTo7DefaultValue { get; } = + { + 055, // 7 + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveTo8DefaultValue { get; } = + { + 056, // 8 + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveTo9DefaultValue { get; } = + { + 057, // 9 + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveTo10DefaultValue { get; } = + { + 048, // 0 + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveAndSwitchTo1DefaultValue { get; } = + { + 049, // 1 + 162, // Left Ctrl + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveAndSwitchTo2DefaultValue { get; } = + { + 050, // 2 + 162, // Left Ctrl + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveAndSwitchTo3DefaultValue { get; } = + { + 051, // 3 + 162, // Left Ctrl + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveAndSwitchTo4DefaultValue { get; } = + { + 052, // 4 + 162, // Left Ctrl + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveAndSwitchTo5DefaultValue { get; } = + { + 053, // 5 + 162, // Left Ctrl + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveAndSwitchTo6DefaultValue { get; } = + { + 054, // 6 + 162, // Left Ctrl + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveAndSwitchTo7DefaultValue { get; } = + { + 055, // 7 + 162, // Left Ctrl + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveAndSwitchTo8DefaultValue { get; } = + { + 056, // 8 + 162, // Left Ctrl + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveAndSwitchTo9DefaultValue { get; } = + { + 057, // 9 + 162, // Left Ctrl + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] MoveAndSwitchTo10DefaultValue { get; } = + { + 048, // 0 + 162, // Left Ctrl + 164, // Left Alt + 091, // Left Windows + }; + #endregion } } diff --git a/source/SylphyHorn/ApplicationPreparation.cs b/source/SylphyHorn/ApplicationPreparation.cs index bd103c3..4ed102c 100644 --- a/source/SylphyHorn/ApplicationPreparation.cs +++ b/source/SylphyHorn/ApplicationPreparation.cs @@ -115,6 +115,127 @@ public void RegisterActions() this._hookService .Register(() => settings.TogglePinApp.ToShortcutKey(), hWnd => hWnd.TogglePinApp()) .AddTo(this._disposable); + + this._hookService + .Register(() => settings.SwitchTo1.ToShortcutKey(), _ => VirtualDesktopService.Get(1)?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.SwitchTo2.ToShortcutKey(), _ => VirtualDesktopService.Get(2)?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.SwitchTo3.ToShortcutKey(), _ => VirtualDesktopService.Get(3)?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.SwitchTo4.ToShortcutKey(), _ => VirtualDesktopService.Get(4)?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.SwitchTo5.ToShortcutKey(), _ => VirtualDesktopService.Get(5)?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.SwitchTo6.ToShortcutKey(), _ => VirtualDesktopService.Get(6)?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.SwitchTo7.ToShortcutKey(), _ => VirtualDesktopService.Get(7)?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.SwitchTo8.ToShortcutKey(), _ => VirtualDesktopService.Get(8)?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.SwitchTo9.ToShortcutKey(), _ => VirtualDesktopService.Get(9)?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.SwitchTo10.ToShortcutKey(), _ => VirtualDesktopService.Get(10)?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveTo1.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(1))) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveTo2.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(2))) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveTo3.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(3))) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveTo4.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(4))) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveTo5.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(5))) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveTo6.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(6))) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveTo7.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(7))) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveTo8.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(8))) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveTo9.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(9))) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveTo10.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(10))) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveAndSwitchTo1.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(1))?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveAndSwitchTo2.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(2))?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveAndSwitchTo3.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(3))?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveAndSwitchTo4.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(4))?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveAndSwitchTo5.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(5))?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveAndSwitchTo6.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(6))?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveAndSwitchTo7.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(7))?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveAndSwitchTo8.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(8))?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveAndSwitchTo9.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(9))?.Switch()) + .AddTo(this._disposable); + + this._hookService + .Register(() => settings.MoveAndSwitchTo10.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(10))?.Switch()) + .AddTo(this._disposable); + } public TaskTrayIcon CreateTaskTrayIcon() diff --git a/source/SylphyHorn/Properties/AssemblyInfo.cs b/source/SylphyHorn/Properties/AssemblyInfo.cs index b3ffefe..01d721c 100644 --- a/source/SylphyHorn/Properties/AssemblyInfo.cs +++ b/source/SylphyHorn/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -[assembly: AssemblyVersion("4.0.1.0")] +[assembly: AssemblyVersion("5.0.0.0")] [assembly: ComVisible(false)] diff --git a/source/SylphyHorn/Properties/Resources.Designer.cs b/source/SylphyHorn/Properties/Resources.Designer.cs index 1e49e10..1034c47 100644 --- a/source/SylphyHorn/Properties/Resources.Designer.cs +++ b/source/SylphyHorn/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace SylphyHorn.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { @@ -249,6 +249,24 @@ public static string Settings_LogViewer_Description { } } + /// + /// Looks up a localized string similar to Move & Switch to {0}. + /// + public static string Settings_MoveAndSwitchTo { + get { + return ResourceManager.GetString("Settings_MoveAndSwitchTo", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Move active window to a specific desktop and switch to it. + /// + public static string Settings_MoveAndSwitchToTitle { + get { + return ResourceManager.GetString("Settings_MoveAndSwitchToTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Move desktop. /// @@ -276,6 +294,24 @@ public static string Settings_MoveDesktop_Right { } } + /// + /// Looks up a localized string similar to Move to {0}. + /// + public static string Settings_MoveTo { + get { + return ResourceManager.GetString("Settings_MoveTo", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Move active window to a specific desktop. + /// + public static string Settings_MoveToTitle { + get { + return ResourceManager.GetString("Settings_MoveToTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Move active window to adjacent desktop. /// @@ -547,7 +583,7 @@ public static string Settings_Placement { } /// - /// Looks up a localized string similar to Shortcut key. + /// Looks up a localized string similar to Shortcuts. /// public static string Settings_ShortcutKey { get { @@ -573,6 +609,24 @@ public static string Settings_Startup_Automaticaly { } } + /// + /// Looks up a localized string similar to Switch to {0}. + /// + public static string Settings_SwitchTo { + get { + return ResourceManager.GetString("Settings_SwitchTo", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Switch to a specific desktop. + /// + public static string Settings_SwitchToTitle { + get { + return ResourceManager.GetString("Settings_SwitchToTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Settings. /// diff --git a/source/SylphyHorn/Properties/Resources.resx b/source/SylphyHorn/Properties/Resources.resx index 7cc04dd..79201bf 100644 --- a/source/SylphyHorn/Properties/Resources.resx +++ b/source/SylphyHorn/Properties/Resources.resx @@ -271,7 +271,7 @@ Placement - Shortcut key + Shortcuts Startup @@ -312,4 +312,22 @@ &Settings (S) + + Move active window to a specific desktop and switch to it + + + Move & Switch to {0} + + + Move active window to a specific desktop + + + Move to {0} + + + Switch to a specific desktop + + + Switch to {0} + \ No newline at end of file diff --git a/source/SylphyHorn/Services/VirtualDesktopService.cs b/source/SylphyHorn/Services/VirtualDesktopService.cs index a4163ac..24968fa 100644 --- a/source/SylphyHorn/Services/VirtualDesktopService.cs +++ b/source/SylphyHorn/Services/VirtualDesktopService.cs @@ -9,6 +9,15 @@ namespace SylphyHorn.Services internal static class VirtualDesktopService { #region Get + public static VirtualDesktop Get(int index) + { + var desktops = VirtualDesktop.GetDesktops(); + + if (index < 1 || index > desktops.Length) + return null; + + return desktops[index-1]; + } public static VirtualDesktop GetLeft() { @@ -33,6 +42,17 @@ public static VirtualDesktop GetRight() #endregion #region Move + public static VirtualDesktop MoveTo(this IntPtr hWnd, VirtualDesktop target) + { + if (target == null) + { + SystemSounds.Asterisk.Play(); + return null; + } + + VirtualDesktopHelper.MoveToDesktop(hWnd, target); + return target; + } public static VirtualDesktop MoveToLeft(this IntPtr hWnd) { @@ -198,6 +218,12 @@ private static void RaisePinnedEvent(IntPtr target, PinOperations operation) WindowPinned?.Invoke(typeof(VirtualDesktopService), new WindowPinnedEventArgs(target, operation)); } + #endregion + + #region Pin / Unpin + + + #endregion } diff --git a/source/SylphyHorn/UI/SettingsWindow.xaml b/source/SylphyHorn/UI/SettingsWindow.xaml index de6c5d9..c477309 100644 --- a/source/SylphyHorn/UI/SettingsWindow.xaml +++ b/source/SylphyHorn/UI/SettingsWindow.xaml @@ -531,7 +531,7 @@ - @@ -641,21 +641,6 @@ - - - - - - - - - - - @@ -701,10 +686,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - Date: Tue, 5 May 2020 17:58:39 +0900 Subject: [PATCH 14/52] Add desktop naming functionality. Doesn't use the same names as Windows, because the API is hidden and the feature is currently only available in Insider Preview. --- .../Serialization/GeneralSettings.cs | 20 +++++++ source/SylphyHorn/Properties/AssemblyInfo.cs | 2 +- .../Properties/Resources.Designer.cs | 18 +++++++ source/SylphyHorn/Properties/Resources.resx | 6 +++ .../Services/NotificationService.cs | 25 ++++++++- source/SylphyHorn/UI/SettingsWindow.xaml | 53 +++++++++++++++++++ 6 files changed, 122 insertions(+), 2 deletions(-) diff --git a/source/SylphyHorn.Core/Serialization/GeneralSettings.cs b/source/SylphyHorn.Core/Serialization/GeneralSettings.cs index ef80c14..c244d2f 100644 --- a/source/SylphyHorn.Core/Serialization/GeneralSettings.cs +++ b/source/SylphyHorn.Core/Serialization/GeneralSettings.cs @@ -38,5 +38,25 @@ public GeneralSettings(ISerializationProvider provider) public SerializableProperty Display => this.Cache(key => new SerializableProperty(key, this._provider, 0)); public SerializableProperty TrayShowDesktop => this.Cache(key => new SerializableProperty(key, this._provider, false)); + + public SerializableProperty DesktopName1 => this.Cache(key => new SerializableProperty(key, this._provider, null)); + + public SerializableProperty DesktopName2 => this.Cache(key => new SerializableProperty(key, this._provider, null)); + + public SerializableProperty DesktopName3 => this.Cache(key => new SerializableProperty(key, this._provider, null)); + + public SerializableProperty DesktopName4 => this.Cache(key => new SerializableProperty(key, this._provider, null)); + + public SerializableProperty DesktopName5 => this.Cache(key => new SerializableProperty(key, this._provider, null)); + + public SerializableProperty DesktopName6 => this.Cache(key => new SerializableProperty(key, this._provider, null)); + + public SerializableProperty DesktopName7 => this.Cache(key => new SerializableProperty(key, this._provider, null)); + + public SerializableProperty DesktopName8 => this.Cache(key => new SerializableProperty(key, this._provider, null)); + + public SerializableProperty DesktopName9 => this.Cache(key => new SerializableProperty(key, this._provider, null)); + + public SerializableProperty DesktopName10 => this.Cache(key => new SerializableProperty(key, this._provider, null)); } } diff --git a/source/SylphyHorn/Properties/AssemblyInfo.cs b/source/SylphyHorn/Properties/AssemblyInfo.cs index 01d721c..dbc5cac 100644 --- a/source/SylphyHorn/Properties/AssemblyInfo.cs +++ b/source/SylphyHorn/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -[assembly: AssemblyVersion("5.0.0.0")] +[assembly: AssemblyVersion("5.1.0.0")] [assembly: ComVisible(false)] diff --git a/source/SylphyHorn/Properties/Resources.Designer.cs b/source/SylphyHorn/Properties/Resources.Designer.cs index 1034c47..ce45b79 100644 --- a/source/SylphyHorn/Properties/Resources.Designer.cs +++ b/source/SylphyHorn/Properties/Resources.Designer.cs @@ -429,6 +429,24 @@ public static string Settings_MultipleDisplays_EachDisplay { } } + /// + /// Looks up a localized string similar to Names. + /// + public static string Settings_NamesTab { + get { + return ResourceManager.GetString("Settings_NamesTab", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Set names for desktops. + /// + public static string Settings_NamesTitle { + get { + return ResourceManager.GetString("Settings_NamesTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Notification. /// diff --git a/source/SylphyHorn/Properties/Resources.resx b/source/SylphyHorn/Properties/Resources.resx index 79201bf..e98515c 100644 --- a/source/SylphyHorn/Properties/Resources.resx +++ b/source/SylphyHorn/Properties/Resources.resx @@ -330,4 +330,10 @@ Switch to {0} + + Names + + + Set names for desktops + \ No newline at end of file diff --git a/source/SylphyHorn/Services/NotificationService.cs b/source/SylphyHorn/Services/NotificationService.cs index d3bab32..59ff133 100644 --- a/source/SylphyHorn/Services/NotificationService.cs +++ b/source/SylphyHorn/Services/NotificationService.cs @@ -45,12 +45,35 @@ private void VirtualDesktopServiceOnWindowPinned(object sender, WindowPinnedEven }); } + private static string GetDesktopName(int index) + { + string setting = null; + switch(index) + { + case 1: setting = Settings.General.DesktopName1.Value; break; + case 2: setting = Settings.General.DesktopName2.Value; break; + case 3: setting = Settings.General.DesktopName3.Value; break; + case 4: setting = Settings.General.DesktopName4.Value; break; + case 5: setting = Settings.General.DesktopName5.Value; break; + case 6: setting = Settings.General.DesktopName6.Value; break; + case 7: setting = Settings.General.DesktopName7.Value; break; + case 8: setting = Settings.General.DesktopName8.Value; break; + case 9: setting = Settings.General.DesktopName9.Value; break; + case 10: setting = Settings.General.DesktopName10.Value; break; + } + if(setting != null && setting != "") + { + return $"{index}: {setting}"; + } + return $"Desktop {index}"; + } + private static IDisposable ShowDesktopWindow(int index) { var vmodel = new NotificationWindowViewModel { Title = ProductInfo.Title, - Body = $"Desktop {index}", + Body = GetDesktopName(index), }; var source = new CancellationTokenSource(); diff --git a/source/SylphyHorn/UI/SettingsWindow.xaml b/source/SylphyHorn/UI/SettingsWindow.xaml index c477309..be78513 100644 --- a/source/SylphyHorn/UI/SettingsWindow.xaml +++ b/source/SylphyHorn/UI/SettingsWindow.xaml @@ -215,6 +215,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Date: Tue, 5 May 2020 19:22:39 +0900 Subject: [PATCH 15/52] When moving whole desktops, swap the names as well. --- source/SylphyHorn/Services/Helpers.cs | 57 +++++++++++++++++++ .../Services/NotificationService.cs | 19 +------ .../Services/VirtualDesktopMoveService.cs | 10 ++++ 3 files changed, 70 insertions(+), 16 deletions(-) diff --git a/source/SylphyHorn/Services/Helpers.cs b/source/SylphyHorn/Services/Helpers.cs index 788aec7..e478a18 100644 --- a/source/SylphyHorn/Services/Helpers.cs +++ b/source/SylphyHorn/Services/Helpers.cs @@ -8,6 +8,8 @@ using Livet; using MetroRadiance.Interop.Win32; using SylphyHorn.Interop; +using SylphyHorn.Serialization; +using WindowsDesktop; namespace SylphyHorn.Services { @@ -47,4 +49,59 @@ public static void InvokeOnUIDispatcher(Action action, DispatcherPriority priori DispatcherHelper.UIDispatcher.BeginInvoke(action, priority); } } + + internal static class DesktopHelper + { + public static int GetIndex(VirtualDesktop desktop) + { + int i = 1; + foreach (var iDesktop in VirtualDesktop.GetDesktops()) + { + if (desktop.Id == iDesktop.Id) + { + return i; + } + ++i; + } + return 0; + } + } + + internal static class SettingsHelper + { + public static string GetDesktopName(int index) + { + switch(index) + { + case 1: return Settings.General.DesktopName1.Value; + case 2: return Settings.General.DesktopName2.Value; + case 3: return Settings.General.DesktopName3.Value; + case 4: return Settings.General.DesktopName4.Value; + case 5: return Settings.General.DesktopName5.Value; + case 6: return Settings.General.DesktopName6.Value; + case 7: return Settings.General.DesktopName7.Value; + case 8: return Settings.General.DesktopName8.Value; + case 9: return Settings.General.DesktopName9.Value; + case 10: return Settings.General.DesktopName10.Value; + } + return null; + } + + public static void SetDesktopName(int index, string name) + { + switch (index) + { + case 1: Settings.General.DesktopName1.Value = name; break; + case 2: Settings.General.DesktopName2.Value = name; break; + case 3: Settings.General.DesktopName3.Value = name; break; + case 4: Settings.General.DesktopName4.Value = name; break; + case 5: Settings.General.DesktopName5.Value = name; break; + case 6: Settings.General.DesktopName6.Value = name; break; + case 7: Settings.General.DesktopName7.Value = name; break; + case 8: Settings.General.DesktopName8.Value = name; break; + case 9: Settings.General.DesktopName9.Value = name; break; + case 10: Settings.General.DesktopName10.Value = name; break; + } + } + } } diff --git a/source/SylphyHorn/Services/NotificationService.cs b/source/SylphyHorn/Services/NotificationService.cs index 59ff133..ca4ae38 100644 --- a/source/SylphyHorn/Services/NotificationService.cs +++ b/source/SylphyHorn/Services/NotificationService.cs @@ -47,23 +47,10 @@ private void VirtualDesktopServiceOnWindowPinned(object sender, WindowPinnedEven private static string GetDesktopName(int index) { - string setting = null; - switch(index) + string name = SettingsHelper.GetDesktopName(index); + if(name != null && name != "") { - case 1: setting = Settings.General.DesktopName1.Value; break; - case 2: setting = Settings.General.DesktopName2.Value; break; - case 3: setting = Settings.General.DesktopName3.Value; break; - case 4: setting = Settings.General.DesktopName4.Value; break; - case 5: setting = Settings.General.DesktopName5.Value; break; - case 6: setting = Settings.General.DesktopName6.Value; break; - case 7: setting = Settings.General.DesktopName7.Value; break; - case 8: setting = Settings.General.DesktopName8.Value; break; - case 9: setting = Settings.General.DesktopName9.Value; break; - case 10: setting = Settings.General.DesktopName10.Value; break; - } - if(setting != null && setting != "") - { - return $"{index}: {setting}"; + return $"{index}: {name}"; } return $"Desktop {index}"; } diff --git a/source/SylphyHorn/Services/VirtualDesktopMoveService.cs b/source/SylphyHorn/Services/VirtualDesktopMoveService.cs index 14d41c5..4780001 100644 --- a/source/SylphyHorn/Services/VirtualDesktopMoveService.cs +++ b/source/SylphyHorn/Services/VirtualDesktopMoveService.cs @@ -4,6 +4,8 @@ using System.Runtime.InteropServices; using WindowsDesktop; using SylphyHorn.Interop; +using SylphyHorn.Serialization; +using System.Runtime.CompilerServices; namespace SylphyHorn.Services { @@ -44,6 +46,14 @@ private static void SwapDesktops(VirtualDesktop source, VirtualDesktop target) VirtualDesktopHelper.MoveToDesktop(window, target); foreach (var window in dstWindows) VirtualDesktopHelper.MoveToDesktop(window, source); + + // Swap the names as well + int sourceIndex = DesktopHelper.GetIndex(source); + int targetIndex = DesktopHelper.GetIndex(target); + var sourceName = SettingsHelper.GetDesktopName(sourceIndex); + var targetName = SettingsHelper.GetDesktopName(targetIndex); + SettingsHelper.SetDesktopName(sourceIndex, targetName); + SettingsHelper.SetDesktopName(targetIndex, sourceName); } private static IEnumerable GetAllWindows() From 3d3fd17a84327d28d8ee4466c26b22c303390acb Mon Sep 17 00:00:00 2001 From: kuukunen Date: Tue, 5 May 2020 22:00:22 +0900 Subject: [PATCH 16/52] Add "Rename Current" functionality. (Ctrl+Win+R by default.) --- .../Serialization/ShortcutKeySettings.cs | 9 ++ source/SylphyHorn/Application.xaml.cs | 1 + source/SylphyHorn/ApplicationPreparation.cs | 4 + .../Properties/Resources.Designer.cs | 18 ++++ source/SylphyHorn/Properties/Resources.resx | 6 ++ source/SylphyHorn/Services/RenameService.cs | 63 +++++++++++++ .../Services/VirtualDesktopService.cs | 16 +++- source/SylphyHorn/SylphyHorn.csproj | 11 +++ .../UI/Bindings/RenameWindowViewModel.cs | 41 +++++++++ .../UI/InteractableNotificationWindow.cs | 52 +++++++++++ source/SylphyHorn/UI/RenameWindow.xaml | 88 ++++++++++++++++++ source/SylphyHorn/UI/RenameWindow.xaml.cs | 89 +++++++++++++++++++ source/SylphyHorn/UI/SettingsWindow.xaml | 19 ++++ source/SylphyHorn/UI/SwitchWindow.xaml | 1 + 14 files changed, 417 insertions(+), 1 deletion(-) create mode 100644 source/SylphyHorn/Services/RenameService.cs create mode 100644 source/SylphyHorn/UI/Bindings/RenameWindowViewModel.cs create mode 100644 source/SylphyHorn/UI/InteractableNotificationWindow.cs create mode 100644 source/SylphyHorn/UI/RenameWindow.xaml create mode 100644 source/SylphyHorn/UI/RenameWindow.xaml.cs diff --git a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs index 0f59bf0..1fcb3a6 100644 --- a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs +++ b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs @@ -51,6 +51,8 @@ public ShortcutKeySettings(ISerializationProvider provider) public ShortcutkeyProperty TogglePinApp => this.Cache(key => new ShortcutkeyProperty(key, this._provider)); + public ShortcutkeyProperty RenameCurrent => this.Cache(key => new ShortcutkeyProperty(key, this._provider, RenameCurrentDefaultValue)); + public ShortcutkeyProperty SwitchTo1 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchTo1DefaultValue)); public ShortcutkeyProperty SwitchTo2 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchTo2DefaultValue)); @@ -173,6 +175,13 @@ public ShortcutKeySettings(ISerializationProvider provider) 091, // Left Windows }; + private static int[] RenameCurrentDefaultValue { get; } = + { + 082, // R + 162, // Left Ctrl + 091, // Left Windows + }; + private static int[] SwitchTo1DefaultValue { get; } = { 049, // 1 diff --git a/source/SylphyHorn/Application.xaml.cs b/source/SylphyHorn/Application.xaml.cs index 4e3f56a..9fb30a0 100644 --- a/source/SylphyHorn/Application.xaml.cs +++ b/source/SylphyHorn/Application.xaml.cs @@ -77,6 +77,7 @@ protected override void OnStartup(StartupEventArgs e) preparation.RegisterActions(); NotificationService.Instance.AddTo(this); + RenameService.Instance.AddTo(this); WallpaperService.Instance.AddTo(this); #if !DEBUG diff --git a/source/SylphyHorn/ApplicationPreparation.cs b/source/SylphyHorn/ApplicationPreparation.cs index 4ed102c..556b891 100644 --- a/source/SylphyHorn/ApplicationPreparation.cs +++ b/source/SylphyHorn/ApplicationPreparation.cs @@ -116,6 +116,10 @@ public void RegisterActions() .Register(() => settings.TogglePinApp.ToShortcutKey(), hWnd => hWnd.TogglePinApp()) .AddTo(this._disposable); + this._hookService + .Register(() => settings.RenameCurrent.ToShortcutKey(), _ => VirtualDesktopService.RaiseRenameEvent()) + .AddTo(this._disposable); + this._hookService .Register(() => settings.SwitchTo1.ToShortcutKey(), _ => VirtualDesktopService.Get(1)?.Switch()) .AddTo(this._disposable); diff --git a/source/SylphyHorn/Properties/Resources.Designer.cs b/source/SylphyHorn/Properties/Resources.Designer.cs index ce45b79..0ea8446 100644 --- a/source/SylphyHorn/Properties/Resources.Designer.cs +++ b/source/SylphyHorn/Properties/Resources.Designer.cs @@ -600,6 +600,24 @@ public static string Settings_Placement { } } + /// + /// Looks up a localized string similar to Rename. + /// + public static string Settings_Rename { + get { + return ResourceManager.GetString("Settings_Rename", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Rename current desktop. + /// + public static string Settings_RenameCurrentDesktop { + get { + return ResourceManager.GetString("Settings_RenameCurrentDesktop", resourceCulture); + } + } + /// /// Looks up a localized string similar to Shortcuts. /// diff --git a/source/SylphyHorn/Properties/Resources.resx b/source/SylphyHorn/Properties/Resources.resx index e98515c..dd86b4b 100644 --- a/source/SylphyHorn/Properties/Resources.resx +++ b/source/SylphyHorn/Properties/Resources.resx @@ -336,4 +336,10 @@ Set names for desktops + + Rename + + + Rename current desktop + \ No newline at end of file diff --git a/source/SylphyHorn/Services/RenameService.cs b/source/SylphyHorn/Services/RenameService.cs new file mode 100644 index 0000000..c20bdb3 --- /dev/null +++ b/source/SylphyHorn/Services/RenameService.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using MetroTrilithon.Lifetime; +using SylphyHorn.Properties; +using SylphyHorn.Serialization; +using SylphyHorn.UI; +using SylphyHorn.UI.Bindings; +using WindowsDesktop; + +namespace SylphyHorn.Services +{ + public class RenameService : IDisposable + { + public static RenameService Instance { get; } = new RenameService(); + + private readonly SerialDisposable _renameWindow = new SerialDisposable(); + + private RenameService() + { + VirtualDesktopService.RenameCurrent += this.VirtualDesktopServiceOnRenameCurrent; + } + + private static IDisposable ShowRenameWindow() + { + var current = VirtualDesktop.Current; + int index = DesktopHelper.GetIndex(current); + + var source = new CancellationTokenSource(); + + var vmodel = new RenameWindowViewModel + { + Index = index, + }; + var window = new RenameWindow(MonitorService.GetCurrentArea().WorkArea) + { + DataContext = vmodel, + }; + window.Show(); + + Task.Delay(TimeSpan.FromMilliseconds(30000), source.Token) + .ContinueWith(_ => window.Close(), TaskScheduler.FromCurrentSynchronizationContext()); + + return Disposable.Create(() => source.Cancel()); + } + + private void VirtualDesktopServiceOnRenameCurrent(object sender, RenameEventArgs e) + { + VisualHelper.InvokeOnUIDispatcher(() => + { + this._renameWindow.Disposable = ShowRenameWindow(); + }); + } + + public void Dispose() + { + VirtualDesktopService.RenameCurrent -= this.VirtualDesktopServiceOnRenameCurrent; + this._renameWindow.Dispose(); + } + } +} diff --git a/source/SylphyHorn/Services/VirtualDesktopService.cs b/source/SylphyHorn/Services/VirtualDesktopService.cs index 24968fa..67f59b1 100644 --- a/source/SylphyHorn/Services/VirtualDesktopService.cs +++ b/source/SylphyHorn/Services/VirtualDesktopService.cs @@ -2,6 +2,8 @@ using System.Linq; using System.Media; using SylphyHorn.Serialization; +using SylphyHorn.UI; +using SylphyHorn.UI.Bindings; using WindowsDesktop; namespace SylphyHorn.Services @@ -220,9 +222,14 @@ private static void RaisePinnedEvent(IntPtr target, PinOperations operation) #endregion - #region Pin / Unpin + #region Rename + public static event EventHandler RenameCurrent; + public static void RaiseRenameEvent() + { + RenameCurrent?.Invoke(typeof(VirtualDesktopService), new RenameEventArgs()); + } #endregion } @@ -239,6 +246,13 @@ public WindowPinnedEventArgs(IntPtr target, PinOperations operation) } } + internal class RenameEventArgs : EventArgs + { + public RenameEventArgs() + { + } + } + [Flags] internal enum PinOperations { diff --git a/source/SylphyHorn/SylphyHorn.csproj b/source/SylphyHorn/SylphyHorn.csproj index 7550556..9a1e42b 100644 --- a/source/SylphyHorn/SylphyHorn.csproj +++ b/source/SylphyHorn/SylphyHorn.csproj @@ -242,9 +242,11 @@ True Resources.resx + + @@ -257,6 +259,10 @@ PinWindow.xaml + + + RenameWindow.xaml + @@ -313,6 +319,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -408,6 +418,7 @@ PublicResXFileCodeGenerator Resources.Designer.cs + Designer Resources.resx diff --git a/source/SylphyHorn/UI/Bindings/RenameWindowViewModel.cs b/source/SylphyHorn/UI/Bindings/RenameWindowViewModel.cs new file mode 100644 index 0000000..0809adc --- /dev/null +++ b/source/SylphyHorn/UI/Bindings/RenameWindowViewModel.cs @@ -0,0 +1,41 @@ +using MetroTrilithon.Mvvm; +using SylphyHorn.Services; + +namespace SylphyHorn.UI.Bindings +{ + public class RenameWindowViewModel : WindowViewModel + { + #region Index + + private int _Index; + + public int Index + { + get { return this._Index; } + set + { + if (this._Index != value) + { + this._Index = value; + this.RaisePropertyChanged(); + } + } + } + + #endregion + + #region Name + + public string Name + { + get => SettingsHelper.GetDesktopName(this._Index); + set + { + SettingsHelper.SetDesktopName(this._Index, value); + this.Close(); + } + } + + #endregion + } +} diff --git a/source/SylphyHorn/UI/InteractableNotificationWindow.cs b/source/SylphyHorn/UI/InteractableNotificationWindow.cs new file mode 100644 index 0000000..d9a9fa4 --- /dev/null +++ b/source/SylphyHorn/UI/InteractableNotificationWindow.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows; +using System.Windows.Interop; +using MetroRadiance.Interop.Win32; +using MetroRadiance.UI.Controls; +using SylphyHorn.Interop; + +namespace SylphyHorn.UI +{ + public class InteractableNotificationWindow : BlurWindow + { + #region NativeOpacity dependency property + + public static readonly DependencyProperty NativeOpacityProperty = DependencyProperty.Register( + nameof(NativeOpacity), typeof(double), typeof(InteractableNotificationWindow), new PropertyMetadata(default(double), HandleNativeOpacityChanged)); + + public double NativeOpacity + { + get { return (double)this.GetValue(NativeOpacityProperty); } + set { this.SetValue(NativeOpacityProperty, value); } + } + + private static void HandleNativeOpacityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) + { + ((InteractableNotificationWindow)sender).ChangeOpacity((double)args.NewValue); + } + + #endregion + + protected override void OnSourceInitialized(EventArgs e) + { + base.OnSourceInitialized(e); + + var source = PresentationSource.FromVisual(this) as HwndSource; + if (source == null) throw new InvalidOperationException(); + + // Reset styles to make it interactive + User32.SetWindowLong(source.Handle, 0); + } + + private void ChangeOpacity(double opacity) + { + var source = (HwndSource)PresentationSource.FromVisual(this); + if (source == null) return; + + var bAlpha = (byte)(opacity * 255.0); + NativeMethods.SetLayeredWindowAttributes(source.Handle, 0, bAlpha, LayeredWindowAttributes.Alpha); + } + } +} diff --git a/source/SylphyHorn/UI/RenameWindow.xaml b/source/SylphyHorn/UI/RenameWindow.xaml new file mode 100644 index 0000000..fd7cf43 --- /dev/null +++ b/source/SylphyHorn/UI/RenameWindow.xaml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/SylphyHorn/UI/RenameWindow.xaml.cs b/source/SylphyHorn/UI/RenameWindow.xaml.cs new file mode 100644 index 0000000..291889e --- /dev/null +++ b/source/SylphyHorn/UI/RenameWindow.xaml.cs @@ -0,0 +1,89 @@ +using System; +using System.Windows; +using System.Windows.Input; +using System.Windows.Interop; +using MetroRadiance.Interop; +using SylphyHorn.Serialization; +using SylphyHorn.UI.Bindings; + +namespace SylphyHorn.UI +{ + partial class RenameWindow + { + private readonly Rect _area; + + public RenameWindow(Rect area) + { + this._area = area; + this.InitializeComponent(); + + this.PreviewKeyDown += new KeyEventHandler(HandleEsc); + } + + protected override void OnSourceInitialized(EventArgs e) + { + base.OnSourceInitialized(e); + + var source = PresentationSource.FromVisual(this) as HwndSource; + if (source == null) throw new InvalidOperationException(); + + var dpi = source.GetDpi(); + var width = this.ActualWidth * dpi.ScaleX; + var height = this.ActualHeight * dpi.ScaleY; + var area = this._area; + + switch ((WindowPlacement)Settings.General.Placement.Value) + { + case WindowPlacement.TopLeft: + case WindowPlacement.BottomLeft: + this.Left = area.Left / dpi.ScaleX; + break; + + case WindowPlacement.TopRight: + case WindowPlacement.BottomRight: + this.Left = (area.Right - width) / dpi.ScaleX; + break; + + case WindowPlacement.Center: + default: + this.Left = (area.Left + (area.Width - width) / 2) / dpi.ScaleX; + break; + } + + switch ((WindowPlacement)Settings.General.Placement.Value) + { + case WindowPlacement.TopLeft: + case WindowPlacement.TopCenter: + case WindowPlacement.TopRight: + this.Top = area.Top / dpi.ScaleY; + break; + + case WindowPlacement.BottomLeft: + case WindowPlacement.BottomCenter: + case WindowPlacement.BottomRight: + this.Top = (area.Bottom - height) / dpi.ScaleY; + break; + + case WindowPlacement.Center: + default: + this.Top = (area.Top + (area.Height - height) / 2) / dpi.ScaleY; + break; + } + + NameBox.Focus(); + NameBox.SelectAll(); + } + + private void HandleEsc(object sender, KeyEventArgs e) + { + if (e.Key == Key.Escape) + Close(); + } + + private void NameBox_KeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Enter) + Close(); + } + } +} diff --git a/source/SylphyHorn/UI/SettingsWindow.xaml b/source/SylphyHorn/UI/SettingsWindow.xaml index be78513..ebb579b 100644 --- a/source/SylphyHorn/UI/SettingsWindow.xaml +++ b/source/SylphyHorn/UI/SettingsWindow.xaml @@ -739,6 +739,25 @@ + + + + + + + + + + + + + + + + diff --git a/source/SylphyHorn/UI/SwitchWindow.xaml b/source/SylphyHorn/UI/SwitchWindow.xaml index e50de09..9251efa 100644 --- a/source/SylphyHorn/UI/SwitchWindow.xaml +++ b/source/SylphyHorn/UI/SwitchWindow.xaml @@ -16,6 +16,7 @@ Width="211.476" Height="100" ResizeMode="NoResize" + SizeToContent="Width" Topmost="True" ShowInTaskbar="False" SnapsToDevicePixels="True"> From 1ed5c7f04cbc79cd5b6973ad5440c49e1a213345 Mon Sep 17 00:00:00 2001 From: kuukunen Date: Tue, 5 May 2020 22:13:54 +0900 Subject: [PATCH 17/52] Add Japanese translations to missing items. Bump version. --- source/SylphyHorn/Properties/AssemblyInfo.cs | 2 +- .../SylphyHorn/Properties/Resources.ja.resx | 45 +++++++++++++++++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/source/SylphyHorn/Properties/AssemblyInfo.cs b/source/SylphyHorn/Properties/AssemblyInfo.cs index dbc5cac..f966605 100644 --- a/source/SylphyHorn/Properties/AssemblyInfo.cs +++ b/source/SylphyHorn/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -[assembly: AssemblyVersion("5.1.0.0")] +[assembly: AssemblyVersion("5.2.0.0")] [assembly: ComVisible(false)] diff --git a/source/SylphyHorn/Properties/Resources.ja.resx b/source/SylphyHorn/Properties/Resources.ja.resx index 2df6bfd..18eef18 100644 --- a/source/SylphyHorn/Properties/Resources.ja.resx +++ b/source/SylphyHorn/Properties/Resources.ja.resx @@ -190,7 +190,7 @@ 左へ移動して切り替え: - 右へ移動 + 右へ移動: 右へ移動して切り替え: @@ -202,10 +202,10 @@ 切り替えのみ - 移動 + 移動: - 移動して切り替え + 移動して切り替え: 通知先のディスプレイ @@ -303,4 +303,43 @@ 設定 + + {0}へ移動して切り替え + + + デスクトップを移動 + + + 左へ移動: + + + 右へ移動: + + + {0}へ移動 + + + アクティブ ウィンドウを特定デスクトップへ移動 + + + アクティブ ウィンドウを特定デスクトップへ移動して切り替え + + + 名前 + + + デスクトップの名前を設定 + + + リネーム + + + 作業中のデスクトップをリネーム + + + {0}に切り替え + + + 特定デスクトップに切り替え + \ No newline at end of file From e403b6a4355c1e8a5a75891df566a8907cb6b4d7 Mon Sep 17 00:00:00 2001 From: kuukunen Date: Tue, 5 May 2020 22:23:17 +0900 Subject: [PATCH 18/52] Add note to Readme. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dff8e6a..deed0bf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SylphyHornEx -> This is a fork of [SylphyHorn](https://github.com/Grabacr07/SylphyHorn) which adds desktop reordering functionality +> This is a fork of [SylphyHorn](https://github.com/Grabacr07/SylphyHorn) which adds desktop reordering functionality, ability to rename desktops and switch/move to specific desktops with number keys (Customizable). SylphyHorn is Virtual Desktop Tools for Windows 10. Provides global hotkeys, switching notification, change background and several functions to virtual desktop. From a49f12a7e29f990ffdbc34fce02d56375a19cb60 Mon Sep 17 00:00:00 2001 From: kuukunen Date: Wed, 6 May 2020 14:24:53 +0900 Subject: [PATCH 19/52] Make desktop names list dynamic based on amount of desktops. Also fix bunch of problems that came up. --- .../Serialization/DictionaryProvider.cs | 3 +- .../Serialization/GeneralSettings.cs | 20 +---- .../Serialization/SerializableProperty.cs | 25 ++++++ source/SylphyHorn/Application.xaml | 1 + source/SylphyHorn/Application.xaml.cs | 7 ++ source/SylphyHorn/Services/Helpers.cs | 66 ++++++++------ .../Services/NotificationService.cs | 2 +- .../Services/VirtualDesktopService.cs | 6 ++ source/SylphyHorn/SylphyHorn.csproj | 1 + .../UI/Bindings/RenameWindowViewModel.cs | 6 +- .../SylphyHorn/UI/Controls/IndexConverter.cs | 27 ++++++ source/SylphyHorn/UI/RenameWindow.xaml | 2 +- source/SylphyHorn/UI/RenameWindow.xaml.cs | 15 +++- source/SylphyHorn/UI/SettingsWindow.xaml | 87 +++++++++++-------- 14 files changed, 176 insertions(+), 92 deletions(-) create mode 100644 source/SylphyHorn/UI/Controls/IndexConverter.cs diff --git a/source/SylphyHorn.Core/Serialization/DictionaryProvider.cs b/source/SylphyHorn.Core/Serialization/DictionaryProvider.cs index fc7a29c..2986cb9 100644 --- a/source/SylphyHorn.Core/Serialization/DictionaryProvider.cs +++ b/source/SylphyHorn.Core/Serialization/DictionaryProvider.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading.Tasks; using MetroTrilithon.Serialization; +using System.Collections.ObjectModel; namespace SylphyHorn.Serialization { @@ -15,7 +16,7 @@ public abstract class DictionaryProvider : ISerializationProvider public virtual string Filename { get; } = "Settings.xml"; - public virtual Type[] KnownTypes { get; } = { typeof(bool), typeof(int[]), }; + public virtual Type[] KnownTypes { get; } = { typeof(bool), typeof(int[]), typeof(ObservableCollection) }; public event EventHandler Reloaded; diff --git a/source/SylphyHorn.Core/Serialization/GeneralSettings.cs b/source/SylphyHorn.Core/Serialization/GeneralSettings.cs index c244d2f..27e9bd2 100644 --- a/source/SylphyHorn.Core/Serialization/GeneralSettings.cs +++ b/source/SylphyHorn.Core/Serialization/GeneralSettings.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading.Tasks; using MetroTrilithon.Serialization; +using System.Collections.ObjectModel; namespace SylphyHorn.Serialization { @@ -39,24 +40,7 @@ public GeneralSettings(ISerializationProvider provider) public SerializableProperty TrayShowDesktop => this.Cache(key => new SerializableProperty(key, this._provider, false)); - public SerializableProperty DesktopName1 => this.Cache(key => new SerializableProperty(key, this._provider, null)); + public SerializableProperty> DesktopNames => this.Cache(key => new SerializableProperty>(key, this._provider)); - public SerializableProperty DesktopName2 => this.Cache(key => new SerializableProperty(key, this._provider, null)); - - public SerializableProperty DesktopName3 => this.Cache(key => new SerializableProperty(key, this._provider, null)); - - public SerializableProperty DesktopName4 => this.Cache(key => new SerializableProperty(key, this._provider, null)); - - public SerializableProperty DesktopName5 => this.Cache(key => new SerializableProperty(key, this._provider, null)); - - public SerializableProperty DesktopName6 => this.Cache(key => new SerializableProperty(key, this._provider, null)); - - public SerializableProperty DesktopName7 => this.Cache(key => new SerializableProperty(key, this._provider, null)); - - public SerializableProperty DesktopName8 => this.Cache(key => new SerializableProperty(key, this._provider, null)); - - public SerializableProperty DesktopName9 => this.Cache(key => new SerializableProperty(key, this._provider, null)); - - public SerializableProperty DesktopName10 => this.Cache(key => new SerializableProperty(key, this._provider, null)); } } diff --git a/source/SylphyHorn.Core/Serialization/SerializableProperty.cs b/source/SylphyHorn.Core/Serialization/SerializableProperty.cs index 5195941..3846264 100644 --- a/source/SylphyHorn.Core/Serialization/SerializableProperty.cs +++ b/source/SylphyHorn.Core/Serialization/SerializableProperty.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using MetroTrilithon.Linq; using MetroTrilithon.Serialization; +using System.ComponentModel; +using System.Runtime.CompilerServices; namespace SylphyHorn.Serialization { @@ -14,6 +16,29 @@ public SerializableProperty(string key, ISerializationProvider provider) : base( public SerializableProperty(string key, ISerializationProvider provider, T defaultValue) : base(key, provider, defaultValue) { } } + public class StringHolder : INotifyPropertyChanged + { + private string _value; + + public string Value + { + get => _value; set + { + if (_value == value) return; + _value = value; + NotifyOfPropertyChange(); + } + } + + public static implicit operator string(StringHolder stringHolder) => stringHolder.Value; + + public static implicit operator StringHolder(string s) => new StringHolder { Value = s }; + + public void NotifyOfPropertyChange([CallerMemberName] string propertyName = "") => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + + public event PropertyChangedEventHandler PropertyChanged; + } + public class ShortcutkeyProperty : SerializablePropertyBase { diff --git a/source/SylphyHorn/Application.xaml b/source/SylphyHorn/Application.xaml index b3e7c15..7774dd2 100644 --- a/source/SylphyHorn/Application.xaml +++ b/source/SylphyHorn/Application.xaml @@ -22,6 +22,7 @@ + diff --git a/source/SylphyHorn/Application.xaml.cs b/source/SylphyHorn/Application.xaml.cs index 9fb30a0..aac4a37 100644 --- a/source/SylphyHorn/Application.xaml.cs +++ b/source/SylphyHorn/Application.xaml.cs @@ -11,6 +11,7 @@ using SylphyHorn.Serialization; using SylphyHorn.Services; using SylphyHorn.UI; +using WindowsDesktop; namespace SylphyHorn { @@ -71,6 +72,12 @@ protected override void OnStartup(StartupEventArgs e) } preparation.VirtualDesktopInitialized += () => this.TaskTrayIcon.Reload(); + preparation.VirtualDesktopInitialized += () => + { + SettingsHelper.ResizeSettingsProperties(); + VirtualDesktop.Created += (sender, args) => SettingsHelper.ResizeSettingsProperties(); + VirtualDesktop.Destroyed += (sender, args) => SettingsHelper.ResizeSettingsProperties(); + }; preparation.VirtualDesktopInitializationCanceled += () => { }; // ToDo preparation.VirtualDesktopInitializationFailed += ex => LoggingService.Instance.Register(ex); preparation.PrepareVirtualDesktop(); diff --git a/source/SylphyHorn/Services/Helpers.cs b/source/SylphyHorn/Services/Helpers.cs index e478a18..2be222e 100644 --- a/source/SylphyHorn/Services/Helpers.cs +++ b/source/SylphyHorn/Services/Helpers.cs @@ -10,6 +10,7 @@ using SylphyHorn.Interop; using SylphyHorn.Serialization; using WindowsDesktop; +using System.Collections.ObjectModel; namespace SylphyHorn.Services { @@ -69,39 +70,52 @@ public static int GetIndex(VirtualDesktop desktop) internal static class SettingsHelper { - public static string GetDesktopName(int index) + public static void ResizeSettingsProperties() { - switch(index) + var desktopCount = VirtualDesktopService.Count(); + var desktopNames = Settings.General.DesktopNames.Value; + if (desktopNames == null) { - case 1: return Settings.General.DesktopName1.Value; - case 2: return Settings.General.DesktopName2.Value; - case 3: return Settings.General.DesktopName3.Value; - case 4: return Settings.General.DesktopName4.Value; - case 5: return Settings.General.DesktopName5.Value; - case 6: return Settings.General.DesktopName6.Value; - case 7: return Settings.General.DesktopName7.Value; - case 8: return Settings.General.DesktopName8.Value; - case 9: return Settings.General.DesktopName9.Value; - case 10: return Settings.General.DesktopName10.Value; + var temp = new StringHolder[desktopCount]; + for(int i = 0; i < desktopCount; ++i) + { + temp[i] = new StringHolder(); + } + desktopNames = new ObservableCollection(temp); + Settings.General.DesktopNames.Value = desktopNames; + } + else if (desktopNames.Count != desktopCount) + { + var temp = new StringHolder[desktopNames.Count]; + desktopNames.CopyTo(temp, 0); + Array.Resize(ref temp, desktopCount); + for (int i = desktopNames.Count; i < temp.Length; i++) + { + temp[i] = new StringHolder(); + } + Settings.General.DesktopNames.Value = new ObservableCollection(temp); } - return null; + } + + public static string GetDesktopName(int index) + { + var desktopNames = Settings.General.DesktopNames.Value; + if (desktopNames == null || index < 1 || index > desktopNames.Count) + return ""; + return desktopNames[index - 1]; } public static void SetDesktopName(int index, string name) { - switch (index) - { - case 1: Settings.General.DesktopName1.Value = name; break; - case 2: Settings.General.DesktopName2.Value = name; break; - case 3: Settings.General.DesktopName3.Value = name; break; - case 4: Settings.General.DesktopName4.Value = name; break; - case 5: Settings.General.DesktopName5.Value = name; break; - case 6: Settings.General.DesktopName6.Value = name; break; - case 7: Settings.General.DesktopName7.Value = name; break; - case 8: Settings.General.DesktopName8.Value = name; break; - case 9: Settings.General.DesktopName9.Value = name; break; - case 10: Settings.General.DesktopName10.Value = name; break; - } + ResizeSettingsProperties(); + var desktopNames = Settings.General.DesktopNames.Value; + if (desktopNames == null) + return; + + if (index < 1 || index > desktopNames.Count) + return; + desktopNames[index - 1] = name; + Settings.General.DesktopNames.Value = desktopNames; } } } diff --git a/source/SylphyHorn/Services/NotificationService.cs b/source/SylphyHorn/Services/NotificationService.cs index ca4ae38..872c7f6 100644 --- a/source/SylphyHorn/Services/NotificationService.cs +++ b/source/SylphyHorn/Services/NotificationService.cs @@ -50,7 +50,7 @@ private static string GetDesktopName(int index) string name = SettingsHelper.GetDesktopName(index); if(name != null && name != "") { - return $"{index}: {name}"; + return $"{index}. {name}"; } return $"Desktop {index}"; } diff --git a/source/SylphyHorn/Services/VirtualDesktopService.cs b/source/SylphyHorn/Services/VirtualDesktopService.cs index 67f59b1..97db63c 100644 --- a/source/SylphyHorn/Services/VirtualDesktopService.cs +++ b/source/SylphyHorn/Services/VirtualDesktopService.cs @@ -10,6 +10,12 @@ namespace SylphyHorn.Services { internal static class VirtualDesktopService { + #region Count + public static int Count() + { + return VirtualDesktop.GetDesktops().Length; + } + #endregion #region Get public static VirtualDesktop Get(int index) { diff --git a/source/SylphyHorn/SylphyHorn.csproj b/source/SylphyHorn/SylphyHorn.csproj index 9a1e42b..5f8331e 100644 --- a/source/SylphyHorn/SylphyHorn.csproj +++ b/source/SylphyHorn/SylphyHorn.csproj @@ -252,6 +252,7 @@ + diff --git a/source/SylphyHorn/UI/Bindings/RenameWindowViewModel.cs b/source/SylphyHorn/UI/Bindings/RenameWindowViewModel.cs index 0809adc..d05c20d 100644 --- a/source/SylphyHorn/UI/Bindings/RenameWindowViewModel.cs +++ b/source/SylphyHorn/UI/Bindings/RenameWindowViewModel.cs @@ -29,11 +29,7 @@ public int Index public string Name { get => SettingsHelper.GetDesktopName(this._Index); - set - { - SettingsHelper.SetDesktopName(this._Index, value); - this.Close(); - } + set => SettingsHelper.SetDesktopName(this._Index, value); } #endregion diff --git a/source/SylphyHorn/UI/Controls/IndexConverter.cs b/source/SylphyHorn/UI/Controls/IndexConverter.cs new file mode 100644 index 0000000..67031c4 --- /dev/null +++ b/source/SylphyHorn/UI/Controls/IndexConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Windows; +using System.Windows.Data; +using SylphyHorn.Services; + +namespace SylphyHorn.UI.Controls +{ + public class IndexConverter : IValueConverter + { + public object Convert(object value, Type targetType, + object parameter, CultureInfo culture) + { + return (int)value + 1; + } + + public object ConvertBack(object value, Type targetType, + object parameter, CultureInfo culture) + { + return null; + } + } +} diff --git a/source/SylphyHorn/UI/RenameWindow.xaml b/source/SylphyHorn/UI/RenameWindow.xaml index fd7cf43..27538d6 100644 --- a/source/SylphyHorn/UI/RenameWindow.xaml +++ b/source/SylphyHorn/UI/RenameWindow.xaml @@ -12,7 +12,7 @@ xmlns:controls="clr-namespace:SylphyHorn.UI.Controls" mc:Ignorable="d" d:DataContext="{d:DesignInstance bindings:RenameWindowViewModel}" - Title="{Binding Title}" + Title="" Width="140" SizeToContent="Width" Height="100" diff --git a/source/SylphyHorn/UI/RenameWindow.xaml.cs b/source/SylphyHorn/UI/RenameWindow.xaml.cs index 291889e..c0adf95 100644 --- a/source/SylphyHorn/UI/RenameWindow.xaml.cs +++ b/source/SylphyHorn/UI/RenameWindow.xaml.cs @@ -5,6 +5,7 @@ using MetroRadiance.Interop; using SylphyHorn.Serialization; using SylphyHorn.UI.Bindings; +using MetroTrilithon.Threading.Tasks; namespace SylphyHorn.UI { @@ -17,7 +18,8 @@ public RenameWindow(Rect area) this._area = area; this.InitializeComponent(); - this.PreviewKeyDown += new KeyEventHandler(HandleEsc); + this.PreviewKeyDown += new KeyEventHandler(PreviewKeyDownHandler); + this.Closed += new EventHandler(ClosedHandler); } protected override void OnSourceInitialized(EventArgs e) @@ -74,16 +76,23 @@ protected override void OnSourceInitialized(EventArgs e) NameBox.SelectAll(); } - private void HandleEsc(object sender, KeyEventArgs e) + private void PreviewKeyDownHandler(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) + { Close(); + } } - private void NameBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) + { Close(); + } + } + private void ClosedHandler(object sender, EventArgs e) + { + LocalSettingsProvider.Instance.SaveAsync().Forget(); } } } diff --git a/source/SylphyHorn/UI/SettingsWindow.xaml b/source/SylphyHorn/UI/SettingsWindow.xaml index ebb579b..4e69603 100644 --- a/source/SylphyHorn/UI/SettingsWindow.xaml +++ b/source/SylphyHorn/UI/SettingsWindow.xaml @@ -221,49 +221,55 @@ Style="{DynamicResource TabitemStyleKey}" /> - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -613,6 +619,8 @@ + + @@ -757,6 +765,7 @@ + + + @@ -830,6 +841,8 @@ + + From 09a62236a89ed71397cb5cd96f671d2abadee36c Mon Sep 17 00:00:00 2001 From: kuukunen Date: Wed, 6 May 2020 16:23:07 +0900 Subject: [PATCH 20/52] Handle interaction with default switching keys better and add the keys to shortcut menu. Reorganize settings panels. Make default shortcuts more consistent. --- .../Serialization/GeneralSettings.cs | 8 +- .../Serialization/ShortcutKeySettings.cs | 63 ++++++---- source/SylphyHorn/Application.xaml.cs | 17 +++ source/SylphyHorn/ApplicationPreparation.cs | 64 ++++++++-- .../Properties/Resources.Designer.cs | 87 +++++++++----- .../SylphyHorn/Properties/Resources.ja.resx | 21 +++- source/SylphyHorn/Properties/Resources.resx | 21 +++- source/SylphyHorn/Services/HookService.cs | 10 +- .../Services/VirtualDesktopService.cs | 2 + source/SylphyHorn/UI/SettingsWindow.xaml | 109 +++++++++++------- 10 files changed, 280 insertions(+), 122 deletions(-) diff --git a/source/SylphyHorn.Core/Serialization/GeneralSettings.cs b/source/SylphyHorn.Core/Serialization/GeneralSettings.cs index 27e9bd2..e9b0723 100644 --- a/source/SylphyHorn.Core/Serialization/GeneralSettings.cs +++ b/source/SylphyHorn.Core/Serialization/GeneralSettings.cs @@ -16,18 +16,18 @@ public GeneralSettings(ISerializationProvider provider) this._provider = provider; } - public SerializableProperty LoopDesktop => this.Cache(key => new SerializableProperty(key, this._provider)); + public SerializableProperty LoopDesktop => this.Cache(key => new SerializableProperty(key, this._provider, true)); + + public SerializableProperty SkipDefaultAnimation => this.Cache(key => new SerializableProperty(key, this._provider, false)); public SerializableProperty NotificationWhenSwitchedDesktop => this.Cache(key => new SerializableProperty(key, this._provider, true)); - public SerializableProperty NotificationDuration => this.Cache(key => new SerializableProperty(key, this._provider, 2500)); + public SerializableProperty NotificationDuration => this.Cache(key => new SerializableProperty(key, this._provider, 1500)); public SerializableProperty ChangeBackgroundEachDesktop => this.Cache(key => new SerializableProperty(key, this._provider)); public SerializableProperty DesktopBackgroundFolderPath => this.Cache(key => new SerializableProperty(key, this._provider)); - public SerializableProperty OverrideWindowsDefaultKeyCombination => this.Cache(key => new SerializableProperty(key, this._provider, false)); - public SerializableProperty SuspendKeyDetection => this.Cache(key => new SerializableProperty(key, this._provider)); public SerializableProperty FirstTime => this.Cache(key => new SerializableProperty(key, this._provider, true)); diff --git a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs index 1fcb3a6..a4325c9 100644 --- a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs +++ b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs @@ -14,16 +14,16 @@ public ShortcutKeySettings(ISerializationProvider provider) { this._provider = provider; } - - public ShortcutkeyProperty MoveDesktopLeft => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveDesktopLeftDefaultValue)); - - public ShortcutkeyProperty MoveDesktopRight => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveDesktopRightDefaultValue)); - public ShortcutkeyProperty MoveLeft => this.Cache(key => new ShortcutkeyProperty(key, this._provider)); + public ShortcutkeyProperty SwitchToLeft => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchToLeftDefaultValue)); + + public ShortcutkeyProperty SwitchToRight => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchToRightDefaultValue)); + + public ShortcutkeyProperty MoveLeft => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveLeftDefaultValue)); public ShortcutkeyProperty MoveLeftAndSwitch => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveLeftAndSwitchDefaultValue)); - public ShortcutkeyProperty MoveRight => this.Cache(key => new ShortcutkeyProperty(key, this._provider)); + public ShortcutkeyProperty MoveRight => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveRightDefaultValue)); public ShortcutkeyProperty MoveRightAndSwitch => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveRightAndSwitchDefaultValue)); @@ -31,10 +31,6 @@ public ShortcutKeySettings(ISerializationProvider provider) public ShortcutkeyProperty MoveNewAndSwitch => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveNewAndSwitchDefaultValue)); - public ShortcutkeyProperty SwitchToLeft => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchToLeftDefaultValue)); - - public ShortcutkeyProperty SwitchToRight => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchToRightDefaultValue)); - public ShortcutkeyProperty CloseAndSwitchLeft => this.Cache(key => new ShortcutkeyProperty(key, this._provider)); public ShortcutkeyProperty CloseAndSwitchRight => this.Cache(key => new ShortcutkeyProperty(key, this._provider)); @@ -53,6 +49,10 @@ public ShortcutKeySettings(ISerializationProvider provider) public ShortcutkeyProperty RenameCurrent => this.Cache(key => new ShortcutkeyProperty(key, this._provider, RenameCurrentDefaultValue)); + public ShortcutkeyProperty SwapDesktopLeft => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwapDesktopLeftDefaultValue)); + + public ShortcutkeyProperty SwapDesktopRight => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwapDesktopRightDefaultValue)); + public ShortcutkeyProperty SwitchTo1 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchTo1DefaultValue)); public ShortcutkeyProperty SwitchTo2 => this.Cache(key => new ShortcutkeyProperty(key, this._provider, SwitchTo2DefaultValue)); @@ -115,19 +115,37 @@ public ShortcutKeySettings(ISerializationProvider provider) #region default values - private static int[] MoveDesktopLeftDefaultValue { get; } = - { - 037, // <= - 091, // Left Windows - 164, // Left Alt - }; + private static int[] MoveLeftDefaultValue { get; } = + { + 037, // <= + 164, // Left Alt + 091, // Left Windows + }; - private static int[] MoveDesktopRightDefaultValue { get; } = - { - 039, // => - 091, // Left Windows - 164, // Left Alt - }; + private static int[] MoveRightDefaultValue { get; } = + { + 039, // => + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] SwapDesktopLeftDefaultValue { get; } = + { + 037, // <= + 160, // Left Shift + 162, // Left Ctrl + 164, // Left Alt + 091, // Left Windows + }; + + private static int[] SwapDesktopRightDefaultValue { get; } = + { + 039, // => + 160, // Left Shift + 162, // Left Ctrl + 164, // Left Alt + 091, // Left Windows + }; private static int[] SwitchToLeftDefaultValue { get; } = { @@ -171,7 +189,6 @@ public ShortcutKeySettings(ISerializationProvider provider) { 080, // P 162, // Left Ctrl - 164, // Left Alt 091, // Left Windows }; diff --git a/source/SylphyHorn/Application.xaml.cs b/source/SylphyHorn/Application.xaml.cs index aac4a37..952e131 100644 --- a/source/SylphyHorn/Application.xaml.cs +++ b/source/SylphyHorn/Application.xaml.cs @@ -77,6 +77,23 @@ protected override void OnStartup(StartupEventArgs e) SettingsHelper.ResizeSettingsProperties(); VirtualDesktop.Created += (sender, args) => SettingsHelper.ResizeSettingsProperties(); VirtualDesktop.Destroyed += (sender, args) => SettingsHelper.ResizeSettingsProperties(); + + VirtualDesktop.Created += (sender, args) => + { + VirtualDesktopService.CachedCount = VirtualDesktopService.Count(); + }; + VirtualDesktop.Destroyed += (sender, args) => + { + VirtualDesktopService.CachedCount = VirtualDesktopService.Count(); + }; + VirtualDesktop.CurrentChanged += (sender, args) => + { + var tDesktops = VirtualDesktop.GetDesktops(); + VirtualDesktopService.CachedIndex = Array.IndexOf(tDesktops, args.NewDesktop) + 1; + }; + VirtualDesktopService.CachedCount = VirtualDesktopService.Count(); + var desktops = VirtualDesktop.GetDesktops(); + VirtualDesktopService.CachedIndex = Array.IndexOf(desktops, VirtualDesktop.Current) + 1; }; preparation.VirtualDesktopInitializationCanceled += () => { }; // ToDo preparation.VirtualDesktopInitializationFailed += ex => LoggingService.Instance.Register(ex); diff --git a/source/SylphyHorn/ApplicationPreparation.cs b/source/SylphyHorn/ApplicationPreparation.cs index 556b891..7a1fa74 100644 --- a/source/SylphyHorn/ApplicationPreparation.cs +++ b/source/SylphyHorn/ApplicationPreparation.cs @@ -11,6 +11,7 @@ using SylphyHorn.Services; using SylphyHorn.UI; using SylphyHorn.UI.Bindings; +using VirtualKey = System.Windows.Forms.Keys; namespace SylphyHorn { @@ -34,16 +35,49 @@ public ApplicationPreparation(HookService hookService, Action shutdownAction, ID this._disposable = disposable; } + public bool IsDefaultLeft(ShortcutKey key) + { + if (key.Key != VirtualKey.Left) + return false; + if (key.ModifiersInternal == null || key.ModifiersInternal.Count != 2) + return false; + if (key.ModifiersInternal.Contains(VirtualKey.RControlKey) || key.ModifiersInternal.Contains(VirtualKey.LControlKey)) + { + if (key.ModifiersInternal.Contains(VirtualKey.LWin) || key.ModifiersInternal.Contains(VirtualKey.RWin)) + { + return true; + } + } + return false; + } + + public bool IsDefaultRight(ShortcutKey key) + { + if (key.Key != VirtualKey.Right) + return false; + if (key.ModifiersInternal == null || key.ModifiersInternal.Count != 2) + return false; + if (key.ModifiersInternal.Contains(VirtualKey.RControlKey) || key.ModifiersInternal.Contains(VirtualKey.LControlKey)) + { + if (key.ModifiersInternal.Contains(VirtualKey.LWin) || key.ModifiersInternal.Contains(VirtualKey.RWin)) + { + return true; + } + } + return false; + + } + public void RegisterActions() { var settings = Settings.ShortcutKey; this._hookService - .Register(()=>settings.MoveDesktopLeft.ToShortcutKey(), hWnd => VirtualDesktopMoveService.MoveLeft()) + .Register(()=>settings.SwapDesktopLeft.ToShortcutKey(), hWnd => VirtualDesktopMoveService.MoveLeft()) .AddTo(this._disposable); this._hookService - .Register(()=>settings.MoveDesktopRight.ToShortcutKey(), hWnd => VirtualDesktopMoveService.MoveRight()) + .Register(()=>settings.SwapDesktopRight.ToShortcutKey(), hWnd => VirtualDesktopMoveService.MoveRight()) .AddTo(this._disposable); this._hookService @@ -72,16 +106,30 @@ public void RegisterActions() this._hookService .Register( - () => settings.SwitchToLeft.ToShortcutKey(), - _ => VirtualDesktopService.GetLeft()?.Switch(), - () => Settings.General.OverrideWindowsDefaultKeyCombination || Settings.General.ChangeBackgroundEachDesktop) + () => settings.SwitchToLeft.ToShortcutKey(), _ => VirtualDesktopService.GetLeft()?.Switch(), + (ShortcutKeyPressedEventArgs args) => { + if (Settings.General.SkipDefaultAnimation || Settings.General.ChangeBackgroundEachDesktop) + return true; + if (Settings.General.LoopDesktop && VirtualDesktopService.CachedIndex == 1) + return true; + if (IsDefaultLeft(args.ShortcutKey)) + return false; + return true; + }) .AddTo(this._disposable); this._hookService .Register( - () => settings.SwitchToRight.ToShortcutKey(), - _ => VirtualDesktopService.GetRight()?.Switch(), - () => Settings.General.OverrideWindowsDefaultKeyCombination || Settings.General.ChangeBackgroundEachDesktop) + () => settings.SwitchToRight.ToShortcutKey(), _ => VirtualDesktopService.GetRight()?.Switch(), + (ShortcutKeyPressedEventArgs args) => { + if (Settings.General.SkipDefaultAnimation || Settings.General.ChangeBackgroundEachDesktop) + return true; + if (Settings.General.LoopDesktop && VirtualDesktopService.CachedIndex == VirtualDesktopService.CachedCount) + return true; + if (IsDefaultRight(args.ShortcutKey)) + return false; + return true; + }) .AddTo(this._disposable); this._hookService diff --git a/source/SylphyHorn/Properties/Resources.Designer.cs b/source/SylphyHorn/Properties/Resources.Designer.cs index 0ea8446..fdf1dff 100644 --- a/source/SylphyHorn/Properties/Resources.Designer.cs +++ b/source/SylphyHorn/Properties/Resources.Designer.cs @@ -187,11 +187,11 @@ public static string Settings_DesktopSwitching_Loop { } /// - /// Looks up a localized string similar to Override OS default key combination (Ctrl+Win+Left and Right). + /// Looks up a localized string similar to Skip default animation of switching (Ctrl+Win+Left and Right). /// - public static string Settings_DesktopSwitching_OverrideOS { + public static string Settings_DesktopSwitching_SkipDefault { get { - return ResourceManager.GetString("Settings_DesktopSwitching_OverrideOS", resourceCulture); + return ResourceManager.GetString("Settings_DesktopSwitching_SkipDefault", resourceCulture); } } @@ -267,33 +267,6 @@ public static string Settings_MoveAndSwitchToTitle { } } - /// - /// Looks up a localized string similar to Move desktop. - /// - public static string Settings_MoveDesktop { - get { - return ResourceManager.GetString("Settings_MoveDesktop", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Left:. - /// - public static string Settings_MoveDesktop_Left { - get { - return ResourceManager.GetString("Settings_MoveDesktop_Left", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Right:. - /// - public static string Settings_MoveDesktop_Right { - get { - return ResourceManager.GetString("Settings_MoveDesktop_Right", resourceCulture); - } - } - /// /// Looks up a localized string similar to Move to {0}. /// @@ -645,6 +618,60 @@ public static string Settings_Startup_Automaticaly { } } + /// + /// Looks up a localized string similar to Swap desktop. + /// + public static string Settings_SwapDesktop { + get { + return ResourceManager.GetString("Settings_SwapDesktop", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Left:. + /// + public static string Settings_SwapDesktop_Left { + get { + return ResourceManager.GetString("Settings_SwapDesktop_Left", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Right:. + /// + public static string Settings_SwapDesktop_Right { + get { + return ResourceManager.GetString("Settings_SwapDesktop_Right", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Switch Desktop. + /// + public static string Settings_SwitchDesktop { + get { + return ResourceManager.GetString("Settings_SwitchDesktop", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Left:. + /// + public static string Settings_SwitchDesktopLeft { + get { + return ResourceManager.GetString("Settings_SwitchDesktopLeft", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Right:. + /// + public static string Settings_SwitchDesktopRight { + get { + return ResourceManager.GetString("Settings_SwitchDesktopRight", resourceCulture); + } + } + /// /// Looks up a localized string similar to Switch to {0}. /// diff --git a/source/SylphyHorn/Properties/Resources.ja.resx b/source/SylphyHorn/Properties/Resources.ja.resx index 18eef18..fac4f5b 100644 --- a/source/SylphyHorn/Properties/Resources.ja.resx +++ b/source/SylphyHorn/Properties/Resources.ja.resx @@ -159,8 +159,8 @@ 仮想デスクトップをループさせる - - OS 既定のキー コンビネーションを上書きする (Ctrl+Win+Left および Right) + + 既定のアニメーションをスキップ(Ctrl+Win+Left および Right) 一般 @@ -306,13 +306,13 @@ {0}へ移動して切り替え - - デスクトップを移動 + + デスクトップを取り替え - + 左へ移動: - + 右へ移動: @@ -342,4 +342,13 @@ 特定デスクトップに切り替え + + デスクトップ切り替え + + + 左へ: + + + 右へ: + \ No newline at end of file diff --git a/source/SylphyHorn/Properties/Resources.resx b/source/SylphyHorn/Properties/Resources.resx index dd86b4b..f6a7c69 100644 --- a/source/SylphyHorn/Properties/Resources.resx +++ b/source/SylphyHorn/Properties/Resources.resx @@ -159,8 +159,8 @@ Loop virtual desktops - - Override OS default key combination (Ctrl+Win+Left and Right) + + Skip default animation of switching (Ctrl+Win+Left and Right) General @@ -279,13 +279,13 @@ Automaticaly start at logon - - Move desktop + + Swap desktop - + Left: - + Right: @@ -342,4 +342,13 @@ Rename current desktop + + Switch Desktop + + + Left: + + + Right: + \ No newline at end of file diff --git a/source/SylphyHorn/Services/HookService.cs b/source/SylphyHorn/Services/HookService.cs index 68a3f52..1fd7364 100644 --- a/source/SylphyHorn/Services/HookService.cs +++ b/source/SylphyHorn/Services/HookService.cs @@ -35,10 +35,10 @@ public IDisposable Suspend() public IDisposable Register(Func getShortcutKey, Action action) { - return this.Register(getShortcutKey, action, () => true); + return this.Register(getShortcutKey, action, (ShortcutKeyPressedEventArgs args) => true); } - public IDisposable Register(Func getShortcutKey, Action action, Func canExecute) + public IDisposable Register(Func getShortcutKey, Action action, Func canExecute) { var hook = new HookAction(getShortcutKey, action, canExecute); this._hookActions.Add(hook); @@ -51,7 +51,7 @@ private void KeyHookOnPressed(object sender, ShortcutKeyPressedEventArgs args) if (args.ShortcutKey == ShortcutKey.None) return; var target = this._hookActions.FirstOrDefault(x => x.GetShortcutKey() == args.ShortcutKey); - if (target != null && target.CanExecute()) + if (target != null && target.CanExecute(args)) { VisualHelper.InvokeOnUIDispatcher(() => target.Action(InteropHelper.GetForegroundWindowEx())); args.Handled = true; @@ -69,9 +69,9 @@ private class HookAction public Action Action { get; } - public Func CanExecute { get; } + public Func CanExecute { get; } - public HookAction(Func getShortcutKey, Action action, Func canExecute) + public HookAction(Func getShortcutKey, Action action, Func canExecute) { this.GetShortcutKey = getShortcutKey; this.Action = action; diff --git a/source/SylphyHorn/Services/VirtualDesktopService.cs b/source/SylphyHorn/Services/VirtualDesktopService.cs index 97db63c..99759fb 100644 --- a/source/SylphyHorn/Services/VirtualDesktopService.cs +++ b/source/SylphyHorn/Services/VirtualDesktopService.cs @@ -15,6 +15,8 @@ public static int Count() { return VirtualDesktop.GetDesktops().Length; } + public static int CachedIndex = 0; + public static int CachedCount = 0; #endregion #region Get public static VirtualDesktop Get(int index) diff --git a/source/SylphyHorn/UI/SettingsWindow.xaml b/source/SylphyHorn/UI/SettingsWindow.xaml index 4e69603..703f8a7 100644 --- a/source/SylphyHorn/UI/SettingsWindow.xaml +++ b/source/SylphyHorn/UI/SettingsWindow.xaml @@ -149,8 +149,12 @@ - - + + + + + + @@ -599,7 +603,8 @@ - @@ -610,13 +615,63 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + @@ -673,35 +728,6 @@ - - - - - - - - - - - - - - - - - - - - - @@ -748,8 +774,9 @@ - + - + + - + + From 5650c26b4b90674ed493570753c1072f0373e69d Mon Sep 17 00:00:00 2001 From: kuukunen Date: Wed, 6 May 2020 17:08:09 +0900 Subject: [PATCH 21/52] Add "Reset Settings to Defaults" button. --- .../Serialization/DictionaryProvider.cs | 4 +++ .../Properties/Resources.Designer.cs | 27 +++++++++++++++++++ .../SylphyHorn/Properties/Resources.ja.resx | 9 +++++++ source/SylphyHorn/Properties/Resources.resx | 9 +++++++ .../Serialization/LocalSettingsProvider.cs | 9 +++++++ source/SylphyHorn/Serialization/Settings.cs | 4 +-- .../UI/Bindings/SettingsWindowViewModel.cs | 16 +++++++++++ source/SylphyHorn/UI/SettingsWindow.xaml | 13 +++++++++ 8 files changed, 89 insertions(+), 2 deletions(-) diff --git a/source/SylphyHorn.Core/Serialization/DictionaryProvider.cs b/source/SylphyHorn.Core/Serialization/DictionaryProvider.cs index 2986cb9..55393d7 100644 --- a/source/SylphyHorn.Core/Serialization/DictionaryProvider.cs +++ b/source/SylphyHorn.Core/Serialization/DictionaryProvider.cs @@ -51,6 +51,10 @@ public bool RemoveValue(string key) } } + public void Clear() + { + this._settings.Clear(); + } void ISerializationProvider.Save() { diff --git a/source/SylphyHorn/Properties/Resources.Designer.cs b/source/SylphyHorn/Properties/Resources.Designer.cs index fdf1dff..462c631 100644 --- a/source/SylphyHorn/Properties/Resources.Designer.cs +++ b/source/SylphyHorn/Properties/Resources.Designer.cs @@ -78,6 +78,15 @@ public static string Common_Reference { } } + /// + /// Looks up a localized string similar to This will delete all settings. Are you sure?. + /// + public static string Dialog_AreYouSure { + get { + return ResourceManager.GetString("Dialog_AreYouSure", resourceCulture); + } + } + /// /// Looks up a localized string similar to Background. /// @@ -591,6 +600,24 @@ public static string Settings_RenameCurrentDesktop { } } + /// + /// Looks up a localized string similar to Reset. + /// + public static string Settings_ResetButton { + get { + return ResourceManager.GetString("Settings_ResetButton", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Reset Settings to Default. + /// + public static string Settings_ResetTitle { + get { + return ResourceManager.GetString("Settings_ResetTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Shortcuts. /// diff --git a/source/SylphyHorn/Properties/Resources.ja.resx b/source/SylphyHorn/Properties/Resources.ja.resx index fac4f5b..c2beb08 100644 --- a/source/SylphyHorn/Properties/Resources.ja.resx +++ b/source/SylphyHorn/Properties/Resources.ja.resx @@ -351,4 +351,13 @@ 右へ: + + リセット + + + 設定をデフォルトにリセット + + + すべての設定が削除されます。 削除してもよろしいですか? + \ No newline at end of file diff --git a/source/SylphyHorn/Properties/Resources.resx b/source/SylphyHorn/Properties/Resources.resx index f6a7c69..c4f84cd 100644 --- a/source/SylphyHorn/Properties/Resources.resx +++ b/source/SylphyHorn/Properties/Resources.resx @@ -351,4 +351,13 @@ Right: + + Reset Settings to Default + + + Reset + + + This will delete all settings. Are you sure? + \ No newline at end of file diff --git a/source/SylphyHorn/Serialization/LocalSettingsProvider.cs b/source/SylphyHorn/Serialization/LocalSettingsProvider.cs index a1669e0..c954ff2 100644 --- a/source/SylphyHorn/Serialization/LocalSettingsProvider.cs +++ b/source/SylphyHorn/Serialization/LocalSettingsProvider.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.IO; using System.Linq; using System.Runtime.Serialization; @@ -45,6 +46,14 @@ private LocalSettingsProvider() this.Available = true; } + public void Reset() + { + Clear(); + SaveAsync().Wait(); + LoadAsync().Wait(); + Settings.General = new GeneralSettings(Instance); + Settings.ShortcutKey = new ShortcutKeySettings(Instance); + } protected override Task SaveAsyncCore(IDictionary dic) { diff --git a/source/SylphyHorn/Serialization/Settings.cs b/source/SylphyHorn/Serialization/Settings.cs index ab6b9cb..fe7372f 100644 --- a/source/SylphyHorn/Serialization/Settings.cs +++ b/source/SylphyHorn/Serialization/Settings.cs @@ -7,8 +7,8 @@ namespace SylphyHorn.Serialization { public static class Settings { - public static GeneralSettings General { get; } = new GeneralSettings(LocalSettingsProvider.Instance); + public static GeneralSettings General { get; set; } = new GeneralSettings(LocalSettingsProvider.Instance); - public static ShortcutKeySettings ShortcutKey { get; } = new ShortcutKeySettings(LocalSettingsProvider.Instance); + public static ShortcutKeySettings ShortcutKey { get; set; } = new ShortcutKeySettings(LocalSettingsProvider.Instance); } } diff --git a/source/SylphyHorn/UI/Bindings/SettingsWindowViewModel.cs b/source/SylphyHorn/UI/Bindings/SettingsWindowViewModel.cs index fdc00c2..e7a8eeb 100644 --- a/source/SylphyHorn/UI/Bindings/SettingsWindowViewModel.cs +++ b/source/SylphyHorn/UI/Bindings/SettingsWindowViewModel.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Windows; using System.Windows.Media; using JetBrains.Annotations; using Livet; @@ -295,5 +296,20 @@ public void OpenBackgroundPathDialog() Settings.General.DesktopBackgroundFolderPath.Value = message.Response; } } + + [UsedImplicitly] + public void ResetSettings() + { + MessageBoxButton btnMessageBox = MessageBoxButton.YesNo; + MessageBoxImage icnMessageBox = MessageBoxImage.Warning; + + MessageBoxResult rsltMessageBox = MessageBox.Show(Resources.Dialog_AreYouSure, "SylphyHorn", btnMessageBox, icnMessageBox); + + if(rsltMessageBox == MessageBoxResult.Yes) + { + LocalSettingsProvider.Instance.Reset(); + } + Close(); + } } } diff --git a/source/SylphyHorn/UI/SettingsWindow.xaml b/source/SylphyHorn/UI/SettingsWindow.xaml index 703f8a7..bf68ae9 100644 --- a/source/SylphyHorn/UI/SettingsWindow.xaml +++ b/source/SylphyHorn/UI/SettingsWindow.xaml @@ -215,6 +215,19 @@ Visibility="{Binding RestartRequired, Converter={StaticResource BooleanToVisibilityConverter}}" Margin="3,2,0,0" /> + + + + + + From 2edfef3a02924d5247a04787f99050adc64d3081 Mon Sep 17 00:00:00 2001 From: kuukunen Date: Wed, 6 May 2020 18:29:37 +0900 Subject: [PATCH 22/52] Fix colours so they work in light and dark theme and don't flicker based on mouse. --- source/SylphyHorn/UI/SettingsWindow.xaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/SylphyHorn/UI/SettingsWindow.xaml b/source/SylphyHorn/UI/SettingsWindow.xaml index bf68ae9..28bb35b 100644 --- a/source/SylphyHorn/UI/SettingsWindow.xaml +++ b/source/SylphyHorn/UI/SettingsWindow.xaml @@ -95,7 +95,7 @@ @@ -471,37 +471,37 @@ + Value="0,0,-310,-170" /> + Value="-155,0,-155,-170" /> + Value="-310,0,0,-170" /> + Value="-155,-85,-155,-85" /> + Value="0,-155,-310,-15" /> + Value="-155,-155,-155,-15" /> + Value="-310,-155,0,-15" /> @@ -556,11 +556,11 @@ Height="270" /> - @@ -582,18 +582,13 @@ - + FontSize="32" + HorizontalAlignment="Center" /> - From ab0e94385018bea2c4b1e4d758bf2dd7d770d547 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 19 May 2020 20:37:44 +0300 Subject: [PATCH 34/52] Fill default shortcut to properly align with built-in, closes #2 --- .../SylphyHorn.Core/Serialization/ShortcutKeySettings.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs index 8dfcd65..38903f5 100644 --- a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs +++ b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs @@ -33,7 +33,7 @@ public ShortcutKeySettings(ISerializationProvider provider) public ShortcutkeyProperty MoveNewAndSwitch => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveNewAndSwitchDefaultValue)); - public ShortcutkeyProperty CloseAndSwitchLeft => this.Cache(key => new ShortcutkeyProperty(key, this._provider)); + public ShortcutkeyProperty CloseAndSwitchLeft => this.Cache(key => new ShortcutkeyProperty(key, this._provider, CloseAndSwitchLeftDefaultValue)); public ShortcutkeyProperty CloseAndSwitchRight => this.Cache(key => new ShortcutkeyProperty(key, this._provider)); @@ -192,6 +192,13 @@ public ShortcutKeySettings(ISerializationProvider provider) 091, // Left Windows }; + private static int[] CloseAndSwitchLeftDefaultValue { get; } = + { + 115, // F4 + 162, // Left Ctrl + 091, // Left Windows + }; + private static int[] TogglePinDefaultValue { get; } = { 080, // P From f44f2b85cd6d07fc06fea67876c95dc73746e3b2 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 19 May 2020 20:40:31 +0300 Subject: [PATCH 35/52] Language consistency --- .../Properties/Resources.Designer.cs | 20 +++++++++---------- source/SylphyHorn/Properties/Resources.resx | 20 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/source/SylphyHorn/Properties/Resources.Designer.cs b/source/SylphyHorn/Properties/Resources.Designer.cs index 79831c1..3dcbdd9 100644 --- a/source/SylphyHorn/Properties/Resources.Designer.cs +++ b/source/SylphyHorn/Properties/Resources.Designer.cs @@ -259,7 +259,7 @@ public static string Settings_LogViewer_Description { } /// - /// Looks up a localized string similar to Move & Switch to {0}. + /// Looks up a localized string similar to Move to desktop {0} (switch):. /// public static string Settings_MoveAndSwitchTo { get { @@ -277,7 +277,7 @@ public static string Settings_MoveAndSwitchToTitle { } /// - /// Looks up a localized string similar to Move to {0}. + /// Looks up a localized string similar to Move to desktop {0}:. /// public static string Settings_MoveTo { get { @@ -313,7 +313,7 @@ public static string Settings_MoveWindowToAdjacentDesktop_Left { } /// - /// Looks up a localized string similar to Left (Switch):. + /// Looks up a localized string similar to Left (switch):. /// public static string Settings_MoveWindowToAdjacentDesktop_LeftAndSwitch { get { @@ -331,7 +331,7 @@ public static string Settings_MoveWindowToAdjacentDesktop_Right { } /// - /// Looks up a localized string similar to Right (Switch):. + /// Looks up a localized string similar to Right (switch):. /// public static string Settings_MoveWindowToAdjacentDesktop_RightAndSwitch { get { @@ -349,7 +349,7 @@ public static string Settings_MoveWindowToCreatedDesktop { } /// - /// Looks up a localized string similar to Switch only. + /// Looks up a localized string similar to Switch only:. /// public static string Settings_MoveWindowToCreatedDesktop_CreateOnly { get { @@ -367,7 +367,7 @@ public static string Settings_MoveWindowToCreatedDesktop_Move { } /// - /// Looks up a localized string similar to Move (Switch):. + /// Looks up a localized string similar to Move (switch):. /// public static string Settings_MoveWindowToCreatedDesktop_MoveAndSwitch { get { @@ -583,7 +583,7 @@ public static string Settings_Placement { } /// - /// Looks up a localized string similar to Rename. + /// Looks up a localized string similar to Rename:. /// public static string Settings_Rename { get { @@ -592,7 +592,7 @@ public static string Settings_Rename { } /// - /// Looks up a localized string similar to Rename current desktop. + /// Looks up a localized string similar to Rename desktop. /// public static string Settings_RenameCurrentDesktop { get { @@ -673,7 +673,7 @@ public static string Settings_SwapDesktop_Right { } /// - /// Looks up a localized string similar to Switch Desktop. + /// Looks up a localized string similar to Switch desktop. /// public static string Settings_SwitchDesktop { get { @@ -709,7 +709,7 @@ public static string Settings_SwitchDesktopRight { } /// - /// Looks up a localized string similar to Switch to {0}. + /// Looks up a localized string similar to Switch to desktop {0}:. /// public static string Settings_SwitchTo { get { diff --git a/source/SylphyHorn/Properties/Resources.resx b/source/SylphyHorn/Properties/Resources.resx index a3df170..b5e3de0 100644 --- a/source/SylphyHorn/Properties/Resources.resx +++ b/source/SylphyHorn/Properties/Resources.resx @@ -187,25 +187,25 @@ Left: - Left (Switch): + Left (switch): Right: - Right (Switch): + Right (switch): Move active window to created new desktop - Switch only + Switch only: Move: - Move (Switch): + Move (switch): Destination displays @@ -316,19 +316,19 @@ Move active window to a specific desktop and switch to it - Move & Switch to {0} + Move to desktop {0} (switch): Move active window to a specific desktop - Move to {0} + Move to desktop {0}: Switch to a specific desktop - Switch to {0} + Switch to desktop {0}: Names @@ -337,13 +337,13 @@ Set names for desktops - Rename + Rename: - Rename current desktop + Rename desktop - Switch Desktop + Switch desktop Left: From 4606be1e81f1475058cbba999fa4f748b08a0031 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 19 May 2020 20:02:34 +0300 Subject: [PATCH 36/52] UI consistency --- source/SylphyHorn/UI/PinWindow.xaml | 3 ++- source/SylphyHorn/UI/RenameWindow.xaml | 2 +- source/SylphyHorn/UI/SettingsWindow.xaml | 6 +++--- source/SylphyHorn/UI/SwitchWindow.xaml | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/source/SylphyHorn/UI/PinWindow.xaml b/source/SylphyHorn/UI/PinWindow.xaml index 2d93b6e..6dbef9b 100644 --- a/source/SylphyHorn/UI/PinWindow.xaml +++ b/source/SylphyHorn/UI/PinWindow.xaml @@ -13,8 +13,9 @@ mc:Ignorable="d" d:DataContext="{d:DesignInstance bindings:NotificationWindowViewModel}" Title="{Binding Title}" - Width="355.462" + MinWidth="210" Height="100" + SizeToContent="Width" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Topmost="True" diff --git a/source/SylphyHorn/UI/RenameWindow.xaml b/source/SylphyHorn/UI/RenameWindow.xaml index da2c6d5..95b807e 100644 --- a/source/SylphyHorn/UI/RenameWindow.xaml +++ b/source/SylphyHorn/UI/RenameWindow.xaml @@ -14,7 +14,7 @@ mc:Ignorable="d" d:DataContext="{d:DesignInstance bindings:RenameWindowViewModel}" Title="" - MinWidth="130" + MinWidth="210" SizeToContent="Width" Height="100" ResizeMode="NoResize" diff --git a/source/SylphyHorn/UI/SettingsWindow.xaml b/source/SylphyHorn/UI/SettingsWindow.xaml index 46ec447..db1750d 100644 --- a/source/SylphyHorn/UI/SettingsWindow.xaml +++ b/source/SylphyHorn/UI/SettingsWindow.xaml @@ -557,10 +557,10 @@ @@ -585,7 +585,7 @@ Text="Desktop 1" Foreground="{Binding NotificationForeground}" FontFamily="Segoe UI Light, Meiryo UI" - FontSize="32" + FontSize="28" HorizontalAlignment="Center" /> From 9657d2601a866db1a0e0c4dad2b384db4a502c2b Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 19 May 2020 21:59:16 +0300 Subject: [PATCH 37/52] Shortcut consistency --- source/SylphyHorn/UI/SettingsWindow.xaml | 38 +++++++----------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/source/SylphyHorn/UI/SettingsWindow.xaml b/source/SylphyHorn/UI/SettingsWindow.xaml index db1750d..7743a1e 100644 --- a/source/SylphyHorn/UI/SettingsWindow.xaml +++ b/source/SylphyHorn/UI/SettingsWindow.xaml @@ -866,34 +866,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -907,6 +879,16 @@ + + + + + + + + + + From db98c3f778a0a050870c9475b8bb12d821eb117b Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 19 May 2020 22:52:57 +0300 Subject: [PATCH 38/52] More reliable rename textbox focus --- source/SylphyHorn/Services/RenameService.cs | 1 - source/SylphyHorn/UI/RenameWindow.xaml.cs | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/source/SylphyHorn/Services/RenameService.cs b/source/SylphyHorn/Services/RenameService.cs index f09f806..e9a435d 100644 --- a/source/SylphyHorn/Services/RenameService.cs +++ b/source/SylphyHorn/Services/RenameService.cs @@ -39,7 +39,6 @@ private static IDisposable ShowRenameWindow() DataContext = vmodel, }; window.Show(); - window.Activate(); Task.Delay(TimeSpan.FromMilliseconds(30000), source.Token) .ContinueWith(_ => window.Close(), TaskScheduler.FromCurrentSynchronizationContext()); diff --git a/source/SylphyHorn/UI/RenameWindow.xaml.cs b/source/SylphyHorn/UI/RenameWindow.xaml.cs index b6c3e7a..a5fb94b 100644 --- a/source/SylphyHorn/UI/RenameWindow.xaml.cs +++ b/source/SylphyHorn/UI/RenameWindow.xaml.cs @@ -21,6 +21,9 @@ public RenameWindow(Rect area) this.PreviewKeyDown += new KeyEventHandler(PreviewKeyDownHandler); this.Closed += new EventHandler(ClosedHandler); this.Activated += new EventHandler(ActivatedHandler); + + this.Activate(); + this.NameBox.Focus(); } protected override void OnSourceInitialized(EventArgs e) From 10b862f8d5b6451447353a0d134f68839f7a87a7 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 19 May 2020 23:12:48 +0300 Subject: [PATCH 39/52] Update shortcut keys --- source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs index 38903f5..752c153 100644 --- a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs +++ b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs @@ -135,7 +135,7 @@ public ShortcutKeySettings(ISerializationProvider provider) { 037, // <= 160, // Left Shift - 164, // Left Alt + 162, // Left Ctrl 091, // Left Windows }; @@ -143,7 +143,7 @@ public ShortcutKeySettings(ISerializationProvider provider) { 039, // => 160, // Left Shift - 164, // Left Alt + 162, // Left Ctrl 091, // Left Windows }; From 06a0ea88d3312d5c451e4204bebf7073864f7665 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 19 May 2020 23:17:44 +0300 Subject: [PATCH 40/52] Update README --- README.md | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index c7900a9..9a4cbad 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,6 @@ # SylphyHornEx -> This is a fork of [SylphyHorn](https://github.com/Grabacr07/SylphyHorn) which adds extra features: -> * Desktop reordering -> * Rename desktops -> * Switch to specific desktops with hotkeys -> * Reset to default settings -> * Tweaks and fixes +> This is a fork of [SylphyHorn](https://github.com/Grabacr07/SylphyHorn) with new features and better optimization. SylphyHorn is Virtual Desktop Tools for Windows 10. Provides global hotkeys, switching notification, change background and several functions to virtual desktop. @@ -26,17 +21,15 @@ Please download from [Releases](https://github.com/ViRb3/SylphyHornEx/releases). ## Features * Switching notification - * Move active window to adjacent desktop -(default key combination: Alt + Win + <- or ->) - +(default key combination: Alt + Win + or ) * Move active window to create new desktop (default key combination: Ctrl + Alt + Win + D) * Reorder virtual desktops -(default key combination: Shift + Alt + Win + <- or ->) +(default key combination: Shift + Ctrl + Win + or ) * Rename desktops from settings or with hotkey (default key combination: Ctrl + Win + R) @@ -47,15 +40,12 @@ Please download from [Releases](https://github.com/ViRb3/SylphyHornEx/releases). * Move active window to specific desktop (default key combination: Alt + Win + 1 to 0) -* Pin window to all desktops ... It is more convenient than using the task view +* Pin window to all desktops (default key combination: Ctrl + Alt + Win + P) -![](https://user-images.githubusercontent.com/1779073/40626965-e400321e-62f6-11e8-8947-b2ded3ed8c77.gif) * Settings GUI (call from tasktray) -![](https://user-images.githubusercontent.com/1779073/40626983-01d4467c-62f7-11e8-8d2f-b9655fa666a5.png) * Change the background for each desktop -![](https://user-images.githubusercontent.com/1779073/40626992-14589938-62f7-11e8-9568-fd956d499500.png) * More... From e9487fa000742311f9a1fc05ed5ab56325a040fc Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 19 May 2020 23:22:47 +0300 Subject: [PATCH 41/52] Bump version --- source/SylphyHorn/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/SylphyHorn/Properties/AssemblyInfo.cs b/source/SylphyHorn/Properties/AssemblyInfo.cs index 33ecd49..6947f31 100644 --- a/source/SylphyHorn/Properties/AssemblyInfo.cs +++ b/source/SylphyHorn/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -[assembly: AssemblyVersion("5.3.2.0")] +[assembly: AssemblyVersion("5.4.0.0")] [assembly: ComVisible(false)] From 3c851130291c7671d3313725b55834281e311298 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 19 May 2020 23:34:03 +0300 Subject: [PATCH 42/52] Fix rename window focus --- source/SylphyHorn/UI/RenameWindow.xaml.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/SylphyHorn/UI/RenameWindow.xaml.cs b/source/SylphyHorn/UI/RenameWindow.xaml.cs index a5fb94b..d476d65 100644 --- a/source/SylphyHorn/UI/RenameWindow.xaml.cs +++ b/source/SylphyHorn/UI/RenameWindow.xaml.cs @@ -21,9 +21,6 @@ public RenameWindow(Rect area) this.PreviewKeyDown += new KeyEventHandler(PreviewKeyDownHandler); this.Closed += new EventHandler(ClosedHandler); this.Activated += new EventHandler(ActivatedHandler); - - this.Activate(); - this.NameBox.Focus(); } protected override void OnSourceInitialized(EventArgs e) @@ -75,6 +72,7 @@ protected override void OnSourceInitialized(EventArgs e) this.Top = (area.Top + (area.Height - height) / 2) / dpi.ScaleY; break; } + this.Activate(); } private void ActivatedHandler(object sender, EventArgs e) From acbfe67b42d5c61edfa9e870877a2df981234bf7 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 19 May 2020 23:34:23 +0300 Subject: [PATCH 43/52] Bump version --- source/SylphyHorn/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/SylphyHorn/Properties/AssemblyInfo.cs b/source/SylphyHorn/Properties/AssemblyInfo.cs index 6947f31..27d2270 100644 --- a/source/SylphyHorn/Properties/AssemblyInfo.cs +++ b/source/SylphyHorn/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -[assembly: AssemblyVersion("5.4.0.0")] +[assembly: AssemblyVersion("5.4.1.0")] [assembly: ComVisible(false)] From 8adc55a56a8f43e95d5fc8d0f26a1621061fac08 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 19 May 2020 23:40:46 +0300 Subject: [PATCH 44/52] Update README --- README.md | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 9a4cbad..027cd86 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,18 @@ # SylphyHornEx +> This is a fork of [SylphyHorn](https://github.com/Grabacr07/SylphyHorn) with new features and better optimization -> This is a fork of [SylphyHorn](https://github.com/Grabacr07/SylphyHorn) with new features and better optimization. - -SylphyHorn is Virtual Desktop Tools for Windows 10. -Provides global hotkeys, switching notification, change background and several functions to virtual desktop. - -This app is Windows Desktop application running on .NET Framework, however built using the Desktop Bridge and published in Windows Store as UWP application. - - -## Installations +SylphyHorn is a collection of virtual desktop tools for Windows 10. +It provides global hotkeys, switching notification, different background per virtual desktop, and many more features to improve your experience. +## Installation Please download from [Releases](https://github.com/ViRb3/SylphyHornEx/releases). ## Requirements - * Windows 10 build 14393 (Anniversary Update) or later ## Features - * Switching notification * Move active window to adjacent desktop @@ -47,14 +40,10 @@ Please download from [Releases](https://github.com/ViRb3/SylphyHornEx/releases). * Change the background for each desktop -* More... - ## Credits - * Manato KAMEYA [@Grabacr07](https://twitter.com/Grabacr07) (Author, Developer) * Yutaka TSUMORI [@tmyt](https://twitter.com/tmyt) (Developer) ## License - SylphyHorn is licensed under [the MIT License](LICENSE.txt). From 80d6987008ee0441c59938092c2ca5f7b6cbd15a Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 20 May 2020 14:45:42 +0300 Subject: [PATCH 45/52] Revert "Fill default shortcut to properly align with built-in" This reverts commit ab0e94385018bea2c4b1e4d758bf2dd7d770d547. --- .../SylphyHorn.Core/Serialization/ShortcutKeySettings.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs index 752c153..b73c2e1 100644 --- a/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs +++ b/source/SylphyHorn.Core/Serialization/ShortcutKeySettings.cs @@ -33,7 +33,7 @@ public ShortcutKeySettings(ISerializationProvider provider) public ShortcutkeyProperty MoveNewAndSwitch => this.Cache(key => new ShortcutkeyProperty(key, this._provider, MoveNewAndSwitchDefaultValue)); - public ShortcutkeyProperty CloseAndSwitchLeft => this.Cache(key => new ShortcutkeyProperty(key, this._provider, CloseAndSwitchLeftDefaultValue)); + public ShortcutkeyProperty CloseAndSwitchLeft => this.Cache(key => new ShortcutkeyProperty(key, this._provider)); public ShortcutkeyProperty CloseAndSwitchRight => this.Cache(key => new ShortcutkeyProperty(key, this._provider)); @@ -192,13 +192,6 @@ public ShortcutKeySettings(ISerializationProvider provider) 091, // Left Windows }; - private static int[] CloseAndSwitchLeftDefaultValue { get; } = - { - 115, // F4 - 162, // Left Ctrl - 091, // Left Windows - }; - private static int[] TogglePinDefaultValue { get; } = { 080, // P From ef8693a3af5f61cbef4426d6dfcdd5e8816b52c6 Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 20 May 2020 14:55:00 +0300 Subject: [PATCH 46/52] refactor: disable loop desktops by default --- source/SylphyHorn.Core/Serialization/GeneralSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/SylphyHorn.Core/Serialization/GeneralSettings.cs b/source/SylphyHorn.Core/Serialization/GeneralSettings.cs index e9b0723..e33d8bb 100644 --- a/source/SylphyHorn.Core/Serialization/GeneralSettings.cs +++ b/source/SylphyHorn.Core/Serialization/GeneralSettings.cs @@ -16,7 +16,7 @@ public GeneralSettings(ISerializationProvider provider) this._provider = provider; } - public SerializableProperty LoopDesktop => this.Cache(key => new SerializableProperty(key, this._provider, true)); + public SerializableProperty LoopDesktop => this.Cache(key => new SerializableProperty(key, this._provider, false)); public SerializableProperty SkipDefaultAnimation => this.Cache(key => new SerializableProperty(key, this._provider, false)); From c76e49844fc7ce8c01e490bddf4f54176cc932f0 Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 20 May 2020 14:59:35 +0300 Subject: [PATCH 47/52] fix: desktop name when removing desktop --- source/SylphyHorn/Application.xaml.cs | 2 +- source/SylphyHorn/Services/Helpers.cs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/source/SylphyHorn/Application.xaml.cs b/source/SylphyHorn/Application.xaml.cs index 6a03efc..69c594d 100644 --- a/source/SylphyHorn/Application.xaml.cs +++ b/source/SylphyHorn/Application.xaml.cs @@ -76,7 +76,7 @@ protected override void OnStartup(StartupEventArgs e) { SettingsHelper.ResizeSettingsProperties(); VirtualDesktop.Created += (sender, args) => SettingsHelper.ResizeSettingsProperties(); - VirtualDesktop.Destroyed += (sender, args) => SettingsHelper.ResizeSettingsProperties(); + VirtualDesktop.DestroyBegin += (sender, args) => SettingsHelper.RemoveDesktopNameEntry(VirtualDesktopService.CachedNumber); VirtualDesktop.Created += VirtualDesktopService.DesktopCreatedHandler; VirtualDesktop.Destroyed += VirtualDesktopService.DesktopDestroyedHandler; diff --git a/source/SylphyHorn/Services/Helpers.cs b/source/SylphyHorn/Services/Helpers.cs index bcc9c4d..9ed2d60 100644 --- a/source/SylphyHorn/Services/Helpers.cs +++ b/source/SylphyHorn/Services/Helpers.cs @@ -117,5 +117,15 @@ public static void SetDesktopName(int number, string name) desktopNames[number - 1] = name; Settings.General.DesktopNames.Value = desktopNames; } + + public static void RemoveDesktopNameEntry(int number) + { + var desktopNames = Settings.General.DesktopNames.Value; + if (desktopNames == null) + return; + + desktopNames.RemoveAt(number - 1); + Settings.General.DesktopNames.Value = desktopNames; + } } } From a0d0e7aaa80b506e7d43e482b61b86a974e82e46 Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 20 May 2020 15:17:41 +0300 Subject: [PATCH 48/52] chore: rework CI --- .github/workflows/main.yml | 69 ++++++++++++++++++++++---------------- .releaserc.json | 53 +++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 28 deletions(-) create mode 100644 .releaserc.json diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9ebfc00..9e6b686 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,36 +1,49 @@ name: CI -on: [push] +on: + push: + branches: [develop] + pull_request: + branches: [develop] jobs: build: - runs-on: [windows-2019] steps: - - name: Setup MSBuild.exe - uses: warrenbuckley/Setup-MSBuild@v1 - - - name: Setup Nuget.exe - uses: warrenbuckley/Setup-Nuget@v1 - - - uses: actions/checkout@v1 - - name: Build - run: | - cd source - git submodule update --init --recursive - nuget restore SylphyHorn.sln - msbuild SylphyHorn.sln /p:Configuration=Release /m /verbosity:normal /p:WarningLevel=0 - - name: Create ZIP - if: startsWith(github.ref, 'refs/tags/') - run: | - Rename-Item -Path "source/SylphyHorn/bin/Release" -NewName "SylphyHornEx" - Compress-Archive -Path "source/SylphyHorn/bin/SylphyHornEx" -DestinationPath SylphyHornEx.zip - - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - files: SylphyHornEx.zip - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Setup MSBuild.exe + uses: warrenbuckley/Setup-MSBuild@v1 + + - name: Setup Nuget.exe + if: success() + uses: warrenbuckley/Setup-Nuget@v1 + + - name: Checkout + if: success() + uses: actions/checkout@v2 + with: + token: ${{ secrets.API_GITHUB_TOKEN }} + + - name: Build + if: success() + run: | + cd source + git submodule update --init --recursive + nuget restore SylphyHorn.sln + msbuild SylphyHorn.sln /p:Configuration=Release /m /verbosity:normal /p:WarningLevel=0 + + - name: Create ZIP + if: success() + run: | + Rename-Item -Path "source/SylphyHorn/bin/Release" -NewName "SylphyHornEx" + Compress-Archive -Path "source/SylphyHorn/bin/SylphyHornEx" -DestinationPath SylphyHornEx.zip + + - name: Release + if: success() + uses: cycjimmy/semantic-release-action@v2.3.0 + with: + extra_plugins: | + @semantic-release/git@9.0.0 + @google/semantic-release-replace-plugin@1.0.0 + env: + GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }} diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..55b4411 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,53 @@ +{ + "branches": [ + "develop" + ], + "plugins": [ + "@semantic-release/commit-analyzer", + [ + "@google/semantic-release-replace-plugin", + { + "replacements": [ + { + "files": [ + "source/SylphyHorn/Properties/AssemblyInfo.cs" + ], + "from": "\\[assembly: AssemblyVersion\\(\".+\"\\)\\]", + "to": "[assembly: AssemblyVersion(\"${nextRelease.version}\")]", + "results": [ + { + "file": "source/SylphyHorn/Properties/AssemblyInfo.cs", + "hasChanged": true, + "numMatches": 1, + "numReplacements": 1 + } + ], + "countMatches": true + } + ] + } + ], + [ + "@semantic-release/git", + { + "assets": [ + "source/SylphyHorn/Properties/AssemblyInfo.cs" + ], + "message": "chore(release): ${nextRelease.version} [skip ci]" + } + ], + "@semantic-release/release-notes-generator", + [ + "@semantic-release/github", + { + "successComment": false, + "failComment": false, + "assets": [ + { + "path": "SylphyHornEx.zip" + } + ] + } + ] + ] +} \ No newline at end of file From fcdf8c0f40a2703049dca01583f3880f061080d5 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 20 May 2020 21:11:25 +0000 Subject: [PATCH 49/52] chore(release): 5.4.2 [skip ci] --- source/SylphyHorn/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/SylphyHorn/Properties/AssemblyInfo.cs b/source/SylphyHorn/Properties/AssemblyInfo.cs index 27d2270..81d7b5c 100644 --- a/source/SylphyHorn/Properties/AssemblyInfo.cs +++ b/source/SylphyHorn/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -[assembly: AssemblyVersion("5.4.1.0")] +[assembly: AssemblyVersion("5.4.2")] [assembly: ComVisible(false)] From 1f50b7543d9d147dacc7f8e603f6e0c27f121dae Mon Sep 17 00:00:00 2001 From: Victor Date: Thu, 21 May 2020 01:15:01 +0300 Subject: [PATCH 50/52] chore(ci): convert to yml --- .releaserc.json | 53 ------------------------------------------------- .releaserc.yml | 33 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 53 deletions(-) delete mode 100644 .releaserc.json create mode 100644 .releaserc.yml diff --git a/.releaserc.json b/.releaserc.json deleted file mode 100644 index 55b4411..0000000 --- a/.releaserc.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "branches": [ - "develop" - ], - "plugins": [ - "@semantic-release/commit-analyzer", - [ - "@google/semantic-release-replace-plugin", - { - "replacements": [ - { - "files": [ - "source/SylphyHorn/Properties/AssemblyInfo.cs" - ], - "from": "\\[assembly: AssemblyVersion\\(\".+\"\\)\\]", - "to": "[assembly: AssemblyVersion(\"${nextRelease.version}\")]", - "results": [ - { - "file": "source/SylphyHorn/Properties/AssemblyInfo.cs", - "hasChanged": true, - "numMatches": 1, - "numReplacements": 1 - } - ], - "countMatches": true - } - ] - } - ], - [ - "@semantic-release/git", - { - "assets": [ - "source/SylphyHorn/Properties/AssemblyInfo.cs" - ], - "message": "chore(release): ${nextRelease.version} [skip ci]" - } - ], - "@semantic-release/release-notes-generator", - [ - "@semantic-release/github", - { - "successComment": false, - "failComment": false, - "assets": [ - { - "path": "SylphyHornEx.zip" - } - ] - } - ] - ] -} \ No newline at end of file diff --git a/.releaserc.yml b/.releaserc.yml new file mode 100644 index 0000000..1983d05 --- /dev/null +++ b/.releaserc.yml @@ -0,0 +1,33 @@ +--- +branches: + - develop +plugins: + - "@semantic-release/commit-analyzer" + + - # + - "@google/semantic-release-replace-plugin" + - replacements: + - files: + - source/SylphyHorn/Properties/AssemblyInfo.cs + from: '\[assembly: AssemblyVersion\(".+"\)\]' + to: '[assembly: AssemblyVersion("${nextRelease.version}")]' + results: + - file: source/SylphyHorn/Properties/AssemblyInfo.cs + hasChanged: true + numMatches: 1 + numReplacements: 1 + countMatches: true + + - # + - "@semantic-release/git" + - assets: + - source/SylphyHorn/Properties/AssemblyInfo.cs + message: "chore(release): ${nextRelease.version} [skip ci]" + - "@semantic-release/release-notes-generator" + + - # + - "@semantic-release/github" + - successComment: false + failComment: false + assets: + - path: SylphyHornEx.zip From c1728a6998805c14093e0d0c8936a607a98c12ac Mon Sep 17 00:00:00 2001 From: Victor Date: Thu, 21 May 2020 00:40:31 +0300 Subject: [PATCH 51/52] fix: proper version in application --- .github/workflows/main.yml | 15 +-------------- .releaserc.yml | 5 +++++ build.ps1 | 7 +++++++ 3 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 build.ps1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9e6b686..2f982d4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,25 +24,12 @@ jobs: with: token: ${{ secrets.API_GITHUB_TOKEN }} - - name: Build - if: success() - run: | - cd source - git submodule update --init --recursive - nuget restore SylphyHorn.sln - msbuild SylphyHorn.sln /p:Configuration=Release /m /verbosity:normal /p:WarningLevel=0 - - - name: Create ZIP - if: success() - run: | - Rename-Item -Path "source/SylphyHorn/bin/Release" -NewName "SylphyHornEx" - Compress-Archive -Path "source/SylphyHorn/bin/SylphyHornEx" -DestinationPath SylphyHornEx.zip - - name: Release if: success() uses: cycjimmy/semantic-release-action@v2.3.0 with: extra_plugins: | + @semantic-release/exec@5.0.0 @semantic-release/git@9.0.0 @google/semantic-release-replace-plugin@1.0.0 env: diff --git a/.releaserc.yml b/.releaserc.yml index 1983d05..295efc2 100644 --- a/.releaserc.yml +++ b/.releaserc.yml @@ -23,6 +23,11 @@ plugins: - assets: - source/SylphyHorn/Properties/AssemblyInfo.cs message: "chore(release): ${nextRelease.version} [skip ci]" + + - # + - "@semantic-release/exec" + - prepareCmd: "powershell -ep bypass -file build.ps1" + - "@semantic-release/release-notes-generator" - # diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..4f5f8bd --- /dev/null +++ b/build.ps1 @@ -0,0 +1,7 @@ +cd source +git submodule update --init --recursive +nuget restore SylphyHorn.sln +msbuild SylphyHorn.sln /p:Configuration=Release /m /verbosity:normal /p:WarningLevel=0 +cd .. +Rename-Item -Path "source/SylphyHorn/bin/Release" -NewName "SylphyHornEx" +Compress-Archive -Path "source/SylphyHorn/bin/SylphyHornEx" -DestinationPath SylphyHornEx.zip From 9c18c1d018076e298940bb5314c601f345df6771 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 20 May 2020 22:36:10 +0000 Subject: [PATCH 52/52] chore(release): 5.4.3 [skip ci] --- source/SylphyHorn/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/SylphyHorn/Properties/AssemblyInfo.cs b/source/SylphyHorn/Properties/AssemblyInfo.cs index 81d7b5c..cc896b7 100644 --- a/source/SylphyHorn/Properties/AssemblyInfo.cs +++ b/source/SylphyHorn/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -[assembly: AssemblyVersion("5.4.2")] +[assembly: AssemblyVersion("5.4.3")] [assembly: ComVisible(false)]