Browse Source

Added commands to open local app data, roaming app data and install location

CPKreuz 4 years ago
parent
commit
e96954a859

+ 30 - 2
PixiEditor/ViewModels/SubViewModels/Main/DebugViewModel.cs

@@ -1,13 +1,41 @@
-using System.Diagnostics;
-using PixiEditor.Helpers;
+using PixiEditor.Helpers;
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Reflection;
 
 namespace PixiEditor.ViewModels.SubViewModels.Main
 {
     public class DebugViewModel : SubViewModel<ViewModelMain>
     {
+        public RelayCommand OpenFolderCommand { get; set; }
+
+        public RelayCommand OpenInstallLocationCommand { get; set; }
+
         public DebugViewModel(ViewModelMain owner)
             : base(owner)
         {
+            OpenFolderCommand = new RelayCommand(OpenFolder);
+            OpenInstallLocationCommand = new RelayCommand(OpenInstallLocation);
+        }
+
+        public static void OpenFolder(object parameter)
+        {
+            OpenShellExecute((string)parameter);
+        }
+
+        public static void OpenInstallLocation(object parameter)
+        {
+            OpenShellExecute(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
+        }
+
+        private static void OpenShellExecute(string path)
+        {
+            ProcessStartInfo startInfo = new (Environment.ExpandEnvironmentVariables(path));
+
+            startInfo.UseShellExecute = true;
+
+            Process.Start(startInfo);
         }
     }
 }

+ 7 - 0
PixiEditor/Views/MainWindow.xaml

@@ -149,6 +149,13 @@
                     <MenuItem Header="_Third Party Licenses" Command="{Binding MiscSubViewModel.OpenHyperlinkCommand}"
                               CommandParameter="https://github.com/PixiEditor/PixiEditor/wiki/Third-party-licenses"/>
                 </MenuItem>
+                <MenuItem Header="_Debug" Visibility="{Binding IsDebug, Converter={StaticResource BoolToVisibilityConverter}}">
+                    <MenuItem Header="_Open Local App Data" Command="{Binding DebugSubViewModel.OpenFolderCommand}"
+                              CommandParameter="%LocalAppData%/PixiEditor"/>
+                    <MenuItem Header="_Open Roaming App Data" Command="{Binding DebugSubViewModel.OpenFolderCommand}"
+                              CommandParameter="%AppData%/PixiEditor"/>
+                    <MenuItem Header="_Open Install Location"  Command="{Binding DebugSubViewModel.OpenInstallLocationCommand}"/>
+                </MenuItem>
             </Menu>
             <StackPanel DockPanel.Dock="Right" VerticalAlignment="Top" Orientation="Horizontal"
                         HorizontalAlignment="Right" WindowChrome.IsHitTestVisibleInChrome="True">