mirror of
				https://github.com/9ParsonsB/Pulsar.git
				synced 2025-11-03 23:36:42 -05:00 
			
		
		
		
	Removed unnecessary. Add summaryt for AddGrid Item. Add ClearGrid and ExecuteOnUIThread.
This commit is contained in:
		@@ -3,34 +3,18 @@ using Observatory.Framework.Files;
 | 
			
		||||
using Observatory.Framework.Interfaces;
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
namespace Observatory.PluginManagement
 | 
			
		||||
{
 | 
			
		||||
    public class PluginCore : IObservatoryCore
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        public string Version => "1.0a";
 | 
			
		||||
        public string Version => System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
 | 
			
		||||
 | 
			
		||||
        public Status GetStatus()
 | 
			
		||||
        {
 | 
			
		||||
            throw new NotImplementedException();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestAllJournals()
 | 
			
		||||
        {
 | 
			
		||||
            throw new NotImplementedException();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestJournalRange(DateTime start, DateTime end)
 | 
			
		||||
        {
 | 
			
		||||
            throw new NotImplementedException();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RequestJournalRange(int startIndex, int number, bool newestFirst)
 | 
			
		||||
        {
 | 
			
		||||
            throw new NotImplementedException();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void SendNotification(string title, string text)
 | 
			
		||||
        {
 | 
			
		||||
            if (!LogMonitor.GetInstance.ReadAllInProgress())
 | 
			
		||||
@@ -54,18 +38,23 @@ namespace Observatory.PluginManagement
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds an item to the datagrid on UI thread to ensure visual update.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="worker"></param>
 | 
			
		||||
        /// <param name="item"></param>
 | 
			
		||||
        public void AddGridItem(IObservatoryWorker worker, object item)
 | 
			
		||||
        {
 | 
			
		||||
            Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(() => 
 | 
			
		||||
            Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(() =>
 | 
			
		||||
            {
 | 
			
		||||
                worker.PluginUI.DataGrid.Add(item); 
 | 
			
		||||
                worker.PluginUI.DataGrid.Add(item);
 | 
			
		||||
 | 
			
		||||
                //Hacky removal of original empty object if one was used to populate columns
 | 
			
		||||
                if (worker.PluginUI.DataGrid.Count == 2)
 | 
			
		||||
                {
 | 
			
		||||
                    bool allNull = true;
 | 
			
		||||
                    Type itemType = worker.PluginUI.DataGrid[0].GetType();
 | 
			
		||||
                    foreach(var property in itemType.GetProperties())
 | 
			
		||||
                    foreach (var property in itemType.GetProperties())
 | 
			
		||||
                    {
 | 
			
		||||
                        if (property.GetValue(worker.PluginUI.DataGrid[0], null) != null)
 | 
			
		||||
                        {
 | 
			
		||||
@@ -77,10 +66,25 @@ namespace Observatory.PluginManagement
 | 
			
		||||
                    if (allNull)
 | 
			
		||||
                        worker.PluginUI.DataGrid.RemoveAt(0);
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void ClearGrid(IObservatoryWorker worker, object templateItem)
 | 
			
		||||
        {
 | 
			
		||||
            Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(() =>
 | 
			
		||||
            {
 | 
			
		||||
                worker.PluginUI.DataGrid.Add(templateItem);
 | 
			
		||||
                while (worker.PluginUI.DataGrid.Count > 1)
 | 
			
		||||
                    worker.PluginUI.DataGrid.RemoveAt(0);
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void ExecuteOnUIThread(Action action)
 | 
			
		||||
        {
 | 
			
		||||
            Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(action);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public event EventHandler<NotificationEventArgs> Notification;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user