diff --git a/.csharpierrc b/.csharpierrc new file mode 100644 index 0000000..c01826a --- /dev/null +++ b/.csharpierrc @@ -0,0 +1,6 @@ +{ + "printWidth": 200, + "useTabs": false, + "tabWidth": 4, + "preprocessorSymbolSets": ["", "DEBUG", "DEBUG,CODE_STYLE"] +} \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ec89859 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,247 @@ +# Entfernen Sie die folgende Zeile, wenn Sie EDITORCONFIG-Einstellungen von höheren Verzeichnissen vererben möchten. +root = true + +# C#-Dateien +[*.cs] + +#### Wichtige EditorConfig-Optionen #### + +# Einzüge und Abstände +indent_size = 4 +indent_style = space +tab_width = 4 + +# Einstellungen für neue Zeilen +end_of_line = crlf +insert_final_newline = true + +#### .NET-Codierungskonventionen #### + +# Using-Direktiven organisieren +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false +file_header_template = unset + +# this.- und Me.-Einstellungen +dotnet_style_qualification_for_event = false +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false +dotnet_style_qualification_for_property = false + +# Einstellungen für Sprachschlüsselwörter und BCL-Typen +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# Einstellungen für Klammern +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity + +# Einstellungen für Modifizierer +dotnet_style_require_accessibility_modifiers = for_non_interface_members + +# Einstellungen für Ausdrucksebene +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true +dotnet_style_prefer_compound_assignment = true +dotnet_style_prefer_conditional_expression_over_assignment = true +dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_prefer_simplified_interpolation = true + +# Einstellungen für Felder +dotnet_style_readonly_field = true + +# Einstellungen für Parameter +dotnet_code_quality_unused_parameters = all + +# Unterdrückungseinstellungen +dotnet_remove_unnecessary_suppression_exclusions = none + +# Einstellungen für neue Zeilen +dotnet_style_allow_multiple_blank_lines_experimental = true +dotnet_style_allow_statement_immediately_after_block_experimental = true + +#### C#-Codierungskonventionen #### + +# Var-Einstellungen +csharp_style_var_elsewhere = false +csharp_style_var_for_built_in_types = false +csharp_style_var_when_type_is_apparent = false + +# Ausdruckskörpermember +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent + +# Einstellungen für den Musterabgleich +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_extended_property_pattern = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_pattern_matching = true +csharp_style_prefer_switch_expression = true:suggestion + +# Einstellungen für NULL-Überprüfung +csharp_style_conditional_delegate_call = true + +# Einstellungen für Modifizierer +csharp_prefer_static_local_function = true +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async +csharp_style_prefer_readonly_struct = true + +# Einstellungen für Codeblöcke +csharp_prefer_braces = true:silent +csharp_prefer_simple_using_statement = true:suggestion +csharp_style_namespace_declarations = block_scoped:silent +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_top_level_statements = true:silent + +# Einstellungen für Ausdrucksebene +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_local_over_anonymous_function = true:suggestion +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_prefer_tuple_swap = true:suggestion +csharp_style_prefer_utf8_string_literals = true:suggestion +csharp_style_throw_expression = true:suggestion +csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:silent + +# Einstellungen für using-Anweisungen +csharp_using_directive_placement = outside_namespace + +# Einstellungen für neue Zeilen +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true +csharp_style_allow_embedded_statements_on_same_line_experimental = true + +#### C#-Formatierungsregeln #### + +# Einstellungen für neue Zeilen +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Einstellungen für Einrückung +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +# Einstellungen für Abstände +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Umbrucheinstellungen +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Benennungsstile #### + +# Benennungsregeln + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbolspezifikationen + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Benennungsstile + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case + +[*.{cs,vb}] +dotnet_style_operator_placement_when_wrapping = beginning_of_line +end_of_line = crlf +tab_width = 4 +indent_size = 4 +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion +dotnet_style_namespace_match_folder = true:suggestion \ No newline at end of file diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index 85d66da..2fd2bdb 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -16,4 +16,4 @@ namespace ModernWpfPlayground ThemeManager.Current.AccentColor = AccentColors.Green.ToWindowsColor(); } } -} \ No newline at end of file +} diff --git a/src/App/AssemblyInfo.cs b/src/App/AssemblyInfo.cs index 2211234..77c6c5d 100644 --- a/src/App/AssemblyInfo.cs +++ b/src/App/AssemblyInfo.cs @@ -1,10 +1,10 @@ using System.Windows; -[assembly:ThemeInfo( +[assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) + //(used if a resource is not found in the page, + // or application resource dictionaries) ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) +//(used if a resource is not found in the page, +// app, or any theme specific resource dictionaries) )] diff --git a/src/App/ContentDialogExample.xaml.cs b/src/App/ContentDialogExample.xaml.cs index a1073ea..9056126 100644 --- a/src/App/ContentDialogExample.xaml.cs +++ b/src/App/ContentDialogExample.xaml.cs @@ -4,12 +4,11 @@ namespace ModernWpfPlayground { public partial class ContentDialogExample { - public static readonly DependencyProperty MessageProperty = DependencyProperty.Register( - "Message", typeof(string), typeof(ContentDialogExample), new PropertyMetadata(default(string))); + public static readonly DependencyProperty MessageProperty = DependencyProperty.Register("Message", typeof(string), typeof(ContentDialogExample), new PropertyMetadata(default(string))); public string? Message { - get => (string?) GetValue(MessageProperty); + get => (string?)GetValue(MessageProperty); set => SetValue(MessageProperty, value); } @@ -18,4 +17,4 @@ namespace ModernWpfPlayground InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/App/DivideByHundredConverter.cs b/src/App/DivideByHundredConverter.cs index 55894b8..dd7afe9 100644 --- a/src/App/DivideByHundredConverter.cs +++ b/src/App/DivideByHundredConverter.cs @@ -20,4 +20,4 @@ public class DivideByHundredConverter : MarkupExtension, IValueConverter { return this; } -} \ No newline at end of file +} diff --git a/src/App/MainWindowViewModel.cs b/src/App/MainWindowViewModel.cs index c7a8f24..af0e552 100644 --- a/src/App/MainWindowViewModel.cs +++ b/src/App/MainWindowViewModel.cs @@ -11,18 +11,41 @@ namespace ModernWpfPlayground { private const string AppName = "TaBEA 3.0.0"; - [ObservableProperty] private string? _path; - [ObservableProperty] private string _title = AppName; - [ObservableProperty] private bool _booleanValue = true; - [ObservableProperty] private Visibility _visibilityEnumTest = Visibility.Visible; - [ObservableProperty] private double _sliderTest = 100; - [ObservableProperty] private double _validationTest; - [ObservableProperty] private string? _welcomeMessage = "Shadow of the empire"; - [ObservableProperty] private ThemeMode _themeMode = ThemeMode.UseSystemSetting; - [ObservableProperty] private AccentColors _accentColors = AccentColors.Green; - [ObservableProperty] private int _windowWidth = 1200; - [ObservableProperty] private int _windowHeight = 600; - [ObservableProperty] private bool _isPaneOpen = true; + [ObservableProperty] + private string? _path; + + [ObservableProperty] + private string _title = AppName; + + [ObservableProperty] + private bool _booleanValue = true; + + [ObservableProperty] + private Visibility _visibilityEnumTest = Visibility.Visible; + + [ObservableProperty] + private double _sliderTest = 100; + + [ObservableProperty] + private double _validationTest; + + [ObservableProperty] + private string? _welcomeMessage = "Shadow of the empire"; + + [ObservableProperty] + private ThemeMode _themeMode = ThemeMode.UseSystemSetting; + + [ObservableProperty] + private AccentColors _accentColors = AccentColors.Green; + + [ObservableProperty] + private int _windowWidth = 1200; + + [ObservableProperty] + private int _windowHeight = 600; + + [ObservableProperty] + private bool _isPaneOpen = true; partial void OnBooleanValueChanged(bool value) { @@ -34,11 +57,8 @@ namespace ModernWpfPlayground Title = value != null ? $"{System.IO.Path.GetFileName(value)} - {AppName}" : AppName; } - [RelayCommand] - private void ShowNotification() - { - } + private void ShowNotification() { } [RelayCommand] private void Close() @@ -79,4 +99,4 @@ namespace ModernWpfPlayground // File.WriteAllText(Path, contents); } } -} \ No newline at end of file +} diff --git a/src/App/ModernWpfPlayground.csproj b/src/App/ModernWpfPlayground.csproj index d2adbda..510582e 100644 --- a/src/App/ModernWpfPlayground.csproj +++ b/src/App/ModernWpfPlayground.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/App/PixelsToGridLengthConverter.cs b/src/App/PixelsToGridLengthConverter.cs index d035150..ab8f7da 100644 --- a/src/App/PixelsToGridLengthConverter.cs +++ b/src/App/PixelsToGridLengthConverter.cs @@ -19,7 +19,6 @@ namespace ModernWpfPlayground throw new NotImplementedException(); } - public override object ProvideValue(IServiceProvider serviceProvider) => - _converter ??= new PixelsToGridLengthConverter(); + public override object ProvideValue(IServiceProvider serviceProvider) => _converter ??= new PixelsToGridLengthConverter(); } -} \ No newline at end of file +} diff --git a/src/App/Types/AccentColors.cs b/src/App/Types/AccentColors.cs index e5c598e..1160a6d 100644 --- a/src/App/Types/AccentColors.cs +++ b/src/App/Types/AccentColors.cs @@ -25,4 +25,4 @@ public static class AccentColorExtension _ => throw new ArgumentOutOfRangeException(nameof(accentColor), accentColor, null) }; } -} \ No newline at end of file +} diff --git a/src/App/Types/ThemeMode.cs b/src/App/Types/ThemeMode.cs index 3b0d491..c081c2c 100644 --- a/src/App/Types/ThemeMode.cs +++ b/src/App/Types/ThemeMode.cs @@ -5,9 +5,14 @@ namespace ModernWpfPlayground.Types { public enum ThemeMode { - [Description("Light")] Light, - [Description("Dark")] Dark, - [Description("Use system setting")] UseSystemSetting + [Description("Light")] + Light, + + [Description("Dark")] + Dark, + + [Description("Use system setting")] + UseSystemSetting } public static class ThemeModeExtension @@ -23,4 +28,4 @@ namespace ModernWpfPlayground.Types }; } } -} \ No newline at end of file +} diff --git a/src/Controls/AssemblyInfo.cs b/src/Controls/AssemblyInfo.cs index 8b5504e..77c6c5d 100644 --- a/src/Controls/AssemblyInfo.cs +++ b/src/Controls/AssemblyInfo.cs @@ -2,9 +2,9 @@ using System.Windows; [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) + //(used if a resource is not found in the page, + // or application resource dictionaries) ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) +//(used if a resource is not found in the page, +// app, or any theme specific resource dictionaries) )] diff --git a/src/Controls/Controls.csproj b/src/Controls/Controls.csproj index 09c3506..8c966a8 100644 --- a/src/Controls/Controls.csproj +++ b/src/Controls/Controls.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/Controls/PropertyPresenter/EnumToItemSourceConverter.cs b/src/Controls/PropertyPresenter/EnumToItemSourceConverter.cs index 88219e5..390d084 100644 --- a/src/Controls/PropertyPresenter/EnumToItemSourceConverter.cs +++ b/src/Controls/PropertyPresenter/EnumToItemSourceConverter.cs @@ -14,9 +14,9 @@ public class EnumToItemSourceConverter : MarkupExtension, IValueConverter object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (value is not Enum) return Binding.DoNothing; - return (from object enumValue in Enum.GetValues(value.GetType()) - select new KeyValuePair(GetDescription(enumValue), enumValue)).ToList(); + if (value is not Enum) + return Binding.DoNothing; + return (from object enumValue in Enum.GetValues(value.GetType()) select new KeyValuePair(GetDescription(enumValue), enumValue)).ToList(); } /// @@ -26,12 +26,9 @@ public class EnumToItemSourceConverter : MarkupExtension, IValueConverter /// private static string GetDescription(object value) { - if (value is not Enum enumValue) return string.Empty; - var descriptionAttribute = enumValue.GetType() - .GetField(enumValue.ToString())? - .GetCustomAttributes(false) - .OfType() - .FirstOrDefault(); + if (value is not Enum enumValue) + return string.Empty; + var descriptionAttribute = enumValue.GetType().GetField(enumValue.ToString())?.GetCustomAttributes(false).OfType().FirstOrDefault(); return descriptionAttribute?.Description ?? value.ToString() ?? string.Empty; } @@ -42,4 +39,4 @@ public class EnumToItemSourceConverter : MarkupExtension, IValueConverter } public override object ProvideValue(IServiceProvider serviceProvider) => _converter ??= new EnumToItemSourceConverter(); -} \ No newline at end of file +} diff --git a/src/Controls/PropertyPresenter/MagicSymbolControl.cs b/src/Controls/PropertyPresenter/MagicSymbolControl.cs index 069c006..f3e13c8 100644 --- a/src/Controls/PropertyPresenter/MagicSymbolControl.cs +++ b/src/Controls/PropertyPresenter/MagicSymbolControl.cs @@ -13,7 +13,12 @@ public class MagicSymbolControl : ContentControl /// /// Dependency property for property /// - public static readonly DependencyProperty SymbolProperty = DependencyProperty.Register(nameof(Symbol), typeof(object), typeof(MagicSymbolControl), new PropertyMetadata(default, PropertyChangedCallback)); + public static readonly DependencyProperty SymbolProperty = DependencyProperty.Register( + nameof(Symbol), + typeof(object), + typeof(MagicSymbolControl), + new PropertyMetadata(default, PropertyChangedCallback) + ); private static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { @@ -39,4 +44,4 @@ public class MagicSymbolControl : ContentControl { Focusable = false; } -} \ No newline at end of file +} diff --git a/src/Controls/PropertyPresenter/MagicSymbolConverter.cs b/src/Controls/PropertyPresenter/MagicSymbolConverter.cs index adeba7a..7c42ec7 100644 --- a/src/Controls/PropertyPresenter/MagicSymbolConverter.cs +++ b/src/Controls/PropertyPresenter/MagicSymbolConverter.cs @@ -9,7 +9,7 @@ using System.Windows.Media; namespace Controls; /// -/// Magically converts a text to +/// Magically converts a text to /// [ValueConversion(typeof(string), typeof(FrameworkElement))] public class MagicSymbolConverter : IValueConverter @@ -32,9 +32,11 @@ public class MagicSymbolConverter : IValueConverter public static object ConvertToFrameworkElement(object value) { var data = value as string; - if (string.IsNullOrWhiteSpace(data)) return value; //maybe not a string. eventually something else. + if (string.IsNullOrWhiteSpace(data)) + return value; //maybe not a string. eventually something else. - if (data.StartsWith(NoParseKeyword, StringComparison.Ordinal)) return data[NoParseKeyword.Length..]; + if (data.StartsWith(NoParseKeyword, StringComparison.Ordinal)) + return data[NoParseKeyword.Length..]; if (data.StartsWith(PathKeyword, StringComparison.Ordinal)) { @@ -72,7 +74,7 @@ public class MagicSymbolConverter : IValueConverter var block = new TextBlock(); foreach (var tc in textComponents) { - var run = new Run(tc.Text) {FontFamily = new FontFamily("Palatino Linotype"), FontSize = 16}; + var run = new Run(tc.Text) { FontFamily = new FontFamily("Palatino Linotype"), FontSize = 16 }; switch (tc.Style) { case BaselineAlignment.Subscript: @@ -111,9 +113,7 @@ public class MagicSymbolConverter : IValueConverter snippet.Clear(); } - alignment = alignment == BaselineAlignment.Subscript - ? BaselineAlignment.Baseline - : BaselineAlignment.Subscript; + alignment = alignment == BaselineAlignment.Subscript ? BaselineAlignment.Baseline : BaselineAlignment.Subscript; break; case '^': if (snippet.Length > 0) @@ -123,9 +123,7 @@ public class MagicSymbolConverter : IValueConverter snippet.Clear(); } - alignment = alignment == BaselineAlignment.Superscript - ? BaselineAlignment.Baseline - : BaselineAlignment.Superscript; + alignment = alignment == BaselineAlignment.Superscript ? BaselineAlignment.Baseline : BaselineAlignment.Superscript; break; default: snippet.Append(c); @@ -144,6 +142,5 @@ public class MagicSymbolConverter : IValueConverter } /// - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - => Binding.DoNothing; -} \ No newline at end of file + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => Binding.DoNothing; +} diff --git a/src/Controls/PropertyPresenter/PropertyDataTemplateSelector.cs b/src/Controls/PropertyPresenter/PropertyDataTemplateSelector.cs index 0ebc95d..e344d9f 100644 --- a/src/Controls/PropertyPresenter/PropertyDataTemplateSelector.cs +++ b/src/Controls/PropertyPresenter/PropertyDataTemplateSelector.cs @@ -34,4 +34,4 @@ public class PropertyDataTemplateSelector : DataTemplateSelector _ => DefaultDataTemplate }; } -} \ No newline at end of file +} diff --git a/src/Controls/PropertyPresenter/PropertyPresenter.xaml.cs b/src/Controls/PropertyPresenter/PropertyPresenter.xaml.cs index f1bb884..820410b 100644 --- a/src/Controls/PropertyPresenter/PropertyPresenter.xaml.cs +++ b/src/Controls/PropertyPresenter/PropertyPresenter.xaml.cs @@ -25,7 +25,12 @@ public sealed partial class PropertyPresenter /// /// Command Parameter property /// - public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.Register(nameof(CommandParameter), typeof(object), typeof(PropertyPresenter), new PropertyMetadata(default(object))); + public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.Register( + nameof(CommandParameter), + typeof(object), + typeof(PropertyPresenter), + new PropertyMetadata(default(object)) + ); /// /// Command property @@ -35,7 +40,12 @@ public sealed partial class PropertyPresenter /// /// is checked property. /// - public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register(nameof(IsChecked), typeof(bool?), typeof(PropertyPresenter), new FrameworkPropertyMetadata(default(bool?), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); + public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register( + nameof(IsChecked), + typeof(bool?), + typeof(PropertyPresenter), + new FrameworkPropertyMetadata(default(bool?), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault) + ); /// /// Is readonly property @@ -60,12 +70,22 @@ public sealed partial class PropertyPresenter /// /// Value Property /// - public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(nameof(Value), typeof(object), typeof(PropertyPresenter), new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); + public static readonly DependencyProperty ValueProperty = DependencyProperty.Register( + nameof(Value), + typeof(object), + typeof(PropertyPresenter), + new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault) + ); /// /// Watermark Property /// - public static readonly DependencyProperty WatermarkProperty = DependencyProperty.Register(nameof(Watermark), typeof(string), typeof(PropertyPresenter), new FrameworkPropertyMetadata(default(string))); + public static readonly DependencyProperty WatermarkProperty = DependencyProperty.Register( + nameof(Watermark), + typeof(string), + typeof(PropertyPresenter), + new FrameworkPropertyMetadata(default(string)) + ); /// public PropertyPresenter() @@ -177,4 +197,4 @@ public sealed partial class PropertyPresenter { return $"{base.ToString()} {Value}"; } -} \ No newline at end of file +} diff --git a/src/Controls/PropertyPresenter/TextBoxEx.cs b/src/Controls/PropertyPresenter/TextBoxEx.cs index be9e113..6b55fd8 100644 --- a/src/Controls/PropertyPresenter/TextBoxEx.cs +++ b/src/Controls/PropertyPresenter/TextBoxEx.cs @@ -13,28 +13,22 @@ public class TextBoxEx : TextBox /// /// Identifies the dependency property. /// - public static readonly DependencyProperty MoveFocusOnEnterProperty = - DependencyProperty.Register( - nameof(MoveFocusOnEnter), typeof(bool), typeof(TextBoxEx), new UIPropertyMetadata(true)); + public static readonly DependencyProperty MoveFocusOnEnterProperty = DependencyProperty.Register(nameof(MoveFocusOnEnter), typeof(bool), typeof(TextBoxEx), new UIPropertyMetadata(true)); /// /// Identifies the dependency property. /// - public static readonly DependencyProperty UpdateBindingOnEnterProperty = - DependencyProperty.Register( - nameof(UpdateBindingOnEnter), typeof(bool), typeof(TextBoxEx), new UIPropertyMetadata(true)); + public static readonly DependencyProperty UpdateBindingOnEnterProperty = DependencyProperty.Register(nameof(UpdateBindingOnEnter), typeof(bool), typeof(TextBoxEx), new UIPropertyMetadata(true)); /// /// Identifies the dependency property. /// - public static readonly DependencyProperty ScrollToHomeOnFocusProperty = - DependencyProperty.Register(nameof(ScrollToHomeOnFocus), typeof(bool), typeof(TextBoxEx), new PropertyMetadata(true)); + public static readonly DependencyProperty ScrollToHomeOnFocusProperty = DependencyProperty.Register(nameof(ScrollToHomeOnFocus), typeof(bool), typeof(TextBoxEx), new PropertyMetadata(true)); /// /// Identifies the dependency property. /// - public static readonly DependencyProperty SelectAllOnFocusProperty = - DependencyProperty.Register(nameof(SelectAllOnFocus), typeof(bool), typeof(TextBoxEx), new PropertyMetadata(true)); + public static readonly DependencyProperty SelectAllOnFocusProperty = DependencyProperty.Register(nameof(SelectAllOnFocus), typeof(bool), typeof(TextBoxEx), new PropertyMetadata(true)); /// /// @@ -75,7 +69,6 @@ public class TextBoxEx : TextBox public bool MoveFocusOnEnter { get => (bool)GetValue(MoveFocusOnEnterProperty); - set => SetValue(MoveFocusOnEnterProperty, value); } @@ -85,7 +78,6 @@ public class TextBoxEx : TextBox public bool UpdateBindingOnEnter { get => (bool)GetValue(UpdateBindingOnEnterProperty); - set => SetValue(UpdateBindingOnEnterProperty, value); } @@ -161,4 +153,4 @@ public class TextBoxEx : TextBox e.Handled = true; } -} \ No newline at end of file +} diff --git a/src/Controls/PropertyPresenter/TextComponent.cs b/src/Controls/PropertyPresenter/TextComponent.cs index 6706288..388448b 100644 --- a/src/Controls/PropertyPresenter/TextComponent.cs +++ b/src/Controls/PropertyPresenter/TextComponent.cs @@ -27,4 +27,4 @@ public readonly struct TextComponent /// Style of the symbol component /// public readonly BaselineAlignment Style; -} \ No newline at end of file +} diff --git a/src/Controls/PropertyPresenter/ValueConverter.cs b/src/Controls/PropertyPresenter/ValueConverter.cs index 851d18e..a59b749 100644 --- a/src/Controls/PropertyPresenter/ValueConverter.cs +++ b/src/Controls/PropertyPresenter/ValueConverter.cs @@ -25,10 +25,11 @@ public sealed class ObjectImageConverter : IValueConverter return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(16, 16)); } - if (value is not string strValue) return Binding.DoNothing; + if (value is not string strValue) + return Binding.DoNothing; if (strValue.StartsWith(dynResPrefix, StringComparison.Ordinal)) { - var resource = Application.Current.TryFindResource(strValue.Replace(dynResPrefix, string.Empty , StringComparison.InvariantCulture)); + var resource = Application.Current.TryFindResource(strValue.Replace(dynResPrefix, string.Empty, StringComparison.InvariantCulture)); return resource is ImageSource source ? source : Binding.DoNothing; } @@ -41,8 +42,7 @@ public sealed class ObjectImageConverter : IValueConverter return GetIcon(Geometry.Parse(strValue), null); } - object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => - Binding.DoNothing; + object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => Binding.DoNothing; /// /// Get icon a ImageSource from geometry. @@ -68,15 +68,15 @@ public sealed class ObjectImageConverter : IValueConverter public static ImageSource DrawText(string text, string strFontFamily, Brush brush) { var fontFamily = new FontFamily(strFontFamily); - var formattedText = new FormattedText(text, + var formattedText = new FormattedText( + text, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, - new Typeface( - fontFamily, - FontStyles.Normal, - FontWeights.Normal, - FontStretches.Normal), - 64, brush, 1.5); + new Typeface(fontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal), + 64, + brush, + 1.5 + ); var geometry = formattedText.BuildGeometry(new Point(0, 0)); return GetIcon(geometry, null); @@ -90,9 +90,8 @@ public sealed class ObjectImageConverter : IValueConverter public class InverseBooleanConverter : IValueConverter { /// - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => - value is bool b ? !b : throw new InvalidOperationException("The target must be a boolean"); + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => value is bool b ? !b : throw new InvalidOperationException("The target must be a boolean"); /// public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => Binding.DoNothing; -} \ No newline at end of file +}