소스 검색

Added FullScreen-Feature

zockicookie 1 주 전
부모
커밋
9d6e8c6cb9
1개의 변경된 파일28개의 추가작업 그리고 0개의 파일을 삭제
  1. 28 0
      src/PixiEditor/ViewModels/SubViewModels/WindowViewModel.cs

+ 28 - 0
src/PixiEditor/ViewModels/SubViewModels/WindowViewModel.cs

@@ -2,6 +2,7 @@
 using System.Drawing;
 using System.Linq;
 using System.Threading.Tasks;
+using Avalonia.Controls;
 using Avalonia.Input;
 using CommunityToolkit.Mvvm.Input;
 using Drawie.Numerics;
@@ -303,4 +304,31 @@ internal class WindowViewModel : SubViewModel<ViewModelMain>, IWindowHandler
         popup.Show();
         return popup;
     }
+
+    /// <summary>
+    /// Used to save the WindowState before toggling to FullScreen-Mode.
+    /// </summary>
+    private WindowState LastWindowState { get; set; }
+
+    /// <summary>
+    /// Method used to toggle to FullScreen-Mode.
+    /// </summary>
+    [Commands_Command.Basic("PixiEditor.Window.ToggleFullscreen", "TOGGLE_FULLSCREEN", "TOGGLE_FULLSCREEN",
+        Key = Key.F11,
+        Icon = PixiPerfectIcons.Fullscreen,
+        AnalyticsTrack = true)]
+    public void ToggleFullscreen()
+    {
+        var window = Owner.AttachedWindow;
+
+        if (window is null) return;
+
+        if (window.WindowState != WindowState.FullScreen) LastWindowState = window.WindowState;
+
+        window.WindowState = window.WindowState switch
+        {
+            WindowState.FullScreen => LastWindowState,
+            _ => WindowState.FullScreen
+        };
+    }
 }