From a2261a5c6ced4348b76d8135157ab0bb2daa0e3e Mon Sep 17 00:00:00 2001 From: Xjph Date: Mon, 18 Oct 2021 10:33:42 -0230 Subject: [PATCH] feat: add plugin folder button --- ObservatoryCore/UI/Views/BasicUIView.axaml.cs | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/ObservatoryCore/UI/Views/BasicUIView.axaml.cs b/ObservatoryCore/UI/Views/BasicUIView.axaml.cs index 6ec24b0..b23164f 100644 --- a/ObservatoryCore/UI/Views/BasicUIView.axaml.cs +++ b/ObservatoryCore/UI/Views/BasicUIView.axaml.cs @@ -14,6 +14,7 @@ using System.Collections.Generic; using Avalonia.Media; using Avalonia.Controls.ApplicationLifetimes; using System.Runtime.InteropServices; +using System.IO; namespace Observatory.UI.Views { @@ -140,7 +141,7 @@ namespace Observatory.UI.Views #region Native Settings #region Plugin List - DataGrid pluginList = new() { Margin = new Thickness(0, 20) }; + DataGrid pluginList = new() { Margin = new Thickness(0, 20, 0, 0) }; pluginList.Columns.Add(new DataGridTextColumn() { @@ -192,6 +193,31 @@ namespace Observatory.UI.Views pluginList.Items = uniquePlugins.Values; gridManager.AddSetting(pluginList); + Button pluginFolderButton = new() + { + Content = "Open Plugin Folder", + Height = 30, + Width = 150, + HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right, + HorizontalContentAlignment = Avalonia.Layout.HorizontalAlignment.Center, + Margin = new Thickness(0, 0, 0, 20) + }; + + pluginFolderButton.Click += (object sender, RoutedEventArgs e) => + { + string pluginDir = AppDomain.CurrentDomain.BaseDirectory + "plugins"; + + if (!Directory.Exists(pluginDir)) + { + Directory.CreateDirectory(pluginDir); + } + + var fileExplorerInfo = new System.Diagnostics.ProcessStartInfo() { FileName = pluginDir, UseShellExecute = true }; + System.Diagnostics.Process.Start(fileExplorerInfo); + }; + + gridManager.AddSetting(pluginFolderButton); + #endregion #region Popup Notification settings @@ -678,7 +704,6 @@ namespace Observatory.UI.Views } }; - #endregion