2
0
mirror of https://github.com/9ParsonsB/Pulsar.git synced 2025-07-01 16:33:43 -04:00

Add project files.

This commit is contained in:
Xjph
2021-06-03 22:25:32 -02:30
parent 7099cf23c6
commit a5154996ee
32 changed files with 2287 additions and 0 deletions

View File

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using Observatory.UI.Models;
using ReactiveUI;
using System.Reactive.Linq;
using Observatory.Framework;
namespace Observatory.UI.ViewModels
{
public class BasicUIViewModel : ViewModelBase
{
private ObservableCollection<object> basicUIGrid;
public ObservableCollection<object> BasicUIGrid
{
get => basicUIGrid;
set
{
basicUIGrid = value;
this.RaisePropertyChanged(nameof(BasicUIGrid));
}
}
public BasicUIViewModel(ObservableCollection<object> BasicUIGrid)
{
this.BasicUIGrid = new();
this.BasicUIGrid = BasicUIGrid;
//// Create a timer and set a two second interval.
//var aTimer = new System.Timers.Timer();
//aTimer.Interval = 2000;
//// Hook up the Elapsed event for the timer.
//aTimer.Elapsed += OnTimedEvent;
//// Have the timer fire repeated events (true is the default)
//aTimer.AutoReset = true;
//// Start the timer
//aTimer.Enabled = true;
}
private PluginUI.UIType uiType;
public PluginUI.UIType UIType
{
get => uiType;
set
{
uiType = value;
this.RaisePropertyChanged(nameof(UIType));
}
}
private void OnTimedEvent(object sender, System.Timers.ElapsedEventArgs e)
{
basicUIGrid.Count();
}
}
}

View File

@ -0,0 +1,110 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Linq;
using Avalonia.Controls;
using Observatory.Framework.Interfaces;
using Observatory.UI.Models;
using ReactiveUI;
namespace Observatory.UI.ViewModels
{
public class CoreViewModel : ViewModelBase
{
private readonly ObservableCollection<IObservatoryNotifier> notifiers;
private readonly ObservableCollection<IObservatoryWorker> workers;
private readonly ObservableCollection<CoreModel> tabs;
private string toggleButtonText;
public CoreViewModel(IEnumerable<(IObservatoryWorker plugin, PluginManagement.PluginManager.PluginStatus signed)> workers, IEnumerable<(IObservatoryNotifier plugin, PluginManagement.PluginManager.PluginStatus signed)> notifiers)
{
this.notifiers = new ObservableCollection<IObservatoryNotifier>(notifiers.Select(p => p.plugin));
this.workers = new ObservableCollection<IObservatoryWorker>(workers.Select(p => p.plugin));
ToggleButtonText = "Start Monitor";
tabs = new ObservableCollection<CoreModel>();
foreach(var worker in workers.Select(p => p.plugin))
{
if (worker.PluginUI.PluginUIType == Framework.PluginUI.UIType.Basic)
{
CoreModel coreModel = new();
coreModel.Name = worker.ShortName;
coreModel.UI = new();
var uiViewModel = new BasicUIViewModel(worker.PluginUI.DataGrid)
{
UIType = worker.PluginUI.PluginUIType
};
coreModel.UI = uiViewModel;
tabs.Add(coreModel);
}
}
foreach(var notifier in notifiers.Select(p => p.plugin))
{
Panel notifierPanel = new Panel();
TextBlock notifierTextBlock = new TextBlock();
notifierTextBlock.Text = notifier.Name;
notifierPanel.Children.Add(notifierTextBlock);
//tabs.Add(new CoreModel() { Name = notifier.ShortName, UI = (ViewModelBase)notifier.UI });
}
tabs.Add(new CoreModel() { Name = "Core", UI = new BasicUIViewModel(new ObservableCollection<object>()) { UIType = Framework.PluginUI.UIType.Core } });
}
public void ReadAll()
{
foreach (var worker in workers)
{
worker.ReadAllStarted();
}
LogMonitor.GetInstance.ReadAllJournals();
}
public void ToggleMonitor()
{
var logMonitor = LogMonitor.GetInstance;
if (logMonitor.IsMonitoring())
{
logMonitor.Stop();
ToggleButtonText = "Start Monitor";
}
else
{
logMonitor.Start();
ToggleButtonText = "Stop Monitor";
}
}
public string ToggleButtonText
{
get => toggleButtonText;
set
{
if (toggleButtonText != value)
{
toggleButtonText = value;
this.RaisePropertyChanged(nameof(ToggleButtonText));
}
}
}
public ObservableCollection<IObservatoryWorker> Workers
{
get { return workers; }
}
public ObservableCollection<IObservatoryNotifier> Notifiers
{
get { return notifiers; }
}
public ObservableCollection<CoreModel> Tabs
{
get { return tabs; }
}
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Observatory.UI.ViewModels
{
public class MainWindowViewModel : ViewModelBase
{
public MainWindowViewModel(PluginManagement.PluginManager pluginManager)
{
core = new CoreViewModel(pluginManager.workerPlugins, pluginManager.notifyPlugins);
}
public CoreViewModel core { get; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Observatory.UI.ViewModels
{
public class NotificationViewModel : ViewModelBase
{
public NotificationViewModel(string title, string detail)
{
Notification = new() { Title = title, Detail = detail };
}
public Models.NotificationModel Notification;
}
}

View File

@ -0,0 +1,11 @@
using ReactiveUI;
using System;
using System.Collections.Generic;
using System.Text;
namespace Observatory.UI.ViewModels
{
public class ViewModelBase : ReactiveObject
{
}
}