mirror of
				https://github.com/9ParsonsB/Pulsar.git
				synced 2025-11-04 07:36:42 -05:00 
			
		
		
		
	Initial overhaul work
This commit is contained in:
		@@ -7,9 +7,9 @@
 | 
				
			|||||||
    <local:ViewLocator/>
 | 
					    <local:ViewLocator/>
 | 
				
			||||||
  </Application.DataTemplates>
 | 
					  </Application.DataTemplates>
 | 
				
			||||||
  <Application.Styles>
 | 
					  <Application.Styles>
 | 
				
			||||||
    <FluentTheme Mode="Light"/>
 | 
					    <FluentTheme Mode="Dark"/>
 | 
				
			||||||
    <StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml"/>
 | 
					    <StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml"/>
 | 
				
			||||||
    <StyleInclude Source="avares://Egorozh.ColorPicker.Avalonia.Dialog/Themes/Default.axaml" />
 | 
					    <StyleInclude Source="avares://Egorozh.ColorPicker.Avalonia.Dialog/Themes/Default.axaml" />
 | 
				
			||||||
    <dialog:FluentColorPickerTheme Mode="Light" />
 | 
					    <dialog:FluentColorPickerTheme Mode="Dark" />
 | 
				
			||||||
  </Application.Styles>
 | 
					  </Application.Styles>
 | 
				
			||||||
</Application>
 | 
					</Application>
 | 
				
			||||||
@@ -9,38 +9,73 @@ using Observatory.UI.Models;
 | 
				
			|||||||
using ReactiveUI;
 | 
					using ReactiveUI;
 | 
				
			||||||
using System.Reactive.Linq;
 | 
					using System.Reactive.Linq;
 | 
				
			||||||
