diff --git a/src/DesktopMagic/BuiltInWindowElements/DatePlugin.cs b/src/DesktopMagic/BuiltInWindowElements/DatePlugin.cs index 06d6a57..460921d 100644 --- a/src/DesktopMagic/BuiltInWindowElements/DatePlugin.cs +++ b/src/DesktopMagic/BuiltInWindowElements/DatePlugin.cs @@ -1,50 +1,54 @@ using DesktopMagicPluginAPI; +using DesktopMagicPluginAPI.Inputs; using System; using System.Drawing; using System.Drawing.Text; -namespace DesktopMagic.BuiltInWindowElements +namespace DesktopMagic.BuiltInWindowElements; + +internal class DatePlugin : Plugin { - internal class DatePlugin : Plugin + [Element("Short date:")] + private readonly CheckBox shortDatecheckBox = new CheckBox(true); + + private DateTime oldDateTime = DateTime.MinValue; + private Color oldColor = Color.White; + private string oldFont; + private bool oldShortDatecheckBoxValue; + public override int UpdateInterval => 1000; + + public override Bitmap Main() { - public override int UpdateInterval => 1000; - - private DateTime oldDateTime = new DateTime(); - private Color oldColor = Color.White; - private string oldFont; - - public override Bitmap Main() + if (oldDateTime.Date == DateTime.Now.Date && oldColor == Application.Theme.PrimaryColor && oldFont == Application.Theme.Font && oldShortDatecheckBoxValue == shortDatecheckBox.Value) { - if (oldDateTime.Date == DateTime.Now.Date && oldColor == Application.Theme.PrimaryColor && oldFont == Application.Theme.Font) - { - return null; - } - - oldDateTime = DateTime.Now; - oldColor = Application.Theme.PrimaryColor; - oldFont = Application.Theme.Font; - - string date = DateTime.Now.ToLongDateString(); - - Font font = new Font(Application.Theme.Font, 200); - - Bitmap bmp = new Bitmap(1, 1); - bmp.SetResolution(100, 100); - using Graphics tmpGr = Graphics.FromImage(bmp); - tmpGr.TextRenderingHint = TextRenderingHint.AntiAlias; - - SizeF size = tmpGr.MeasureString(date, font); - - bmp = new Bitmap((int)size.Width, (int)size.Height); - bmp.SetResolution(100, 100); - - using Graphics gr = Graphics.FromImage(bmp); - - gr.TextRenderingHint = TextRenderingHint.AntiAlias; - gr.DrawString(date, font, new SolidBrush(Application.Theme.PrimaryColor), 0, 0); - - return bmp; + return null; } + + oldDateTime = DateTime.Now; + oldColor = Application.Theme.PrimaryColor; + oldFont = Application.Theme.Font; + oldShortDatecheckBoxValue = shortDatecheckBox.Value; + + string date = shortDatecheckBox.Value ? DateTime.Now.ToShortDateString() : DateTime.Now.ToLongDateString(); + + Font font = new Font(Application.Theme.Font, 200); + + Bitmap bmp = new Bitmap(1, 1); + bmp.SetResolution(100, 100); + using Graphics tmpGr = Graphics.FromImage(bmp); + tmpGr.TextRenderingHint = TextRenderingHint.AntiAlias; + + SizeF size = tmpGr.MeasureString(date, font); + + bmp = new Bitmap((int)size.Width, (int)size.Height); + bmp.SetResolution(100, 100); + + using Graphics gr = Graphics.FromImage(bmp); + + gr.TextRenderingHint = TextRenderingHint.AntiAlias; + gr.DrawString(date, font, new SolidBrush(Application.Theme.PrimaryColor), 0, 0); + + return bmp; } } \ No newline at end of file diff --git a/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerPlugin.cs b/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerPlugin.cs index 42e0417..95eea84 100644 --- a/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerPlugin.cs +++ b/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerPlugin.cs @@ -1,4 +1,6 @@ -using DesktopMagicPluginAPI; +using DesktopMagic.Helpers; + +using DesktopMagicPluginAPI; using NAudio.Wave; @@ -7,279 +9,279 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; -namespace DesktopMagic.BuiltInWindowElements +namespace DesktopMagic.BuiltInWindowElements; + +internal class MusicVisualizerPlugin : Plugin { - internal class MusicVisualizerPlugin : Plugin + private const int fftLength = 1024; + + // NAudio fft wants powers of two! + private readonly SampleAggregator sampleAggregator = new SampleAggregator(fftLength); + + private readonly Bitmap output = new Bitmap(880, 300); + private WasapiLoopbackCapture waveIn; + private volatile bool calculate = true; + private List lastFft = []; + public override int UpdateInterval => 0; + + public override void Start() { - private IWaveIn waveIn; - private const int fftLength = 1024; // NAudio fft wants powers of two! - private readonly SampleAggregator sampleAggregator = new SampleAggregator(fftLength); - private volatile bool calculate = true; - private readonly Bitmap output = new Bitmap(880, 300); + sampleAggregator.FftCalculated += FftCalculated; + sampleAggregator.PerformFFT = true; - public override int UpdateInterval => 0; + waveIn = new WasapiLoopbackCapture(); - public override void Start() + waveIn.DataAvailable += OnDataAvailable; + waveIn.StartRecording(); + } + + public override Bitmap Main() + { + return output; + } + + public override void Stop() + { + calculate = false; + waveIn?.StopRecording(); + } + + private void OnDataAvailable(object sender, WaveInEventArgs e) + { + if (calculate) { - sampleAggregator.FftCalculated += FftCalculated; - sampleAggregator.PerformFFT = true; + byte[] buffer = e.Buffer; + int bytesRecorded = e.BytesRecorded; + int bufferIncrement = waveIn.WaveFormat.BlockAlign; - waveIn = new WasapiLoopbackCapture(); + for (int index = 0; index < bytesRecorded; index += bufferIncrement) + { + float sample32 = BitConverter.ToSingle(buffer, index); + sampleAggregator.Add(sample32); + } + } + } - waveIn.DataAvailable += OnDataAvailable; - waveIn.StartRecording(); + private void FftCalculated(object sender, FftEventArgs e) + { + if (!calculate) + { + return; } - private void OnDataAvailable(object sender, WaveInEventArgs e) + List fft = []; + for (int i = 0; i < (e.Result.Length / 2) - 70; i++) { - if (calculate) + int v = i; + if (v < 20) { - byte[] buffer = e.Buffer; - int bytesRecorded = e.BytesRecorded; - int bufferIncrement = waveIn.WaveFormat.BlockAlign; + v = 20; + } - for (int index = 0; index < bytesRecorded; index += bufferIncrement) + int multiplier = 100 - (MainWindow.AmplifierLevel * 2); + multiplier = multiplier == 0 ? 1 : multiplier; + fft.Add(Math.Abs(e.Result[i].Y * v / multiplier)); + } + + if (lastFft.Count != 0) + { + for (int i = 0; i < fft.Count; i++) + { + if (fft[i] > lastFft[i]) { - float sample32 = BitConverter.ToSingle(buffer, index); - sampleAggregator.Add(sample32); + fft[i] = (fft[i] + lastFft[i]) / 2.05; + } + else + { + fft[i] = lastFft[i] - 0.0005; } } } - private List lastFft = new List(); + int barCount = 0; + List scaledFft = []; - private void FftCalculated(object sender, FftEventArgs e) + if (barCount > 0) { - if (!calculate) + int count = fft.Count / barCount; + Console.WriteLine(count); + for (int i = 0; i < barCount; i++) { - return; - } - - List fft = new List(); - for (int i = 0; i < (e.Result.Length / 2) - 70; i++) - { - int v = i; - if (v < 20) + double temp = 0; + int j; + for (j = i * count; j < count + (i * count); j++) { - v = 20; + temp += fft[j]; } - int multiplier = 100 - (MainWindow.AmplifierLevel * 2); - multiplier = multiplier == 0 ? 1 : multiplier; - fft.Add(Math.Abs(e.Result[i].Y * v / multiplier)); + scaledFft.Add(temp); } + } + else + { + scaledFft.AddRange(fft); + } - if (lastFft.Count != 0) + #region flatten + + int flattenValue = 4; + + for (int i = 0; i < scaledFft.Count; i++) + { + if (flattenValue > 0) { - for (int i = 0; i < fft.Count; i++) + double temp = 0; + for (int j = 0; j < flattenValue; j++) { - if (fft[i] > lastFft[i]) + if (i + j < scaledFft.Count) { - fft[i] = (fft[i] + lastFft[i]) / 2.05; - } - else - { - fft[i] = lastFft[i] - 0.0005; + temp += scaledFft[i + j]; } } + scaledFft[i] = temp / flattenValue; } + } - int barCount = 0; - List scaledFft = new List(); - - if (barCount > 0) + for (int i = 0; i < scaledFft.Count; i++) + { + if (flattenValue > 0) { - int count = fft.Count / barCount; - Console.WriteLine(count); - for (int i = 0; i < barCount; i++) + double temp = 0; + for (int j = 0; j < flattenValue; j++) { - double temp = 0; - int j; - for (j = i * count; j < count + (i * count); j++) + if (i - j >= 0) { - temp += fft[j]; + temp += scaledFft[i - j]; } - - scaledFft.Add(temp); } + scaledFft[i] = temp / flattenValue; } - else + } + + #endregion flatten + + lastFft = fft; + try + { + int offset = 0; + + if (!MainWindow.MirrorMode && MainWindow.SpectrumMode != 1) { - scaledFft.AddRange(fft); + scaledFft.Insert(0, 0); } - #region flatten - - int flattenValue = 4; - - for (int i = 0; i < scaledFft.Count; i++) + if (!MainWindow.LineMode) { - if (flattenValue > 0) + offset = 1; + } + + using (Graphics gr = Graphics.FromImage(output)) + { + gr.Clear(Color.Transparent); + PointF[] points = new PointF[scaledFft.Count + 2]; + + int fftIndex = 0; + bool fftIndexReverse = false; + + if (MainWindow.MirrorMode || MainWindow.SpectrumMode == 1) { - double temp = 0; - for (int j = 0; j < flattenValue; j++) + fftIndex = scaledFft.Count - 1; + } + for (int pointIndex = 0; pointIndex < scaledFft.Count; pointIndex += 1) + { + int value = (int)Math.Max(scaledFft[fftIndex] * 50000, 0); + + switch (MainWindow.SpectrumMode) { - if (i + j < scaledFft.Count) - { - temp += scaledFft[i + j]; - } + case 1: + + if (!fftIndexReverse) + { + points[pointIndex + 1] = new PointF(output.Width - (4 * pointIndex), (output.Height / 2) + value); + points[(points.Length / 2) + pointIndex + 1] = new PointF(output.Width - (4 * pointIndex), (output.Height / 2) - value); + } + break; + + case 2: + points[pointIndex + 1] = new PointF(2 * pointIndex, value); + break; + + default: + points[pointIndex + 1] = new PointF(2 * pointIndex, output.Height - value - 1 + offset); + break; } - scaledFft[i] = temp / flattenValue; - } - } - - for (int i = 0; i < scaledFft.Count; i++) - { - if (flattenValue > 0) - { - double temp = 0; - for (int j = 0; j < flattenValue; j++) - { - if (i - j >= 0) - { - temp += scaledFft[i - j]; - } - } - scaledFft[i] = temp / flattenValue; - } - } - - #endregion flatten - - lastFft = fft; - try - { - int offset = 0; - - if (!MainWindow.MirrorMode && MainWindow.SpectrumMode != 1) - { - scaledFft.Insert(0, 0); - } - - if (!MainWindow.LineMode) - { - offset = 1; - } - - using (Graphics gr = Graphics.FromImage(output)) - { - gr.Clear(Color.Transparent); - PointF[] points = new PointF[scaledFft.Count + 2]; - - int fftIndex = 0; - bool fftIndexReverse = false; if (MainWindow.MirrorMode || MainWindow.SpectrumMode == 1) { - fftIndex = scaledFft.Count - 1; - } - for (int pointIndex = 0; pointIndex < scaledFft.Count; pointIndex += 1) - { - int value = (int)Math.Max(scaledFft[fftIndex] * 50000, 0); - - switch (MainWindow.SpectrumMode) + if (!fftIndexReverse) { - case 1: - - if (!fftIndexReverse) - { - points[pointIndex + 1] = new PointF(output.Width - (4 * pointIndex), (output.Height / 2) + value); - points[(points.Length / 2) + pointIndex + 1] = new PointF(output.Width - (4 * pointIndex), (output.Height / 2) - value); - } - break; - - case 2: - points[pointIndex + 1] = new PointF(2 * pointIndex, value); - break; - - default: - points[pointIndex + 1] = new PointF(2 * pointIndex, output.Height - value - 1 + offset); - break; + fftIndex -= 2; } - - if (MainWindow.MirrorMode || MainWindow.SpectrumMode == 1) + if (fftIndex <= 0 || fftIndexReverse) { - if (!fftIndexReverse) - { - fftIndex -= 2; - } - if (fftIndex <= 0 || fftIndexReverse) - { - fftIndexReverse = true; - fftIndex += 2; - } - } - else - { - fftIndex++; - } - } - - SetPoints(points, output.Width, output.Height, offset); - - Brush brush = MainWindow.MusicVisualzerColor.HasValue - ? new SolidBrush(MainWindow.MusicVisualzerColor.Value) - : new SolidBrush(MainWindow.Theme.PrimaryColor); - - if (MainWindow.LineMode) - { - if (MainWindow.SpectrumMode == 1) - { - gr.DrawLines(new Pen(brush), points.Take(points.Length / 2).ToArray()); - gr.DrawLines(new Pen(brush), points.Skip(points.Length / 2).ToArray()); - } - else - { - gr.DrawLines(new Pen(brush), points); + fftIndexReverse = true; + fftIndex += 2; } } else { - gr.FillPolygon(brush, points); + fftIndex++; } } - Application.UpdateWindow(); - } - catch (Exception ex) - { - App.Logger.Log(ex.Message, "Music Visualizer", LogSeverity.Error); + SetPoints(points, output.Width, output.Height, offset); + + Brush brush = MainWindow.MusicVisualzerColor.HasValue + ? new SolidBrush(MainWindow.MusicVisualzerColor.Value) + : new SolidBrush(MainWindow.Theme.PrimaryColor); + + if (MainWindow.LineMode) + { + if (MainWindow.SpectrumMode == 1) + { + gr.DrawLines(new Pen(brush), points.Take(points.Length / 2).ToArray()); + gr.DrawLines(new Pen(brush), points.Skip(points.Length / 2).ToArray()); + } + else + { + gr.DrawLines(new Pen(brush), points); + } + } + else + { + gr.FillPolygon(brush, points); + } } + + Application.UpdateWindow(); } - - private void SetPoints(PointF[] points, int width, int height, int offset) + catch (Exception ex) { - switch (MainWindow.SpectrumMode) - { - case 1: - points[0] = new PointF(width, height / 2); - points[^1] = new PointF(0, height / 2); - - points[points.Length / 2] = new PointF(width, height / 2); - points[(points.Length / 2) - 1] = new PointF(0, height / 2); - break; - - case 2: - points[0] = new PointF(0, 0 - offset); - points[^1] = new PointF(points[^2].X, 0 - offset); - break; - - default: - points[0] = new PointF(0, height); - points[^1] = new PointF(points[^2].X, height); - break; - } + App.Logger.Log(ex.Message, "Music Visualizer", LogSeverity.Error); } + } - public override Bitmap Main() + private void SetPoints(PointF[] points, int width, int height, int offset) + { + switch (MainWindow.SpectrumMode) { - return output; - } + case 1: + points[0] = new PointF(width, height / 2); + points[^1] = new PointF(0, height / 2); - public override void Stop() - { - calculate = false; - waveIn?.StopRecording(); + points[points.Length / 2] = new PointF(width, height / 2); + points[(points.Length / 2) - 1] = new PointF(0, height / 2); + break; + + case 2: + points[0] = new PointF(0, 0 - offset); + points[^1] = new PointF(points[^2].X, 0 - offset); + break; + + default: + points[0] = new PointF(0, height); + points[^1] = new PointF(points[^2].X, height); + break; } } } \ No newline at end of file diff --git a/src/DesktopMagic/BuiltInWindowElements/TimePlugin.cs b/src/DesktopMagic/BuiltInWindowElements/TimePlugin.cs index 640e6ef..07d375d 100644 --- a/src/DesktopMagic/BuiltInWindowElements/TimePlugin.cs +++ b/src/DesktopMagic/BuiltInWindowElements/TimePlugin.cs @@ -1,55 +1,40 @@ using DesktopMagicPluginAPI; -using DesktopMagicPluginAPI.Drawing; using DesktopMagicPluginAPI.Inputs; using System; using System.Drawing; using System.Drawing.Text; -namespace DesktopMagic.BuiltInWindowElements +namespace DesktopMagic.BuiltInWindowElements; + +internal class TimePlugin : Plugin { - internal class TimePlugin : Plugin + [Element("Display Seconds:")] + private readonly CheckBox displaySecondscheckBox = new CheckBox(true); + + public override int UpdateInterval => 1000; + + public override Bitmap Main() { - [Element("Display Seconds:")] - private readonly CheckBox checkBox = new CheckBox(true); + string time = displaySecondscheckBox.Value ? DateTime.Now.ToLongTimeString() : DateTime.Now.ToShortTimeString(); - public override int UpdateInterval => 1000; + Font font = new Font(Application.Theme.Font, 200); - public override Bitmap Main() - { - string time = checkBox.Value ? DateTime.Now.ToLongTimeString() : DateTime.Now.ToShortTimeString(); + Bitmap bmp = new Bitmap(1, 1); + bmp.SetResolution(100, 100); + using Graphics tmpGr = Graphics.FromImage(bmp); + tmpGr.TextRenderingHint = TextRenderingHint.AntiAlias; - Font font = new Font(Application.Theme.Font, 200); + SizeF size = tmpGr.MeasureString(time, font); - Bitmap bmp = new Bitmap(1, 1); - using Graphics tmpGr = Graphics.FromImage(bmp); - tmpGr.TextRenderingHint = TextRenderingHint.AntiAlias; + bmp = new Bitmap((int)size.Width, (int)size.Height); + bmp.SetResolution(100, 100); - SizeF size = CalculateSize(tmpGr, font); + using Graphics gr = Graphics.FromImage(bmp); - bmp = new Bitmap((int)size.Width, (int)size.Height); - bmp.SetResolution(100, 100); + gr.TextRenderingHint = TextRenderingHint.AntiAlias; + gr.DrawString(time, font, new SolidBrush(Application.Theme.PrimaryColor), 0, 0); - using Graphics gr = Graphics.FromImage(bmp); - - gr.TextRenderingHint = TextRenderingHint.AntiAlias; - gr.DrawStringNoLeftPadding(time, font, new SolidBrush(Application.Theme.PrimaryColor), 0, 0); - - return bmp; - } - - private SizeF CalculateSize(Graphics graphics, Font font) - { - string template = checkBox.Value ? "##:##:##" : "##:##"; - SizeF size = new SizeF(); - for (int i = 0; i < 9; i++) - { - SizeF newSize = graphics.MeasureStringNoLeftPadding(template.Replace("#", i.ToString()), font); - - size.Width = Math.Max(size.Width, newSize.Width); - size.Height = Math.Max(size.Height, newSize.Height); - } - return size; - } + return bmp; } } \ No newline at end of file diff --git a/src/DesktopMagic/DesktopMagic.csproj b/src/DesktopMagic/DesktopMagic.csproj index 8c74544..1ac5379 100644 --- a/src/DesktopMagic/DesktopMagic.csproj +++ b/src/DesktopMagic/DesktopMagic.csproj @@ -12,7 +12,7 @@ https://github.com/Stone-Red-Code/DesktopMagic 0.0.3.2 0.0.3.2 - net6.0-windows + net8.0-windows7.0 @@ -27,12 +27,12 @@ - - - - + + + + - + diff --git a/src/DesktopMagic/Dialogs/ColorDialog.xaml.cs b/src/DesktopMagic/Dialogs/ColorDialog.xaml.cs index 045e59f..fcf7c2a 100644 --- a/src/DesktopMagic/Dialogs/ColorDialog.xaml.cs +++ b/src/DesktopMagic/Dialogs/ColorDialog.xaml.cs @@ -6,123 +6,122 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Media; -namespace DesktopMagic.Dialogs +namespace DesktopMagic.Dialogs; + +/// +/// Interaction logic for ColorDialog.xaml +/// +public partial class ColorDialog : Window { - /// - /// Interaction logic for ColorDialog.xaml - /// - public partial class ColorDialog : Window + public System.Drawing.Color ResultColor { get; private set; } + + public Brush ResultBrush { get; private set; } + + public ColorDialog(string content, System.Drawing.Color defaultColor, string title = "ColorDialog") { - public ColorDialog(string content, System.Drawing.Color defaultColor, string title = "ColorDialog") + InitializeComponent(); + label.Content = content; + Title = title; + SetLanguageDictionary(); + + alphaSlider.Value = defaultColor.A; + redSlider.Value = defaultColor.R; + greenSlider.Value = defaultColor.G; + blueSlider.Value = defaultColor.B; + } + + private void OkButton_Click(object sender, RoutedEventArgs e) + { + DialogResult = true; + } + + private void CancelButton_Click(object sender, RoutedEventArgs e) + { + DialogResult = false; + } + + private void ColorSliders_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + colorHexTextBox.Select(colorHexTextBox.Text.Length, 0); + SetColorText(); + } + + private void ColorHexTextBox_TextChanged(object sender, TextChangedEventArgs e) + { + if (colorHexTextBox.Text.Length > 0) { - InitializeComponent(); - label.Content = content; - Title = title; - SetLanguageDictionary(); - - alphaSlider.Value = defaultColor.A; - redSlider.Value = defaultColor.R; - greenSlider.Value = defaultColor.G; - blueSlider.Value = defaultColor.B; - } - - public System.Drawing.Color ResultColor { get; private set; } - - public Brush ResultBrush { get; private set; } - - private void OkButton_Click(object sender, RoutedEventArgs e) - { - DialogResult = true; - } - - private void CancelButton_Click(object sender, RoutedEventArgs e) - { - DialogResult = false; - } - - private void ColorSliders_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) - { - colorHexTextBox.Select(colorHexTextBox.Text.Length, 0); - SetColorText(); - } - - private void ColorHexTextBox_TextChanged(object sender, TextChangedEventArgs e) - { - if (colorHexTextBox.Text.Length > 0) + if (colorHexTextBox.Text[0] != '#') { - if (colorHexTextBox.Text[0] != '#') - { - colorHexTextBox.Text = "#" + colorHexTextBox.Text.Replace("#", ""); - } + colorHexTextBox.Text = "#" + colorHexTextBox.Text.Replace("#", ""); } - else + } + else + { + colorHexTextBox.Text = "#"; + colorHexTextBox.Select(colorHexTextBox.Text.Length, 0); + } + + if (colorHexTextBox.SelectionStart == 0) + { + if (colorHexTextBox.Text.Length <= 2) { - colorHexTextBox.Text = "#"; colorHexTextBox.Select(colorHexTextBox.Text.Length, 0); } - - if (colorHexTextBox.SelectionStart == 0) - { - if (colorHexTextBox.Text.Length <= 2) - { - colorHexTextBox.Select(colorHexTextBox.Text.Length, 0); - } - else - { - colorHexTextBox.Select(1, 0); - } - } - - string hex = colorHexTextBox.Text; - - if (MultiColorConverter.TryConvertToMediaColor(hex, out Color color) && MultiColorConverter.TryConvertToSystemColor(hex, out System.Drawing.Color systemColor)) - { - alphaSlider.Value = color.A; - redSlider.Value = color.R; - greenSlider.Value = color.G; - blueSlider.Value = color.B; - - Brush brush = new SolidColorBrush(color); - - ResultBrush = brush; - ResultColor = systemColor; - colorRechtangle.Fill = brush; - colorHexTextBox.Foreground = Brushes.Black; - } else { - colorHexTextBox.Foreground = Brushes.Red; + colorHexTextBox.Select(1, 0); } } - private void SetColorText() - { - if (alphaSlider.Value == 255) - { - colorHexTextBox.Text = "#"; - } - else - { - colorHexTextBox.Text = "#" + ((int)alphaSlider.Value).ToString("X2"); - } + string hex = colorHexTextBox.Text; - colorHexTextBox.Text += ((int)redSlider.Value).ToString("X2") + ((int)greenSlider.Value).ToString("X2") + ((int)blueSlider.Value).ToString("X2"); + if (MultiColorConverter.TryConvertToMediaColor(hex, out Color color) && MultiColorConverter.TryConvertToSystemColor(hex, out System.Drawing.Color systemColor)) + { + alphaSlider.Value = color.A; + redSlider.Value = color.R; + greenSlider.Value = color.G; + blueSlider.Value = color.B; + + Brush brush = new SolidColorBrush(color); + + ResultBrush = brush; + ResultColor = systemColor; + colorRechtangle.Fill = brush; + colorHexTextBox.Foreground = Brushes.Black; } - - private void SetLanguageDictionary() + else { - ResourceDictionary dict = new ResourceDictionary(); - string currentCulture = Thread.CurrentThread.CurrentCulture.ToString(); - - if (currentCulture.Contains("de")) - { - dict.Source = new Uri("..\\Resources\\StringResources.de.xaml", UriKind.Relative); - } - else - { - dict.Source = new Uri("..\\Resources\\StringResources.en.xaml", UriKind.Relative); - } - Resources.MergedDictionaries.Add(dict); + colorHexTextBox.Foreground = Brushes.Red; } } + + private void SetColorText() + { + if (alphaSlider.Value == 255) + { + colorHexTextBox.Text = "#"; + } + else + { + colorHexTextBox.Text = "#" + ((int)alphaSlider.Value).ToString("X2"); + } + + colorHexTextBox.Text += ((int)redSlider.Value).ToString("X2") + ((int)greenSlider.Value).ToString("X2") + ((int)blueSlider.Value).ToString("X2"); + } + + private void SetLanguageDictionary() + { + ResourceDictionary dict = []; + string currentCulture = Thread.CurrentThread.CurrentCulture.ToString(); + + if (currentCulture.Contains("de")) + { + dict.Source = new Uri("..\\Resources\\StringResources.de.xaml", UriKind.Relative); + } + else + { + dict.Source = new Uri("..\\Resources\\StringResources.en.xaml", UriKind.Relative); + } + Resources.MergedDictionaries.Add(dict); + } } \ No newline at end of file diff --git a/src/DesktopMagic/Dialogs/InputDialog.xaml.cs b/src/DesktopMagic/Dialogs/InputDialog.xaml.cs index 9d559f2..523af7f 100644 --- a/src/DesktopMagic/Dialogs/InputDialog.xaml.cs +++ b/src/DesktopMagic/Dialogs/InputDialog.xaml.cs @@ -2,48 +2,47 @@ using System.Threading; using System.Windows; -namespace DesktopMagic.Dialogs +namespace DesktopMagic.Dialogs; + +public partial class InputDialog : Window { - public partial class InputDialog : Window + public string ResponseText { - public InputDialog(string content, string title = "InputDialog") - { - InitializeComponent(); - label.Content = content; - Title = title; - SetLanguageDictionary(); - } + get => textBox.Text; + set => textBox.Text = value; + } - public string ResponseText - { - get => textBox.Text; - set => textBox.Text = value; - } + public InputDialog(string content, string title = "InputDialog") + { + InitializeComponent(); + label.Content = content; + Title = title; + SetLanguageDictionary(); + } - private void OkButton_Click(object sender, RoutedEventArgs e) - { - DialogResult = true; - } + private void OkButton_Click(object sender, RoutedEventArgs e) + { + DialogResult = true; + } - private void CancelButton_Click(object sender, RoutedEventArgs e) - { - DialogResult = false; - } + private void CancelButton_Click(object sender, RoutedEventArgs e) + { + DialogResult = false; + } - private void SetLanguageDictionary() - { - ResourceDictionary dict = new ResourceDictionary(); - string currentCulture = Thread.CurrentThread.CurrentCulture.ToString(); + private void SetLanguageDictionary() + { + ResourceDictionary dict = []; + string currentCulture = Thread.CurrentThread.CurrentCulture.ToString(); - if (currentCulture.Contains("de")) - { - dict.Source = new Uri("..\\Resources\\StringResources.de.xaml", UriKind.Relative); - } - else - { - dict.Source = new Uri("..\\Resources\\StringResources.en.xaml", UriKind.Relative); - } - Resources.MergedDictionaries.Add(dict); + if (currentCulture.Contains("de")) + { + dict.Source = new Uri("..\\Resources\\StringResources.de.xaml", UriKind.Relative); } + else + { + dict.Source = new Uri("..\\Resources\\StringResources.en.xaml", UriKind.Relative); + } + Resources.MergedDictionaries.Add(dict); } } \ No newline at end of file diff --git a/src/DesktopMagic/GlobalSuppressions.cs b/src/DesktopMagic/GlobalSuppressions.cs index 9bb0139..35e3ca4 100644 --- a/src/DesktopMagic/GlobalSuppressions.cs +++ b/src/DesktopMagic/GlobalSuppressions.cs @@ -6,4 +6,6 @@ using System.Diagnostics.CodeAnalysis; [assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "Windows only application")] -[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "No need to")] \ No newline at end of file +[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "No need to")] +[assembly: SuppressMessage("Minor Code Smell", "S1075:URIs should not be hardcoded", Justification = "")] +[assembly: SuppressMessage("Minor Code Smell", "S3604:Member initializer values should not be redundant", Justification = "False postives")] \ No newline at end of file diff --git a/src/DesktopMagic/Helpers/ColorConverter.cs b/src/DesktopMagic/Helpers/ColorConverter.cs index efdd6fc..1504563 100644 --- a/src/DesktopMagic/Helpers/ColorConverter.cs +++ b/src/DesktopMagic/Helpers/ColorConverter.cs @@ -1,76 +1,82 @@ -using System.Globalization; +using System; +using System.Globalization; using System.Text.RegularExpressions; -namespace DesktopMagic.Helpers +namespace DesktopMagic.Helpers; + +internal static partial class MultiColorConverter { - internal static class MultiColorConverter + public static string ConvertToHex(System.Drawing.Color color) { - public static string ConvertToHex(System.Drawing.Color color) + return $"#{color.A:X2}{color.R:X2}{color.G:X2}{color.B:X2}"; + } + + public static string ConvertToHex(System.Windows.Media.Color color) + { + return $"#{color.A:X2}{color.R:X2}{color.G:X2}{color.B:X2}"; + } + + public static bool TryConvertToSystemColor(string hex, out System.Drawing.Color color) + { + hex = hex.Replace("#", ""); + + if (hex.Length == 8 && Hex8().IsMatch(hex)) { - return $"#{color.A:X2}{color.R:X2}{color.G:X2}{color.B:X2}"; + int a = int.Parse(hex.AsSpan(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); + int r = int.Parse(hex.AsSpan(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); + int g = int.Parse(hex.AsSpan(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); + int b = int.Parse(hex.AsSpan(6, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); + color = System.Drawing.Color.FromArgb((byte)a, (byte)r, (byte)g, (byte)b); + return true; } - - public static string ConvertToHex(System.Windows.Media.Color color) + else if (hex.Length == 6 && Hex6().IsMatch(hex)) { - return $"#{color.A:X2}{color.R:X2}{color.G:X2}{color.B:X2}"; + int a = 255; + int r = int.Parse(hex.AsSpan(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); + int g = int.Parse(hex.AsSpan(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); + int b = int.Parse(hex.AsSpan(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); + color = System.Drawing.Color.FromArgb((byte)a, (byte)r, (byte)g, (byte)b); + return true; } - - public static bool TryConvertToSystemColor(string hex, out System.Drawing.Color color) + else { - hex = hex.Replace("#", ""); - - if (hex.Length == 8 && Regex.IsMatch(hex, "(?:[0-9a-fA-F]{8})")) - { - int a = int.Parse(hex.Substring(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); - int r = int.Parse(hex.Substring(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); - int g = int.Parse(hex.Substring(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); - int b = int.Parse(hex.Substring(6, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); - color = System.Drawing.Color.FromArgb((byte)a, (byte)r, (byte)g, (byte)b); - return true; - } - else if (hex.Length == 6 && Regex.IsMatch(hex, "(?:[0-9a-fA-F]{6})")) - { - int a = 255; - int r = int.Parse(hex.Substring(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); - int g = int.Parse(hex.Substring(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); - int b = int.Parse(hex.Substring(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); - color = System.Drawing.Color.FromArgb((byte)a, (byte)r, (byte)g, (byte)b); - return true; - } - else - { - color = System.Drawing.Color.Transparent; - return false; - } - } - - public static bool TryConvertToMediaColor(string hex, out System.Windows.Media.Color color) - { - hex = hex.Replace("#", ""); - - if (hex.Length == 8 && Regex.IsMatch(hex, "(?:[0-9a-fA-F]{8})")) - { - int a = int.Parse(hex.Substring(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); - int r = int.Parse(hex.Substring(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); - int g = int.Parse(hex.Substring(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); - int b = int.Parse(hex.Substring(6, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); - color = System.Windows.Media.Color.FromArgb((byte)a, (byte)r, (byte)g, (byte)b); - return true; - } - else if (hex.Length == 6 && Regex.IsMatch(hex, "(?:[0-9a-fA-F]{6})")) - { - int a = 255; - int r = int.Parse(hex.Substring(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); - int g = int.Parse(hex.Substring(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); - int b = int.Parse(hex.Substring(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); - color = System.Windows.Media.Color.FromArgb((byte)a, (byte)r, (byte)g, (byte)b); - return true; - } - else - { - color = System.Windows.Media.Colors.Transparent; - return false; - } + color = System.Drawing.Color.Transparent; + return false; } } + + public static bool TryConvertToMediaColor(string hex, out System.Windows.Media.Color color) + { + hex = hex.Replace("#", ""); + + if (hex.Length == 8 && Hex8().IsMatch(hex)) + { + int a = int.Parse(hex.AsSpan(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); + int r = int.Parse(hex.AsSpan(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); + int g = int.Parse(hex.AsSpan(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); + int b = int.Parse(hex.AsSpan(6, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); + color = System.Windows.Media.Color.FromArgb((byte)a, (byte)r, (byte)g, (byte)b); + return true; + } + else if (hex.Length == 6 && Hex6().IsMatch(hex)) + { + int a = 255; + int r = int.Parse(hex.AsSpan(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); + int g = int.Parse(hex.AsSpan(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); + int b = int.Parse(hex.AsSpan(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); + color = System.Windows.Media.Color.FromArgb((byte)a, (byte)r, (byte)g, (byte)b); + return true; + } + else + { + color = System.Windows.Media.Colors.Transparent; + return false; + } + } + + [GeneratedRegex("(?:[0-9a-fA-F]{8})")] + private static partial Regex Hex8(); + + [GeneratedRegex("(?:[0-9a-fA-F]{6})")] + private static partial Regex Hex6(); } \ No newline at end of file diff --git a/src/DesktopMagic/Helpers/SampleAggregator.cs b/src/DesktopMagic/Helpers/SampleAggregator.cs index 2ac2f8d..46dae3f 100644 --- a/src/DesktopMagic/Helpers/SampleAggregator.cs +++ b/src/DesktopMagic/Helpers/SampleAggregator.cs @@ -1,65 +1,59 @@ using NAudio.Dsp; + using System; -namespace DesktopMagic +namespace DesktopMagic.Helpers; + +internal class SampleAggregator { - internal class SampleAggregator + // FFT + public event EventHandler FftCalculated; + + // This Complex is NAudio's own! + private readonly Complex[] fftBuffer; + + private readonly FftEventArgs fftArgs; + private readonly int fftLength; + private readonly int m; + private int fftPos; + public bool PerformFFT { get; set; } + + public SampleAggregator(int fftLength) { - // FFT - public event EventHandler FftCalculated; - - public bool PerformFFT { get; set; } - - // This Complex is NAudio's own! - private readonly Complex[] fftBuffer; - - private readonly FftEventArgs fftArgs; - private readonly int fftLength; - private readonly int m; - private int fftPos; - - public SampleAggregator(int fftLength) + if (!IsPowerOfTwo(fftLength)) { - if (!IsPowerOfTwo(fftLength)) - { - throw new ArgumentException("FFT Length must be a power of two"); - } - this.m = (int)Math.Log(fftLength, 2.0); - this.fftLength = fftLength; - this.fftBuffer = new Complex[fftLength]; - this.fftArgs = new FftEventArgs(fftBuffer); + throw new ArgumentException("FFT Length must be a power of two"); } + m = (int)Math.Log(fftLength, 2.0); + this.fftLength = fftLength; + fftBuffer = new Complex[fftLength]; + fftArgs = new FftEventArgs(fftBuffer); + } - private bool IsPowerOfTwo(int x) + public void Add(float value) + { + if (PerformFFT && FftCalculated != null) { - return (x & (x - 1)) == 0; - } - - public void Add(float value) - { - if (PerformFFT && FftCalculated != null) + // Remember the window function! There are many others as well. + fftBuffer[fftPos].X = (float)(value * FastFourierTransform.HammingWindow(fftPos, fftLength)); + fftBuffer[fftPos].Y = 0; // This is always zero with audio. + fftPos++; + if (fftPos >= fftLength) { - // Remember the window function! There are many others as well. - fftBuffer[fftPos].X = (float)(value * FastFourierTransform.HammingWindow(fftPos, fftLength)); - fftBuffer[fftPos].Y = 0; // This is always zero with audio. - fftPos++; - if (fftPos >= fftLength) - { - fftPos = 0; - FastFourierTransform.FFT(true, m, fftBuffer); - FftCalculated(this, fftArgs); - } + fftPos = 0; + FastFourierTransform.FFT(true, m, fftBuffer); + FftCalculated(this, fftArgs); } } } - public class FftEventArgs : EventArgs + private bool IsPowerOfTwo(int x) { - public FftEventArgs(Complex[] result) - { - this.Result = result; - } - - public Complex[] Result { get; private set; } + return (x & (x - 1)) == 0; } +} + +public class FftEventArgs(Complex[] result) : EventArgs +{ + public Complex[] Result { get; private set; } = result; } \ No newline at end of file diff --git a/src/DesktopMagic/Helpers/SettingElementGenerator.cs b/src/DesktopMagic/Helpers/SettingElementGenerator.cs index 98e72e0..4d91159 100644 --- a/src/DesktopMagic/Helpers/SettingElementGenerator.cs +++ b/src/DesktopMagic/Helpers/SettingElementGenerator.cs @@ -4,235 +4,229 @@ using System; using System.Windows; using System.Windows.Controls; -namespace DesktopMagic.Helpers +namespace DesktopMagic.Helpers; + +internal class SettingElementGenerator(ComboBox optionsComboBox) { - internal class SettingElementGenerator + private readonly ComboBox optionsComboBox = optionsComboBox; + + public void Generate(SettingElement settingElement, DockPanel dockPanel, TextBlock textBlock) { - private readonly ComboBox optionsComboBox; - - public SettingElementGenerator(ComboBox optionsComboBox) + dockPanel.UpdateLayout(); + textBlock.UpdateLayout(); + if (settingElement.Element is DesktopMagicPluginAPI.Inputs.Label eLabel) { - this.optionsComboBox = optionsComboBox; - } + textBlock.Text = eLabel.Value; + textBlock.Margin = new Thickness(0, 5, 3, 0); + textBlock.HorizontalAlignment = HorizontalAlignment.Stretch; + textBlock.TextWrapping = TextWrapping.WrapWithOverflow; - public void Generate(SettingElement settingElement, DockPanel dockPanel, TextBlock textBlock) - { - dockPanel.UpdateLayout(); - textBlock.UpdateLayout(); - if (settingElement.Element is DesktopMagicPluginAPI.Inputs.Label eLabel) + if (eLabel.Bold) { - textBlock.Text = eLabel.Value; - textBlock.Margin = new Thickness(0, 5, 3, 0); - textBlock.HorizontalAlignment = HorizontalAlignment.Stretch; - textBlock.TextWrapping = TextWrapping.WrapWithOverflow; - - if (eLabel.Bold) + textBlock.FontWeight = FontWeights.Bold; + } + eLabel.OnValueChanged += () => + { + textBlock.Dispatcher.Invoke(() => { - textBlock.FontWeight = FontWeights.Bold; + textBlock.Text = eLabel.Value; + }); + }; + } + else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.Button eButton) + { + Button button = new() + { + Content = eButton.Value, + FontSize = 10, + Height = 20, + Margin = new Thickness(0, 10, 0, 10), + Padding = new Thickness(0), + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Stretch + }; + button.Click += (_s, _e) => + { + try + { + eButton.Click(); } - eLabel.OnValueChanged += () => + catch (Exception ex) { - textBlock.Dispatcher.Invoke(() => - { - textBlock.Text = eLabel.Value; - }); - }; - } - else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.Button eButton) + DisplayException(ex.Message); + } + }; + eButton.OnValueChanged += () => { - Button button = new() + button.Dispatcher.Invoke(() => { - Content = eButton.Value, - FontSize = 10, - Height = 20, - Margin = new Thickness(0, 10, 0, 10), - Padding = new Thickness(0), - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Stretch - }; - button.Click += (_s, _e) => - { - try - { - eButton.Click(); - } - catch (Exception ex) - { - DisplayException(ex.Message); - } - }; - eButton.OnValueChanged += () => - { - button.Dispatcher.Invoke(() => - { - button.Content = eButton.Value; - }); - }; + button.Content = eButton.Value; + }); + }; - _ = dockPanel.Children.Add(button); - } - else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.CheckBox eCheckBox) - { - CheckBox checkBox = new() - { - IsChecked = eCheckBox.Value, - Style = (Style)dockPanel.FindResource("MaterialDesignDarkCheckBox"), - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Stretch - }; - checkBox.Click += (_s, _e) => - { - try - { - eCheckBox.Value = checkBox.IsChecked.GetValueOrDefault(); - } - catch (Exception ex) - { - DisplayException(ex.Message); - } - }; - eCheckBox.OnValueChanged += () => - { - checkBox.Dispatcher.Invoke(() => - { - checkBox.IsChecked = eCheckBox.Value; - }); - }; - - _ = dockPanel.Children.Add(checkBox); - } - else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.TextBox eTextBox) - { - TextBox textBox = new() - { - Text = eTextBox.Value, - TextWrapping = TextWrapping.Wrap, - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Stretch - }; - textBox.TextChanged += (_s, _e) => - { - try - { - eTextBox.Value = textBox.Text; - } - catch (Exception ex) - { - DisplayException(ex.Message); - } - }; - eTextBox.OnValueChanged += () => - { - textBox.Dispatcher.Invoke(() => - { - textBox.Text = eTextBox.Value; - }); - }; - _ = dockPanel.Children.Add(textBox); - } - else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.IntegerUpDown eIntegerUpDown) - { - Xceed.Wpf.Toolkit.IntegerUpDown integerUpDown = new() - { - Value = eIntegerUpDown.Value, - Minimum = eIntegerUpDown.Minimum, - Maximum = eIntegerUpDown.Maximum, - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Stretch - }; - integerUpDown.ValueChanged += (_s, _e) => - { - try - { - eIntegerUpDown.Value = integerUpDown.Value.GetValueOrDefault(); - } - catch (Exception ex) - { - DisplayException(ex.Message); - } - }; - eIntegerUpDown.OnValueChanged += () => - { - integerUpDown.Dispatcher.Invoke(() => - { - integerUpDown.Value = eIntegerUpDown.Value; - }); - }; - _ = dockPanel.Children.Add(integerUpDown); - } - else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.Slider eSlider) - { - Slider slider = new() - { - Value = eSlider.Value, - Minimum = eSlider.Minimum, - Maximum = eSlider.Maximum, - TickFrequency = 1, - IsSnapToTickEnabled = true, - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Stretch - }; - slider.ValueChanged += (_s, _e) => - { - try - { - eSlider.Value = slider.Value; - } - catch (Exception ex) - { - DisplayException(ex.Message); - } - }; - eSlider.OnValueChanged += () => - { - slider.Dispatcher.Invoke(() => - { - slider.Value = eSlider.Value; - }); - }; - - _ = dockPanel.Children.Add(slider); - } - else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.ComboBox eComboBox) - { - ComboBox comboBox = new() - { - ItemsSource = eComboBox.Items, - IsEditable = false, - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Stretch, - SelectedIndex = 0 - }; - - comboBox.SelectionChanged += (_s, _e) => - { - try - { - eComboBox.Value = comboBox.Text; - } - catch (Exception ex) - { - DisplayException(ex.Message); - } - }; - - eComboBox.OnValueChanged += () => - { - comboBox.SelectedItem = eComboBox.Value; - }; - - _ = dockPanel.Children.Add(comboBox); - } + _ = dockPanel.Children.Add(button); } - - private void DisplayException(string message) + else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.CheckBox eCheckBox) { - App.Logger.Log(message, "PluginInput"); - _ = MessageBox.Show("File execution error:\n" + message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); - int index = MainWindow.WindowNames.IndexOf(optionsComboBox.SelectedItem.ToString()); + CheckBox checkBox = new() + { + IsChecked = eCheckBox.Value, + Style = (Style)dockPanel.FindResource("MaterialDesignDarkCheckBox"), + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Stretch + }; + checkBox.Click += (_s, _e) => + { + try + { + eCheckBox.Value = checkBox.IsChecked.GetValueOrDefault(); + } + catch (Exception ex) + { + DisplayException(ex.Message); + } + }; + eCheckBox.OnValueChanged += () => + { + checkBox.Dispatcher.Invoke(() => + { + checkBox.IsChecked = eCheckBox.Value; + }); + }; - PluginWindow window = MainWindow.Windows[index]; - window?.Exit(); + _ = dockPanel.Children.Add(checkBox); + } + else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.TextBox eTextBox) + { + TextBox textBox = new() + { + Text = eTextBox.Value, + TextWrapping = TextWrapping.Wrap, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Stretch + }; + textBox.TextChanged += (_s, _e) => + { + try + { + eTextBox.Value = textBox.Text; + } + catch (Exception ex) + { + DisplayException(ex.Message); + } + }; + eTextBox.OnValueChanged += () => + { + textBox.Dispatcher.Invoke(() => + { + textBox.Text = eTextBox.Value; + }); + }; + _ = dockPanel.Children.Add(textBox); + } + else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.IntegerUpDown eIntegerUpDown) + { + Xceed.Wpf.Toolkit.IntegerUpDown integerUpDown = new() + { + Value = eIntegerUpDown.Value, + Minimum = eIntegerUpDown.Minimum, + Maximum = eIntegerUpDown.Maximum, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Stretch + }; + integerUpDown.ValueChanged += (_s, _e) => + { + try + { + eIntegerUpDown.Value = integerUpDown.Value.GetValueOrDefault(); + } + catch (Exception ex) + { + DisplayException(ex.Message); + } + }; + eIntegerUpDown.OnValueChanged += () => + { + integerUpDown.Dispatcher.Invoke(() => + { + integerUpDown.Value = eIntegerUpDown.Value; + }); + }; + _ = dockPanel.Children.Add(integerUpDown); + } + else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.Slider eSlider) + { + Slider slider = new() + { + Value = eSlider.Value, + Minimum = eSlider.Minimum, + Maximum = eSlider.Maximum, + TickFrequency = 1, + IsSnapToTickEnabled = true, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Stretch + }; + slider.ValueChanged += (_s, _e) => + { + try + { + eSlider.Value = slider.Value; + } + catch (Exception ex) + { + DisplayException(ex.Message); + } + }; + eSlider.OnValueChanged += () => + { + slider.Dispatcher.Invoke(() => + { + slider.Value = eSlider.Value; + }); + }; + + _ = dockPanel.Children.Add(slider); + } + else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.ComboBox eComboBox) + { + ComboBox comboBox = new() + { + ItemsSource = eComboBox.Items, + IsEditable = false, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Stretch, + SelectedIndex = 0 + }; + + comboBox.SelectionChanged += (_s, _e) => + { + try + { + eComboBox.Value = comboBox.Text; + } + catch (Exception ex) + { + DisplayException(ex.Message); + } + }; + + eComboBox.OnValueChanged += () => + { + comboBox.SelectedItem = eComboBox.Value; + }; + + _ = dockPanel.Children.Add(comboBox); } } + + private void DisplayException(string message) + { + App.Logger.Log(message, "PluginInput"); + _ = MessageBox.Show("File execution error:\n" + message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); + int index = MainWindow.WindowNames.IndexOf(optionsComboBox.SelectedItem.ToString()); + + PluginWindow window = MainWindow.Windows[index]; + window?.Exit(); + } } \ No newline at end of file diff --git a/src/DesktopMagic/Helpers/Win32Wrapper.cs b/src/DesktopMagic/Helpers/Win32Wrapper.cs index 15befda..be79580 100644 --- a/src/DesktopMagic/Helpers/Win32Wrapper.cs +++ b/src/DesktopMagic/Helpers/Win32Wrapper.cs @@ -2,728 +2,727 @@ using System.Runtime.InteropServices; using System.Text; -namespace DesktopMagic +namespace DesktopMagic.Helpers; + +internal class W32 { - internal class W32 + public const int SM_CXSCREEN = 0; + + public const int SM_CYSCREEN = 1; + + public const int SPI_SETDESKWALLPAPER = 20; + public const int SPIF_SENDWININICHANGE = 0x02; + public const int SPIF_UPDATEINIFILE = 0x01; + public const int SRCCOPY = 13369376; + + public const int WM_GETICON = 0x7F; + + public delegate bool EnumWindowsProc(nint hwnd, nint lParam); + + [DllImport("gdi32.dll", EntryPoint = "BitBlt")] + public static extern bool BitBlt(nint hdcDest, int xDest, int yDest, int wDest, int hDest, nint hdcSource, int xSrc, int ySrc, int RasterOp); + + [DllImport("gdi32.dll", EntryPoint = "CreateCompatibleBitmap")] + public static extern nint CreateCompatibleBitmap(nint hdc, int nWidth, int nHeight); + + [DllImport("gdi32.dll", EntryPoint = "CreateCompatibleDC")] + public static extern nint CreateCompatibleDC(nint hdc); + + [DllImport("gdi32.dll", EntryPoint = "DeleteDC")] + public static extern nint DeleteDC(nint hDc); + + [DllImport("gdi32.dll", EntryPoint = "DeleteObject")] + public static extern nint DeleteObject(nint hDc); + + [DllImport("dwmapi.dll")] + public static extern int DwmEnableBlurBehindWindow(nint hWnd, ref BbStruct blurBehind); + + [DllImport("DwmApi.dll")] + public static extern int DwmExtendFrameIntoClientArea(nint hwnd, ref Margins pMarInset); + + [DllImport("dwmapi.dll", EntryPoint = "#127", PreserveSig = false)] + public static extern void DwmGetColorizationParameters(out DWM_COLORIZATION_PARAMS parameters); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern bool DwmIsCompositionEnabled(); + + [DllImport("dwmapi.dll")] + public static extern int DwmIsCompositionEnabled(out bool enabled); + + [DllImport("dwmapi.dll", EntryPoint = "#131", PreserveSig = false)] + public static extern void DwmSetColorizationParameters(ref DWM_COLORIZATION_PARAMS parameters, long uUnknown); + + [DllImport("dwmapi.dll")] + public static extern int DwmSetWindowAttribute(nint hwnd, int attr, ref int attrValue, int attrSize); + + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, nint lParam); + + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool EnumChildWindows(nint parentHandle, EnumWindowsProc lpEnumFunc, nint lParam); + + [DllImport("user32.dll", SetLastError = true)] + public static extern nint FindWindow(string lpClassName, string lpWindowName); + + [DllImport("user32.dll", SetLastError = true)] + public static extern nint FindWindowEx(nint parentHandle, nint childAfter, string className, nint windowTitle); + + [DllImport("user32.dll")] + public static extern uint GetClassLong(nint hWnd, int nIndex); + + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] + public static extern int GetClassName(nint hWnd, StringBuilder lpClassName, int nMaxCount); + + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] + public static extern int GetWindowText(nint hWnd, StringBuilder lpWindowText, int nMaxCount); + + [DllImport("user32.dll", EntryPoint = "GetDC")] + public static extern nint GetDC(nint ptr); + + [DllImport("user32.dll")] + public static extern nint GetDCEx(nint hWnd, nint hrgnClip, DeviceContextValues flags); + + [DllImport("user32.dll", EntryPoint = "GetDesktopWindow")] + public static extern nint GetDesktopWindow(); + + [DllImport("user32.dll")] + public static extern nint GetForegroundWindow(); + + [DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)] + public static extern nint GetParent(nint hWnd); + + [DllImport("user32.dll")] + public static extern nint GetShellWindow(); + + [DllImport("user32.dll", EntryPoint = "GetSystemMetrics")] + public static extern int GetSystemMetrics(int abc); + + [DllImport("user32.dll", EntryPoint = "GetWindowDC")] + public static extern nint GetWindowDC(int ptr); + + [DllImport("user32.dll")] + public static extern bool IsWindowVisible(nint hWnd); + + [DllImport("user32.dll")] + public static extern bool RedrawWindow(nint hWnd, [In] ref RECT lprcUpdate, nint hrgnUpdate, RedrawWindowFlags flags); + + [DllImport("user32.dll")] + public static extern bool RedrawWindow(nint hWnd, nint lprcUpdate, nint hrgnUpdate, RedrawWindowFlags flags); + + [DllImport("user32.dll", EntryPoint = "ReleaseDC")] + public static extern nint ReleaseDC(nint hWnd, nint hDc); + + [DllImport("gdi32.dll", EntryPoint = "SelectObject")] + public static extern nint SelectObject(nint hdc, nint bmp); + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern nint SendMessage(nint hWnd, uint Msg, int wParam, nint lParam); + + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] + public static extern nint SendMessageTimeout(nint windowHandle, uint Msg, nint wParam, nint lParam, SendMessageTimeoutFlags flags, uint timeout, out nint result); + + [DllImport("user32.dll", SetLastError = true)] + public static extern nint SetParent(nint hWndChild, nint hWndNewParent); + + [DllImport("kernel32.dll")] + public static extern bool SetProcessWorkingSetSize(nint handle, int minimumWorkingSetSize, int maximumWorkingSetSize); + + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool EnableWindow(nint hWnd, bool bEnable); + + /// + /// Changes an attribute of the specified window. The function also sets the 32-bit (long) value at the specified offset into the extra window memory. + /// + /// A handle to the window and, indirectly, the class to which the window belongs.. + /// GWL_EXSTYLE, GWL_HINSTANCE, GWL_ID, GWL_STYLE, GWL_USERDATA, GWL_WNDPROC + /// The replacement value. + /// If the function succeeds, the return value is the previous value of the specified 32-bit integer. + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + [DllImport("user32.dll")] + public static extern int SetWindowLong(nint hWnd, WindowLongFlags nIndex, int dwNewLong); + + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SetWindowPos(nint hWnd, nint hWndInsertAfter, int X, int Y, int cx, int cy, SetWindowPosFlags uFlags); + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern int SystemParametersInfo(uint action, uint uParam, string vParam, uint winIni); + + [Flags] + public enum BbFlags : byte //Blur Behind Flags { - public const int SM_CXSCREEN = 0; + DwmBbEnable = 1, + DwmBbBlurregion = 2, + DwmBbTransitiononmaximized = 4, + }; - public const int SM_CYSCREEN = 1; + /// Values to pass to the GetDCEx method. + [Flags()] + public enum DeviceContextValues : uint + { + /// DCX_WINDOW: Returns a DC that corresponds to the window rectangle rather + /// than the client rectangle. + Window = 0x00000001, - public const int SPI_SETDESKWALLPAPER = 20; - public const int SPIF_SENDWININICHANGE = 0x02; - public const int SPIF_UPDATEINIFILE = 0x01; - public const int SRCCOPY = 13369376; + /// DCX_CACHE: Returns a DC from the cache, rather than the OWNDC or CLASSDC + /// window. Essentially overrides CS_OWNDC and CS_CLASSDC. + Cache = 0x00000002, - public const int WM_GETICON = 0x7F; + /// DCX_NORESETATTRS: Does not reset the attributes of this DC to the + /// default attributes when this DC is released. + NoResetAttrs = 0x00000004, - public delegate bool EnumWindowsProc(IntPtr hwnd, IntPtr lParam); + /// DCX_CLIPCHILDREN: Excludes the visible regions of all child windows + /// below the window identified by hWnd. + ClipChildren = 0x00000008, - [Flags] - public enum BbFlags : byte //Blur Behind Flags - { - DwmBbEnable = 1, - DwmBbBlurregion = 2, - DwmBbTransitiononmaximized = 4, - }; + /// DCX_CLIPSIBLINGS: Excludes the visible regions of all sibling windows + /// above the window identified by hWnd. + ClipSiblings = 0x00000010, - /// Values to pass to the GetDCEx method. - [Flags()] - public enum DeviceContextValues : uint - { - /// DCX_WINDOW: Returns a DC that corresponds to the window rectangle rather - /// than the client rectangle. - Window = 0x00000001, + /// DCX_PARENTCLIP: Uses the visible region of the parent window. The + /// parent's WS_CLIPCHILDREN and CS_PARENTDC style bits are ignored. The origin is + /// set to the upper-left corner of the window identified by hWnd. + ParentClip = 0x00000020, - /// DCX_CACHE: Returns a DC from the cache, rather than the OWNDC or CLASSDC - /// window. Essentially overrides CS_OWNDC and CS_CLASSDC. - Cache = 0x00000002, + /// DCX_EXCLUDERGN: The clipping region identified by hrgnClip is excluded + /// from the visible region of the returned DC. + ExcludeRgn = 0x00000040, - /// DCX_NORESETATTRS: Does not reset the attributes of this DC to the - /// default attributes when this DC is released. - NoResetAttrs = 0x00000004, + /// DCX_INTERSECTRGN: The clipping region identified by hrgnClip is + /// intersected with the visible region of the returned DC. + IntersectRgn = 0x00000080, - /// DCX_CLIPCHILDREN: Excludes the visible regions of all child windows - /// below the window identified by hWnd. - ClipChildren = 0x00000008, + /// DCX_EXCLUDEUPDATE: Unknown...Undocumented + ExcludeUpdate = 0x00000100, - /// DCX_CLIPSIBLINGS: Excludes the visible regions of all sibling windows - /// above the window identified by hWnd. - ClipSiblings = 0x00000010, + /// DCX_INTERSECTUPDATE: Unknown...Undocumented + IntersectUpdate = 0x00000200, - /// DCX_PARENTCLIP: Uses the visible region of the parent window. The - /// parent's WS_CLIPCHILDREN and CS_PARENTDC style bits are ignored. The origin is - /// set to the upper-left corner of the window identified by hWnd. - ParentClip = 0x00000020, + /// DCX_LOCKWINDOWUPDATE: Allows drawing even if there is a LockWindowUpdate + /// call in effect that would otherwise exclude this window. Used for drawing during + /// tracking. + LockWindowUpdate = 0x00000400, - /// DCX_EXCLUDERGN: The clipping region identified by hrgnClip is excluded - /// from the visible region of the returned DC. - ExcludeRgn = 0x00000040, + /// DCX_USESTYLE: Undocumented, something related to WM_NCPAINT message. + UseStyle = 0x00010000, - /// DCX_INTERSECTRGN: The clipping region identified by hrgnClip is - /// intersected with the visible region of the returned DC. - IntersectRgn = 0x00000080, + /// DCX_VALIDATE When specified with DCX_INTERSECTUPDATE, causes the DC to + /// be completely validated. Using this function with both DCX_INTERSECTUPDATE and + /// DCX_VALIDATE is identical to using the BeginPaint function. + Validate = 0x00200000, + } - /// DCX_EXCLUDEUPDATE: Unknown...Undocumented - ExcludeUpdate = 0x00000100, + [Flags] + public enum RedrawWindowFlags : uint + { + /// + /// Invalidates the rectangle or region that you specify in lprcUpdate or hrgnUpdate. + /// You can set only one of these parameters to a non-NULL value. If both are NULL, RDW_INVALIDATE invalidates the entire window. + /// + Invalidate = 0x1, - /// DCX_INTERSECTUPDATE: Unknown...Undocumented - IntersectUpdate = 0x00000200, - - /// DCX_LOCKWINDOWUPDATE: Allows drawing even if there is a LockWindowUpdate - /// call in effect that would otherwise exclude this window. Used for drawing during - /// tracking. - LockWindowUpdate = 0x00000400, - - /// DCX_USESTYLE: Undocumented, something related to WM_NCPAINT message. - UseStyle = 0x00010000, - - /// DCX_VALIDATE When specified with DCX_INTERSECTUPDATE, causes the DC to - /// be completely validated. Using this function with both DCX_INTERSECTUPDATE and - /// DCX_VALIDATE is identical to using the BeginPaint function. - Validate = 0x00200000, - } - - [Flags] - public enum RedrawWindowFlags : uint - { - /// - /// Invalidates the rectangle or region that you specify in lprcUpdate or hrgnUpdate. - /// You can set only one of these parameters to a non-NULL value. If both are NULL, RDW_INVALIDATE invalidates the entire window. - /// - Invalidate = 0x1, - - /// Causes the OS to post a WM_PAINT message to the window regardless of whether a portion of the window is invalid. - InternalPaint = 0x2, - - /// - /// Causes the window to receive a WM_ERASEBKGND message when the window is repainted. - /// Specify this value in combination with the RDW_INVALIDATE value; otherwise, RDW_ERASE has no effect. - /// - Erase = 0x4, - - /// - /// Validates the rectangle or region that you specify in lprcUpdate or hrgnUpdate. - /// You can set only one of these parameters to a non-NULL value. If both are NULL, RDW_VALIDATE validates the entire window. - /// This value does not affect internal WM_PAINT messages. - /// - Validate = 0x8, - - NoInternalPaint = 0x10, - - /// Suppresses any pending WM_ERASEBKGND messages. - NoErase = 0x20, - - /// Excludes child windows, if any, from the repainting operation. - NoChildren = 0x40, - - /// Includes child windows, if any, in the repainting operation. - AllChildren = 0x80, - - /// Causes the affected windows, which you specify by setting the RDW_ALLCHILDREN and RDW_NOCHILDREN values, to receive WM_ERASEBKGND and WM_PAINT messages before the RedrawWindow returns, if necessary. - UpdateNow = 0x100, - - /// - /// Causes the affected windows, which you specify by setting the RDW_ALLCHILDREN and RDW_NOCHILDREN values, to receive WM_ERASEBKGND messages before RedrawWindow returns, if necessary. - /// The affected windows receive WM_PAINT messages at the ordinary time. - /// - EraseNow = 0x200, - - Frame = 0x400, - - NoFrame = 0x800 - } - - [Flags()] - public enum SetWindowPosFlags : uint - { - /// If the calling thread and the thread that owns the window are attached to different input queues, - /// the system posts the request to the thread that owns the window. This prevents the calling thread from - /// blocking its execution while other threads process the request. - /// SWP_ASYNCWINDOWPOS - AsynWindowPos = 0x4000, - - /// Prevents generation of the WM_SYNCPAINT message. - /// SWP_DEFERERASE - DeferErase = 0x2000, - - /// Draws a frame (defined in the window's class description) around the window. - /// SWP_DRAWFRAME - DrawFrame = 0x0020, - - /// Applies new frame styles set using the SetWindowLong function. Sends a WM_NCCALCSIZE message to - /// the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZE - /// is sent only when the window's size is being changed. - /// SWP_FRAMECHANGED - FrameChanged = 0x0020, - - /// Hides the window. - /// SWP_HIDEWINDOW - HideWindow = 0x0080, - - /// Does not activate the window. If this flag is not set, the window is activated and moved to the - /// top of either the topmost or non-topmost group (depending on the setting of the hWndInsertAfter - /// parameter). - /// SWP_NOACTIVATE - NoActivate = 0x0010, - - /// Discards the entire contents of the client area. If this flag is not specified, the valid - /// contents of the client area are saved and copied back into the client area after the window is sized or - /// repositioned. - /// SWP_NOCOPYBITS - NoCopyBits = 0x0100, - - /// Retains the current position (ignores X and Y parameters). - /// SWP_NOMOVE - NoMove = 0x0002, - - /// Does not change the owner window's position in the Z order. - /// SWP_NOOWNERZORDER - NoOwnerZOrder = 0x0200, - - /// Does not redraw changes. If this flag is set, no repainting of any kind occurs. This applies to - /// the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent - /// window uncovered as a result of the window being moved. When this flag is set, the application must - /// explicitly invalidate or redraw any parts of the window and parent window that need redrawing. - /// SWP_NOREDRAW - NoRedraw = 0x0008, - - /// Same as the SWP_NOOWNERZORDER flag. - /// SWP_NOREPOSITION - NoReposition = 0x0200, - - /// Prevents the window from receiving the WM_WINDOWPOSCHANGING message. - /// SWP_NOSENDCHANGING - NoSendChanging = 0x0400, - - /// Retains the current size (ignores the cx and cy parameters). - /// SWP_NOSIZE - NoSize = 0x0001, - - /// Retains the current Z order (ignores the hWndInsertAfter parameter). - /// SWP_NOZORDER - NoZOrder = 0x0004, - - /// Displays the window. - /// SWP_SHOWWINDOW - ShowWindow = 0x0040 - } - - public enum WindowLongFlags - { - GWL_EXSTYLE = -20, - GWLP_HINSTANCE = -6, - GWLP_HWNDPARENT = -8, - GWL_ID = -12, - GWL_STYLE = -16, - GWL_USERDATA = -21, - GWL_WNDPROC = -4, - DWLP_USER = 0x8, - DWLP_MSGRESULT = 0x0, - DWLP_DLGPROC = 0x4 - } + /// Causes the OS to post a WM_PAINT message to the window regardless of whether a portion of the window is invalid. + InternalPaint = 0x2, /// - /// Window Styles. - /// The following styles can be specified wherever a window style is required. After the control has been created, these styles cannot be Pluginified, except as noted. + /// Causes the window to receive a WM_ERASEBKGND message when the window is repainted. + /// Specify this value in combination with the RDW_INVALIDATE value; otherwise, RDW_ERASE has no effect. /// - [Flags] - public enum WindowStyles : uint - { - /// The window has a thin-line border. - WS_BORDER = 0x800000, + Erase = 0x4, - /// The window has a title bar (includes the WS_BORDER style). - WS_CAPTION = 0xc00000, + /// + /// Validates the rectangle or region that you specify in lprcUpdate or hrgnUpdate. + /// You can set only one of these parameters to a non-NULL value. If both are NULL, RDW_VALIDATE validates the entire window. + /// This value does not affect internal WM_PAINT messages. + /// + Validate = 0x8, - /// The window is a child window. A window with this style cannot have a menu bar. This style cannot be used with the WS_POPUP style. - WS_CHILD = 0x40000000, + NoInternalPaint = 0x10, - /// Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window. - WS_CLIPCHILDREN = 0x2000000, + /// Suppresses any pending WM_ERASEBKGND messages. + NoErase = 0x20, - /// - /// Clips child windows relative to each other; that is, when a particular child window receives a WM_PAINT message, the WS_CLIPSIBLINGS style clips all other overlapping child windows out of the region of the child window to be updated. - /// If WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, when drawing within the client area of a child window, to draw within the client area of a neighboring child window. - /// - WS_CLIPSIBLINGS = 0x4000000, + /// Excludes child windows, if any, from the repainting operation. + NoChildren = 0x40, - /// The window is initially disabled. A disabled window cannot receive input from the user. To change this after a window has been created, use the EnableWindow function. - WS_DISABLED = 0x8000000, + /// Includes child windows, if any, in the repainting operation. + AllChildren = 0x80, - /// The window has a border of a style typically used with dialog boxes. A window with this style cannot have a title bar. - WS_DLGFRAME = 0x400000, + /// Causes the affected windows, which you specify by setting the RDW_ALLCHILDREN and RDW_NOCHILDREN values, to receive WM_ERASEBKGND and WM_PAINT messages before the RedrawWindow returns, if necessary. + UpdateNow = 0x100, - /// - /// The window is the first control of a group of controls. The group consists of this first control and all controls defined after it, up to the next control with the WS_GROUP style. - /// The first control in each group usually has the WS_TABSTOP style so that the user can move from group to group. The user can subsequently change the keyboard focus from one control in the group to the next control in the group by using the direction keys. - /// You can turn this style on and off to change dialog box navigation. To change this style after a window has been created, use the SetWindowLong function. - /// - WS_GROUP = 0x20000, + /// + /// Causes the affected windows, which you specify by setting the RDW_ALLCHILDREN and RDW_NOCHILDREN values, to receive WM_ERASEBKGND messages before RedrawWindow returns, if necessary. + /// The affected windows receive WM_PAINT messages at the ordinary time. + /// + EraseNow = 0x200, - /// The window has a horizontal scroll bar. - WS_HSCROLL = 0x100000, + Frame = 0x400, - /// The window is initially maximized. - WS_MAXIMIZE = 0x1000000, + NoFrame = 0x800 + } - /// The window has a maximize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified. - WS_MAXIMIZEBOX = 0x10000, + [Flags()] + public enum SetWindowPosFlags : uint + { + /// If the calling thread and the thread that owns the window are attached to different input queues, + /// the system posts the request to the thread that owns the window. This prevents the calling thread from + /// blocking its execution while other threads process the request. + /// SWP_ASYNCWINDOWPOS + AsynWindowPos = 0x4000, - /// The window is initially minimized. - WS_MINIMIZE = 0x20000000, + /// Prevents generation of the WM_SYNCPAINT message. + /// SWP_DEFERERASE + DeferErase = 0x2000, - /// The window has a minimize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified. - WS_MINIMIZEBOX = 0x20000, + /// Draws a frame (defined in the window's class description) around the window. + /// SWP_DRAWFRAME + DrawFrame = 0x0020, - /// The window is an overlapped window. An overlapped window has a title bar and a border. - WS_OVERLAPPED = 0x0, + /// Applies new frame styles set using the SetWindowLong function. Sends a WM_NCCALCSIZE message to + /// the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZE + /// is sent only when the window's size is being changed. + /// SWP_FRAMECHANGED + FrameChanged = 0x0020, - ///// The window is an overlapped window. - //WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_SIZEFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, + /// Hides the window. + /// SWP_HIDEWINDOW + HideWindow = 0x0080, - /// The window is a pop-up window. This style cannot be used with the WS_CHILD style. - WS_POPUP = 0x80000000u, + /// Does not activate the window. If this flag is not set, the window is activated and moved to the + /// top of either the topmost or non-topmost group (depending on the setting of the hWndInsertAfter + /// parameter). + /// SWP_NOACTIVATE + NoActivate = 0x0010, - ///// The window is a pop-up window. The WS_CAPTION and WS_POPUPWINDOW styles must be combined to make the window menu visible. - //WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU, + /// Discards the entire contents of the client area. If this flag is not specified, the valid + /// contents of the client area are saved and copied back into the client area after the window is sized or + /// repositioned. + /// SWP_NOCOPYBITS + NoCopyBits = 0x0100, - /// The window has a sizing border. - WS_SIZEFRAME = 0x40000, + /// Retains the current position (ignores X and Y parameters). + /// SWP_NOMOVE + NoMove = 0x0002, - /// The window has a window menu on its title bar. The WS_CAPTION style must also be specified. - WS_SYSMENU = 0x80000, + /// Does not change the owner window's position in the Z order. + /// SWP_NOOWNERZORDER + NoOwnerZOrder = 0x0200, - /// - /// The window is a control that can receive the keyboard focus when the user presses the TAB key. - /// Pressing the TAB key changes the keyboard focus to the next control with the WS_TABSTOP style. - /// You can turn this style on and off to change dialog box navigation. To change this style after a window has been created, use the SetWindowLong function. - /// For user-created windows and Plugineless dialogs to work with tab stops, alter the message loop to call the IsDialogMessage function. - /// - WS_TABSTOP = 0x10000, + /// Does not redraw changes. If this flag is set, no repainting of any kind occurs. This applies to + /// the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent + /// window uncovered as a result of the window being moved. When this flag is set, the application must + /// explicitly invalidate or redraw any parts of the window and parent window that need redrawing. + /// SWP_NOREDRAW + NoRedraw = 0x0008, - /// The window is initially visible. This style can be turned on and off by using the ShowWindow or SetWindowPos function. - WS_VISIBLE = 0x10000000, + /// Same as the SWP_NOOWNERZORDER flag. + /// SWP_NOREPOSITION + NoReposition = 0x0200, - /// The window has a vertical scroll bar. - WS_VSCROLL = 0x200000 - } + /// Prevents the window from receiving the WM_WINDOWPOSCHANGING message. + /// SWP_NOSENDCHANGING + NoSendChanging = 0x0400, - [Flags] - public enum WindowStylesEx : uint - { - /// - /// Specifies that a window created with this style accepts drag-drop files. - /// - WS_EX_ACCEPTFILES = 0x00000010, + /// Retains the current size (ignores the cx and cy parameters). + /// SWP_NOSIZE + NoSize = 0x0001, - /// - /// Forces a top-level window onto the taskbar when the window is visible. - /// - WS_EX_APPWINDOW = 0x00040000, + /// Retains the current Z order (ignores the hWndInsertAfter parameter). + /// SWP_NOZORDER + NoZOrder = 0x0004, - /// - /// Specifies that a window has a border with a sunken edge. - /// - WS_EX_CLIENTEDGE = 0x00000200, + /// Displays the window. + /// SWP_SHOWWINDOW + ShowWindow = 0x0040 + } - /// - /// Windows XP: Paints all descendants of a window in bottom-to-top painting order using double-buffering. For more information, see Remarks. This cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC. - /// - WS_EX_COMPOSITED = 0x02000000, + public enum WindowLongFlags + { + GWL_EXSTYLE = -20, + GWLP_HINSTANCE = -6, + GWLP_HWNDPARENT = -8, + GWL_ID = -12, + GWL_STYLE = -16, + GWL_USERDATA = -21, + GWL_WNDPROC = -4, + DWLP_USER = 0x8, + DWLP_MSGRESULT = 0x0, + DWLP_DLGPROC = 0x4 + } - /// - /// Includes a question mark in the title bar of the window. When the user clicks the question mark, the cursor changes to a question mark with a pointer. If the user then clicks a child window, the child receives a WM_HELP message. The child window should pass the message to the parent window procedure, which should call the WinHelp function using the HELP_WM_HELP command. The Help application displays a pop-up window that typically contains help for the child window. - /// WS_EX_CONTEXTHELP cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles. - /// - WS_EX_CONTEXTHELP = 0x00000400, + /// + /// Window Styles. + /// The following styles can be specified wherever a window style is required. After the control has been created, these styles cannot be Pluginified, except as noted. + /// + [Flags] + public enum WindowStyles : uint + { + /// The window has a thin-line border. + WS_BORDER = 0x800000, - /// - /// The window itself contains child windows that should take part in dialog box navigation. If this style is specified, the dialog manager recurses into children of this window when performing navigation operations such as handling the TAB key, an arrow key, or a keyboard mnemonic. - /// - WS_EX_CONTROLPARENT = 0x00010000, + /// The window has a title bar (includes the WS_BORDER style). + WS_CAPTION = 0xc00000, - /// - /// Creates a window that has a double border; the window can, optionally, be created with a title bar by specifying the WS_CAPTION style in the dwStyle parameter. - /// - WS_EX_DLGPluginALFRAME = 0x00000001, + /// The window is a child window. A window with this style cannot have a menu bar. This style cannot be used with the WS_POPUP style. + WS_CHILD = 0x40000000, - /// - /// Windows 2000/XP: Creates a layered window. Note that this cannot be used for child windows. Also, this cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC. - /// - WS_EX_LAYERED = 0x00080000, + /// Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window. + WS_CLIPCHILDREN = 0x2000000, - /// - /// Arabic and Hebrew versions of Windows 98/Me, Windows 2000/XP: Creates a window whose horizontal origin is on the right edge. Increasing horizontal values advance to the left. - /// - WS_EX_LAYOUTRTL = 0x00400000, + /// + /// Clips child windows relative to each other; that is, when a particular child window receives a WM_PAINT message, the WS_CLIPSIBLINGS style clips all other overlapping child windows out of the region of the child window to be updated. + /// If WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, when drawing within the client area of a child window, to draw within the client area of a neighboring child window. + /// + WS_CLIPSIBLINGS = 0x4000000, - /// - /// Creates a window that has generic left-aligned properties. This is the default. - /// - WS_EX_LEFT = 0x00000000, + /// The window is initially disabled. A disabled window cannot receive input from the user. To change this after a window has been created, use the EnableWindow function. + WS_DISABLED = 0x8000000, - /// - /// If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the vertical scroll bar (if present) is to the left of the client area. For other languages, the style is ignored. - /// - WS_EX_LEFTSCROLLBAR = 0x00004000, + /// The window has a border of a style typically used with dialog boxes. A window with this style cannot have a title bar. + WS_DLGFRAME = 0x400000, - /// - /// The window text is displayed using left-to-right reading-order properties. This is the default. - /// - WS_EX_LTRREADING = 0x00000000, + /// + /// The window is the first control of a group of controls. The group consists of this first control and all controls defined after it, up to the next control with the WS_GROUP style. + /// The first control in each group usually has the WS_TABSTOP style so that the user can move from group to group. The user can subsequently change the keyboard focus from one control in the group to the next control in the group by using the direction keys. + /// You can turn this style on and off to change dialog box navigation. To change this style after a window has been created, use the SetWindowLong function. + /// + WS_GROUP = 0x20000, - /// - /// Creates a multiple-document interface (MDI) child window. - /// - WS_EX_MDICHILD = 0x00000040, + /// The window has a horizontal scroll bar. + WS_HSCROLL = 0x100000, - /// - /// Windows 2000/XP: A top-level window created with this style does not become the foreground window when the user clicks it. The system does not bring this window to the foreground when the user minimizes or closes the foreground window. - /// To activate the window, use the SetActiveWindow or SetForegroundWindow function. - /// The window does not appear on the taskbar by default. To force the window to appear on the taskbar, use the WS_EX_APPWINDOW style. - /// - WS_EX_NOACTIVATE = 0x08000000, + /// The window is initially maximized. + WS_MAXIMIZE = 0x1000000, - /// - /// Windows 2000/XP: A window created with this style does not pass its window layout to its child windows. - /// - WS_EX_NOINHERITLAYOUT = 0x00100000, + /// The window has a maximize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified. + WS_MAXIMIZEBOX = 0x10000, - /// - /// Specifies that a child window created with this style does not send the WM_PARENTNOTIFY message to its parent window when it is created or destroyed. - /// - WS_EX_NOPARENTNOTIFY = 0x00000004, + /// The window is initially minimized. + WS_MINIMIZE = 0x20000000, - /// - /// Combines the WS_EX_CLIENTEDGE and WS_EX_WINDOWEDGE styles. - /// - WS_EX_OVERLAPPEDWINDOW = WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE, + /// The window has a minimize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified. + WS_MINIMIZEBOX = 0x20000, - /// - /// Combines the WS_EX_WINDOWEDGE, WS_EX_TOOLWINDOW, and WS_EX_TOPMOST styles. - /// - WS_EX_PALETTEWINDOW = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST, + /// The window is an overlapped window. An overlapped window has a title bar and a border. + WS_OVERLAPPED = 0x0, - /// - /// The window has generic "right-aligned" properties. This depends on the window class. This style has an effect only if the shell language is Hebrew, Arabic, or another language that supports reading-order alignment; otherwise, the style is ignored. - /// Using the WS_EX_RIGHT style for static or edit controls has the same effect as using the SS_RIGHT or ES_RIGHT style, respectively. Using this style with button controls has the same effect as using BS_RIGHT and BS_RIGHTBUTTON styles. - /// - WS_EX_RIGHT = 0x00001000, + ///// The window is an overlapped window. + //WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_SIZEFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, - /// - /// Vertical scroll bar (if present) is to the right of the client area. This is the default. - /// - WS_EX_RIGHTSCROLLBAR = 0x00000000, + /// The window is a pop-up window. This style cannot be used with the WS_CHILD style. + WS_POPUP = 0x80000000u, - /// - /// If the shell language is Hebrew, Arabic, or another language that supports reading-order alignment, the window text is displayed using right-to-left reading-order properties. For other languages, the style is ignored. - /// - WS_EX_RTLREADING = 0x00002000, + ///// The window is a pop-up window. The WS_CAPTION and WS_POPUPWINDOW styles must be combined to make the window menu visible. + //WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU, - /// - /// Creates a window with a three-dimensional border style intended to be used for items that do not accept user input. - /// - WS_EX_STATICEDGE = 0x00020000, + /// The window has a sizing border. + WS_SIZEFRAME = 0x40000, - /// - /// Creates a tool window; that is, a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by right-clicking or by typing ALT+SPACE. - /// - WS_EX_TOOLWINDOW = 0x00000080, + /// The window has a window menu on its title bar. The WS_CAPTION style must also be specified. + WS_SYSMENU = 0x80000, - /// - /// Specifies that a window created with this style should be placed above all non-topmost windows and should stay above them, even when the window is deactivated. To add or remove this style, use the SetWindowPos function. - /// - WS_EX_TOPMOST = 0x00000008, + /// + /// The window is a control that can receive the keyboard focus when the user presses the TAB key. + /// Pressing the TAB key changes the keyboard focus to the next control with the WS_TABSTOP style. + /// You can turn this style on and off to change dialog box navigation. To change this style after a window has been created, use the SetWindowLong function. + /// For user-created windows and Plugineless dialogs to work with tab stops, alter the message loop to call the IsDialogMessage function. + /// + WS_TABSTOP = 0x10000, - /// - /// Specifies that a window created with this style should not be painted until siblings beneath the window (that were created by the same thread) have been painted. The window appears transparent because the bits of underlying sibling windows have already been painted. - /// To achieve transparency without these restrictions, use the SetWindowRgn function. - /// - WS_EX_TRANSPARENT = 0x00000020, + /// The window is initially visible. This style can be turned on and off by using the ShowWindow or SetWindowPos function. + WS_VISIBLE = 0x10000000, - /// - /// Specifies that a window has a border with a raised edge. - /// - WS_EX_WINDOWEDGE = 0x00000100 - } + /// The window has a vertical scroll bar. + WS_VSCROLL = 0x200000 + } - [Flags] - public enum SendMessageTimeoutFlags : uint - { - SMTO_NORMAL = 0x0, - SMTO_BLOCK = 0x1, - SMTO_ABORTIFHUNG = 0x2, - SMTO_NOTIMEOUTIFNOTHUNG = 0x8, - SMTO_ERRORONEXIT = 0x20 - } + [Flags] + public enum WindowStylesEx : uint + { + /// + /// Specifies that a window created with this style accepts drag-drop files. + /// + WS_EX_ACCEPTFILES = 0x00000010, + + /// + /// Forces a top-level window onto the taskbar when the window is visible. + /// + WS_EX_APPWINDOW = 0x00040000, + + /// + /// Specifies that a window has a border with a sunken edge. + /// + WS_EX_CLIENTEDGE = 0x00000200, + + /// + /// Windows XP: Paints all descendants of a window in bottom-to-top painting order using double-buffering. For more information, see Remarks. This cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC. + /// + WS_EX_COMPOSITED = 0x02000000, + + /// + /// Includes a question mark in the title bar of the window. When the user clicks the question mark, the cursor changes to a question mark with a pointer. If the user then clicks a child window, the child receives a WM_HELP message. The child window should pass the message to the parent window procedure, which should call the WinHelp function using the HELP_WM_HELP command. The Help application displays a pop-up window that typically contains help for the child window. + /// WS_EX_CONTEXTHELP cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles. + /// + WS_EX_CONTEXTHELP = 0x00000400, + + /// + /// The window itself contains child windows that should take part in dialog box navigation. If this style is specified, the dialog manager recurses into children of this window when performing navigation operations such as handling the TAB key, an arrow key, or a keyboard mnemonic. + /// + WS_EX_CONTROLPARENT = 0x00010000, + + /// + /// Creates a window that has a double border; the window can, optionally, be created with a title bar by specifying the WS_CAPTION style in the dwStyle parameter. + /// + WS_EX_DLGPluginALFRAME = 0x00000001, + + /// + /// Windows 2000/XP: Creates a layered window. Note that this cannot be used for child windows. Also, this cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC. + /// + WS_EX_LAYERED = 0x00080000, + + /// + /// Arabic and Hebrew versions of Windows 98/Me, Windows 2000/XP: Creates a window whose horizontal origin is on the right edge. Increasing horizontal values advance to the left. + /// + WS_EX_LAYOUTRTL = 0x00400000, + + /// + /// Creates a window that has generic left-aligned properties. This is the default. + /// + WS_EX_LEFT = 0x00000000, + + /// + /// If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the vertical scroll bar (if present) is to the left of the client area. For other languages, the style is ignored. + /// + WS_EX_LEFTSCROLLBAR = 0x00004000, + + /// + /// The window text is displayed using left-to-right reading-order properties. This is the default. + /// + WS_EX_LTRREADING = 0x00000000, + + /// + /// Creates a multiple-document interface (MDI) child window. + /// + WS_EX_MDICHILD = 0x00000040, + + /// + /// Windows 2000/XP: A top-level window created with this style does not become the foreground window when the user clicks it. The system does not bring this window to the foreground when the user minimizes or closes the foreground window. + /// To activate the window, use the SetActiveWindow or SetForegroundWindow function. + /// The window does not appear on the taskbar by default. To force the window to appear on the taskbar, use the WS_EX_APPWINDOW style. + /// + WS_EX_NOACTIVATE = 0x08000000, + + /// + /// Windows 2000/XP: A window created with this style does not pass its window layout to its child windows. + /// + WS_EX_NOINHERITLAYOUT = 0x00100000, + + /// + /// Specifies that a child window created with this style does not send the WM_PARENTNOTIFY message to its parent window when it is created or destroyed. + /// + WS_EX_NOPARENTNOTIFY = 0x00000004, + + /// + /// Combines the WS_EX_CLIENTEDGE and WS_EX_WINDOWEDGE styles. + /// + WS_EX_OVERLAPPEDWINDOW = WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE, + + /// + /// Combines the WS_EX_WINDOWEDGE, WS_EX_TOOLWINDOW, and WS_EX_TOPMOST styles. + /// + WS_EX_PALETTEWINDOW = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST, + + /// + /// The window has generic "right-aligned" properties. This depends on the window class. This style has an effect only if the shell language is Hebrew, Arabic, or another language that supports reading-order alignment; otherwise, the style is ignored. + /// Using the WS_EX_RIGHT style for static or edit controls has the same effect as using the SS_RIGHT or ES_RIGHT style, respectively. Using this style with button controls has the same effect as using BS_RIGHT and BS_RIGHTBUTTON styles. + /// + WS_EX_RIGHT = 0x00001000, + + /// + /// Vertical scroll bar (if present) is to the right of the client area. This is the default. + /// + WS_EX_RIGHTSCROLLBAR = 0x00000000, + + /// + /// If the shell language is Hebrew, Arabic, or another language that supports reading-order alignment, the window text is displayed using right-to-left reading-order properties. For other languages, the style is ignored. + /// + WS_EX_RTLREADING = 0x00002000, + + /// + /// Creates a window with a three-dimensional border style intended to be used for items that do not accept user input. + /// + WS_EX_STATICEDGE = 0x00020000, + + /// + /// Creates a tool window; that is, a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by right-clicking or by typing ALT+SPACE. + /// + WS_EX_TOOLWINDOW = 0x00000080, + + /// + /// Specifies that a window created with this style should be placed above all non-topmost windows and should stay above them, even when the window is deactivated. To add or remove this style, use the SetWindowPos function. + /// + WS_EX_TOPMOST = 0x00000008, + + /// + /// Specifies that a window created with this style should not be painted until siblings beneath the window (that were created by the same thread) have been painted. The window appears transparent because the bits of underlying sibling windows have already been painted. + /// To achieve transparency without these restrictions, use the SetWindowRgn function. + /// + WS_EX_TRANSPARENT = 0x00000020, + + /// + /// Specifies that a window has a border with a raised edge. + /// + WS_EX_WINDOWEDGE = 0x00000100 + } + + [Flags] + public enum SendMessageTimeoutFlags : uint + { + SMTO_NORMAL = 0x0, + SMTO_BLOCK = 0x1, + SMTO_ABORTIFHUNG = 0x2, + SMTO_NOTIMEOUTIFNOTHUNG = 0x8, + SMTO_ERRORONEXIT = 0x20 + } #pragma warning disable CA2101 - [DllImport("gdi32.dll", EntryPoint = "BitBlt")] - public static extern bool BitBlt(IntPtr hdcDest, int xDest, int yDest, int wDest, int hDest, IntPtr hdcSource, int xSrc, int ySrc, int RasterOp); + [StructLayout(LayoutKind.Sequential)] + public struct BbStruct //Blur Behind Structure + { + public BbFlags Flags; + public bool Enable; + public nint Region; + public bool TransitionOnMaximized; + } - [DllImport("gdi32.dll", EntryPoint = "CreateCompatibleBitmap")] - public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight); + [StructLayout(LayoutKind.Sequential)] + public struct DWM_COLORIZATION_PARAMS + { + public int clrColor; + public int clrAfterGlow; + public int nIntensity; + public int clrAfterGlowBalance; + public int clrBlurBalance; + public int clrGlassReflectionIntensity; + public bool fOpaque; + } - [DllImport("gdi32.dll", EntryPoint = "CreateCompatibleDC")] - public static extern IntPtr CreateCompatibleDC(IntPtr hdc); + [StructLayout(LayoutKind.Sequential)] + public struct Margins + { + public int cxLeftWidth; // width of left border that retains its size + public int cxRightWidth; // width of right border that retains its size + public int cyTopHeight; // height of top border that retains its size + public int cyBottomHeight; // height of bottom border that retains its size + }; - [DllImport("gdi32.dll", EntryPoint = "DeleteDC")] - public static extern IntPtr DeleteDC(IntPtr hDc); + [StructLayout(LayoutKind.Sequential)] + public struct RECT + { + public int Left, Top, Right, Bottom; - [DllImport("gdi32.dll", EntryPoint = "DeleteObject")] - public static extern IntPtr DeleteObject(IntPtr hDc); - - [DllImport("dwmapi.dll")] - public static extern int DwmEnableBlurBehindWindow(IntPtr hWnd, ref BbStruct blurBehind); - - [DllImport("DwmApi.dll")] - public static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref Margins pMarInset); - - [DllImport("dwmapi.dll", EntryPoint = "#127", PreserveSig = false)] - public static extern void DwmGetColorizationParameters(out DWM_COLORIZATION_PARAMS parameters); - - [DllImport("dwmapi.dll", PreserveSig = false)] - public static extern bool DwmIsCompositionEnabled(); - - [DllImport("dwmapi.dll")] - public static extern int DwmIsCompositionEnabled(out bool enabled); - - [DllImport("dwmapi.dll", EntryPoint = "#131", PreserveSig = false)] - public static extern void DwmSetColorizationParameters(ref DWM_COLORIZATION_PARAMS parameters, long uUnknown); - - [DllImport("dwmapi.dll")] - public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize); - - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam); - - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool EnumChildWindows(IntPtr parentHandle, EnumWindowsProc lpEnumFunc, IntPtr lParam); - - [DllImport("user32.dll", SetLastError = true)] - public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); - - [DllImport("user32.dll", SetLastError = true)] - public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, IntPtr windowTitle); - - [DllImport("user32.dll")] - public static extern uint GetClassLong(IntPtr hWnd, int nIndex); - - [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] - public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount); - - [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] - public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpWindowText, int nMaxCount); - - [DllImport("user32.dll", EntryPoint = "GetDC")] - public static extern IntPtr GetDC(IntPtr ptr); - - [DllImport("user32.dll")] - public static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, DeviceContextValues flags); - - [DllImport("user32.dll", EntryPoint = "GetDesktopWindow")] - public static extern IntPtr GetDesktopWindow(); - - [DllImport("user32.dll")] - public static extern IntPtr GetForegroundWindow(); - - [DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)] - public static extern IntPtr GetParent(IntPtr hWnd); - - [DllImport("user32.dll")] - public static extern IntPtr GetShellWindow(); - - [DllImport("user32.dll", EntryPoint = "GetSystemMetrics")] - public static extern int GetSystemMetrics(int abc); - - [DllImport("user32.dll", EntryPoint = "GetWindowDC")] - public static extern IntPtr GetWindowDC(int ptr); - - [DllImport("user32.dll")] - public static extern bool IsWindowVisible(IntPtr hWnd); - - [DllImport("user32.dll")] - public static extern bool RedrawWindow(IntPtr hWnd, [In] ref RECT lprcUpdate, IntPtr hrgnUpdate, RedrawWindowFlags flags); - - [DllImport("user32.dll")] - public static extern bool RedrawWindow(IntPtr hWnd, IntPtr lprcUpdate, IntPtr hrgnUpdate, RedrawWindowFlags flags); - - [DllImport("user32.dll", EntryPoint = "ReleaseDC")] - public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDc); - - [DllImport("gdi32.dll", EntryPoint = "SelectObject")] - public static extern IntPtr SelectObject(IntPtr hdc, IntPtr bmp); - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, IntPtr lParam); - - [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] - public static extern IntPtr SendMessageTimeout(IntPtr windowHandle, uint Msg, IntPtr wParam, IntPtr lParam, SendMessageTimeoutFlags flags, uint timeout, out IntPtr result); - - [DllImport("user32.dll", SetLastError = true)] - public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); - - [DllImport("kernel32.dll")] - public static extern bool SetProcessWorkingSetSize(IntPtr handle, int minimumWorkingSetSize, int maximumWorkingSetSize); - - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool EnableWindow(IntPtr hWnd, bool bEnable); - - /// - /// Changes an attribute of the specified window. The function also sets the 32-bit (long) value at the specified offset into the extra window memory. - /// - /// A handle to the window and, indirectly, the class to which the window belongs.. - /// GWL_EXSTYLE, GWL_HINSTANCE, GWL_ID, GWL_STYLE, GWL_USERDATA, GWL_WNDPROC - /// The replacement value. - /// If the function succeeds, the return value is the previous value of the specified 32-bit integer. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - [DllImport("user32.dll")] - public static extern int SetWindowLong(IntPtr hWnd, WindowLongFlags nIndex, int dwNewLong); - - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, SetWindowPosFlags uFlags); - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - public static extern int SystemParametersInfo(uint action, uint uParam, string vParam, uint winIni); - - [StructLayout(LayoutKind.Sequential)] - public struct BbStruct //Blur Behind Structure + public RECT(int left, int top, int right, int bottom) { - public BbFlags Flags; - public bool Enable; - public IntPtr Region; - public bool TransitionOnMaximized; + Left = left; + Top = top; + Right = right; + Bottom = bottom; } - [StructLayout(LayoutKind.Sequential)] - public struct DWM_COLORIZATION_PARAMS + public RECT(System.Drawing.Rectangle r) + : this(r.Left, r.Top, r.Right, r.Bottom) { - public int clrColor; - public int clrAfterGlow; - public int nIntensity; - public int clrAfterGlowBalance; - public int clrBlurBalance; - public int clrGlassReflectionIntensity; - public bool fOpaque; } - [StructLayout(LayoutKind.Sequential)] - public struct Margins + public int X { - public int cxLeftWidth; // width of left border that retains its size - public int cxRightWidth; // width of right border that retains its size - public int cyTopHeight; // height of top border that retains its size - public int cyBottomHeight; // height of bottom border that retains its size - }; + get => Left; + set { Right -= Left - value; Left = value; } + } - [StructLayout(LayoutKind.Sequential)] - public struct RECT + public int Y { - public int Left, Top, Right, Bottom; + get => Top; + set { Bottom -= Top - value; Top = value; } + } - public RECT(int left, int top, int right, int bottom) + public int Height + { + get => Bottom - Top; + set => Bottom = value + Top; + } + + public int Width + { + get => Right - Left; + set => Right = value + Left; + } + + public System.Drawing.Point Location + { + get => new System.Drawing.Point(Left, Top); + set { X = value.X; Y = value.Y; } + } + + public System.Drawing.Size Size + { + get => new System.Drawing.Size(Width, Height); + set { Width = value.Width; Height = value.Height; } + } + + public static implicit operator System.Drawing.Rectangle(RECT r) + { + return new System.Drawing.Rectangle(r.Left, r.Top, r.Width, r.Height); + } + + public static implicit operator RECT(System.Drawing.Rectangle r) + { + return new RECT(r); + } + + public static bool operator ==(RECT r1, RECT r2) + { + return r1.Equals(r2); + } + + public static bool operator !=(RECT r1, RECT r2) + { + return !r1.Equals(r2); + } + + public bool Equals(RECT r) + { + return r.Left == Left && r.Top == Top && r.Right == Right && r.Bottom == Bottom; + } + + public override bool Equals(object obj) + { + if (obj is RECT rECT) { - Left = left; - Top = top; - Right = right; - Bottom = bottom; + return Equals(rECT); + } + else if (obj is System.Drawing.Rectangle rectangle) + { + return Equals(new RECT(rectangle)); } - public RECT(System.Drawing.Rectangle r) - : this(r.Left, r.Top, r.Right, r.Bottom) - { - } + return false; + } - public int X - { - get => Left; - set { Right -= (Left - value); Left = value; } - } + public override int GetHashCode() + { + return ((System.Drawing.Rectangle)this).GetHashCode(); + } - public int Y - { - get => Top; - set { Bottom -= (Top - value); Top = value; } - } - - public int Height - { - get => Bottom - Top; - set => Bottom = value + Top; - } - - public int Width - { - get => Right - Left; - set => Right = value + Left; - } - - public System.Drawing.Point Location - { - get => new System.Drawing.Point(Left, Top); - set { X = value.X; Y = value.Y; } - } - - public System.Drawing.Size Size - { - get => new System.Drawing.Size(Width, Height); - set { Width = value.Width; Height = value.Height; } - } - - public static implicit operator System.Drawing.Rectangle(RECT r) - { - return new System.Drawing.Rectangle(r.Left, r.Top, r.Width, r.Height); - } - - public static implicit operator RECT(System.Drawing.Rectangle r) - { - return new RECT(r); - } - - public static bool operator ==(RECT r1, RECT r2) - { - return r1.Equals(r2); - } - - public static bool operator !=(RECT r1, RECT r2) - { - return !r1.Equals(r2); - } - - public bool Equals(RECT r) - { - return r.Left == Left && r.Top == Top && r.Right == Right && r.Bottom == Bottom; - } - - public override bool Equals(object obj) - { - if (obj is RECT rECT) - { - return Equals(rECT); - } - else if (obj is System.Drawing.Rectangle rectangle) - { - return Equals(new RECT(rectangle)); - } - - return false; - } - - public override int GetHashCode() - { - return ((System.Drawing.Rectangle)this).GetHashCode(); - } - - public override string ToString() - { - return string.Format(System.Globalization.CultureInfo.CurrentCulture, "{{Left={0},Top={1},Right={2},Bottom={3}}}", Left, Top, Right, Bottom); - } + public override string ToString() + { + return string.Format(System.Globalization.CultureInfo.CurrentCulture, "{{Left={0},Top={1},Right={2},Bottom={3}}}", Left, Top, Right, Bottom); } } } \ No newline at end of file diff --git a/src/DesktopMagic/MainWindow.xaml.cs b/src/DesktopMagic/MainWindow.xaml.cs index ce87884..852e051 100644 --- a/src/DesktopMagic/MainWindow.xaml.cs +++ b/src/DesktopMagic/MainWindow.xaml.cs @@ -25,8 +25,8 @@ namespace DesktopMagic { #region Global settings - internal static Theme Theme { get; } = new Theme(); public static bool EditMode { get; private set; } = false; + internal static Theme Theme { get; } = new Theme(); #endregion Global settings @@ -42,18 +42,16 @@ namespace DesktopMagic #region Plugins settings - internal static Dictionary> PluginsSettings { get; } = new Dictionary>(); + internal static Dictionary> PluginsSettings { get; } = []; #endregion Plugins settings - public static List Windows { get; } = new List(); - public static List WindowNames { get; } = new List(); private readonly RegistryKey key; private readonly System.Windows.Forms.NotifyIcon notifyIcon = new(); - private bool loaded = false; - private bool blockWindowsClosing = true; + public static List Windows { get; } = []; + public static List WindowNames { get; } = []; public MainWindow() { @@ -126,7 +124,7 @@ namespace DesktopMagic foreach (string fileName in Directory.GetFiles(PluginsPath, "*.dll")) { - string PluginName = fileName[(fileName.LastIndexOf("\\", StringComparison.InvariantCulture) + 1)..].Replace(fileName[fileName.LastIndexOf(".", StringComparison.InvariantCulture)..], ""); + string PluginName = fileName[(fileName.LastIndexOf('\\') + 1)..].Replace(fileName[fileName.LastIndexOf('.')..], ""); try { _ = Directory.CreateDirectory(Path.Combine(PluginsPath, PluginName)); @@ -143,10 +141,10 @@ namespace DesktopMagic foreach (string fileName in Directory.GetFiles(directory).Where(s => s.EndsWith(".dll", StringComparison.InvariantCulture) || s.EndsWith(".cs", StringComparison.InvariantCulture))) { string badChars = ",#-<>?!=()*,. "; - string PluginName = fileName[(fileName.LastIndexOf("\\", StringComparison.InvariantCulture) + 1)..].Replace(fileName[fileName.LastIndexOf(".", StringComparison.InvariantCulture)..], ""); + string PluginName = fileName[(fileName.LastIndexOf('\\') + 1)..].Replace(fileName[fileName.LastIndexOf('.')..], ""); string clearPluginName = PluginName; - if (PluginName == directory[(directory.LastIndexOf("\\", StringComparison.InvariantCulture) + 1)..]) + if (PluginName == directory[(directory.LastIndexOf('\\') + 1)..]) { foreach (char c in badChars) { @@ -156,9 +154,9 @@ namespace DesktopMagic CheckBox checkBox = new() { Name = "_PluginCb_" + clearPluginName, - Content = PluginName + Content = PluginName, + Style = (Style)FindResource("MaterialDesignDarkCheckBox") }; - checkBox.Style = (Style)FindResource("MaterialDesignDarkCheckBox"); checkBox.Click += CheckBox_Click; bool exists = false; @@ -446,7 +444,7 @@ namespace DesktopMagic optionsPanel.UpdateLayout(); bool success = PluginsSettings.TryGetValue(optionsComboBox.SelectedItem.ToString(), out List settingElements); - if (!success || settingElements?.Count == 0) + if (!success || settingElements is null || settingElements.Count == 0) { _ = optionsPanel.Children.Add(new TextBlock() { Text = (string)FindResource("noOptions") }); return; @@ -593,7 +591,7 @@ namespace DesktopMagic string[] data = lines[layoutsComboBox.SelectedIndex].Split(';'); foreach (string dat in data.Where(dat => dat.Contains(':'))) { - string value = dat[(dat.LastIndexOf(":", StringComparison.InvariantCulture) + 1)..]; + string value = dat[(dat.LastIndexOf(':') + 1)..]; string name = dat.Replace(":" + value, ""); key.SetValue(name, value); } @@ -638,7 +636,7 @@ namespace DesktopMagic return; } - List lines = File.ReadAllLines(App.ApplicationDataPath + "\\layouts.save").ToList(); + List lines = [.. File.ReadAllLines(App.ApplicationDataPath + "\\layouts.save")]; lines.RemoveAt(layoutsComboBox.SelectedIndex); File.WriteAllLines(App.ApplicationDataPath + "\\layouts.save", lines); LoadLayoutNames(); @@ -656,7 +654,7 @@ namespace DesktopMagic { lock (App.ApplicationDataPath) { - List lines = File.ReadAllLines(App.ApplicationDataPath + "\\layouts.save").ToList(); + List lines = [.. File.ReadAllLines(App.ApplicationDataPath + "\\layouts.save")]; StringBuilder content = new StringBuilder(); foreach (string valueName in key.GetValueNames()) { @@ -682,7 +680,7 @@ namespace DesktopMagic foreach (string line in lines) { - string name = line[(line.LastIndexOf(";", StringComparison.InvariantCulture) + 1)..]; + string name = line[(line.LastIndexOf(';') + 1)..]; _ = layoutsComboBox.Items.Add(name); } layoutsComboBox.SelectedIndex = int.Parse(key.GetValue("SelectedLayout", "0").ToString(), CultureInfo.InvariantCulture); @@ -857,7 +855,7 @@ namespace DesktopMagic private void SetLanguageDictionary() { - ResourceDictionary dict = new ResourceDictionary(); + ResourceDictionary dict = []; string currentCulture = Thread.CurrentThread.CurrentUICulture.ToString(); if (currentCulture.Contains("de")) diff --git a/src/DesktopMagic/Plugins/PluginData.cs b/src/DesktopMagic/Plugins/PluginData.cs index 9092edc..93b6613 100644 --- a/src/DesktopMagic/Plugins/PluginData.cs +++ b/src/DesktopMagic/Plugins/PluginData.cs @@ -4,14 +4,9 @@ using System.Drawing; namespace DesktopMagic.Plugins; -internal class PluginData : IPluginData +internal class PluginData(PluginWindow window) : IPluginData { - private readonly PluginWindow window; - - public PluginData(PluginWindow window) - { - this.window = window; - } + private readonly PluginWindow window = window; public string Font => Theme.Font; diff --git a/src/DesktopMagic/Plugins/PluginWindow.xaml.cs b/src/DesktopMagic/Plugins/PluginWindow.xaml.cs index 178134a..56b1ed3 100644 --- a/src/DesktopMagic/Plugins/PluginWindow.xaml.cs +++ b/src/DesktopMagic/Plugins/PluginWindow.xaml.cs @@ -24,6 +24,10 @@ namespace DesktopMagic; public partial class PluginWindow : Window { + public event Action PluginLoaded; + + public event Action OnExit; + private readonly RegistryKey key; private Thread pluginThread; private System.Timers.Timer valueTimer; @@ -34,10 +38,6 @@ public partial class PluginWindow : Window public string PluginName { get; private set; } public string PluginFolderPath { get; private set; } - public event Action PluginLoaded; - - public event Action OnExit; - public PluginWindow(string pluginName) { InitializeComponent(); @@ -77,6 +77,21 @@ public partial class PluginWindow : Window this.pluginClassInstance = pluginClassInstance; } + public void UpdatePluginWindow() + { + ValueTimer_Elapsed(valueTimer, null); + } + + public void Exit() + { + IsRunning = false; + + Dispatcher.Invoke(() => + { + OnExit?.Invoke(); + }); + } + protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); @@ -87,18 +102,26 @@ public partial class PluginWindow : Window WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE); } - private void Window_ContentRendered(object sender, EventArgs e) + private static BitmapSource BitmapToImageSource(Bitmap bitmap) { - pluginThread = new Thread(() => - { - LoadPlugin(); - }); - pluginThread.Start(); + BitmapData bitmapData = bitmap.LockBits( + new Rectangle(0, 0, bitmap.Width, bitmap.Height), + ImageLockMode.ReadOnly, bitmap.PixelFormat); + + BitmapSource bitmapSource = BitmapSource.Create( + bitmapData.Width, bitmapData.Height, + bitmap.HorizontalResolution, bitmap.VerticalResolution, + PixelFormats.Bgra32, null, + bitmapData.Scan0, bitmapData.Stride * bitmapData.Height, bitmapData.Stride); + + bitmap.UnlockBits(bitmapData); + return bitmapSource; } - public void UpdatePluginWindow() + private void Window_ContentRendered(object sender, EventArgs e) { - ValueTimer_Elapsed(valueTimer, null); + pluginThread = new Thread(LoadPlugin); + pluginThread.Start(); } private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e) @@ -171,7 +194,7 @@ public partial class PluginWindow : Window { byte[] assemblyBytes = File.ReadAllBytes($"{PluginFolderPath}\\{PluginName}.dll"); Assembly dll = Assembly.Load(assemblyBytes); - Type instanceType = dll.GetTypes().FirstOrDefault(type => type.GetTypeInfo().BaseType == typeof(Plugin)); + Type instanceType = Array.Find(dll.GetTypes(), type => type.GetTypeInfo().BaseType == typeof(Plugin)); if (instanceType is null) { @@ -220,7 +243,7 @@ public partial class PluginWindow : Window FieldInfo[] props = instance.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.GetField); #pragma warning restore S3011 // Reflection should not be used to increase accessibility of classes, methods, or fields - List settingElements = new List(); + List settingElements = []; foreach (FieldInfo prop in props) { if (prop.GetValue(instance) is Element element) @@ -237,15 +260,11 @@ public partial class PluginWindow : Window } } - settingElements = settingElements.OrderBy(x => x.OrderIndex).ToList(); - if (MainWindow.PluginsSettings.ContainsKey(PluginName)) + settingElements = [.. settingElements.OrderBy(x => x.OrderIndex)]; + if (!MainWindow.PluginsSettings.TryAdd(PluginName, settingElements)) { MainWindow.PluginsSettings[PluginName] = settingElements; } - else - { - MainWindow.PluginsSettings.Add(PluginName, settingElements); - } } catch (Exception ex) { @@ -307,32 +326,6 @@ public partial class PluginWindow : Window } } - private static BitmapSource BitmapToImageSource(Bitmap bitmap) - { - BitmapData bitmapData = bitmap.LockBits( - new Rectangle(0, 0, bitmap.Width, bitmap.Height), - ImageLockMode.ReadOnly, bitmap.PixelFormat); - - BitmapSource bitmapSource = BitmapSource.Create( - bitmapData.Width, bitmapData.Height, - bitmap.HorizontalResolution, bitmap.VerticalResolution, - PixelFormats.Bgra32, null, - bitmapData.Scan0, bitmapData.Stride * bitmapData.Height, bitmapData.Stride); - - bitmap.UnlockBits(bitmapData); - return bitmapSource; - } - - public void Exit() - { - IsRunning = false; - - Dispatcher.Invoke(() => - { - OnExit?.Invoke(); - }); - } - private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { pluginClassInstance?.Stop(); diff --git a/src/DesktopMagic/Plugins/SettingElement.cs b/src/DesktopMagic/Plugins/SettingElement.cs index 2eec58d..5ae108b 100644 --- a/src/DesktopMagic/Plugins/SettingElement.cs +++ b/src/DesktopMagic/Plugins/SettingElement.cs @@ -2,16 +2,9 @@ namespace DesktopMagic.Plugins; -internal class SettingElement +internal class SettingElement(Element element, string name, int orderIndex) { - public Element Element { get; } - public string Name { get; } - public int OrderIndex { get; } - - public SettingElement(Element element, string name, int orderIndex) - { - Element = element; - Name = name; - OrderIndex = orderIndex; - } + public Element Element { get; } = element; + public string Name { get; } = name; + public int OrderIndex { get; } = orderIndex; } \ No newline at end of file diff --git a/src/DesktopMagicPlugin.Test/DesktopMagicPlugin.Test.csproj b/src/DesktopMagicPlugin.Test/DesktopMagicPlugin.Test.csproj index f050f7c..045de12 100644 --- a/src/DesktopMagicPlugin.Test/DesktopMagicPlugin.Test.csproj +++ b/src/DesktopMagicPlugin.Test/DesktopMagicPlugin.Test.csproj @@ -1,11 +1,12 @@  - net6.0 + net8.0-windows + Library - + diff --git a/src/DesktopMagicPlugin.Test/PluginScript.cs b/src/DesktopMagicPlugin.Test/PluginScript.cs index 19a386a..39ccaf4 100644 --- a/src/DesktopMagicPlugin.Test/PluginScript.cs +++ b/src/DesktopMagicPlugin.Test/PluginScript.cs @@ -8,82 +8,81 @@ using System.Drawing.Imaging; using System.IO; using System.Threading.Tasks; -namespace DesktopMagicPlugin.Test +namespace DesktopMagicPlugin.Test; + +public class GifPlugin : Plugin { - public class GifPlugin : Plugin + private const string SaveFilePath = "gifPath.txt"; + + [Element("Gif path:")] + private readonly TextBox input = new TextBox(""); + + [Element] + private readonly Label info = new Label(""); + + private readonly List bitmaps = []; + + private int frameCount = -1; + + public override void Start() { - [Element("Gif path:")] - private readonly TextBox input = new TextBox(""); - - [Element] - private readonly Label info = new Label(""); - - private readonly List bitmaps = new List(); - - private int frameCount = -1; - - private const string SaveFilePath = "gifPath.txt"; - - public override void Start() + input.OnValueChanged += Input_OnValueChanged; + if (File.Exists(SaveFilePath)) { - input.OnValueChanged += Input_OnValueChanged; - if (File.Exists(SaveFilePath)) - { - input.Value = File.ReadAllText(SaveFilePath); - } - } - - private void Input_OnValueChanged() - { - _ = Task.Run(() => - { - try - { - if (File.Exists(input.Value)) - { - info.Value = "Loading..."; - Image gif = Image.FromFile(input.Value); - - PropertyItem item = gif.GetPropertyItem(0x5100); // FrameDelay in libgdiplus - - UpdateInterval = (item.Value[0] + item.Value[1] * 256) * 10; //FrameDelay in ms - bitmaps.Clear(); - for (int i = 0; i < gif.GetFrameCount(FrameDimension.Time); i++) - { - gif.SelectActiveFrame(FrameDimension.Time, i); - - bitmaps.Add(new Bitmap(gif)); - } - File.WriteAllText(SaveFilePath, input.Value); - info.Value = string.Empty; - } - else - { - info.Value = "File not found!"; - } - } - catch (Exception ex) - { - info.Value = $"Error: {ex.Message}"; - } - }); - } - - public override Bitmap Main() - { - if (bitmaps.Count == 0) - { - return new Bitmap(1, 1); - } - - frameCount++; - - if (frameCount >= bitmaps.Count) - { - frameCount = 0; - } - - return bitmaps[frameCount]; + input.Value = File.ReadAllText(SaveFilePath); } } + + public override Bitmap Main() + { + if (bitmaps.Count == 0) + { + return new Bitmap(1, 1); + } + + frameCount++; + + if (frameCount >= bitmaps.Count) + { + frameCount = 0; + } + + return bitmaps[frameCount]; + } + + private void Input_OnValueChanged() + { + _ = Task.Run(() => + { + try + { + if (File.Exists(input.Value)) + { + info.Value = "Loading..."; + Image gif = Image.FromFile(input.Value); + + PropertyItem item = gif.GetPropertyItem(0x5100); // FrameDelay in libgdiplus + + UpdateInterval = (item.Value[0] + (item.Value[1] * 256)) * 10; //FrameDelay in ms + bitmaps.Clear(); + for (int i = 0; i < gif.GetFrameCount(FrameDimension.Time); i++) + { + _ = gif.SelectActiveFrame(FrameDimension.Time, i); + + bitmaps.Add(new Bitmap(gif)); + } + File.WriteAllText(SaveFilePath, input.Value); + info.Value = string.Empty; + } + else + { + info.Value = "File not found!"; + } + } + catch (Exception ex) + { + info.Value = $"Error: {ex.Message}"; + } + }); + } } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/.gitignore b/src/DesktopMagicPluginAPI/.gitignore deleted file mode 100644 index 4378419..0000000 --- a/src/DesktopMagicPluginAPI/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -############### -# folder # -############### -/**/DROP/ -/**/TEMP/ -/**/packages/ -/**/bin/ -/**/obj/ -_site diff --git a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.csproj b/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.csproj index 1276f4b..fd6b028 100644 --- a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.csproj +++ b/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0-windows Stone_Red Stone_Red 0.0.0.5 @@ -22,11 +22,7 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + diff --git a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.xml b/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.xml deleted file mode 100644 index e11ef9c..0000000 --- a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.xml +++ /dev/null @@ -1,468 +0,0 @@ - - - - DesktopMagicPluginAPI - - - - - Extensions for the class. - - - - - - - Graphics object. - String to draw. - that defines the text format of the string. - that determines the color and texture of the drawn text. - The x-coordinate of the upper-left corner of the drawn text. - The y-coordinate of the upper-left corner of the drawn text. - - - - - - Graphics object. - String to draw. - that defines the text format of the string. - that determines the color and texture of the drawn text. - structure that specifies the upper-left corner of the drawn text. - - - - - - Graphics object. - String to draw. - that defines the text format of the string. - that determines the color and texture of the drawn text. - The x-coordinate of the upper-left corner of the drawn text. - The y-coordinate of the upper-left corner of the drawn text. - /// The specified width. - - - - - - Graphics object. - String to draw. - that defines the text format of the string. - that determines the color and texture of the drawn text. - structure that specifies the upper-left corner of the drawn text. - The specified width. - - - - - - Graphics object. - String to draw. - that defines the text format of the string. - that determines the color and texture of the drawn text. - The x-coordinate of the upper-left corner of the drawn text. - The y-coordinate of the upper-left corner of the drawn text. - - - - - - Graphics object. - String to draw. - that defines the text format of the string. - that determines the color and texture of the drawn text. - structure that specifies the upper-left corner of the drawn text. - - - - - - Graphics object. - String to measure. - that defines the text format of the string. - - - - - Specifies which render quality is used to display the bitmap images. - - - - - Slower then but produces higher quality output. - - - - - Faster then but produces lower quality output. - - - - - Provides performance benefits over - - - - - Represents a button control. - - - - - Occurs when the button gets clicked. - - - - - Gets or sets the text caption displayed in the element. - - - - - Initializes a new instance of the class with the provided . - - The text caption displayed in the control. - - - - Triggers the event. - - - - - Represents a check box control. - - - - - Gets or set a value indicating whether the is in the checked state. - - - - - Initializes a new instance of the class with the provided . - - A value indicating whether the is in the checked state. - - - - Represents a selection control with a drop-down list. - - - - - Gets the collection used to generate the content of the . - - - - - Gets the currently selected item associated with this . - - If you assign a value to this property, the displayed text in the user interface will not be changed. - - - - Initializes a new instance of the class with the provided . - - - - - - The element base class. - - - - - Occurs when the value has been changed. - - - - - Triggers the event. - - - - - Marks a Property as element. - - - - - The name of the element. - - - - - The order index of the element. - - - - - Marks a Property as element with the provided and . - - The name of the element. - The order index of the element. - - - - Marks a Property as element with the provided . - - The order index of the element. - - - - - - - Represents a up-down control. - - - - - Gets or sets the maximum value for the element. - - - - - Gets or sets the minimum value for the element. - - - - - Gets or sets the value assigned to the element. - - - - - Initializes a new instance of the class with the provided value, value and . - - The maximum value for the element. - The minimum value for the element. - The value assigned to the element. - - - - - Represents a label control. - - - - - Gets or sets the text associated with this . - - - - - Gets or set a value indicating whether the content of the is bold or not. - - - - - Initializes a new instance of the class with the provided . - - The text associated with this - A value indicating whether the content of the is bold or not. - - - - Mouse Buttons - - - - - The left mouse button. - - - - - The middle mouse button. - - - - - The right mouse button. - - - - - Represents a slider control. - - - - - Gets or sets the maximum value for the element. - - - - - Gets or sets the minimum value for the element. - - - - - Gets or sets the value assigned to the element. - - - - - Initializes a new instance of the class with the provided value, value and . - - The maximum value for the element. - The minimum value for the element. - The value assigned to the element. - - - - Represents a text box control. - - - - - Gets or sets the text associated with this . - - - - - Initializes a new instance of the class with the provided . - - The text associated with this control. - - - - Defines properties and methods that provide information about the main application. - - - - - Gets the current font of the current theme. - - - - - Gets the current color of the current theme. - - - - - Gets the current theme setting of the main application. - - - - - Gets the window size of the plugin window. - - - - - Gets the window position of the plugin window. - - - - - Gets the name of the plugin. - - - - - Gets the path of the parent directory of the plugin. - - - - - Updates the plugin window. - - - - - The theme settings of the main application. - - - - - Gets the primary color of the current theme. - - - - - Gets the secondary color of the current theme. - - - - - Gets the background color of the current theme. - - - - - Gets the font of the current theme. - - - - - Gets the corner radius of the current theme. - - - - - Gets the corner radius of the current theme. - - - - - The plugin class. - - - - - Informations about the main application. - - - - - Gets or sets the interval, expressed in milliseconds, at which to call the method. - - - - - Gets or sets the render quality of the bitmap image. - - - - - Occurs once when the plugin gets activated. - - - - - Occurs once when the plugin gets deactivated. - - - - - Occurs when the elapses. - - - - - - Occurs when the window is clicked by the mouse. - - The x- and y-coordinates of the mouse pointer position relative to the plugin window. - The button associated with the event. - - - - Occurs when the mouse pointer is moved over the control. - - The x- and y-coordinates of the mouse pointer position relative to the plugin window. - - - - Occurs when the user rotates the mouse wheel while the mouse pointer is over this element. - - The x- and y-coordinates of the mouse pointer position relative to the plugin window. - A value that indicates the amount that the mouse wheel has changed. - - - diff --git a/src/DesktopMagicPluginAPI/Drawing/FontComparer.cs b/src/DesktopMagicPluginAPI/Drawing/FontComparer.cs index aa994a9..df72204 100644 --- a/src/DesktopMagicPluginAPI/Drawing/FontComparer.cs +++ b/src/DesktopMagicPluginAPI/Drawing/FontComparer.cs @@ -1,26 +1,33 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace DesktopMagicPluginAPI.Drawing +namespace DesktopMagicPluginAPI.Drawing; + +internal class FontComparer : IEqualityComparer { - internal class FontComparer : IEqualityComparer + public bool Equals(Font font1, Font font2) { - public bool Equals(Font font1, Font font2) + if (font1.Name != font2.Name) { - if (font1.Name != font2.Name) return false; - if (font1.SizeInPoints != font2.SizeInPoints) return false; - if (font1.Style != font2.Style) return false; - return true; + return false; } - public int GetHashCode([DisallowNull] Font obj) + if (font1.SizeInPoints != font2.SizeInPoints) { - return obj.GetHashCode(); + return false; } + + if (font1.Style != font2.Style) + { + return false; + } + + return true; + } + + public int GetHashCode([DisallowNull] Font obj) + { + return obj.GetHashCode(); } } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/Drawing/GraphicsExtentions.cs b/src/DesktopMagicPluginAPI/Drawing/GraphicsExtentions.cs index a984bb4..74f9f59 100644 --- a/src/DesktopMagicPluginAPI/Drawing/GraphicsExtentions.cs +++ b/src/DesktopMagicPluginAPI/Drawing/GraphicsExtentions.cs @@ -2,184 +2,183 @@ using System.Collections.Generic; using System.Drawing; -namespace DesktopMagicPluginAPI.Drawing +namespace DesktopMagicPluginAPI.Drawing; + +/// +/// Extensions for the class. +/// +public static class GraphicsExtentions { + private static readonly Dictionary fonts = new Dictionary(new FontComparer()); + /// - /// Extensions for the class. + /// /// - public static class GraphicsExtentions + /// Graphics object. + /// String to draw. + /// that defines the text format of the string. + /// that determines the color and texture of the drawn text. + /// The x-coordinate of the upper-left corner of the drawn text. + /// The y-coordinate of the upper-left corner of the drawn text. + public static void DrawStringMonospace(this Graphics graphics, string s, Font font, Brush brush, float x, float y) { - private static readonly Dictionary fonts = new Dictionary(new FontComparer()); + int widest = graphics.GetWidestChar(font); - /// - /// - /// - /// Graphics object. - /// String to draw. - /// that defines the text format of the string. - /// that determines the color and texture of the drawn text. - /// The x-coordinate of the upper-left corner of the drawn text. - /// The y-coordinate of the upper-left corner of the drawn text. - public static void DrawStringMonospace(this Graphics graphics, string s, Font font, Brush brush, float x, float y) + for (int i = 0; i < s.Length; i++) { - int widest = graphics.GetWidestChar(font); + graphics.DrawString(s[i].ToString(), font, brush, x, y); - for (int i = 0; i < s.Length; i++) - { - graphics.DrawString(s[i].ToString(), font, brush, x, y); - - x += widest; - } - } - - /// - /// - /// - /// Graphics object. - /// String to draw. - /// that defines the text format of the string. - /// that determines the color and texture of the drawn text. - /// structure that specifies the upper-left corner of the drawn text. - public static void DrawStringMonospace(this Graphics graphics, string s, Font font, Brush brush, PointF point) - { - int widest = graphics.GetWidestChar(font); - - for (int i = 0; i < s.Length; i++) - { - graphics.DrawString(s[i].ToString(), font, brush, point); - - point.X += widest; - } - } - - /// - /// - /// - /// Graphics object. - /// String to draw. - /// that defines the text format of the string. - /// that determines the color and texture of the drawn text. - /// The x-coordinate of the upper-left corner of the drawn text. - /// The y-coordinate of the upper-left corner of the drawn text. - /// /// The specified width. - public static void DrawStringFixedWidth(this Graphics graphics, string s, Font font, Brush brush, float x, float y, float width) - { - for (int i = 0; i < s.Length; i++) - { - graphics.DrawString(s[i].ToString(), font, brush, x, y); - - x += width; - } - } - - /// - /// - /// - /// Graphics object. - /// String to draw. - /// that defines the text format of the string. - /// that determines the color and texture of the drawn text. - /// structure that specifies the upper-left corner of the drawn text. - /// The specified width. - public static void DrawStringFixedWidth(this Graphics graphics, string s, Font font, Brush brush, PointF point, float width) - { - for (int i = 0; i < s.Length; i++) - { - graphics.DrawString(s[i].ToString(), font, brush, point); - - point.X += width; - } - } - - /// - /// - /// - /// Graphics object. - /// String to draw. - /// that defines the text format of the string. - /// that determines the color and texture of the drawn text. - /// The x-coordinate of the upper-left corner of the drawn text. - /// The y-coordinate of the upper-left corner of the drawn text. - public static void DrawStringNoLeftPadding(this Graphics graphics, string s, Font font, Brush brush, float x, float y) - { - // measure left padding - StringFormat sf = new StringFormat(StringFormatFlags.NoClip); - sf.SetMeasurableCharacterRanges(new CharacterRange[] { new CharacterRange(0, 1) }); - Region[] r = graphics.MeasureCharacterRanges(s, font, new RectangleF(0, 0, 1000, 100), sf); - float leftPadding = r[0].GetBounds(graphics).Left; - - // draw string - sf = new StringFormat(StringFormatFlags.NoClip); - graphics.DrawString(s, font, brush, x - leftPadding, y, sf); - } - - /// - /// - /// - /// Graphics object. - /// String to draw. - /// that defines the text format of the string. - /// that determines the color and texture of the drawn text. - /// structure that specifies the upper-left corner of the drawn text. - public static void DrawStringNoLeftPadding(this Graphics graphics, string s, Font font, Brush brush, PointF point) - { - // measure left padding - StringFormat sf = new StringFormat(StringFormatFlags.NoClip); - sf.SetMeasurableCharacterRanges(new CharacterRange[] { new CharacterRange(0, 1) }); - Region[] r = graphics.MeasureCharacterRanges(s, font, new RectangleF(0, 0, 1000, 100), sf); - float leftPadding = r[0].GetBounds(graphics).Left; - - // draw string - sf = new StringFormat(StringFormatFlags.NoClip); - graphics.DrawString(s, font, brush, point.X - leftPadding, point.Y, sf); - } - - /// - /// - /// - /// Graphics object. - /// String to measure. - /// that defines the text format of the string. - /// - public static SizeF MeasureStringNoLeftPadding(this Graphics graphics, string text, Font font) - { - SizeF size = graphics.MeasureString(text, font, int.MaxValue); - - StringFormat sf = new StringFormat(StringFormatFlags.NoClip); - sf.SetMeasurableCharacterRanges(new CharacterRange[] { new CharacterRange(0, 1) }); - Region[] r = graphics.MeasureCharacterRanges(text, font, new RectangleF(0, 0, 1000, 100), sf); - float leftPadding = r[0].GetBounds(graphics).Left; - - size.Width -= leftPadding / 1.5f; - return size; - } - - private static int GetWidestChar(this Graphics graphics, Font font) - { - if (fonts.ContainsKey(font)) - { - return fonts[font]; - } - - float max = 0; - char maxx = ' '; - for (int i = 0; i <= 255; i++) - { - char c = (char)i; - if (char.IsLetterOrDigit(c)) - { - float neww = graphics.MeasureString(c.ToString(), font).Width; - if (neww >= max) - { - max = neww; - maxx = c; - } - } - } - Console.WriteLine((int)Math.Round(max, 0)); - Console.WriteLine(maxx); - fonts.Add(font, (int)Math.Round(max, 0)); - return (int)Math.Round(max, 0); + x += widest; } } + + /// + /// + /// + /// Graphics object. + /// String to draw. + /// that defines the text format of the string. + /// that determines the color and texture of the drawn text. + /// structure that specifies the upper-left corner of the drawn text. + public static void DrawStringMonospace(this Graphics graphics, string s, Font font, Brush brush, PointF point) + { + int widest = graphics.GetWidestChar(font); + + for (int i = 0; i < s.Length; i++) + { + graphics.DrawString(s[i].ToString(), font, brush, point); + + point.X += widest; + } + } + + /// + /// + /// + /// Graphics object. + /// String to draw. + /// that defines the text format of the string. + /// that determines the color and texture of the drawn text. + /// The x-coordinate of the upper-left corner of the drawn text. + /// The y-coordinate of the upper-left corner of the drawn text. + /// /// The specified width. + public static void DrawStringFixedWidth(this Graphics graphics, string s, Font font, Brush brush, float x, float y, float width) + { + for (int i = 0; i < s.Length; i++) + { + graphics.DrawString(s[i].ToString(), font, brush, x, y); + + x += width; + } + } + + /// + /// + /// + /// Graphics object. + /// String to draw. + /// that defines the text format of the string. + /// that determines the color and texture of the drawn text. + /// structure that specifies the upper-left corner of the drawn text. + /// The specified width. + public static void DrawStringFixedWidth(this Graphics graphics, string s, Font font, Brush brush, PointF point, float width) + { + for (int i = 0; i < s.Length; i++) + { + graphics.DrawString(s[i].ToString(), font, brush, point); + + point.X += width; + } + } + + /// + /// + /// + /// Graphics object. + /// String to draw. + /// that defines the text format of the string. + /// that determines the color and texture of the drawn text. + /// The x-coordinate of the upper-left corner of the drawn text. + /// The y-coordinate of the upper-left corner of the drawn text. + public static void DrawStringNoLeftPadding(this Graphics graphics, string s, Font font, Brush brush, float x, float y) + { + // measure left padding + StringFormat sf = new StringFormat(StringFormatFlags.NoClip); + sf.SetMeasurableCharacterRanges([new CharacterRange(0, 1)]); + Region[] r = graphics.MeasureCharacterRanges(s, font, new RectangleF(0, 0, 1000, 100), sf); + float leftPadding = r[0].GetBounds(graphics).Left; + + // draw string + sf = new StringFormat(StringFormatFlags.NoClip); + graphics.DrawString(s, font, brush, x - leftPadding, y, sf); + } + + /// + /// + /// + /// Graphics object. + /// String to draw. + /// that defines the text format of the string. + /// that determines the color and texture of the drawn text. + /// structure that specifies the upper-left corner of the drawn text. + public static void DrawStringNoLeftPadding(this Graphics graphics, string s, Font font, Brush brush, PointF point) + { + // measure left padding + StringFormat sf = new StringFormat(StringFormatFlags.NoClip); + sf.SetMeasurableCharacterRanges([new CharacterRange(0, 1)]); + Region[] r = graphics.MeasureCharacterRanges(s, font, new RectangleF(0, 0, 1000, 100), sf); + float leftPadding = r[0].GetBounds(graphics).Left; + + // draw string + sf = new StringFormat(StringFormatFlags.NoClip); + graphics.DrawString(s, font, brush, point.X - leftPadding, point.Y, sf); + } + + /// + /// + /// + /// Graphics object. + /// String to measure. + /// that defines the text format of the string. + /// + public static SizeF MeasureStringNoLeftPadding(this Graphics graphics, string text, Font font) + { + SizeF size = graphics.MeasureString(text, font, int.MaxValue); + + StringFormat sf = new StringFormat(StringFormatFlags.NoClip); + sf.SetMeasurableCharacterRanges([new CharacterRange(0, 1)]); + Region[] r = graphics.MeasureCharacterRanges(text, font, new RectangleF(0, 0, 1000, 100), sf); + float leftPadding = r[0].GetBounds(graphics).Left; + + size.Width -= leftPadding / 1.5f; + return size; + } + + private static int GetWidestChar(this Graphics graphics, Font font) + { + if (fonts.TryGetValue(font, out int value)) + { + return value; + } + + float max = 0; + char maxx = ' '; + for (int i = 0; i <= 255; i++) + { + char c = (char)i; + if (char.IsLetterOrDigit(c)) + { + float neww = graphics.MeasureString(c.ToString(), font).Width; + if (neww >= max) + { + max = neww; + maxx = c; + } + } + } + Console.WriteLine((int)Math.Round(max, 0)); + Console.WriteLine(maxx); + fonts.Add(font, (int)Math.Round(max, 0)); + return (int)Math.Round(max, 0); + } } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/Drawing/RenderQuality.cs b/src/DesktopMagicPluginAPI/Drawing/RenderQuality.cs index 41a8e75..08d7fe9 100644 --- a/src/DesktopMagicPluginAPI/Drawing/RenderQuality.cs +++ b/src/DesktopMagicPluginAPI/Drawing/RenderQuality.cs @@ -1,29 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace DesktopMagicPluginAPI.Drawing; -namespace DesktopMagicPluginAPI.Drawing +/// +/// Specifies which render quality is used to display the bitmap images. +/// +public enum RenderQuality { /// - /// Specifies which render quality is used to display the bitmap images. + /// Slower then but produces higher quality output. /// - public enum RenderQuality - { - /// - /// Slower then but produces higher quality output. - /// - High, + High, - /// - /// Faster then but produces lower quality output. - /// - Low, + /// + /// Faster then but produces lower quality output. + /// + Low, - /// - /// Provides performance benefits over - /// - Performance - } + /// + /// Provides performance benefits over + /// + Performance } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/IPluginData.cs b/src/DesktopMagicPluginAPI/IPluginData.cs index aaabd7a..a34bc4d 100644 --- a/src/DesktopMagicPluginAPI/IPluginData.cs +++ b/src/DesktopMagicPluginAPI/IPluginData.cs @@ -1,53 +1,52 @@ using System; using System.Drawing; -namespace DesktopMagicPluginAPI +namespace DesktopMagicPluginAPI; + +/// +/// Defines properties and methods that provide information about the main application. +/// +public interface IPluginData { /// - /// Defines properties and methods that provide information about the main application. + /// Gets the current font of the current theme. /// - public interface IPluginData - { - /// - /// Gets the current font of the current theme. - /// - [Obsolete("Use the \"Theme\" property instead")] - string Font { get; } + [Obsolete("Use the \"Theme\" property instead")] + string Font { get; } - /// - /// Gets the current color of the current theme. - /// - [Obsolete("Use the \"Theme\" property instead")] - Color Color { get; } + /// + /// Gets the current color of the current theme. + /// + [Obsolete("Use the \"Theme\" property instead")] + Color Color { get; } - /// - /// Gets the current theme setting of the main application. - /// - ITheme Theme { get; } + /// + /// Gets the current theme setting of the main application. + /// + ITheme Theme { get; } - /// - /// Gets the window size of the plugin window. - /// - Size WindowSize { get; } + /// + /// Gets the window size of the plugin window. + /// + Size WindowSize { get; } - /// - /// Gets the window position of the plugin window. - /// - Point WindowPosition { get; } + /// + /// Gets the window position of the plugin window. + /// + Point WindowPosition { get; } - /// - /// Gets the name of the plugin. - /// - string PluginName { get; } + /// + /// Gets the name of the plugin. + /// + string PluginName { get; } - /// - /// Gets the path of the parent directory of the plugin. - /// - string PluginPath { get; } + /// + /// Gets the path of the parent directory of the plugin. + /// + string PluginPath { get; } - /// - /// Updates the plugin window. - /// - void UpdateWindow(); - } + /// + /// Updates the plugin window. + /// + void UpdateWindow(); } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/ITheme.cs b/src/DesktopMagicPluginAPI/ITheme.cs index 7d5f8f9..e952a5f 100644 --- a/src/DesktopMagicPluginAPI/ITheme.cs +++ b/src/DesktopMagicPluginAPI/ITheme.cs @@ -1,40 +1,39 @@ using System.Drawing; -namespace DesktopMagicPluginAPI +namespace DesktopMagicPluginAPI; + +/// +/// The theme settings of the main application. +/// +public interface ITheme { /// - /// The theme settings of the main application. + /// Gets the primary color of the current theme. /// - public interface ITheme - { - /// - /// Gets the primary color of the current theme. - /// - Color PrimaryColor { get; } + Color PrimaryColor { get; } - /// - /// Gets the secondary color of the current theme. - /// - Color SecondaryColor { get; } + /// + /// Gets the secondary color of the current theme. + /// + Color SecondaryColor { get; } - /// - /// Gets the background color of the current theme. - /// - Color BackgroundColor { get; } + /// + /// Gets the background color of the current theme. + /// + Color BackgroundColor { get; } - /// - /// Gets the font of the current theme. - /// - string Font { get; } + /// + /// Gets the font of the current theme. + /// + string Font { get; } - /// - /// Gets the corner radius of the current theme. - /// - int CornerRadius { get; } + /// + /// Gets the corner radius of the current theme. + /// + int CornerRadius { get; } - /// - /// Gets the corner radius of the current theme. - /// - int Margin { get; } - } + /// + /// Gets the corner radius of the current theme. + /// + int Margin { get; } } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/Inputs/Button.cs b/src/DesktopMagicPluginAPI/Inputs/Button.cs index c8e813c..51e9694 100644 --- a/src/DesktopMagicPluginAPI/Inputs/Button.cs +++ b/src/DesktopMagicPluginAPI/Inputs/Button.cs @@ -1,50 +1,49 @@ using System; -namespace DesktopMagicPluginAPI.Inputs +namespace DesktopMagicPluginAPI.Inputs; + +/// +/// Represents a button control. +/// +public class Button : Element { /// - /// Represents a button control. + /// Occurs when the button gets clicked. /// - public class Button : Element + public event Action OnClick; + + private string _value; + + /// + /// Gets or sets the text caption displayed in the element. + /// + public string Value { - /// - /// Occurs when the button gets clicked. - /// - public event Action OnClick; - - private string _value; - - /// - /// Gets or sets the text caption displayed in the element. - /// - public string Value + get => _value; + set { - get => _value; - set + if (_value != value) { - if (_value != value) - { - _value = value; - ValueChanged(); - } + _value = value; + ValueChanged(); } } + } - /// - /// Initializes a new instance of the class with the provided . - /// - /// The text caption displayed in the control. - public Button(string value) - { - Value = value; - } + /// + /// Initializes a new instance of the class with the provided . + /// + /// The text caption displayed in the control. + public Button(string value) + { + Value = value; + } - /// - /// Triggers the event. - /// - public void Click() - { - OnClick?.Invoke(); - } + /// + /// Triggers the event. + /// + public void Click() + { + OnClick?.Invoke(); } } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/Inputs/CheckBox.cs b/src/DesktopMagicPluginAPI/Inputs/CheckBox.cs index f51c4f5..3cc9625 100644 --- a/src/DesktopMagicPluginAPI/Inputs/CheckBox.cs +++ b/src/DesktopMagicPluginAPI/Inputs/CheckBox.cs @@ -1,35 +1,34 @@ -namespace DesktopMagicPluginAPI.Inputs -{ - /// - /// Represents a check box control. - /// - public class CheckBox : Element - { - private bool _value; +namespace DesktopMagicPluginAPI.Inputs; - /// - /// Gets or set a value indicating whether the is in the checked state. - /// - public bool Value +/// +/// Represents a check box control. +/// +public class CheckBox : Element +{ + private bool _value; + + /// + /// Gets or set a value indicating whether the is in the checked state. + /// + public bool Value + { + get => _value; + set { - get => _value; - set + if (_value != value) { - if (_value != value) - { - _value = value; - ValueChanged(); - } + _value = value; + ValueChanged(); } } + } - /// - /// Initializes a new instance of the class with the provided . - /// - /// A value indicating whether the is in the checked state. - public CheckBox(bool value) - { - Value = value; - } + /// + /// Initializes a new instance of the class with the provided . + /// + /// A value indicating whether the is in the checked state. + public CheckBox(bool value) + { + Value = value; } } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/Inputs/ComboBox.cs b/src/DesktopMagicPluginAPI/Inputs/ComboBox.cs index 3bfa2d5..0fccc37 100644 --- a/src/DesktopMagicPluginAPI/Inputs/ComboBox.cs +++ b/src/DesktopMagicPluginAPI/Inputs/ComboBox.cs @@ -1,46 +1,45 @@ using System.Collections.ObjectModel; -namespace DesktopMagicPluginAPI.Inputs +namespace DesktopMagicPluginAPI.Inputs; + +/// +/// Represents a selection control with a drop-down list. +/// +public class ComboBox : Element { + private string _value; + /// - /// Represents a selection control with a drop-down list. + /// Gets the collection used to generate the content of the . /// - public class ComboBox : Element + public ObservableCollection Items { get; } = []; + + /// + /// Gets the currently selected item associated with this . + /// + /// If you assign a value to this property, the displayed text in the user interface will not be changed. + public string Value { - private string _value; - - /// - /// Gets the collection used to generate the content of the . - /// - public ObservableCollection Items { get; } = new ObservableCollection(); - - /// - /// Gets the currently selected item associated with this . - /// - /// If you assign a value to this property, the displayed text in the user interface will not be changed. - public string Value + get => _value; + set { - get => _value; - set + if (_value != value) { - if (_value != value) - { - _value = value; - ValueChanged(); - } - } - } - - /// - /// Initializes a new instance of the class with the provided . - /// - /// - public ComboBox(params string[] items) - { - foreach (string item in items) - { - Items.Add(item); + _value = value; + ValueChanged(); } } } + + /// + /// Initializes a new instance of the class with the provided . + /// + /// + public ComboBox(params string[] items) + { + foreach (string item in items) + { + Items.Add(item); + } + } } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/Inputs/Element.cs b/src/DesktopMagicPluginAPI/Inputs/Element.cs index b23b4fa..010151a 100644 --- a/src/DesktopMagicPluginAPI/Inputs/Element.cs +++ b/src/DesktopMagicPluginAPI/Inputs/Element.cs @@ -1,23 +1,22 @@ using System; -namespace DesktopMagicPluginAPI.Inputs +namespace DesktopMagicPluginAPI.Inputs; + +/// +/// The element base class. +/// +public abstract class Element { /// - /// The element base class. + /// Occurs when the value has been changed. /// - public abstract class Element - { - /// - /// Occurs when the value has been changed. - /// - public event Action OnValueChanged; + public event Action OnValueChanged; - /// - /// Triggers the event. - /// - protected void ValueChanged() - { - OnValueChanged?.Invoke(); - } + /// + /// Triggers the event. + /// + protected void ValueChanged() + { + OnValueChanged?.Invoke(); } } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/Inputs/ElementAttribute.cs b/src/DesktopMagicPluginAPI/Inputs/ElementAttribute.cs index f017486..e958ab3 100644 --- a/src/DesktopMagicPluginAPI/Inputs/ElementAttribute.cs +++ b/src/DesktopMagicPluginAPI/Inputs/ElementAttribute.cs @@ -1,46 +1,45 @@ using System; -namespace DesktopMagicPluginAPI.Inputs +namespace DesktopMagicPluginAPI.Inputs; + +/// +/// Marks a Property as element. +/// +[AttributeUsage(AttributeTargets.Field)] +public class ElementAttribute : Attribute { /// - /// Marks a Property as element. + /// The name of the element. /// - [AttributeUsage(AttributeTargets.Field)] - public class ElementAttribute : Attribute + public string Name { get; } + + /// + /// The order index of the element. + /// + public int OrderIndex { get; } + + /// + /// Marks a Property as element with the provided and . + /// + /// The name of the element. + /// The order index of the element. + public ElementAttribute(string name, int orderIndex = 0) { - /// - /// The name of the element. - /// - public string Name { get; } + Name = name; + OrderIndex = orderIndex; + } - /// - /// The order index of the element. - /// - public int OrderIndex { get; } + /// + /// Marks a Property as element with the provided . + /// + /// The order index of the element. + public ElementAttribute(int orderIndex) + { + OrderIndex = orderIndex; + } - /// - /// Marks a Property as element with the provided and . - /// - /// The name of the element. - /// The order index of the element. - public ElementAttribute(string name, int orderIndex = 0) - { - Name = name; - OrderIndex = orderIndex; - } - - /// - /// Marks a Property as element with the provided . - /// - /// The order index of the element. - public ElementAttribute(int orderIndex) - { - OrderIndex = orderIndex; - } - - /// - public ElementAttribute() - { - } + /// + public ElementAttribute() + { } } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/Inputs/IntegerUpDown.cs b/src/DesktopMagicPluginAPI/Inputs/IntegerUpDown.cs index 1bb788e..4485054 100644 --- a/src/DesktopMagicPluginAPI/Inputs/IntegerUpDown.cs +++ b/src/DesktopMagicPluginAPI/Inputs/IntegerUpDown.cs @@ -1,73 +1,72 @@ using System; -namespace DesktopMagicPluginAPI.Inputs +namespace DesktopMagicPluginAPI.Inputs; + +/// +/// Represents a up-down control. +/// +public class IntegerUpDown : Element { + private int _value; + /// - /// Represents a up-down control. + /// Gets or sets the maximum value for the element. /// - public class IntegerUpDown : Element + public int Maximum { get; } + + /// + /// Gets or sets the minimum value for the element. + /// + public int Minimum { get; } + + /// + /// Gets or sets the value assigned to the element. + /// + public int Value { - private int _value; - - /// - /// Gets or sets the maximum value for the element. - /// - public int Maximum { get; } - - /// - /// Gets or sets the minimum value for the element. - /// - public int Minimum { get; } - - /// - /// Gets or sets the value assigned to the element. - /// - public int Value + get => _value; + set { - get => _value; - set + if (_value != value) { - if (_value != value) - { - _value = value; - ValueChanged(); - } + _value = value; + ValueChanged(); } } + } - /// - /// Initializes a new instance of the class with the provided value, value and . - /// - /// The maximum value for the element. - /// The minimum value for the element. - /// The value assigned to the element. - /// - public IntegerUpDown(int min, int max, int value = 0) + /// + /// Initializes a new instance of the class with the provided value, value and . + /// + /// The maximum value for the element. + /// The minimum value for the element. + /// The value assigned to the element. + /// + public IntegerUpDown(int min, int max, int value = 0) + { + if (min < 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) - { - throw new ArgumentException($"{nameof(min)} is greater than or equal to {nameof(max)}!"); - } - if (value > max) - { - throw new ArgumentException($"{nameof(value)} is greater than {nameof(max)}!"); - } - if (value < min) - { - throw new ArgumentException($"{nameof(value)} is less than {nameof(min)}!"); - } + 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) + { + throw new ArgumentException($"{nameof(min)} is greater than or equal to {nameof(max)}!"); + } + if (value > max) + { + throw new ArgumentException($"{nameof(value)} is greater than {nameof(max)}!"); + } + if (value < min) + { + throw new ArgumentException($"{nameof(value)} is less than {nameof(min)}!"); + } - Minimum = min; - Maximum = max; - Value = value; - } + Minimum = min; + Maximum = max; + Value = value; } } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/Inputs/Label.cs b/src/DesktopMagicPluginAPI/Inputs/Label.cs index 56198da..1646422 100644 --- a/src/DesktopMagicPluginAPI/Inputs/Label.cs +++ b/src/DesktopMagicPluginAPI/Inputs/Label.cs @@ -1,42 +1,41 @@ -namespace DesktopMagicPluginAPI.Inputs -{ - /// - /// Represents a label control. - /// - public class Label : Element - { - private string _value; +namespace DesktopMagicPluginAPI.Inputs; - /// - /// Gets or sets the text associated with this . - /// - public string Value +/// +/// Represents a label control. +/// +public class Label : Element +{ + private string _value; + + /// + /// Gets or sets the text associated with this . + /// + public string Value + { + get => _value; + set { - get => _value; - set + if (_value != value) { - if (_value != value) - { - _value = value; - ValueChanged(); - } + _value = value; + ValueChanged(); } } + } - /// - /// Gets or set a value indicating whether the content of the is bold or not. - /// - public bool Bold { get; set; } + /// + /// Gets or set a value indicating whether the content of the is bold or not. + /// + public bool Bold { get; set; } - /// - /// Initializes a new instance of the class with the provided . - /// - /// The text associated with this - /// A value indicating whether the content of the is bold or not. - public Label(string value, bool bold = false) - { - Value = value; - Bold = bold; - } + /// + /// Initializes a new instance of the class with the provided . + /// + /// The text associated with this + /// A value indicating whether the content of the is bold or not. + public Label(string value, bool bold = false) + { + Value = value; + Bold = bold; } } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/Inputs/MouseButton.cs b/src/DesktopMagicPluginAPI/Inputs/MouseButton.cs index 498b38b..c66748a 100644 --- a/src/DesktopMagicPluginAPI/Inputs/MouseButton.cs +++ b/src/DesktopMagicPluginAPI/Inputs/MouseButton.cs @@ -1,29 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace DesktopMagicPluginAPI.Inputs; -namespace DesktopMagicPluginAPI.Inputs +/// +/// Mouse Buttons +/// +public enum MouseButton { /// - /// Mouse Buttons + /// The left mouse button. /// - public enum MouseButton - { - /// - /// The left mouse button. - /// - Left, + Left, - /// - /// The middle mouse button. - /// - Middle, + /// + /// The middle mouse button. + /// + Middle, - /// - /// The right mouse button. - /// - Right, - } + /// + /// The right mouse button. + /// + Right, } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/Inputs/Slider.cs b/src/DesktopMagicPluginAPI/Inputs/Slider.cs index d90545a..32bacb9 100644 --- a/src/DesktopMagicPluginAPI/Inputs/Slider.cs +++ b/src/DesktopMagicPluginAPI/Inputs/Slider.cs @@ -1,72 +1,71 @@ using System; -namespace DesktopMagicPluginAPI.Inputs +namespace DesktopMagicPluginAPI.Inputs; + +/// +/// Represents a slider control. +/// +public sealed class Slider : Element { + private double _value; + /// - /// Represents a slider control. + /// Gets or sets the maximum value for the element. /// - public sealed class Slider : Element + public double Maximum { get; } + + /// + /// Gets or sets the minimum value for the element. + /// + public double Minimum { get; } + + /// + /// Gets or sets the value assigned to the element. + /// + public double Value { - private double _value; - - /// - /// Gets or sets the maximum value for the element. - /// - public double Maximum { get; } - - /// - /// Gets or sets the minimum value for the element. - /// - public double Minimum { get; } - - /// - /// Gets or sets the value assigned to the element. - /// - public double Value + get => _value; + set { - get => _value; - set + if (_value != value) { - if (_value != value) - { - _value = value; - ValueChanged(); - } + _value = value; + ValueChanged(); } } + } - /// - /// Initializes a new instance of the class with the provided value, value and . - /// - /// The maximum value for the element. - /// The minimum value for the element. - /// The value assigned to the element. - public Slider(double min, double max, double value = 0) + /// + /// Initializes a new instance of the class with the provided value, value and . + /// + /// The maximum value for the element. + /// The minimum value for the element. + /// The value assigned to the element. + public Slider(double min, double max, double value = 0) + { + if (min < 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) - { - throw new ArgumentException($"{nameof(min)} is greater than or equal to {nameof(max)}!"); - } - if (value > max) - { - throw new ArgumentException($"{nameof(value)} is greater than {nameof(max)}!"); - } - if (value < min) - { - throw new ArgumentException($"{nameof(value)} is less than {nameof(min)}!"); - } + 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) + { + throw new ArgumentException($"{nameof(min)} is greater than or equal to {nameof(max)}!"); + } + if (value > max) + { + throw new ArgumentException($"{nameof(value)} is greater than {nameof(max)}!"); + } + if (value < min) + { + throw new ArgumentException($"{nameof(value)} is less than {nameof(min)}!"); + } - Minimum = min; - Maximum = max; - Value = value; - } + Minimum = min; + Maximum = max; + Value = value; } } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/Inputs/TextBox.cs b/src/DesktopMagicPluginAPI/Inputs/TextBox.cs index 8bf3724..ac97a75 100644 --- a/src/DesktopMagicPluginAPI/Inputs/TextBox.cs +++ b/src/DesktopMagicPluginAPI/Inputs/TextBox.cs @@ -1,35 +1,34 @@ -namespace DesktopMagicPluginAPI.Inputs -{ - /// - /// Represents a text box control. - /// - public class TextBox : Element - { - private string _value; +namespace DesktopMagicPluginAPI.Inputs; - /// - /// Gets or sets the text associated with this . - /// - public string Value +/// +/// Represents a text box control. +/// +public class TextBox : Element +{ + private string _value; + + /// + /// Gets or sets the text associated with this . + /// + public string Value + { + get => _value; + set { - get => _value; - set + if (_value != value) { - if (_value != value) - { - _value = value; - ValueChanged(); - } + _value = value; + ValueChanged(); } } + } - /// - /// Initializes a new instance of the class with the provided . - /// - /// The text associated with this control. - public TextBox(string value) - { - Value = value; - } + /// + /// Initializes a new instance of the class with the provided . + /// + /// The text associated with this control. + public TextBox(string value) + { + Value = value; } } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/Plugin.cs b/src/DesktopMagicPluginAPI/Plugin.cs index fb0cb81..1db3caf 100644 --- a/src/DesktopMagicPluginAPI/Plugin.cs +++ b/src/DesktopMagicPluginAPI/Plugin.cs @@ -4,78 +4,77 @@ using DesktopMagicPluginAPI.Inputs; using System; using System.Drawing; -namespace DesktopMagicPluginAPI +namespace DesktopMagicPluginAPI; + +/// +/// The plugin class. +/// +public abstract class Plugin { + private IPluginData application = null; + /// - /// The plugin class. + /// Informations about the main application. /// - public abstract class Plugin + public IPluginData Application { - private IPluginData application = null; + get => application; + set => application = application is null ? value : throw new InvalidOperationException($"You cannot set the value of the {nameof(Application)} property"); + } - /// - /// Informations about the main application. - /// - public IPluginData Application - { - get => application; - set => application = application is null ? value : throw new InvalidOperationException($"You cannot set the value of the {nameof(Application)} property"); - } + /// + /// Gets or sets the interval, expressed in milliseconds, at which to call the method. + /// + public virtual int UpdateInterval { get; set; } = 1000; - /// - /// Gets or sets the interval, expressed in milliseconds, at which to call the method. - /// - public virtual int UpdateInterval { get; set; } = 1000; + /// + /// Gets or sets the render quality of the bitmap image. + /// + public virtual RenderQuality RenderQuality { get; set; } = RenderQuality.High; - /// - /// Gets or sets the render quality of the bitmap image. - /// - public virtual RenderQuality RenderQuality { get; set; } = RenderQuality.High; + /// + /// Occurs once when the plugin gets activated. + /// + public virtual void Start() + { + } - /// - /// Occurs once when the plugin gets activated. - /// - public virtual void Start() - { - } + /// + /// Occurs once when the plugin gets deactivated. + /// + public virtual void Stop() + { + } - /// - /// Occurs once when the plugin gets deactivated. - /// - public virtual void Stop() - { - } + /// + /// Occurs when the elapses. + /// + /// + public abstract Bitmap Main(); - /// - /// Occurs when the elapses. - /// - /// - public abstract Bitmap Main(); + /// + /// Occurs when the window is clicked by the mouse. + /// + /// The x- and y-coordinates of the mouse pointer position relative to the plugin window. + /// The button associated with the event. + public virtual void OnMouseClick(Point position, MouseButton mouseButton) + { + } - /// - /// Occurs when the window is clicked by the mouse. - /// - /// The x- and y-coordinates of the mouse pointer position relative to the plugin window. - /// The button associated with the event. - public virtual void OnMouseClick(Point position, MouseButton mouseButton) - { - } + /// + /// Occurs when the mouse pointer is moved over the control. + /// + /// The x- and y-coordinates of the mouse pointer position relative to the plugin window. + public virtual void OnMouseMove(Point position) + { + } - /// - /// Occurs when the mouse pointer is moved over the control. - /// - /// The x- and y-coordinates of the mouse pointer position relative to the plugin window. - public virtual void OnMouseMove(Point position) - { - } - - /// - /// Occurs when the user rotates the mouse wheel while the mouse pointer is over this element. - /// - /// The x- and y-coordinates of the mouse pointer position relative to the plugin window. - /// A value that indicates the amount that the mouse wheel has changed. - public virtual void OnMouseWheel(Point position, int delta) - { - } + /// + /// Occurs when the user rotates the mouse wheel while the mouse pointer is over this element. + /// + /// The x- and y-coordinates of the mouse pointer position relative to the plugin window. + /// A value that indicates the amount that the mouse wheel has changed. + public virtual void OnMouseWheel(Point position, int delta) + { } } \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/api/.gitignore b/src/DesktopMagicPluginAPI/api/.gitignore deleted file mode 100644 index e8079a3..0000000 --- a/src/DesktopMagicPluginAPI/api/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -############### -# temp file # -############### -*.yml -.manifest diff --git a/src/DesktopMagicPluginAPI/api/index.md b/src/DesktopMagicPluginAPI/api/index.md deleted file mode 100644 index 78dc9c0..0000000 --- a/src/DesktopMagicPluginAPI/api/index.md +++ /dev/null @@ -1,2 +0,0 @@ -# PLACEHOLDER -TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*! diff --git a/src/DesktopMagicPluginAPI/articles/intro.md b/src/DesktopMagicPluginAPI/articles/intro.md deleted file mode 100644 index c0478ce..0000000 --- a/src/DesktopMagicPluginAPI/articles/intro.md +++ /dev/null @@ -1 +0,0 @@ -# Add your introductions here! diff --git a/src/DesktopMagicPluginAPI/articles/toc.yml b/src/DesktopMagicPluginAPI/articles/toc.yml deleted file mode 100644 index ff89ef1..0000000 --- a/src/DesktopMagicPluginAPI/articles/toc.yml +++ /dev/null @@ -1,2 +0,0 @@ -- name: Introduction - href: intro.md diff --git a/src/DesktopMagicPluginAPI/docfx.json b/src/DesktopMagicPluginAPI/docfx.json deleted file mode 100644 index ac49d2d..0000000 --- a/src/DesktopMagicPluginAPI/docfx.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "metadata": [ - { - "src": [ - { - "files": [ - "**.csproj" - ], - "src": "C:\\Users\\David\\Programmieren\\DesktopMagic\\src\\DesktopMagicPluginAPI" - } - ], - "dest": "api", - "disableGitFeatures": false, - "disableDefaultFilter": false - } - ], - "build": { - "content": [ - { - "files": [ - "api/**.yml", - "api/index.md" - ] - }, - { - "files": [ - "articles/**.md", - "articles/**/toc.yml", - "toc.yml", - "*.md" - ] - } - ], - "resource": [ - { - "files": [ - "images/**" - ] - } - ], - "overwrite": [ - { - "files": [ - "apidoc/**.md" - ], - "exclude": [ - "obj/**", - "_site/**" - ] - } - ], - "dest": "_site", - "globalMetadataFiles": [], - "fileMetadataFiles": [], - "template": [ - "default" - ], - "postProcessors": [], - "markdownEngineName": "markdig", - "noLangKeyword": false, - "keepFileLink": false, - "cleanupCacheHistory": false, - "disableGitFeatures": false - } -} \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/index.md b/src/DesktopMagicPluginAPI/index.md deleted file mode 100644 index 3ae2506..0000000 --- a/src/DesktopMagicPluginAPI/index.md +++ /dev/null @@ -1,4 +0,0 @@ -# This is the **HOMEPAGE**. -Refer to [Markdown](http://daringfireball.net/projects/markdown/) for how to write markdown files. -## Quick Start Notes: -1. Add images to the *images* folder if the file is referencing an image. diff --git a/src/DesktopMagicPluginAPI/toc.yml b/src/DesktopMagicPluginAPI/toc.yml deleted file mode 100644 index 59f8010..0000000 --- a/src/DesktopMagicPluginAPI/toc.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: Articles - href: articles/ -- name: Api Documentation - href: api/ - homepage: api/index.md