mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-08 07:46:13 +02:00
Fix built in plugins
This commit is contained in:
@@ -10,138 +10,137 @@ using System.Windows.Interop;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
|
||||||
namespace DesktopMagic
|
namespace DesktopMagic;
|
||||||
|
|
||||||
|
public partial class CpuUsageWindow : Window
|
||||||
{
|
{
|
||||||
public partial class CpuUsageWindow : Window
|
private readonly RegistryKey key;
|
||||||
|
private readonly PerformanceCounter cpuCounter = new PerformanceCounter();
|
||||||
|
|
||||||
|
public CpuUsageWindow()
|
||||||
{
|
{
|
||||||
private readonly RegistryKey key;
|
InitializeComponent();
|
||||||
private readonly PerformanceCounter cpuCounter = new PerformanceCounter();
|
|
||||||
|
|
||||||
public CpuUsageWindow()
|
Window w = new()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
Top = -100,
|
||||||
|
Left = -100,
|
||||||
|
Width = 0,
|
||||||
|
Height = 0,
|
||||||
|
|
||||||
Window w = new()
|
WindowStyle = WindowStyle.ToolWindow,
|
||||||
{
|
ShowInTaskbar = false
|
||||||
Top = -100,
|
};
|
||||||
Left = -100,
|
w.Show();
|
||||||
Width = 0,
|
Owner = w;
|
||||||
Height = 0,
|
w.Hide();
|
||||||
|
|
||||||
WindowStyle = WindowStyle.ToolWindow,
|
cpuCounter.CategoryName = "Processor";
|
||||||
ShowInTaskbar = false
|
cpuCounter.CounterName = "% Processor Time";
|
||||||
};
|
cpuCounter.InstanceName = "_Total";
|
||||||
w.Show();
|
|
||||||
Owner = w;
|
|
||||||
w.Hide();
|
|
||||||
|
|
||||||
cpuCounter.CategoryName = "Processor";
|
Timer t = new Timer
|
||||||
cpuCounter.CounterName = "% Processor Time";
|
|
||||||
cpuCounter.InstanceName = "_Total";
|
|
||||||
|
|
||||||
Timer t = new Timer
|
|
||||||
{
|
|
||||||
Interval = 100
|
|
||||||
};
|
|
||||||
t.Elapsed += UpdateTimer_Elapsed;
|
|
||||||
t.Start();
|
|
||||||
|
|
||||||
Timer valueTimer = new Timer
|
|
||||||
{
|
|
||||||
Interval = 1000
|
|
||||||
};
|
|
||||||
valueTimer.Elapsed += ValueTimer_Elapsed;
|
|
||||||
|
|
||||||
valueTimer.Start();
|
|
||||||
|
|
||||||
key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName);
|
|
||||||
Top = double.Parse(key.GetValue("CpuUsageWindowTop", 100).ToString());
|
|
||||||
Left = double.Parse(key.GetValue("CpuUsageWindowLeft", 100).ToString());
|
|
||||||
Height = double.Parse(key.GetValue("CpuUsageWindowHeight", 200).ToString());
|
|
||||||
Width = double.Parse(key.GetValue("CpuUsageWindowWidth", 500).ToString());
|
|
||||||
IsEnabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnSourceInitialized(EventArgs e)
|
|
||||||
{
|
{
|
||||||
base.OnSourceInitialized(e);
|
Interval = 100
|
||||||
|
};
|
||||||
|
t.Elapsed += UpdateTimer_Elapsed;
|
||||||
|
t.Start();
|
||||||
|
|
||||||
//Set the window style to noactivate.
|
Timer valueTimer = new Timer
|
||||||
WindowInteropHelper helper = new WindowInteropHelper(this);
|
|
||||||
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
|
|
||||||
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
|
|
||||||
{
|
{
|
||||||
Dispatcher.Invoke(() =>
|
Interval = 1000
|
||||||
{
|
};
|
||||||
if (MainWindow.EditMode)
|
valueTimer.Elapsed += ValueTimer_Elapsed;
|
||||||
{
|
|
||||||
panel.Visibility = Visibility.Visible;
|
|
||||||
tileBar.CaptionHeight = tileBar.CaptionHeight = ActualHeight - 10 < 0 ? 0 : ActualHeight - 10;
|
|
||||||
WindowPos.SetIsLocked(this, false);
|
|
||||||
ResizeMode = ResizeMode.CanResize;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
panel.Visibility = Visibility.Collapsed;
|
|
||||||
tileBar.CaptionHeight = 0;
|
|
||||||
WindowPos.SetIsLocked(this, true);
|
|
||||||
ResizeMode = ResizeMode.NoResize;
|
|
||||||
}
|
|
||||||
|
|
||||||
rectangleGeometry.Rect = new Rect(0, 0, border.ActualWidth, border.ActualHeight);
|
valueTimer.Start();
|
||||||
border.Background = MainWindow.Theme.BackgroundBrush;
|
|
||||||
border.CornerRadius = new CornerRadius(MainWindow.Theme.CornerRadius);
|
|
||||||
viewBox.Margin = new Thickness(MainWindow.Theme.Margin);
|
|
||||||
border.Width = viewBox.ActualWidth + MainWindow.Theme.Margin * 2;
|
|
||||||
border.Height = viewBox.ActualHeight + MainWindow.Theme.Margin * 2;
|
|
||||||
textBlock.FontFamily = new FontFamily(MainWindow.Theme.Font);
|
|
||||||
textBlock.Foreground = MainWindow.Theme.PrimaryBrush;
|
|
||||||
valueTextBlock.FontFamily = new FontFamily(MainWindow.Theme.Font);
|
|
||||||
valueTextBlock.Foreground = MainWindow.Theme.PrimaryBrush;
|
|
||||||
|
|
||||||
ClculateWidth();
|
key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName);
|
||||||
});
|
Top = double.Parse(key.GetValue("CpuUsageWindowTop", 100).ToString());
|
||||||
}
|
Left = double.Parse(key.GetValue("CpuUsageWindowLeft", 100).ToString());
|
||||||
|
Height = double.Parse(key.GetValue("CpuUsageWindowHeight", 200).ToString());
|
||||||
|
Width = double.Parse(key.GetValue("CpuUsageWindowWidth", 500).ToString());
|
||||||
|
IsEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
private void ValueTimer_Elapsed(object sender, ElapsedEventArgs e)
|
protected override void OnSourceInitialized(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnSourceInitialized(e);
|
||||||
|
|
||||||
|
//Set the window style to noactivate.
|
||||||
|
WindowInteropHelper helper = new WindowInteropHelper(this);
|
||||||
|
_ = WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
|
||||||
|
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
string cpuUsage = GetCpuUsage();
|
if (MainWindow.EditMode)
|
||||||
Dispatcher.Invoke(() =>
|
|
||||||
{
|
{
|
||||||
valueTextBlock.Text = cpuUsage;
|
panel.Visibility = Visibility.Visible;
|
||||||
});
|
tileBar.CaptionHeight = tileBar.CaptionHeight = ActualHeight - 10 < 0 ? 0 : ActualHeight - 10;
|
||||||
}
|
WindowPos.SetIsLocked(this, false);
|
||||||
|
ResizeMode = ResizeMode.CanResize;
|
||||||
private void ClculateWidth()
|
}
|
||||||
{
|
else
|
||||||
string template = "CPU: ###%";
|
|
||||||
double lenght = 0;
|
|
||||||
for (int i = 0; i < 9; i++)
|
|
||||||
{
|
{
|
||||||
lenght = Math.Max(StringUtilities.MeasureString(template.Replace('#', i.ToString()[0]), textBlock).Width, lenght);
|
panel.Visibility = Visibility.Collapsed;
|
||||||
|
tileBar.CaptionHeight = 0;
|
||||||
|
WindowPos.SetIsLocked(this, true);
|
||||||
|
ResizeMode = ResizeMode.NoResize;
|
||||||
}
|
}
|
||||||
dockPanel.Width = lenght;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetCpuUsage()
|
rectangleGeometry.Rect = new Rect(0, 0, border.ActualWidth, border.ActualHeight);
|
||||||
{
|
border.Background = MainWindow.Theme.BackgroundBrush;
|
||||||
return $"{(int)cpuCounter.NextValue()}%";
|
border.CornerRadius = new CornerRadius(MainWindow.Theme.CornerRadius);
|
||||||
}
|
viewBox.Margin = new Thickness(MainWindow.Theme.Margin);
|
||||||
|
border.Width = viewBox.ActualWidth + (MainWindow.Theme.Margin * 2);
|
||||||
|
border.Height = viewBox.ActualHeight + (MainWindow.Theme.Margin * 2);
|
||||||
|
textBlock.FontFamily = new FontFamily(MainWindow.Theme.Font);
|
||||||
|
textBlock.Foreground = MainWindow.Theme.PrimaryBrush;
|
||||||
|
valueTextBlock.FontFamily = new FontFamily(MainWindow.Theme.Font);
|
||||||
|
valueTextBlock.Foreground = MainWindow.Theme.PrimaryBrush;
|
||||||
|
|
||||||
private void Window_LocationChanged(object sender, EventArgs e)
|
ClculateWidth();
|
||||||
{
|
});
|
||||||
key.SetValue("CpuUsageWindowTop", Top);
|
}
|
||||||
key.SetValue("CpuUsageWindowLeft", Left);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
private void ValueTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
string cpuUsage = GetCpuUsage();
|
||||||
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
key.SetValue("CpuUsageWindowHeight", Height);
|
valueTextBlock.Text = cpuUsage;
|
||||||
key.SetValue("CpuUsageWindowWidth", Width);
|
});
|
||||||
tileBar.CaptionHeight = ActualHeight - 10;
|
}
|
||||||
|
|
||||||
|
private void ClculateWidth()
|
||||||
|
{
|
||||||
|
string template = "CPU: ###%";
|
||||||
|
double lenght = 0;
|
||||||
|
for (int i = 0; i < 9; i++)
|
||||||
|
{
|
||||||
|
lenght = Math.Max(StringUtilities.MeasureString(template.Replace('#', i.ToString()[0]), textBlock).Width, lenght);
|
||||||
}
|
}
|
||||||
|
dockPanel.Width = lenght;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetCpuUsage()
|
||||||
|
{
|
||||||
|
return $"{(int)cpuCounter.NextValue()}%";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Window_LocationChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
key.SetValue("CpuUsageWindowTop", Top);
|
||||||
|
key.SetValue("CpuUsageWindowLeft", Left);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||||
|
{
|
||||||
|
key.SetValue("CpuUsageWindowHeight", Height);
|
||||||
|
key.SetValue("CpuUsageWindowWidth", Width);
|
||||||
|
tileBar.CaptionHeight = ActualHeight - 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ namespace DesktopMagic.BuiltInWindowElements;
|
|||||||
|
|
||||||
internal class DatePlugin : Plugin
|
internal class DatePlugin : Plugin
|
||||||
{
|
{
|
||||||
[Element("Short date:")]
|
[Element("Short date")]
|
||||||
private readonly CheckBox shortDatecheckBox = new CheckBox(true);
|
private readonly CheckBox shortDatecheckBox = new CheckBox(true);
|
||||||
|
|
||||||
private DateTime oldDateTime = DateTime.MinValue;
|
private DateTime oldDateTime = DateTime.MinValue;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using DesktopMagic.Helpers;
|
using DesktopMagic.Helpers;
|
||||||
|
|
||||||
using DesktopMagicPluginAPI;
|
using DesktopMagicPluginAPI;
|
||||||
|
using DesktopMagicPluginAPI.Inputs;
|
||||||
|
|
||||||
using NAudio.Wave;
|
using NAudio.Wave;
|
||||||
|
|
||||||
@@ -19,6 +20,22 @@ internal class MusicVisualizerPlugin : Plugin
|
|||||||
private readonly SampleAggregator sampleAggregator = new SampleAggregator(fftLength);
|
private readonly SampleAggregator sampleAggregator = new SampleAggregator(fftLength);
|
||||||
|
|
||||||
private readonly Bitmap output = new Bitmap(880, 300);
|
private readonly Bitmap output = new Bitmap(880, 300);
|
||||||
|
|
||||||
|
[Element("Mirror")]
|
||||||
|
private readonly CheckBox mirrorMode = new CheckBox(false);
|
||||||
|
|
||||||
|
[Element("Line")]
|
||||||
|
private readonly CheckBox lineMode = new CheckBox(false);
|
||||||
|
|
||||||
|
[Element("Spectrum Mode")]
|
||||||
|
private readonly ComboBox spectrumMode = new ComboBox("Bottom", "Middle", "Top");
|
||||||
|
|
||||||
|
[Element("Amplification")]
|
||||||
|
private readonly IntegerUpDown amplifierLevel = new IntegerUpDown(-50, 50, 0);
|
||||||
|
|
||||||
|
[Element("Line thickness")]
|
||||||
|
private readonly IntegerUpDown lineThickness = new IntegerUpDown(1, 10, 1);
|
||||||
|
|
||||||
private WasapiLoopbackCapture waveIn;
|
private WasapiLoopbackCapture waveIn;
|
||||||
private volatile bool calculate = true;
|
private volatile bool calculate = true;
|
||||||
private List<double> lastFft = [];
|
private List<double> lastFft = [];
|
||||||
@@ -78,7 +95,7 @@ internal class MusicVisualizerPlugin : Plugin
|
|||||||
v = 20;
|
v = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
int multiplier = 100 - (MainWindow.AmplifierLevel * 2);
|
int multiplier = 100 - (amplifierLevel.Value * 2);
|
||||||
multiplier = multiplier == 0 ? 1 : multiplier;
|
multiplier = multiplier == 0 ? 1 : multiplier;
|
||||||
fft.Add(Math.Abs(e.Result[i].Y * v / multiplier));
|
fft.Add(Math.Abs(e.Result[i].Y * v / multiplier));
|
||||||
}
|
}
|
||||||
@@ -165,12 +182,12 @@ internal class MusicVisualizerPlugin : Plugin
|
|||||||
{
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
if (!MainWindow.MirrorMode && MainWindow.SpectrumMode != 1)
|
if (!mirrorMode.Value && spectrumMode.Value != "Middle")
|
||||||
{
|
{
|
||||||
scaledFft.Insert(0, 0);
|
scaledFft.Insert(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MainWindow.LineMode)
|
if (!lineMode.Value)
|
||||||
{
|
{
|
||||||
offset = 1;
|
offset = 1;
|
||||||
}
|
}
|
||||||
@@ -183,17 +200,18 @@ internal class MusicVisualizerPlugin : Plugin
|
|||||||
int fftIndex = 0;
|
int fftIndex = 0;
|
||||||
bool fftIndexReverse = false;
|
bool fftIndexReverse = false;
|
||||||
|
|
||||||
if (MainWindow.MirrorMode || MainWindow.SpectrumMode == 1)
|
if (mirrorMode.Value || spectrumMode.Value == "Middle")
|
||||||
{
|
{
|
||||||
fftIndex = scaledFft.Count - 1;
|
fftIndex = scaledFft.Count - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int pointIndex = 0; pointIndex < scaledFft.Count; pointIndex += 1)
|
for (int pointIndex = 0; pointIndex < scaledFft.Count; pointIndex += 1)
|
||||||
{
|
{
|
||||||
int value = (int)Math.Max(scaledFft[fftIndex] * 50000, 0);
|
int value = (int)Math.Max(scaledFft[fftIndex] * 50000, 0);
|
||||||
|
|
||||||
switch (MainWindow.SpectrumMode)
|
switch (spectrumMode.Value)
|
||||||
{
|
{
|
||||||
case 1:
|
case "Middle":
|
||||||
|
|
||||||
if (!fftIndexReverse)
|
if (!fftIndexReverse)
|
||||||
{
|
{
|
||||||
@@ -202,7 +220,7 @@ internal class MusicVisualizerPlugin : Plugin
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case "Top":
|
||||||
points[pointIndex + 1] = new PointF(2 * pointIndex, value);
|
points[pointIndex + 1] = new PointF(2 * pointIndex, value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -211,7 +229,7 @@ internal class MusicVisualizerPlugin : Plugin
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MainWindow.MirrorMode || MainWindow.SpectrumMode == 1)
|
if (mirrorMode.Value || spectrumMode.Value == "Middle")
|
||||||
{
|
{
|
||||||
if (!fftIndexReverse)
|
if (!fftIndexReverse)
|
||||||
{
|
{
|
||||||
@@ -231,20 +249,18 @@ internal class MusicVisualizerPlugin : Plugin
|
|||||||
|
|
||||||
SetPoints(points, output.Width, output.Height, offset);
|
SetPoints(points, output.Width, output.Height, offset);
|
||||||
|
|
||||||
Brush brush = MainWindow.MusicVisualzerColor.HasValue
|
Brush brush = new SolidBrush(Application.Theme.PrimaryColor);
|
||||||
? new SolidBrush(MainWindow.MusicVisualzerColor.Value)
|
|
||||||
: new SolidBrush(MainWindow.Theme.PrimaryColor);
|
|
||||||
|
|
||||||
if (MainWindow.LineMode)
|
if (lineMode.Value)
|
||||||
{
|
{
|
||||||
if (MainWindow.SpectrumMode == 1)
|
if (spectrumMode.Value == "Middle")
|
||||||
{
|
{
|
||||||
gr.DrawLines(new Pen(brush), points.Take(points.Length / 2).ToArray());
|
gr.DrawLines(new Pen(brush, lineThickness.Value), points.Take(points.Length / 2).ToArray());
|
||||||
gr.DrawLines(new Pen(brush), points.Skip(points.Length / 2).ToArray());
|
gr.DrawLines(new Pen(brush, lineThickness.Value), points.Skip(points.Length / 2).ToArray());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gr.DrawLines(new Pen(brush), points);
|
gr.DrawLines(new Pen(brush, lineThickness.Value), points);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -263,9 +279,9 @@ internal class MusicVisualizerPlugin : Plugin
|
|||||||
|
|
||||||
private void SetPoints(PointF[] points, int width, int height, int offset)
|
private void SetPoints(PointF[] points, int width, int height, int offset)
|
||||||
{
|
{
|
||||||
switch (MainWindow.SpectrumMode)
|
switch (spectrumMode.Value)
|
||||||
{
|
{
|
||||||
case 1:
|
case "Middle":
|
||||||
points[0] = new PointF(width, height / 2);
|
points[0] = new PointF(width, height / 2);
|
||||||
points[^1] = new PointF(0, height / 2);
|
points[^1] = new PointF(0, height / 2);
|
||||||
|
|
||||||
@@ -273,7 +289,7 @@ internal class MusicVisualizerPlugin : Plugin
|
|||||||
points[(points.Length / 2) - 1] = new PointF(0, height / 2);
|
points[(points.Length / 2) - 1] = new PointF(0, height / 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case "Top":
|
||||||
points[0] = new PointF(0, 0 - offset);
|
points[0] = new PointF(0, 0 - offset);
|
||||||
points[^1] = new PointF(points[^2].X, 0 - offset);
|
points[^1] = new PointF(points[^2].X, 0 - offset);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace DesktopMagic.BuiltInWindowElements;
|
|||||||
|
|
||||||
internal class TimePlugin : Plugin
|
internal class TimePlugin : Plugin
|
||||||
{
|
{
|
||||||
[Element("Display Seconds:")]
|
[Element("Display Seconds")]
|
||||||
private readonly CheckBox displaySecondscheckBox = new CheckBox(true);
|
private readonly CheckBox displaySecondscheckBox = new CheckBox(true);
|
||||||
|
|
||||||
public override int UpdateInterval => 1000;
|
public override int UpdateInterval => 1000;
|
||||||
|
|||||||
@@ -19,12 +19,25 @@
|
|||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Remove="BuiltInWindowElements\CpuUsageWindow.xaml.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="icon.ico" />
|
<None Remove="icon.ico" />
|
||||||
<None Remove="icons8_volunteering_26_85L_icon.ico" />
|
<None Remove="icons8_volunteering_26_85L_icon.ico" />
|
||||||
<None Remove="icon_Dark.ico" />
|
<None Remove="icon_Dark.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Page Remove="BuiltInWindowElements\CpuUsageWindow.xaml" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="BuiltInWindowElements\CpuUsageWindow.xaml" />
|
||||||
|
<None Include="BuiltInWindowElements\CpuUsageWindow.xaml.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AlwaysUpToDate" Version="1.0.0.4" />
|
<PackageReference Include="AlwaysUpToDate" Version="1.0.0.4" />
|
||||||
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.1" />
|
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.1" />
|
||||||
|
|||||||
@@ -31,14 +31,14 @@
|
|||||||
<DockPanel Margin="0,0,2.5,0">
|
<DockPanel Margin="0,0,2.5,0">
|
||||||
<Grid DockPanel.Dock="Top">
|
<Grid DockPanel.Dock="Top">
|
||||||
<Rectangle Grid.Row="1" Fill="#FFECECEC" Height="24" />
|
<Rectangle Grid.Row="1" Fill="#FFECECEC" Height="24" />
|
||||||
<CheckBox x:Name="EditCheckBox" VerticalAlignment="Center" Grid.Row="1" Content="{DynamicResource edit}" Click="EditCheckBox_Click" Foreground="Black" BorderBrush="#FF323232" Style="{StaticResource MaterialDesignDarkCheckBox}" IsChecked="True"/>
|
<CheckBox x:Name="EditCheckBox" VerticalAlignment="Center" Grid.Row="1" Content="{DynamicResource edit}" Click="EditCheckBox_Click" Foreground="Black" BorderBrush="#FF323232" Style="{StaticResource MaterialDesignDarkCheckBox}" IsChecked="True" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<ScrollViewer Background="#FFBBBBBB" PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
|
<ScrollViewer Background="#FFBBBBBB" PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
|
||||||
<StackPanel x:Name="stackPanel">
|
<StackPanel x:Name="stackPanel">
|
||||||
<CheckBox x:Name="TimeCb" Content="{DynamicResource time}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
|
<CheckBox x:Name="TimeCb" Content="{DynamicResource time}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
|
||||||
<CheckBox x:Name="DateCb" Content="{DynamicResource date}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
|
<CheckBox x:Name="DateCb" Content="{DynamicResource date}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
|
||||||
<CheckBox x:Name="CpuUsageCb" Content="{DynamicResource cpuUsage}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
|
<CheckBox x:Name="CpuUsageCb" Content="{DynamicResource cpuUsage}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
|
||||||
<CheckBox x:Name="CalendarCb" Content="{DynamicResource googleCalendar}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" Visibility="Collapsed"/>
|
<CheckBox x:Name="CalendarCb" Content="{DynamicResource googleCalendar}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" Visibility="Collapsed" />
|
||||||
<!--Currently disabled because it's not working-->
|
<!--Currently disabled because it's not working-->
|
||||||
<CheckBox x:Name="MusicVisualizerCb" Content="{DynamicResource musicVisualizer}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
|
<CheckBox x:Name="MusicVisualizerCb" Content="{DynamicResource musicVisualizer}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -46,24 +46,10 @@
|
|||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|
||||||
<DockPanel Grid.Column="1" Margin="2.5,0,0,0">
|
<DockPanel Grid.Column="1" Margin="2.5,0,0,0">
|
||||||
<ComboBox x:Name="optionsComboBox" DockPanel.Dock="Top" Height="24" SelectedIndex="0" SelectionChanged="OptionsComboBox_SelectionChanged" Background="#FFECECEC" Padding="4" VerticalAlignment="Center"/>
|
<ComboBox x:Name="optionsComboBox" DockPanel.Dock="Top" Height="24" SelectedIndex="0" SelectionChanged="OptionsComboBox_SelectionChanged" Background="#FFECECEC" Padding="4" VerticalAlignment="Center" />
|
||||||
<ScrollViewer Background="#FFBBBBBB">
|
<ScrollViewer Background="#FFBBBBBB">
|
||||||
<Grid>
|
<Grid>
|
||||||
<StackPanel x:Name="optionsPanel" Margin="3,3,3,0" HorizontalAlignment="Stretch" Visibility="Collapsed" >
|
<StackPanel x:Name="optionsPanel" Margin="3,3,3,0" HorizontalAlignment="Stretch" Visibility="Collapsed">
|
||||||
</StackPanel>
|
|
||||||
<StackPanel x:Name="musicVisualizerOptionsPanel" Margin="3,3,3,0">
|
|
||||||
<Label Content="{DynamicResource color}" HorizontalAlignment="Left" VerticalAlignment="Top" Padding="0,1" />
|
|
||||||
<TextBox x:Name="musicVisualizerColorTextBox" Text="" TextChanged="MusicVisualizerColorTextBox_TextChanged" MaxLength="7" CharacterCasing="Upper">
|
|
||||||
<materialDesign:TextFieldAssist.CharacterCounterStyle>
|
|
||||||
<Style TargetType="TextBlock" />
|
|
||||||
</materialDesign:TextFieldAssist.CharacterCounterStyle>
|
|
||||||
</TextBox>
|
|
||||||
<ComboBox x:Name="spectrumModeComboBox" ItemsSource="{DynamicResource musicVisualizerOptionsComboboxItems}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" SelectionChanged="SpectrumModeComboBox_SelectionChanged" />
|
|
||||||
<CheckBox x:Name="mirrorModeCheckBox" Content="{DynamicResource mirrorMode}" Click="MirrorModeCheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
|
|
||||||
<CheckBox x:Name="lineModeCheckBox" Content="{DynamicResource lineMode}" Click="LineModeCheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
|
|
||||||
<Label Content="{DynamicResource amplifier}" HorizontalAlignment="Left" VerticalAlignment="Top" Padding="0,1" />
|
|
||||||
<Slider x:Name="amplifierLevelSlider" HorizontalAlignment="Stretch" VerticalAlignment="Top" ValueChanged="AmplifierLevelSlider_ValueChanged" Maximum="50" Minimum="-50" SmallChange="1" LargeChange="5" Foreground="Gray" />
|
|
||||||
<Label x:Name="amplifierLevelLabel" Content="Label" HorizontalAlignment="Left" VerticalAlignment="Top" Padding="0,1" />
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
@@ -75,20 +61,20 @@
|
|||||||
<RowDefinition Height="110" />
|
<RowDefinition Height="110" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition />
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid Grid.Column="0" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch">
|
<Grid Grid.Column="0" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<TextBlock Text="Display Font: " Grid.Column="0" Grid.Row="0" VerticalAlignment="Center"></TextBlock>
|
<TextBlock Text="Display Font: " Grid.Column="0" Grid.Row="0" VerticalAlignment="Center"></TextBlock>
|
||||||
<ComboBox x:Name="fontComboBox" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Top" SelectionChanged="FontComboBox_SelectionChanged" Margin="0,0,0,5" />
|
<ComboBox x:Name="fontComboBox" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Top" SelectionChanged="FontComboBox_SelectionChanged" Margin="0,0,0,5" />
|
||||||
|
|
||||||
@@ -111,7 +97,7 @@
|
|||||||
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
|
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
|
||||||
<Rectangle x:Name="primaryColorRechtangle" Fill="White" />
|
<Rectangle x:Name="primaryColorRechtangle" Fill="White" />
|
||||||
</Border>
|
</Border>
|
||||||
<Button Content="Change Primary Color" Height="23" FontSize="12" FontWeight="Regular" Click="ChangePrimaryColorButton_Click"/>
|
<Button Content="Change Primary Color" Height="23" FontSize="12" FontWeight="Regular" Click="ChangePrimaryColorButton_Click" />
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
<DockPanel Margin="0,0,0,5">
|
<DockPanel Margin="0,0,0,5">
|
||||||
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
|
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
|
||||||
|
|||||||
@@ -25,21 +25,11 @@ namespace DesktopMagic
|
|||||||
{
|
{
|
||||||
#region Global settings
|
#region Global settings
|
||||||
|
|
||||||
public static bool EditMode { get; private set; } = false;
|
|
||||||
internal static Theme Theme { get; } = new Theme();
|
internal static Theme Theme { get; } = new Theme();
|
||||||
|
internal static bool EditMode { get; private set; } = false;
|
||||||
|
|
||||||
#endregion Global settings
|
#endregion Global settings
|
||||||
|
|
||||||
#region Music Visualizer Settings
|
|
||||||
|
|
||||||
public static int SpectrumMode { get; private set; } = 0;
|
|
||||||
public static int AmplifierLevel { get; private set; } = 0;
|
|
||||||
public static bool MirrorMode { get; private set; } = false;
|
|
||||||
public static bool LineMode { get; private set; } = false;
|
|
||||||
public static System.Drawing.Color? MusicVisualzerColor { get; private set; }
|
|
||||||
|
|
||||||
#endregion Music Visualizer Settings
|
|
||||||
|
|
||||||
#region Plugins settings
|
#region Plugins settings
|
||||||
|
|
||||||
internal static Dictionary<string, List<SettingElement>> PluginsSettings { get; } = [];
|
internal static Dictionary<string, List<SettingElement>> PluginsSettings { get; } = [];
|
||||||
@@ -336,80 +326,6 @@ namespace DesktopMagic
|
|||||||
|
|
||||||
#region Options
|
#region Options
|
||||||
|
|
||||||
private void AmplifierLevelSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
|
||||||
{
|
|
||||||
amplifierLevelLabel.Content = (int)amplifierLevelSlider.Value;
|
|
||||||
AmplifierLevel = (int)amplifierLevelSlider.Value;
|
|
||||||
key.SetValue("AmplifierLevel", AmplifierLevel);
|
|
||||||
SaveLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MirrorModeCheckBox_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
MirrorMode = (bool)mirrorModeCheckBox.IsChecked;
|
|
||||||
key.SetValue("MirrorMode", mirrorModeCheckBox.IsChecked.ToString());
|
|
||||||
SaveLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LineModeCheckBox_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
LineMode = (bool)lineModeCheckBox.IsChecked;
|
|
||||||
key.SetValue("LineMode", lineModeCheckBox.IsChecked.ToString());
|
|
||||||
SaveLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MusicVisualizerColorTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrWhiteSpace(musicVisualizerColorTextBox.Text) && musicVisualizerColorTextBox.Text != "Default")
|
|
||||||
{
|
|
||||||
if (musicVisualizerColorTextBox.Text.Length > 0)
|
|
||||||
{
|
|
||||||
if (musicVisualizerColorTextBox.Text[0] != '#')
|
|
||||||
{
|
|
||||||
musicVisualizerColorTextBox.Text = "#" + musicVisualizerColorTextBox.Text.Replace("#", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
musicVisualizerColorTextBox.Text = "#";
|
|
||||||
musicVisualizerColorTextBox.Select(musicVisualizerColorTextBox.Text.Length, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (musicVisualizerColorTextBox.SelectionStart == 0)
|
|
||||||
{
|
|
||||||
if (musicVisualizerColorTextBox.Text.Length <= 2)
|
|
||||||
{
|
|
||||||
musicVisualizerColorTextBox.Select(musicVisualizerColorTextBox.Text.Length, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
musicVisualizerColorTextBox.Select(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
string hex = musicVisualizerColorTextBox.Text;
|
|
||||||
|
|
||||||
if (MultiColorConverter.TryConvertToSystemColor(hex, out System.Drawing.Color systemColor))
|
|
||||||
{
|
|
||||||
MusicVisualzerColor = systemColor;
|
|
||||||
musicVisualizerColorTextBox.Foreground = Brushes.Black;
|
|
||||||
|
|
||||||
key.SetValue("MusicVisualizerColor", musicVisualizerColorTextBox.Text);
|
|
||||||
SaveLayout();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
musicVisualizerColorTextBox.Foreground = Brushes.Red;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MusicVisualzerColor = null;
|
|
||||||
key.SetValue("MusicVisualizerColor", musicVisualizerColorTextBox.Text);
|
|
||||||
SaveLayout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FontComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void FontComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
Theme.Font = fontComboBox.SelectedValue.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");
|
Theme.Font = fontComboBox.SelectedValue.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");
|
||||||
@@ -417,60 +333,44 @@ namespace DesktopMagic
|
|||||||
SaveLayout();
|
SaveLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SpectrumModeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
SpectrumMode = spectrumModeComboBox.SelectedIndex;
|
|
||||||
key.SetValue("SpectrumMode", spectrumModeComboBox.SelectedIndex);
|
|
||||||
|
|
||||||
mirrorModeCheckBox.IsEnabled = spectrumModeComboBox.SelectedIndex != 1;
|
|
||||||
SaveLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OptionsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void OptionsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (optionsComboBox.SelectedIndex < 1)
|
optionsPanel.Visibility = Visibility.Visible;
|
||||||
|
optionsPanel.Children.Clear();
|
||||||
|
optionsPanel.UpdateLayout();
|
||||||
|
|
||||||
|
if (optionsComboBox.SelectedItem is null)
|
||||||
{
|
{
|
||||||
if (musicVisualizerOptionsPanel != null)
|
return;
|
||||||
{
|
|
||||||
musicVisualizerOptionsPanel.Visibility = Visibility.Visible;
|
|
||||||
optionsPanel.Visibility = Visibility.Collapsed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
bool success = PluginsSettings.TryGetValue(optionsComboBox.SelectedItem.ToString(), out List<SettingElement> settingElements);
|
||||||
|
if (!success || settingElements is null || settingElements.Count == 0)
|
||||||
{
|
{
|
||||||
musicVisualizerOptionsPanel.Visibility = Visibility.Collapsed;
|
_ = optionsPanel.Children.Add(new TextBlock() { Text = (string)FindResource("noOptions") });
|
||||||
optionsPanel.Visibility = Visibility.Visible;
|
return;
|
||||||
optionsPanel.Children.Clear();
|
}
|
||||||
optionsPanel.UpdateLayout();
|
|
||||||
|
|
||||||
bool success = PluginsSettings.TryGetValue(optionsComboBox.SelectedItem.ToString(), out List<SettingElement> settingElements);
|
SettingElementGenerator settingElementGenerator = new SettingElementGenerator(optionsComboBox);
|
||||||
if (!success || settingElements is null || settingElements.Count == 0)
|
|
||||||
|
foreach (SettingElement settingElement in settingElements)
|
||||||
|
{
|
||||||
|
DockPanel dockPanel = new()
|
||||||
{
|
{
|
||||||
_ = optionsPanel.Children.Add(new TextBlock() { Text = (string)FindResource("noOptions") });
|
LastChildFill = true,
|
||||||
return;
|
HorizontalAlignment = HorizontalAlignment.Stretch
|
||||||
}
|
};
|
||||||
|
_ = optionsPanel.Children.Add(dockPanel);
|
||||||
|
|
||||||
SettingElementGenerator settingElementGenerator = new SettingElementGenerator(optionsComboBox);
|
TextBlock textBlock = new()
|
||||||
|
|
||||||
foreach (SettingElement settingElement in settingElements)
|
|
||||||
{
|
{
|
||||||
DockPanel dockPanel = new()
|
Text = $"{settingElement.Name}:",
|
||||||
{
|
Padding = new Thickness(0, 0, 3, 0),
|
||||||
LastChildFill = true,
|
VerticalAlignment = VerticalAlignment.Center
|
||||||
HorizontalAlignment = HorizontalAlignment.Stretch
|
};
|
||||||
};
|
|
||||||
_ = optionsPanel.Children.Add(dockPanel);
|
|
||||||
|
|
||||||
TextBlock textBlock = new()
|
_ = dockPanel.Children.Add(textBlock);
|
||||||
{
|
settingElementGenerator.Generate(settingElement, dockPanel, textBlock);
|
||||||
Text = settingElement.Name,
|
|
||||||
Padding = new Thickness(0, 0, 3, 0),
|
|
||||||
VerticalAlignment = VerticalAlignment.Center
|
|
||||||
};
|
|
||||||
|
|
||||||
_ = dockPanel.Children.Add(textBlock);
|
|
||||||
settingElementGenerator.Generate(settingElement, dockPanel, textBlock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -689,11 +589,6 @@ namespace DesktopMagic
|
|||||||
private void LoadLayout(bool minimize = true)
|
private void LoadLayout(bool minimize = true)
|
||||||
{
|
{
|
||||||
Theme.Font = key.GetValue("Font", "Segoe UI").ToString();
|
Theme.Font = key.GetValue("Font", "Segoe UI").ToString();
|
||||||
spectrumModeComboBox.SelectedIndex = int.Parse(key.GetValue("SpectrumMode", "0").ToString(), CultureInfo.InvariantCulture);
|
|
||||||
amplifierLevelSlider.Value = int.Parse(key.GetValue("AmplifierLevel", "0").ToString(), CultureInfo.InvariantCulture);
|
|
||||||
mirrorModeCheckBox.IsChecked = bool.Parse(key.GetValue("MirrorMode", "false").ToString());
|
|
||||||
lineModeCheckBox.IsChecked = bool.Parse(key.GetValue("LineMode", "false").ToString());
|
|
||||||
musicVisualizerColorTextBox.Text = key.GetValue("MusicVisualizerColor", "").ToString();
|
|
||||||
cornerRadiusTextBox.Text = key.GetValue("CornerRadius", "0").ToString();
|
cornerRadiusTextBox.Text = key.GetValue("CornerRadius", "0").ToString();
|
||||||
marginTextBox.Text = key.GetValue("Margin", "0").ToString();
|
marginTextBox.Text = key.GetValue("Margin", "0").ToString();
|
||||||
blockWindowsClosing = false;
|
blockWindowsClosing = false;
|
||||||
@@ -722,11 +617,6 @@ namespace DesktopMagic
|
|||||||
secondaryColorRechtangle.Fill = Theme.SecondaryBrush;
|
secondaryColorRechtangle.Fill = Theme.SecondaryBrush;
|
||||||
backgroundColorRechtangle.Fill = Theme.BackgroundBrush;
|
backgroundColorRechtangle.Fill = Theme.BackgroundBrush;
|
||||||
|
|
||||||
MusicVisualizerColorTextBox_TextChanged(null, null);
|
|
||||||
MirrorModeCheckBox_Click(null, null);
|
|
||||||
LineModeCheckBox_Click(null, null);
|
|
||||||
SpectrumModeComboBox_SelectionChanged(null, null);
|
|
||||||
AmplifierLevelSlider_ValueChanged(null, null);
|
|
||||||
CornerRadiusTextBox_TextChanged(null, null);
|
CornerRadiusTextBox_TextChanged(null, null);
|
||||||
MarginTextBox_TextChanged(null, null);
|
MarginTextBox_TextChanged(null, null);
|
||||||
|
|
||||||
|
|||||||
@@ -44,14 +44,6 @@ public class IntegerUpDown : Element
|
|||||||
/// <exception cref="ArgumentException"></exception>
|
/// <exception cref="ArgumentException"></exception>
|
||||||
public IntegerUpDown(int min, int max, int value = 0)
|
public IntegerUpDown(int min, int max, int value = 0)
|
||||||
{
|
{
|
||||||
if (min < 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Value can not be negative!", nameof(min));
|
|
||||||
}
|
|
||||||
if (max < 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Value can not be negative!", nameof(max));
|
|
||||||
}
|
|
||||||
if (min > max)
|
if (min > max)
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"{nameof(min)} is greater than or equal to {nameof(max)}!");
|
throw new ArgumentException($"{nameof(min)} is greater than or equal to {nameof(max)}!");
|
||||||
|
|||||||
@@ -43,14 +43,6 @@ public sealed class Slider : Element
|
|||||||
/// <param name="value">The value assigned to the <see cref="Slider"/> element.</param>
|
/// <param name="value">The value assigned to the <see cref="Slider"/> element.</param>
|
||||||
public Slider(double min, double max, double value = 0)
|
public Slider(double min, double max, double value = 0)
|
||||||
{
|
{
|
||||||
if (min < 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Value can not be negative!", nameof(min));
|
|
||||||
}
|
|
||||||
if (max < 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Value can not be negative!", nameof(max));
|
|
||||||
}
|
|
||||||
if (min > max)
|
if (min > max)
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"{nameof(min)} is greater than or equal to {nameof(max)}!");
|
throw new ArgumentException($"{nameof(min)} is greater than or equal to {nameof(max)}!");
|
||||||
|
|||||||
Reference in New Issue
Block a user