using Observatory.Framework;
 | 
					using Observatory.Framework;
 | 
				
			||||||
 | 
					using System.Collections.Specialized;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Observatory.UI.ViewModels
 | 
					namespace Observatory.UI.ViewModels
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public class BasicUIViewModel : ViewModelBase
 | 
					    public class BasicUIViewModel : ViewModelBase
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        private ObservableCollection<object> basicUIGrid;
 | 
					        private ObservableCollection<string> _headers;
 | 
				
			||||||
 | 
					        private ObservableCollection<string> _formats;
 | 
				
			||||||
 | 
					        private ObservableCollection<ObservableCollection<object>> _items;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public System.Collections.IList SelectedItems { get; set; }        
 | 
					        public System.Collections.IList SelectedItems { get; set; }        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public ObservableCollection<object> BasicUIGrid
 | 
					        
 | 
				
			||||||
 | 
					        public ObservableCollection<string> Headers
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get => basicUIGrid;
 | 
					            get => _headers;
 | 
				
			||||||
            set
 | 
					            set
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                basicUIGrid = value;
 | 
					                _headers = value;
 | 
				
			||||||
                this.RaisePropertyChanged(nameof(BasicUIGrid));
 | 
					                _headers.CollectionChanged += (o, e) => this.RaisePropertyChanged(nameof(Headers));
 | 
				
			||||||
 | 
					                this.RaisePropertyChanged(nameof(Headers));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public BasicUIViewModel(ObservableCollection<object> BasicUIGrid)
 | 
					        public ObservableCollection<string> Formats
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            this.BasicUIGrid = BasicUIGrid;
 | 
					            get => _formats;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _formats = value;
 | 
				
			||||||
 | 
					                _formats.CollectionChanged += (o, e) => this.RaisePropertyChanged(nameof(Formats));
 | 
				
			||||||
 | 
					                this.RaisePropertyChanged(nameof(Formats));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private PluginUI.UIType uiType;
 | 
					        public ObservableCollection<ObservableCollection<object>> Items
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _items;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                void raiseItemChanged(object o, NotifyCollectionChangedEventArgs e) { this.RaisePropertyChanged(nameof(Items)); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                _items = value;
 | 
				
			||||||
 | 
					                _items.CollectionChanged += raiseItemChanged;
 | 
				
			||||||
 | 
					                this.RaisePropertyChanged(nameof(Items));
 | 
				
			||||||
 | 
					                foreach (var itemColumn in value)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    itemColumn.CollectionChanged += raiseItemChanged;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public BasicUIViewModel(ObservableCollection<string> headers, ObservableCollection<string> formats)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Headers = headers;
 | 
				
			||||||
 | 
					            Formats = formats;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private PluginUI.UIType _uiType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public PluginUI.UIType UIType
 | 
					        public PluginUI.UIType UIType
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get => uiType;
 | 
					            get => _uiType;
 | 
				
			||||||
            set
 | 
					            set
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                uiType = value;
 | 
					                _uiType = value;
 | 
				
			||||||
                this.RaisePropertyChanged(nameof(UIType));
 | 
					                this.RaisePropertyChanged(nameof(UIType));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,8 +47,8 @@ namespace Observatory.UI.ViewModels
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            foreach(var notifier in notifiers.Select(p => p.plugin))
 | 
					            foreach(var notifier in notifiers.Select(p => p.plugin))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Panel notifierPanel = new Panel();
 | 
					                Panel notifierPanel = new();
 | 
				
			||||||
                TextBlock notifierTextBlock = new TextBlock();
 | 
					                TextBlock notifierTextBlock = new();
 | 
				
			||||||
                notifierTextBlock.Text = notifier.Name;
 | 
					                notifierTextBlock.Text = notifier.Name;
 | 
				
			||||||
                notifierPanel.Children.Add(notifierTextBlock);
 | 
					                notifierPanel.Children.Add(notifierTextBlock);
 | 
				
			||||||
                //tabs.Add(new CoreModel() { Name = notifier.ShortName, UI = (ViewModelBase)notifier.UI });
 | 
					                //tabs.Add(new CoreModel() { Name = notifier.ShortName, UI = (ViewModelBase)notifier.UI });
 | 
				
			||||||
@@ -65,7 +65,7 @@ namespace Observatory.UI.ViewModels
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void ReadAll()
 | 
					        public static void ReadAll()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            LogMonitor.GetInstance.ReadAllJournals();
 | 
					            LogMonitor.GetInstance.ReadAllJournals();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -86,21 +86,21 @@ namespace Observatory.UI.ViewModels
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void OpenGithub()
 | 
					        public static void OpenGithub()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            ProcessStartInfo githubOpen = new("https://github.com/Xjph/ObservatoryCore");
 | 
					            ProcessStartInfo githubOpen = new("https://github.com/Xjph/ObservatoryCore");
 | 
				
			||||||
            githubOpen.UseShellExecute = true;
 | 
					            githubOpen.UseShellExecute = true;
 | 
				
			||||||
            Process.Start(githubOpen);
 | 
					            Process.Start(githubOpen);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void OpenDonate()
 | 
					        public static void OpenDonate()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            ProcessStartInfo donateOpen = new("https://paypal.me/eliteobservatory");
 | 
					            ProcessStartInfo donateOpen = new("https://paypal.me/eliteobservatory");
 | 
				
			||||||
            donateOpen.UseShellExecute = true;
 | 
					            donateOpen.UseShellExecute = true;
 | 
				
			||||||
            Process.Start(donateOpen);
 | 
					            Process.Start(donateOpen);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void GetUpdate()
 | 
					        public static void GetUpdate()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            ProcessStartInfo githubOpen = new("https://github.com/Xjph/ObservatoryCore/releases");
 | 
					            ProcessStartInfo githubOpen = new("https://github.com/Xjph/ObservatoryCore/releases");
 | 
				
			||||||
            githubOpen.UseShellExecute = true;
 | 
					            githubOpen.UseShellExecute = true;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,7 @@ using Avalonia.Media;
 | 
				
			|||||||
using Avalonia.Controls.ApplicationLifetimes;
 | 
					using Avalonia.Controls.ApplicationLifetimes;
 | 
				
			||||||
using System.Runtime.InteropServices;
 | 
					using System.Runtime.InteropServices;
 | 
				
			||||||
using System.IO;
 | 
					using System.IO;
 | 
				
			||||||
 | 
					using Avalonia.Platform.Storage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Observatory.UI.Views
 | 
					namespace Observatory.UI.Views
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -71,6 +72,7 @@ namespace Observatory.UI.Views
 | 
				
			|||||||
            e.Column.CanUserResize = true;
 | 
					            e.Column.CanUserResize = true;
 | 
				
			||||||
            e.Column.CanUserSort = true;
 | 
					            e.Column.CanUserSort = true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void UITypeChange()
 | 
					        private void UITypeChange()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var uiPanel = this.Find<Panel>("UIPanel");
 | 
					            var uiPanel = this.Find<Panel>("UIPanel");
 | 
				
			||||||
@@ -83,10 +85,9 @@ namespace Observatory.UI.Views
 | 
				
			|||||||
                case PluginUI.UIType.Basic:
 | 
					                case PluginUI.UIType.Basic:
 | 
				
			||||||
                    dataGrid = new()
 | 
					                    dataGrid = new()
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        [!DataGrid.ItemsProperty] = new Binding("BasicUIGrid"),
 | 
					                        [!DataGrid.ItemsProperty] = new Binding("Items"),
 | 
				
			||||||
                        SelectionMode = DataGridSelectionMode.Extended,
 | 
					                        SelectionMode = DataGridSelectionMode.Extended,
 | 
				
			||||||
                        GridLinesVisibility = DataGridGridLinesVisibility.Vertical,
 | 
					                        GridLinesVisibility = DataGridGridLinesVisibility.Vertical,
 | 
				
			||||||
                        AutoGenerateColumns = true,
 | 
					 | 
				
			||||||
                        IsReadOnly = true
 | 
					                        IsReadOnly = true
 | 
				
			||||||
                    };
 | 
					                    };
 | 
				
			||||||
                    dataGrid.AutoGeneratingColumn += ColumnGeneration;
 | 
					                    dataGrid.AutoGeneratingColumn += ColumnGeneration;
 | 
				
			||||||
