Fix multiple warnings

This commit is contained in:
Stone_Red
2024-11-15 19:41:16 +01:00
parent 7e1736696d
commit 3993e6d612
7 changed files with 41 additions and 34 deletions
+7 -7
View File
@@ -102,7 +102,13 @@ public partial class App : Application
eventThread?.Interrupt();
}
private void Setup(bool clearLogFile)
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Exception exception = (Exception)e.ExceptionObject;
Logger.LogFatal(exception + (e.IsTerminating ? "\t Process terminating!" : ""), source: exception.Source ?? "Unknown");
}
private static void Setup(bool clearLogFile)
{
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
@@ -127,10 +133,4 @@ public partial class App : Application
Logger.LogInfo("Setup complete", source: "Setup");
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Exception exception = (Exception)e.ExceptionObject;
Logger.LogFatal(exception + (e.IsTerminating ? "\t Process terminating!" : ""), source: exception.Source ?? "Unknown");
}
}
+1 -1
View File
@@ -97,7 +97,7 @@ public partial class ColorDialog : Window
private void SetColorText()
{
if (alphaSlider.Value == 255)
if ((int)alphaSlider.Value == 255)
{
colorHexTextBox.Text = "#";
}
+2
View File
@@ -10,3 +10,5 @@ using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Minor Code Smell", "S1075:URIs should not be hardcoded", Justification = "<Pending>")]
[assembly: SuppressMessage("Critical Code Smell", "S2696:Instance members should not write to \"static\" fields", Justification = "<Pending>", Scope = "member", Target = "~P:DesktopMagic.DataContexts.MainWindowDataContext.Settings")]
[assembly: SuppressMessage("Major Code Smell", "S3885:\"Assembly.Load\" should be used", Justification = "Assembly.Load does not load dependencies", Scope = "member", Target = "~M:DesktopMagic.PluginWindow.ExecuteSource")]
[assembly: SuppressMessage("Minor Code Smell", "S2325:Methods and properties that don't access instance data should be static", Justification = "<Pending>", Scope = "member", Target = "~M:DesktopMagic.MainWindow.OpenPluginsFolderButton_Click(System.Object,System.Windows.RoutedEventArgs)")]
[assembly: SuppressMessage("Minor Code Smell", "S2325:Methods and properties that don't access instance data should be static", Justification = "<Pending>", Scope = "member", Target = "~M:DesktopMagic.MainWindow.ScrollViewer_PreviewMouseWheel(System.Object,System.Windows.Input.MouseWheelEventArgs)")]
+1 -1
View File
@@ -47,7 +47,7 @@ internal class SampleAggregator
}
}
private bool IsPowerOfTwo(int x)
private static bool IsPowerOfTwo(int x)
{
return (x & (x - 1)) == 0;
}
+23 -23
View File
@@ -160,6 +160,17 @@ namespace DesktopMagic
#region Windows
private static void DisplayWindow_ContentRendered(object? sender, EventArgs e)
{
if (sender is not Window window)
{
return;
}
WindowPos.SendWpfWindowBack(window);
WindowPos.SendWpfWindowBack(window);
}
private void EditCheckBox_Click(object? sender, RoutedEventArgs? e)
{
EditMode = EditCheckBox.IsChecked == true;
@@ -256,17 +267,6 @@ namespace DesktopMagic
WindowNames.Add(window.Title);
}
private void DisplayWindow_ContentRendered(object? sender, EventArgs e)
{
if (sender is not Window window)
{
return;
}
WindowPos.SendWpfWindowBack(window);
WindowPos.SendWpfWindowBack(window);
}
private void DisplayWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = blockWindowsClosing;
@@ -372,6 +372,18 @@ namespace DesktopMagic
}
}
private void OpenPluginsFolderButton_Click(object sender, RoutedEventArgs e)
{
_ = Process.Start("explorer.exe", App.ApplicationDataPath + "\\Plugins");
}
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
private void TextBlock_Loaded(object sender, RoutedEventArgs e)
{
int index = 0;
@@ -619,18 +631,6 @@ namespace DesktopMagic
LoadLayout(false);
}
private void OpenPluginsFolderButton_Click(object sender, RoutedEventArgs e)
{
_ = Process.Start("explorer.exe", App.ApplicationDataPath + "\\Plugins");
}
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
private void TaskbarIcon_TrayLeftClick(object? sender, EventArgs e)
{
RestoreWindow();
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
@@ -6,6 +7,8 @@ namespace DesktopMagic.Api.Drawing;
internal class FontComparer : IEqualityComparer<Font>
{
private const float Tolerance = 0.01f;
public bool Equals(Font? font1, Font? font2)
{
if (font1 is null || font2 is null)
@@ -18,7 +21,7 @@ internal class FontComparer : IEqualityComparer<Font>
return false;
}
if (font1.SizeInPoints != font2.SizeInPoints)
if (Math.Abs(font1.SizeInPoints - font2.SizeInPoints) > Tolerance)
{
return false;
}
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
namespace DesktopMagic.Api.Settings;
@@ -22,6 +23,7 @@ public sealed class Slider : Setting
/// <summary>
/// Gets or sets the value assigned to the <see cref="Slider"/> element.
/// </summary>
[SuppressMessage("Major Bug", "S1244:Floating point numbers should not be tested for equality", Justification = "Not applicable here since we want to detect changes in the value.")]
public double Value
{
get => _value;