mirror of
https://github.com/9ParsonsB/Pulsar.git
synced 2025-04-05 17:39:39 -04:00
Revert LogMonitor/CoreViewModel changes, implement Slider int setting
Also revert the PluginType enum. Fix more whitespace
This commit is contained in:
parent
73c9b94b0f
commit
e523dddfe3
@ -146,9 +146,7 @@ namespace Observatory
|
|||||||
|
|
||||||
// We found an FSD jump, buffered the lines for that system (possibly including startup logs
|
// We found an FSD jump, buffered the lines for that system (possibly including startup logs
|
||||||
// over a file boundary). Pump these through the plugins.
|
// over a file boundary). Pump these through the plugins.
|
||||||
readall = true;
|
|
||||||
ReportErrors(ProcessLines(lastSystemLines, "Pre-read"));
|
ReportErrors(ProcessLines(lastSystemLines, "Pre-read"));
|
||||||
readall = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -55,9 +55,15 @@ namespace Observatory.UI.ViewModels
|
|||||||
|
|
||||||
public void ReadAll()
|
public void ReadAll()
|
||||||
{
|
{
|
||||||
SetWorkerReadAllState(true);
|
foreach (var worker in workers)
|
||||||
|
{
|
||||||
|
worker.ReadAllStarted();
|
||||||
|
}
|
||||||
LogMonitor.GetInstance.ReadAllJournals();
|
LogMonitor.GetInstance.ReadAllJournals();
|
||||||
SetWorkerReadAllState(false);
|
foreach (var worker in workers)
|
||||||
|
{
|
||||||
|
worker.ReadAllFinished();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleMonitor()
|
public void ToggleMonitor()
|
||||||
@ -71,10 +77,7 @@ namespace Observatory.UI.ViewModels
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// HACK: Find a better way of suppressing notifications when pre-reading.
|
|
||||||
SetWorkerReadAllState(true);
|
|
||||||
logMonitor.Start();
|
logMonitor.Start();
|
||||||
SetWorkerReadAllState(false);
|
|
||||||
ToggleButtonText = "Stop Monitor";
|
ToggleButtonText = "Stop Monitor";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,20 +123,5 @@ namespace Observatory.UI.ViewModels
|
|||||||
{
|
{
|
||||||
get { return tabs; }
|
get { return tabs; }
|
||||||
}
|
}
|
||||||
private void SetWorkerReadAllState(bool isReadingAll)
|
|
||||||
{
|
|
||||||
foreach (var worker in workers)
|
|
||||||
{
|
|
||||||
if (isReadingAll)
|
|
||||||
{
|
|
||||||
worker.ReadAllStarted();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
worker.ReadAllFinished();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ namespace Observatory.UI.Views
|
|||||||
if (!uniquePlugins.ContainsKey(plugin.Name))
|
if (!uniquePlugins.ContainsKey(plugin.Name))
|
||||||
{
|
{
|
||||||
uniquePlugins.Add(plugin.Name,
|
uniquePlugins.Add(plugin.Name,
|
||||||
new PluginView() { Name = plugin.Name, Types = new() { PluginType.Worker }, Version = plugin.Version, Status = GetStatusText(signed) });
|
new PluginView() { Name = plugin.Name, Types = new() { typeof(IObservatoryWorker).Name }, Version = plugin.Version, Status = GetStatusText(signed) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,10 +286,10 @@ namespace Observatory.UI.Views
|
|||||||
if (!uniquePlugins.ContainsKey(plugin.Name))
|
if (!uniquePlugins.ContainsKey(plugin.Name))
|
||||||
{
|
{
|
||||||
uniquePlugins.Add(plugin.Name,
|
uniquePlugins.Add(plugin.Name,
|
||||||
new PluginView() { Name = plugin.Name, Types = new() { PluginType.Notifier }, Version = plugin.Version, Status = GetStatusText(signed) });
|
new PluginView() { Name = plugin.Name, Types = new() { typeof(IObservatoryNotifier).Name }, Version = plugin.Version, Status = GetStatusText(signed) });
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
uniquePlugins[plugin.Name].Types.Add(PluginType.Notifier);
|
uniquePlugins[plugin.Name].Types.Add(typeof(IObservatoryNotifier).Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ namespace Observatory.UI.Views
|
|||||||
{
|
{
|
||||||
settingsGrid.RowDefinitions.Add(new RowDefinition()
|
settingsGrid.RowDefinitions.Add(new RowDefinition()
|
||||||
{
|
{
|
||||||
Height = new GridLength(setting.Key.PropertyType != typeof(bool) ? 32 : 25),
|
Height = new GridLength(setting.Key.PropertyType != typeof(bool) ? 40 : 25),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,21 +380,55 @@ namespace Observatory.UI.Views
|
|||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case int intSetting:
|
case int intSetting:
|
||||||
NumericUpDown numericUpDown = new() { Value = intSetting, AllowSpin = true };
|
// We have two options for integer values:
|
||||||
SettingNumericBounds attr = (SettingNumericBounds)System.Attribute.GetCustomAttribute(setting.Key, typeof(SettingNumericBounds));
|
// 1) A slider (explicit by way of the SettingIntegerUseSlider attribute and bounded to 0..100 by default)
|
||||||
if (attr != null)
|
// 2) A numeric up/down (default otherwise, and is unbounded by default).
|
||||||
|
// Bounds for both can be set via the SettingNumericBounds attribute, only the up/down uses Increment.
|
||||||
|
Control intControl;
|
||||||
|
SettingNumericBounds bounds = (SettingNumericBounds)System.Attribute.GetCustomAttribute(setting.Key, typeof(SettingNumericBounds));
|
||||||
|
if (System.Attribute.IsDefined(setting.Key, typeof(SettingNumericUseSlider)))
|
||||||
{
|
{
|
||||||
numericUpDown.Minimum = attr.Minimum;
|
// TODO: Suss the contents of this block into a function to share with non-integral numeric types as well?
|
||||||
numericUpDown.Maximum = attr.Maximum;
|
Slider slider = new()
|
||||||
numericUpDown.Increment = attr.Increment;
|
{
|
||||||
|
Value = intSetting,
|
||||||
|
Height = 40,
|
||||||
|
Width = 300,
|
||||||
|
};
|
||||||
|
if (bounds != null)
|
||||||
|
{
|
||||||
|
slider.Minimum = bounds.Minimum;
|
||||||
|
slider.Maximum = bounds.Maximum;
|
||||||
|
};
|
||||||
|
slider.PropertyChanged += (object sender, AvaloniaPropertyChangedEventArgs e) =>
|
||||||
|
{
|
||||||
|
if (e.Property == Slider.ValueProperty)
|
||||||
|
{
|
||||||
|
setting.Key.SetValue(plugin.Settings, Convert.ToInt32(e.NewValue));
|
||||||
|
PluginManagement.PluginManager.GetInstance.SaveSettings(plugin, plugin.Settings);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
intControl = slider;
|
||||||
|
}
|
||||||
|
else // Use a Numeric Up/Down
|
||||||
|
{
|
||||||
|
NumericUpDown numericUpDown = new() { Value = intSetting, AllowSpin = true };
|
||||||
|
if (bounds != null)
|
||||||
|
{
|
||||||
|
numericUpDown.Minimum = bounds.Minimum;
|
||||||
|
numericUpDown.Maximum = bounds.Maximum;
|
||||||
|
numericUpDown.Increment = bounds.Increment;
|
||||||
}
|
}
|
||||||
settingsGrid.AddControl(label, settingsGrid.RowDefinitions.Count - 1, 0);
|
|
||||||
settingsGrid.AddControl(numericUpDown, settingsGrid.RowDefinitions.Count - 1, 1);
|
|
||||||
numericUpDown.ValueChanged += (object sender, NumericUpDownValueChangedEventArgs e) =>
|
numericUpDown.ValueChanged += (object sender, NumericUpDownValueChangedEventArgs e) =>
|
||||||
{
|
{
|
||||||
setting.Key.SetValue(plugin.Settings, Convert.ToInt32(e.NewValue));
|
setting.Key.SetValue(plugin.Settings, Convert.ToInt32(e.NewValue));
|
||||||
PluginManagement.PluginManager.GetInstance.SaveSettings(plugin, plugin.Settings);
|
PluginManagement.PluginManager.GetInstance.SaveSettings(plugin, plugin.Settings);
|
||||||
};
|
};
|
||||||
|
intControl = numericUpDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
settingsGrid.AddControl(label, settingsGrid.RowDefinitions.Count - 1, 0);
|
||||||
|
settingsGrid.AddControl(intControl, settingsGrid.RowDefinitions.Count - 1, 1);
|
||||||
break;
|
break;
|
||||||
case System.IO.FileInfo fileSetting:
|
case System.IO.FileInfo fileSetting:
|
||||||
label.Text += ": ";
|
label.Text += ": ";
|
||||||
@ -402,7 +436,7 @@ namespace Observatory.UI.Views
|
|||||||
TextBox settingPath = new()
|
TextBox settingPath = new()
|
||||||
{
|
{
|
||||||
Text = fileSetting.FullName,
|
Text = fileSetting.FullName,
|
||||||
Width = 250,
|
Width = 300,
|
||||||
HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right
|
HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -499,23 +533,16 @@ namespace Observatory.UI.Views
|
|||||||
internal class PluginView
|
internal class PluginView
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public HashSet<PluginType> Types { get; set; }
|
public HashSet<string> Types { get; set; }
|
||||||
public string TypesString {
|
public string TypesString
|
||||||
get
|
|
||||||
{
|
{
|
||||||
return string.Join(", ", Types);
|
get => string.Join(", ", Types);
|
||||||
|
set { }
|
||||||
}
|
}
|
||||||
set { } }
|
|
||||||
public string Version { get; set; }
|
public string Version { get; set; }
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PluginType
|
|
||||||
{
|
|
||||||
Worker,
|
|
||||||
Notifier,
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static class GridExtention
|
internal static class GridExtention
|
||||||
{
|
{
|
||||||
public static void AddControl(this Grid grid, Control control, int row, int column, int span = 1)
|
public static void AddControl(this Grid grid, Control control, int row, int column, int span = 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user