@@ -1028,21 +1029,33 @@ namespace Observatory.UI.Views
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                            settingBrowse.Click += (object source, RoutedEventArgs e) =>
 | 
					                            settingBrowse.Click += (object source, RoutedEventArgs e) =>
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                OpenFileDialog openFileDialog = new()
 | 
					                                var currentFolder = new Avalonia.Platform.Storage.FileIO.BclStorageFolder(fileSetting.DirectoryName);
 | 
				
			||||||
 | 
					                                var fileOptions = new FilePickerOpenOptions()
 | 
				
			||||||
                                {
 | 
					                                {
 | 
				
			||||||
                                    Directory = fileSetting.DirectoryName,
 | 
					                                    AllowMultiple = false,
 | 
				
			||||||
                                    AllowMultiple = false
 | 
					                                    SuggestedStartLocation = currentFolder
 | 
				
			||||||
                                };
 | 
					                                };
 | 
				
			||||||
                                var browseTask = openFileDialog.ShowAsync((Window)((Button)source).GetVisualRoot());
 | 
					
 | 
				
			||||||
 | 
					                                var browseTask = ((Window)settingBrowse.FindAncestorOfType<Window>()).StorageProvider.OpenFilePickerAsync(fileOptions);
 | 
				
			||||||
 | 
					                                
 | 
				
			||||||
 | 
					                                //OpenFileDialog openFileDialog = new()
 | 
				
			||||||
 | 
					                                //{
 | 
				
			||||||
 | 
					                                //    Directory = fileSetting.DirectoryName,
 | 
				
			||||||
 | 
					                                //    AllowMultiple = false
 | 
				
			||||||
 | 
					                                //};
 | 
				
			||||||
 | 
					                                
 | 
				
			||||||
 | 
					                                // = openFileDialog.ShowAsync((Window)((Button)source).GetVisualRoot());
 | 
				
			||||||
 | 
					                                
 | 
				
			||||||
                                browseTask.ContinueWith((task) => 
 | 
					                                browseTask.ContinueWith((task) => 
 | 
				
			||||||
                                {
 | 
					                                {
 | 
				
			||||||
                                    if (task.Result?.Count() > 0)
 | 
					                                    if (task.Result?.Count() > 0)
 | 
				
			||||||
                                    {
 | 
					                                    {
 | 
				
			||||||
                                        string path = browseTask.Result[0];
 | 
					                                        if (browseTask.Result[0].TryGetUri(out Uri path))
 | 
				
			||||||
                                        Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(() => { settingPath.Text = path; });
 | 
					                                        {
 | 
				
			||||||
                                        setting.Key.SetValue(plugin.Settings, new FileInfo(path));
 | 
					                                            Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(() => { settingPath.Text = path.AbsolutePath; });
 | 
				
			||||||
                                        PluginManagement.PluginManager.GetInstance.SaveSettings(plugin, plugin.Settings);
 | 
					                                            setting.Key.SetValue(plugin.Settings, new FileInfo(path.AbsolutePath));
 | 
				
			||||||
 | 
					                                            PluginManagement.PluginManager.GetInstance.SaveSettings(plugin, plugin.Settings);
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
                                    }
 | 
					                                    }
 | 
				
			||||||
                                });
 | 
					                                });
 | 
				
			||||||
                                
 | 
					                                
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,11 +23,26 @@ namespace Observatory.Framework
 | 
				
			|||||||
        public object UI;
 | 
					        public object UI;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// <para>Collection bound to DataGrid used byu plugins with UIType.Basic.</para>
 | 
					        /// <para>Collection bound to DataGrid used by plugins with UIType.Basic.</para>
 | 
				
			||||||
        /// <para>Objects in collection should be of a class defined within the plugin consisting of string properties.<br/>Each object is a single row, and the property names are used as column headers.</para>
 | 
					        /// <para>Objects in collection should be of a class defined within the plugin consisting of string properties.<br/>Each object is a single row, and the property names are used as column headers.</para>
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        public ObservableCollection<object> DataGrid;
 | 
					        public ObservableCollection<object> DataGrid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// <para>Collection bound to DataGrid headers used by plugins with UIType.Basic.</para>
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public ObservableCollection<string> Headers;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// <para>Collection used to specify formatting of items in respective columns.</para>
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public ObservableCollection<string> Formats;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// <para>Two-dimensional collection of items to display in UI grid.</para>
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public ObservableCollection<ObservableCollection<object>> Items;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Instantiate PluginUI of UIType.Basic.
 | 
					        /// Instantiate PluginUI of UIType.Basic.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user