From 67cdc4cc4b8a0209c1f71bf676b4f58e7ddd88b4 Mon Sep 17 00:00:00 2001 From: SlimeNull Date: Thu, 1 Aug 2024 08:40:49 +0800 Subject: [PATCH] Format code --- .../WindowOptionColorConverter.cs | 77 +++--- .../Utilities/WindowAccentState.cs | 64 +++-- .../Utilities/WindowBackdrop.cs | 56 +++-- .../EleCho.WpfSuite/Utilities/WindowCorner.cs | 46 ++-- .../Utilities/WindowOptionColor.cs | 225 +++++++++--------- 5 files changed, 221 insertions(+), 247 deletions(-) diff --git a/dnSpy/dnSpy/Lib/EleCho.WpfSuite/TypeConverters/WindowOptionColorConverter.cs b/dnSpy/dnSpy/Lib/EleCho.WpfSuite/TypeConverters/WindowOptionColorConverter.cs index bd902c02a9..bce7a84ee8 100644 --- a/dnSpy/dnSpy/Lib/EleCho.WpfSuite/TypeConverters/WindowOptionColorConverter.cs +++ b/dnSpy/dnSpy/Lib/EleCho.WpfSuite/TypeConverters/WindowOptionColorConverter.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; @@ -7,49 +7,40 @@ using System.Threading.Tasks; using System.Windows.Media; -namespace EleCho.WpfSuite -{ - /// - /// converter - /// - public class WindowOptionColorConverter : TypeConverter - { - /// - public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) - { - if (sourceType == typeof(string) || - sourceType == typeof(Color)) - return true; +namespace EleCho.WpfSuite { + /// + /// converter + /// + public class WindowOptionColorConverter : TypeConverter { + /// + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) { + if (sourceType == typeof(string) || + sourceType == typeof(Color)) + return true; - return base.CanConvertFrom(context, sourceType); - } + return base.CanConvertFrom(context, sourceType); + } - /// - public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) - { - if (value is string stringValue) - { - if (stringValue.Equals(nameof(WindowOptionColor.Default), StringComparison.OrdinalIgnoreCase)) - { - return WindowOptionColor.Default; - } - else if (stringValue.Equals(nameof(WindowOptionColor.None), StringComparison.OrdinalIgnoreCase)) - { - return WindowOptionColor.None; - } - else if (ColorConverter.ConvertFromString(stringValue) is Color color) - { - color.A = 0xFF; - return (WindowOptionColor)color; - } - } - else if (value is Color colorValue) - { - colorValue.A = 0xFF; - return (WindowOptionColor)colorValue; - } + /// + public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) { + if (value is string stringValue) { + if (stringValue.Equals(nameof(WindowOptionColor.Default), StringComparison.OrdinalIgnoreCase)) { + return WindowOptionColor.Default; + } + else if (stringValue.Equals(nameof(WindowOptionColor.None), StringComparison.OrdinalIgnoreCase)) { + return WindowOptionColor.None; + } + else if (ColorConverter.ConvertFromString(stringValue) is Color color) { + color.A = 0xFF; + return (WindowOptionColor)color; + } + } + else if (value is Color colorValue) { + colorValue.A = 0xFF; + return (WindowOptionColor)colorValue; + } - return base.ConvertFrom(context, culture, value); - } - } + return base.ConvertFrom(context, culture, value); + } + } } diff --git a/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowAccentState.cs b/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowAccentState.cs index 8ba60ae729..879451c996 100644 --- a/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowAccentState.cs +++ b/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowAccentState.cs @@ -1,38 +1,36 @@ -namespace EleCho.WpfSuite -{ - /// - /// Window accent state - /// - public enum WindowAccentState - { - /// - /// None - /// - None, +namespace EleCho.WpfSuite { + /// + /// Window accent state + /// + public enum WindowAccentState { + /// + /// None + /// + None, - /// - /// Gradient - /// - Gradient = 1, + /// + /// Gradient + /// + Gradient = 1, - /// - /// Transparent - /// - Transparent = 2, - - /// - /// Blur behind - /// - BlurBehind = 3, + /// + /// Transparent + /// + Transparent = 2, - /// - /// Acrylic blur behind - /// - AcrylicBlurBehind = 4, + /// + /// Blur behind + /// + BlurBehind = 3, - /// - /// Host backdrop - /// - HostBackdrop = 5, - } + /// + /// Acrylic blur behind + /// + AcrylicBlurBehind = 4, + + /// + /// Host backdrop + /// + HostBackdrop = 5, + } } diff --git a/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowBackdrop.cs b/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowBackdrop.cs index b70c7d225c..5f0b051455 100644 --- a/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowBackdrop.cs +++ b/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowBackdrop.cs @@ -1,35 +1,33 @@ -using System.Windows.Media; +using System.Windows.Media; -namespace EleCho.WpfSuite -{ - /// - /// Window backdrop - /// - public enum WindowBackdrop - { - /// - /// Automatic - /// - Auto = 0, +namespace EleCho.WpfSuite { + /// + /// Window backdrop + /// + public enum WindowBackdrop { + /// + /// Automatic + /// + Auto = 0, - /// - /// None - /// - None = 1, + /// + /// None + /// + None = 1, - /// - /// Mica - /// - Mica = 2, + /// + /// Mica + /// + Mica = 2, - /// - /// Acrylic - /// - Acrylic = 3, + /// + /// Acrylic + /// + Acrylic = 3, - /// - /// Mica alternate - /// - MicaAlt = 4 - } + /// + /// Mica alternate + /// + MicaAlt = 4 + } } diff --git a/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowCorner.cs b/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowCorner.cs index 13850c1299..c7d47f08ed 100644 --- a/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowCorner.cs +++ b/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowCorner.cs @@ -1,28 +1,26 @@ -namespace EleCho.WpfSuite -{ - /// - /// Window corner - /// - public enum WindowCorner - { - /// - /// Default - /// - Default = 0, +namespace EleCho.WpfSuite { + /// + /// Window corner + /// + public enum WindowCorner { + /// + /// Default + /// + Default = 0, - /// - /// Do not round - /// - DoNotRound = 1, + /// + /// Do not round + /// + DoNotRound = 1, - /// - /// Round - /// - Round = 2, + /// + /// Round + /// + Round = 2, - /// - /// Round small - /// - RoundSmall = 3 - } + /// + /// Round small + /// + RoundSmall = 3 + } } diff --git a/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowOptionColor.cs b/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowOptionColor.cs index c0e8ccac93..0f3e79a6ad 100644 --- a/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowOptionColor.cs +++ b/dnSpy/dnSpy/Lib/EleCho.WpfSuite/Utilities/WindowOptionColor.cs @@ -1,122 +1,111 @@ -using System.ComponentModel; +using System.ComponentModel; using System.Runtime.InteropServices; using System.Windows.Media; -namespace EleCho.WpfSuite -{ - /// - /// Color for WindowOption - /// - [TypeConverter(typeof(WindowOptionColorConverter))] - [StructLayout(LayoutKind.Sequential)] - public struct WindowOptionColor - { - private int _value; - - /// - /// Integer value - /// - public int Value - { - get => _value; - set => _value = value; - } - - /// - /// Red channel value - /// - public byte R - { - get => (byte)(_value); - set => _value = (_value & ~0xFF) + value; - } - - /// - /// Green channel value - /// - public byte G - { - get => (byte)(_value >> 8); - set => _value = (_value & ~0xFF00) + (value << 8); - } - - /// - /// Blue channel value - /// - public byte B - { - get => (byte)(_value >> 16); - set => _value = (_value & ~0xFF0000) + (value << 16); - } - - /// - /// Extra byte - /// - public byte Extra - { - get => (byte)(_value >> 24); - set => _value = (int)(_value & ~0xFF000000) + (value << 24); - } - - /// - /// Create an empty window option color - /// - public WindowOptionColor() - { - - } - - /// - /// Create a window option color with specified channel values - /// - /// Red channel value - /// Green channel value - /// Blue channel value - public WindowOptionColor(byte r, byte g, byte b) : this(r, g, b, 0xFF) - { } - - /// - /// Create a window option color with specified channel values and extra byte - /// - /// Red channel value - /// Green channel value - /// Blue channel value - /// Extra byte - public WindowOptionColor(byte r, byte g, byte b, byte extra) - { - _value = r | g << 8 | b << 16 | extra << 24; - } - - /// - /// Create a window option color with specified value - /// - /// - public WindowOptionColor(int value) - { - _value = value; - } - - /// - /// Default color - /// - public static WindowOptionColor Default { get; } = new WindowOptionColor(unchecked((int)0xFFFFFFFF)); - - /// - /// No color - /// - public static WindowOptionColor None { get; } = new WindowOptionColor(unchecked((int)0xFFFFFFFE)); - - - /// - /// Convert window option color to color - /// - /// - public static implicit operator Color(WindowOptionColor color) => Color.FromArgb(0xFF, color.R, color.G, color.B); - - /// - /// Convert color to window option color - /// - /// - public static implicit operator WindowOptionColor(Color color) => new WindowOptionColor(color.R, color.G, color.B, 0); - } +namespace EleCho.WpfSuite { + /// + /// Color for WindowOption + /// + [TypeConverter(typeof(WindowOptionColorConverter))] + [StructLayout(LayoutKind.Sequential)] + public struct WindowOptionColor { + private int _value; + + /// + /// Integer value + /// + public int Value { + get => _value; + set => _value = value; + } + + /// + /// Red channel value + /// + public byte R { + get => (byte)(_value); + set => _value = (_value & ~0xFF) + value; + } + + /// + /// Green channel value + /// + public byte G { + get => (byte)(_value >> 8); + set => _value = (_value & ~0xFF00) + (value << 8); + } + + /// + /// Blue channel value + /// + public byte B { + get => (byte)(_value >> 16); + set => _value = (_value & ~0xFF0000) + (value << 16); + } + + /// + /// Extra byte + /// + public byte Extra { + get => (byte)(_value >> 24); + set => _value = (int)(_value & ~0xFF000000) + (value << 24); + } + + /// + /// Create an empty window option color + /// + public WindowOptionColor() { + + } + + /// + /// Create a window option color with specified channel values + /// + /// Red channel value + /// Green channel value + /// Blue channel value + public WindowOptionColor(byte r, byte g, byte b) : this(r, g, b, 0xFF) { } + + /// + /// Create a window option color with specified channel values and extra byte + /// + /// Red channel value + /// Green channel value + /// Blue channel value + /// Extra byte + public WindowOptionColor(byte r, byte g, byte b, byte extra) { + _value = r | g << 8 | b << 16 | extra << 24; + } + + /// + /// Create a window option color with specified value + /// + /// + public WindowOptionColor(int value) { + _value = value; + } + + /// + /// Default color + /// + public static WindowOptionColor Default { get; } = new WindowOptionColor(unchecked((int)0xFFFFFFFF)); + + /// + /// No color + /// + public static WindowOptionColor None { get; } = new WindowOptionColor(unchecked((int)0xFFFFFFFE)); + + + /// + /// Convert window option color to color + /// + /// + public static implicit operator Color(WindowOptionColor color) => Color.FromArgb(0xFF, color.R, color.G, color.B); + + /// + /// Convert color to window option color + /// + /// + public static implicit operator WindowOptionColor(Color color) => new WindowOptionColor(color.R, color.G, color.B, 0); + } }