diff --git a/.editorconfig b/.editorconfig index bba08dd5e24..e7fcfa6c07e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,6 +14,11 @@ indent_size = 4 [*.json] indent_size = 2 +# Bvc.dll crashed in the CI build when this rule is enabled for VB. +# C# files +[src/**/*.cs] +file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license. + # C# and VB files [*.{cs,vb}] charset = utf-8-bom @@ -32,7 +37,7 @@ dotnet_style_predefined_type_for_member_access = true:suggestion # name all constant fields using PascalCase dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields -dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style dotnet_naming_symbols.constant_fields.applicable_kinds = field dotnet_naming_symbols.constant_fields.required_modifiers = const @@ -42,7 +47,7 @@ dotnet_naming_style.pascal_case_style.capitalization = pascal_case # static fields should have s_ prefix dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields -dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style +dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style dotnet_naming_symbols.static_fields.applicable_kinds = field dotnet_naming_symbols.static_fields.required_modifiers = static @@ -53,7 +58,7 @@ dotnet_naming_style.static_prefix_style.capitalization = camel_case # internal and private fields should be _camelCase dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields -dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style +dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style dotnet_naming_symbols.private_internal_fields.applicable_kinds = field dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal @@ -70,13 +75,28 @@ dotnet_style_collection_initializer = true:suggestion dotnet_style_explicit_tuple_names = true:suggestion dotnet_style_coalesce_expression = true:suggestion dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error +dotnet_style_prefer_auto_properties = true:silent +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_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 +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +end_of_line = crlf +dotnet_style_allow_multiple_blank_lines_experimental = true:silent +dotnet_style_allow_statement_immediately_after_block_experimental = true:silent # C# files [*.cs] # .NET diagnostic dotnet_diagnostic.RS0041.severity = none -dotnet_diagnostic.IDE0005.severity = warning +dotnet_diagnostic.IDE0005.severity = error # New line preferences csharp_new_line_before_open_brace = all @@ -95,7 +115,7 @@ csharp_indent_switch_labels = true csharp_indent_labels = one_less_than_current # only use var when it's obvious what the variable type is -csharp_style_var_for_built_in_types = false:silent +csharp_style_var_for_built_in_types = false:error csharp_style_var_when_type_is_apparent = true:silent csharp_style_var_elsewhere = false:silent @@ -104,12 +124,12 @@ csharp_preserve_single_line_blocks = true csharp_preserve_single_line_statements = false # Expression-bodied members -csharp_style_expression_bodied_methods = false:none -csharp_style_expression_bodied_constructors = false:none -csharp_style_expression_bodied_operators = false:none -csharp_style_expression_bodied_properties = true:none -csharp_style_expression_bodied_indexers = true:none -csharp_style_expression_bodied_accessors = true:none +csharp_style_expression_bodied_methods = true:silent +csharp_style_expression_bodied_constructors = true:silent +csharp_style_expression_bodied_operators = true:silent +csharp_style_expression_bodied_properties = true:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_accessors = true:silent # Pattern matching csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion @@ -146,6 +166,23 @@ csharp_space_between_square_brackets = false # IDE0008: Use explicit type dotnet_diagnostic.IDE0008.severity = silent +csharp_using_directive_placement = outside_namespace:silent +csharp_prefer_simple_using_statement = true:suggestion +csharp_prefer_braces = true:silent +csharp_style_namespace_declarations = block_scoped:silent +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_top_level_statements = true:silent +csharp_style_prefer_primary_constructors = true:suggestion +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent +# IDE0090: Use new() +dotnet_diagnostic.IDE0090.severity = error +csharp_style_deconstructed_variable_declaration = true:suggestion # Visual Basic files @@ -185,4 +222,4 @@ insert_final_newline = true end_of_line = lf [*.{cmd,bat}] -end_of_line = crlf \ No newline at end of file +end_of_line = crlf diff --git a/.github/fabricbot.json b/.github/fabricbot.json index 431495c8361..cd6e5413f02 100644 --- a/.github/fabricbot.json +++ b/.github/fabricbot.json @@ -645,7 +645,7 @@ { "name": "addMilestone", "parameters": { - "milestoneName": "8.0 RC1" + "milestoneName": "9.0 Preview1" } } ], diff --git a/Directory.Build.props b/Directory.Build.props index 52995daa3a6..e3ee7a0c954 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -6,9 +6,13 @@ + + net8.0 + net8.0 + net8.0 net - 8 - 0 + 8 + 0 $(TargetFrameworkMajorVersion).$(TargetFrameworkMinorVersion) $(TargetFrameworkName)$(TargetFrameworkVersion) Microsoft® .NET diff --git a/NuGet.config b/NuGet.config index 5b4943b80ec..8ff93f5d295 100644 --- a/NuGet.config +++ b/NuGet.config @@ -8,6 +8,8 @@ + + diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8ba94c0ec10..9091f016da3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -34,6 +34,7 @@ pr: - internal/release/* - internal/experimental/* - feature/win32 + - feature/9.0 paths: include: - '*' diff --git a/docs/designer/designer-high-dpi-mode.md b/docs/designer/designer-high-dpi-mode.md new file mode 100644 index 00000000000..1fd8266cff5 --- /dev/null +++ b/docs/designer/designer-high-dpi-mode.md @@ -0,0 +1,38 @@ +# Designer HighDpi mode +Visual Studio 2022 and beyond by default launch in PerMonitor DpiAwareness mode but it also supports SystemAware and Unaware DpiAwareness modes when users launch it with [custom settings](https://docs.microsoft.com/visualstudio/designers/disable-dpi-awareness?view=vs-2022). The WinForms designer does not fully support PerMonitor DpiAwareness mode yet and by default launches in SystemAware mode. + +In .NET 6, as part of unifying the information sharing between WinForms designer and WinForms runtime, we added [support](https://aka.ms/applicationconfiguration) for specifying the application dpi mode as a build time property on the project and share it for both designtime and at runtime. + +## Issues + The Winforms designer, when operating in SystemAware/PermonitorV2 mode, serializes layout metrics into the source file based on the Dpi setting of the current display device on which it is being rendered. This may lead to two kinds of problems. + + 1. WinForms applications developed on a machine with DPI settings different from the machine where they are executed may encounter layout inconsistencies. + + 2. Within a team of multiple developers collaborating on the same project, this situation can lead to unintentional modifications in the serialized source code, even if they are unrelated to the intended changes. As a consequence, it introduces additional overhead in the code review and merging process. + +The following example demonstrates an undesired modification in the serialized WinForms source code. + +![Unwanted Serialization changes](../images/Serialization.png) + + +Up until now, developers have been advised to adhere to the instructions given [here](https://go.microsoft.com/fwlink/?linkid=875609) and restart Visual Studio in DpiUnAware mode to resolve these problems. Nevertheless, this process requires individual developers to do it every time they work on the project, adding inconvenience. Additionally, the entire Visual Studio IDE would be launched as DPI Unaware resulting in a blurry IDE experience. + +## Solution + +In Visual Studio 2022 Version 17.8, we are introducing a new [configuration]((https://aka.ms/applicationconfiguration)) option called `ForceDesignerDpiUnaware`, distinct from `ApplicationHighDpiMode`. This option enables developers to enforce DpiUnAware mode for all WinForms designers in the project, regardless of the `ApplicationHighDpiMode`, which continues to take effect during runtime. The rest of the Visual Studio environment remains in PerMonitor mode and renders crisply. + + +```CS + + + + WinExe + net7.0-windows + enable + true + enable + SystemAware + true + +``` + diff --git a/docs/images/Serialization.png b/docs/images/Serialization.png new file mode 100644 index 00000000000..cfc6dfbb5cd Binary files /dev/null and b/docs/images/Serialization.png differ diff --git a/docs/testing.md b/docs/testing.md index 4cd82d1cbde..957d524b48e 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -126,7 +126,7 @@ Tests are built and executed by file name convention [WinFormsFact] public void ButtonBase_GetAutoSizeMode_Invoke_ReturnsExpected() { - using var control = new SubButtonBase(); + using SubButtonBase control = new(); Assert.Equal(AutoSizeMode.GrowOnly, control.GetAutoSizeMode()); } ``` @@ -163,8 +163,8 @@ When writing theories note the following: [WinFormsTheory] [MemberData(nameof(GetButton_TestData))] public void Ctor_Control_DataGridViewCellStyle(string buttonText) - { - using var button = new Button() { Text = buttonText }; + { + using Button button = new() { Text = buttonText }; ... } ``` @@ -184,7 +184,7 @@ When writing theories note the following: // ** DO NOT DO THIS! ** public static IEnumerable GetButton_TestData() { - var button = new Button(); + Button button = new(); yield return new object[] { button, new DataGridViewCellStyle() }; yield return new object[] { button { Text = "bla" }, new DataGridViewCellStyle() }; // the button could already be disposed by the time this theory runs } @@ -233,12 +233,12 @@ public void MyControl_Rendering() // 1. Create a control to validate rendering for. // 2. Add the control to a form, and make sure the form is created using Form form = new Form(); - using var control = new MyControl { ... }; + using MyControl control = new() { ... }; form.Controls.Add(control); Assert.NotEqual(IntPtr.Zero, form.Handle); // Create an Enhance Metafile into which we will render the control - using var emf = new EmfScope(); + using EmfScope emf = new(); DeviceContextState state = new DeviceContextState(emf); // Render the control diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 8a7f26b422d..0626e52fe29 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -7,201 +7,201 @@ Note: if the Uri is a new place, you will need to add a subscription from that p --> - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + f8c110b8003d68cc635add4ca791d6cf2e645561 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + de0ab156194eb64deae0e1018db9a58f7b02f4a3 - + https://github.com/dotnet/arcade - 9fba71ca242ef84c4b7696c380cc00efe734adb3 + 4665b3d04e1da3796b965c3c3e3b97f55c449a6e - + https://github.com/dotnet/arcade - 9fba71ca242ef84c4b7696c380cc00efe734adb3 + 4665b3d04e1da3796b965c3c3e3b97f55c449a6e - + https://github.com/dotnet/arcade - 9fba71ca242ef84c4b7696c380cc00efe734adb3 + 4665b3d04e1da3796b965c3c3e3b97f55c449a6e - + https://github.com/dotnet/arcade - 9fba71ca242ef84c4b7696c380cc00efe734adb3 + 4665b3d04e1da3796b965c3c3e3b97f55c449a6e - + https://github.com/dotnet/arcade - 9fba71ca242ef84c4b7696c380cc00efe734adb3 + 4665b3d04e1da3796b965c3c3e3b97f55c449a6e - + https://github.com/dotnet/arcade - 9fba71ca242ef84c4b7696c380cc00efe734adb3 + 4665b3d04e1da3796b965c3c3e3b97f55c449a6e diff --git a/eng/Versions.props b/eng/Versions.props index 6d45b73bdd1..e22eec0679b 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -1,46 +1,45 @@ - 8 + 9 0 0 - rc + alpha 1 $(MajorVersion).$(MinorVersion).$(PatchVersion) - - false + true - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 + 8.0.0-rc.1.23421.3 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 5.0.0-preview.7.20320.5 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 6.0.0 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 + 9.0.0-alpha.1.23460.2 @@ -53,9 +52,9 @@ - 8.0.0-beta.23369.2 - 8.0.0-beta.23369.2 - 8.0.0-beta.23369.2 + 8.0.0-beta.23451.1 + 8.0.0-beta.23451.1 + 8.0.0-beta.23451.1 17.4.0-preview-20220707-01 @@ -91,7 +90,7 @@ 0.1.329 1.0.0-beta.59 3.3.5-beta1.23327.3 - 4.4.0 + 4.8.0-1.23378.8 $(MicrosoftCodeAnalysisCommonPackageVersion) $(MicrosoftCodeAnalysisCommonPackageVersion) $(MicrosoftCodeAnalysisCommonPackageVersion) @@ -99,6 +98,7 @@ 1.1.2-beta1.23322.1 $(MicrosoftCodeAnalysisAnalyzersVersion) 8.0.0-preview.23327.3 + 4.8.0-1.23403.1 1.2.0-beta.507 diff --git a/eng/common/SetupNugetSources.ps1 b/eng/common/SetupNugetSources.ps1 index 6e997239451..6c65e81925f 100644 --- a/eng/common/SetupNugetSources.ps1 +++ b/eng/common/SetupNugetSources.ps1 @@ -153,7 +153,7 @@ if ($dotnet31Source -ne $null) { AddPackageSource -Sources $sources -SourceName "dotnet3.1-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-transport/nuget/v2" -Creds $creds -Username $userName -Password $Password } -$dotnetVersions = @('5','6','7') +$dotnetVersions = @('5','6','7','8') foreach ($dotnetVersion in $dotnetVersions) { $feedPrefix = "dotnet" + $dotnetVersion; diff --git a/eng/common/SetupNugetSources.sh b/eng/common/SetupNugetSources.sh index 8af7d899db1..d387c7eac95 100644 --- a/eng/common/SetupNugetSources.sh +++ b/eng/common/SetupNugetSources.sh @@ -105,7 +105,7 @@ if [ "$?" == "0" ]; then PackageSources+=('dotnet3.1-internal-transport') fi -DotNetVersions=('5' '6' '7') +DotNetVersions=('5' '6' '7' '8') for DotNetVersion in ${DotNetVersions[@]} ; do FeedPrefix="dotnet${DotNetVersion}"; diff --git a/eng/common/cross/toolchain.cmake b/eng/common/cross/toolchain.cmake index a88d643c8a7..0998e875e5f 100644 --- a/eng/common/cross/toolchain.cmake +++ b/eng/common/cross/toolchain.cmake @@ -207,6 +207,7 @@ elseif(ILLUMOS) set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lssp") elseif(HAIKU) set(CMAKE_SYSROOT "${CROSS_ROOTFS}") + set(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH};${CROSS_ROOTFS}/cross-tools-x86_64/bin") set(TOOLSET_PREFIX ${TOOLCHAIN}-) function(locate_toolchain_exec exec var) @@ -217,7 +218,6 @@ elseif(HAIKU) endif() find_program(EXEC_LOCATION_${exec} - PATHS "${CROSS_ROOTFS}/cross-tools-x86_64/bin" NAMES "${TOOLSET_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}" "${TOOLSET_PREFIX}${exec}") diff --git a/eng/common/loc/P22DotNetHtmlLocalization.lss b/eng/common/loc/P22DotNetHtmlLocalization.lss index 6661fed566e..5d892d61939 100644 Binary files a/eng/common/loc/P22DotNetHtmlLocalization.lss and b/eng/common/loc/P22DotNetHtmlLocalization.lss differ diff --git a/eng/common/native/init-compiler.sh b/eng/common/native/init-compiler.sh index 517401b688b..f5c1ec7eafe 100755 --- a/eng/common/native/init-compiler.sh +++ b/eng/common/native/init-compiler.sh @@ -63,7 +63,7 @@ if [ -z "$CLR_CC" ]; then # Set default versions if [ -z "$majorVersion" ]; then # note: gcc (all versions) and clang versions higher than 6 do not have minor version in file name, if it is zero. - if [ "$compiler" = "clang" ]; then versions="16 15 14 13 12 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5" + if [ "$compiler" = "clang" ]; then versions="17 16 15 14 13 12 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5" elif [ "$compiler" = "gcc" ]; then versions="13 12 11 10 9 8 7 6 5 4.9"; fi for version in $versions; do diff --git a/eng/common/native/init-distro-rid.sh b/eng/common/native/init-distro-rid.sh new file mode 100644 index 00000000000..de1687b2ccb --- /dev/null +++ b/eng/common/native/init-distro-rid.sh @@ -0,0 +1,130 @@ +#!/usr/bin/env bash + +# getNonPortableDistroRid +# +# Input: +# targetOs: (str) +# targetArch: (str) +# rootfsDir: (str) +# +# Return: +# non-portable rid +getNonPortableDistroRid() +{ + local targetOs="$1" + local targetArch="$2" + local rootfsDir="$3" + local nonPortableRid="" + + if [ "$targetOs" = "linux" ]; then + if [ -e "${rootfsDir}/etc/os-release" ]; then + source "${rootfsDir}/etc/os-release" + + if [[ "${ID}" == "rhel" || "${ID}" == "rocky" || "${ID}" == "alpine" ]]; then + # remove the last version digit + VERSION_ID="${VERSION_ID%.*}" + fi + + if [[ "${VERSION_ID:-}" =~ ^([[:digit:]]|\.)+$ ]]; then + nonPortableRid="${ID}.${VERSION_ID}-${targetArch}" + else + # Rolling release distros either do not set VERSION_ID, set it as blank or + # set it to non-version looking string (such as TEMPLATE_VERSION_ID on ArchLinux); + # so omit it here to be consistent with everything else. + nonPortableRid="${ID}-${targetArch}" + fi + + elif [ -e "${rootfsDir}/android_platform" ]; then + source "$rootfsDir"/android_platform + nonPortableRid="$RID" + fi + fi + + if [ "$targetOs" = "freebsd" ]; then + # $rootfsDir can be empty. freebsd-version is shell script and it should always work. + __freebsd_major_version=$($rootfsDir/bin/freebsd-version | { read v; echo "${v%%.*}"; }) + nonPortableRid="freebsd.$__freebsd_major_version-${targetArch}" + elif command -v getprop && getprop ro.product.system.model 2>&1 | grep -qi android; then + __android_sdk_version=$(getprop ro.build.version.sdk) + nonPortableRid="android.$__android_sdk_version-${targetArch}" + elif [ "$targetOs" = "illumos" ]; then + __uname_version=$(uname -v) + case "$__uname_version" in + omnios-*) + __omnios_major_version=$(echo "${__uname_version:8:2}") + nonPortableRid=omnios."$__omnios_major_version"-"$targetArch" + ;; + joyent_*) + __smartos_major_version=$(echo "${__uname_version:7:4}") + nonPortableRid=smartos."$__smartos_major_version"-"$targetArch" + ;; + illumos_*) + nonPortableRid=openindiana-"$targetArch" + ;; + esac + elif [ "$targetOs" = "solaris" ]; then + __uname_version=$(uname -v) + __solaris_major_version=$(echo "${__uname_version%.*}") + nonPortableRid=solaris."$__solaris_major_version"-"$targetArch" + elif [ "$targetOs" = "haiku" ]; then + __uname_release=$(uname -r) + nonPortableRid=haiku.r"$__uname_release"-"$targetArch" + fi + + echo "$(echo $nonPortableRid | tr '[:upper:]' '[:lower:]')" +} + +# initDistroRidGlobal +# +# Input: +# os: (str) +# arch: (str) +# rootfsDir?: (nullable:string) +# +# Return: +# None +# +# Notes: +# +# It is important to note that the function does not return anything, but it +# exports the following variables on success: +# +# __DistroRid : Non-portable rid of the target platform. +# __PortableTargetOS : OS-part of the portable rid that corresponds to the target platform. +# +initDistroRidGlobal() +{ + local targetOs="$1" + local targetArch="$2" + local rootfsDir="" + if [ "$#" -ge 3 ]; then + rootfsDir="$3" + fi + + if [ -n "${rootfsDir}" ]; then + # We may have a cross build. Check for the existence of the rootfsDir + if [ ! -e "${rootfsDir}" ]; then + echo "Error rootfsDir has been passed, but the location is not valid." + exit 1 + fi + fi + + __DistroRid=$(getNonPortableDistroRid "${targetOs}" "${targetArch}" "${rootfsDir}") + + if [ -z "${__PortableTargetOS:-}" ]; then + __PortableTargetOS="$targetOs" + + STRINGS="$(command -v strings || true)" + if [ -z "$STRINGS" ]; then + STRINGS="$(command -v llvm-strings || true)" + fi + + # Check for musl-based distros (e.g Alpine Linux, Void Linux). + if "${rootfsDir}/usr/bin/ldd" --version 2>&1 | grep -q musl || + ( [ -n "$STRINGS" ] && "$STRINGS" "${rootfsDir}/usr/bin/ldd" 2>&1 | grep -q musl ); then + __PortableTargetOS="linux-musl" + fi + fi + + export __DistroRid __PortableTargetOS +} diff --git a/eng/common/native/init-os-and-arch.sh b/eng/common/native/init-os-and-arch.sh new file mode 100644 index 00000000000..e693617a6c2 --- /dev/null +++ b/eng/common/native/init-os-and-arch.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +# Use uname to determine what the OS is. +OSName=$(uname -s | tr '[:upper:]' '[:lower:]') + +if command -v getprop && getprop ro.product.system.model 2>&1 | grep -qi android; then + OSName="android" +fi + +case "$OSName" in +freebsd|linux|netbsd|openbsd|sunos|android|haiku) + os="$OSName" ;; +darwin) + os=osx ;; +*) + echo "Unsupported OS $OSName detected!" + exit 1 ;; +esac + +# On Solaris, `uname -m` is discouraged, see https://docs.oracle.com/cd/E36784_01/html/E36870/uname-1.html +# and `uname -p` returns processor type (e.g. i386 on amd64). +# The appropriate tool to determine CPU is isainfo(1) https://docs.oracle.com/cd/E36784_01/html/E36870/isainfo-1.html. +if [ "$os" = "sunos" ]; then + if uname -o 2>&1 | grep -q illumos; then + os="illumos" + else + os="solaris" + fi + CPUName=$(isainfo -n) +else + # For the rest of the operating systems, use uname(1) to determine what the CPU is. + CPUName=$(uname -m) +fi + +case "$CPUName" in + arm64|aarch64) + arch=arm64 + ;; + + loongarch64) + arch=loongarch64 + ;; + + riscv64) + arch=riscv64 + ;; + + amd64|x86_64) + arch=x64 + ;; + + armv7l|armv8l) + if (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then + arch=armel + else + arch=arm + fi + ;; + + armv6l) + arch=armv6 + ;; + + i[3-6]86) + echo "Unsupported CPU $CPUName detected, build might not succeed!" + arch=x86 + ;; + + s390x) + arch=s390x + ;; + + ppc64le) + arch=ppc64le + ;; + *) + echo "Unknown CPU $CPUName detected!" + exit 1 + ;; +esac diff --git a/eng/common/sdl/configure-sdl-tool.ps1 b/eng/common/sdl/configure-sdl-tool.ps1 index e4108e39d9a..27f5a4115fc 100644 --- a/eng/common/sdl/configure-sdl-tool.ps1 +++ b/eng/common/sdl/configure-sdl-tool.ps1 @@ -93,7 +93,9 @@ try { } 'binskim' { if ($targetDirectory) { - $tool.Args += "`"Target < $TargetDirectory\**`"" + # Binskim crashes due to specific PDBs. GitHub issue: https://github.com/microsoft/binskim/issues/924. + # We are excluding all `_.pdb` files from the scan. + $tool.Args += "`"Target < $TargetDirectory\**;-:file|$TargetDirectory\**\_.pdb`"" } $tool.Args += $BinskimAdditionalRunConfigParams } diff --git a/eng/common/sdl/extract-artifact-packages.ps1 b/eng/common/sdl/extract-artifact-packages.ps1 index 7f28d9c59ec..f031ed5b25e 100644 --- a/eng/common/sdl/extract-artifact-packages.ps1 +++ b/eng/common/sdl/extract-artifact-packages.ps1 @@ -35,31 +35,33 @@ try { param( [string] $PackagePath # Full path to a NuGet package ) - + if (!(Test-Path $PackagePath)) { Write-PipelineTelemetryError -Category 'Build' -Message "Input file does not exist: $PackagePath" ExitWithExitCode 1 } - + $RelevantExtensions = @('.dll', '.exe', '.pdb') Write-Host -NoNewLine 'Extracting ' ([System.IO.Path]::GetFileName($PackagePath)) '...' - + $PackageId = [System.IO.Path]::GetFileNameWithoutExtension($PackagePath) $ExtractPath = Join-Path -Path $using:ExtractPath -ChildPath $PackageId - + Add-Type -AssemblyName System.IO.Compression.FileSystem - + [System.IO.Directory]::CreateDirectory($ExtractPath); - + try { $zip = [System.IO.Compression.ZipFile]::OpenRead($PackagePath) $zip.Entries | Where-Object {$RelevantExtensions -contains [System.IO.Path]::GetExtension($_.Name)} | ForEach-Object { - $TargetFile = Join-Path -Path $ExtractPath -ChildPath $_.Name - - [System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $TargetFile, $true) + $TargetPath = Join-Path -Path $ExtractPath -ChildPath (Split-Path -Path $_.FullName) + [System.IO.Directory]::CreateDirectory($TargetPath); + + $TargetFile = Join-Path -Path $ExtractPath -ChildPath $_.FullName + [System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $TargetFile) } } catch { diff --git a/eng/common/sdl/trim-assets-version.ps1 b/eng/common/sdl/trim-assets-version.ps1 new file mode 100644 index 00000000000..a2e00487704 --- /dev/null +++ b/eng/common/sdl/trim-assets-version.ps1 @@ -0,0 +1,75 @@ +<# +.SYNOPSIS +Install and run the 'Microsoft.DotNet.VersionTools.Cli' tool with the 'trim-artifacts-version' command to trim the version from the NuGet assets file name. + +.PARAMETER InputPath +Full path to directory where artifact packages are stored + +.PARAMETER Recursive +Search for NuGet packages recursively + +#> + +Param( + [string] $InputPath, + [bool] $Recursive = $true +) + +$CliToolName = "Microsoft.DotNet.VersionTools.Cli" + +function Install-VersionTools-Cli { + param( + [Parameter(Mandatory=$true)][string]$Version + ) + + Write-Host "Installing the package '$CliToolName' with a version of '$version' ..." + $feed = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" + + $argumentList = @("tool", "install", "--local", "$CliToolName", "--add-source $feed", "--no-cache", "--version $Version", "--create-manifest-if-needed") + Start-Process "$dotnet" -Verbose -ArgumentList $argumentList -NoNewWindow -Wait +} + +# ------------------------------------------------------------------- + +if (!(Test-Path $InputPath)) { + Write-Host "Input Path '$InputPath' does not exist" + ExitWithExitCode 1 +} + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version 2.0 + +$disableConfigureToolsetImport = $true +$global:LASTEXITCODE = 0 + +# `tools.ps1` checks $ci to perform some actions. Since the SDL +# scripts don't necessarily execute in the same agent that run the +# build.ps1/sh script this variable isn't automatically set. +$ci = $true +. $PSScriptRoot\..\tools.ps1 + +try { + $dotnetRoot = InitializeDotNetCli -install:$true + $dotnet = "$dotnetRoot\dotnet.exe" + + $toolsetVersion = Read-ArcadeSdkVersion + Install-VersionTools-Cli -Version $toolsetVersion + + $cliToolFound = (& "$dotnet" tool list --local | Where-Object {$_.Split(' ')[0] -eq $CliToolName}) + if ($null -eq $cliToolFound) { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "The '$CliToolName' tool is not installed." + ExitWithExitCode 1 + } + + Exec-BlockVerbosely { + & "$dotnet" $CliToolName trim-assets-version ` + --assets-path $InputPath ` + --recursive $Recursive + Exit-IfNZEC "Sdl" + } +} +catch { + Write-Host $_ + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ + ExitWithExitCode 1 +} \ No newline at end of file diff --git a/eng/common/templates/job/execute-sdl.yml b/eng/common/templates/job/execute-sdl.yml index 7aabaa18017..7870f93bc17 100644 --- a/eng/common/templates/job/execute-sdl.yml +++ b/eng/common/templates/job/execute-sdl.yml @@ -105,6 +105,11 @@ jobs: downloadPath: $(Build.ArtifactStagingDirectory)\artifacts checkDownloadedFiles: true + - powershell: eng/common/sdl/trim-assets-version.ps1 + -InputPath $(Build.ArtifactStagingDirectory)\artifacts + displayName: Trim the version from the NuGet packages + continueOnError: ${{ parameters.sdlContinueOnError }} + - powershell: eng/common/sdl/extract-artifact-packages.ps1 -InputPath $(Build.ArtifactStagingDirectory)\artifacts\BlobArtifacts -ExtractPath $(Build.ArtifactStagingDirectory)\artifacts\BlobArtifacts diff --git a/eng/common/templates/steps/source-build.yml b/eng/common/templates/steps/source-build.yml index 1100521834a..41bbb915736 100644 --- a/eng/common/templates/steps/source-build.yml +++ b/eng/common/templates/steps/source-build.yml @@ -118,3 +118,12 @@ steps: artifactName: BuildLogs_SourceBuild_${{ parameters.platform.name }}_Attempt$(System.JobAttempt) continueOnError: true condition: succeededOrFailed() + +# Manually inject component detection so that we can ignore the source build upstream cache, which contains +# a nupkg cache of input packages (a local feed). +# This path must match the upstream cache path in property 'CurrentRepoSourceBuiltNupkgCacheDir' +# in src\Microsoft.DotNet.Arcade.Sdk\tools\SourceBuild\SourceBuildArcade.targets +- task: ComponentGovernanceComponentDetection@0 + displayName: Component Detection (Exclude upstream cache) + inputs: + ignoreDirectories: '$(Build.SourcesDirectory)/artifacts/source-build/self/src/artifacts/obj/source-built-upstream-cache' diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index c9eced9f7df..aa74ab4a81e 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -671,6 +671,10 @@ function InitializeNativeTools() { } } +function Read-ArcadeSdkVersion() { + return $GlobalJson.'msbuild-sdks'.'Microsoft.DotNet.Arcade.Sdk' +} + function InitializeToolset() { if (Test-Path variable:global:_ToolsetBuildProj) { return $global:_ToolsetBuildProj @@ -678,7 +682,7 @@ function InitializeToolset() { $nugetCache = GetNuGetPackageCachePath - $toolsetVersion = $GlobalJson.'msbuild-sdks'.'Microsoft.DotNet.Arcade.Sdk' + $toolsetVersion = Read-ArcadeSdkVersion $toolsetLocationFile = Join-Path $ToolsetDir "$toolsetVersion.txt" if (Test-Path $toolsetLocationFile) { diff --git a/global.json b/global.json index f9dafb285fc..1c325a80dff 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "tools": { - "dotnet": "8.0.100-preview.6.23330.14", + "dotnet": "8.0.100-preview.7.23376.3", "runtimes": { "dotnet/x64": [ "$(VSRedistCommonNetCoreSharedFrameworkx6480PackageVersion)" @@ -11,14 +11,14 @@ } }, "sdk": { - "version": "8.0.100-preview.6.23330.14" + "version": "8.0.100-preview.7.23376.3" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23369.2", - "Microsoft.DotNet.CMake.Sdk": "8.0.0-beta.23369.2", - "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23369.2", + "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23451.1", + "Microsoft.DotNet.CMake.Sdk": "8.0.0-beta.23451.1", + "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23451.1", "FIX-85B6-MERGE-9C38-CONFLICT": "1.0.0", - "Microsoft.NET.Sdk.IL": "8.0.0-preview.7.23367.16" + "Microsoft.NET.Sdk.IL": "9.0.0-alpha.1.23460.2" }, "native-tools": { "cmake": "latest" diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.cs.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.cs.json index 6147a62c5df..8db678c5b37 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.cs.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.cs.json @@ -15,6 +15,8 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Target net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", "symbols/Framework/displayName": "Framework", "symbols/langVersion/description": "Nastaví langVersion ve vytvořeném souboru projektu.", "symbols/langVersion/displayName": "Verze jazyka", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.de.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.de.json index bf80d969532..53a007ffd38 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.de.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.de.json @@ -15,6 +15,8 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Ziel net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Ziel net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", "symbols/Framework/displayName": "Framework", "symbols/langVersion/description": "Legt „langVersion“ in der erstellten Projektdatei fest", "symbols/langVersion/displayName": "Sprachversion", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.en.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.en.json index 7ca54565f89..a3871a6b87f 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.en.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.en.json @@ -15,6 +15,8 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Target net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", "symbols/Framework/displayName": "Framework", "symbols/langVersion/description": "Sets langVersion in the created project file", "symbols/langVersion/displayName": "Language Version", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.es.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.es.json index 6e6f740e9b0..dbb2829069f 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.es.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.es.json @@ -15,6 +15,8 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Net8.0 de destino", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 de destino", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", "symbols/Framework/displayName": "Plataforma", "symbols/langVersion/description": "Establece langVersion en el archivo de proyecto creado.", "symbols/langVersion/displayName": "Versión de lenguaje", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.fr.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.fr.json index c07b1473841..ea15e45c62a 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.fr.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.fr.json @@ -15,6 +15,8 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Cible Net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 cible", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", "symbols/Framework/displayName": "Framework", "symbols/langVersion/description": "Définit langVersion dans le fichier projet créé", "symbols/langVersion/displayName": "Version du Langage", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.it.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.it.json index 76c08a26e0d..6b2400f28d4 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.it.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.it.json @@ -15,6 +15,8 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Destinazione net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 di destinazione", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", "symbols/Framework/displayName": "Framework", "symbols/langVersion/description": "Imposta langVersion nel file di progetto creato", "symbols/langVersion/displayName": "Versione linguaggio", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.ja.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.ja.json index 3f155205df2..b5ea92cdea4 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.ja.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.ja.json @@ -15,6 +15,8 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "ターゲット net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "ターゲット net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", "symbols/Framework/displayName": "フレームワーク", "symbols/langVersion/description": "作成されたプロジェクト ファイルで langVersion を設定します", "symbols/langVersion/displayName": "言語バージョン", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.ko.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.ko.json index ce3622d75e3..43845d8bf28 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.ko.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.ko.json @@ -15,6 +15,8 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "대상 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", "symbols/Framework/displayName": "프레임워크", "symbols/langVersion/description": "만든 프로젝트 파일의 langVersion를 설정합니다", "symbols/langVersion/displayName": "언어 버전", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.pl.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.pl.json index 0b9370b60b3..720a1ed5985 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.pl.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.pl.json @@ -15,6 +15,8 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Docelowa platforma NET 8.0", "symbols/Framework/choices/net8.0/displayName": "NET 8.0", + "symbols/Framework/choices/net9.0/description": "Docelowa platforma net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", "symbols/Framework/displayName": "Platforma", "symbols/langVersion/description": "Ustawia langVersion w utworzonym pliku projektu", "symbols/langVersion/displayName": "Wersja języka", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.pt-BR.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.pt-BR.json index a52e2179daa..ae0ef420d99 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.pt-BR.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.pt-BR.json @@ -15,6 +15,8 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": ".NET 8.0 de destino", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", "symbols/Framework/displayName": "Framework", "symbols/langVersion/description": "Define a langVersion no arquivo do projeto criado", "symbols/langVersion/displayName": "Versão da Linguagem", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.ru.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.ru.json index def09ea8562..98ae138dd4d 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.ru.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.ru.json @@ -15,6 +15,8 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Целевая net8.0", "symbols/Framework/choices/net8.0/displayName": "NET 8.0", + "symbols/Framework/choices/net9.0/description": "Целевая среда net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", "symbols/Framework/displayName": "Платформа", "symbols/langVersion/description": "Задает свойство langVersion в созданном файле проекта", "symbols/langVersion/displayName": "Версия языка", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.tr.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.tr.json index 7b4caa9bd1c..5396a8e6e02 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.tr.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.tr.json @@ -15,6 +15,8 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Hedef net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Hedef net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", "symbols/Framework/displayName": "Çerçeve", "symbols/langVersion/description": "Oluşturulan proje dosyasında langVersion'ı ayarlar", "symbols/langVersion/displayName": "Dil Sürümü", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.zh-Hans.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.zh-Hans.json index 5d7eb55ec41..142b4024358 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.zh-Hans.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.zh-Hans.json @@ -15,6 +15,8 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "目标 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "目标 net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", "symbols/Framework/displayName": "框架", "symbols/langVersion/description": "在创建的项目文件中设置 langVersion", "symbols/langVersion/displayName": "语言版本", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.zh-Hant.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.zh-Hant.json index e570cf29584..cb0551d6785 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.zh-Hant.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/localize/templatestrings.zh-Hant.json @@ -15,6 +15,8 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "目標 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "目標 net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", "symbols/Framework/displayName": "架構", "symbols/langVersion/description": "在建立的專案檔中設定 langVersion", "symbols/langVersion/displayName": "語言版本", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/template.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/template.json index 3155149cc93..bd86a859337 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/template.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/template.json @@ -6,8 +6,8 @@ "generatorVersions": "[1.0.0.0-*)", "description": "A project template for creating a .NET Windows Forms (WinForms) App.", "groupIdentity": "Microsoft.Common.WinForms", - "precedence": "8000", - "identity": "Microsoft.Common.WinForms.CSharp.8.0", + "precedence": "9000", + "identity": "Microsoft.Common.WinForms.CSharp.9.0", "shortName": "winforms", "tags": { "language": "C#", @@ -53,10 +53,15 @@ "choice": "net8.0", "description": "Target net8.0", "displayName": ".NET 8.0" + }, + { + "choice": "net9.0", + "description": "Target net9.0", + "displayName": ".NET 9.0" } ], "replaces": "FrameworkParameter", - "defaultValue": "net8.0", + "defaultValue": "net9.0", "displayName": "Framework" }, "langVersion": { @@ -100,11 +105,11 @@ }, "csharpFeature_ImplicitUsings": { "type": "computed", - "value": "(Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\") && csharp10orLater == \"true\"" + "value": "(Framework == \"net9.0\" || Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\") && csharp10orLater == \"true\"" }, "csharpFeature_FileScopedNamespaces": { "type": "computed", - "value": "(Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\" || langVersion != \"\") && csharp10orLater == \"true\"" + "value": "(Framework == \"net9.0\" || Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\" || langVersion != \"\") && csharp10orLater == \"true\"" } }, "primaryOutputs": [ @@ -129,7 +134,7 @@ }, { "exclude": [ "**/[Bb]in/**", "**/[Oo]bj/**", ".template.config/**/*", "**/*.filelist", "**/*.lock.json" ], - "condition": "(Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\")", + "condition": "(Framework == \"net9.0\" || Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\")", "source": "./net6.0", "target": "./" } diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.cs.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.cs.json index 05ccfc4666c..7be08ccf804 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.cs.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.cs.json @@ -16,7 +16,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Target net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Nastaví langVersion ve vytvořeném souboru projektu.", "symbols/langVersion/displayName": "Verze jazyka", "symbols/skipRestore/description": "Pokud se tato možnost zadá, přeskočí automatické obnovení projektu při vytvoření.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.de.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.de.json index 46e5084adf8..11c3be9c2b2 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.de.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.de.json @@ -16,7 +16,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Ziel net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Ziel net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Legt „langVersion“ in der erstellten Projektdatei fest", "symbols/langVersion/displayName": "Sprachversion", "symbols/skipRestore/description": "Wenn angegeben, wird die automatische Wiederherstellung des Projekts beim Erstellen übersprungen.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.en.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.en.json index 31ab6e4e365..7a66ab28395 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.en.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.en.json @@ -16,7 +16,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Target net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Sets langVersion in the created project file", "symbols/langVersion/displayName": "Language Version", "symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.es.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.es.json index 5ac70674ca0..b00e5846c62 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.es.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.es.json @@ -16,7 +16,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Net8.0 de destino", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 de destino", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Establece langVersion en el archivo de proyecto creado.", "symbols/langVersion/displayName": "Versión de lenguaje", "symbols/skipRestore/description": "Si se especifica, se omite la restauración automática del proyecto durante la creación.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.fr.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.fr.json index 23863f8f040..2b54bba63e4 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.fr.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.fr.json @@ -16,7 +16,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Cible Net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 cible", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Définit langVersion dans le fichier projet créé", "symbols/langVersion/displayName": "Version du Langage", "symbols/skipRestore/description": "S’il est spécifié, ignore la restauration automatique du projet lors de la création.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.it.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.it.json index eba5f277c51..9e481323135 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.it.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.it.json @@ -16,7 +16,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Destinazione net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 di destinazione", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Imposta langVersion nel file di progetto creato", "symbols/langVersion/displayName": "Versione linguaggio", "symbols/skipRestore/description": "Se specificato, ignora il ripristino automatico del progetto durante la creazione.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.ja.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.ja.json index 9094f57ce42..f6a4c875601 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.ja.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.ja.json @@ -16,7 +16,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "ターゲット net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "ターゲット net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "作成されたプロジェクト ファイルで langVersion を設定します", "symbols/langVersion/displayName": "言語バージョン", "symbols/skipRestore/description": "指定した場合、作成時にプロジェクトの自動復元がスキップされます。", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.ko.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.ko.json index 674afce8b6c..602dbe3a70c 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.ko.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.ko.json @@ -16,7 +16,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "대상 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "대상 net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "만든 프로젝트 파일의 langVersion를 설정합니다", "symbols/langVersion/displayName": "언어 버전", "symbols/skipRestore/description": "지정된 경우, 프로젝트 생성 시 자동 복원을 건너뜁니다.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.pl.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.pl.json index 357e710e844..86905de75e8 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.pl.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.pl.json @@ -16,7 +16,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Docelowa platforma NET 8.0", "symbols/Framework/choices/net8.0/displayName": "NET 8.0", - "symbols/Framework/displayName": "NET 8.0", + "symbols/Framework/choices/net9.0/description": "Docelowa platforma net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Ustawia langVersion w utworzonym pliku projektu", "symbols/langVersion/displayName": "Wersja języka", "symbols/skipRestore/description": "Jeśli ta opcja jest określona, pomija automatyczne przywracanie projektu podczas tworzenia.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.pt-BR.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.pt-BR.json index bad04e88b71..b47b4c8825e 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.pt-BR.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.pt-BR.json @@ -16,7 +16,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": ".NET 8.0 de destino", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Define a langVersion no arquivo do projeto criado", "symbols/langVersion/displayName": "Versão da Linguagem", "symbols/skipRestore/description": "Se especificado, ignora a restauração automática do projeto sendo criado.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.ru.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.ru.json index 411ca3cadd1..3c9c6d35356 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.ru.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.ru.json @@ -16,7 +16,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Целевая net8.0", "symbols/Framework/choices/net8.0/displayName": "NET 8.0", - "symbols/Framework/displayName": "NET 8.0", + "symbols/Framework/choices/net9.0/description": "Целевая среда net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Задает свойство langVersion в созданном файле проекта", "symbols/langVersion/displayName": "Версия языка", "symbols/skipRestore/description": "Если установлено, автоматическое восстановление проекта при создании пропускается.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.tr.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.tr.json index f3c141de7aa..50bb2329527 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.tr.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.tr.json @@ -16,7 +16,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Hedef net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Hedef net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Oluşturulan proje dosyasında langVersion'ı ayarlar", "symbols/langVersion/displayName": "Dil Sürümü", "symbols/skipRestore/description": "Belirtilmişse, oluşturulmakta olan projenin otomatik geri yüklenmesini atlar.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.zh-Hans.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.zh-Hans.json index 99be4628388..c88fc57078e 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.zh-Hans.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.zh-Hans.json @@ -16,7 +16,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "目标 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "目标 net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "在创建的项目文件中设置 langVersion", "symbols/langVersion/displayName": "语言版本", "symbols/skipRestore/description": "如果指定,则在创建时跳过项目的自动还原。", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.zh-Hant.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.zh-Hant.json index 1e19ed4e629..e5ebc2955bf 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.zh-Hant.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/localize/templatestrings.zh-Hant.json @@ -16,7 +16,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "目標 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "目標 net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "在建立的專案檔中設定 langVersion", "symbols/langVersion/displayName": "語言版本", "symbols/skipRestore/description": "若指定,會在建立時跳過專案的自動還原。", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/template.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/template.json index 3bc9aa672cf..57d093e1059 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/template.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/template.json @@ -6,8 +6,8 @@ "generatorVersions": "[1.0.0.0-*)", "description": "A project template for creating a .NET Windows Forms (WinForms) App.", "groupIdentity": "Microsoft.Common.WinForms", - "precedence": "8000", - "identity": "Microsoft.Common.WinForms.VisualBasic.8.0", + "precedence": "9000", + "identity": "Microsoft.Common.WinForms.VisualBasic.9.0", "shortName": "winforms", "tags": { "language": "VB", @@ -59,11 +59,16 @@ "choice": "net8.0", "description": "Target net8.0", "displayName": ".NET 8.0" + }, + { + "choice": "net9.0", + "description": "Target net9.0", + "displayName": ".NET 9.0" } ], "replaces": "FrameworkParameter", - "defaultValue": "net8.0", - "displayName": ".NET 8.0" + "defaultValue": "net9.0", + "displayName": ".NET 9.0" }, "UseWindowsDesktopSdk": { "type": "computed", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.cs.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.cs.json index 2af45c5494d..f7338f5dad2 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.cs.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.cs.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Target net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Nastaví langVersion ve vytvořeném souboru projektu.", "symbols/langVersion/displayName": "Verze jazyka", "symbols/skipRestore/description": "Pokud se tato možnost zadá, přeskočí automatické obnovení projektu při vytvoření.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.de.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.de.json index 01525a25494..aedbea69320 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.de.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.de.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Ziel net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Ziel net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Legt „langVersion“ in der erstellten Projektdatei fest", "symbols/langVersion/displayName": "Sprachversion", "symbols/skipRestore/description": "Wenn angegeben, wird die automatische Wiederherstellung des Projekts beim Erstellen übersprungen.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.en.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.en.json index a2248fa76ea..0a2f330863f 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.en.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.en.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Target net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Sets langVersion in the created project file", "symbols/langVersion/displayName": "Language Version", "symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.es.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.es.json index 2b39b58a669..54c4ed90ffc 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.es.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.es.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Net8.0 de destino", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 de destino", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Establece langVersion en el archivo de proyecto creado.", "symbols/langVersion/displayName": "Versión de lenguaje", "symbols/skipRestore/description": "Si se especifica, se omite la restauración automática del proyecto durante la creación.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.fr.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.fr.json index ec95903ec9b..d1962ae4eff 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.fr.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.fr.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Cible Net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 cible", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Définit langVersion dans le fichier projet créé", "symbols/langVersion/displayName": "Version du Langage", "symbols/skipRestore/description": "S’il est spécifié, ignore la restauration automatique du projet lors de la création.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.it.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.it.json index 278ae81bf14..6937ad2531e 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.it.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.it.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Destinazione net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 di destinazione", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Imposta langVersion nel file di progetto creato", "symbols/langVersion/displayName": "Versione linguaggio", "symbols/skipRestore/description": "Se specificato, ignora il ripristino automatico del progetto durante la creazione.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.ja.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.ja.json index 64018179a3d..ec58184cef2 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.ja.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.ja.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "ターゲット net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "ターゲット net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "作成されたプロジェクト ファイルで langVersion を設定します", "symbols/langVersion/displayName": "言語バージョン", "symbols/skipRestore/description": "指定した場合、作成時にプロジェクトの自動復元がスキップされます。", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.ko.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.ko.json index 288fa288c20..a3a20d59324 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.ko.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.ko.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "대상 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "만든 프로젝트 파일의 langVersion를 설정합니다", "symbols/langVersion/displayName": "언어 버전", "symbols/skipRestore/description": "지정된 경우, 프로젝트 생성 시 자동 복원을 건너뜁니다.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.pl.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.pl.json index f7f9c0ce4a2..9e6e95732f8 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.pl.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.pl.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Docelowa platforma NET 8.0", "symbols/Framework/choices/net8.0/displayName": "NET 8.0", - "symbols/Framework/displayName": "NET 8.0", + "symbols/Framework/choices/net9.0/description": "Docelowa platforma net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Ustawia langVersion w utworzonym pliku projektu", "symbols/langVersion/displayName": "Wersja języka", "symbols/skipRestore/description": "Jeśli ta opcja jest określona, pomija automatyczne przywracanie projektu podczas tworzenia.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.pt-BR.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.pt-BR.json index 87a094ce6d8..7219b231297 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.pt-BR.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.pt-BR.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": ".NET 8.0 de destino", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Define a langVersion no arquivo do projeto criado", "symbols/langVersion/displayName": "Versão da Linguagem", "symbols/skipRestore/description": "Se especificado, ignora a restauração automática do projeto sendo criado.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.ru.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.ru.json index fc01c2a2a58..e05346e0e9f 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.ru.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.ru.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Целевая net8.0", "symbols/Framework/choices/net8.0/displayName": "NET 8.0", - "symbols/Framework/displayName": "NET 8.0", + "symbols/Framework/choices/net9.0/description": "Целевая среда net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Задает свойство langVersion в созданном файле проекта", "symbols/langVersion/displayName": "Версия языка", "symbols/skipRestore/description": "Если установлено, автоматическое восстановление проекта при создании пропускается.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.tr.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.tr.json index 879f2de70d1..5264513da87 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.tr.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.tr.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Hedef net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Hedef net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Oluşturulan proje dosyasında langVersion'ı ayarlar", "symbols/langVersion/displayName": "Dil Sürümü", "symbols/skipRestore/description": "Belirtilmişse, oluşturulmakta olan projenin otomatik geri yüklenmesini atlar.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.zh-Hans.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.zh-Hans.json index de098b3a1f1..5cc2cdccd48 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.zh-Hans.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.zh-Hans.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "目标 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "目标 net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "在创建的项目文件中设置 langVersion", "symbols/langVersion/displayName": "语言版本", "symbols/skipRestore/description": "如果指定,则在创建时跳过项目的自动还原。", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.zh-Hant.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.zh-Hant.json index c33a4453736..800578a52f5 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.zh-Hant.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/localize/templatestrings.zh-Hant.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "目標 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "目標 net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "在建立的專案檔中設定 langVersion", "symbols/langVersion/displayName": "語言版本", "symbols/skipRestore/description": "若指定,會在建立時跳過專案的自動還原。", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/template.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/template.json index 848a505d58b..b6ed1857780 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/template.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/template.json @@ -6,8 +6,8 @@ "generatorVersions": "[1.0.0.0-*)", "description": "A project template for creating a control library that targets .NET Windows Forms (WinForms).", "groupIdentity": "Microsoft.Common.WinForms.ControlLibrary", - "precedence": "8000", - "identity": "Microsoft.Common.WinForms.ControlLibrary.CSharp.8.0", + "precedence": "9000", + "identity": "Microsoft.Common.WinForms.ControlLibrary.CSharp.9.0", "shortName": "winformscontrollib", "tags": { "language": "C#", @@ -53,11 +53,16 @@ "choice": "net8.0", "description": "Target net8.0", "displayName": ".NET 8.0" + }, + { + "choice": "net9.0", + "description": "Target net9.0", + "displayName": ".NET 9.0" } ], "replaces": "FrameworkParameter", - "defaultValue": "net8.0", - "displayName": ".NET 8.0" + "defaultValue": "net9.0", + "displayName": ".NET 9.0" }, "langVersion": { "type": "parameter", @@ -100,11 +105,11 @@ }, "csharpFeature_ImplicitUsings": { "type": "computed", - "value": "(Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\") && csharp10orLater == \"true\"" + "value": "(Framework == \"net9.0\" || Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\") && csharp10orLater == \"true\"" }, "csharpFeature_FileScopedNamespaces": { "type": "computed", - "value": "(Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\" || langVersion != \"\") && csharp10orLater == \"true\"" + "value": "(Framework == \"net9.0\" || Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\" || langVersion != \"\") && csharp10orLater == \"true\"" } }, "primaryOutputs": [ @@ -129,7 +134,7 @@ }, { "exclude": [ "**/[Bb]in/**", "**/[Oo]bj/**", ".template.config/**/*", "**/*.filelist", "**/*.lock.json" ], - "condition": "(Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\")", + "condition": "(Framework == \"net9.0\" || Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\")", "source": "./net6.0", "target": "./" } diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.cs.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.cs.json index fb3dc54a27c..22b8f4f374c 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.cs.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.cs.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Target net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Nastaví langVersion ve vytvořeném souboru projektu.", "symbols/langVersion/displayName": "Verze jazyka", "symbols/skipRestore/description": "Pokud se tato možnost zadá, přeskočí automatické obnovení projektu při vytvoření.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.de.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.de.json index 5d89ab95b62..c6606dcc4a4 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.de.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.de.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Ziel net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Ziel net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Legt „langVersion“ in der erstellten Projektdatei fest", "symbols/langVersion/displayName": "Sprachversion", "symbols/skipRestore/description": "Wenn angegeben, wird die automatische Wiederherstellung des Projekts beim Erstellen übersprungen.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.en.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.en.json index 6cb55d60109..ec386d24217 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.en.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.en.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Target net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Sets langVersion in the created project file", "symbols/langVersion/displayName": "Language Version", "symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.es.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.es.json index 4be7882a4f7..c3e5e0101a4 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.es.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.es.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Net8.0 de destino", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 de destino", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Establece langVersion en el archivo de proyecto creado.", "symbols/langVersion/displayName": "Versión de lenguaje", "symbols/skipRestore/description": "Si se especifica, se omite la restauración automática del proyecto durante la creación.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.fr.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.fr.json index 93948338bdc..0b134555e81 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.fr.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.fr.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Cible Net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 cible", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Définit langVersion dans le fichier projet créé", "symbols/langVersion/displayName": "Version du Langage", "symbols/skipRestore/description": "S’il est spécifié, ignore la restauration automatique du projet lors de la création.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.it.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.it.json index 0e6bc534e3b..2c7701a6e13 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.it.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.it.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Destinazione net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 di destinazione", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Imposta langVersion nel file di progetto creato", "symbols/langVersion/displayName": "Versione linguaggio", "symbols/skipRestore/description": "Se specificato, ignora il ripristino automatico del progetto durante la creazione.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.ja.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.ja.json index d43a06dbd4d..3975172dc02 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.ja.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.ja.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "ターゲット net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "ターゲット net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "作成されたプロジェクト ファイルで langVersion を設定します", "symbols/langVersion/displayName": "言語バージョン", "symbols/skipRestore/description": "指定した場合、作成時にプロジェクトの自動復元がスキップされます。", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.ko.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.ko.json index 37ecb547921..c8bab7db962 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.ko.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.ko.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "대상 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "대상 net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "만든 프로젝트 파일의 langVersion를 설정합니다", "symbols/langVersion/displayName": "언어 버전", "symbols/skipRestore/description": "지정된 경우, 프로젝트 생성 시 자동 복원을 건너뜁니다.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.pl.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.pl.json index 83880387c35..49312c5e612 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.pl.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.pl.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Docelowa platforma NET 8.0", "symbols/Framework/choices/net8.0/displayName": "NET 8.0", - "symbols/Framework/displayName": "NET 8.0", + "symbols/Framework/choices/net9.0/description": "Docelowa platforma net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Ustawia langVersion w utworzonym pliku projektu", "symbols/langVersion/displayName": "Wersja języka", "symbols/skipRestore/description": "Jeśli ta opcja jest określona, pomija automatyczne przywracanie projektu podczas tworzenia.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.pt-BR.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.pt-BR.json index fdedceb5cb6..cb396266ac3 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.pt-BR.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.pt-BR.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": ".NET 8.0 de destino", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Define a langVersion no arquivo do projeto criado", "symbols/langVersion/displayName": "Versão da Linguagem", "symbols/skipRestore/description": "Se especificado, ignora a restauração automática do projeto sendo criado.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.ru.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.ru.json index 5715d8b2aa6..52fb91e96b2 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.ru.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.ru.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Целевая net8.0", "symbols/Framework/choices/net8.0/displayName": "NET 8.0", - "symbols/Framework/displayName": "NET 8.0", + "symbols/Framework/choices/net9.0/description": "Целевая среда net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Задает свойство langVersion в созданном файле проекта", "symbols/langVersion/displayName": "Версия языка", "symbols/skipRestore/description": "Если установлено, автоматическое восстановление проекта при создании пропускается.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.tr.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.tr.json index 4e5882555c3..e0c5bf8d5a2 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.tr.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.tr.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Hedef net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Hedef net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Oluşturulan proje dosyasında langVersion'ı ayarlar", "symbols/langVersion/displayName": "Dil Sürümü", "symbols/skipRestore/description": "Belirtilmişse, oluşturulmakta olan projenin otomatik geri yüklenmesini atlar.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hans.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hans.json index 8c6348e6e11..8362bc24103 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hans.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hans.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "目标 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "目标 net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "在创建的项目文件中设置 langVersion", "symbols/langVersion/displayName": "语言版本", "symbols/skipRestore/description": "如果指定,则在创建时跳过项目的自动还原。", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hant.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hant.json index a2ae2448e4d..40f71dc2ce8 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hant.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hant.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "目標 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "目標 net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "在建立的專案檔中設定 langVersion", "symbols/langVersion/displayName": "語言版本", "symbols/skipRestore/description": "若指定,會在建立時跳過專案的自動還原。", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/template.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/template.json index 3ffce7f9077..fe7bdf9d65d 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/template.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-VisualBasic/.template.config/template.json @@ -6,8 +6,8 @@ "generatorVersions": "[1.0.0.0-*)", "description": "A project template for creating a control library that targets .NET Windows Forms (WinForms).", "groupIdentity": "Microsoft.Common.WinForms.ControlLibrary", - "precedence": "8000", - "identity": "Microsoft.Common.WinForms.ControlLibrary.VisualBasic.8.0", + "precedence": "9000", + "identity": "Microsoft.Common.WinForms.ControlLibrary.VisualBasic.9.0", "shortName": "winformscontrollib", "tags": { "language": "VB", @@ -53,11 +53,16 @@ "choice": "net8.0", "description": "Target net8.0", "displayName": ".NET 8.0" + }, + { + "choice": "net9.0", + "description": "Target net9.0", + "displayName": ".NET 9.0" } ], "replaces": "FrameworkParameter", - "defaultValue": "net8.0", - "displayName": ".NET 8.0" + "defaultValue": "net9.0", + "displayName": ".NET 9.0" }, "UseWindowsDesktopSdk": { "type": "computed", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.cs.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.cs.json index 96090a4437b..317d0401fa2 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.cs.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.cs.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Target net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Nastaví langVersion ve vytvořeném souboru projektu.", "symbols/langVersion/displayName": "Verze jazyka", "symbols/skipRestore/description": "Pokud se tato možnost zadá, přeskočí automatické obnovení projektu při vytvoření.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.de.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.de.json index 724a7cd82ca..f762ea8cf33 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.de.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.de.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Ziel net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Ziel net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Legt „langVersion“ in der erstellten Projektdatei fest", "symbols/langVersion/displayName": "Sprachversion", "symbols/skipRestore/description": "Wenn angegeben, wird die automatische Wiederherstellung des Projekts beim Erstellen übersprungen.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.en.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.en.json index 66eb2533651..e2baa55cb16 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.en.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.en.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Target net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Sets langVersion in the created project file", "symbols/langVersion/displayName": "Language Version", "symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.es.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.es.json index 6126c0b433a..7ef244c244d 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.es.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.es.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Net8.0 de destino", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 de destino", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Establece langVersion en el archivo de proyecto creado.", "symbols/langVersion/displayName": "Versión de lenguaje", "symbols/skipRestore/description": "Si se especifica, se omite la restauración automática del proyecto durante la creación.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.fr.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.fr.json index 2b8dcd54499..547629a11a9 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.fr.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.fr.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Cible Net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 cible", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Définit langVersion dans le fichier projet créé", "symbols/langVersion/displayName": "Version du Langage", "symbols/skipRestore/description": "S’il est spécifié, ignore la restauration automatique du projet lors de la création.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.it.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.it.json index d049caeedd2..ecd8a695814 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.it.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.it.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Destinazione net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 di destinazione", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Imposta langVersion nel file di progetto creato", "symbols/langVersion/displayName": "Versione linguaggio", "symbols/skipRestore/description": "Se specificato, ignora il ripristino automatico del progetto durante la creazione.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.ja.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.ja.json index c4e885f5c23..98c1cfda941 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.ja.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.ja.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "ターゲット net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "ターゲット net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "作成されたプロジェクト ファイルで langVersion を設定します", "symbols/langVersion/displayName": "言語バージョン", "symbols/skipRestore/description": "指定した場合、作成時にプロジェクトの自動復元がスキップされます。", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.ko.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.ko.json index 2ad236e1bde..8d8a124f869 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.ko.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.ko.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "대상 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "만든 프로젝트 파일의 langVersion를 설정합니다", "symbols/langVersion/displayName": "언어 버전", "symbols/skipRestore/description": "지정된 경우, 프로젝트 생성 시 자동 복원을 건너뜁니다.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.pl.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.pl.json index c97177f5d2c..2bab28375ad 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.pl.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.pl.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Docelowa platforma NET 8.0", "symbols/Framework/choices/net8.0/displayName": "NET 8.0", - "symbols/Framework/displayName": "NET 8.0", + "symbols/Framework/choices/net9.0/description": "Docelowa platforma net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Ustawia langVersion w utworzonym pliku projektu", "symbols/langVersion/displayName": "Wersja języka", "symbols/skipRestore/description": "Jeśli ta opcja jest określona, pomija automatyczne przywracanie projektu podczas tworzenia.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.pt-BR.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.pt-BR.json index c5a0d7a239e..299f5724164 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.pt-BR.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.pt-BR.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": ".NET 8.0 de destino", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Define a langVersion no arquivo do projeto criado", "symbols/langVersion/displayName": "Versão da Linguagem", "symbols/skipRestore/description": "Se especificado, ignora a restauração automática do projeto sendo criado.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.ru.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.ru.json index 396cf4f998a..509d013e251 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.ru.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.ru.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Целевая net8.0", "symbols/Framework/choices/net8.0/displayName": "NET 8.0", - "symbols/Framework/displayName": "NET 8.0", + "symbols/Framework/choices/net9.0/description": "Целевая среда net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Задает свойство langVersion в созданном файле проекта", "symbols/langVersion/displayName": "Версия языка", "symbols/skipRestore/description": "Если установлено, автоматическое восстановление проекта при создании пропускается.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.tr.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.tr.json index 5da670b6dcb..9c6d1ff92e4 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.tr.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.tr.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Hedef net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Hedef net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Oluşturulan proje dosyasında langVersion'ı ayarlar", "symbols/langVersion/displayName": "Dil Sürümü", "symbols/skipRestore/description": "Belirtilmişse, oluşturulmakta olan projenin otomatik geri yüklenmesini atlar.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.zh-Hans.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.zh-Hans.json index 0eeb2d3f581..480a2abebcf 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.zh-Hans.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.zh-Hans.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "目标 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "目标 net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "在创建的项目文件中设置 langVersion", "symbols/langVersion/displayName": "语言版本", "symbols/skipRestore/description": "如果指定,则在创建时跳过项目的自动还原。", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.zh-Hant.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.zh-Hant.json index a9eaa765de8..4274f8fa99f 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.zh-Hant.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/localize/templatestrings.zh-Hant.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "目標 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "目標 net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "在建立的專案檔中設定 langVersion", "symbols/langVersion/displayName": "語言版本", "symbols/skipRestore/description": "若指定,會在建立時跳過專案的自動還原。", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/template.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/template.json index 23e907023df..8710df17c2f 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/template.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/template.json @@ -6,8 +6,8 @@ "generatorVersions": "[1.0.0.0-*)", "description": "A project template for creating a class library that targets .NET Windows Forms (WinForms).", "groupIdentity": "Microsoft.Common.WinForms.Library", - "precedence": "8000", - "identity": "Microsoft.Common.WinForms.Library.CSharp.8.0", + "precedence": "9000", + "identity": "Microsoft.Common.WinForms.Library.CSharp.9.0", "shortName": "winformslib", "tags": { "language": "C#", @@ -53,11 +53,16 @@ "choice": "net8.0", "description": "Target net8.0", "displayName": ".NET 8.0" + }, + { + "choice": "net9.0", + "description": "Target net9.0", + "displayName": ".NET 9.0" } ], "replaces": "FrameworkParameter", - "defaultValue": "net8.0", - "displayName": ".NET 8.0" + "defaultValue": "net9.0", + "displayName": ".NET 9.0" }, "langVersion": { "type": "parameter", @@ -100,11 +105,11 @@ }, "csharpFeature_ImplicitUsings": { "type": "computed", - "value": "(Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\") && csharp10orLater == \"true\"" + "value": "(Framework == \"net9.0\" || Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\") && csharp10orLater == \"true\"" }, "csharpFeature_FileScopedNamespaces": { "type": "computed", - "value": "(Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\" || langVersion != \"\") && csharp10orLater == \"true\"" + "value": "(Framework == \"net9.0\" || Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\" || langVersion != \"\") && csharp10orLater == \"true\"" } }, "primaryOutputs": [ @@ -126,7 +131,7 @@ "target": "./" }, { - "condition": "(Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\")", + "condition": "(Framework == \"net9.0\" || Framework == \"net8.0\" || Framework == \"net7.0\" || Framework == \"net6.0\")", "source": "./net6.0", "target": "./" } diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.cs.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.cs.json index 9d82c4e710c..f3cfa6e7d9b 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.cs.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.cs.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Target net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Nastaví langVersion ve vytvořeném souboru projektu.", "symbols/langVersion/displayName": "Verze jazyka", "symbols/skipRestore/description": "Pokud se tato možnost zadá, přeskočí automatické obnovení projektu při vytvoření.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.de.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.de.json index e27828a85f5..dba508e39f0 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.de.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.de.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Ziel net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Ziel net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Legt „langVersion“ in der erstellten Projektdatei fest", "symbols/langVersion/displayName": "Sprachversion", "symbols/skipRestore/description": "Wenn angegeben, wird die automatische Wiederherstellung des Projekts beim Erstellen übersprungen.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.en.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.en.json index 874ef954ce5..fc885d63c14 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.en.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.en.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Target net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Sets langVersion in the created project file", "symbols/langVersion/displayName": "Language Version", "symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.es.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.es.json index 96d70a10dae..e68173d5335 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.es.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.es.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Net8.0 de destino", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 de destino", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Establece langVersion en el archivo de proyecto creado.", "symbols/langVersion/displayName": "Versión de lenguaje", "symbols/skipRestore/description": "Si se especifica, se omite la restauración automática del proyecto durante la creación.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.fr.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.fr.json index d6d109eab9f..afda2f8797c 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.fr.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.fr.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Cible Net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 cible", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Définit langVersion dans le fichier projet créé", "symbols/langVersion/displayName": "Version du Langage", "symbols/skipRestore/description": "S’il est spécifié, ignore la restauration automatique du projet lors de la création.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.it.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.it.json index ce91f9f1d6d..cb876bd1a09 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.it.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.it.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Destinazione net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Net9.0 di destinazione", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Imposta langVersion nel file di progetto creato", "symbols/langVersion/displayName": "Versione linguaggio", "symbols/skipRestore/description": "Se specificato, ignora il ripristino automatico del progetto durante la creazione.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.ja.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.ja.json index 61c36cb4602..33faa154cff 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.ja.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.ja.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "ターゲット net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "ターゲット net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "作成されたプロジェクト ファイルで langVersion を設定します", "symbols/langVersion/displayName": "言語バージョン", "symbols/skipRestore/description": "指定した場合、作成時にプロジェクトの自動復元がスキップされます。", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.ko.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.ko.json index 50d7c3107ca..286b4a802b5 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.ko.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.ko.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "대상 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "대상 net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "만든 프로젝트 파일의 langVersion를 설정합니다", "symbols/langVersion/displayName": "언어 버전", "symbols/skipRestore/description": "지정된 경우, 프로젝트 생성 시 자동 복원을 건너뜁니다.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.pl.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.pl.json index 38e572347a9..c24bbb01d83 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.pl.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.pl.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Docelowa platforma NET 8.0", "symbols/Framework/choices/net8.0/displayName": "NET 8.0", - "symbols/Framework/displayName": "NET 8.0", + "symbols/Framework/choices/net9.0/description": "Docelowa platforma net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Ustawia langVersion w utworzonym pliku projektu", "symbols/langVersion/displayName": "Wersja języka", "symbols/skipRestore/description": "Jeśli ta opcja jest określona, pomija automatyczne przywracanie projektu podczas tworzenia.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.pt-BR.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.pt-BR.json index f38f4c97800..b13830f8ef6 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.pt-BR.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.pt-BR.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": ".NET 8.0 de destino", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Define a langVersion no arquivo do projeto criado", "symbols/langVersion/displayName": "Versão da Linguagem", "symbols/skipRestore/description": "Se especificado, ignora a restauração automática do projeto sendo criado.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.ru.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.ru.json index 7d732f0da64..61ef4ac6efd 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.ru.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.ru.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Целевая net8.0", "symbols/Framework/choices/net8.0/displayName": "NET 8.0", - "symbols/Framework/displayName": "NET 8.0", + "symbols/Framework/choices/net9.0/description": "Целевая среда net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Задает свойство langVersion в созданном файле проекта", "symbols/langVersion/displayName": "Версия языка", "symbols/skipRestore/description": "Если установлено, автоматическое восстановление проекта при создании пропускается.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.tr.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.tr.json index 3bed6a482c4..a2dd47bea63 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.tr.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.tr.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "Hedef net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "Hedef net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "Oluşturulan proje dosyasında langVersion'ı ayarlar", "symbols/langVersion/displayName": "Dil Sürümü", "symbols/skipRestore/description": "Belirtilmişse, oluşturulmakta olan projenin otomatik geri yüklenmesini atlar.", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hans.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hans.json index fefbde1aab6..bf19877d19e 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hans.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hans.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "目标 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "目标 net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "在创建的项目文件中设置 langVersion", "symbols/langVersion/displayName": "语言版本", "symbols/skipRestore/description": "如果指定,则在创建时跳过项目的自动还原。", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hant.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hant.json index 7936498d80f..2a91ccf4957 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hant.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/localize/templatestrings.zh-Hant.json @@ -15,7 +15,9 @@ "symbols/Framework/choices/net7.0/displayName": ".NET 7.0", "symbols/Framework/choices/net8.0/description": "目標 net8.0", "symbols/Framework/choices/net8.0/displayName": ".NET 8.0", - "symbols/Framework/displayName": ".NET 8.0", + "symbols/Framework/choices/net9.0/description": "目標 net9.0", + "symbols/Framework/choices/net9.0/displayName": ".NET 9.0", + "symbols/Framework/displayName": ".NET 9.0", "symbols/langVersion/description": "在建立的專案檔中設定 langVersion", "symbols/langVersion/displayName": "語言版本", "symbols/skipRestore/description": "若指定,會在建立時跳過專案的自動還原。", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/template.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/template.json index d03b83ab050..0c98781c89d 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/template.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-VisualBasic/.template.config/template.json @@ -6,8 +6,8 @@ "generatorVersions": "[1.0.0.0-*)", "description": "A project template for creating a class library that targets .NET Windows Forms (WinForms).", "groupIdentity": "Microsoft.Common.WinForms.Library", - "precedence": "8000", - "identity": "Microsoft.Common.WinForms.Library.VisualBasic.8.0", + "precedence": "9000", + "identity": "Microsoft.Common.WinForms.Library.VisualBasic.9.0", "shortName": "winformslib", "tags": { "language": "VB", @@ -53,11 +53,16 @@ "choice": "net8.0", "description": "Target net8.0", "displayName": ".NET 8.0" + }, + { + "choice": "net9.0", + "description": "Target net9.0", + "displayName": ".NET 9.0" } ], "replaces": "FrameworkParameter", - "defaultValue": "net8.0", - "displayName": ".NET 8.0" + "defaultValue": "net9.0", + "displayName": ".NET 9.0" }, "UseWindowsDesktopSdk": { "type": "computed", diff --git a/src/Common/src/IComparerHelpers.cs b/src/Common/src/IComparerHelpers.cs index 29d7cc6dcd4..2c195bafcca 100644 --- a/src/Common/src/IComparerHelpers.cs +++ b/src/Common/src/IComparerHelpers.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System; diff --git a/src/Common/src/RTLAwareMessageBox.cs b/src/Common/src/RTLAwareMessageBox.cs index 5f52485ca7b..954dca38193 100644 --- a/src/Common/src/RTLAwareMessageBox.cs +++ b/src/Common/src/RTLAwareMessageBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/Common/tests/TestUtilities/AppContextSwitchNames.cs b/src/Common/tests/TestUtilities/AppContextSwitchNames.cs index 61213f90b05..cfff428ac46 100644 --- a/src/Common/tests/TestUtilities/AppContextSwitchNames.cs +++ b/src/Common/tests/TestUtilities/AppContextSwitchNames.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.Serialization.Formatters.Binary; diff --git a/src/Common/tests/TestUtilities/AppContextSwitchScope.cs b/src/Common/tests/TestUtilities/AppContextSwitchScope.cs index 413829ecfa6..ff771db020b 100644 --- a/src/Common/tests/TestUtilities/AppContextSwitchScope.cs +++ b/src/Common/tests/TestUtilities/AppContextSwitchScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System; diff --git a/src/Common/tests/TestUtilities/BinaryFormatterScope.cs b/src/Common/tests/TestUtilities/BinaryFormatterScope.cs index fe84f89b1d3..ba22e532693 100644 --- a/src/Common/tests/TestUtilities/BinaryFormatterScope.cs +++ b/src/Common/tests/TestUtilities/BinaryFormatterScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.Serialization.Formatters.Binary; diff --git a/src/Common/tests/TestUtilities/BinarySerialization.cs b/src/Common/tests/TestUtilities/BinarySerialization.cs index b247568b0b8..02e2e5a3a20 100644 --- a/src/Common/tests/TestUtilities/BinarySerialization.cs +++ b/src/Common/tests/TestUtilities/BinarySerialization.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; using System.Runtime.CompilerServices; @@ -69,13 +68,13 @@ static object FromByteArray(byte[] raw, FormatterAssemblyStyle assemblyStyle = FormatterAssemblyStyle.Simple) { #pragma warning disable SYSLIB0011 // Type or member is obsolete - var binaryFormatter = new BinaryFormatter + BinaryFormatter binaryFormatter = new() { AssemblyFormat = assemblyStyle }; #pragma warning restore SYSLIB0011 // Type or member is obsolete - using var serializedStream = new MemoryStream(raw); + using MemoryStream serializedStream = new(raw); return binaryFormatter.Deserialize(serializedStream); } } @@ -90,15 +89,15 @@ static byte[] ToByteArray(object obj, FormatterAssemblyStyle assemblyStyle = FormatterAssemblyStyle.Simple) { #pragma warning disable SYSLIB0011 // Type or member is obsolete - var binaryFormatter = new BinaryFormatter + BinaryFormatter binaryFormatter = new() { AssemblyFormat = assemblyStyle }; #pragma warning restore SYSLIB0011 // Type or member is obsolete - using var ms = new MemoryStream(); - binaryFormatter.Serialize(ms, obj); - return ms.ToArray(); + using MemoryStream stream = new(); + binaryFormatter.Serialize(stream, obj); + return stream.ToArray(); } } #pragma warning restore SYSLIB0050 // Type or member is obsolete diff --git a/src/Common/tests/TestUtilities/CommonTestHelper.cs b/src/Common/tests/TestUtilities/CommonTestHelper.cs index 5f6e4d210ee..a70c320a385 100644 --- a/src/Common/tests/TestUtilities/CommonTestHelper.cs +++ b/src/Common/tests/TestUtilities/CommonTestHelper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design.Serialization; using System.Drawing; diff --git a/src/Common/tests/TestUtilities/ComparisonHelpers.cs b/src/Common/tests/TestUtilities/ComparisonHelpers.cs index d7e54e94b60..a80634fa30d 100644 --- a/src/Common/tests/TestUtilities/ComparisonHelpers.cs +++ b/src/Common/tests/TestUtilities/ComparisonHelpers.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Numerics; @@ -11,10 +10,7 @@ public static class ComparisonHelpers public static bool EqualsInteger(T x, T y, T variance) where T : struct, IBinaryInteger { - if (variance < T.Zero) - { - throw new ArgumentOutOfRangeException(nameof(variance)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(variance, T.Zero); return T.Abs(x > y ? x - y : y - x) <= variance; } @@ -22,10 +18,7 @@ public static bool EqualsInteger(T x, T y, T variance) public static bool EqualsFloating(T x, T y, T variance) where T : struct, IFloatingPoint { - if (variance < T.Zero) - { - throw new ArgumentOutOfRangeException(nameof(variance)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(variance, T.Zero); if (T.IsNaN(x)) { diff --git a/src/Common/tests/TestUtilities/CustomConverter.cs b/src/Common/tests/TestUtilities/CustomConverter.cs index cace9dd02b2..aa71a40908d 100644 --- a/src/Common/tests/TestUtilities/CustomConverter.cs +++ b/src/Common/tests/TestUtilities/CustomConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/Common/tests/TestUtilities/DebuggerAttributes.cs b/src/Common/tests/TestUtilities/DebuggerAttributes.cs index e1c1c465835..fcfd25b495f 100644 --- a/src/Common/tests/TestUtilities/DebuggerAttributes.cs +++ b/src/Common/tests/TestUtilities/DebuggerAttributes.cs @@ -140,7 +140,7 @@ internal static string ValidateDebuggerDisplayReferences(object obj) throw new InvalidOperationException($"The DebuggerDisplayAttribute for {objType} doesn't reference any expressions."); } - var sb = new StringBuilder(); + StringBuilder sb = new(); for (int i = 0; i < segments.Length; i += 2) { diff --git a/src/Common/tests/TestUtilities/FileCleanupTestBase.cs b/src/Common/tests/TestUtilities/FileCleanupTestBase.cs index a637557b43a..1dfb32d0278 100644 --- a/src/Common/tests/TestUtilities/FileCleanupTestBase.cs +++ b/src/Common/tests/TestUtilities/FileCleanupTestBase.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System; diff --git a/src/Common/tests/TestUtilities/GlobalUsings.cs b/src/Common/tests/TestUtilities/GlobalUsings.cs index e6d52b53fa7..581f24df927 100644 --- a/src/Common/tests/TestUtilities/GlobalUsings.cs +++ b/src/Common/tests/TestUtilities/GlobalUsings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. global using System.Diagnostics.CodeAnalysis; global using Xunit; diff --git a/src/Common/tests/TestUtilities/ITestAccessor.cs b/src/Common/tests/TestUtilities/ITestAccessor.cs index c01ec1d8e3c..d9f706c29e6 100644 --- a/src/Common/tests/TestUtilities/ITestAccessor.cs +++ b/src/Common/tests/TestUtilities/ITestAccessor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System; diff --git a/src/Common/tests/TestUtilities/ModuleInitializer.cs b/src/Common/tests/TestUtilities/ModuleInitializer.cs index dbd8f999cb2..2cb757018d6 100644 --- a/src/Common/tests/TestUtilities/ModuleInitializer.cs +++ b/src/Common/tests/TestUtilities/ModuleInitializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Diagnostics; using System.Runtime.CompilerServices; diff --git a/src/Common/tests/TestUtilities/ReflectionHelper.cs b/src/Common/tests/TestUtilities/ReflectionHelper.cs index 722533b0456..f5395289855 100644 --- a/src/Common/tests/TestUtilities/ReflectionHelper.cs +++ b/src/Common/tests/TestUtilities/ReflectionHelper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; diff --git a/src/Common/tests/TestUtilities/TempFile.cs b/src/Common/tests/TestUtilities/TempFile.cs index cf5b9bef97d..1a0d0cfa2e5 100644 --- a/src/Common/tests/TestUtilities/TempFile.cs +++ b/src/Common/tests/TestUtilities/TempFile.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/Common/tests/TestUtilities/TestAccessor.cs b/src/Common/tests/TestUtilities/TestAccessor.cs index da89f9021eb..e5a91cd1982 100644 --- a/src/Common/tests/TestUtilities/TestAccessor.cs +++ b/src/Common/tests/TestUtilities/TestAccessor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Dynamic; using System.Reflection; diff --git a/src/Common/tests/TestUtilities/TestAccessors.cs b/src/Common/tests/TestUtilities/TestAccessors.cs index 25386ec0257..50250220628 100644 --- a/src/Common/tests/TestUtilities/TestAccessors.cs +++ b/src/Common/tests/TestUtilities/TestAccessors.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System; diff --git a/src/Common/tests/TestUtilities/TestIncludeType.cs b/src/Common/tests/TestUtilities/TestIncludeType.cs index b5571f9d9fa..f65421e8124 100644 --- a/src/Common/tests/TestUtilities/TestIncludeType.cs +++ b/src/Common/tests/TestUtilities/TestIncludeType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.TestUtilities; diff --git a/src/Common/tests/TestUtilities/ThrowingTraceListener.cs b/src/Common/tests/TestUtilities/ThrowingTraceListener.cs index b2c53a4a5ac..f85b1a03788 100644 --- a/src/Common/tests/TestUtilities/ThrowingTraceListener.cs +++ b/src/Common/tests/TestUtilities/ThrowingTraceListener.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Diagnostics; diff --git a/src/Common/tests/TestUtilities/XUnit/BoolDataAttribute.cs b/src/Common/tests/TestUtilities/XUnit/BoolDataAttribute.cs index e0cbf73e9ad..fe5f3e085e8 100644 --- a/src/Common/tests/TestUtilities/XUnit/BoolDataAttribute.cs +++ b/src/Common/tests/TestUtilities/XUnit/BoolDataAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Xunit; diff --git a/src/Common/tests/TestUtilities/XUnit/CommonMemberDataAttribute.cs b/src/Common/tests/TestUtilities/XUnit/CommonMemberDataAttribute.cs index 7020aaef9af..953f4837f4a 100644 --- a/src/Common/tests/TestUtilities/XUnit/CommonMemberDataAttribute.cs +++ b/src/Common/tests/TestUtilities/XUnit/CommonMemberDataAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; diff --git a/src/Common/tests/TestUtilities/XUnit/EnumDataAttribute.cs b/src/Common/tests/TestUtilities/XUnit/EnumDataAttribute.cs index 65c568dcb65..a7658589eff 100644 --- a/src/Common/tests/TestUtilities/XUnit/EnumDataAttribute.cs +++ b/src/Common/tests/TestUtilities/XUnit/EnumDataAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Xunit; diff --git a/src/Common/tests/TestUtilities/XUnit/FloatingPointDataAttribute.cs b/src/Common/tests/TestUtilities/XUnit/FloatingPointDataAttribute.cs index a0941b1ff5f..bace832f5d1 100644 --- a/src/Common/tests/TestUtilities/XUnit/FloatingPointDataAttribute.cs +++ b/src/Common/tests/TestUtilities/XUnit/FloatingPointDataAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Numerics; diff --git a/src/Common/tests/TestUtilities/XUnit/FloatingPointToleranceComparerer.cs b/src/Common/tests/TestUtilities/XUnit/FloatingPointToleranceComparerer.cs index afa6d77595d..520a0c7d18e 100644 --- a/src/Common/tests/TestUtilities/XUnit/FloatingPointToleranceComparerer.cs +++ b/src/Common/tests/TestUtilities/XUnit/FloatingPointToleranceComparerer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Numerics; diff --git a/src/Common/tests/TestUtilities/XUnit/IntegerDataAttribute.cs b/src/Common/tests/TestUtilities/XUnit/IntegerDataAttribute.cs index d39952ac2fc..2c3a4d0d54b 100644 --- a/src/Common/tests/TestUtilities/XUnit/IntegerDataAttribute.cs +++ b/src/Common/tests/TestUtilities/XUnit/IntegerDataAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Numerics; diff --git a/src/Common/tests/TestUtilities/XUnit/InvalidEnumDataAttribute.cs b/src/Common/tests/TestUtilities/XUnit/InvalidEnumDataAttribute.cs index 7171d4b9e25..e382fb92680 100644 --- a/src/Common/tests/TestUtilities/XUnit/InvalidEnumDataAttribute.cs +++ b/src/Common/tests/TestUtilities/XUnit/InvalidEnumDataAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; using System.Runtime.CompilerServices; diff --git a/src/Common/tests/TestUtilities/XUnit/NewAndDefaultDataAttribute.cs b/src/Common/tests/TestUtilities/XUnit/NewAndDefaultDataAttribute.cs index 68b22355e85..cec932e0059 100644 --- a/src/Common/tests/TestUtilities/XUnit/NewAndDefaultDataAttribute.cs +++ b/src/Common/tests/TestUtilities/XUnit/NewAndDefaultDataAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Xunit; diff --git a/src/Common/tests/TestUtilities/XUnit/NormalizedStringDataAttribute.cs b/src/Common/tests/TestUtilities/XUnit/NormalizedStringDataAttribute.cs index 0294332c198..46526385344 100644 --- a/src/Common/tests/TestUtilities/XUnit/NormalizedStringDataAttribute.cs +++ b/src/Common/tests/TestUtilities/XUnit/NormalizedStringDataAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Xunit; diff --git a/src/Common/tests/TestUtilities/XUnit/NullAndEmptyStringDataAttribute.cs b/src/Common/tests/TestUtilities/XUnit/NullAndEmptyStringDataAttribute.cs index 5d016771077..866f289af99 100644 --- a/src/Common/tests/TestUtilities/XUnit/NullAndEmptyStringDataAttribute.cs +++ b/src/Common/tests/TestUtilities/XUnit/NullAndEmptyStringDataAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Xunit; diff --git a/src/Common/tests/TestUtilities/XUnit/PositiveNumberDataAttribute.cs b/src/Common/tests/TestUtilities/XUnit/PositiveNumberDataAttribute.cs index c6bc0b34806..0214e957a8c 100644 --- a/src/Common/tests/TestUtilities/XUnit/PositiveNumberDataAttribute.cs +++ b/src/Common/tests/TestUtilities/XUnit/PositiveNumberDataAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Numerics; diff --git a/src/Common/tests/TestUtilities/XUnit/ReadOnlyTheoryData.cs b/src/Common/tests/TestUtilities/XUnit/ReadOnlyTheoryData.cs index d7aff821790..52365efabde 100644 --- a/src/Common/tests/TestUtilities/XUnit/ReadOnlyTheoryData.cs +++ b/src/Common/tests/TestUtilities/XUnit/ReadOnlyTheoryData.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/Common/tests/TestUtilities/XUnit/SkipOnArchitectureAttribute.cs b/src/Common/tests/TestUtilities/XUnit/SkipOnArchitectureAttribute.cs index bbd6cbc948f..415907fe649 100644 --- a/src/Common/tests/TestUtilities/XUnit/SkipOnArchitectureAttribute.cs +++ b/src/Common/tests/TestUtilities/XUnit/SkipOnArchitectureAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Xunit.Sdk; diff --git a/src/Common/tests/TestUtilities/XUnit/SkipOnArchitectureDiscoverer.cs b/src/Common/tests/TestUtilities/XUnit/SkipOnArchitectureDiscoverer.cs index fe5e5a6e5c5..9b395d7f916 100644 --- a/src/Common/tests/TestUtilities/XUnit/SkipOnArchitectureDiscoverer.cs +++ b/src/Common/tests/TestUtilities/XUnit/SkipOnArchitectureDiscoverer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Microsoft.DotNet.XUnitExtensions; diff --git a/src/Common/tests/TestUtilities/XUnit/StringDataAttribute.cs b/src/Common/tests/TestUtilities/XUnit/StringDataAttribute.cs index 8b1ba4ab0d6..55b91582a22 100644 --- a/src/Common/tests/TestUtilities/XUnit/StringDataAttribute.cs +++ b/src/Common/tests/TestUtilities/XUnit/StringDataAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Xunit; diff --git a/src/Common/tests/TestUtilities/XUnit/StringWithNullDataAttribute.cs b/src/Common/tests/TestUtilities/XUnit/StringWithNullDataAttribute.cs index 9ac7f3b3fa4..90933b49959 100644 --- a/src/Common/tests/TestUtilities/XUnit/StringWithNullDataAttribute.cs +++ b/src/Common/tests/TestUtilities/XUnit/StringWithNullDataAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Xunit; diff --git a/src/Common/tests/TestUtilities/XUnit/TestArchitectures.cs b/src/Common/tests/TestUtilities/XUnit/TestArchitectures.cs index 8fb548eccb2..4b89411a692 100644 --- a/src/Common/tests/TestUtilities/XUnit/TestArchitectures.cs +++ b/src/Common/tests/TestUtilities/XUnit/TestArchitectures.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Xunit; diff --git a/src/Common/tests/TestUtilities/XUnit/TestData.cs b/src/Common/tests/TestUtilities/XUnit/TestData.cs index d313b2506f2..30cf86dd4fb 100644 --- a/src/Common/tests/TestUtilities/XUnit/TestData.cs +++ b/src/Common/tests/TestUtilities/XUnit/TestData.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Immutable; using System.Numerics; diff --git a/src/Common/tests/TestUtilities/XUnit/UseCultureAttribute.cs b/src/Common/tests/TestUtilities/XUnit/UseCultureAttribute.cs index 07ca9f810ba..99509da412b 100644 --- a/src/Common/tests/TestUtilities/XUnit/UseCultureAttribute.cs +++ b/src/Common/tests/TestUtilities/XUnit/UseCultureAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. // The original code was borrowed from https://github.com/xunit/samples.xunit/blob/93f87d5/UseCulture/UseCultureAttribute.cs // Licensed under http://www.apache.org/licenses/LICENSE-2.0. diff --git a/src/Common/tests/TestUtilities/XUnit/UseDefaultXunitCultureAttribute.cs b/src/Common/tests/TestUtilities/XUnit/UseDefaultXunitCultureAttribute.cs index 96f20378212..bd89f93dc46 100644 --- a/src/Common/tests/TestUtilities/XUnit/UseDefaultXunitCultureAttribute.cs +++ b/src/Common/tests/TestUtilities/XUnit/UseDefaultXunitCultureAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/ApplicationBase.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/ApplicationBase.vb index 41806fad7f5..3ca6a80b3f3 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/ApplicationBase.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/ApplicationBase.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/ApplyApplicationDefaultsEventArgs.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/ApplyApplicationDefaultsEventArgs.vb index 3a2f3123f14..cb198ad556f 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/ApplyApplicationDefaultsEventArgs.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/ApplyApplicationDefaultsEventArgs.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/AssemblyInfo.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/AssemblyInfo.vb index 156a97733fc..faa2a2ed6c2 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/AssemblyInfo.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/AssemblyInfo.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/CantStartSingleInstanceException.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/CantStartSingleInstanceException.vb index bb3fc321758..f6a9d71e011 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/CantStartSingleInstanceException.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/CantStartSingleInstanceException.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/ConsoleApplicationBase.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/ConsoleApplicationBase.vb index e7475e13edd..e438449ab72 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/ConsoleApplicationBase.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/ConsoleApplicationBase.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/NoStartupFormException.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/NoStartupFormException.vb index 5a2d1a9a8b5..967c9c805c7 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/NoStartupFormException.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/NoStartupFormException.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb index 5800e98282f..2e9ad84e522 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/StartupEventArgs.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/StartupEventArgs.vb index e649ee2901b..1520b75763e 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/StartupEventArgs.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/StartupEventArgs.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/StartupNextInstanceEventArgs.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/StartupNextInstanceEventArgs.vb index 79174da4e7e..fc1f473fb1d 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/StartupNextInstanceEventArgs.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/StartupNextInstanceEventArgs.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/UnhandledExceptionEventArgs.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/UnhandledExceptionEventArgs.vb index 4ca32a88be2..efbf9f7eac3 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/UnhandledExceptionEventArgs.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/UnhandledExceptionEventArgs.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/User.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/User.vb index f0899b2a52a..99acb320540 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/User.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/User.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Explicit On Option Strict On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBase.WinFormsAppContext.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBase.WinFormsAppContext.vb index 6d860a91c1b..75cdbcfee4b 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBase.WinFormsAppContext.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBase.WinFormsAppContext.vb @@ -3,7 +3,6 @@ Option Explicit On Option Infer On ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Imports System.Security Imports System.Windows.Forms diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBase.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBase.vb index 801e326b231..d33cfb1fae5 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBase.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBase.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On @@ -910,17 +909,25 @@ Namespace Microsoft.VisualBasic.ApplicationServices Dim invoked = False Try - AsyncOperationManager. - SynchronizationContext. - Send( - Sub() - invoked = True - - OnStartupNextInstance( - New StartupNextInstanceEventArgs( - New ReadOnlyCollection(Of String)(args), - bringToForegroundFlag:=True)) - End Sub, Nothing) + Dim handleNextInstance As New Action( + Sub() + invoked = True + OnStartupNextInstance(New StartupNextInstanceEventArgs( + New ReadOnlyCollection(Of String)(args), + bringToForegroundFlag:=True)) + End Sub) + + ' If we have a Main form, we need to make sure that we are on _its_ UI thread + ' before we call OnStartupNextInstance. + If MainForm IsNot Nothing Then + MainForm.Invoke(handleNextInstance) + Else + ' Otherwise, we need to make sure that we are on the thread + ' provided by the SynchronizationContext. + AsyncOperationManager. + SynchronizationContext. + Send(Sub() handleNextInstance(), Nothing) + End If Catch ex As Exception When Not invoked ' Only catch exceptions thrown when the UI thread is not available, before diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/CompilerServices/ExceptionUtils.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/CompilerServices/ExceptionUtils.vb index 332f77de959..e54eda83619 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/CompilerServices/ExceptionUtils.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/CompilerServices/ExceptionUtils.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/CompilerServices/Utils.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/CompilerServices/Utils.vb index 3d1aebe3c85..4f4c8eeab82 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/CompilerServices/Utils.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/CompilerServices/Utils.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Imports System.Globalization diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Audio.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Audio.vb index f94a0e13e82..341112efb86 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Audio.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Audio.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Explicit On Option Strict On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Clock.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Clock.vb index 3dbb9b32791..c7ea5c6fb79 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Clock.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Clock.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Computer.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Computer.vb index c52d933178c..f4098d32bad 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Computer.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Computer.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/ComputerInfo.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/ComputerInfo.vb index c5e57945e85..775801fb383 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/ComputerInfo.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/ComputerInfo.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Imports System.Runtime.InteropServices Imports Microsoft.VisualBasic.CompilerServices diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Keyboard.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Keyboard.vb index be3e7b6f112..bb5d1689ba5 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Keyboard.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Keyboard.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Explicit On Option Strict On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Mouse.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Mouse.vb index 2483ba73129..0f3ca96b6d1 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Mouse.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Mouse.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Network.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Network.vb index 7b6ee6953cb..123d1319407 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Network.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/Network.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Explicit On Option Strict On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/ServerComputer.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/ServerComputer.vb index 93c85202862..063073676b0 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/ServerComputer.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Devices/ServerComputer.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/FileSystemUtils.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/FileSystemUtils.vb index e50e2728deb..10357a7ae66 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/FileSystemUtils.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/FileSystemUtils.vb @@ -1,6 +1,6 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. + Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/Hosting.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/Hosting.vb index aba7c7584fb..50af821b5cd 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/Hosting.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/Hosting.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Namespace Microsoft.VisualBasic.CompilerServices diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/NativeMethods.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/NativeMethods.vb index d64420c83fe..7c9780356c0 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/NativeMethods.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/NativeMethods.vb @@ -1,6 +1,6 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. + Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/NativeTypes.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/NativeTypes.vb index d854001c780..f5986f5564b 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/NativeTypes.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/NativeTypes.vb @@ -1,6 +1,6 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. + Option Explicit On Option Strict On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/SafeNativeMethods.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/SafeNativeMethods.vb index eaca50d4d2d..e9445f00f5e 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/SafeNativeMethods.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/SafeNativeMethods.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Imports System.Runtime.InteropServices diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/UnsafeNativeMethods.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/UnsafeNativeMethods.vb index 773d638cc4a..c1eee7c5e2f 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/UnsafeNativeMethods.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/UnsafeNativeMethods.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Imports System.Runtime.InteropServices diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/VBInputBox.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/VBInputBox.vb index 73a019ce728..62fb8bbb7e2 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/VBInputBox.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/VBInputBox.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Imports System.ComponentModel Imports System.Drawing diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Interaction.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Interaction.vb index bf916f7ffce..8d958ecc515 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Interaction.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Interaction.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Imports System.Runtime.InteropServices Imports System.Security diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Logging/FileLogTraceListener.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Logging/FileLogTraceListener.vb index 960d010b75d..8413e3e3bbd 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Logging/FileLogTraceListener.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Logging/FileLogTraceListener.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Explicit On Option Strict On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Logging/Log.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Logging/Log.vb index c74c73ae4f6..49ea2c047d3 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Logging/Log.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Logging/Log.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Explicit On Option Strict On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/ClipboardProxy.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/ClipboardProxy.vb index bc5ea61f503..b60616852ca 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/ClipboardProxy.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/ClipboardProxy.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Explicit On Option Strict On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb index 3ce1dfeb9a6..b4a14a98322 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/FileSystemProxy.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Strict On Option Explicit On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/Internal/ContextValue.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/Internal/ContextValue.vb index c5d926de691..8963ff68ccd 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/Internal/ContextValue.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/Internal/ContextValue.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Explicit On Option Strict On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/Internal/ProgressDialog.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/Internal/ProgressDialog.vb index 47f3a33245a..c7b97f8f532 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/Internal/ProgressDialog.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/Internal/ProgressDialog.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Explicit On Option Strict On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/Internal/WebClientCopy.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/Internal/WebClientCopy.vb index b75236d598c..539204e84a8 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/Internal/WebClientCopy.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/Internal/WebClientCopy.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Option Explicit On Option Strict On diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/RegistryProxy.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/RegistryProxy.vb index c7fbd107427..e981b1c5316 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/RegistryProxy.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/RegistryProxy.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Imports System.ComponentModel Imports Microsoft.Win32 diff --git a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb index 8ae60f73c92..a28c07a16b3 100644 --- a/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb +++ b/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxy.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Imports System.ComponentModel Imports Microsoft.VisualBasic.FileIO diff --git a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.vb b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.vb index b30fbb1ba7f..b8df093183f 100644 --- a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.vb +++ b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.vb @@ -1,6 +1,5 @@ ' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. Imports System.Windows.Forms Imports Xunit diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/GlobalUsings.cs b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/GlobalUsings.cs index a499ca8b64b..5abc35b2162 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/GlobalUsings.cs +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/GlobalUsings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. global using System.Diagnostics; global using Xunit; diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/InteractionTests.cs b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/InteractionTests.cs index a48cb8ae6b8..cb4cb2065d2 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/InteractionTests.cs +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/InteractionTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.IntegrationTests.Common; @@ -114,7 +113,7 @@ public void Shell_FileNotFoundException() private static Process StartTestProcess(string arguments) { - var startInfo = new ProcessStartInfo { FileName = _exePath, Arguments = arguments }; + ProcessStartInfo startInfo = new() { FileName = _exePath, Arguments = arguments }; return TestHelpers.StartProcess(startInfo); } diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBaseTests.cs b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBaseTests.cs index 6212bb96618..194ffecfd7a 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBaseTests.cs +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBaseTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.IntegrationTests.Common; using Microsoft.VisualBasic.ApplicationServices; @@ -13,7 +12,7 @@ public class WindowsFormsApplicationBaseTests public void Run() { string exePath = TestHelpers.GetExePath("VisualBasicRuntimeTest"); - var startInfo = new ProcessStartInfo { FileName = exePath, Arguments = "WindowsFormsApplicationBase.Run" }; + ProcessStartInfo startInfo = new() { FileName = exePath, Arguments = "WindowsFormsApplicationBase.Run" }; Process process = TestHelpers.StartProcess(startInfo); TestHelpers.EndProcess(process, timeout: 1000); Assert.True(process.HasExited); @@ -34,7 +33,7 @@ public void RunSingleInstance() [Fact] public void Run_NoStartupFormException() { - var application = new WindowsFormsApplicationBase(); + WindowsFormsApplicationBase application = new(); // Exception.ToString() called to verify message is constructed successfully. _ = Assert.Throws(() => application.Run(Array.Empty())).ToString(); } diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/MyServices/Internal/ProgressDialogTests.cs b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/MyServices/Internal/ProgressDialogTests.cs index 31d74d6abb4..3483da4641e 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/MyServices/Internal/ProgressDialogTests.cs +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/MyServices/Internal/ProgressDialogTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.IntegrationTests.Common; @@ -12,8 +11,8 @@ public class ProgressDialogTests public void ShowProgressDialog() { string exePath = TestHelpers.GetExePath("VisualBasicRuntimeTest"); - var startInfo = new ProcessStartInfo { FileName = exePath, Arguments = "ProgressDialog.ShowProgressDialog" }; - var process = TestHelpers.StartProcess(startInfo); + ProcessStartInfo startInfo = new() { FileName = exePath, Arguments = "ProgressDialog.ShowProgressDialog" }; + Process process = TestHelpers.StartProcess(startInfo); TestHelpers.EndProcess(process, timeout: 1000); Assert.True(process.HasExited); Assert.NotEqual(2, process.ExitCode); diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/Program.cs b/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/Program.cs index e5779843eef..2e299db7c69 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/Program.cs +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/Program.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Reflection; @@ -79,8 +78,8 @@ private static void Interaction_MsgBox(bool useVbHost) private static void WindowsFormsApplicationBase_Run(bool isSingleInstance, bool isFirstInstance) { - var mainForm = new Form(); - var application = new WindowsApplication(mainForm, isSingleInstance); + Form mainForm = new(); + WindowsApplication application = new(mainForm, isSingleInstance); bool valid = false; bool loaded = false; @@ -131,7 +130,7 @@ private static void ProgressDialog_ShowProgressDialog() Type dialogType = typeof(ApplicationBase).Assembly.GetType("Microsoft.VisualBasic.MyServices.Internal.ProgressDialog"); var dialog = (Form)Activator.CreateInstance(dialogType, nonPublic: true); - var resources = new ResourceManager(dialogType); + ResourceManager resources = new(dialogType); var expectedValue = (Point)resources.GetObject("ProgressBarWork.Location"); if (expectedValue == new Point(0, 0)) { @@ -155,7 +154,7 @@ private static void VBInputBox_ShowDialog() Type formType = typeof(ApplicationBase).Assembly.GetType("Microsoft.VisualBasic.CompilerServices.VBInputBox"); var form = (Form)Activator.CreateInstance(formType, nonPublic: true); - var resources = new ResourceManager(formType); + ResourceManager resources = new(formType); var expectedValue = (Point)resources.GetObject("TextBox.Location"); if (expectedValue == new Point(0, 0)) { diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/GlobalUsings.cs b/src/Microsoft.VisualBasic/tests/UnitTests/GlobalUsings.cs index a499ca8b64b..5abc35b2162 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/GlobalUsings.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/GlobalUsings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. global using System.Diagnostics; global using Xunit; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/ApplicationBaseTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/ApplicationBaseTests.cs index 3a6196a94b0..87fbe88925c 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/ApplicationBaseTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/ApplicationBaseTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualBasic.ApplicationServices.Tests; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/AssemblyInfoTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/AssemblyInfoTests.cs index 17b1f6d7ea6..133883b16c6 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/AssemblyInfoTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/AssemblyInfoTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/ConsoleApplicationBaseTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/ConsoleApplicationBaseTests.cs index e911484e9df..99e0922eecb 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/ConsoleApplicationBaseTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/ConsoleApplicationBaseTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualBasic.ApplicationServices.Tests; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/SingleInstanceTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/SingleInstanceTests.cs index 5ec2edc8973..5d19f76c2fd 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/SingleInstanceTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/SingleInstanceTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Immutable; using System.IO.Pipes; @@ -15,7 +14,7 @@ public class SingleInstanceTests private sealed class ReceivedArgs { - private List _received = new List(); + private List _received = new(); internal void Add(string[] args) { diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/StartupEventArgsTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/StartupEventArgsTests.cs index 75743112d75..5cea119d70e 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/StartupEventArgsTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/StartupEventArgsTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.ObjectModel; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/StartupNextInstanceEventArgsTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/StartupNextInstanceEventArgsTests.cs index 155dad2f6c1..833937e9d5f 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/StartupNextInstanceEventArgsTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/StartupNextInstanceEventArgsTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.ObjectModel; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/UnhandledExceptionEventArgsTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/UnhandledExceptionEventArgsTests.cs index 51cb213eec3..2ecd2d153c4 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/UnhandledExceptionEventArgsTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/UnhandledExceptionEventArgsTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualBasic.ApplicationServices.Tests; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/UserTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/UserTests.cs index a0bfa5e264e..bf143be283f 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/UserTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/UserTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualBasic.ApplicationServices.Tests; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBaseTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBaseTests.cs index e9f084b0830..368ded09eab 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBaseTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBaseTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; using System.Reflection.Emit; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/AudioTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/AudioTests.cs index a39437184cf..116a7efc5fb 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/AudioTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/AudioTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualBasic.Devices.Tests; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ClockTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ClockTests.cs index 24e5715351d..6b2be555f59 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ClockTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ClockTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualBasic.Devices.Tests; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ComputerInfoTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ComputerInfoTests.cs index 33fc6210571..2b0d7cfd049 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ComputerInfoTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ComputerInfoTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualBasic.Devices.Tests; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ComputerTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ComputerTests.cs index 5c9c55e4676..f0614cb1758 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ComputerTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ComputerTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualBasic.Devices.Tests; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/KeyboardTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/KeyboardTests.cs index d968d0e0f8b..6dde1beacef 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/KeyboardTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/KeyboardTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualBasic.Devices.Tests; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/MouseTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/MouseTests.cs index 0cdb330da8a..294c38cd441 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/MouseTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/MouseTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/NetworkAvailableEventArgsTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/NetworkAvailableEventArgsTests.cs index 80d564af417..57440a76fad 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/NetworkAvailableEventArgsTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/NetworkAvailableEventArgsTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualBasic.Devices.Tests; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/NetworkTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/NetworkTests.cs index 555868c38e9..47879b54643 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/NetworkTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/NetworkTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualBasic.Devices.Tests; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ServerComputerTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ServerComputerTests.cs index 67f973bce3b..8311b2561fd 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ServerComputerTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/ServerComputerTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualBasic.Devices.Tests; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/FileLogTraceListenerTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/FileLogTraceListenerTests.cs index f4e296196cf..54975475a41 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/FileLogTraceListenerTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/FileLogTraceListenerTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualBasic.Logging.Tests; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/LogTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/LogTests.cs index fb0bee49548..b066f6e40c8 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/LogTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Logging/LogTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualBasic.Logging.Tests; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/ClipboardProxyTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/ClipboardProxyTests.cs index d9b0a6c983c..aa95e0afc5a 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/ClipboardProxyTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/ClipboardProxyTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using Microsoft.VisualBasic.Devices; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/FileSystemProxyTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/FileSystemProxyTests.cs index 5625f706a89..d288e9a57f1 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/FileSystemProxyTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/FileSystemProxyTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.VisualBasic.FileIO; using SearchOption = Microsoft.VisualBasic.FileIO.SearchOption; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/Internal/ContextValueTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/Internal/ContextValueTests.cs index 1b1d14dd8a0..1ecdfd27a7f 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/Internal/ContextValueTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/Internal/ContextValueTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualBasic.MyServices.Internal.Tests; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/RegistryProxyTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/RegistryProxyTests.cs index 1b207714aef..06713c81d60 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/RegistryProxyTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/RegistryProxyTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.VisualBasic.Devices; diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxyTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxyTests.cs index d7ca3f03541..5868f530c06 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxyTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/MyServices/SpecialDirectoriesProxyTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.VisualBasic.Devices; diff --git a/src/System.Design/src/System.Design.Forwards.cs b/src/System.Design/src/System.Design.Forwards.cs index 736ef9f0a65..207af0196c7 100644 --- a/src/System.Design/src/System.Design.Forwards.cs +++ b/src/System.Design/src/System.Design.Forwards.cs @@ -1,13 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; // internal UITypeEditors +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.BindingNavigatorDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.BindingSourceDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ColumnHeaderCollectionEditor))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.DataMemberFieldConverter))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.DataGridViewCellStyleEditor))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.DataSourceListEditor))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.FormatStringEditor))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.HelpNamespaceEditor))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ImageCollectionEditor))] @@ -35,20 +37,37 @@ // internal designers [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ButtonBaseDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ComboBoxDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.DataGridViewDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.DataGridViewColumnDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.DateTimePickerDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.FormDocumentDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.FlowPanelDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.GroupBoxDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ImageListDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.LabelDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ListBoxDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ListViewDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.MaskedTextBoxDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.MonthCalendarDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.NotifyIconDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.PanelDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.PropertyGridDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.PictureBoxDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.PrintDialogDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.RadioButtonDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.RichTextBoxDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.SaveFileDialogDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.SplitContainerDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.SplitterPanelDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.SplitterDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.FlowLayoutPanelDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.FolderBrowserDialogDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TabControlDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TableLayoutPanelDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TabPageDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ToolStripContainerDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ToolStripContentPanelDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ToolStripPanelDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TextBoxBaseDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TextBoxDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ToolStripDesigner))] @@ -56,6 +75,7 @@ [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ToolStripDropDownItemDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ToolStripItemDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ToolStripMenuItemDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TrackBarDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TreeViewDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.UpDownBaseDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.UserControlDocumentDesigner))] diff --git a/src/System.Drawing.Common/README.md b/src/System.Drawing.Common/README.md index 08e253582f2..ae4d34f762c 100644 --- a/src/System.Drawing.Common/README.md +++ b/src/System.Drawing.Common/README.md @@ -1,16 +1,16 @@ # System.Drawing.Common -This assembly provides access to GDI+ basic graphics functionality via types such as [`Bitmap`](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.bitmap) and [`Font`](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.font). +This assembly provides access to GDI+ basic graphics functionality via types such as [`Bitmap`](https://learn.microsoft.com/dotnet/api/system.drawing.bitmap) and [`Font`](https://learn.microsoft.com/dotnet/api/system.drawing.font). -Note that `System.Drawing.Common` is only supported on Windows: https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only. +Note that `System.Drawing.Common` is only supported on Windows: https://learn.microsoft.com/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only. -Documentation can be found at https://learn.microsoft.com/en-us/dotnet/api/system.drawing. +Documentation can be found at https://learn.microsoft.com/dotnet/api/system.drawing. ## Contribution Bar -- [x] [We consider new features, new APIs and performance changes](../README.md#primary-bar) -- [x] [We consider PRs that target this library for new source code analyzers](../README.md#secondary-bars) -- [ ] [We don't accept refactoring changes due to new language features](../README.md#secondary-bars) +- [x] We consider new features, new APIs and performance changes +- [x] We consider PRs that target this library for new source code analyzers +- [ ] We don't accept refactoring changes due to new language features -See the [Help Wanted](https://github.com/dotnet/runtime/issues?q=is%3Aissue+is%3Aopen+label%3Aarea-System.Drawing+label%3A%22help+wanted%22) issues. +See the [Help Wanted](https://github.com/dotnet/winforms/labels/help%20wanted) issues. ## Deployment `System.Drawing.Common` is provided as a [NuGet package](https://www.nuget.org/packages/System.Drawing.Common) and part of the `Microsoft.WindowsDesktop.App` shared framework. diff --git a/src/System.Drawing.Common/src/AssemblyRef.cs b/src/System.Drawing.Common/src/AssemblyRef.cs index 53ed3b7b85f..0d07cb8bca4 100644 --- a/src/System.Drawing.Common/src/AssemblyRef.cs +++ b/src/System.Drawing.Common/src/AssemblyRef.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static class FXAssembly { diff --git a/src/System.Drawing.Common/src/CompatibilitySuppressions.xml b/src/System.Drawing.Common/src/CompatibilitySuppressions.xml index bdafcf63cc3..f182e5528b0 100644 --- a/src/System.Drawing.Common/src/CompatibilitySuppressions.xml +++ b/src/System.Drawing.Common/src/CompatibilitySuppressions.xml @@ -31,90 +31,6 @@ lib/netstandard2.0/System.Drawing.Common.dll lib/net462/System.Drawing.Common.dll - - CP0002 - M:System.Drawing.CharacterRange.Equals(System.Drawing.CharacterRange) - lib/net6.0/System.Drawing.Common.dll - lib/netstandard2.0/System.Drawing.Common.dll - true - - - CP0002 - M:System.Drawing.Drawing2D.Matrix.#ctor(System.Numerics.Matrix3x2) - lib/net6.0/System.Drawing.Common.dll - lib/netstandard2.0/System.Drawing.Common.dll - true - - - CP0002 - M:System.Drawing.Drawing2D.Matrix.get_MatrixElements - lib/net6.0/System.Drawing.Common.dll - lib/netstandard2.0/System.Drawing.Common.dll - true - - - CP0002 - M:System.Drawing.Drawing2D.Matrix.set_MatrixElements(System.Numerics.Matrix3x2) - lib/net6.0/System.Drawing.Common.dll - lib/netstandard2.0/System.Drawing.Common.dll - true - - - CP0002 - M:System.Drawing.Graphics.DrawRectangle(System.Drawing.Pen,System.Drawing.RectangleF) - lib/net6.0/System.Drawing.Common.dll - lib/netstandard2.0/System.Drawing.Common.dll - true - - - CP0002 - M:System.Drawing.Graphics.FillPie(System.Drawing.Brush,System.Drawing.RectangleF,System.Single,System.Single) - lib/net6.0/System.Drawing.Common.dll - lib/netstandard2.0/System.Drawing.Common.dll - true - - - CP0002 - M:System.Drawing.Graphics.get_TransformElements - lib/net6.0/System.Drawing.Common.dll - lib/netstandard2.0/System.Drawing.Common.dll - true - - - CP0002 - M:System.Drawing.Graphics.GetContextInfo(System.Drawing.PointF@,System.Drawing.Region@) - lib/net6.0/System.Drawing.Common.dll - lib/netstandard2.0/System.Drawing.Common.dll - true - - - CP0002 - M:System.Drawing.Graphics.GetContextInfo(System.Drawing.PointF@) - lib/net6.0/System.Drawing.Common.dll - lib/netstandard2.0/System.Drawing.Common.dll - true - - - CP0002 - M:System.Drawing.Graphics.set_TransformElements(System.Numerics.Matrix3x2) - lib/net6.0/System.Drawing.Common.dll - lib/netstandard2.0/System.Drawing.Common.dll - true - - - CP0002 - M:System.Drawing.Imaging.ImageFormat.get_Heif - lib/net6.0/System.Drawing.Common.dll - lib/netstandard2.0/System.Drawing.Common.dll - true - - - CP0002 - M:System.Drawing.Imaging.ImageFormat.get_Webp - lib/net6.0/System.Drawing.Common.dll - lib/netstandard2.0/System.Drawing.Common.dll - true - CP0002 F:System.Drawing.Imaging.Encoder.ColorSpace @@ -139,13 +55,6 @@ lib/netstandard2.0/System.Drawing.Common.dll lib/net462/System.Drawing.Common.dll - - CP0008 - T:System.Drawing.CharacterRange - lib/net6.0/System.Drawing.Common.dll - lib/netstandard2.0/System.Drawing.Common.dll - true - CP0015 P:System.Drawing.Font.Name:[T:System.ComponentModel.EditorAttribute] diff --git a/src/System.Drawing.Common/src/Forwards.cs b/src/System.Drawing.Common/src/Forwards.cs index 8178458fc67..8b38b6eba35 100644 --- a/src/System.Drawing.Common/src/Forwards.cs +++ b/src/System.Drawing.Common/src/Forwards.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + #pragma warning disable CS0618,CA2252 #if NETCOREAPP diff --git a/src/System.Drawing.Common/src/GlobalUsings.cs b/src/System.Drawing.Common/src/GlobalUsings.cs index 036612d9742..a1a1ea28d85 100644 --- a/src/System.Drawing.Common/src/GlobalUsings.cs +++ b/src/System.Drawing.Common/src/GlobalUsings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. global using System.Diagnostics; global using System.Diagnostics.CodeAnalysis; diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.RECT.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.RECT.cs index fdd5de32a0e..450f6f21436 100644 --- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.RECT.cs +++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.RECT.cs @@ -16,7 +16,7 @@ public struct RECT public int right; public int bottom; - public Size Size => new Size(right - left, bottom - top); + public Size Size => new(right - left, bottom - top); } } } diff --git a/src/System.Drawing.Common/src/NotSupported.cs b/src/System.Drawing.Common/src/NotSupported.cs index e07b38e887c..2fc692d3c3a 100644 --- a/src/System.Drawing.Common/src/NotSupported.cs +++ b/src/System.Drawing.Common/src/NotSupported.cs @@ -1,5 +1,6 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. + // ------------------------------------------------------------------------------ // Changes to this file must follow the https://aka.ms/api-review process. // ------------------------------------------------------------------------------ @@ -232,10 +233,10 @@ public partial struct CharacterRange { private int _dummyPrimitive; public CharacterRange(int First, int Length) { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } - public int First { get { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } set { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } } - public int Length { get { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } set { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } } - public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } - public override int GetHashCode() { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } + public int First { readonly get { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } set { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } } + public int Length { readonly get { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } set { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } } + public override readonly bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } + public override readonly int GetHashCode() { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } public static bool operator ==(System.Drawing.CharacterRange cr1, System.Drawing.CharacterRange cr2) { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } public static bool operator !=(System.Drawing.CharacterRange cr1, System.Drawing.CharacterRange cr2) { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } } diff --git a/src/System.Drawing.Common/src/PACKAGE.md b/src/System.Drawing.Common/src/PACKAGE.md new file mode 100644 index 00000000000..cbc11143d0a --- /dev/null +++ b/src/System.Drawing.Common/src/PACKAGE.md @@ -0,0 +1,66 @@ +# System.Drawing.Common + +The `System.Drawing.Common` package allows .NET Core and .NET 6+ applications to access GDI+ graphics functionality. +This package is especially useful for porting .NET Framework applications that rely on the `System.Drawing` namespace. + +## Getting Started + +To get started with `System.Drawing.Common`, install it using the NuGet Package Manager, the .NET CLI, or by editing your project file directly. + +**NOTE:** If you are developing a **WinForms** application, you **do not** need to install the `System.Drawing.Common` package separately (to this end, you use the `Sdk` attribute for the `Project` element like `` in the .csproj or the .vbproj file and then specify `true`). This package is then automatically included as part of the .NET SDK for WinForms Apps, which means you can start using the `System.Drawing` namespace right away in your WinForms projects. + +## Usage + +The following examples demonstrate some basic tasks you can accomplish with `System.Drawing.Common`. + +### Create a Simple Bitmap and Save it + +#### C# +```csharp +using System.Drawing; + +class Program +{ + static void Main() + { + using (Bitmap bitmap = new Bitmap(100, 100)) + { + using (Graphics g = Graphics.FromImage(bitmap)) + { + g.Clear(Color.Red); + } + bitmap.Save("output.bmp"); + } + } +} +``` + +#### VB +```vb +Imports System.Drawing + +Module Program + Sub Main() + Using bitmap As New Bitmap(100, 100) + Using g As Graphics = Graphics.FromImage(bitmap) + g.Clear(Color.Red) + End Using + bitmap.Save("output.bmp") + End Using + End Sub +End Module +``` + +## Additional Documentation + +For more in-depth tutorials and API references, you can check the following resources: + +- [NuGet Gallery | System.Drawing.Common](https://nuget.org/packages/System.Drawing.Common/) +- [System.Drawing.Common Namespace | Microsoft Docs](https://docs.microsoft.com/dotnet/api/system.drawing) +- [Drawing with System.Drawing.Common | Microsoft Learn](https://learn.microsoft.com/dotnet/core/drawing/) + +## Feedback + +- Open an issue on the [GitHub repository](https://github.com/dotnet/winforms/issues) +- Reach out on Twitter with the [hashtag #winforms](https://twitter.com/search?q=%23winforms) +- Join our Discord channel: [dotnet/Discord](https://discord.com/invite/dotnet) diff --git a/src/System.Drawing.Common/src/System.Drawing.Common.csproj b/src/System.Drawing.Common/src/System.Drawing.Common.csproj index 4617602845d..c1f5b2de16d 100644 --- a/src/System.Drawing.Common/src/System.Drawing.Common.csproj +++ b/src/System.Drawing.Common/src/System.Drawing.Common.csproj @@ -11,6 +11,11 @@ true true true + + true 7.0.0 true @@ -24,9 +29,15 @@ System.Drawing.Font System.Drawing.Graphics System.Drawing.Icon -Since .NET 7, non-Windows platforms are not supported, even with the runtime configuration switch. See https://aka.ms/systemdrawingnonwindows for more information. +Since .NET 7, non-Windows platforms are not supported, even with the runtime configuration switch. See https://aka.ms/systemdrawingnonwindows for more information. + + PACKAGE.md + + + + true diff --git a/src/System.Drawing.Common/src/System/Drawing/Bitmap.cs b/src/System.Drawing.Common/src/System/Drawing/Bitmap.cs index 46e8457b3f6..2c505ab4b6b 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Bitmap.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Bitmap.cs @@ -248,13 +248,13 @@ public void MakeTransparent(Color transparentColor) // The new bitmap must be in 32bppARGB format, because that's the only // thing that supports alpha. (And that's what the image is initialized to -- transparent) - using var result = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppArgb); + using Bitmap result = new(size.Width, size.Height, PixelFormat.Format32bppArgb); using var graphics = Graphics.FromImage(result); graphics.Clear(Color.Transparent); Rectangle rectangle = new Rectangle(0, 0, size.Width, size.Height); - using (var attributes = new ImageAttributes()) + using (ImageAttributes attributes = new()) { attributes.SetColorKey(transparentColor, transparentColor); graphics.DrawImage(this, rectangle, diff --git a/src/System.Drawing.Common/src/System/Drawing/Brushes.cs b/src/System.Drawing.Common/src/System/Drawing/Brushes.cs index 3444006d1bc..1bebcf5f67c 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Brushes.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Brushes.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Gdip = System.Drawing.SafeNativeMethods.Gdip; @@ -6,147 +6,147 @@ namespace System.Drawing; public static class Brushes { - private static readonly object s_transparentKey = new object(); - private static readonly object s_aliceBlueKey = new object(); - private static readonly object s_antiqueWhiteKey = new object(); - private static readonly object s_aquaKey = new object(); - private static readonly object s_aquamarineKey = new object(); - private static readonly object s_azureKey = new object(); - private static readonly object s_beigeKey = new object(); - private static readonly object s_bisqueKey = new object(); - private static readonly object s_blackKey = new object(); - private static readonly object s_blanchedAlmondKey = new object(); - private static readonly object s_blueKey = new object(); - private static readonly object s_blueVioletKey = new object(); - private static readonly object s_brownKey = new object(); - private static readonly object s_burlyWoodKey = new object(); - private static readonly object s_cadetBlueKey = new object(); - private static readonly object s_chartreuseKey = new object(); - private static readonly object s_chocolateKey = new object(); - private static readonly object s_coralKey = new object(); - private static readonly object s_cornflowerBlueKey = new object(); - private static readonly object s_cornsilkKey = new object(); - private static readonly object s_crimsonKey = new object(); - private static readonly object s_cyanKey = new object(); - private static readonly object s_darkBlueKey = new object(); - private static readonly object s_darkCyanKey = new object(); - private static readonly object s_darkGoldenrodKey = new object(); - private static readonly object s_darkGrayKey = new object(); - private static readonly object s_darkGreenKey = new object(); - private static readonly object s_darkKhakiKey = new object(); - private static readonly object s_darkMagentaKey = new object(); - private static readonly object s_darkOliveGreenKey = new object(); - private static readonly object s_darkOrangeKey = new object(); - private static readonly object s_darkOrchidKey = new object(); - private static readonly object s_darkRedKey = new object(); - private static readonly object s_darkSalmonKey = new object(); - private static readonly object s_darkSeaGreenKey = new object(); - private static readonly object s_darkSlateBlueKey = new object(); - private static readonly object s_darkSlateGrayKey = new object(); - private static readonly object s_darkTurquoiseKey = new object(); - private static readonly object s_darkVioletKey = new object(); - private static readonly object s_deepPinkKey = new object(); - private static readonly object s_deepSkyBlueKey = new object(); - private static readonly object s_dimGrayKey = new object(); - private static readonly object s_dodgerBlueKey = new object(); - private static readonly object s_firebrickKey = new object(); - private static readonly object s_floralWhiteKey = new object(); - private static readonly object s_forestGreenKey = new object(); - private static readonly object s_fuchsiaKey = new object(); - private static readonly object s_gainsboroKey = new object(); - private static readonly object s_ghostWhiteKey = new object(); - private static readonly object s_goldKey = new object(); - private static readonly object s_goldenrodKey = new object(); - private static readonly object s_grayKey = new object(); - private static readonly object s_greenKey = new object(); - private static readonly object s_greenYellowKey = new object(); - private static readonly object s_honeydewKey = new object(); - private static readonly object s_hotPinkKey = new object(); - private static readonly object s_indianRedKey = new object(); - private static readonly object s_indigoKey = new object(); - private static readonly object s_ivoryKey = new object(); - private static readonly object s_khakiKey = new object(); - private static readonly object s_lavenderKey = new object(); - private static readonly object s_lavenderBlushKey = new object(); - private static readonly object s_lawnGreenKey = new object(); - private static readonly object s_lemonChiffonKey = new object(); - private static readonly object s_lightBlueKey = new object(); - private static readonly object s_lightCoralKey = new object(); - private static readonly object s_lightCyanKey = new object(); - private static readonly object s_lightGoldenrodYellowKey = new object(); - private static readonly object s_lightGreenKey = new object(); - private static readonly object s_lightGrayKey = new object(); - private static readonly object s_lightPinkKey = new object(); - private static readonly object s_lightSalmonKey = new object(); - private static readonly object s_lightSeaGreenKey = new object(); - private static readonly object s_lightSkyBlueKey = new object(); - private static readonly object s_lightSlateGrayKey = new object(); - private static readonly object s_lightSteelBlueKey = new object(); - private static readonly object s_lightYellowKey = new object(); - private static readonly object s_limeKey = new object(); - private static readonly object s_limeGreenKey = new object(); - private static readonly object s_linenKey = new object(); - private static readonly object s_magentaKey = new object(); - private static readonly object s_maroonKey = new object(); - private static readonly object s_mediumAquamarineKey = new object(); - private static readonly object s_mediumBlueKey = new object(); - private static readonly object s_mediumOrchidKey = new object(); - private static readonly object s_mediumPurpleKey = new object(); - private static readonly object s_mediumSeaGreenKey = new object(); - private static readonly object s_mediumSlateBlueKey = new object(); - private static readonly object s_mediumSpringGreenKey = new object(); - private static readonly object s_mediumTurquoiseKey = new object(); - private static readonly object s_mediumVioletRedKey = new object(); - private static readonly object s_midnightBlueKey = new object(); - private static readonly object s_mintCreamKey = new object(); - private static readonly object s_mistyRoseKey = new object(); - private static readonly object s_moccasinKey = new object(); - private static readonly object s_navajoWhiteKey = new object(); - private static readonly object s_navyKey = new object(); - private static readonly object s_oldLaceKey = new object(); - private static readonly object s_oliveKey = new object(); - private static readonly object s_oliveDrabKey = new object(); - private static readonly object s_orangeKey = new object(); - private static readonly object s_orangeRedKey = new object(); - private static readonly object s_orchidKey = new object(); - private static readonly object s_paleGoldenrodKey = new object(); - private static readonly object s_paleGreenKey = new object(); - private static readonly object s_paleTurquoiseKey = new object(); - private static readonly object s_paleVioletRedKey = new object(); - private static readonly object s_papayaWhipKey = new object(); - private static readonly object s_peachPuffKey = new object(); - private static readonly object s_peruKey = new object(); - private static readonly object s_pinkKey = new object(); - private static readonly object s_plumKey = new object(); - private static readonly object s_powderBlueKey = new object(); - private static readonly object s_purpleKey = new object(); - private static readonly object s_redKey = new object(); - private static readonly object s_rosyBrownKey = new object(); - private static readonly object s_royalBlueKey = new object(); - private static readonly object s_saddleBrownKey = new object(); - private static readonly object s_salmonKey = new object(); - private static readonly object s_sandyBrownKey = new object(); - private static readonly object s_seaGreenKey = new object(); - private static readonly object s_seaShellKey = new object(); - private static readonly object s_siennaKey = new object(); - private static readonly object s_silverKey = new object(); - private static readonly object s_skyBlueKey = new object(); - private static readonly object s_slateBlueKey = new object(); - private static readonly object s_slateGrayKey = new object(); - private static readonly object s_snowKey = new object(); - private static readonly object s_springGreenKey = new object(); - private static readonly object s_steelBlueKey = new object(); - private static readonly object s_tanKey = new object(); - private static readonly object s_tealKey = new object(); - private static readonly object s_thistleKey = new object(); - private static readonly object s_tomatoKey = new object(); - private static readonly object s_turquoiseKey = new object(); - private static readonly object s_violetKey = new object(); - private static readonly object s_wheatKey = new object(); - private static readonly object s_whiteKey = new object(); - private static readonly object s_whiteSmokeKey = new object(); - private static readonly object s_yellowKey = new object(); - private static readonly object s_yellowGreenKey = new object(); + private static readonly object s_transparentKey = new(); + private static readonly object s_aliceBlueKey = new(); + private static readonly object s_antiqueWhiteKey = new(); + private static readonly object s_aquaKey = new(); + private static readonly object s_aquamarineKey = new(); + private static readonly object s_azureKey = new(); + private static readonly object s_beigeKey = new(); + private static readonly object s_bisqueKey = new(); + private static readonly object s_blackKey = new(); + private static readonly object s_blanchedAlmondKey = new(); + private static readonly object s_blueKey = new(); + private static readonly object s_blueVioletKey = new(); + private static readonly object s_brownKey = new(); + private static readonly object s_burlyWoodKey = new(); + private static readonly object s_cadetBlueKey = new(); + private static readonly object s_chartreuseKey = new(); + private static readonly object s_chocolateKey = new(); + private static readonly object s_coralKey = new(); + private static readonly object s_cornflowerBlueKey = new(); + private static readonly object s_cornsilkKey = new(); + private static readonly object s_crimsonKey = new(); + private static readonly object s_cyanKey = new(); + private static readonly object s_darkBlueKey = new(); + private static readonly object s_darkCyanKey = new(); + private static readonly object s_darkGoldenrodKey = new(); + private static readonly object s_darkGrayKey = new(); + private static readonly object s_darkGreenKey = new(); + private static readonly object s_darkKhakiKey = new(); + private static readonly object s_darkMagentaKey = new(); + private static readonly object s_darkOliveGreenKey = new(); + private static readonly object s_darkOrangeKey = new(); + private static readonly object s_darkOrchidKey = new(); + private static readonly object s_darkRedKey = new(); + private static readonly object s_darkSalmonKey = new(); + private static readonly object s_darkSeaGreenKey = new(); + private static readonly object s_darkSlateBlueKey = new(); + private static readonly object s_darkSlateGrayKey = new(); + private static readonly object s_darkTurquoiseKey = new(); + private static readonly object s_darkVioletKey = new(); + private static readonly object s_deepPinkKey = new(); + private static readonly object s_deepSkyBlueKey = new(); + private static readonly object s_dimGrayKey = new(); + private static readonly object s_dodgerBlueKey = new(); + private static readonly object s_firebrickKey = new(); + private static readonly object s_floralWhiteKey = new(); + private static readonly object s_forestGreenKey = new(); + private static readonly object s_fuchsiaKey = new(); + private static readonly object s_gainsboroKey = new(); + private static readonly object s_ghostWhiteKey = new(); + private static readonly object s_goldKey = new(); + private static readonly object s_goldenrodKey = new(); + private static readonly object s_grayKey = new(); + private static readonly object s_greenKey = new(); + private static readonly object s_greenYellowKey = new(); + private static readonly object s_honeydewKey = new(); + private static readonly object s_hotPinkKey = new(); + private static readonly object s_indianRedKey = new(); + private static readonly object s_indigoKey = new(); + private static readonly object s_ivoryKey = new(); + private static readonly object s_khakiKey = new(); + private static readonly object s_lavenderKey = new(); + private static readonly object s_lavenderBlushKey = new(); + private static readonly object s_lawnGreenKey = new(); + private static readonly object s_lemonChiffonKey = new(); + private static readonly object s_lightBlueKey = new(); + private static readonly object s_lightCoralKey = new(); + private static readonly object s_lightCyanKey = new(); + private static readonly object s_lightGoldenrodYellowKey = new(); + private static readonly object s_lightGreenKey = new(); + private static readonly object s_lightGrayKey = new(); + private static readonly object s_lightPinkKey = new(); + private static readonly object s_lightSalmonKey = new(); + private static readonly object s_lightSeaGreenKey = new(); + private static readonly object s_lightSkyBlueKey = new(); + private static readonly object s_lightSlateGrayKey = new(); + private static readonly object s_lightSteelBlueKey = new(); + private static readonly object s_lightYellowKey = new(); + private static readonly object s_limeKey = new(); + private static readonly object s_limeGreenKey = new(); + private static readonly object s_linenKey = new(); + private static readonly object s_magentaKey = new(); + private static readonly object s_maroonKey = new(); + private static readonly object s_mediumAquamarineKey = new(); + private static readonly object s_mediumBlueKey = new(); + private static readonly object s_mediumOrchidKey = new(); + private static readonly object s_mediumPurpleKey = new(); + private static readonly object s_mediumSeaGreenKey = new(); + private static readonly object s_mediumSlateBlueKey = new(); + private static readonly object s_mediumSpringGreenKey = new(); + private static readonly object s_mediumTurquoiseKey = new(); + private static readonly object s_mediumVioletRedKey = new(); + private static readonly object s_midnightBlueKey = new(); + private static readonly object s_mintCreamKey = new(); + private static readonly object s_mistyRoseKey = new(); + private static readonly object s_moccasinKey = new(); + private static readonly object s_navajoWhiteKey = new(); + private static readonly object s_navyKey = new(); + private static readonly object s_oldLaceKey = new(); + private static readonly object s_oliveKey = new(); + private static readonly object s_oliveDrabKey = new(); + private static readonly object s_orangeKey = new(); + private static readonly object s_orangeRedKey = new(); + private static readonly object s_orchidKey = new(); + private static readonly object s_paleGoldenrodKey = new(); + private static readonly object s_paleGreenKey = new(); + private static readonly object s_paleTurquoiseKey = new(); + private static readonly object s_paleVioletRedKey = new(); + private static readonly object s_papayaWhipKey = new(); + private static readonly object s_peachPuffKey = new(); + private static readonly object s_peruKey = new(); + private static readonly object s_pinkKey = new(); + private static readonly object s_plumKey = new(); + private static readonly object s_powderBlueKey = new(); + private static readonly object s_purpleKey = new(); + private static readonly object s_redKey = new(); + private static readonly object s_rosyBrownKey = new(); + private static readonly object s_royalBlueKey = new(); + private static readonly object s_saddleBrownKey = new(); + private static readonly object s_salmonKey = new(); + private static readonly object s_sandyBrownKey = new(); + private static readonly object s_seaGreenKey = new(); + private static readonly object s_seaShellKey = new(); + private static readonly object s_siennaKey = new(); + private static readonly object s_silverKey = new(); + private static readonly object s_skyBlueKey = new(); + private static readonly object s_slateBlueKey = new(); + private static readonly object s_slateGrayKey = new(); + private static readonly object s_snowKey = new(); + private static readonly object s_springGreenKey = new(); + private static readonly object s_steelBlueKey = new(); + private static readonly object s_tanKey = new(); + private static readonly object s_tealKey = new(); + private static readonly object s_thistleKey = new(); + private static readonly object s_tomatoKey = new(); + private static readonly object s_turquoiseKey = new(); + private static readonly object s_violetKey = new(); + private static readonly object s_wheatKey = new(); + private static readonly object s_whiteKey = new(); + private static readonly object s_whiteSmokeKey = new(); + private static readonly object s_yellowKey = new(); + private static readonly object s_yellowGreenKey = new(); public static Brush Transparent => GetBrush(s_transparentKey, Color.Transparent); diff --git a/src/System.Drawing.Common/src/System/Drawing/CharacterRange.cs b/src/System.Drawing.Common/src/System/Drawing/CharacterRange.cs index 2c8ade6dd0a..60cef9f147d 100644 --- a/src/System.Drawing.Common/src/System/Drawing/CharacterRange.cs +++ b/src/System.Drawing.Common/src/System/Drawing/CharacterRange.cs @@ -21,28 +21,28 @@ public CharacterRange(int First, int Length) /// Gets the First character position of this . public int First { - get => _first; + readonly get => _first; set => _first = value; } /// Gets the Length of this . public int Length { - get => _length; + readonly get => _length; set => _length = value; } - public override bool Equals([NotNullWhen(true)] object? obj) => + public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is CharacterRange other && Equals(other); /// Indicates whether the current instance is equal to another instance of the same type. /// An instance to compare with this instance. /// true if the current instance is equal to the other instance; otherwise, false. - public bool Equals(CharacterRange other) => First == other.First && Length == other.Length; + public readonly bool Equals(CharacterRange other) => First == other.First && Length == other.Length; public static bool operator ==(CharacterRange cr1, CharacterRange cr2) => cr1.Equals(cr2); public static bool operator !=(CharacterRange cr1, CharacterRange cr2) => !cr1.Equals(cr2); - public override int GetHashCode() => HashCode.Combine(First, Length); + public override readonly int GetHashCode() => HashCode.Combine(First, Length); } diff --git a/src/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs b/src/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs index 675ef3a3748..c6be45bf672 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; @@ -202,7 +202,7 @@ public Blend? Blend Gdip.CheckStatus(Gdip.GdipGetLineBlend(new HandleRef(this, NativeBrush), factors, positions, count)); // Return the result in a managed array. - var blend = new Blend(count); + Blend blend = new(count); Marshal.Copy(factors, blend.Factors, 0, count); Marshal.Copy(positions, blend.Positions, 0, count); @@ -335,7 +335,7 @@ public ColorBlend InterpolationColors Gdip.CheckStatus(Gdip.GdipGetLinePresetBlend(new HandleRef(this, NativeBrush), colors, positions, count)); // Return the result in a managed array. - var blend = new ColorBlend(count); + ColorBlend blend = new(count); int[] argb = new int[count]; Marshal.Copy(colors, argb, 0, count); @@ -455,7 +455,7 @@ public Matrix Transform { get { - var matrix = new Matrix(); + Matrix matrix = new(); Gdip.CheckStatus(Gdip.GdipGetLineTransform(new HandleRef(this, NativeBrush), new HandleRef(matrix, matrix.NativeMatrix))); return matrix; } diff --git a/src/System.Drawing.Common/src/System/Drawing/Drawing2D/SafeCustomLineCapHandle.cs b/src/System.Drawing.Common/src/System/Drawing/Drawing2D/SafeCustomLineCapHandle.cs index 4ef5b791579..7b0bd34d7de 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Drawing2D/SafeCustomLineCapHandle.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Drawing2D/SafeCustomLineCapHandle.cs @@ -55,5 +55,5 @@ protected override bool ReleaseHandle() public static implicit operator IntPtr(SafeCustomLineCapHandle handle) => handle?.handle ?? IntPtr.Zero; - public static explicit operator SafeCustomLineCapHandle(IntPtr handle) => new SafeCustomLineCapHandle(handle); + public static explicit operator SafeCustomLineCapHandle(IntPtr handle) => new(handle); } diff --git a/src/System.Drawing.Common/src/System/Drawing/DrawingCom.ComWrappers.cs b/src/System.Drawing.Common/src/System/Drawing/DrawingCom.ComWrappers.cs index e1d1ab94a74..012cad34071 100644 --- a/src/System.Drawing.Common/src/System/Drawing/DrawingCom.ComWrappers.cs +++ b/src/System.Drawing.Common/src/System/Drawing/DrawingCom.ComWrappers.cs @@ -10,14 +10,17 @@ namespace System.Drawing; /// -/// The ComWrappers implementation for System.Drawing.Common's COM interop usages. -/// -/// Supports IStream and IPicture COM interfaces. +/// The ComWrappers implementation for System.Drawing.Common's COM interop usages. /// +/// +/// +/// Supports IStream and IPicture COM interfaces. +/// +/// internal unsafe partial class DrawingCom : ComWrappers { private const int S_OK = (int)HRESULT.S_OK; - private static readonly Guid IID_IStream = new Guid(0x0000000C, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); + private static readonly Guid IID_IStream = new(0x0000000C, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); private static readonly ComInterfaceEntry* s_wrapperEntry = InitializeComInterfaceEntry(); @@ -52,7 +55,11 @@ protected override object CreateObject(IntPtr externalComObject, CreateObjectFla Debug.Assert(flags == CreateObjectFlags.UniqueInstance); Guid pictureIID = IPicture.IID; +#if NET8_0_OR_GREATER + int hr = Marshal.QueryInterface(externalComObject, in pictureIID, out IntPtr comObject); +#else int hr = Marshal.QueryInterface(externalComObject, ref pictureIID, out IntPtr comObject); +#endif if (hr == S_OK) { return new PictureWrapper(comObject); @@ -71,11 +78,16 @@ internal static IStreamWrapper GetComWrapper(Ole32.IStream stream) IntPtr streamWrapperPtr = Instance.GetOrCreateComInterfaceForObject(stream, CreateComInterfaceFlags.None); Guid streamIID = IID_IStream; - int result = Marshal.QueryInterface(streamWrapperPtr, ref streamIID, out IntPtr streamPtr); + +#if NET8_0_OR_GREATER + int hr = Marshal.QueryInterface(streamWrapperPtr, in streamIID, out IntPtr streamPtr); +#else + int hr = Marshal.QueryInterface(streamWrapperPtr, ref streamIID, out IntPtr streamPtr); +#endif Marshal.Release(streamWrapperPtr); - ThrowExceptionForHR(result); + ThrowExceptionForHR(hr); return new IStreamWrapper(streamPtr); } @@ -283,7 +295,7 @@ private static int Clone(IntPtr thisPtr, IntPtr* ppstm) internal interface IPicture : IDisposable { - static readonly Guid IID = new Guid(0x7BF80980, 0xBF32, 0x101A, 0x8B, 0xBB, 0, 0xAA, 0x00, 0x30, 0x0C, 0xAB); + static readonly Guid IID = new(0x7BF80980, 0xBF32, 0x101A, 0x8B, 0xBB, 0, 0xAA, 0x00, 0x30, 0x0C, 0xAB); // NOTE: Only SaveAsFile is invoked. The other methods on IPicture are not necessary @@ -308,7 +320,12 @@ public unsafe int SaveAsFile(IntPtr pstm, int fSaveMemCopy, int* pcbSize) { // Get the IStream implementation, since the ComWrappers runtime returns a pointer to the IUnknown interface implementation Guid streamIID = IID_IStream; + +#if NET8_0_OR_GREATER + ThrowExceptionForHR(Marshal.QueryInterface(pstm, in streamIID, out IntPtr pstmImpl)); +#else ThrowExceptionForHR(Marshal.QueryInterface(pstm, ref streamIID, out IntPtr pstmImpl)); +#endif try { diff --git a/src/System.Drawing.Common/src/System/Drawing/Font.cs b/src/System.Drawing.Common/src/System/Drawing/Font.cs index eb523f0a8a3..ccb5cfd640e 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Font.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Font.cs @@ -596,8 +596,7 @@ static unsafe Font FromLogFont(in LOGFONT logFont, IntPtr hdc) throw new ArgumentException(SR.Format(SR.GdiplusNotTrueTypeFont, logFont.AsString())); } - bool gdiVerticalFont = logFont.lfFaceName[0] == '@'; - return new Font(font, logFont.lfCharSet, gdiVerticalFont); + return new Font(font, logFont.lfCharSet, logFont.IsGdiVerticalFont); } /// diff --git a/src/System.Drawing.Common/src/System/Drawing/FontFamily.cs b/src/System.Drawing.Common/src/System/Drawing/FontFamily.cs index ca7fbf8bfcd..fe73b9fb095 100644 --- a/src/System.Drawing.Common/src/System/Drawing/FontFamily.cs +++ b/src/System.Drawing.Common/src/System/Drawing/FontFamily.cs @@ -18,7 +18,7 @@ public sealed class FontFamily : MarshalByRefObject, IDisposable private readonly bool _createDefaultOnFail; #if DEBUG - private static readonly object s_lockObj = new object(); + private static readonly object s_lockObj = new(); private static int s_idCount; private int _id; #endif @@ -216,7 +216,7 @@ public unsafe string GetName(int language) /// /// Gets a generic SansSerif . /// - public static FontFamily GenericSansSerif => new FontFamily(GetGdipGenericSansSerif()); + public static FontFamily GenericSansSerif => new(GetGdipGenericSansSerif()); private static IntPtr GetGdipGenericSansSerif() { @@ -230,12 +230,12 @@ private static IntPtr GetGdipGenericSansSerif() /// /// Gets a generic Serif . /// - public static FontFamily GenericSerif => new FontFamily(GenericFontFamilies.Serif); + public static FontFamily GenericSerif => new(GenericFontFamilies.Serif); /// /// Gets a generic monospace . /// - public static FontFamily GenericMonospace => new FontFamily(GenericFontFamilies.Monospace); + public static FontFamily GenericMonospace => new(GenericFontFamilies.Monospace); /// /// Returns an array that contains all of the objects associated with the specified diff --git a/src/System.Drawing.Common/src/System/Drawing/Graphics.cs b/src/System.Drawing.Common/src/System/Drawing/Graphics.cs index e8928050c74..39f97465381 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Graphics.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Graphics.cs @@ -44,7 +44,7 @@ internal static string GetAllocationStack() { /// private GraphicsContext? _previousContext; - private static readonly object s_syncObject = new object(); + private static readonly object s_syncObject = new(); // Object reference used for printing; it could point to a PrintPreviewGraphics to obtain the VisibleClipBounds, or // a DeviceContext holding a printer DC. diff --git a/src/System.Drawing.Common/src/System/Drawing/Icon.ComWrappers.cs b/src/System.Drawing.Common/src/System/Drawing/Icon.ComWrappers.cs index 56335e5dbf6..32ce2dacd6e 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Icon.ComWrappers.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Icon.ComWrappers.cs @@ -88,6 +88,6 @@ private unsafe PICTDESC(int picType, IntPtr hicon) } public static PICTDESC CreateIconPICTDESC(IntPtr hicon) => - new PICTDESC(Ole.PICTYPE_ICON, hicon); + new(Ole.PICTYPE_ICON, hicon); } } diff --git a/src/System.Drawing.Common/src/System/Drawing/Image.cs b/src/System.Drawing.Common/src/System/Drawing/Image.cs index bb19e432168..53f11648d41 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Image.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Image.cs @@ -513,7 +513,7 @@ public SizeF PhysicalDimension /// /// Gets the width and height of this . /// - public Size Size => new Size(Width, Height); + public Size Size => new(Width, Height); /// /// Gets the width of this . diff --git a/src/System.Drawing.Common/src/System/Drawing/ImageAnimator.cs b/src/System.Drawing.Common/src/System/Drawing/ImageAnimator.cs index 2492d9255ca..40c84cea075 100644 --- a/src/System.Drawing.Common/src/System/Drawing/ImageAnimator.cs +++ b/src/System.Drawing.Common/src/System/Drawing/ImageAnimator.cs @@ -61,7 +61,7 @@ public sealed partial class ImageAnimator /// access to it for a single thread. Observe that synchronization access to image objects are done /// with critical sections (lock). /// - private static readonly ReaderWriterLock s_rwImgListLock = new ReaderWriterLock(); + private static readonly ReaderWriterLock s_rwImgListLock = new(); /// /// Flag to avoid a deadlock when waiting on a write-lock and an attempt to acquire a read-lock is diff --git a/src/System.Drawing.Common/src/System/Drawing/Imaging/Encoder.cs b/src/System.Drawing.Common/src/System/Drawing/Imaging/Encoder.cs index b3b7a5c4d12..fbd36c32512 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Imaging/Encoder.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Imaging/Encoder.cs @@ -5,31 +5,31 @@ namespace System.Drawing.Imaging; public sealed class Encoder { - public static readonly Encoder Compression = new Encoder(new Guid(unchecked((int)0xe09d739d), unchecked((short)0xccd4), unchecked((short)0x44ee), new byte[] { 0x8e, 0xba, 0x3f, 0xbf, 0x8b, 0xe4, 0xfc, 0x58 })); - public static readonly Encoder ColorDepth = new Encoder(new Guid(0x66087055, unchecked((short)0xad66), unchecked((short)0x4c7c), new byte[] { 0x9a, 0x18, 0x38, 0xa2, 0x31, 0x0b, 0x83, 0x37 })); - public static readonly Encoder ScanMethod = new Encoder(new Guid(0x3a4e2661, (short)0x3109, (short)0x4e56, new byte[] { 0x85, 0x36, 0x42, 0xc1, 0x56, 0xe7, 0xdc, 0xfa })); - public static readonly Encoder Version = new Encoder(new Guid(0x24d18c76, unchecked((short)0x814a), unchecked((short)0x41a4), new byte[] { 0xbf, 0x53, 0x1c, 0x21, 0x9c, 0xcc, 0xf7, 0x97 })); - public static readonly Encoder RenderMethod = new Encoder(new Guid(0x6d42c53a, (short)0x229a, (short)0x4825, new byte[] { 0x8b, 0xb7, 0x5c, 0x99, 0xe2, 0xb9, 0xa8, 0xb8 })); - public static readonly Encoder Quality = new Encoder(new Guid(0x1d5be4b5, unchecked((short)0xfa4a), unchecked((short)0x452d), new byte[] { 0x9c, 0xdd, 0x5d, 0xb3, 0x51, 0x05, 0xe7, 0xeb })); - public static readonly Encoder Transformation = new Encoder(new Guid(unchecked((int)0x8d0eb2d1), unchecked((short)0xa58e), unchecked((short)0x4ea8), new byte[] { 0xaa, 0x14, 0x10, 0x80, 0x74, 0xb7, 0xb6, 0xf9 })); - public static readonly Encoder LuminanceTable = new Encoder(new Guid(unchecked((int)0xedb33bce), unchecked((short)0x0266), unchecked((short)0x4a77), new byte[] { 0xb9, 0x04, 0x27, 0x21, 0x60, 0x99, 0xe7, 0x17 })); - public static readonly Encoder ChrominanceTable = new Encoder(new Guid(unchecked((int)0xf2e455dc), unchecked((short)0x09b3), unchecked((short)0x4316), new byte[] { 0x82, 0x60, 0x67, 0x6a, 0xda, 0x32, 0x48, 0x1c })); - public static readonly Encoder SaveFlag = new Encoder(new Guid(unchecked((int)0x292266fc), unchecked((short)0xac40), unchecked((short)0x47bf), new byte[] { 0x8c, 0xfc, 0xa8, 0x5b, 0x89, 0xa6, 0x55, 0xde })); + public static readonly Encoder Compression = new(new Guid(unchecked((int)0xe09d739d), unchecked((short)0xccd4), unchecked((short)0x44ee), new byte[] { 0x8e, 0xba, 0x3f, 0xbf, 0x8b, 0xe4, 0xfc, 0x58 })); + public static readonly Encoder ColorDepth = new(new Guid(0x66087055, unchecked((short)0xad66), unchecked((short)0x4c7c), new byte[] { 0x9a, 0x18, 0x38, 0xa2, 0x31, 0x0b, 0x83, 0x37 })); + public static readonly Encoder ScanMethod = new(new Guid(0x3a4e2661, (short)0x3109, (short)0x4e56, new byte[] { 0x85, 0x36, 0x42, 0xc1, 0x56, 0xe7, 0xdc, 0xfa })); + public static readonly Encoder Version = new(new Guid(0x24d18c76, unchecked((short)0x814a), unchecked((short)0x41a4), new byte[] { 0xbf, 0x53, 0x1c, 0x21, 0x9c, 0xcc, 0xf7, 0x97 })); + public static readonly Encoder RenderMethod = new(new Guid(0x6d42c53a, (short)0x229a, (short)0x4825, new byte[] { 0x8b, 0xb7, 0x5c, 0x99, 0xe2, 0xb9, 0xa8, 0xb8 })); + public static readonly Encoder Quality = new(new Guid(0x1d5be4b5, unchecked((short)0xfa4a), unchecked((short)0x452d), new byte[] { 0x9c, 0xdd, 0x5d, 0xb3, 0x51, 0x05, 0xe7, 0xeb })); + public static readonly Encoder Transformation = new(new Guid(unchecked((int)0x8d0eb2d1), unchecked((short)0xa58e), unchecked((short)0x4ea8), new byte[] { 0xaa, 0x14, 0x10, 0x80, 0x74, 0xb7, 0xb6, 0xf9 })); + public static readonly Encoder LuminanceTable = new(new Guid(unchecked((int)0xedb33bce), unchecked((short)0x0266), unchecked((short)0x4a77), new byte[] { 0xb9, 0x04, 0x27, 0x21, 0x60, 0x99, 0xe7, 0x17 })); + public static readonly Encoder ChrominanceTable = new(new Guid(unchecked((int)0xf2e455dc), unchecked((short)0x09b3), unchecked((short)0x4316), new byte[] { 0x82, 0x60, 0x67, 0x6a, 0xda, 0x32, 0x48, 0x1c })); + public static readonly Encoder SaveFlag = new(new Guid(unchecked((int)0x292266fc), unchecked((short)0xac40), unchecked((short)0x47bf), new byte[] { 0x8c, 0xfc, 0xa8, 0x5b, 0x89, 0xa6, 0x55, 0xde })); /// /// An object that is initialized with the globally unique identifier for the color space category. /// - public static readonly Encoder ColorSpace = new Encoder(new Guid(unchecked((int)0xae7a62a0), unchecked((short)0xee2c), unchecked((short)0x49d8), new byte[] { 0x9d, 0x07, 0x1b, 0xa8, 0xa9, 0x27, 0x59, 0x6e })); + public static readonly Encoder ColorSpace = new(new Guid(unchecked((int)0xae7a62a0), unchecked((short)0xee2c), unchecked((short)0x49d8), new byte[] { 0x9d, 0x07, 0x1b, 0xa8, 0xa9, 0x27, 0x59, 0x6e })); /// /// An object that is initialized with the globally unique identifier for the image items category. /// - public static readonly Encoder ImageItems = new Encoder(new Guid(unchecked((int)0x63875e13), unchecked((short)0x1f1d), unchecked((short)0x45ab), new byte[] { 0x91, 0x95, 0xa2, 0x9b, 0x60, 0x66, 0xa6, 0x50 })); + public static readonly Encoder ImageItems = new(new Guid(unchecked((int)0x63875e13), unchecked((short)0x1f1d), unchecked((short)0x45ab), new byte[] { 0x91, 0x95, 0xa2, 0x9b, 0x60, 0x66, 0xa6, 0x50 })); /// /// An object that is initialized with the globally unique identifier for the save as CMYK category. /// - public static readonly Encoder SaveAsCmyk = new Encoder(new Guid(unchecked((int)0xa219bbc9), unchecked((short)0x0a9d), unchecked((short)0x4005), new byte[] { 0xa3, 0xee, 0x3a, 0x42, 0x1b, 0x8b, 0xb0, 0x6c })); + public static readonly Encoder SaveAsCmyk = new(new Guid(unchecked((int)0xa219bbc9), unchecked((short)0x0a9d), unchecked((short)0x4005), new byte[] { 0xa3, 0xee, 0x3a, 0x42, 0x1b, 0x8b, 0xb0, 0x6c })); private Guid _guid; diff --git a/src/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameter.cs b/src/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameter.cs index bdcd5ae32db..d94f4a75b67 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameter.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameter.cs @@ -27,7 +27,7 @@ public sealed unsafe class EncoderParameter : IDisposable /// public Encoder Encoder { - get => new Encoder(_parameterGuid); + get => new(_parameterGuid); set => _parameterGuid = value.Guid; } diff --git a/src/System.Drawing.Common/src/System/Drawing/Imaging/FrameDimension.cs b/src/System.Drawing.Common/src/System/Drawing/Imaging/FrameDimension.cs index 84c25edab89..0e8455d5511 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Imaging/FrameDimension.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Imaging/FrameDimension.cs @@ -6,9 +6,9 @@ namespace System.Drawing.Imaging; public sealed class FrameDimension { // Frame dimension GUIDs, from sdkinc\imgguids.h - private static readonly FrameDimension s_time = new FrameDimension(new Guid("{6aedbd6d-3fb5-418a-83a6-7f45229dc872}")); - private static readonly FrameDimension s_resolution = new FrameDimension(new Guid("{84236f7b-3bd3-428f-8dab-4ea1439ca315}")); - private static readonly FrameDimension s_page = new FrameDimension(new Guid("{7462dc86-6180-4c7e-8e3f-ee7333a7a483}")); + private static readonly FrameDimension s_time = new(new Guid("{6aedbd6d-3fb5-418a-83a6-7f45229dc872}")); + private static readonly FrameDimension s_resolution = new(new Guid("{84236f7b-3bd3-428f-8dab-4ea1439ca315}")); + private static readonly FrameDimension s_page = new(new Guid("{7462dc86-6180-4c7e-8e3f-ee7333a7a483}")); private Guid _guid; diff --git a/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageAttributes.cs b/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageAttributes.cs index 2049edebb11..5d984503d32 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageAttributes.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageAttributes.cs @@ -499,7 +499,7 @@ public void ClearBrushRemapTable() public void SetWrapMode(WrapMode mode) { - SetWrapMode(mode, default(Color), false); + SetWrapMode(mode, default, false); } public void SetWrapMode(WrapMode mode, Color color) diff --git a/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageFormat.cs b/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageFormat.cs index e936747c64d..8d636865a5f 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageFormat.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageFormat.cs @@ -14,18 +14,18 @@ public sealed class ImageFormat { // Format IDs // private static ImageFormat undefined = new ImageFormat(new Guid("{b96b3ca9-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_memoryBMP = new ImageFormat(new Guid("{b96b3caa-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_bmp = new ImageFormat(new Guid("{b96b3cab-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_emf = new ImageFormat(new Guid("{b96b3cac-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_wmf = new ImageFormat(new Guid("{b96b3cad-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_jpeg = new ImageFormat(new Guid("{b96b3cae-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_png = new ImageFormat(new Guid("{b96b3caf-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_gif = new ImageFormat(new Guid("{b96b3cb0-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_tiff = new ImageFormat(new Guid("{b96b3cb1-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_exif = new ImageFormat(new Guid("{b96b3cb2-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_icon = new ImageFormat(new Guid("{b96b3cb5-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_heif = new ImageFormat(new Guid("{b96b3cb6-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_webp = new ImageFormat(new Guid("{b96b3cb7-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_memoryBMP = new(new Guid("{b96b3caa-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_bmp = new(new Guid("{b96b3cab-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_emf = new(new Guid("{b96b3cac-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_wmf = new(new Guid("{b96b3cad-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_jpeg = new(new Guid("{b96b3cae-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_png = new(new Guid("{b96b3caf-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_gif = new(new Guid("{b96b3cb0-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_tiff = new(new Guid("{b96b3cb1-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_exif = new(new Guid("{b96b3cb2-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_icon = new(new Guid("{b96b3cb5-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_heif = new(new Guid("{b96b3cb6-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_webp = new(new Guid("{b96b3cb7-0728-11d3-9d7b-0000f81ef32e}")); private Guid _guid; diff --git a/src/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs b/src/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs index cebaa528b8c..9cd530b68a9 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs @@ -34,7 +34,7 @@ internal sealed class MetafileHeaderWmf #pragma warning disable CS0618 // Legacy code: We don't care about using obsolete API's. [MarshalAs(UnmanagedType.Struct)] #pragma warning restore CS0618 - public MetaHeader WmfHeader = new MetaHeader(); + public MetaHeader WmfHeader = new(); public int dummy1; public int dummy2; public int dummy3; diff --git a/src/System.Drawing.Common/src/System/Drawing/Internal/SystemColorTracker.cs b/src/System.Drawing.Common/src/System/Drawing/Internal/SystemColorTracker.cs index 995808e3bca..1223bd7d8d0 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Internal/SystemColorTracker.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Internal/SystemColorTracker.cs @@ -19,7 +19,7 @@ internal static class SystemColorTracker private static WeakReference[] list = new WeakReference[INITIAL_SIZE]; private static int count; private static bool addedTracker; - private static readonly object lockObject = new object(); + private static readonly object lockObject = new(); internal static void Add(ISystemColorTracker obj) { diff --git a/src/System.Drawing.Common/src/System/Drawing/Interop/LOGFONT.cs b/src/System.Drawing.Common/src/System/Drawing/Interop/LOGFONT.cs index 9cb75b4964b..62b6c31bd45 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Interop/LOGFONT.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Interop/LOGFONT.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System.Drawing.Interop; @@ -31,16 +32,18 @@ unsafe struct LOGFONT public byte lfPitchAndFamily; private fixed char _lfFaceName[LF_FACESIZE]; + internal readonly bool IsGdiVerticalFont => _lfFaceName[0] == '@'; + #if NET7_0_OR_GREATER [UnscopedRef] #endif public Span lfFaceName => MemoryMarshal.CreateSpan(ref _lfFaceName[0], LF_FACESIZE); - internal string AsString() + internal readonly string AsString() #pragma warning disable format => $"lfHeight={lfHeight}, lfWidth={lfWidth}, lfEscapement={lfEscapement}, lfOrientation={lfOrientation }, lfWeight={lfWeight}, lfItalic={lfItalic}, lfUnderline={lfUnderline}, lfStrikeOut={lfStrikeOut }, lfCharSet={lfCharSet}, lfOutPrecision={lfOutPrecision}, lfClipPrecision={lfClipPrecision - }, lfQuality={lfQuality}, lfPitchAndFamily={lfPitchAndFamily}, lfFaceName={lfFaceName}"; + }, lfQuality={lfQuality}, lfPitchAndFamily={lfPitchAndFamily}, lfFaceName={Unsafe.AsRef(in this).lfFaceName}"; #pragma warning restore format } diff --git a/src/System.Drawing.Common/src/System/Drawing/NativeMethods.cs b/src/System.Drawing.Common/src/System/Drawing/NativeMethods.cs index 2dc0e960929..d96eab2c4c1 100644 --- a/src/System.Drawing.Common/src/System/Drawing/NativeMethods.cs +++ b/src/System.Drawing.Common/src/System/Drawing/NativeMethods.cs @@ -7,7 +7,7 @@ namespace System.Drawing; internal static class NativeMethods { - internal static HandleRef NullHandleRef => new HandleRef(null, IntPtr.Zero); + internal static HandleRef NullHandleRef => new(null, IntPtr.Zero); public const int MAX_PATH = 260; internal const int SM_REMOTESESSION = 0x1000; diff --git a/src/System.Drawing.Common/src/System/Drawing/Pens.cs b/src/System.Drawing.Common/src/System/Drawing/Pens.cs index 30c8c7dbebf..96b498afdaf 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Pens.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Pens.cs @@ -6,147 +6,147 @@ namespace System.Drawing; public static class Pens { - private static readonly object s_transparentKey = new object(); - private static readonly object s_aliceBlueKey = new object(); - private static readonly object s_antiqueWhiteKey = new object(); - private static readonly object s_aquaKey = new object(); - private static readonly object s_aquamarineKey = new object(); - private static readonly object s_azureKey = new object(); - private static readonly object s_beigeKey = new object(); - private static readonly object s_bisqueKey = new object(); - private static readonly object s_blackKey = new object(); - private static readonly object s_blanchedAlmondKey = new object(); - private static readonly object s_blueKey = new object(); - private static readonly object s_blueVioletKey = new object(); - private static readonly object s_brownKey = new object(); - private static readonly object s_burlyWoodKey = new object(); - private static readonly object s_cadetBlueKey = new object(); - private static readonly object s_chartreuseKey = new object(); - private static readonly object s_chocolateKey = new object(); - private static readonly object s_coralKey = new object(); - private static readonly object s_cornflowerBlueKey = new object(); - private static readonly object s_cornsilkKey = new object(); - private static readonly object s_crimsonKey = new object(); - private static readonly object s_cyanKey = new object(); - private static readonly object s_darkBlueKey = new object(); - private static readonly object s_darkCyanKey = new object(); - private static readonly object s_darkGoldenrodKey = new object(); - private static readonly object s_darkGrayKey = new object(); - private static readonly object s_darkGreenKey = new object(); - private static readonly object s_darkKhakiKey = new object(); - private static readonly object s_darkMagentaKey = new object(); - private static readonly object s_darkOliveGreenKey = new object(); - private static readonly object s_darkOrangeKey = new object(); - private static readonly object s_darkOrchidKey = new object(); - private static readonly object s_darkRedKey = new object(); - private static readonly object s_darkSalmonKey = new object(); - private static readonly object s_darkSeaGreenKey = new object(); - private static readonly object s_darkSlateBlueKey = new object(); - private static readonly object s_darkSlateGrayKey = new object(); - private static readonly object s_darkTurquoiseKey = new object(); - private static readonly object s_darkVioletKey = new object(); - private static readonly object s_deepPinkKey = new object(); - private static readonly object s_deepSkyBlueKey = new object(); - private static readonly object s_dimGrayKey = new object(); - private static readonly object s_dodgerBlueKey = new object(); - private static readonly object s_firebrickKey = new object(); - private static readonly object s_floralWhiteKey = new object(); - private static readonly object s_forestGreenKey = new object(); - private static readonly object s_fuchsiaKey = new object(); - private static readonly object s_gainsboroKey = new object(); - private static readonly object s_ghostWhiteKey = new object(); - private static readonly object s_goldKey = new object(); - private static readonly object s_goldenrodKey = new object(); - private static readonly object s_grayKey = new object(); - private static readonly object s_greenKey = new object(); - private static readonly object s_greenYellowKey = new object(); - private static readonly object s_honeydewKey = new object(); - private static readonly object s_hotPinkKey = new object(); - private static readonly object s_indianRedKey = new object(); - private static readonly object s_indigoKey = new object(); - private static readonly object s_ivoryKey = new object(); - private static readonly object s_khakiKey = new object(); - private static readonly object s_lavenderKey = new object(); - private static readonly object s_lavenderBlushKey = new object(); - private static readonly object s_lawnGreenKey = new object(); - private static readonly object s_lemonChiffonKey = new object(); - private static readonly object s_lightBlueKey = new object(); - private static readonly object s_lightCoralKey = new object(); - private static readonly object s_lightCyanKey = new object(); - private static readonly object s_lightGoldenrodYellowKey = new object(); - private static readonly object s_lightGreenKey = new object(); - private static readonly object s_lightGrayKey = new object(); - private static readonly object s_lightPinkKey = new object(); - private static readonly object s_lightSalmonKey = new object(); - private static readonly object s_lightSeaGreenKey = new object(); - private static readonly object s_lightSkyBlueKey = new object(); - private static readonly object s_lightSlateGrayKey = new object(); - private static readonly object s_lightSteelBlueKey = new object(); - private static readonly object s_lightYellowKey = new object(); - private static readonly object s_limeKey = new object(); - private static readonly object s_limeGreenKey = new object(); - private static readonly object s_linenKey = new object(); - private static readonly object s_magentaKey = new object(); - private static readonly object s_maroonKey = new object(); - private static readonly object s_mediumAquamarineKey = new object(); - private static readonly object s_mediumBlueKey = new object(); - private static readonly object s_mediumOrchidKey = new object(); - private static readonly object s_mediumPurpleKey = new object(); - private static readonly object s_mediumSeaGreenKey = new object(); - private static readonly object s_mediumSlateBlueKey = new object(); - private static readonly object s_mediumSpringGreenKey = new object(); - private static readonly object s_mediumTurquoiseKey = new object(); - private static readonly object s_mediumVioletRedKey = new object(); - private static readonly object s_midnightBlueKey = new object(); - private static readonly object s_mintCreamKey = new object(); - private static readonly object s_mistyRoseKey = new object(); - private static readonly object s_moccasinKey = new object(); - private static readonly object s_navajoWhiteKey = new object(); - private static readonly object s_navyKey = new object(); - private static readonly object s_oldLaceKey = new object(); - private static readonly object s_oliveKey = new object(); - private static readonly object s_oliveDrabKey = new object(); - private static readonly object s_orangeKey = new object(); - private static readonly object s_orangeRedKey = new object(); - private static readonly object s_orchidKey = new object(); - private static readonly object s_paleGoldenrodKey = new object(); - private static readonly object s_paleGreenKey = new object(); - private static readonly object s_paleTurquoiseKey = new object(); - private static readonly object s_paleVioletRedKey = new object(); - private static readonly object s_papayaWhipKey = new object(); - private static readonly object s_peachPuffKey = new object(); - private static readonly object s_peruKey = new object(); - private static readonly object s_pinkKey = new object(); - private static readonly object s_plumKey = new object(); - private static readonly object s_powderBlueKey = new object(); - private static readonly object s_purpleKey = new object(); - private static readonly object s_redKey = new object(); - private static readonly object s_rosyBrownKey = new object(); - private static readonly object s_royalBlueKey = new object(); - private static readonly object s_saddleBrownKey = new object(); - private static readonly object s_salmonKey = new object(); - private static readonly object s_sandyBrownKey = new object(); - private static readonly object s_seaGreenKey = new object(); - private static readonly object s_seaShellKey = new object(); - private static readonly object s_siennaKey = new object(); - private static readonly object s_silverKey = new object(); - private static readonly object s_skyBlueKey = new object(); - private static readonly object s_slateBlueKey = new object(); - private static readonly object s_slateGrayKey = new object(); - private static readonly object s_snowKey = new object(); - private static readonly object s_springGreenKey = new object(); - private static readonly object s_steelBlueKey = new object(); - private static readonly object s_tanKey = new object(); - private static readonly object s_tealKey = new object(); - private static readonly object s_thistleKey = new object(); - private static readonly object s_tomatoKey = new object(); - private static readonly object s_turquoiseKey = new object(); - private static readonly object s_violetKey = new object(); - private static readonly object s_wheatKey = new object(); - private static readonly object s_whiteKey = new object(); - private static readonly object s_whiteSmokeKey = new object(); - private static readonly object s_yellowKey = new object(); - private static readonly object s_yellowGreenKey = new object(); + private static readonly object s_transparentKey = new(); + private static readonly object s_aliceBlueKey = new(); + private static readonly object s_antiqueWhiteKey = new(); + private static readonly object s_aquaKey = new(); + private static readonly object s_aquamarineKey = new(); + private static readonly object s_azureKey = new(); + private static readonly object s_beigeKey = new(); + private static readonly object s_bisqueKey = new(); + private static readonly object s_blackKey = new(); + private static readonly object s_blanchedAlmondKey = new(); + private static readonly object s_blueKey = new(); + private static readonly object s_blueVioletKey = new(); + private static readonly object s_brownKey = new(); + private static readonly object s_burlyWoodKey = new(); + private static readonly object s_cadetBlueKey = new(); + private static readonly object s_chartreuseKey = new(); + private static readonly object s_chocolateKey = new(); + private static readonly object s_coralKey = new(); + private static readonly object s_cornflowerBlueKey = new(); + private static readonly object s_cornsilkKey = new(); + private static readonly object s_crimsonKey = new(); + private static readonly object s_cyanKey = new(); + private static readonly object s_darkBlueKey = new(); + private static readonly object s_darkCyanKey = new(); + private static readonly object s_darkGoldenrodKey = new(); + private static readonly object s_darkGrayKey = new(); + private static readonly object s_darkGreenKey = new(); + private static readonly object s_darkKhakiKey = new(); + private static readonly object s_darkMagentaKey = new(); + private static readonly object s_darkOliveGreenKey = new(); + private static readonly object s_darkOrangeKey = new(); + private static readonly object s_darkOrchidKey = new(); + private static readonly object s_darkRedKey = new(); + private static readonly object s_darkSalmonKey = new(); + private static readonly object s_darkSeaGreenKey = new(); + private static readonly object s_darkSlateBlueKey = new(); + private static readonly object s_darkSlateGrayKey = new(); + private static readonly object s_darkTurquoiseKey = new(); + private static readonly object s_darkVioletKey = new(); + private static readonly object s_deepPinkKey = new(); + private static readonly object s_deepSkyBlueKey = new(); + private static readonly object s_dimGrayKey = new(); + private static readonly object s_dodgerBlueKey = new(); + private static readonly object s_firebrickKey = new(); + private static readonly object s_floralWhiteKey = new(); + private static readonly object s_forestGreenKey = new(); + private static readonly object s_fuchsiaKey = new(); + private static readonly object s_gainsboroKey = new(); + private static readonly object s_ghostWhiteKey = new(); + private static readonly object s_goldKey = new(); + private static readonly object s_goldenrodKey = new(); + private static readonly object s_grayKey = new(); + private static readonly object s_greenKey = new(); + private static readonly object s_greenYellowKey = new(); + private static readonly object s_honeydewKey = new(); + private static readonly object s_hotPinkKey = new(); + private static readonly object s_indianRedKey = new(); + private static readonly object s_indigoKey = new(); + private static readonly object s_ivoryKey = new(); + private static readonly object s_khakiKey = new(); + private static readonly object s_lavenderKey = new(); + private static readonly object s_lavenderBlushKey = new(); + private static readonly object s_lawnGreenKey = new(); + private static readonly object s_lemonChiffonKey = new(); + private static readonly object s_lightBlueKey = new(); + private static readonly object s_lightCoralKey = new(); + private static readonly object s_lightCyanKey = new(); + private static readonly object s_lightGoldenrodYellowKey = new(); + private static readonly object s_lightGreenKey = new(); + private static readonly object s_lightGrayKey = new(); + private static readonly object s_lightPinkKey = new(); + private static readonly object s_lightSalmonKey = new(); + private static readonly object s_lightSeaGreenKey = new(); + private static readonly object s_lightSkyBlueKey = new(); + private static readonly object s_lightSlateGrayKey = new(); + private static readonly object s_lightSteelBlueKey = new(); + private static readonly object s_lightYellowKey = new(); + private static readonly object s_limeKey = new(); + private static readonly object s_limeGreenKey = new(); + private static readonly object s_linenKey = new(); + private static readonly object s_magentaKey = new(); + private static readonly object s_maroonKey = new(); + private static readonly object s_mediumAquamarineKey = new(); + private static readonly object s_mediumBlueKey = new(); + private static readonly object s_mediumOrchidKey = new(); + private static readonly object s_mediumPurpleKey = new(); + private static readonly object s_mediumSeaGreenKey = new(); + private static readonly object s_mediumSlateBlueKey = new(); + private static readonly object s_mediumSpringGreenKey = new(); + private static readonly object s_mediumTurquoiseKey = new(); + private static readonly object s_mediumVioletRedKey = new(); + private static readonly object s_midnightBlueKey = new(); + private static readonly object s_mintCreamKey = new(); + private static readonly object s_mistyRoseKey = new(); + private static readonly object s_moccasinKey = new(); + private static readonly object s_navajoWhiteKey = new(); + private static readonly object s_navyKey = new(); + private static readonly object s_oldLaceKey = new(); + private static readonly object s_oliveKey = new(); + private static readonly object s_oliveDrabKey = new(); + private static readonly object s_orangeKey = new(); + private static readonly object s_orangeRedKey = new(); + private static readonly object s_orchidKey = new(); + private static readonly object s_paleGoldenrodKey = new(); + private static readonly object s_paleGreenKey = new(); + private static readonly object s_paleTurquoiseKey = new(); + private static readonly object s_paleVioletRedKey = new(); + private static readonly object s_papayaWhipKey = new(); + private static readonly object s_peachPuffKey = new(); + private static readonly object s_peruKey = new(); + private static readonly object s_pinkKey = new(); + private static readonly object s_plumKey = new(); + private static readonly object s_powderBlueKey = new(); + private static readonly object s_purpleKey = new(); + private static readonly object s_redKey = new(); + private static readonly object s_rosyBrownKey = new(); + private static readonly object s_royalBlueKey = new(); + private static readonly object s_saddleBrownKey = new(); + private static readonly object s_salmonKey = new(); + private static readonly object s_sandyBrownKey = new(); + private static readonly object s_seaGreenKey = new(); + private static readonly object s_seaShellKey = new(); + private static readonly object s_siennaKey = new(); + private static readonly object s_silverKey = new(); + private static readonly object s_skyBlueKey = new(); + private static readonly object s_slateBlueKey = new(); + private static readonly object s_slateGrayKey = new(); + private static readonly object s_snowKey = new(); + private static readonly object s_springGreenKey = new(); + private static readonly object s_steelBlueKey = new(); + private static readonly object s_tanKey = new(); + private static readonly object s_tealKey = new(); + private static readonly object s_thistleKey = new(); + private static readonly object s_tomatoKey = new(); + private static readonly object s_turquoiseKey = new(); + private static readonly object s_violetKey = new(); + private static readonly object s_wheatKey = new(); + private static readonly object s_whiteKey = new(); + private static readonly object s_whiteSmokeKey = new(); + private static readonly object s_yellowKey = new(); + private static readonly object s_yellowGreenKey = new(); public static Pen Transparent => GetPen(s_transparentKey, Color.Transparent); diff --git a/src/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.cs b/src/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.cs index 4d1abe68d7f..018b2e94253 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.cs @@ -19,7 +19,7 @@ public partial class PageSettings : ICloneable private PaperSource? _paperSource; private PrinterResolution? _printerResolution; private TriState _landscape = TriState.Default; - private Margins _margins = new Margins(); + private Margins _margins = new(); /// /// Initializes a new instance of the class using the default printer. diff --git a/src/System.Drawing.Common/src/System/Drawing/Printing/PreviewPrintController.cs b/src/System.Drawing.Common/src/System/Drawing/Printing/PreviewPrintController.cs index d92da4fa812..77ae1b7a6e1 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Printing/PreviewPrintController.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Printing/PreviewPrintController.cs @@ -18,7 +18,7 @@ public class PreviewPrintController : PrintController { private Graphics? _graphics; private DeviceContext? _dc; - private readonly ArrayList _list = new ArrayList(); + private readonly ArrayList _list = new(); public override bool IsPreview => true; diff --git a/src/System.Drawing.Common/src/System/Drawing/Printing/PrintDocument.cs b/src/System.Drawing.Common/src/System/Drawing/Printing/PrintDocument.cs index 3069f5d3b6c..2352807de2d 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Printing/PrintDocument.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Printing/PrintDocument.cs @@ -18,7 +18,7 @@ public class PrintDocument : Component private PrintPageEventHandler? _printPageHandler; private QueryPageSettingsEventHandler? _queryHandler; - private PrinterSettings _printerSettings = new PrinterSettings(); + private PrinterSettings _printerSettings = new(); private PageSettings _defaultPageSettings; private PrintController? _printController; diff --git a/src/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs b/src/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs index 165d9afe747..fcf08ce7a11 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs @@ -7,9 +7,9 @@ namespace System.Drawing.Printing; { private readonly byte _value; // 0 is "default", not false - public static readonly TriState Default = new TriState(0); - public static readonly TriState False = new TriState(1); - public static readonly TriState True = new TriState(2); + public static readonly TriState Default = new(0); + public static readonly TriState False = new(1); + public static readonly TriState True = new(2); private TriState(byte value) => _value = value; diff --git a/src/System.Drawing.Common/src/System/Drawing/PropertyItemInternal.cs b/src/System.Drawing.Common/src/System/Drawing/PropertyItemInternal.cs index db6efb31356..95f0f0e4021 100644 --- a/src/System.Drawing.Common/src/System/Drawing/PropertyItemInternal.cs +++ b/src/System.Drawing.Common/src/System/Drawing/PropertyItemInternal.cs @@ -10,5 +10,5 @@ internal unsafe struct PropertyItemInternal public short type; public byte* value; - public Span Value => new Span(value, len); + public Span Value => new(value, len); } diff --git a/src/System.Drawing.Common/src/System/Drawing/ScreenDC.cs b/src/System.Drawing.Common/src/System/Drawing/ScreenDC.cs index 2d7bc9d92c3..5c28158d5e6 100644 --- a/src/System.Drawing.Common/src/System/Drawing/ScreenDC.cs +++ b/src/System.Drawing.Common/src/System/Drawing/ScreenDC.cs @@ -12,7 +12,7 @@ internal struct ScreenDC : IDisposable { private IntPtr _handle; - public static ScreenDC Create() => new ScreenDC + public static ScreenDC Create() => new() { _handle = User32.GetDC(IntPtr.Zero) }; diff --git a/src/System.Drawing.Common/src/System/Drawing/SystemBrushes.cs b/src/System.Drawing.Common/src/System/Drawing/SystemBrushes.cs index 4e5f0f0a407..f1413e9e429 100644 --- a/src/System.Drawing.Common/src/System/Drawing/SystemBrushes.cs +++ b/src/System.Drawing.Common/src/System/Drawing/SystemBrushes.cs @@ -7,7 +7,7 @@ namespace System.Drawing; public static class SystemBrushes { - private static readonly object s_systemBrushesKey = new object(); + private static readonly object s_systemBrushesKey = new(); public static Brush ActiveBorder => FromSystemColor(SystemColors.ActiveBorder); public static Brush ActiveCaption => FromSystemColor(SystemColors.ActiveCaption); diff --git a/src/System.Drawing.Common/src/System/Drawing/SystemPens.cs b/src/System.Drawing.Common/src/System/Drawing/SystemPens.cs index 28bded2e633..af01ce3c9ba 100644 --- a/src/System.Drawing.Common/src/System/Drawing/SystemPens.cs +++ b/src/System.Drawing.Common/src/System/Drawing/SystemPens.cs @@ -7,7 +7,7 @@ namespace System.Drawing; public static class SystemPens { - private static readonly object s_systemPensKey = new object(); + private static readonly object s_systemPensKey = new(); public static Pen ActiveBorder => FromSystemColor(SystemColors.ActiveBorder); public static Pen ActiveCaption => FromSystemColor(SystemColors.ActiveCaption); diff --git a/src/System.Drawing.Common/src/System/Drawing/ToolboxBitmapAttribute.cs b/src/System.Drawing.Common/src/System/Drawing/ToolboxBitmapAttribute.cs index f356a0ab850..da02d165c21 100644 --- a/src/System.Drawing.Common/src/System/Drawing/ToolboxBitmapAttribute.cs +++ b/src/System.Drawing.Common/src/System/Drawing/ToolboxBitmapAttribute.cs @@ -23,8 +23,8 @@ public class ToolboxBitmapAttribute : Attribute private readonly string? _imageName; - private static readonly Size s_largeSize = new Size(32, 32); - private static readonly Size s_smallSize = new Size(16, 16); + private static readonly Size s_largeSize = new(32, 32); + private static readonly Size s_smallSize = new(16, 16); public ToolboxBitmapAttribute(string imageFile) : this(GetImageFromFile(imageFile, false), GetImageFromFile(imageFile, true)) { @@ -306,7 +306,7 @@ private static void MakeBackgroundAlphaZero(Bitmap img) img.SetPixel(0, img.Height - 1, newBottomLeft); } - public static readonly ToolboxBitmapAttribute Default = new ToolboxBitmapAttribute(null, (Image?)null); + public static readonly ToolboxBitmapAttribute Default = new(null, (Image?)null); private static readonly ToolboxBitmapAttribute s_defaultComponent; diff --git a/src/System.Drawing.Common/src/misc/DbgUtil.cs b/src/System.Drawing.Common/src/misc/DbgUtil.cs index 93f5e714c0f..0c4f303d1e6 100644 --- a/src/System.Drawing.Common/src/misc/DbgUtil.cs +++ b/src/System.Drawing.Common/src/misc/DbgUtil.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; @@ -56,7 +56,7 @@ public static void AssertWin32(bool expression, string format, params object[] a { if (!expression) { - var e = new Win32Exception(); + Win32Exception e = new(); string message = string.Format(CultureInfo.CurrentCulture, format, args); Debug.Fail($"{message}\r\nError: 0x{e.NativeErrorCode:x8} - {e.Message}"); } diff --git a/src/System.Drawing.Common/tests/BitmapTests.cs b/src/System.Drawing.Common/tests/BitmapTests.cs index b03e01bf7e4..f429838ce85 100644 --- a/src/System.Drawing.Common/tests/BitmapTests.cs +++ b/src/System.Drawing.Common/tests/BitmapTests.cs @@ -1093,7 +1093,7 @@ public void SetResolution_Disposed_ThrowsArgumentException() public static IEnumerable LockBits_TestData() { - Bitmap bitmap() => new Bitmap(2, 2, PixelFormat.Format32bppArgb); + Bitmap bitmap() => new(2, 2, PixelFormat.Format32bppArgb); yield return new object[] { bitmap(), new Rectangle(0, 0, 2, 2), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb, 8, 1 }; yield return new object[] { bitmap(), new Rectangle(0, 0, 2, 2), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb, 8, 3 }; yield return new object[] { bitmap(), new Rectangle(0, 0, 2, 2), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb, 8, 2 }; diff --git a/src/System.Drawing.Common/tests/Drawing2D/MatrixTests.cs b/src/System.Drawing.Common/tests/Drawing2D/MatrixTests.cs index 4a02a26dff8..e302b52623c 100644 --- a/src/System.Drawing.Common/tests/Drawing2D/MatrixTests.cs +++ b/src/System.Drawing.Common/tests/Drawing2D/MatrixTests.cs @@ -78,7 +78,7 @@ public void Ctor_Elements(float m11, float m12, float m21, float m22, float dx, } public static TheoryData MatrixElements_TestData - => new TheoryData + => new() { { 1, 0, 0, 1, 0, 0, true, true }, { 0, 1, 2, 1, 3, 4, false, true }, diff --git a/src/System.Drawing.Common/tests/Drawing2D/PathGradientBrushTests.cs b/src/System.Drawing.Common/tests/Drawing2D/PathGradientBrushTests.cs index ea0073f8fbd..a329ae6c352 100644 --- a/src/System.Drawing.Common/tests/Drawing2D/PathGradientBrushTests.cs +++ b/src/System.Drawing.Common/tests/Drawing2D/PathGradientBrushTests.cs @@ -29,7 +29,7 @@ public class PathGradientBrushTests { private readonly Point[] _defaultIntPoints = new Point[2] { new Point(1, 2), new Point(20, 30) }; private readonly PointF[] _defaultFloatPoints = new PointF[2] { new PointF(1, 2), new PointF(20, 30) }; - private readonly RectangleF _defaultRectangle = new RectangleF(1, 2, 19, 28); + private readonly RectangleF _defaultRectangle = new(1, 2, 19, 28); [Fact] public void Ctor_Points_ReturnsExpected() diff --git a/src/System.Drawing.Common/tests/GlobalUsings.cs b/src/System.Drawing.Common/tests/GlobalUsings.cs index be9336ac8b4..af753dde135 100644 --- a/src/System.Drawing.Common/tests/GlobalUsings.cs +++ b/src/System.Drawing.Common/tests/GlobalUsings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. global using System.Drawing; global using System.Diagnostics; diff --git a/src/System.Drawing.Common/tests/ImageTests.cs b/src/System.Drawing.Common/tests/ImageTests.cs index ff0082687da..7b25bae6adc 100644 --- a/src/System.Drawing.Common/tests/ImageTests.cs +++ b/src/System.Drawing.Common/tests/ImageTests.cs @@ -519,7 +519,7 @@ public void FromFile_LongSegment_ThrowsException() // Throws PathTooLongException on Desktop and FileNotFoundException elsewhere. if (PlatformDetection.IsNetFramework) { - string fileName = new string('a', 261); + string fileName = new('a', 261); Assert.Throws(() => Image.FromFile(fileName)); Assert.Throws(() => Image.FromFile(fileName, @@ -527,7 +527,7 @@ public void FromFile_LongSegment_ThrowsException() } else { - string fileName = new string('a', 261); + string fileName = new('a', 261); Assert.Throws(() => Image.FromFile(fileName)); Assert.Throws(() => Image.FromFile(fileName, diff --git a/src/System.Drawing.Common/tests/Imaging/ImageAttributesTests.cs b/src/System.Drawing.Common/tests/Imaging/ImageAttributesTests.cs index 8802f943c64..f87327c82b4 100644 --- a/src/System.Drawing.Common/tests/Imaging/ImageAttributesTests.cs +++ b/src/System.Drawing.Common/tests/Imaging/ImageAttributesTests.cs @@ -29,12 +29,12 @@ namespace System.Drawing.Imaging.Tests; public class ImageAttributesTests { - private readonly Rectangle _rectangle = new Rectangle(0, 0, 64, 64); + private readonly Rectangle _rectangle = new(0, 0, 64, 64); private readonly Color _actualYellow = Color.FromArgb(255, 255, 255, 0); private readonly Color _actualGreen = Color.FromArgb(255, 0, 255, 0); private readonly Color _expectedRed = Color.FromArgb(255, 255, 0, 0); private readonly Color _expectedBlack = Color.FromArgb(255, 0, 0, 0); - private readonly ColorMatrix _greenComponentToZeroColorMatrix = new ColorMatrix(new float[][] + private readonly ColorMatrix _greenComponentToZeroColorMatrix = new(new float[][] { new float[] {1, 0, 0, 0, 0}, new float[] {0, 0, 0, 0, 0}, @@ -43,7 +43,7 @@ public class ImageAttributesTests new float[] {0, 0, 0, 0, 0}, }); - private readonly ColorMatrix _grayMatrix = new ColorMatrix(new float[][] { + private readonly ColorMatrix _grayMatrix = new(new float[][] { new float[] {1, 0, 0, 0, 0}, new float[] {0, 2, 0, 0, 0}, new float[] {0, 0, 3, 0, 0}, @@ -1215,7 +1215,7 @@ public void SetOutputChannelColorProfile_InvalidPath_ThrowsOutOfMemoryException( [Fact] public void SetOutputChannelColorProfile_InvalidPath_ThrowsPathTooLongException() { - string fileNameTooLong = new string('a', short.MaxValue); + string fileNameTooLong = new('a', short.MaxValue); using (var imageAttr = new ImageAttributes()) { Assert.Throws(() => imageAttr.SetOutputChannelColorProfile(fileNameTooLong)); diff --git a/src/System.Drawing.Common/tests/Imaging/ImageFormatTests.cs b/src/System.Drawing.Common/tests/Imaging/ImageFormatTests.cs index d5292c83a27..2845c4bd09b 100644 --- a/src/System.Drawing.Common/tests/Imaging/ImageFormatTests.cs +++ b/src/System.Drawing.Common/tests/Imaging/ImageFormatTests.cs @@ -5,19 +5,19 @@ namespace System.Drawing.Imaging.Tests; public class ImageFormatTests { - private static ImageFormat BmpImageFormat = new ImageFormat(new Guid("b96b3cab-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat EmfImageFormat = new ImageFormat(new Guid("b96b3cac-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat ExifImageFormat = new ImageFormat(new Guid("b96b3cb2-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat GifImageFormat = new ImageFormat(new Guid("b96b3cb0-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat TiffImageFormat = new ImageFormat(new Guid("b96b3cb1-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat PngImageFormat = new ImageFormat(new Guid("b96b3caf-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat MemoryBmpImageFormat = new ImageFormat(new Guid("b96b3caa-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat IconImageFormat = new ImageFormat(new Guid("b96b3cb5-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat JpegImageFormat = new ImageFormat(new Guid("b96b3cae-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat WmfImageFormat = new ImageFormat(new Guid("b96b3cad-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat HeifImageFormat = new ImageFormat(new Guid("{b96b3cb6-0728-11d3-9d7b-0000f81ef32e}")); - private static ImageFormat WebpImageFormat = new ImageFormat(new Guid("{b96b3cb7-0728-11d3-9d7b-0000f81ef32e}")); - private static ImageFormat CustomImageFormat = new ImageFormat(new Guid("48749428-316f-496a-ab30-c819a92b3137")); + private static ImageFormat BmpImageFormat = new(new Guid("b96b3cab-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat EmfImageFormat = new(new Guid("b96b3cac-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat ExifImageFormat = new(new Guid("b96b3cb2-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat GifImageFormat = new(new Guid("b96b3cb0-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat TiffImageFormat = new(new Guid("b96b3cb1-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat PngImageFormat = new(new Guid("b96b3caf-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat MemoryBmpImageFormat = new(new Guid("b96b3caa-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat IconImageFormat = new(new Guid("b96b3cb5-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat JpegImageFormat = new(new Guid("b96b3cae-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat WmfImageFormat = new(new Guid("b96b3cad-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat HeifImageFormat = new(new Guid("{b96b3cb6-0728-11d3-9d7b-0000f81ef32e}")); + private static ImageFormat WebpImageFormat = new(new Guid("{b96b3cb7-0728-11d3-9d7b-0000f81ef32e}")); + private static ImageFormat CustomImageFormat = new(new Guid("48749428-316f-496a-ab30-c819a92b3137")); public static IEnumerable ImageFormatGuidTestData { diff --git a/src/System.Drawing.Common/tests/Imaging/MetafileTests.cs b/src/System.Drawing.Common/tests/Imaging/MetafileTests.cs index 454ac5b7e62..9274ea35438 100644 --- a/src/System.Drawing.Common/tests/Imaging/MetafileTests.cs +++ b/src/System.Drawing.Common/tests/Imaging/MetafileTests.cs @@ -31,8 +31,8 @@ public class MetafileTests { private const string WmfFile = "telescope_01.wmf"; private const string BmpFile = "bitmap_173x183_indexed_8bit.bmp"; - private readonly Rectangle _rectangle = new Rectangle(0, 0, 64, 64); - private readonly RectangleF _rectangleF = new RectangleF(0, 0, 64, 64); + private readonly Rectangle _rectangle = new(0, 0, 64, 64); + private readonly RectangleF _rectangleF = new(0, 0, 64, 64); [Fact] public void Ctor_IntPtrZero_ThrowsArgumentException() diff --git a/src/System.Drawing.Common/tests/Printing/PrintDocumentTests.cs b/src/System.Drawing.Common/tests/Printing/PrintDocumentTests.cs index 97d0d4a4694..9af2b3e48e7 100644 --- a/src/System.Drawing.Common/tests/Printing/PrintDocumentTests.cs +++ b/src/System.Drawing.Common/tests/Printing/PrintDocumentTests.cs @@ -27,7 +27,7 @@ namespace System.Drawing.Printing.Tests; public class PrintDocumentTests : FileCleanupTestBase { - private readonly PageSettings _pageSettings = new PageSettings() + private readonly PageSettings _pageSettings = new() { PaperSize = new PaperSize() { diff --git a/src/System.Drawing.Common/tests/System/Drawing/FontConverterTests.cs b/src/System.Drawing.Common/tests/System/Drawing/FontConverterTests.cs index 1dcdfd677e6..083f7a4ef7a 100644 --- a/src/System.Drawing.Common/tests/System/Drawing/FontConverterTests.cs +++ b/src/System.Drawing.Common/tests/System/Drawing/FontConverterTests.cs @@ -195,7 +195,7 @@ private static bool EmptyFontPresent } } - public static TheoryData ArgumentExceptionFontConverterData() => new TheoryData() + public static TheoryData ArgumentExceptionFontConverterData() => new() { { $"Courier New{s_separator} 11 px{s_separator} type=Bold{s_separator} Italic", "units", null }, { $"Courier New{s_separator} {s_separator} Style=Bold", "value", null }, @@ -209,7 +209,7 @@ private static bool EmptyFontPresent { $"Arial{s_separator} 10style{s_separator} style=bold", "units", null }, }; - public static TheoryData InvalidEnumArgumentExceptionFontConverterData() => new TheoryData() + public static TheoryData InvalidEnumArgumentExceptionFontConverterData() => new() { { $"Arial{s_separator} 10{s_separator} style=56", "style" }, { $"Arial{s_separator} 10{s_separator} style=-1", "style" }, diff --git a/src/System.Drawing.Common/tests/ToolboxBitmapAttributeTests.cs b/src/System.Drawing.Common/tests/ToolboxBitmapAttributeTests.cs index 368d0ab4ba2..7b9e3438920 100644 --- a/src/System.Drawing.Common/tests/ToolboxBitmapAttributeTests.cs +++ b/src/System.Drawing.Common/tests/ToolboxBitmapAttributeTests.cs @@ -14,7 +14,7 @@ public class Icon_toolboxBitmapAttributeTest { } public class ToolboxBitmapAttributeTests { - private static Size DefaultSize = new Size(16, 16); + private static Size DefaultSize = new(16, 16); private void AssertDefaultSize(Image image) { Assert.Equal(DefaultSize, image.Size); diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/DiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/DiagnosticDescriptors.cs index 2beed5d064e..d4754eff009 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/DiagnosticDescriptors.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/DiagnosticDescriptors.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/Properties/AssemblyInfo.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/Properties/AssemblyInfo.cs index 7724dd7c685..18c78a00dd6 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/Properties/AssemblyInfo.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/Properties/AssemblyInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationGenerator.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationGenerator.cs index 6cd7a447998..21f6052ac8d 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationGenerator.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationGenerator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.Analyzers; using Microsoft.CodeAnalysis; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilder.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilder.cs index 14c318715f1..fdb9d7ae931 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilder.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilder.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Text; using System.Windows.Forms.Analyzers; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.FontConverter.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.FontConverter.cs index f58a938ee1a..4a5704b5e3a 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.FontConverter.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.FontConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs index cc7efc572b4..6b74a36189b 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.Analyzers; using Microsoft.CodeAnalysis; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/CompilerAnalyzerConfigOptions.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/CompilerAnalyzerConfigOptions.cs index ace119a3c17..ebeecf43bc1 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/CompilerAnalyzerConfigOptions.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/CompilerAnalyzerConfigOptions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/CompilerAnalyzerConfigOptionsProvider.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/CompilerAnalyzerConfigOptionsProvider.cs index ee69266b233..691b01ba4d4 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/CompilerAnalyzerConfigOptionsProvider.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/CompilerAnalyzerConfigOptionsProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs index 64a1d7b4adc..9f957a3e8d0 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationGeneratorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Text; using System.Windows.Forms.Analyzers; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilderTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilderTests.cs index 4bf820319b5..77fd3124ed9 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilderTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ApplicationConfigurationInitializeBuilderTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; using System.Windows.Forms.Analyzers; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.FontConverter.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.FontConverter.cs index 03a0e07e7ce..316fbc4022d 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.FontConverter.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.FontConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs index 4356e4c83e7..1ab65bba012 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/System/Windows/Forms/Generators/ProjectFileReaderTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Immutable; using System.Globalization; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/TestAdditionalText.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/TestAdditionalText.cs index 1384ac263b2..d2c3d139283 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/TestAdditionalText.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/TestAdditionalText.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs index 3d117a91eda..530188736a5 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpIncrementalSourceGeneratorVerifier.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpSourceGeneratorTest`1.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpSourceGeneratorTest`1.cs index c041d105e3a..7d1fbe564b6 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpSourceGeneratorTest`1.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpSourceGeneratorTest`1.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Testing; diff --git a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpVerifierHelper.cs b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpVerifierHelper.cs index 1f6cb1c14b8..9d5eb03101f 100644 --- a/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpVerifierHelper.cs +++ b/src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/Verifiers/CSharpVerifierHelper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Immutable; using Microsoft.CodeAnalysis; diff --git a/src/System.Windows.Forms.Analyzers/src/DiagnosticDescriptors.cs b/src/System.Windows.Forms.Analyzers/src/DiagnosticDescriptors.cs index a509c367ca8..7106437ba1b 100644 --- a/src/System.Windows.Forms.Analyzers/src/DiagnosticDescriptors.cs +++ b/src/System.Windows.Forms.Analyzers/src/DiagnosticDescriptors.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis; diff --git a/src/System.Windows.Forms.Analyzers/src/Properties/AssemblyInfo.cs b/src/System.Windows.Forms.Analyzers/src/Properties/AssemblyInfo.cs index 4fb491f70cf..ba34ad5403a 100644 --- a/src/System.Windows.Forms.Analyzers/src/Properties/AssemblyInfo.cs +++ b/src/System.Windows.Forms.Analyzers/src/Properties/AssemblyInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/AnalyzerConfigOptionsProviderExtensions.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/AnalyzerConfigOptionsProviderExtensions.cs index 6af6bb56653..9495f028900 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/AnalyzerConfigOptionsProviderExtensions.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/AnalyzerConfigOptionsProviderExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.Diagnostics; diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/AppManifestAnalyzer.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/AppManifestAnalyzer.cs index d08e336844a..aa504c345aa 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/AppManifestAnalyzer.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/AppManifestAnalyzer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Immutable; using System.Xml; diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.FontDescriptor.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.FontDescriptor.cs index b7d0970d0c4..ae9884542f1 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.FontDescriptor.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.FontDescriptor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; using System.Text.RegularExpressions; diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.FontStyle.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.FontStyle.cs index 7e6778fe076..f5af959ce99 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.FontStyle.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.FontStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Analyzers; diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.GraphicsUnit.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.GraphicsUnit.cs index ff2c9edf6d8..22dce2e37f6 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.GraphicsUnit.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.GraphicsUnit.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Analyzers; diff --git a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.cs b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.cs index 56dcd8e6fca..3d97028fae6 100644 --- a/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.cs +++ b/src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/ApplicationConfig.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Runtime.CompilerServices { diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs index 4dc3450e864..800eaf6ee0c 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/AppManifestAnalyzerTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.FontDescriptor.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.FontDescriptor.cs index c00914a698d..ffaa924630b 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.FontDescriptor.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.FontDescriptor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; using Xunit; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.FontStyle.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.FontStyle.cs index 5439d704d72..6d7dd0c1cdf 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.FontStyle.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.FontStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Xunit; using static System.Windows.Forms.Analyzers.ApplicationConfig; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.GraphicsUnit.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.GraphicsUnit.cs index 64c19fb4b1a..a0be6ece1db 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.GraphicsUnit.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.GraphicsUnit.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Xunit; using static System.Windows.Forms.Analyzers.ApplicationConfig; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.cs index dc90bd2e005..a725b5a116a 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/System/Windows/Forms/Analyzers/ApplicationConfigTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Analyzers.Tests; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs index 44902c4085e..6905e29ec43 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Testing; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1.cs index 6ab18543b00..e317183b963 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpAnalyzerVerifier`1.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Testing; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs index f67c65644a8..99626f17ae5 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeFixes; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2.cs index 8d13200ffb9..3070478ab92 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeFixVerifier`2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeFixes; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1+Test.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1+Test.cs index 0129dcc904a..0922d3fcc2c 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1+Test.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1+Test.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeRefactorings; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1.cs index a94d549db1c..13d8999d867 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpCodeRefactoringVerifier`1.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.Testing; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpVerifierHelper.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpVerifierHelper.cs index b46c76d443f..ff766b66212 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpVerifierHelper.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/CSharpVerifierHelper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1+Test.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1+Test.cs index 4664826cc28..d4afd5bc2b7 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1+Test.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1+Test.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1.cs index 8f6438c8659..a2791ca44c1 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicAnalyzerVerifier`1.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2+Test.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2+Test.cs index 031b56d7d15..9e59d844bc6 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2+Test.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2+Test.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.Diagnostics; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2.cs index ca8a07475a8..e05c8fa0b53 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeFixVerifier`2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeFixes; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1+Test.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1+Test.cs index daeda0e2d12..e4927138b71 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1+Test.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1+Test.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.Testing.Verifiers; diff --git a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1.cs b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1.cs index 4e2b9dc832c..113bf6e2baa 100644 --- a/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1.cs +++ b/src/System.Windows.Forms.Analyzers/tests/UnitTests/Verifiers/VisualBasicCodeRefactoringVerifier`1.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.Testing; diff --git a/src/System.Windows.Forms.Design/src/AssemblyRef.cs b/src/System.Windows.Forms.Design/src/AssemblyRef.cs index b0d77212d91..926015f15c1 100644 --- a/src/System.Windows.Forms.Design/src/AssemblyRef.cs +++ b/src/System.Windows.Forms.Design/src/AssemblyRef.cs @@ -1,9 +1,16 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. + +internal static class FXAssembly +{ + // NB: this must never-ever change to facilitate type-forwarding from + // .NET Framework, if those are referenced in .NET project. + internal const string Version = "4.0.0.0"; +} internal static class AssemblyRef { internal const string MicrosoftPublicKey = "b03f5f7f11d50a3a"; internal const string EnvDTE = $"EnvDTE, Version=7.0.3300.0, Culture=neutral, PublicKeyToken={MicrosoftPublicKey}"; + internal const string SystemDesign = $"System.Design, Version={FXAssembly.Version}, Culture=neutral, PublicKeyToken={MicrosoftPublicKey}"; } diff --git a/src/System.Windows.Forms.Design/src/DataSourceDescriptor.cs b/src/System.Windows.Forms.Design/src/DataSourceDescriptor.cs new file mode 100644 index 00000000000..fffb0531483 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/DataSourceDescriptor.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Drawing; + +namespace System.Windows.Forms.Design; + +internal abstract class DataSourceDescriptor +{ + public abstract string Name { get; } + + public abstract Bitmap Image { get; } + + public abstract string TypeName { get; } + + public abstract bool IsDesignable { get; } +} diff --git a/src/System.Windows.Forms.Design/src/GlobalUsings.cs b/src/System.Windows.Forms.Design/src/GlobalUsings.cs index e7b964da64c..6bbe13b8690 100644 --- a/src/System.Windows.Forms.Design/src/GlobalUsings.cs +++ b/src/System.Windows.Forms.Design/src/GlobalUsings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. global using System.Diagnostics; global using System.Diagnostics.CodeAnalysis; diff --git a/src/System.Windows.Forms.Design/src/Properties/AssemblyInfo.cs b/src/System.Windows.Forms.Design/src/Properties/AssemblyInfo.cs index 0fc33884f91..d4b6c6d124c 100644 --- a/src/System.Windows.Forms.Design/src/Properties/AssemblyInfo.cs +++ b/src/System.Windows.Forms.Design/src/Properties/AssemblyInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt b/src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt index ede1767e625..68d331b894a 100644 --- a/src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt +++ b/src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt @@ -1,25 +1,24 @@ #nullable enable -~abstract System.ComponentModel.Design.EventBindingService.CreateUniqueMethodName(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor e) -> string -~abstract System.ComponentModel.Design.EventBindingService.GetCompatibleMethods(System.ComponentModel.EventDescriptor e) -> System.Collections.ICollection -~abstract System.ComponentModel.Design.EventBindingService.ShowCode(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor e, string methodName) -> bool -~abstract System.ComponentModel.Design.Serialization.BasicDesignerLoader.PerformFlush(System.ComponentModel.Design.Serialization.IDesignerSerializationManager serializationManager) -> void -~abstract System.ComponentModel.Design.Serialization.BasicDesignerLoader.PerformLoad(System.ComponentModel.Design.Serialization.IDesignerSerializationManager serializationManager) -> void -~abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.CodeDomProvider.get -> System.CodeDom.Compiler.CodeDomProvider -~abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.Parse() -> System.CodeDom.CodeCompileUnit -~abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.TypeResolutionService.get -> System.ComponentModel.Design.ITypeResolutionService -~abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.Write(System.CodeDom.CodeCompileUnit unit) -> void +abstract System.ComponentModel.Design.EventBindingService.CreateUniqueMethodName(System.ComponentModel.IComponent! component, System.ComponentModel.EventDescriptor! e) -> string! +abstract System.ComponentModel.Design.EventBindingService.GetCompatibleMethods(System.ComponentModel.EventDescriptor! e) -> System.Collections.ICollection! +abstract System.ComponentModel.Design.EventBindingService.ShowCode(System.ComponentModel.IComponent! component, System.ComponentModel.EventDescriptor! e, string! methodName) -> bool +abstract System.ComponentModel.Design.Serialization.BasicDesignerLoader.PerformFlush(System.ComponentModel.Design.Serialization.IDesignerSerializationManager! serializationManager) -> void +abstract System.ComponentModel.Design.Serialization.BasicDesignerLoader.PerformLoad(System.ComponentModel.Design.Serialization.IDesignerSerializationManager! serializationManager) -> void +abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.CodeDomProvider.get -> System.CodeDom.Compiler.CodeDomProvider? +abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.Parse() -> System.CodeDom.CodeCompileUnit! +abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.TypeResolutionService.get -> System.ComponentModel.Design.ITypeResolutionService? +abstract System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.Write(System.CodeDom.CodeCompileUnit! unit) -> void ~abstract System.ComponentModel.Design.Serialization.MemberCodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value, System.ComponentModel.MemberDescriptor descriptor, System.CodeDom.CodeStatementCollection statements) -> void ~abstract System.ComponentModel.Design.Serialization.MemberCodeDomSerializer.ShouldSerialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value, System.ComponentModel.MemberDescriptor descriptor) -> bool -~abstract System.ComponentModel.Design.UndoEngine.AddUndoUnit(System.ComponentModel.Design.UndoEngine.UndoUnit unit) -> void -~abstract System.Windows.Forms.Design.MaskDescriptor.Mask.get -> string -~abstract System.Windows.Forms.Design.MaskDescriptor.Name.get -> string -~abstract System.Windows.Forms.Design.MaskDescriptor.Sample.get -> string -~abstract System.Windows.Forms.Design.MaskDescriptor.ValidatingType.get -> System.Type +abstract System.Windows.Forms.Design.MaskDescriptor.Mask.get -> string? +abstract System.Windows.Forms.Design.MaskDescriptor.Name.get -> string? +abstract System.Windows.Forms.Design.MaskDescriptor.Sample.get -> string? +abstract System.Windows.Forms.Design.MaskDescriptor.ValidatingType.get -> System.Type? ~override System.ComponentModel.Design.ArrayEditor.CreateCollectionItemType() -> System.Type ~override System.ComponentModel.Design.ArrayEditor.GetItems(object editValue) -> object[] ~override System.ComponentModel.Design.ArrayEditor.SetItems(object editValue, object[] value) -> object -~override System.ComponentModel.Design.BinaryEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -~override System.ComponentModel.Design.BinaryEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +override System.ComponentModel.Design.BinaryEditor.EditValue(System.ComponentModel.ITypeDescriptorContext? context, System.IServiceProvider! provider, object? value) -> object? +override System.ComponentModel.Design.BinaryEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext? context) -> System.Drawing.Design.UITypeEditorEditStyle ~override System.ComponentModel.Design.ByteViewer.OnKeyDown(System.Windows.Forms.KeyEventArgs e) -> void ~override System.ComponentModel.Design.ByteViewer.OnLayout(System.Windows.Forms.LayoutEventArgs e) -> void ~override System.ComponentModel.Design.ByteViewer.OnPaint(System.Windows.Forms.PaintEventArgs e) -> void @@ -27,12 +26,7 @@ ~override System.ComponentModel.Design.CollectionEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle ~override System.ComponentModel.Design.DateTimeEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object ~override System.ComponentModel.Design.DateTimeEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -~override System.ComponentModel.Design.ObjectSelectorEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -~override System.ComponentModel.Design.ObjectSelectorEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -~override System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnKeyDown(System.Windows.Forms.KeyEventArgs e) -> void -~override System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnKeyPress(System.Windows.Forms.KeyPressEventArgs e) -> void -~override System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnNodeMouseClick(System.Windows.Forms.TreeNodeMouseClickEventArgs e) -> void -~override System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(System.ComponentModel.Design.Serialization.IDesignerLoaderHost host) -> void +override System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(System.ComponentModel.Design.Serialization.IDesignerLoaderHost! host) -> void ~override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.CreateStore() -> System.ComponentModel.Design.Serialization.SerializationStore ~override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.Deserialize(System.ComponentModel.Design.Serialization.SerializationStore store) -> System.Collections.ICollection ~override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.Deserialize(System.ComponentModel.Design.Serialization.SerializationStore store, System.ComponentModel.IContainer container) -> System.Collections.ICollection @@ -42,26 +36,14 @@ ~override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.SerializeAbsolute(System.ComponentModel.Design.Serialization.SerializationStore store, object value) -> void ~override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.SerializeMember(System.ComponentModel.Design.Serialization.SerializationStore store, object owningObject, System.ComponentModel.MemberDescriptor member) -> void ~override System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.SerializeMemberAbsolute(System.ComponentModel.Design.Serialization.SerializationStore store, object owningObject, System.ComponentModel.MemberDescriptor member) -> void -~override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.OnEndLoad(bool successful, System.Collections.ICollection errors) -> void -~override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformFlush(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager) -> void -~override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager) -> void -~override System.ComponentModel.Design.Serialization.CodeDomSerializerException.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) -> void +override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.OnEndLoad(bool successful, System.Collections.ICollection? errors) -> void +override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformFlush(System.ComponentModel.Design.Serialization.IDesignerSerializationManager! manager) -> void +override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(System.ComponentModel.Design.Serialization.IDesignerSerializationManager! manager) -> void ~override System.ComponentModel.Design.Serialization.CollectionCodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value) -> object -~override System.ComponentModel.Design.UndoEngine.UndoUnit.ToString() -> string -~override System.Drawing.Design.ContentAlignmentEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -~override System.Drawing.Design.ContentAlignmentEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -~override System.Drawing.Design.CursorEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -~override System.Drawing.Design.CursorEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -~override System.Drawing.Design.FontEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -~override System.Drawing.Design.FontEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -~override System.Drawing.Design.FontNameEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context) -> bool -~override System.Drawing.Design.FontNameEditor.PaintValue(System.Drawing.Design.PaintValueEventArgs e) -> void ~override System.Drawing.Design.ToolboxItem.Equals(object obj) -> bool ~override System.Drawing.Design.ToolboxItem.ToString() -> string -~override System.Windows.Forms.Design.AnchorEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -~override System.Windows.Forms.Design.AnchorEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -~override System.Windows.Forms.Design.BorderSidesEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -~override System.Windows.Forms.Design.BorderSidesEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle +override System.Windows.Forms.Design.AnchorEditor.EditValue(System.ComponentModel.ITypeDescriptorContext? context, System.IServiceProvider! provider, object? value) -> object? +override System.Windows.Forms.Design.AnchorEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext? context) -> System.Drawing.Design.UITypeEditorEditStyle ~override System.Windows.Forms.Design.ComponentDocumentDesigner.Initialize(System.ComponentModel.IComponent component) -> void ~override System.Windows.Forms.Design.ComponentDocumentDesigner.PreFilterProperties(System.Collections.IDictionary properties) -> void ~override System.Windows.Forms.Design.ComponentTray.GetService(System.Type serviceType) -> object @@ -83,19 +65,11 @@ ~override System.Windows.Forms.Design.ControlDesigner.InitializeNewComponent(System.Collections.IDictionary defaultValues) -> void ~override System.Windows.Forms.Design.ControlDesigner.ParentComponent.get -> System.ComponentModel.IComponent ~override System.Windows.Forms.Design.ControlDesigner.PreFilterProperties(System.Collections.IDictionary properties) -> void -~override System.Windows.Forms.Design.DockEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -~override System.Windows.Forms.Design.DockEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle ~override System.Windows.Forms.Design.DocumentDesigner.GetGlyphs(System.Windows.Forms.Design.Behavior.GlyphSelectionType selectionType) -> System.Windows.Forms.Design.Behavior.GlyphCollection ~override System.Windows.Forms.Design.DocumentDesigner.Initialize(System.ComponentModel.IComponent component) -> void ~override System.Windows.Forms.Design.DocumentDesigner.PreFilterProperties(System.Collections.IDictionary properties) -> void -~override System.Windows.Forms.Design.FileNameEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -~override System.Windows.Forms.Design.FileNameEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -~override System.Windows.Forms.Design.FolderNameEditor.EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) -> object -~override System.Windows.Forms.Design.FolderNameEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) -> System.Drawing.Design.UITypeEditorEditStyle -~override System.Windows.Forms.Design.ImageListCodeDomSerializer.Deserialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object codeObject) -> object -~override System.Windows.Forms.Design.ImageListCodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value) -> object -~override System.Windows.Forms.Design.MaskDescriptor.Equals(object maskDescriptor) -> bool -~override System.Windows.Forms.Design.MaskDescriptor.ToString() -> string +override System.Windows.Forms.Design.MaskDescriptor.Equals(object? maskDescriptor) -> bool +override System.Windows.Forms.Design.MaskDescriptor.ToString() -> string! ~override System.Windows.Forms.Design.ParentControlDesigner.GetControlGlyph(System.Windows.Forms.Design.Behavior.GlyphSelectionType selectionType) -> System.Windows.Forms.Design.Behavior.ControlBodyGlyph ~override System.Windows.Forms.Design.ParentControlDesigner.GetGlyphs(System.Windows.Forms.Design.Behavior.GlyphSelectionType selectionType) -> System.Windows.Forms.Design.Behavior.GlyphCollection ~override System.Windows.Forms.Design.ParentControlDesigner.Initialize(System.ComponentModel.IComponent component) -> void @@ -146,14 +120,13 @@ ~static readonly System.Windows.Forms.Design.MenuCommands.SetStatusRectangle -> System.ComponentModel.Design.CommandID ~static readonly System.Windows.Forms.Design.MenuCommands.SetStatusText -> System.ComponentModel.Design.CommandID ~static readonly System.Windows.Forms.Design.MenuCommands.TraySelectionMenu -> System.ComponentModel.Design.CommandID -~static System.ComponentModel.Design.ObjectSelectorEditor.ApplyTreeViewThemeStyles(System.Windows.Forms.TreeView treeView) -> void ~static System.Resources.Tools.StronglyTypedResourceBuilder.Create(string resxFile, string baseName, string generatedCodeNamespace, string resourcesNamespace, System.CodeDom.Compiler.CodeDomProvider codeProvider, bool internalClass, out string[] unmatchable) -> System.CodeDom.CodeCompileUnit ~static System.Resources.Tools.StronglyTypedResourceBuilder.Create(string resxFile, string baseName, string generatedCodeNamespace, System.CodeDom.Compiler.CodeDomProvider codeProvider, bool internalClass, out string[] unmatchable) -> System.CodeDom.CodeCompileUnit ~static System.Resources.Tools.StronglyTypedResourceBuilder.Create(System.Collections.IDictionary resourceList, string baseName, string generatedCodeNamespace, string resourcesNamespace, System.CodeDom.Compiler.CodeDomProvider codeProvider, bool internalClass, out string[] unmatchable) -> System.CodeDom.CodeCompileUnit ~static System.Resources.Tools.StronglyTypedResourceBuilder.Create(System.Collections.IDictionary resourceList, string baseName, string generatedCodeNamespace, System.CodeDom.Compiler.CodeDomProvider codeProvider, bool internalClass, out string[] unmatchable) -> System.CodeDom.CodeCompileUnit ~static System.Resources.Tools.StronglyTypedResourceBuilder.VerifyResourceName(string key, System.CodeDom.Compiler.CodeDomProvider provider) -> string -~static System.Windows.Forms.Design.MaskDescriptor.IsValidMaskDescriptor(System.Windows.Forms.Design.MaskDescriptor maskDescriptor) -> bool -~static System.Windows.Forms.Design.MaskDescriptor.IsValidMaskDescriptor(System.Windows.Forms.Design.MaskDescriptor maskDescriptor, out string validationErrorDescription) -> bool +static System.Windows.Forms.Design.MaskDescriptor.IsValidMaskDescriptor(System.Windows.Forms.Design.MaskDescriptor? maskDescriptor) -> bool +static System.Windows.Forms.Design.MaskDescriptor.IsValidMaskDescriptor(System.Windows.Forms.Design.MaskDescriptor? maskDescriptor, out string! validationErrorDescription) -> bool ~static System.Windows.Forms.Design.ParentControlDesigner.InvokeCreateTool(System.Windows.Forms.Design.ParentControlDesigner toInvoke, System.Drawing.Design.ToolboxItem tool) -> void ~System.ComponentModel.Design.ArrayEditor.ArrayEditor(System.Type type) -> void ~System.ComponentModel.Design.CollectionEditor.CollectionEditor(System.Type type) -> void @@ -178,62 +151,36 @@ ~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, string category, string description, bool includeAsDesignerVerb) -> void ~System.ComponentModel.Design.DesignerActionMethodItem.RelatedComponent.get -> System.ComponentModel.IComponent ~System.ComponentModel.Design.DesignerActionMethodItem.RelatedComponent.set -> void -~System.ComponentModel.Design.DesignerActionService.Add(System.ComponentModel.IComponent comp, System.ComponentModel.Design.DesignerActionList actionList) -> void -~System.ComponentModel.Design.DesignerActionService.Add(System.ComponentModel.IComponent comp, System.ComponentModel.Design.DesignerActionListCollection designerActionListCollection) -> void -~System.ComponentModel.Design.DesignerActionService.Contains(System.ComponentModel.IComponent comp) -> bool -~System.ComponentModel.Design.DesignerActionService.DesignerActionService(System.IServiceProvider serviceProvider) -> void -~System.ComponentModel.Design.DesignerActionService.GetComponentActions(System.ComponentModel.IComponent component) -> System.ComponentModel.Design.DesignerActionListCollection -~System.ComponentModel.Design.DesignerActionService.Remove(System.ComponentModel.Design.DesignerActionList actionList) -> void -~System.ComponentModel.Design.DesignerActionService.Remove(System.ComponentModel.IComponent comp) -> void -~System.ComponentModel.Design.DesignerActionService.Remove(System.ComponentModel.IComponent comp, System.ComponentModel.Design.DesignerActionList actionList) -> void -~System.ComponentModel.Design.DesignerActionUIService.HideUI(System.ComponentModel.IComponent component) -> void -~System.ComponentModel.Design.DesignerActionUIService.Refresh(System.ComponentModel.IComponent component) -> void -~System.ComponentModel.Design.DesignerActionUIService.ShouldAutoShow(System.ComponentModel.IComponent component) -> bool -~System.ComponentModel.Design.DesignerActionUIService.ShowUI(System.ComponentModel.IComponent component) -> void -~System.ComponentModel.Design.DesignerActionUIStateChangeEventArgs.DesignerActionUIStateChangeEventArgs(object relatedObject, System.ComponentModel.Design.DesignerActionUIStateChangeType changeType) -> void -~System.ComponentModel.Design.DesignerActionUIStateChangeEventArgs.RelatedObject.get -> object -~System.ComponentModel.Design.EventBindingService.EventBindingService(System.IServiceProvider provider) -> void -~System.ComponentModel.Design.EventBindingService.GetService(System.Type serviceType) -> object -~System.ComponentModel.Design.InheritanceService.AddInheritedComponents(System.ComponentModel.IComponent component, System.ComponentModel.IContainer container) -> void -~System.ComponentModel.Design.InheritanceService.GetInheritanceAttribute(System.ComponentModel.IComponent component) -> System.ComponentModel.InheritanceAttribute -~System.ComponentModel.Design.LoadedEventArgs.Errors.get -> System.Collections.ICollection -~System.ComponentModel.Design.LoadedEventArgs.LoadedEventArgs(bool succeeded, System.Collections.ICollection errors) -> void +System.ComponentModel.Design.DesignerActionService.Add(System.ComponentModel.IComponent! comp, System.ComponentModel.Design.DesignerActionList! actionList) -> void +System.ComponentModel.Design.DesignerActionService.Add(System.ComponentModel.IComponent! comp, System.ComponentModel.Design.DesignerActionListCollection! designerActionListCollection) -> void +System.ComponentModel.Design.DesignerActionService.Contains(System.ComponentModel.IComponent! comp) -> bool +System.ComponentModel.Design.DesignerActionService.DesignerActionService(System.IServiceProvider? serviceProvider) -> void +System.ComponentModel.Design.DesignerActionService.GetComponentActions(System.ComponentModel.IComponent! component) -> System.ComponentModel.Design.DesignerActionListCollection! +System.ComponentModel.Design.DesignerActionService.Remove(System.ComponentModel.Design.DesignerActionList! actionList) -> void +System.ComponentModel.Design.DesignerActionService.Remove(System.ComponentModel.IComponent! comp) -> void +System.ComponentModel.Design.DesignerActionService.Remove(System.ComponentModel.IComponent! comp, System.ComponentModel.Design.DesignerActionList! actionList) -> void +System.ComponentModel.Design.DesignerActionUIService.HideUI(System.ComponentModel.IComponent? component) -> void +System.ComponentModel.Design.DesignerActionUIService.Refresh(System.ComponentModel.IComponent? component) -> void +System.ComponentModel.Design.DesignerActionUIService.ShouldAutoShow(System.ComponentModel.IComponent! component) -> bool +System.ComponentModel.Design.DesignerActionUIService.ShowUI(System.ComponentModel.IComponent? component) -> void +System.ComponentModel.Design.DesignerActionUIStateChangeEventArgs.DesignerActionUIStateChangeEventArgs(object? relatedObject, System.ComponentModel.Design.DesignerActionUIStateChangeType changeType) -> void +System.ComponentModel.Design.DesignerActionUIStateChangeEventArgs.RelatedObject.get -> object? +System.ComponentModel.Design.EventBindingService.EventBindingService(System.IServiceProvider! provider) -> void +System.ComponentModel.Design.EventBindingService.GetService(System.Type! serviceType) -> object? ~System.ComponentModel.Design.MenuCommandService.FindCommand(System.ComponentModel.Design.CommandID commandID) -> System.ComponentModel.Design.MenuCommand ~System.ComponentModel.Design.MenuCommandService.FindCommand(System.Guid guid, int id) -> System.ComponentModel.Design.MenuCommand ~System.ComponentModel.Design.MenuCommandService.GetCommandList(System.Guid guid) -> System.Collections.ICollection ~System.ComponentModel.Design.MenuCommandService.GetService(System.Type serviceType) -> object ~System.ComponentModel.Design.MenuCommandService.MenuCommandService(System.IServiceProvider serviceProvider) -> void -~System.ComponentModel.Design.ObjectSelectorEditor.currValue -> object -~System.ComponentModel.Design.ObjectSelectorEditor.EqualsToValue(object value) -> bool -~System.ComponentModel.Design.ObjectSelectorEditor.prevValue -> object -~System.ComponentModel.Design.ObjectSelectorEditor.Selector.AddNode(string label, object value, System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode parent) -> System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode -~System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnAfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) -> void -~System.ComponentModel.Design.ObjectSelectorEditor.Selector.Selector(System.ComponentModel.Design.ObjectSelectorEditor editor) -> void -~System.ComponentModel.Design.ObjectSelectorEditor.Selector.SetSelection(object value, System.Windows.Forms.TreeNodeCollection nodes) -> bool -~System.ComponentModel.Design.ObjectSelectorEditor.Selector.Start(System.Windows.Forms.Design.IWindowsFormsEditorService edSvc, object value) -> void -~System.ComponentModel.Design.Serialization.BasicDesignerLoader.GetService(System.Type serviceType) -> object -~System.ComponentModel.Design.Serialization.BasicDesignerLoader.LoaderHost.get -> System.ComponentModel.Design.Serialization.IDesignerLoaderHost -~System.ComponentModel.Design.Serialization.BasicDesignerLoader.PropertyProvider.get -> object -~System.ComponentModel.Design.Serialization.BasicDesignerLoader.PropertyProvider.set -> void -~System.ComponentModel.Design.Serialization.BasicDesignerLoader.SetBaseComponentClassName(string name) -> void +System.ComponentModel.Design.Serialization.BasicDesignerLoader.GetService(System.Type! serviceType) -> object? +System.ComponentModel.Design.Serialization.BasicDesignerLoader.LoaderHost.get -> System.ComponentModel.Design.Serialization.IDesignerLoaderHost! +System.ComponentModel.Design.Serialization.BasicDesignerLoader.PropertyProvider.get -> object? +System.ComponentModel.Design.Serialization.BasicDesignerLoader.PropertyProvider.set -> void +System.ComponentModel.Design.Serialization.BasicDesignerLoader.SetBaseComponentClassName(string! name) -> void ~System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.CodeDomComponentSerializationService(System.IServiceProvider provider) -> void ~System.ComponentModel.Design.Serialization.CodeDomLocalizationProvider.CodeDomLocalizationProvider(System.IServiceProvider provider, System.ComponentModel.Design.Serialization.CodeDomLocalizationModel model) -> void ~System.ComponentModel.Design.Serialization.CodeDomLocalizationProvider.CodeDomLocalizationProvider(System.IServiceProvider provider, System.ComponentModel.Design.Serialization.CodeDomLocalizationModel model, System.Globalization.CultureInfo[] supportedCultures) -> void -~System.ComponentModel.Design.Serialization.CodeDomSerializer.DeserializeStatementToInstance(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeStatement statement) -> object -~System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeToReferenceExpression(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value) -> System.CodeDom.CodeExpression -~System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(string message, System.CodeDom.CodeLinePragma linePragma) -> void -~System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(string message, System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager) -> void -~System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(System.Exception ex, System.CodeDom.CodeLinePragma linePragma) -> void -~System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(System.Exception ex, System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager) -> void -~System.ComponentModel.Design.Serialization.CodeDomSerializerException.LinePragma.get -> System.CodeDom.CodeLinePragma ~System.ComponentModel.Design.Serialization.CollectionCodeDomSerializer.MethodSupportsSerialization(System.Reflection.MethodInfo method) -> bool -~System.ComponentModel.Design.UndoEngine.GetRequiredService(System.Type serviceType) -> object -~System.ComponentModel.Design.UndoEngine.GetService(System.Type serviceType) -> object -~System.ComponentModel.Design.UndoEngine.UndoEngine(System.IServiceProvider provider) -> void -~System.ComponentModel.Design.UndoEngine.UndoUnit.GetService(System.Type serviceType) -> object -~System.ComponentModel.Design.UndoEngine.UndoUnit.Name.get -> string -~System.ComponentModel.Design.UndoEngine.UndoUnit.UndoEngine.get -> System.ComponentModel.Design.UndoEngine -~System.ComponentModel.Design.UndoEngine.UndoUnit.UndoUnit(System.ComponentModel.Design.UndoEngine engine, string name) -> void ~System.Drawing.Design.IToolboxService.AddCreator(System.Drawing.Design.ToolboxItemCreatorCallback creator, string format) -> void ~System.Drawing.Design.IToolboxService.AddCreator(System.Drawing.Design.ToolboxItemCreatorCallback creator, string format, System.ComponentModel.Design.IDesignerHost host) -> void ~System.Drawing.Design.IToolboxService.AddLinkedToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, string category, System.ComponentModel.Design.IDesignerHost host) -> void @@ -296,18 +243,6 @@ ~System.Drawing.Design.ToolboxItemCollection.this[int index].get -> System.Drawing.Design.ToolboxItem ~System.Drawing.Design.ToolboxItemCollection.ToolboxItemCollection(System.Drawing.Design.ToolboxItem[] value) -> void ~System.Drawing.Design.ToolboxItemCollection.ToolboxItemCollection(System.Drawing.Design.ToolboxItemCollection value) -> void -~System.Windows.Forms.Design.AxImporter.AxImporter(System.Windows.Forms.Design.AxImporter.Options options) -> void -~System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveActiveXReference(System.Runtime.InteropServices.UCOMITypeLib typeLib) -> string -~System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveComReference(System.Reflection.AssemblyName name) -> string -~System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveComReference(System.Runtime.InteropServices.UCOMITypeLib typeLib) -> string -~System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveManagedReference(string assemName) -> string -~System.Windows.Forms.Design.AxImporter.Options.keyContainer -> string -~System.Windows.Forms.Design.AxImporter.Options.keyFile -> string -~System.Windows.Forms.Design.AxImporter.Options.keyPair -> System.Reflection.StrongNameKeyPair -~System.Windows.Forms.Design.AxImporter.Options.outputDirectory -> string -~System.Windows.Forms.Design.AxImporter.Options.outputName -> string -~System.Windows.Forms.Design.AxImporter.Options.publicKey -> byte[] -~System.Windows.Forms.Design.AxImporter.Options.references -> System.Windows.Forms.Design.AxImporter.IReferenceResolver ~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.Add(System.Windows.Forms.Design.Behavior.Adorner value) -> int ~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.AddRange(System.Windows.Forms.Design.Behavior.Adorner[] value) -> void ~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.AddRange(System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection value) -> void @@ -351,15 +286,6 @@ ~System.Windows.Forms.Design.ControlDesigner.EnableDesignMode(System.Windows.Forms.Control child, string name) -> bool ~System.Windows.Forms.Design.ControlDesigner.HookChildControls(System.Windows.Forms.Control firstChild) -> void ~System.Windows.Forms.Design.ControlDesigner.UnhookChildControls(System.Windows.Forms.Control firstChild) -> void -~System.Windows.Forms.Design.EventHandlerService.EventHandlerService(System.Windows.Forms.Control focusWnd) -> void -~System.Windows.Forms.Design.EventHandlerService.FocusWindow.get -> System.Windows.Forms.Control -~System.Windows.Forms.Design.EventHandlerService.GetHandler(System.Type handlerType) -> object -~System.Windows.Forms.Design.EventHandlerService.PopHandler(object handler) -> void -~System.Windows.Forms.Design.EventHandlerService.PushHandler(object handler) -> void -~System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.Description.get -> string -~System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.Description.set -> void -~System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.DirectoryPath.get -> string -~System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.ShowDialog(System.Windows.Forms.IWin32Window owner) -> System.Windows.Forms.DialogResult ~System.Windows.Forms.Design.ParentControlDesigner.AddPaddingSnapLines(ref System.Collections.ArrayList snapLines) -> void ~System.Windows.Forms.Design.ParentControlDesigner.CreateTool(System.Drawing.Design.ToolboxItem tool) -> void ~System.Windows.Forms.Design.ParentControlDesigner.CreateTool(System.Drawing.Design.ToolboxItem tool, System.Drawing.Point location) -> void @@ -398,14 +324,12 @@ ~virtual System.ComponentModel.Design.ComponentDesigner.PreFilterProperties(System.Collections.IDictionary properties) -> void ~virtual System.ComponentModel.Design.ComponentDesigner.Verbs.get -> System.ComponentModel.Design.DesignerVerbCollection ~virtual System.ComponentModel.Design.DesignerActionMethodItem.MemberName.get -> string -~virtual System.ComponentModel.Design.DesignerActionService.GetComponentActions(System.ComponentModel.IComponent component, System.Windows.Forms.Design.ComponentActionsType type) -> System.ComponentModel.Design.DesignerActionListCollection -~virtual System.ComponentModel.Design.DesignerActionService.GetComponentDesignerActions(System.ComponentModel.IComponent component, System.ComponentModel.Design.DesignerActionListCollection actionLists) -> void -~virtual System.ComponentModel.Design.DesignerActionService.GetComponentServiceActions(System.ComponentModel.IComponent component, System.ComponentModel.Design.DesignerActionListCollection actionLists) -> void -~virtual System.ComponentModel.Design.EventBindingService.FreeMethod(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor e, string methodName) -> void -~virtual System.ComponentModel.Design.EventBindingService.UseMethod(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor e, string methodName) -> void -~virtual System.ComponentModel.Design.EventBindingService.ValidateMethodName(string methodName) -> void -~virtual System.ComponentModel.Design.InheritanceService.AddInheritedComponents(System.Type type, System.ComponentModel.IComponent component, System.ComponentModel.IContainer container) -> void -~virtual System.ComponentModel.Design.InheritanceService.IgnoreInheritedMember(System.Reflection.MemberInfo member, System.ComponentModel.IComponent component) -> bool +virtual System.ComponentModel.Design.DesignerActionService.GetComponentActions(System.ComponentModel.IComponent! component, System.Windows.Forms.Design.ComponentActionsType type) -> System.ComponentModel.Design.DesignerActionListCollection! +virtual System.ComponentModel.Design.DesignerActionService.GetComponentDesignerActions(System.ComponentModel.IComponent! component, System.ComponentModel.Design.DesignerActionListCollection! actionLists) -> void +virtual System.ComponentModel.Design.DesignerActionService.GetComponentServiceActions(System.ComponentModel.IComponent! component, System.ComponentModel.Design.DesignerActionListCollection! actionLists) -> void +virtual System.ComponentModel.Design.EventBindingService.FreeMethod(System.ComponentModel.IComponent! component, System.ComponentModel.EventDescriptor! e, string! methodName) -> void +virtual System.ComponentModel.Design.EventBindingService.UseMethod(System.ComponentModel.IComponent! component, System.ComponentModel.EventDescriptor! e, string! methodName) -> void +virtual System.ComponentModel.Design.EventBindingService.ValidateMethodName(string! methodName) -> void ~virtual System.ComponentModel.Design.MenuCommandService.AddCommand(System.ComponentModel.Design.MenuCommand command) -> void ~virtual System.ComponentModel.Design.MenuCommandService.AddVerb(System.ComponentModel.Design.DesignerVerb verb) -> void ~virtual System.ComponentModel.Design.MenuCommandService.GlobalInvoke(System.ComponentModel.Design.CommandID commandID) -> bool @@ -415,33 +339,14 @@ ~virtual System.ComponentModel.Design.MenuCommandService.RemoveVerb(System.ComponentModel.Design.DesignerVerb verb) -> void ~virtual System.ComponentModel.Design.MenuCommandService.ShowContextMenu(System.ComponentModel.Design.CommandID menuID, int x, int y) -> void ~virtual System.ComponentModel.Design.MenuCommandService.Verbs.get -> System.ComponentModel.Design.DesignerVerbCollection -~virtual System.ComponentModel.Design.ObjectSelectorEditor.FillTreeWithData(System.ComponentModel.Design.ObjectSelectorEditor.Selector selector, System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider) -> void -~virtual System.ComponentModel.Design.ObjectSelectorEditor.SetValue(object value) -> void -~virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.OnEndLoad(bool successful, System.Collections.ICollection errors) -> void -~virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.ReportFlushErrors(System.Collections.ICollection errors) -> void -~virtual System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.OnComponentRename(object component, string oldName, string newName) -> void -~virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.Deserialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object codeObject) -> object -~virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.GetTargetComponentName(System.CodeDom.CodeStatement statement, System.CodeDom.CodeExpression expression, System.Type targetType) -> string -~virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value) -> object -~virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeAbsolute(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object value) -> object -~virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeMember(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object owningObject, System.ComponentModel.MemberDescriptor member) -> System.CodeDom.CodeStatementCollection -~virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeMemberAbsolute(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object owningObject, System.ComponentModel.MemberDescriptor member) -> System.CodeDom.CodeStatementCollection +virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.OnEndLoad(bool successful, System.Collections.ICollection? errors) -> void +virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.ReportFlushErrors(System.Collections.ICollection! errors) -> void +virtual System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.OnComponentRename(object! component, string? oldName, string? newName) -> void ~virtual System.ComponentModel.Design.Serialization.CollectionCodeDomSerializer.SerializeCollection(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeExpression targetExpression, System.Type targetType, System.Collections.ICollection originalCollection, System.Collections.ICollection valuesToSerialize) -> object ~virtual System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeTypeDeclaration declaration) -> object ~virtual System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.GetInitializeMethod(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeTypeDeclaration declaration, object value) -> System.CodeDom.CodeMemberMethod ~virtual System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.GetInitializeMethods(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, System.CodeDom.CodeTypeDeclaration declaration) -> System.CodeDom.CodeMemberMethod[] ~virtual System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager, object root, System.Collections.ICollection members) -> System.CodeDom.CodeTypeDeclaration -~virtual System.ComponentModel.Design.UndoEngine.CreateUndoUnit(string name, bool primary) -> System.ComponentModel.Design.UndoEngine.UndoUnit -~virtual System.ComponentModel.Design.UndoEngine.DiscardUndoUnit(System.ComponentModel.Design.UndoEngine.UndoUnit unit) -> void -~virtual System.ComponentModel.Design.UndoEngine.OnUndoing(System.EventArgs e) -> void -~virtual System.ComponentModel.Design.UndoEngine.OnUndone(System.EventArgs e) -> void -~virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentAdded(System.ComponentModel.Design.ComponentEventArgs e) -> void -~virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentAdding(System.ComponentModel.Design.ComponentEventArgs e) -> void -~virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentChanged(System.ComponentModel.Design.ComponentChangedEventArgs e) -> void -~virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentChanging(System.ComponentModel.Design.ComponentChangingEventArgs e) -> void -~virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentRemoved(System.ComponentModel.Design.ComponentEventArgs e) -> void -~virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentRemoving(System.ComponentModel.Design.ComponentEventArgs e) -> void -~virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentRename(System.ComponentModel.Design.ComponentRenameEventArgs e) -> void ~virtual System.Drawing.Design.ToolboxItem.ComponentType.get -> string ~virtual System.Drawing.Design.ToolboxItem.CreateComponentsCore(System.ComponentModel.Design.IDesignerHost host) -> System.ComponentModel.IComponent[] ~virtual System.Drawing.Design.ToolboxItem.CreateComponentsCore(System.ComponentModel.Design.IDesignerHost host, System.Collections.IDictionary defaultValues) -> System.ComponentModel.IComponent[] @@ -475,9 +380,7 @@ ~virtual System.Windows.Forms.Design.ControlDesigner.SnapLines.get -> System.Collections.IList ~virtual System.Windows.Forms.Design.DocumentDesigner.GetToolSupported(System.Drawing.Design.ToolboxItem tool) -> bool ~virtual System.Windows.Forms.Design.DocumentDesigner.ToolPicked(System.Drawing.Design.ToolboxItem tool) -> void -~virtual System.Windows.Forms.Design.FileNameEditor.InitializeDialog(System.Windows.Forms.OpenFileDialog openFileDialog) -> void -~virtual System.Windows.Forms.Design.FolderNameEditor.InitializeDialog(System.Windows.Forms.Design.FolderNameEditor.FolderBrowser folderBrowser) -> void -~virtual System.Windows.Forms.Design.MaskDescriptor.Culture.get -> System.Globalization.CultureInfo +virtual System.Windows.Forms.Design.MaskDescriptor.Culture.get -> System.Globalization.CultureInfo! ~virtual System.Windows.Forms.Design.ParentControlDesigner.CanAddComponent(System.ComponentModel.IComponent component) -> bool ~virtual System.Windows.Forms.Design.ParentControlDesigner.CanParent(System.Windows.Forms.Control control) -> bool ~virtual System.Windows.Forms.Design.ParentControlDesigner.CanParent(System.Windows.Forms.Design.ControlDesigner controlDesigner) -> bool @@ -487,6 +390,7 @@ abstract System.ComponentModel.Design.CollectionEditor.CollectionForm.OnEditValueChanged() -> void abstract System.ComponentModel.Design.EventBindingService.ShowCode() -> bool abstract System.ComponentModel.Design.EventBindingService.ShowCode(int lineNumber) -> bool +abstract System.ComponentModel.Design.UndoEngine.AddUndoUnit(System.ComponentModel.Design.UndoEngine.UndoUnit! unit) -> void abstract System.Windows.Forms.Design.Behavior.Glyph.GetHitTest(System.Drawing.Point p) -> System.Windows.Forms.Cursor? abstract System.Windows.Forms.Design.Behavior.Glyph.Paint(System.Windows.Forms.PaintEventArgs! pe) -> void override System.ComponentModel.Design.CollectionEditor.CollectionForm.GetService(System.Type! serviceType) -> object! @@ -495,6 +399,11 @@ override System.ComponentModel.Design.ExceptionCollection.GetObjectData(System.R override System.ComponentModel.Design.MultilineStringEditor.EditValue(System.ComponentModel.ITypeDescriptorContext? context, System.IServiceProvider! provider, object? value) -> object? override System.ComponentModel.Design.MultilineStringEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext? context) -> System.Drawing.Design.UITypeEditorEditStyle override System.ComponentModel.Design.MultilineStringEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext? context) -> bool +override System.ComponentModel.Design.ObjectSelectorEditor.EditValue(System.ComponentModel.ITypeDescriptorContext? context, System.IServiceProvider! provider, object? value) -> object? +override System.ComponentModel.Design.ObjectSelectorEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext? context) -> System.Drawing.Design.UITypeEditorEditStyle +override System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnKeyDown(System.Windows.Forms.KeyEventArgs! e) -> void +override System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnKeyPress(System.Windows.Forms.KeyPressEventArgs! e) -> void +override System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnNodeMouseClick(System.Windows.Forms.TreeNodeMouseClickEventArgs! e) -> void override System.ComponentModel.Design.ObjectSelectorEditor.Selector.WndProc(ref System.Windows.Forms.Message m) -> void override System.ComponentModel.Design.Serialization.BasicDesignerLoader.Dispose() -> void override System.ComponentModel.Design.Serialization.BasicDesignerLoader.Flush() -> void @@ -504,6 +413,8 @@ override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.Initia override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.IsReloadNeeded() -> bool override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.OnBeginLoad() -> void override System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.OnBeginUnload() -> void +override System.ComponentModel.Design.Serialization.CodeDomSerializerException.GetObjectData(System.Runtime.Serialization.SerializationInfo! info, System.Runtime.Serialization.StreamingContext context) -> void +override System.ComponentModel.Design.UndoEngine.UndoUnit.ToString() -> string! override System.Drawing.Design.BitmapEditor.GetExtensions() -> string![]! override System.Drawing.Design.BitmapEditor.GetFileDialogDescription() -> string! override System.Drawing.Design.BitmapEditor.LoadFromStream(System.IO.Stream! stream) -> System.Drawing.Image! @@ -511,7 +422,15 @@ override System.Drawing.Design.ColorEditor.EditValue(System.ComponentModel.IType override System.Drawing.Design.ColorEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext? context) -> System.Drawing.Design.UITypeEditorEditStyle override System.Drawing.Design.ColorEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext? context) -> bool override System.Drawing.Design.ColorEditor.PaintValue(System.Drawing.Design.PaintValueEventArgs! e) -> void +override System.Drawing.Design.ContentAlignmentEditor.EditValue(System.ComponentModel.ITypeDescriptorContext? context, System.IServiceProvider! provider, object? value) -> object? +override System.Drawing.Design.ContentAlignmentEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext? context) -> System.Drawing.Design.UITypeEditorEditStyle +override System.Drawing.Design.CursorEditor.EditValue(System.ComponentModel.ITypeDescriptorContext? context, System.IServiceProvider! provider, object? value) -> object? +override System.Drawing.Design.CursorEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext? context) -> System.Drawing.Design.UITypeEditorEditStyle override System.Drawing.Design.CursorEditor.IsDropDownResizable.get -> bool +override System.Drawing.Design.FontEditor.EditValue(System.ComponentModel.ITypeDescriptorContext? context, System.IServiceProvider! provider, object? value) -> object? +override System.Drawing.Design.FontEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext? context) -> System.Drawing.Design.UITypeEditorEditStyle +override System.Drawing.Design.FontNameEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext? context) -> bool +override System.Drawing.Design.FontNameEditor.PaintValue(System.Drawing.Design.PaintValueEventArgs! e) -> void override System.Drawing.Design.IconEditor.EditValue(System.ComponentModel.ITypeDescriptorContext? context, System.IServiceProvider! provider, object? value) -> object? override System.Drawing.Design.IconEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext? context) -> System.Drawing.Design.UITypeEditorEditStyle override System.Drawing.Design.IconEditor.GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext? context) -> bool @@ -529,6 +448,8 @@ override System.Windows.Forms.Design.Behavior.ComponentGlyph.Paint(System.Window override System.Windows.Forms.Design.Behavior.ControlBodyGlyph.Bounds.get -> System.Drawing.Rectangle override System.Windows.Forms.Design.Behavior.ControlBodyGlyph.GetHitTest(System.Drawing.Point p) -> System.Windows.Forms.Cursor? override System.Windows.Forms.Design.Behavior.SnapLine.ToString() -> string! +override System.Windows.Forms.Design.BorderSidesEditor.EditValue(System.ComponentModel.ITypeDescriptorContext? context, System.IServiceProvider! provider, object? value) -> object? +override System.Windows.Forms.Design.BorderSidesEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext? context) -> System.Drawing.Design.UITypeEditorEditStyle override System.Windows.Forms.Design.ComponentDocumentDesigner.Dispose(bool disposing) -> void override System.Windows.Forms.Design.ComponentTray.Dispose(bool disposing) -> void override System.Windows.Forms.Design.ComponentTray.WndProc(ref System.Windows.Forms.Message m) -> void @@ -547,10 +468,18 @@ override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleOb override System.Windows.Forms.Design.ControlDesigner.ControlDesignerAccessibleObject.Value.get -> string? override System.Windows.Forms.Design.ControlDesigner.Dispose(bool disposing) -> void override System.Windows.Forms.Design.ControlDesigner.OnSetComponentDefaults() -> void +override System.Windows.Forms.Design.DockEditor.EditValue(System.ComponentModel.ITypeDescriptorContext? context, System.IServiceProvider! provider, object? value) -> object? +override System.Windows.Forms.Design.DockEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext? context) -> System.Drawing.Design.UITypeEditorEditStyle override System.Windows.Forms.Design.DocumentDesigner.Dispose(bool disposing) -> void override System.Windows.Forms.Design.DocumentDesigner.OnContextMenu(int x, int y) -> void override System.Windows.Forms.Design.DocumentDesigner.OnCreateHandle() -> void override System.Windows.Forms.Design.DocumentDesigner.SelectionRules.get -> System.Windows.Forms.Design.SelectionRules +override System.Windows.Forms.Design.FileNameEditor.EditValue(System.ComponentModel.ITypeDescriptorContext? context, System.IServiceProvider! provider, object? value) -> object? +override System.Windows.Forms.Design.FileNameEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext? context) -> System.Drawing.Design.UITypeEditorEditStyle +override System.Windows.Forms.Design.FolderNameEditor.EditValue(System.ComponentModel.ITypeDescriptorContext? context, System.IServiceProvider! provider, object? value) -> object? +override System.Windows.Forms.Design.FolderNameEditor.GetEditStyle(System.ComponentModel.ITypeDescriptorContext? context) -> System.Drawing.Design.UITypeEditorEditStyle +override System.Windows.Forms.Design.ImageListCodeDomSerializer.Deserialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager! manager, object! codeObject) -> object? +override System.Windows.Forms.Design.ImageListCodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager! manager, object! value) -> object? override System.Windows.Forms.Design.ImageListImageEditor.EditValue(System.ComponentModel.ITypeDescriptorContext? context, System.IServiceProvider! provider, object? value) -> object? override System.Windows.Forms.Design.ImageListImageEditor.GetFileDialogDescription() -> string! override System.Windows.Forms.Design.ImageListImageEditor.GetImageExtenders() -> System.Type![]! @@ -566,6 +495,7 @@ override System.Windows.Forms.Design.ParentControlDesigner.OnSetCursor() -> void override System.Windows.Forms.Design.ScrollableControlDesigner.GetHitTest(System.Drawing.Point pt) -> bool override System.Windows.Forms.Design.ScrollableControlDesigner.WndProc(ref System.Windows.Forms.Message m) -> void static readonly System.Windows.Forms.Design.ControlDesigner.InvalidPoint -> System.Drawing.Point +static System.ComponentModel.Design.ObjectSelectorEditor.ApplyTreeViewThemeStyles(System.Windows.Forms.TreeView! treeView) -> void static System.Drawing.Design.BitmapEditor.BitmapExtensions -> System.Collections.Generic.List! static System.Drawing.Design.IconEditor.CreateExtensionsString(string?[]? extensions, string! sep) -> string? static System.Drawing.Design.IconEditor.CreateFilterEntry(System.Drawing.Design.IconEditor! editor) -> string! @@ -659,12 +589,12 @@ System.ComponentModel.Design.DesignerActionPropertyItem.RelatedComponent.get -> System.ComponentModel.Design.DesignerActionPropertyItem.RelatedComponent.set -> void System.ComponentModel.Design.DesignerActionService System.ComponentModel.Design.DesignerActionService.Clear() -> void -System.ComponentModel.Design.DesignerActionService.DesignerActionListsChanged -> System.ComponentModel.Design.DesignerActionListsChangedEventHandler +System.ComponentModel.Design.DesignerActionService.DesignerActionListsChanged -> System.ComponentModel.Design.DesignerActionListsChangedEventHandler? System.ComponentModel.Design.DesignerActionService.Dispose() -> void System.ComponentModel.Design.DesignerActionTextItem System.ComponentModel.Design.DesignerActionTextItem.DesignerActionTextItem(string? displayName, string? category) -> void System.ComponentModel.Design.DesignerActionUIService -System.ComponentModel.Design.DesignerActionUIService.DesignerActionUIStateChange -> System.ComponentModel.Design.DesignerActionUIStateChangeEventHandler +System.ComponentModel.Design.DesignerActionUIService.DesignerActionUIStateChange -> System.ComponentModel.Design.DesignerActionUIStateChangeEventHandler? System.ComponentModel.Design.DesignerActionUIService.Dispose() -> void System.ComponentModel.Design.DesignerActionUIStateChangeEventArgs System.ComponentModel.Design.DesignerActionUIStateChangeEventArgs.ChangeType.get -> System.ComponentModel.Design.DesignerActionUIStateChangeType @@ -737,10 +667,14 @@ System.ComponentModel.Design.ExceptionCollection.Exceptions.get -> System.Collec System.ComponentModel.Design.IMultitargetHelperService System.ComponentModel.Design.IMultitargetHelperService.GetAssemblyQualifiedName(System.Type! type) -> string! System.ComponentModel.Design.InheritanceService +System.ComponentModel.Design.InheritanceService.AddInheritedComponents(System.ComponentModel.IComponent! component, System.ComponentModel.IContainer! container) -> void System.ComponentModel.Design.InheritanceService.Dispose() -> void +System.ComponentModel.Design.InheritanceService.GetInheritanceAttribute(System.ComponentModel.IComponent! component) -> System.ComponentModel.InheritanceAttribute! System.ComponentModel.Design.InheritanceService.InheritanceService() -> void System.ComponentModel.Design.LoadedEventArgs +System.ComponentModel.Design.LoadedEventArgs.Errors.get -> System.Collections.ICollection! System.ComponentModel.Design.LoadedEventArgs.HasSucceeded.get -> bool +System.ComponentModel.Design.LoadedEventArgs.LoadedEventArgs(bool succeeded, System.Collections.ICollection? errors) -> void System.ComponentModel.Design.LoadedEventHandler System.ComponentModel.Design.MenuCommandsChangedEventArgs System.ComponentModel.Design.MenuCommandsChangedEventArgs.ChangeType.get -> System.ComponentModel.Design.MenuCommandsChangedType @@ -758,14 +692,22 @@ System.ComponentModel.Design.MenuCommandService.MenuCommandsChanged -> System.Co System.ComponentModel.Design.MultilineStringEditor System.ComponentModel.Design.MultilineStringEditor.MultilineStringEditor() -> void System.ComponentModel.Design.ObjectSelectorEditor +System.ComponentModel.Design.ObjectSelectorEditor.currValue -> object? +System.ComponentModel.Design.ObjectSelectorEditor.EqualsToValue(object? value) -> bool System.ComponentModel.Design.ObjectSelectorEditor.ObjectSelectorEditor() -> void System.ComponentModel.Design.ObjectSelectorEditor.ObjectSelectorEditor(bool subObjectSelector) -> void +System.ComponentModel.Design.ObjectSelectorEditor.prevValue -> object? System.ComponentModel.Design.ObjectSelectorEditor.Selector +System.ComponentModel.Design.ObjectSelectorEditor.Selector.AddNode(string? label, object? value, System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode? parent) -> System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode! System.ComponentModel.Design.ObjectSelectorEditor.Selector.Clear() -> void System.ComponentModel.Design.ObjectSelectorEditor.Selector.clickSeen -> bool +System.ComponentModel.Design.ObjectSelectorEditor.Selector.OnAfterSelect(object? sender, System.Windows.Forms.TreeViewEventArgs! e) -> void +System.ComponentModel.Design.ObjectSelectorEditor.Selector.Selector(System.ComponentModel.Design.ObjectSelectorEditor! editor) -> void +System.ComponentModel.Design.ObjectSelectorEditor.Selector.SetSelection(object? value, System.Windows.Forms.TreeNodeCollection? nodes) -> bool +System.ComponentModel.Design.ObjectSelectorEditor.Selector.Start(System.Windows.Forms.Design.IWindowsFormsEditorService! edSvc, object? value) -> void System.ComponentModel.Design.ObjectSelectorEditor.Selector.Stop() -> void System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode -System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode.SelectorNode(string! label, object? value) -> void +System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode.SelectorNode(string? label, object? value) -> void System.ComponentModel.Design.ObjectSelectorEditor.SelectorNode.value -> object? System.ComponentModel.Design.ObjectSelectorEditor.SubObjectSelector -> bool System.ComponentModel.Design.ProjectTargetFrameworkAttribute @@ -792,8 +734,15 @@ System.ComponentModel.Design.Serialization.CodeDomLocalizationProvider System.ComponentModel.Design.Serialization.CodeDomLocalizationProvider.Dispose() -> void System.ComponentModel.Design.Serialization.CodeDomSerializer System.ComponentModel.Design.Serialization.CodeDomSerializer.CodeDomSerializer() -> void +System.ComponentModel.Design.Serialization.CodeDomSerializer.DeserializeStatementToInstance(System.ComponentModel.Design.Serialization.IDesignerSerializationManager! manager, System.CodeDom.CodeStatement! statement) -> object? +System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeToReferenceExpression(System.ComponentModel.Design.Serialization.IDesignerSerializationManager! manager, object! value) -> System.CodeDom.CodeExpression? System.ComponentModel.Design.Serialization.CodeDomSerializerBase System.ComponentModel.Design.Serialization.CodeDomSerializerException +System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(string? message, System.CodeDom.CodeLinePragma? linePragma) -> void +System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(string? message, System.ComponentModel.Design.Serialization.IDesignerSerializationManager! manager) -> void +System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(System.Exception? ex, System.CodeDom.CodeLinePragma? linePragma) -> void +System.ComponentModel.Design.Serialization.CodeDomSerializerException.CodeDomSerializerException(System.Exception? ex, System.ComponentModel.Design.Serialization.IDesignerSerializationManager! manager) -> void +System.ComponentModel.Design.Serialization.CodeDomSerializerException.LinePragma.get -> System.CodeDom.CodeLinePragma? System.ComponentModel.Design.Serialization.CollectionCodeDomSerializer System.ComponentModel.Design.Serialization.CollectionCodeDomSerializer.CollectionCodeDomSerializer() -> void System.ComponentModel.Design.Serialization.DesignerSerializationManager @@ -850,11 +799,18 @@ System.ComponentModel.Design.UndoEngine System.ComponentModel.Design.UndoEngine.Dispose() -> void System.ComponentModel.Design.UndoEngine.Enabled.get -> bool System.ComponentModel.Design.UndoEngine.Enabled.set -> void -System.ComponentModel.Design.UndoEngine.Undoing -> System.EventHandler +System.ComponentModel.Design.UndoEngine.GetRequiredService(System.Type! serviceType) -> object! +System.ComponentModel.Design.UndoEngine.GetService(System.Type! serviceType) -> object? +System.ComponentModel.Design.UndoEngine.UndoEngine(System.IServiceProvider! provider) -> void +System.ComponentModel.Design.UndoEngine.Undoing -> System.EventHandler? System.ComponentModel.Design.UndoEngine.UndoInProgress.get -> bool -System.ComponentModel.Design.UndoEngine.Undone -> System.EventHandler +System.ComponentModel.Design.UndoEngine.Undone -> System.EventHandler? System.ComponentModel.Design.UndoEngine.UndoUnit +System.ComponentModel.Design.UndoEngine.UndoUnit.GetService(System.Type! serviceType) -> object? +System.ComponentModel.Design.UndoEngine.UndoUnit.Name.get -> string! System.ComponentModel.Design.UndoEngine.UndoUnit.Undo() -> void +System.ComponentModel.Design.UndoEngine.UndoUnit.UndoEngine.get -> System.ComponentModel.Design.UndoEngine! +System.ComponentModel.Design.UndoEngine.UndoUnit.UndoUnit(System.ComponentModel.Design.UndoEngine! engine, string? name) -> void System.Drawing.Design.BitmapEditor System.Drawing.Design.BitmapEditor.BitmapEditor() -> void System.Drawing.Design.ColorEditor @@ -952,7 +908,7 @@ System.Windows.Forms.Design.Behavior.BehaviorService.Invalidate() -> void System.Windows.Forms.Design.Behavior.BehaviorService.Invalidate(System.Drawing.Rectangle rect) -> void System.Windows.Forms.Design.Behavior.BehaviorService.Invalidate(System.Drawing.Region! r) -> void System.Windows.Forms.Design.Behavior.BehaviorService.MapAdornerWindowPoint(nint handle, System.Drawing.Point pt) -> System.Drawing.Point -System.Windows.Forms.Design.Behavior.BehaviorService.PopBehavior(System.Windows.Forms.Design.Behavior.Behavior! behavior) -> System.Windows.Forms.Design.Behavior.Behavior? +System.Windows.Forms.Design.Behavior.BehaviorService.PopBehavior(System.Windows.Forms.Design.Behavior.Behavior! behavior) -> System.Windows.Forms.Design.Behavior.Behavior! System.Windows.Forms.Design.Behavior.BehaviorService.PushBehavior(System.Windows.Forms.Design.Behavior.Behavior! behavior) -> void System.Windows.Forms.Design.Behavior.BehaviorService.PushCaptureBehavior(System.Windows.Forms.Design.Behavior.Behavior! behavior) -> void System.Windows.Forms.Design.Behavior.BehaviorService.ScreenToAdornerWindow(System.Drawing.Point p) -> System.Drawing.Point @@ -1038,13 +994,22 @@ System.Windows.Forms.Design.DockEditor.DockEditor() -> void System.Windows.Forms.Design.DocumentDesigner System.Windows.Forms.Design.DocumentDesigner.DocumentDesigner() -> void System.Windows.Forms.Design.EventHandlerService -System.Windows.Forms.Design.EventHandlerService.EventHandlerChanged -> System.EventHandler +System.Windows.Forms.Design.EventHandlerService.EventHandlerChanged -> System.EventHandler? +System.Windows.Forms.Design.EventHandlerService.EventHandlerService(System.Windows.Forms.Control? focusWnd) -> void +System.Windows.Forms.Design.EventHandlerService.FocusWindow.get -> System.Windows.Forms.Control? +System.Windows.Forms.Design.EventHandlerService.GetHandler(System.Type! handlerType) -> object? +System.Windows.Forms.Design.EventHandlerService.PopHandler(object! handler) -> void +System.Windows.Forms.Design.EventHandlerService.PushHandler(object! handler) -> void System.Windows.Forms.Design.FileNameEditor System.Windows.Forms.Design.FileNameEditor.FileNameEditor() -> void System.Windows.Forms.Design.FolderNameEditor System.Windows.Forms.Design.FolderNameEditor.FolderBrowser +System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.Description.get -> string! +System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.Description.set -> void +System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.DirectoryPath.get -> string! System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.FolderBrowser() -> void System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.ShowDialog() -> System.Windows.Forms.DialogResult +System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.ShowDialog(System.Windows.Forms.IWin32Window? owner) -> System.Windows.Forms.DialogResult System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.StartLocation.get -> System.Windows.Forms.Design.FolderNameEditor.FolderBrowserFolder System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.StartLocation.set -> void System.Windows.Forms.Design.FolderNameEditor.FolderBrowser.Style.get -> System.Windows.Forms.Design.FolderNameEditor.FolderBrowserStyles @@ -1146,8 +1111,12 @@ virtual System.ComponentModel.Design.DesignSurfaceManager.ActiveDesignSurface.ge virtual System.ComponentModel.Design.DesignSurfaceManager.ActiveDesignSurface.set -> void virtual System.ComponentModel.Design.DesignSurfaceManager.CreateDesignSurfaceCore(System.IServiceProvider! parentProvider) -> System.ComponentModel.Design.DesignSurface! virtual System.ComponentModel.Design.DesignSurfaceManager.Dispose(bool disposing) -> void +virtual System.ComponentModel.Design.InheritanceService.AddInheritedComponents(System.Type? type, System.ComponentModel.IComponent! component, System.ComponentModel.IContainer! container) -> void virtual System.ComponentModel.Design.InheritanceService.Dispose(bool disposing) -> void +virtual System.ComponentModel.Design.InheritanceService.IgnoreInheritedMember(System.Reflection.MemberInfo! member, System.ComponentModel.IComponent? component) -> bool virtual System.ComponentModel.Design.MenuCommandService.Dispose(bool disposing) -> void +virtual System.ComponentModel.Design.ObjectSelectorEditor.FillTreeWithData(System.ComponentModel.Design.ObjectSelectorEditor.Selector! selector, System.ComponentModel.ITypeDescriptorContext? context, System.IServiceProvider! provider) -> void +virtual System.ComponentModel.Design.ObjectSelectorEditor.SetValue(object? value) -> void virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.EnableComponentNotification(bool enable) -> bool virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.Initialize() -> void virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.IsReloadNeeded() -> bool @@ -1156,14 +1125,31 @@ virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.Modified. virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.OnBeginLoad() -> void virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.OnBeginUnload() -> void virtual System.ComponentModel.Design.Serialization.BasicDesignerLoader.OnModifying() -> void +virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.Deserialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager! manager, object! codeObject) -> object? +virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.GetTargetComponentName(System.CodeDom.CodeStatement? statement, System.CodeDom.CodeExpression? expression, System.Type? targetType) -> string? +virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager! manager, object! value) -> object? +virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeAbsolute(System.ComponentModel.Design.Serialization.IDesignerSerializationManager! manager, object! value) -> object? +virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeMember(System.ComponentModel.Design.Serialization.IDesignerSerializationManager! manager, object! owningObject, System.ComponentModel.MemberDescriptor! member) -> System.CodeDom.CodeStatementCollection! +virtual System.ComponentModel.Design.Serialization.CodeDomSerializer.SerializeMemberAbsolute(System.ComponentModel.Design.Serialization.IDesignerSerializationManager! manager, object! owningObject, System.ComponentModel.MemberDescriptor! member) -> System.CodeDom.CodeStatementCollection! virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(System.Type! type, System.Collections.ICollection? arguments, string? name, bool addToContainer) -> object! virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetService(System.Type! serviceType) -> object? virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetType(string? typeName) -> System.Type? virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.OnResolveName(System.ComponentModel.Design.Serialization.ResolveNameEventArgs! e) -> void virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.OnSessionCreated(System.EventArgs! e) -> void virtual System.ComponentModel.Design.Serialization.DesignerSerializationManager.OnSessionDisposed(System.EventArgs! e) -> void +virtual System.ComponentModel.Design.UndoEngine.CreateUndoUnit(string? name, bool primary) -> System.ComponentModel.Design.UndoEngine.UndoUnit! +virtual System.ComponentModel.Design.UndoEngine.DiscardUndoUnit(System.ComponentModel.Design.UndoEngine.UndoUnit! unit) -> void virtual System.ComponentModel.Design.UndoEngine.Dispose(bool disposing) -> void +virtual System.ComponentModel.Design.UndoEngine.OnUndoing(System.EventArgs! e) -> void +virtual System.ComponentModel.Design.UndoEngine.OnUndone(System.EventArgs! e) -> void virtual System.ComponentModel.Design.UndoEngine.UndoUnit.Close() -> void +virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentAdded(System.ComponentModel.Design.ComponentEventArgs! e) -> void +virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentAdding(System.ComponentModel.Design.ComponentEventArgs! e) -> void +virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentChanged(System.ComponentModel.Design.ComponentChangedEventArgs! e) -> void +virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentChanging(System.ComponentModel.Design.ComponentChangingEventArgs! e) -> void +virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentRemoved(System.ComponentModel.Design.ComponentEventArgs! e) -> void +virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentRemoving(System.ComponentModel.Design.ComponentEventArgs! e) -> void +virtual System.ComponentModel.Design.UndoEngine.UndoUnit.ComponentRename(System.ComponentModel.Design.ComponentRenameEventArgs! e) -> void virtual System.ComponentModel.Design.UndoEngine.UndoUnit.IsEmpty.get -> bool virtual System.ComponentModel.Design.UndoEngine.UndoUnit.UndoCore() -> void virtual System.Drawing.Design.IconEditor.GetExtensions() -> string![]! @@ -1227,6 +1213,8 @@ virtual System.Windows.Forms.Design.DesignerOptions.UseSmartTags.get -> bool virtual System.Windows.Forms.Design.DesignerOptions.UseSmartTags.set -> void virtual System.Windows.Forms.Design.DesignerOptions.UseSnapLines.get -> bool virtual System.Windows.Forms.Design.DesignerOptions.UseSnapLines.set -> void +virtual System.Windows.Forms.Design.FileNameEditor.InitializeDialog(System.Windows.Forms.OpenFileDialog! openFileDialog) -> void +virtual System.Windows.Forms.Design.FolderNameEditor.InitializeDialog(System.Windows.Forms.Design.FolderNameEditor.FolderBrowser! folderBrowser) -> void virtual System.Windows.Forms.Design.ParentControlDesigner.AllowControlLasso.get -> bool virtual System.Windows.Forms.Design.ParentControlDesigner.AllowGenericDragBox.get -> bool virtual System.Windows.Forms.Design.ParentControlDesigner.AllowSetChildIndexOnDrop.get -> bool diff --git a/src/System.Windows.Forms.Design/src/PublicAPI.Unshipped.txt b/src/System.Windows.Forms.Design/src/PublicAPI.Unshipped.txt index e69de29bb2d..ab438209800 100644 --- a/src/System.Windows.Forms.Design/src/PublicAPI.Unshipped.txt +++ b/src/System.Windows.Forms.Design/src/PublicAPI.Unshipped.txt @@ -0,0 +1,60 @@ +System.Windows.Forms.Design.AxImporter.AxImporter(System.Windows.Forms.Design.AxImporter.Options! options) -> void +System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveActiveXReference(System.Runtime.InteropServices.UCOMITypeLib! typeLib) -> string? +System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveComReference(System.Reflection.AssemblyName! name) -> string? +System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveComReference(System.Runtime.InteropServices.UCOMITypeLib! typeLib) -> string? +System.Windows.Forms.Design.AxImporter.IReferenceResolver.ResolveManagedReference(string! assemName) -> string? +System.Windows.Forms.Design.AxImporter.Options.keyContainer -> string? +System.Windows.Forms.Design.AxImporter.Options.keyFile -> string? +System.Windows.Forms.Design.AxImporter.Options.keyPair -> System.Reflection.StrongNameKeyPair? +System.Windows.Forms.Design.AxImporter.Options.outputDirectory -> string? +System.Windows.Forms.Design.AxImporter.Options.outputName -> string? +System.Windows.Forms.Design.AxImporter.Options.publicKey -> byte[]? +System.Windows.Forms.Design.AxImporter.Options.references -> System.Windows.Forms.Design.AxImporter.IReferenceResolver? +virtual System.ComponentModel.Design.ComponentDesigner.SetTextualDefaultProperty.get -> bool +*REMOVED*System.ComponentModel.Design.DesignerActionListCollection.AddRange(System.ComponentModel.Design.DesignerActionList?[]! value) -> void +*REMOVED*~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.AddRange(System.Windows.Forms.Design.Behavior.Adorner[] value) -> void +*REMOVED*~System.Windows.Forms.Design.Behavior.GlyphCollection.AddRange(System.Windows.Forms.Design.Behavior.Glyph[] value) -> void +System.ComponentModel.Design.DesignerActionListCollection.AddRange(params System.ComponentModel.Design.DesignerActionList?[]! value) -> void +~System.Windows.Forms.Design.Behavior.BehaviorServiceAdornerCollection.AddRange(params System.Windows.Forms.Design.Behavior.Adorner[] value) -> void +~System.Windows.Forms.Design.Behavior.GlyphCollection.AddRange(params System.Windows.Forms.Design.Behavior.Glyph[] value) -> void +abstract System.ComponentModel.Design.DataSourceDescriptor.Image.get -> System.Drawing.Bitmap! +abstract System.ComponentModel.Design.DataSourceDescriptor.IsDesignable.get -> bool +abstract System.ComponentModel.Design.DataSourceDescriptor.Name.get -> string! +abstract System.ComponentModel.Design.DataSourceDescriptor.TypeName.get -> string! +abstract System.ComponentModel.Design.DataSourceGroup.DataSources.get -> System.ComponentModel.Design.DataSourceDescriptorCollection! +abstract System.ComponentModel.Design.DataSourceGroup.Image.get -> System.Drawing.Bitmap! +abstract System.ComponentModel.Design.DataSourceGroup.IsDefault.get -> bool +abstract System.ComponentModel.Design.DataSourceGroup.Name.get -> string! +abstract System.ComponentModel.Design.DataSourceProviderService.AddDataSourceInstance(System.ComponentModel.Design.IDesignerHost! host, System.ComponentModel.Design.DataSourceDescriptor! dataSourceDescriptor) -> object! +abstract System.ComponentModel.Design.DataSourceProviderService.GetDataSources() -> System.ComponentModel.Design.DataSourceGroupCollection! +abstract System.ComponentModel.Design.DataSourceProviderService.InvokeAddNewDataSource(System.Windows.Forms.IWin32Window! parentWindow, System.Windows.Forms.FormStartPosition startPosition) -> System.ComponentModel.Design.DataSourceGroup! +abstract System.ComponentModel.Design.DataSourceProviderService.InvokeConfigureDataSource(System.Windows.Forms.IWin32Window! parentWindow, System.Windows.Forms.FormStartPosition startPosition, System.ComponentModel.Design.DataSourceDescriptor! dataSourceDescriptor) -> bool +abstract System.ComponentModel.Design.DataSourceProviderService.NotifyDataSourceComponentAdded(object! dsc) -> void +abstract System.ComponentModel.Design.DataSourceProviderService.SupportsAddNewDataSource.get -> bool +abstract System.ComponentModel.Design.DataSourceProviderService.SupportsConfigureDataSource.get -> bool +System.ComponentModel.Design.DataSourceDescriptor +System.ComponentModel.Design.DataSourceDescriptor.DataSourceDescriptor() -> void +System.ComponentModel.Design.DataSourceDescriptorCollection +System.ComponentModel.Design.DataSourceDescriptorCollection.Add(System.ComponentModel.Design.DataSourceDescriptor! value) -> int +System.ComponentModel.Design.DataSourceDescriptorCollection.Contains(System.ComponentModel.Design.DataSourceDescriptor! value) -> bool +System.ComponentModel.Design.DataSourceDescriptorCollection.CopyTo(System.ComponentModel.Design.DataSourceDescriptor![]! array, int index) -> void +System.ComponentModel.Design.DataSourceDescriptorCollection.DataSourceDescriptorCollection() -> void +System.ComponentModel.Design.DataSourceDescriptorCollection.IndexOf(System.ComponentModel.Design.DataSourceDescriptor! value) -> int +System.ComponentModel.Design.DataSourceDescriptorCollection.Insert(int index, System.ComponentModel.Design.DataSourceDescriptor! value) -> void +System.ComponentModel.Design.DataSourceDescriptorCollection.Remove(System.ComponentModel.Design.DataSourceDescriptor! value) -> void +System.ComponentModel.Design.DataSourceDescriptorCollection.this[int index].get -> System.ComponentModel.Design.DataSourceDescriptor? +System.ComponentModel.Design.DataSourceDescriptorCollection.this[int index].set -> void +System.ComponentModel.Design.DataSourceGroup +System.ComponentModel.Design.DataSourceGroup.DataSourceGroup() -> void +System.ComponentModel.Design.DataSourceGroupCollection +System.ComponentModel.Design.DataSourceGroupCollection.Add(System.ComponentModel.Design.DataSourceGroup! value) -> int +System.ComponentModel.Design.DataSourceGroupCollection.Contains(System.ComponentModel.Design.DataSourceGroup! value) -> bool +System.ComponentModel.Design.DataSourceGroupCollection.CopyTo(System.ComponentModel.Design.DataSourceGroup![]! array, int index) -> void +System.ComponentModel.Design.DataSourceGroupCollection.DataSourceGroupCollection() -> void +System.ComponentModel.Design.DataSourceGroupCollection.IndexOf(System.ComponentModel.Design.DataSourceGroup! value) -> int +System.ComponentModel.Design.DataSourceGroupCollection.Insert(int index, System.ComponentModel.Design.DataSourceGroup! value) -> void +System.ComponentModel.Design.DataSourceGroupCollection.Remove(System.ComponentModel.Design.DataSourceGroup! value) -> void +System.ComponentModel.Design.DataSourceGroupCollection.this[int index].get -> System.ComponentModel.Design.DataSourceGroup? +System.ComponentModel.Design.DataSourceGroupCollection.this[int index].set -> void +System.ComponentModel.Design.DataSourceProviderService +System.ComponentModel.Design.DataSourceProviderService.DataSourceProviderService() -> void \ No newline at end of file diff --git a/src/System.Windows.Forms.Design/src/Resources/SR.resx b/src/System.Windows.Forms.Design/src/Resources/SR.resx index 6ef22cc4d66..84d969f4dd9 100644 --- a/src/System.Windows.Forms.Design/src/Resources/SR.resx +++ b/src/System.Windows.Forms.Design/src/Resources/SR.resx @@ -120,6 +120,15 @@ Winforms Designer is not supported on this platform. + + Dock Fill in Form + + + Dock Fill in UserControl + + + Re-parent Controls + Layout Settings @@ -564,6 +573,39 @@ Changes the GripStyle property + + Show + + + Panel Visibility + + + Top + + + Toggles the participation of TopToolStripPanel in runtime dragging of ToolStrip. + + + Bottom + + + Toggles the participation of BottomToolStripPanel in runtime dragging of ToolStrip. + + + Left + + + Toggles the participation of LeftToolStripPanel in runtime dragging of ToolStrip. + + + Right + + + Toggles the participation of RightToolStripPanel in runtime dragging of ToolStrip. + + + {0} Reparent Controls Transaction. + Layout && Appearance @@ -579,6 +621,9 @@ AllowItemReorder and AllowDrop cannot both be true. + + Unsupported Dock + ToolStrip New Item create Transaction. @@ -1317,10 +1362,263 @@ Press Ctrl+Enter to accept Text. Argument must only contain objects of type '{0}'. - + Vertical Splitter Orientation. - + Horizontal Splitter Orientation. - \ No newline at end of file + + Add Tab + + + Add tab to '{0}' + + + Remove Tab + + + Remove tab '{0}' from '{1}' + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + + + A&bsolute + + + &Add Column + + + Add Column on {0} + + + &Add + + + Add Ro&w + + + Add Row on {0} + + + A&utoSize + + + Change SizeType on {0} + + + Clearing Anchor property of {0} for {1} + + + Clearing Dock property of {0} for {1} + + + &Column + + + C&opy TableLayoutPanel + + + &Cut TableLayoutPanel + + + &Delete TableLayoutPanel + + + {0} swapped with {1} + + + &Delete + + + 0 + + + &Edit Rows and Columns... + + + &Insert + + + {0} must be greater than zero. + + + SizeMode + + + &Percentage + + + Remove Last Colu&mn + + + Remove Column on {0} + + + Remo&ve Last Row + + + Remove Row on {0} + + + &Row + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + + + Resizing {0} within {1} + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + + + Opens the Images collection editor + + + Choose images + + + Changes the bit depth images imported into this ImageList are stored at + + + Image Bit Depth + + + Changes the size images imported into this ImageList are stored at + + + Image Size + + + Choose Icon... + + + Close + + + The name {0} is already in use by another column. + + + &Edit Columns... + + + &Add Column... + + + Unable to create columns for the data source. The data source is no longer valid + + + Edit Columns + + + Add Column + + + {0} DataSource changed + + + Choose Data Source: + + + Enable Adding + + + Enable Editing + + + Enable Deleting + + + Enable Column Reordering + + + Enable Adding + + + Disable Adding + + + Enable Deleting + + + Disable Deleting + + + Enable Column Reordering + + + Disable Column Reordering + + + Enable Editing + + + Disable Editing + + + &Properties + + + Unbound Column &Properties + + + Bound Column &Properties + + + The DataGridViewColumn type. + + + Add new Object Data Source... + + + Bindable data sources and data members + + + Data binding editor + + + Currently data bound to '{0}'. + + + Select a data member to bind to. + + + Select a BindingSource to bind to. + + + Select a data source under 'Other Data Sources' to connect to data. + + + Click the 'Add Project Data Source...' link to connect to data. + + + None + + + Selecting 'None' clears the current data binding. + + + Other Data Sources + + + Contains all project data sources and local form list instances. + + + {0} List Instances + + + Contains all form components that implement IList, IListSource or Array. + + + Project Data Sources + + + Contains all project data sources. + + + Contains project data sources belonging to this namespace. + + + diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/AddNewDataSource.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/AddNewDataSource.bmp new file mode 100644 index 00000000000..883cdd1f48a Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/AddNewDataSource.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/BottomClose.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/BottomClose.bmp new file mode 100644 index 00000000000..ab28310c308 Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/BottomClose.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/BottomOpen.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/BottomOpen.bmp new file mode 100644 index 00000000000..38d996642e7 Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/BottomOpen.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/LeftClose.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/LeftClose.bmp new file mode 100644 index 00000000000..f4c4d64c309 Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/LeftClose.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/LeftOpen.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/LeftOpen.bmp new file mode 100644 index 00000000000..55bff8b8fd9 Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/LeftOpen.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/RightClose.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/RightClose.bmp new file mode 100644 index 00000000000..037bbad11c0 Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/RightClose.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/RightOpen.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/RightOpen.bmp new file mode 100644 index 00000000000..2b8ac2968d4 Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/RightOpen.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/ToolStripContainer_BottomToolStripPanel.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/ToolStripContainer_BottomToolStripPanel.bmp new file mode 100644 index 00000000000..35961a3d946 Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/ToolStripContainer_BottomToolStripPanel.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/ToolStripContainer_LeftToolStripPanel.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/ToolStripContainer_LeftToolStripPanel.bmp new file mode 100644 index 00000000000..a42076edf2a Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/ToolStripContainer_LeftToolStripPanel.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/ToolStripContainer_RightToolStripPanel.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/ToolStripContainer_RightToolStripPanel.bmp new file mode 100644 index 00000000000..9cae12d28c4 Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/ToolStripContainer_RightToolStripPanel.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/ToolStripContainer_TopToolStripPanel.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/ToolStripContainer_TopToolStripPanel.bmp new file mode 100644 index 00000000000..52543a70c9f Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/ToolStripContainer_TopToolStripPanel.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/TopClose.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/TopClose.bmp new file mode 100644 index 00000000000..9378f4ef547 Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/TopClose.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/TopOpen.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/TopOpen.bmp new file mode 100644 index 00000000000..5ea8c9a90e3 Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/Behavior/TopOpen.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/DataGridViewColumnsDialog.selectedColumns.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/DataGridViewColumnsDialog.selectedColumns.bmp new file mode 100644 index 00000000000..779effa9cac Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/DataGridViewColumnsDialog.selectedColumns.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/DataPickerImages.bmp b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/DataPickerImages.bmp new file mode 100644 index 00000000000..caacf163b1e Binary files /dev/null and b/src/System.Windows.Forms.Design/src/Resources/System/WinForms/Design/DataPickerImages.bmp differ diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf index d643def79a9..8cacee0b24f 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf @@ -2,6 +2,11 @@ + + {0} Reparent Controls Transaction. + Transakce nadřízeného ovládacího prvku {0}. + + Could not create ActiveX control '{0}' because it is not properly registered. Ovládací prvek {0} typu ActiveX nelze vytvořit, protože prvek není správně registrován. @@ -227,6 +232,11 @@ Náhled na vybrané položky + + Choose Icon... + Vybrat ikonu... + + Select the image displayed in the PictureBox Vyberte obrázek zobrazený v ovládacím prvku PictureBox @@ -641,11 +651,136 @@ vyhledávání prostředků pomocí této třídy prostředků silného typu. + + Add Column + Add Column + + + + &Add Column... + &Add Column... + + + + Bound Column &Properties + Bound Column &Properties + + + + Choose Data Source: + Choose Data Source: + + + + {0} DataSource changed + {0} DataSource changed + + + + The DataGridViewColumn type. + The DataGridViewColumn type. + + + + Unable to create columns for the data source. The data source is no longer valid + Unable to create columns for the data source. The data source is no longer valid + + + + Disable Adding + Disable Adding + + + + Disable Column Reordering + Disable Column Reordering + + + + Disable Deleting + Disable Deleting + + + + Disable Editing + Disable Editing + + + + The name {0} is already in use by another column. + The name {0} is already in use by another column. + + + + Edit Columns + Edit Columns + + + + &Edit Columns... + &Edit Columns... + + + + Enable Adding + Enable Adding + + + + Enable Adding + Enable Adding + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Deleting + Enable Deleting + + + + Enable Deleting + Enable Deleting + + + + Enable Editing + Enable Editing + + + + Enable Editing + Enable Editing + + + + &Properties + &Properties + + + + Unbound Column &Properties + Unbound Column &Properties + + Cancel Storno + + Close + Close + + OK OK @@ -656,6 +791,91 @@ Je-li nastavena vlastnost DataSource, nelze kolekci Items upravit. + + Data binding editor + Editor datových vazeb + + + + Add new Object Data Source... + Přidat nový zdroj dat objektu… + + + + Click the 'Add Project Data Source...' link to connect to data. + Kliknutím na odkaz Přidat zdroj dat projektu se připojte k datům. + + + + Currently data bound to '{0}'. + Aktuálně jsou data svázána s {0}. + + + + Select a BindingSource to bind to. + Vyberte objekt BindingSource, k němuž má být vytvořena vazba. + + + + Select a data source under 'Other Data Sources' to connect to data. + Chcete-li se připojit k datům, vyberte zdroj dat v části Jiné zdroje dat. + + + + Select a data member to bind to. + Vyberte datový člen, k němuž má být vytvořena vazba. + + + + Contains all form components that implement IList, IListSource or Array. + Obsahuje všechny součásti formuláře, které implementují objekty IList, IListSource nebo Array. + + + + Selecting 'None' clears the current data binding. + Vyberete-li možnost Žádný, bude aktuální datová vazba vymazána. + + + + Contains all project data sources and local form list instances. + Obsahuje všechny zdroje dat projektu a místní instance seznamů formulářů. + + + + Contains all project data sources. + Obsahuje všechny zdroje dat projektu. + + + + Contains project data sources belonging to this namespace. + Obsahuje zdroje dat projektu patřící do tohoto oboru názvů. + + + + {0} List Instances + Počet instancí seznamu: {0} + + + + None + Žádné + + + + Other Data Sources + Jiné zdroje dat + + + + Project Data Sources + Zdroje dat projektu + + + + Bindable data sources and data members + Zdroje dat a datové členy, s nimiž lze vytvořit vazbu + + Could not convert value '{0}' to the type '{1}'. Hodnotu {0} nelze převést na typ {1}. @@ -905,16 +1125,31 @@ Určuje název použitý v kódu k identifikaci objektu. + + Dock Fill in Form + Ukotvit výplň ve formuláři + + Dock in Parent Container Ukotvit v nadřazeném kontejneru + + Dock Fill in UserControl + Ukotvit výplň prvku UserControl + + Horizontal Splitter Orientation. Orientace vodorovného rozdělovače. + + Re-parent Controls + Změnit nadřazenost ovládacích prvků + + Undock in Parent Container Zrušit ukotvení k nadřazenému kontejneru @@ -1080,6 +1315,36 @@ Editor kolekce Images + + Opens the Images collection editor + Otevře editor kolekce Images. + + + + Choose images + Vybrat obrázky + + + + Changes the bit depth images imported into this ImageList are stored at + Změny bitové hloubky obrázků importovaných do této třídy ImageList jsou uloženy v + + + + Image Bit Depth + Bitová hloubka obrázku + + + + Changes the size images imported into this ImageList are stored at + Změny velikosti obrázků importovaných do této třídy ImageList jsou uloženy v + + + + Image Size + Velikost obrázku + + Chooses an ImageList to use with this TreeView Vybere třídu ImageList, která má být použita s tímto prvkem TreeView. @@ -1712,6 +1977,181 @@ Stisknutím kombinace kláves Ctrl+Enter text přijměte. {0} [zbytek řetězce byl zkrácen]“; + + Add Tab + Přidat kartu + + + + Add tab to '{0}' + Přidat kartu k objektu {0} + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Objekt {0} nelze přidat k ovládacímu prvku TabControl. K ovládacím prvkům TabControls lze přímo přidat pouze objekty TabPages. + + + + Remove Tab + Odebrat kartu + + + + Remove tab '{0}' from '{1}' + Odebrat kartu {0} z objektu {1} + + + + A&bsolute + A&bsolutní + + + + &Add Column + &Přidat sloupec + + + + Add Column on {0} + Přidat sloupec v {0} + + + + &Add + &Přidat + + + + Add Ro&w + Přidat řáde&k + + + + Add Row on {0} + Přidat řádek v {0} + + + + A&utoSize + A&utomatická velikost (AutoSize) + + + + Change SizeType on {0} + Změnit typ SizeType v {0} + + + + Clearing Anchor property of {0} for {1} + Vymazání vlastnosti Anchor objektu {0} pro {1} + + + + Clearing Dock property of {0} for {1} + Vymazání vlastnosti Dock objektu {0} pro {1} + + + + &Column + &Sloupec + + + + C&opy TableLayoutPanel + &Kopírovat kontejner TableLayoutPanel + + + + &Cut TableLayoutPanel + &Vyjmout kontejner TableLayoutPanel + + + + &Delete TableLayoutPanel + &Odstranit kontejner TableLayoutPanel + + + + {0} swapped with {1} + {0} bylo zaměněno s {1} + + + + &Delete + &Odstranit + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Upravit řádky a sloupce... + + + + &Insert + &Vložit + + + + {0} must be greater than zero. + Parametr {0} musí být větší než nula. + + + + SizeMode + SizeMode + + + + &Percentage + &Procento + + + + Remove Last Colu&mn + Odebrat poslední &sloupec + + + + Remove Column on {0} + Odebrat sloupec v {0} + + + + Remo&ve Last Row + Odebrat poslední řá&dek + + + + Remove Row on {0} + Odebrat řádek v {0} + + + + &Row + Řá&dek + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Nelze vytvořit další řádky nebo sloupce. Ovládací prvek TableLayoutPanel je plný a vlastnost GrowStyle má hodnotu FixedSize. + + + + Resizing {0} within {1} + Změna velikosti {0} v rámci {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + Ovládací prvek TableLayoutPanel nelze rozšířit tak, aby obsahoval tento ovládací prvek, protože vlastnost GrowStyle panelu je nastavena na hodnotu FixedSize. + + Dock: Dok: @@ -1757,6 +2197,56 @@ Stisknutím kombinace kláves Ctrl+Enter text přijměte. Vlastnosti AllowItemReorder a AllowDrop nemohou být současně nastaveny na hodnotu True. + + Bottom + Dolů + + + + Toggles the participation of BottomToolStripPanel in runtime dragging of ToolStrip. + Přepíná účast vlastnosti BottomToolStripPanel při přetahování prvku ToolStrip v době běhu. + + + + Left + Vlevo + + + + Toggles the participation of LeftToolStripPanel in runtime dragging of ToolStrip. + Přepíná účast prvku LeftToolStripPanel při přetahování prvku ToolStrip v době běhu. + + + + Right + Vpravo + + + + Toggles the participation of RightToolStripPanel in runtime dragging of ToolStrip. + Přepíná účast prvku RightToolStripPanel při přetahování prvku ToolStrip v době běhu. + + + + Show + Zobrazit + + + + Top + Nahoru + + + + Toggles the participation of TopToolStripPanel in runtime dragging of ToolStrip. + Přepíná účast prvku TopToolStripPanel při přetahování prvku ToolStrip v době běhu. + + + + Panel Visibility + Viditelnost panelu + + ToolStrip New Item create Transaction. Transakce vytvoření nové položky prvku ToolStrip. @@ -1862,6 +2352,11 @@ Stisknutím kombinace kláves Ctrl+Enter text přijměte. Transakce morfingu prvku ToolStripItem + + Unsupported Dock + Nepodporované ukotvení + + '{0}' {0} diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf index 5e89ca3f540..f10d4b41dfa 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf @@ -2,6 +2,11 @@ + + {0} Reparent Controls Transaction. + {0}-Transaktion zum erneuten Unterordnen von Steuerelementen. + + Could not create ActiveX control '{0}' because it is not properly registered. Das ActiveX-Steuerelement {0} konnte nicht erstellt werden, da es nicht ordnungsgemäß registriert ist. @@ -227,6 +232,11 @@ Auswahlvorschau + + Choose Icon... + Symbol auswählen... + + Select the image displayed in the PictureBox In PictureBox angezeigtes Bild auswählen @@ -641,11 +651,136 @@ Ressourcensuchvorgänge, die diese stark typisierte Ressourcenklasse verwenden. + + Add Column + Add Column + + + + &Add Column... + &Add Column... + + + + Bound Column &Properties + Bound Column &Properties + + + + Choose Data Source: + Choose Data Source: + + + + {0} DataSource changed + {0} DataSource changed + + + + The DataGridViewColumn type. + The DataGridViewColumn type. + + + + Unable to create columns for the data source. The data source is no longer valid + Unable to create columns for the data source. The data source is no longer valid + + + + Disable Adding + Disable Adding + + + + Disable Column Reordering + Disable Column Reordering + + + + Disable Deleting + Disable Deleting + + + + Disable Editing + Disable Editing + + + + The name {0} is already in use by another column. + The name {0} is already in use by another column. + + + + Edit Columns + Edit Columns + + + + &Edit Columns... + &Edit Columns... + + + + Enable Adding + Enable Adding + + + + Enable Adding + Enable Adding + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Deleting + Enable Deleting + + + + Enable Deleting + Enable Deleting + + + + Enable Editing + Enable Editing + + + + Enable Editing + Enable Editing + + + + &Properties + &Properties + + + + Unbound Column &Properties + Unbound Column &Properties + + Cancel Abbrechen + + Close + Close + + OK OK @@ -656,6 +791,91 @@ Die Items-Sammlung kann nicht geändert werden, wenn die DataSource-Eigenschaft festgelegt ist. + + Data binding editor + Datenbindungs-Editor + + + + Add new Object Data Source... + Objektdatenquelle hinzufügen... + + + + Click the 'Add Project Data Source...' link to connect to data. + Klicken Sie auf den Link "Projektdatenquelle hinzufügen", um eine Datenverbindung aufzubauen. + + + + Currently data bound to '{0}'. + Derzeit sind Daten an {0} gebunden. + + + + Select a BindingSource to bind to. + Wählen Sie eine BindingSource aus, an die eine Bindung hergestellt werden soll. + + + + Select a data source under 'Other Data Sources' to connect to data. + Wählen Sie unter "Weitere Datenquellen" eine Datenquelle für die Datenverbindung aus. + + + + Select a data member to bind to. + Wählen Sie einen Datenmember, an den eine Bindung hergestellt werden soll. + + + + Contains all form components that implement IList, IListSource or Array. + Enthält alle Formularkomponenten, die IList, IListSource oder Array implementieren. + + + + Selecting 'None' clears the current data binding. + Mit der Auswahl von "Keine" wird die aktuelle Datenbindung gelöscht. + + + + Contains all project data sources and local form list instances. + Enthält alle Projektdatenquellen und lokalen Formularlisteninstanzen. + + + + Contains all project data sources. + Enthält alle Projektdatenquellen. + + + + Contains project data sources belonging to this namespace. + Enthält Projektdatenquellen, die zu diesem Namespace gehören. + + + + {0} List Instances + {0}-Listeninstanzen + + + + None + Keine + + + + Other Data Sources + Weitere Datenquellen + + + + Project Data Sources + Projektdatenquellen + + + + Bindable data sources and data members + Bindbare Datenquellen und Datenmember + + Could not convert value '{0}' to the type '{1}'. Wert {0} konnte nicht in Typ {1} konvertiert werden. @@ -905,16 +1125,31 @@ Gibt den im Code zum Identifizieren des Objekts verwendeten Namen an. + + Dock Fill in Form + Ausfüllformular andocken + + Dock in Parent Container In übergeordnetem Container andocken + + Dock Fill in UserControl + Ausfüll-UserControl andocken + + Horizontal Splitter Orientation. Horizontale Teilungsausrichtung. + + Re-parent Controls + Steuerelemente neu unterordnen + + Undock in Parent Container In übergeordnetem Container abdocken @@ -1080,6 +1315,36 @@ Bildsammlungs-Editor + + Opens the Images collection editor + Öffnet den Bildsammlungs-Editor + + + + Choose images + Bilder auswählen + + + + Changes the bit depth images imported into this ImageList are stored at + Ändert die Bittiefe, mit der Bilder, die in diese ImageList importiert wurden, gespeichert werden + + + + Image Bit Depth + Bittiefe für Bilder + + + + Changes the size images imported into this ImageList are stored at + Ändert die Größe, mit der Bilder, die in diese ImageList importiert wurden, gespeichert werden + + + + Image Size + Bildgröße + + Chooses an ImageList to use with this TreeView Wählt eine ImageList aus, die mit dieser TreeView verwendet wird @@ -1712,6 +1977,181 @@ Drücken Sie STRG+EINGABETASTE, um Text zu übernehmen. {0} [Rest der Zeichenfolge wurde abgeschnitten]"; + + Add Tab + Registerkarte hinzufügen + + + + Add tab to '{0}' + Registerkarte zu {0} hinzufügen + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + {0} kann nicht zu TabControl hinzugefügt werden. Nur TabPages können direkt zu TabControls hinzugefügt werden. + + + + Remove Tab + Registerkarte entfernen + + + + Remove tab '{0}' from '{1}' + Registerkarte {0} von {1} entfernen + + + + A&bsolute + A&bsolut + + + + &Add Column + Sp&alte hinzufügen + + + + Add Column on {0} + Spalte für {0} hinzufügen + + + + &Add + &Hinzufügen + + + + Add Ro&w + Z&eile hinzufügen + + + + Add Row on {0} + Zeile für {0} hinzufügen + + + + A&utoSize + A&utoSize + + + + Change SizeType on {0} + SizeType für {0} ändern + + + + Clearing Anchor property of {0} for {1} + Anchor-Eigenschaft {0} für {1} löschen + + + + Clearing Dock property of {0} for {1} + Dock-Eigenschaft {0} für {1} löschen + + + + &Column + &Spalte + + + + C&opy TableLayoutPanel + TableLayoutPanel k&opieren + + + + &Cut TableLayoutPanel + TableLayoutPanel auss&chneiden + + + + &Delete TableLayoutPanel + TableLayoutPanel &löschen + + + + {0} swapped with {1} + {0} mit {1} vertauscht + + + + &Delete + &Löschen + + + + 0 + 0 + + + + &Edit Rows and Columns... + Zeilen und Spalten b&earbeiten... + + + + &Insert + &Einfügen + + + + {0} must be greater than zero. + {0} muss größer als 0 sein. + + + + SizeMode + SizeMode + + + + &Percentage + &Prozentsatz + + + + Remove Last Colu&mn + Letzte S&palte entfernen + + + + Remove Column on {0} + Spalte in {0} entfernen + + + + Remo&ve Last Row + Letzte Zeile e&ntfernen + + + + Remove Row on {0} + Zeile in {0} entfernen + + + + &Row + Z&eile + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Es können keine weiteren Zeilen oder Spalten erstellt werden. "TableLayoutPanel" ist voll, und "GrowStyle" ist "FixedSize". + + + + Resizing {0} within {1} + Größe von {0} in {1} ändern + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + "TableLayoutPanel" kann nicht als Container für das Steuerelement erweitert werden, da die GrowStyle-Eigenschaft des Bereichs auf "FixedSize" festgelegt wurde. + + Dock: Dock: @@ -1757,6 +2197,56 @@ Drücken Sie STRG+EINGABETASTE, um Text zu übernehmen. AllowItemReorder und AllowDrop können nicht beide "true" sein. + + Bottom + Unten + + + + Toggles the participation of BottomToolStripPanel in runtime dragging of ToolStrip. + Schaltet die Einbeziehung von BottomToolStripPanel beim Ziehen von ToolStrip zur Laufzeit um. + + + + Left + Links + + + + Toggles the participation of LeftToolStripPanel in runtime dragging of ToolStrip. + Schaltet die Einbeziehung von LeftToolStripPanel beim Ziehen von ToolStrip zur Laufzeit um. + + + + Right + Rechts + + + + Toggles the participation of RightToolStripPanel in runtime dragging of ToolStrip. + Schaltet die Einbeziehung von RightToolStripPanel beim Ziehen von ToolStrip zur Laufzeit um. + + + + Show + Anzeigen + + + + Top + Oben + + + + Toggles the participation of TopToolStripPanel in runtime dragging of ToolStrip. + Schaltet die Einbeziehung von TopToolStripPanel beim Ziehen von ToolStrip zur Laufzeit um. + + + + Panel Visibility + Bereichsichtbarkeit + + ToolStrip New Item create Transaction. Transaktion "Neues ToolStrip-Element erstellen". @@ -1862,6 +2352,11 @@ Drücken Sie STRG+EINGABETASTE, um Text zu übernehmen. Transaktion "ToolStripItem-Morphing". + + Unsupported Dock + Nicht unterstütztes Andocken + + '{0}' "{0}" diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf index 162b99fe9fb..ad30073288b 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf @@ -2,6 +2,11 @@ + + {0} Reparent Controls Transaction. + {0} Transacción de controles cambiar primarios. + + Could not create ActiveX control '{0}' because it is not properly registered. No se pudo crear el control ActiveX '{0}' porque no está registrado correctamente. @@ -227,6 +232,11 @@ Vista previa seleccionada + + Choose Icon... + Elegir icono... + + Select the image displayed in the PictureBox Seleccione la imagen mostrada en PictureBox @@ -641,11 +651,136 @@ búsquedas de recursos mediante esta clase de recurso fuertemente tipado. + + Add Column + Add Column + + + + &Add Column... + &Add Column... + + + + Bound Column &Properties + Bound Column &Properties + + + + Choose Data Source: + Choose Data Source: + + + + {0} DataSource changed + {0} DataSource changed + + + + The DataGridViewColumn type. + The DataGridViewColumn type. + + + + Unable to create columns for the data source. The data source is no longer valid + Unable to create columns for the data source. The data source is no longer valid + + + + Disable Adding + Disable Adding + + + + Disable Column Reordering + Disable Column Reordering + + + + Disable Deleting + Disable Deleting + + + + Disable Editing + Disable Editing + + + + The name {0} is already in use by another column. + The name {0} is already in use by another column. + + + + Edit Columns + Edit Columns + + + + &Edit Columns... + &Edit Columns... + + + + Enable Adding + Enable Adding + + + + Enable Adding + Enable Adding + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Deleting + Enable Deleting + + + + Enable Deleting + Enable Deleting + + + + Enable Editing + Enable Editing + + + + Enable Editing + Enable Editing + + + + &Properties + &Properties + + + + Unbound Column &Properties + Unbound Column &Properties + + Cancel Cancelar + + Close + Close + + OK Aceptar @@ -656,6 +791,91 @@ No se puede modificar la colección Items cuando está establecida la propiedad DataSource. + + Data binding editor + Editor del enlace de datos + + + + Add new Object Data Source... + Agregar nuevo origen de datos del objeto... + + + + Click the 'Add Project Data Source...' link to connect to data. + Haga clic en el vínculo 'Agregar origen de datos del proyecto...' para conectarse con los datos. + + + + Currently data bound to '{0}'. + Datos enlazados actualmente a '{0}'. + + + + Select a BindingSource to bind to. + Seleccione un BindingSource al que enlazar. + + + + Select a data source under 'Other Data Sources' to connect to data. + Seleccione un origen de datos en 'Otros orígenes de datos' para conectar con los datos. + + + + Select a data member to bind to. + Seleccione un miembro de datos al que enlazar. + + + + Contains all form components that implement IList, IListSource or Array. + Contiene todos los componentes de formularios que implementan IList, IListSource o Array. + + + + Selecting 'None' clears the current data binding. + Al seleccionar 'Ninguno' se elimina el enlace de datos actual. + + + + Contains all project data sources and local form list instances. + Contiene todos los orígenes de datos del proyecto y las instancias de listas de formularios locales. + + + + Contains all project data sources. + Contiene todos los orígenes de datos del proyecto. + + + + Contains project data sources belonging to this namespace. + Contiene los orígenes de datos del proyecto que pertenecen a este espacio de nombres. + + + + {0} List Instances + {0} instancias de listas + + + + None + Ninguna + + + + Other Data Sources + Otros orígenes de datos + + + + Project Data Sources + Orígenes de datos del proyecto + + + + Bindable data sources and data members + Miembros de datos y orígenes de datos enlazables + + Could not convert value '{0}' to the type '{1}'. No se pudo convertir el valor '{0}' en el tipo '{1}'. @@ -905,16 +1125,31 @@ Indica el nombre utilizado en el código para identificar el objeto. + + Dock Fill in Form + Acoplar relleno en formulario + + Dock in Parent Container Acoplar en contenedor primario + + Dock Fill in UserControl + Acoplar relleno en UserControl + + Horizontal Splitter Orientation. Orientación del divisor horizontal. + + Re-parent Controls + Cambiar primario de los controles + + Undock in Parent Container Desacoplar en contenedor primario @@ -1080,6 +1315,36 @@ Editor de la colección Imágenes + + Opens the Images collection editor + Abre el Editor de la colección Imágenes + + + + Choose images + Elegir imágenes + + + + Changes the bit depth images imported into this ImageList are stored at + Cambia la profundidad de bits con la que se almacenan las imágenes importadas a esta ImageList + + + + Image Bit Depth + Profundidad de bits de imágenes + + + + Changes the size images imported into this ImageList are stored at + Cambia el tamaño con el que se almacenen las imágenes importadas a esta ImageList + + + + Image Size + Tamaño de imagen + + Chooses an ImageList to use with this TreeView Elige una ImageList para utilizar con esta TreeView @@ -1712,6 +1977,181 @@ Presione Ctrl+Entrar para aceptar el texto. {0} [resto de la cadena truncado]"; + + Add Tab + Agregar pestaña + + + + Add tab to '{0}' + Agregar pestaña a '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + No se puede agregar '{0}' a TabControl. Sólo se pueden agregar directamente TabPages a TabControls. + + + + Remove Tab + Quitar pestaña + + + + Remove tab '{0}' from '{1}' + Quitar la pestaña '{0}' de '{1}' + + + + A&bsolute + &Absoluto + + + + &Add Column + &Agregar columna + + + + Add Column on {0} + Agregar columna en {0} + + + + &Add + &Agregar + + + + Add Ro&w + Agr&egar fila + + + + Add Row on {0} + Agregar fila en {0} + + + + A&utoSize + &Ajuste automático + + + + Change SizeType on {0} + Cambiar SizeType en {0} + + + + Clearing Anchor property of {0} for {1} + Quitar la propiedad Anchor de {0} para {1} + + + + Clearing Dock property of {0} for {1} + Quitar la propiedad Dock de {0} para {1} + + + + &Column + &Columna + + + + C&opy TableLayoutPanel + C&opiar TableLayoutPanel + + + + &Cut TableLayoutPanel + &Cortar TableLayoutPanel + + + + &Delete TableLayoutPanel + &Eliminar TableLayoutPanel + + + + {0} swapped with {1} + {0} se intercambió con {1} + + + + &Delete + &Eliminar + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Editar filas y columnas... + + + + &Insert + &Insertar + + + + {0} must be greater than zero. + {0} debe ser mayor que cero. + + + + SizeMode + SizeMode + + + + &Percentage + &Porcentaje + + + + Remove Last Colu&mn + Quitar la última colu&mna + + + + Remove Column on {0} + Quitar columna en {0} + + + + Remo&ve Last Row + &Quitar la última fila + + + + Remove Row on {0} + Quitar fila en {0} + + + + &Row + &Fila + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + No se pueden crear filas o columnas adicionales. TableLayoutPanel está lleno y GrowStyle es 'FixedSize'. + + + + Resizing {0} within {1} + Cambiar de tamaño {0} dentro de {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel no se puede expandir para contener el control porque la propiedad GrowStyle del panel está establecida en 'FixedSize'. + + Dock: Acoplar: @@ -1757,6 +2197,56 @@ Presione Ctrl+Entrar para aceptar el texto. AllowItemReorder y AllowDrop no pueden ser ambos true. + + Bottom + Inferior + + + + Toggles the participation of BottomToolStripPanel in runtime dragging of ToolStrip. + Alterna la participación de BottomToolStripPanel en la acción de arrastrar ToolStrip en tiempo de ejecución. + + + + Left + Izquierdo + + + + Toggles the participation of LeftToolStripPanel in runtime dragging of ToolStrip. + Alterna la participación de LeftToolStripPanel en la acción de arrastrar ToolStrip en tiempo de ejecución. + + + + Right + Derecho + + + + Toggles the participation of RightToolStripPanel in runtime dragging of ToolStrip. + Alterna la participación de RightToolStripPanel en la acción de arrastrar ToolStrip en tiempo de ejecución. + + + + Show + Mostrar + + + + Top + Superior + + + + Toggles the participation of TopToolStripPanel in runtime dragging of ToolStrip. + Alterna la participación de TopToolStripPanel en la acción de arrastrar ToolStrip en tiempo de ejecución. + + + + Panel Visibility + Visibilidad del panel + + ToolStrip New Item create Transaction. Transacción de creación de nuevo elemento ToolStrip. @@ -1862,6 +2352,11 @@ Presione Ctrl+Entrar para aceptar el texto. Transacción de cambio de forma de ToolStripItem. + + Unsupported Dock + Acoplado no compatible + + '{0}' '{0}' diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf index 8107c1ce581..a6545e9996c 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf @@ -2,6 +2,11 @@ + + {0} Reparent Controls Transaction. + {0} Apparenter à nouveau à la transaction des contrôles. + + Could not create ActiveX control '{0}' because it is not properly registered. Impossible de créer le contrôle ActiveX '{0}', car il n'est pas correctement inscrit. @@ -227,6 +232,11 @@ Aperçu sélectionné + + Choose Icon... + Choisir une icône... + + Select the image displayed in the PictureBox Sélectionnez l'image affichée dans PictureBox @@ -641,11 +651,136 @@ les recherches de ressources à l'aide de cette classe de ressource fortement typée. + + Add Column + Add Column + + + + &Add Column... + &Add Column... + + + + Bound Column &Properties + Bound Column &Properties + + + + Choose Data Source: + Choose Data Source: + + + + {0} DataSource changed + {0} DataSource changed + + + + The DataGridViewColumn type. + The DataGridViewColumn type. + + + + Unable to create columns for the data source. The data source is no longer valid + Unable to create columns for the data source. The data source is no longer valid + + + + Disable Adding + Disable Adding + + + + Disable Column Reordering + Disable Column Reordering + + + + Disable Deleting + Disable Deleting + + + + Disable Editing + Disable Editing + + + + The name {0} is already in use by another column. + The name {0} is already in use by another column. + + + + Edit Columns + Edit Columns + + + + &Edit Columns... + &Edit Columns... + + + + Enable Adding + Enable Adding + + + + Enable Adding + Enable Adding + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Deleting + Enable Deleting + + + + Enable Deleting + Enable Deleting + + + + Enable Editing + Enable Editing + + + + Enable Editing + Enable Editing + + + + &Properties + &Properties + + + + Unbound Column &Properties + Unbound Column &Properties + + Cancel Annuler + + Close + Close + + OK OK @@ -656,6 +791,91 @@ Impossible de modifier la collection d'éléments lorsque la propriété DataSource est définie. + + Data binding editor + Éditeur de liaisons de données + + + + Add new Object Data Source... + Ajouter une nouvelle source de données Objet... + + + + Click the 'Add Project Data Source...' link to connect to data. + Cliquez sur le lien 'Ajouter la source de données du projet...' pour vous connecter aux données. + + + + Currently data bound to '{0}'. + Actuellement lié aux données de '{0}'. + + + + Select a BindingSource to bind to. + Sélectionnez un BindingSource auquel vous pouvez vous lier. + + + + Select a data source under 'Other Data Sources' to connect to data. + Sélectionnez une source de données sous 'Autres sources de données' pour vous connecter aux données. + + + + Select a data member to bind to. + Sélectionnez une donnée membre à laquelle vous pouvez vous lier. + + + + Contains all form components that implement IList, IListSource or Array. + Contient tous les composants de formulaire qui implémentent IList, IListSource ou Array. + + + + Selecting 'None' clears the current data binding. + La sélection de l'option 'Aucun' entraîne la suppression de la liaison de données actuelle. + + + + Contains all project data sources and local form list instances. + Contient toutes les sources de données des projets et les instances de listes des formulaires locaux. + + + + Contains all project data sources. + Contient toutes les sources de données des projets. + + + + Contains project data sources belonging to this namespace. + Contient les sources de données des projets appartenant à cet espace de noms. + + + + {0} List Instances + Instances de listes {0} + + + + None + Aucun + + + + Other Data Sources + Autres sources de données + + + + Project Data Sources + Sources de données du projet + + + + Bindable data sources and data members + Sources de données et données membres pouvant être liées + + Could not convert value '{0}' to the type '{1}'. Impossible de convertir la valeur '{0}' en type '{1}'. @@ -905,16 +1125,31 @@ Indique le nom utilisé dans le code pour identifier l'objet. + + Dock Fill in Form + Ancrer dans le formulaire + + Dock in Parent Container Ancrer dans le conteneur parent + + Dock Fill in UserControl + Ancrer dans le UserControl + + Horizontal Splitter Orientation. Orientation du séparateur horizontal. + + Re-parent Controls + Apparenter les contrôles + + Undock in Parent Container Annuler l'ancrage dans le conteneur parent @@ -1080,6 +1315,36 @@ Éditeur de collections Images + + Opens the Images collection editor + Ouvre l'éditeur de collections Images + + + + Choose images + Choisir des images + + + + Changes the bit depth images imported into this ImageList are stored at + Modifie la profondeur de couleur selon laquelle les images importées dans cet ImageList sont stockées + + + + Image Bit Depth + Profondeur de couleur de l'image + + + + Changes the size images imported into this ImageList are stored at + Modifie la taille selon laquelle les images importées dans cet ImageList sont stockées + + + + Image Size + Taille d'image + + Chooses an ImageList to use with this TreeView Choisit un ImageList à utiliser avec ce contrôle TreeView @@ -1712,6 +1977,181 @@ Appuyez sur Ctrl+Entrée pour valider le texte. {0} [le reste de la chaîne a été tronqué]"; + + Add Tab + Ajouter un onglet + + + + Add tab to '{0}' + Ajouter un onglet à '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Impossible d'ajouter '{0}' à TabControl. Seuls des TabPages peuvent être ajoutés directement à des TabControls. + + + + Remove Tab + Supprimer l'onglet + + + + Remove tab '{0}' from '{1}' + Supprimer l'onglet '{0}' de '{1}' + + + + A&bsolute + A&bsolu + + + + &Add Column + Aj&outer une colonne + + + + Add Column on {0} + Ajouter une colonne dans {0} + + + + &Add + &Ajouter + + + + Add Ro&w + Ajouter une &ligne + + + + Add Row on {0} + Ajouter une ligne dans {0} + + + + A&utoSize + Redimensionner a&utomatiquement + + + + Change SizeType on {0} + Modifier SizeType dans {0} + + + + Clearing Anchor property of {0} for {1} + Suppression de la propriété Anchor de {0} pour {1} + + + + Clearing Dock property of {0} for {1} + Suppression de la propriété Dock de {0} pour {1} + + + + &Column + &Colonne + + + + C&opy TableLayoutPanel + C&opier TableLayoutPanel + + + + &Cut TableLayoutPanel + &Couper TableLayoutPanel + + + + &Delete TableLayoutPanel + &Supprimer TableLayoutPanel + + + + {0} swapped with {1} + {0} échangé avec {1} + + + + &Delete + &Supprimer + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Modifier les lignes et les colonnes... + + + + &Insert + &Insérer + + + + {0} must be greater than zero. + {0} doit être supérieur à zéro. + + + + SizeMode + SizeMode + + + + &Percentage + &Pourcentage + + + + Remove Last Colu&mn + Suppri&mer la dernière colonne + + + + Remove Column on {0} + Supprimer la colonne dans {0} + + + + Remo&ve Last Row + Supprimer la der&nière ligne + + + + Remove Row on {0} + Supprimer la ligne dans {0} + + + + &Row + &Ligne + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Impossible de créer des lignes ou colonnes supplémentaires. TableLayoutPanel est saturé et GrowDirection est 'FixedSize'. + + + + Resizing {0} within {1} + Redimensionnement de {0} dans {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + Impossible d'étendre TableLayoutPanel pour contenir le contrôle, car la propriété GrowStyle du panneau a la valeur 'FixedSize'. + + Dock: Dock : @@ -1757,6 +2197,56 @@ Appuyez sur Ctrl+Entrée pour valider le texte. AllowItemReorder et AllowDrop ne peuvent pas être true en même temps. + + Bottom + Bas + + + + Toggles the participation of BottomToolStripPanel in runtime dragging of ToolStrip. + Active/Désactive la participation de BottomToolStripPanel lors du déplacement de ToolStrip à l'exécution. + + + + Left + Gauche + + + + Toggles the participation of LeftToolStripPanel in runtime dragging of ToolStrip. + Active/Désactive la participation de LeftToolStripPanel lors du déplacement de ToolStrip à l'exécution. + + + + Right + Droite + + + + Toggles the participation of RightToolStripPanel in runtime dragging of ToolStrip. + Active/Désactive la participation de RightToolStripPanel lors du déplacement de ToolStrip à l'exécution. + + + + Show + Afficher + + + + Top + Haut + + + + Toggles the participation of TopToolStripPanel in runtime dragging of ToolStrip. + Active/Désactive la participation de TopToolStripPanel lors du déplacement de ToolStrip à l'exécution. + + + + Panel Visibility + Visibilité des panneaux + + ToolStrip New Item create Transaction. Transaction Création d'un nouvel élément ToolStrip. @@ -1862,6 +2352,11 @@ Appuyez sur Ctrl+Entrée pour valider le texte. Transaction Transformation de ToolStripItem. + + Unsupported Dock + Dock non pris en charge + + '{0}' '{0}' diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf index 7a6442c201f..8cf6dd56b67 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf @@ -2,6 +2,11 @@ + + {0} Reparent Controls Transaction. + {0} Associa con un nuovo elemento padre la transazione controlli. + + Could not create ActiveX control '{0}' because it is not properly registered. Impossibile creare il controllo ActiveX '{0}' perché non è correttamente registrato. @@ -227,6 +232,11 @@ Anteprima selezionata + + Choose Icon... + Seleziona icona... + + Select the image displayed in the PictureBox Selezionare l'immagine da visualizzare nel controllo PictureBox. @@ -641,11 +651,136 @@ ricerche di risorse eseguite con questa classe di risorse fortemente tipizzata. + + Add Column + Add Column + + + + &Add Column... + &Add Column... + + + + Bound Column &Properties + Bound Column &Properties + + + + Choose Data Source: + Choose Data Source: + + + + {0} DataSource changed + {0} DataSource changed + + + + The DataGridViewColumn type. + The DataGridViewColumn type. + + + + Unable to create columns for the data source. The data source is no longer valid + Unable to create columns for the data source. The data source is no longer valid + + + + Disable Adding + Disable Adding + + + + Disable Column Reordering + Disable Column Reordering + + + + Disable Deleting + Disable Deleting + + + + Disable Editing + Disable Editing + + + + The name {0} is already in use by another column. + The name {0} is already in use by another column. + + + + Edit Columns + Edit Columns + + + + &Edit Columns... + &Edit Columns... + + + + Enable Adding + Enable Adding + + + + Enable Adding + Enable Adding + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Deleting + Enable Deleting + + + + Enable Deleting + Enable Deleting + + + + Enable Editing + Enable Editing + + + + Enable Editing + Enable Editing + + + + &Properties + &Properties + + + + Unbound Column &Properties + Unbound Column &Properties + + Cancel Annulla + + Close + Close + + OK OK @@ -656,6 +791,91 @@ Impossibile modificare la raccolta degli elementi quando è impostata la proprietà DataSource. + + Data binding editor + Editor di data binding. + + + + Add new Object Data Source... + Aggiungi nuova origine dati oggetto + + + + Click the 'Add Project Data Source...' link to connect to data. + Per stabilire la connessione ai dati, fare clic sul collegamento 'Aggiungi origine dati progetto'. + + + + Currently data bound to '{0}'. + Dati correntemente associati a '{0}'. + + + + Select a BindingSource to bind to. + Selezionare un BindingSource con cui stabilire l'associazione. + + + + Select a data source under 'Other Data Sources' to connect to data. + Per stabilire la connessione ai dati, selezionare un'origine dati in 'Altre origini dati'. + + + + Select a data member to bind to. + Selezionare un membro dati con cui stabilire l'associazione. + + + + Contains all form components that implement IList, IListSource or Array. + Contiene tutti i componenti del form che implementano IList, IListSource o Array. + + + + Selecting 'None' clears the current data binding. + Se si seleziona 'Nessuna', il data binding corrente verrà cancellato. + + + + Contains all project data sources and local form list instances. + Contiene tutte le origini dati del progetto e le istanze degli elenchi di form locali. + + + + Contains all project data sources. + Contiene tutte le origini dati del progetto. + + + + Contains project data sources belonging to this namespace. + Contiene le origini dati del progetto appartenenti a questo spazio dei nomi. + + + + {0} List Instances + Istanze dell'elenco {0} + + + + None + Nessuno + + + + Other Data Sources + Altre origini dati + + + + Project Data Sources + Origini dati del progetto + + + + Bindable data sources and data members + Membri dati e origini dati associabili + + Could not convert value '{0}' to the type '{1}'. Impossibile convertire il valore '{0}' nel tipo '{1}'. @@ -905,16 +1125,31 @@ Indica il nome utilizzato nel codice per identificare l'oggetto. + + Dock Fill in Form + Ancora riempimento nel form + + Dock in Parent Container Ancora nel contenitore padre + + Dock Fill in UserControl + Ancora riempimento in UserControl + + Horizontal Splitter Orientation. Barra di divisione orizzontale. + + Re-parent Controls + Assegna nuovo elemento padre ai controlli + + Undock in Parent Container Disancora nel contenitore padre @@ -1080,6 +1315,36 @@ Editor della raccolta Images + + Opens the Images collection editor + Apre l'editor della raccolta Images + + + + Choose images + Seleziona immagini + + + + Changes the bit depth images imported into this ImageList are stored at + Consente di modificare la profondità in bit a cui vengono archiviate le immagini importate nel controllo ImageList. + + + + Image Bit Depth + Profondità in bit immagini + + + + Changes the size images imported into this ImageList are stored at + Consente di modificare le dimensioni a cui vengono archiviate le immagini importate nel controllo ImageList. + + + + Image Size + Dimensioni immagine + + Chooses an ImageList to use with this TreeView Consente di selezionare il controllo ImageList da utilizzare con il controllo TreeView selezionato. @@ -1712,6 +1977,181 @@ Per accettare testo premere CTRL+INVIO. {0} [stringa troncata]"; + + Add Tab + Aggiungi scheda + + + + Add tab to '{0}' + Aggiunge una scheda a '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Impossibile aggiungere '{0}' a una classe TabControl. Solo gli oggetti TabPage possono essere aggiunti direttamente a oggetti TabControl. + + + + Remove Tab + Rimuovi scheda + + + + Remove tab '{0}' from '{1}' + Rimuove la scheda '{0}' da '{1}' + + + + A&bsolute + A&ssoluto + + + + &Add Column + &Aggiungi colonna + + + + Add Column on {0} + Aggiungi colonna su {0} + + + + &Add + &Aggiungi + + + + Add Ro&w + Aggi&ungi riga + + + + Add Row on {0} + Aggiungi riga su {0} + + + + A&utoSize + A&utoSize + + + + Change SizeType on {0} + Modifica SizeType su {0} + + + + Clearing Anchor property of {0} for {1} + Cancellazione della proprietà Anchor di {0} per {1} in corso... + + + + Clearing Dock property of {0} for {1} + Cancellazione della proprietà Dock di {0} per {1} in corso... + + + + &Column + &Colonna + + + + C&opy TableLayoutPanel + C&opia TableLayoutPanel + + + + &Cut TableLayoutPanel + &Taglia TableLayoutPanel + + + + &Delete TableLayoutPanel + &Elimina TableLayoutPanel + + + + {0} swapped with {1} + Il controllo {0} è stato scambiato con {1}. + + + + &Delete + &Elimina + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Modifica righe e colonne... + + + + &Insert + &Inserisci + + + + {0} must be greater than zero. + {0} deve essere maggiore di zero. + + + + SizeMode + SizeMode + + + + &Percentage + &Percentuale + + + + Remove Last Colu&mn + Rimuovi ulti&ma colonna + + + + Remove Column on {0} + Rimuovi colonna su {0} + + + + Remo&ve Last Row + Rimuo&vi ultima riga + + + + Remove Row on {0} + Rimuovi riga su {0} + + + + &Row + &Riga + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Impossibile creare righe o colonne aggiuntive. TableLayoutPanel è pieno e GrowStyle è 'FixedSize'. + + + + Resizing {0} within {1} + Ridimensionamento di {0} in {1} in corso... + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + Impossibile espandere TableLayoutPanel affinché contenga il controllo perché la proprietà GrowStyle del riquadro è impostata su 'FixedSize'. + + Dock: Dock: @@ -1757,6 +2197,56 @@ Per accettare testo premere CTRL+INVIO. Le proprietà AllowItemReorder e AllowDrop non possono avere entrambe valore true. + + Bottom + Inferiore + + + + Toggles the participation of BottomToolStripPanel in runtime dragging of ToolStrip. + Attiva o disattiva la partecipazione di BottomToolStripPanel durante il trascinamento di ToolStrip in fase di esecuzione. + + + + Left + Sinistro + + + + Toggles the participation of LeftToolStripPanel in runtime dragging of ToolStrip. + Attiva o disattiva la partecipazione di LeftToolStripPanel durante il trascinamento di ToolStrip in fase di esecuzione. + + + + Right + Destro + + + + Toggles the participation of RightToolStripPanel in runtime dragging of ToolStrip. + Attiva o disattiva la partecipazione di RightToolStripPanel durante il trascinamento di ToolStrip in fase di esecuzione. + + + + Show + Mostra + + + + Top + Superiore + + + + Toggles the participation of TopToolStripPanel in runtime dragging of ToolStrip. + Attiva o disattiva la partecipazione di TopToolStripPanel durante il trascinamento di ToolStrip in fase di esecuzione. + + + + Panel Visibility + Visibilità pannello + + ToolStrip New Item create Transaction. Transazione Crea nuovo elemento del controllo ToolStrip @@ -1862,6 +2352,11 @@ Per accettare testo premere CTRL+INVIO. Transazione Morphing del controllo ToolStripItem. + + Unsupported Dock + Ancoraggio non supportato + + '{0}' '{0}' diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf index 85b53bd0403..c01d36b57fc 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf @@ -2,6 +2,11 @@ + + {0} Reparent Controls Transaction. + {0} でのコントロールの親の再設定のトランザクション。 + + Could not create ActiveX control '{0}' because it is not properly registered. 正しく登録されていないため、ActiveX コントロール '{0}' を作成できませんでした。 @@ -227,6 +232,11 @@ 選択されたプレビュー + + Choose Icon... + アイコンの選択... + + Select the image displayed in the PictureBox PictureBox に表示されているイメージを選択してください @@ -641,11 +651,136 @@ この厳密に型指定されたリソース クラスを使用したリソースの検索。 + + Add Column + Add Column + + + + &Add Column... + &Add Column... + + + + Bound Column &Properties + Bound Column &Properties + + + + Choose Data Source: + Choose Data Source: + + + + {0} DataSource changed + {0} DataSource changed + + + + The DataGridViewColumn type. + The DataGridViewColumn type. + + + + Unable to create columns for the data source. The data source is no longer valid + Unable to create columns for the data source. The data source is no longer valid + + + + Disable Adding + Disable Adding + + + + Disable Column Reordering + Disable Column Reordering + + + + Disable Deleting + Disable Deleting + + + + Disable Editing + Disable Editing + + + + The name {0} is already in use by another column. + The name {0} is already in use by another column. + + + + Edit Columns + Edit Columns + + + + &Edit Columns... + &Edit Columns... + + + + Enable Adding + Enable Adding + + + + Enable Adding + Enable Adding + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Deleting + Enable Deleting + + + + Enable Deleting + Enable Deleting + + + + Enable Editing + Enable Editing + + + + Enable Editing + Enable Editing + + + + &Properties + &Properties + + + + Unbound Column &Properties + Unbound Column &Properties + + Cancel キャンセル + + Close + Close + + OK OK @@ -656,6 +791,91 @@ データソース プロパティを設定したときに Items コレクションを変更することはできません。 + + Data binding editor + データ バインディング エディター + + + + Add new Object Data Source... + オブジェクト データ ソースを追加します... + + + + Click the 'Add Project Data Source...' link to connect to data. + [プロジェクト データ ソースの追加...] をクリックして、データに接続します。 + + + + Currently data bound to '{0}'. + データは現在 '{0}' にバインドしています。 + + + + Select a BindingSource to bind to. + バインド先の BindingSource を選択してください。 + + + + Select a data source under 'Other Data Sources' to connect to data. + [他のデータ ソース] のデータを選択して、データに接続します。 + + + + Select a data member to bind to. + バインドするデータ メンバーを選択します。 + + + + Contains all form components that implement IList, IListSource or Array. + IList、IListSource または Array を実装するすべてのフォームのコンポーネントを含んでいます。 + + + + Selecting 'None' clears the current data binding. + [なし] を選択すると、現在のデータ バインディングをクリアします。 + + + + Contains all project data sources and local form list instances. + すべてのプロジェクト データ ソースおよびローカルのフォーム一覧インスタンスを含んでいます。 + + + + Contains all project data sources. + すべてのプロジェクト データ ソースを含んでいます。 + + + + Contains project data sources belonging to this namespace. + 名前空間に属するプロジェクト データ ソースを含んでいます。 + + + + {0} List Instances + {0} 一覧インスタンス + + + + None + なし + + + + Other Data Sources + 他のデータ ソース + + + + Project Data Sources + プロジェクト データ ソース + + + + Bindable data sources and data members + バインド可能なデータ ソースおよびデータ メンバー + + Could not convert value '{0}' to the type '{1}'. 値 '{0}' を型 '{1}' に変換できませんでした。 @@ -905,16 +1125,31 @@ オブジェクトを識別するコードで使われる名前です。 + + Dock Fill in Form + フォームの四辺にドッキングする + + Dock in Parent Container 親コンテナーにドッキングする + + Dock Fill in UserControl + UserControl の四辺にドッキングする + + Horizontal Splitter Orientation. 上下スプリッターの方向。 + + Re-parent Controls + コントロールの親を再指定する + + Undock in Parent Container 親コンテナーでドッキングを解除する @@ -1080,6 +1315,36 @@ イメージ コレクション エディター + + Opens the Images collection editor + イメージ コレクション エディターを開きます + + + + Choose images + イメージの選択 + + + + Changes the bit depth images imported into this ImageList are stored at + 次の場所に保存されたこの ImageList にインポートされるビットの深さのイメージを変更します: + + + + Image Bit Depth + イメージ ビットの深さ + + + + Changes the size images imported into this ImageList are stored at + 次の場所に保存されたこの ImageList にインポートされるビットの深さのイメージを変更します: + + + + Image Size + イメージ サイズ + + Chooses an ImageList to use with this TreeView この TreeView に使用する ImageList を選択します @@ -1712,6 +1977,181 @@ Press Ctrl+Enter to accept Text. {0} [残りの文字列は切り詰められました]"; + + Add Tab + タブの追加 + + + + Add tab to '{0}' + タブを '{0}' に追加 + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + '{0}' を TabControl に追加できません。 TabPages のみを直接 TabControls に追加できます。 + + + + Remove Tab + タブの削除 + + + + Remove tab '{0}' from '{1}' + タブ '{0}' を '{1}' から削除 + + + + A&bsolute + 絶対サイズ(&B) + + + + &Add Column + 列の追加(&A) + + + + Add Column on {0} + {0} 上の列の追加 + + + + &Add + 追加(&A) + + + + Add Ro&w + 行の追加(&W) + + + + Add Row on {0} + {0} 上の行の追加 + + + + A&utoSize + 自動調整(&U) + + + + Change SizeType on {0} + {0} 上の SizeType の変更 + + + + Clearing Anchor property of {0} for {1} + {0} の Anchor プロパティを {1} のためにクリアしています。 + + + + Clearing Dock property of {0} for {1} + {0} の Dock プロパティを {1} のためにクリアしています。 + + + + &Column + 列(&C) + + + + C&opy TableLayoutPanel + TableLayoutPanel のコピー(&O) + + + + &Cut TableLayoutPanel + TableLayoutPanel の切り取り(&C) + + + + &Delete TableLayoutPanel + TableLayoutPanel の削除(&D) + + + + {0} swapped with {1} + {0} は {1} と交換されました + + + + &Delete + 削除(&D) + + + + 0 + 0 + + + + &Edit Rows and Columns... + 行および列の編集(&E)... + + + + &Insert + 挿入(&I) + + + + {0} must be greater than zero. + {0} は 0 より大きくなければなりません。 + + + + SizeMode + SizeMode + + + + &Percentage + パーセンテージ(&P) + + + + Remove Last Colu&mn + 最終列の削除(&M) + + + + Remove Column on {0} + {0} 上の列の削除 + + + + Remo&ve Last Row + 最終行の削除(&V) + + + + Remove Row on {0} + {0} 上の行の削除 + + + + &Row + 行(&R) + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + 追加の行または列を作成できません。 TableLayoutPanel はいっぱいであり、GrowStyle は 'FixedSize' に設定されています。 + + + + Resizing {0} within {1} + {0} を {1} でリサイズしています。 + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + パネルの GrowStyle プロパティが 'FixedSize' に設定されているため、TableLayoutPanel を拡張してコントロールを含めることはできません。 + + Dock: ドッキング: @@ -1757,6 +2197,56 @@ Press Ctrl+Enter to accept Text. AllowItemReorder と AllowDrop の両方を true にすることはできません。 + + Bottom + + + + + Toggles the participation of BottomToolStripPanel in runtime dragging of ToolStrip. + ToolStrip の実行時のドラッグでの BottomToolStripPanel の表示を切り替えます + + + + Left + + + + + Toggles the participation of LeftToolStripPanel in runtime dragging of ToolStrip. + ToolStrip の実行時のドラッグでの LeftToolStripPanel の表示を切り替えます + + + + Right + + + + + Toggles the participation of RightToolStripPanel in runtime dragging of ToolStrip. + ToolStrip の実行時のドラッグでの RightToolStripPanel の表示を切り替えます + + + + Show + 表示 + + + + Top + + + + + Toggles the participation of TopToolStripPanel in runtime dragging of ToolStrip. + ToolStrip の実行時のドラッグでの TopToolStripPanel の表示を切り替えます + + + + Panel Visibility + パネルの表示 + + ToolStrip New Item create Transaction. ToolStrip の新しいアイテムの作成トランザクションです。 @@ -1862,6 +2352,11 @@ Press Ctrl+Enter to accept Text. ToolStripItem モーフィング のトランザクションです。 + + Unsupported Dock + サポートされていないドッキングです + + '{0}' '{0}' diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf index 97c63d80de1..8167b69574a 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf @@ -2,6 +2,11 @@ + + {0} Reparent Controls Transaction. + {0}이(가) 컨트롤 트랜잭션의 부모를 다시 지정합니다. + + Could not create ActiveX control '{0}' because it is not properly registered. '{0}' ActiveX 컨트롤이 제대로 등록되어 있지 않으므로 이 컨트롤을 만들 수 없습니다. @@ -227,6 +232,11 @@ 선택된 미리 보기 + + Choose Icon... + 아이콘 선택... + + Select the image displayed in the PictureBox PictureBox에 표시된 이미지를 선택합니다. @@ -641,11 +651,136 @@ 이 강력한 형식의 리소스 클래스를 사용하는 리소스를 조회합니다. + + Add Column + Add Column + + + + &Add Column... + &Add Column... + + + + Bound Column &Properties + Bound Column &Properties + + + + Choose Data Source: + Choose Data Source: + + + + {0} DataSource changed + {0} DataSource changed + + + + The DataGridViewColumn type. + The DataGridViewColumn type. + + + + Unable to create columns for the data source. The data source is no longer valid + Unable to create columns for the data source. The data source is no longer valid + + + + Disable Adding + Disable Adding + + + + Disable Column Reordering + Disable Column Reordering + + + + Disable Deleting + Disable Deleting + + + + Disable Editing + Disable Editing + + + + The name {0} is already in use by another column. + The name {0} is already in use by another column. + + + + Edit Columns + Edit Columns + + + + &Edit Columns... + &Edit Columns... + + + + Enable Adding + Enable Adding + + + + Enable Adding + Enable Adding + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Deleting + Enable Deleting + + + + Enable Deleting + Enable Deleting + + + + Enable Editing + Enable Editing + + + + Enable Editing + Enable Editing + + + + &Properties + &Properties + + + + Unbound Column &Properties + Unbound Column &Properties + + Cancel 취소 + + Close + Close + + OK 확인 @@ -656,6 +791,91 @@ DataSource 속성이 설정된 경우에는 Items 컬렉션을 수정할 수 없습니다. + + Data binding editor + 데이터 바인딩 편집기 + + + + Add new Object Data Source... + 새 개체 데이터 원본 추가... + + + + Click the 'Add Project Data Source...' link to connect to data. + 데이터에 연결하려면 '프로젝트 데이터 소스 추가...' 링크를 클릭하십시오. + + + + Currently data bound to '{0}'. + 현재 데이터가 '{0}'에 바인딩되어 있습니다. + + + + Select a BindingSource to bind to. + 바인딩할 BindingSource를 선택하십시오. + + + + Select a data source under 'Other Data Sources' to connect to data. + 데이터에 연결하려면 '기타 데이터 소스' 아래에 있는 데이터 소스를 선택하십시오. + + + + Select a data member to bind to. + 바인딩할 데이터 멤버를 선택하십시오. + + + + Contains all form components that implement IList, IListSource or Array. + IList, IListSource 또는 Array를 구현하는 모든 폼 구성 요소를 포함합니다. + + + + Selecting 'None' clears the current data binding. + '없음'을 선택하면 현재 데이터 바인딩이 지워집니다. + + + + Contains all project data sources and local form list instances. + 모든 프로젝트 데이터 소스 및 로컬 폼 목록 인스턴스를 포함합니다. + + + + Contains all project data sources. + 모든 프로젝트 데이터 소스를 포함합니다. + + + + Contains project data sources belonging to this namespace. + 이 네임스페이스에 속해 있는 프로젝트 데이터 소스를 포함합니다. + + + + {0} List Instances + {0} 목록 인스턴스 + + + + None + 없음 + + + + Other Data Sources + 기타 데이터 원본 + + + + Project Data Sources + 프로젝트 데이터 원본 + + + + Bindable data sources and data members + 바인딩 가능 데이터 소스 및 데이터 멤버 + + Could not convert value '{0}' to the type '{1}'. '{0}' 값을 '{1}' 형식으로 변환할 수 없습니다. @@ -905,16 +1125,31 @@ 개체를 식별하기 위해 코드에 사용되는 이름을 나타냅니다. + + Dock Fill in Form + 폼에서 전체 도킹 + + Dock in Parent Container 부모 컨테이너에서 도킹 + + Dock Fill in UserControl + UserControl에서 전체 도킹 + + Horizontal Splitter Orientation. 가로 분할자 방향입니다. + + Re-parent Controls + 컨트롤 부모 재지정 + + Undock in Parent Container 부모 컨테이너에서 도킹 해제 @@ -1080,6 +1315,36 @@ 이미지 컬렉션 편집기 + + Opens the Images collection editor + 이미지 컬렉션 편집기를 엽니다. + + + + Choose images + 이미지 선택 + + + + Changes the bit depth images imported into this ImageList are stored at + 이 ImageList가 저장되어 있는 위치로 가져온 이미지의 비트 수준을 변경합니다. + + + + Image Bit Depth + 이미지 비트 수준 + + + + Changes the size images imported into this ImageList are stored at + 이 ImageList가 저장되어 있는 위치로 가져온 이미지의 크기를 변경합니다. + + + + Image Size + 이미지 크기 + + Chooses an ImageList to use with this TreeView 이 TreeView와 함께 사용할 ImageList를 선택하십시오. @@ -1712,6 +1977,181 @@ Press Ctrl+Enter to accept Text. {0}[나머지 문자열은 잘림]"; + + Add Tab + 탭 추가 + + + + Add tab to '{0}' + '{0}'에 탭을 추가합니다. + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + TabControl에 '{0}'을(를) 추가할 수 없습니다. TabControls에는 TabPages만 직접 추가할 수 있습니다. + + + + Remove Tab + 탭 제거 + + + + Remove tab '{0}' from '{1}' + '{1}'에서 '{0}' 탭을 제거합니다. + + + + A&bsolute + 절대(&B) + + + + &Add Column + 열 추가(&A) + + + + Add Column on {0} + {0}에 열 추가 + + + + &Add + 추가(&A) + + + + Add Ro&w + 행 추가(&W) + + + + Add Row on {0} + {0}에 행 추가 + + + + A&utoSize + 크기 자동 조정(&U) + + + + Change SizeType on {0} + {0}의 SizeType 변경 + + + + Clearing Anchor property of {0} for {1} + {1}에 대한 {0}의 Anchor 속성 지우기 + + + + Clearing Dock property of {0} for {1} + {1}에 대한 {0}의 Dock 속성 지우기 + + + + &Column + 열(&C) + + + + C&opy TableLayoutPanel + TableLayoutPanel 복사(&O) + + + + &Cut TableLayoutPanel + TableLayoutPanel 잘라내기(&C) + + + + &Delete TableLayoutPanel + TableLayoutPanel 삭제(&D) + + + + {0} swapped with {1} + {1}과(와) 대체된 {0} + + + + &Delete + 삭제(&D) + + + + 0 + 0 + + + + &Edit Rows and Columns... + 행 및 열 편집(&E)... + + + + &Insert + 삽입(&I) + + + + {0} must be greater than zero. + {0}은(는) 0보다 커야 합니다. + + + + SizeMode + SizeMode + + + + &Percentage + 백분율(&P) + + + + Remove Last Colu&mn + 마지막 열 제거(&M) + + + + Remove Column on {0} + {0}에서 열 제거 + + + + Remo&ve Last Row + 마지막 행 제거(&V) + + + + Remove Row on {0} + {0}에서 행 제거 + + + + &Row + 행(&R) + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + 추가 행이나 열을 만들 수 없습니다. TableLayoutPanel에 여유 공간이 없고 GrowStyle이 'FixedSize'입니다. + + + + Resizing {0} within {1} + {1}에서 {0} 크기 조정 + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + 패널의 GrowStyle 속성이 'FixedSize'로 설정되어 있으므로 컨트롤을 포함하도록 TableLayoutPanel을 확장할 수 없습니다. + + Dock: 도킹: @@ -1757,6 +2197,56 @@ Press Ctrl+Enter to accept Text. AllowItemReorder 및 AllowDrop이 모두 true일 수 없습니다. + + Bottom + 아래쪽 + + + + Toggles the participation of BottomToolStripPanel in runtime dragging of ToolStrip. + ToolStrip의 런타임 끌기 동작에서 BottomToolStripPanel의 사용을 설정/해제합니다. + + + + Left + 왼쪽 + + + + Toggles the participation of LeftToolStripPanel in runtime dragging of ToolStrip. + ToolStrip의 런타임 끌기 동작에서 LeftToolStripPanel의 사용을 설정/해제합니다. + + + + Right + 오른쪽 + + + + Toggles the participation of RightToolStripPanel in runtime dragging of ToolStrip. + ToolStrip의 런타임 끌기 동작에서 RightToolStripPanel의 사용을 설정/해제합니다. + + + + Show + 표시 + + + + Top + 위쪽 + + + + Toggles the participation of TopToolStripPanel in runtime dragging of ToolStrip. + ToolStrip의 런타임 끌기 동작에서 TopToolStripPanel의 사용을 설정/해제합니다. + + + + Panel Visibility + 패널 표시 + + ToolStrip New Item create Transaction. ToolStrip 새 항목 만들기 트랜잭션입니다. @@ -1862,6 +2352,11 @@ Press Ctrl+Enter to accept Text. ToolStripItem 모핑 트랜잭션입니다. + + Unsupported Dock + 지원되지 않는 도킹 + + '{0}' '{0}' diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf index 489583e8730..8ca6fe3b93f 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf @@ -2,6 +2,11 @@ + + {0} Reparent Controls Transaction. + {0} Reparent Controls Transaction. + + Could not create ActiveX control '{0}' because it is not properly registered. Nie można utworzyć formantu ActiveX '{0}', ponieważ nie został on zarejestrowany poprawnie. @@ -227,6 +232,11 @@ Wybrany podgląd + + Choose Icon... + Wybierz ikonę... + + Select the image displayed in the PictureBox Wybierz obraz wyświetlany w polu PictureBox @@ -641,11 +651,136 @@ przypadków przeszukiwania zasobów za pomocą tej klasy zasobów wymagającej zdefiniowania typu. + + Add Column + Add Column + + + + &Add Column... + &Add Column... + + + + Bound Column &Properties + Bound Column &Properties + + + + Choose Data Source: + Choose Data Source: + + + + {0} DataSource changed + {0} DataSource changed + + + + The DataGridViewColumn type. + The DataGridViewColumn type. + + + + Unable to create columns for the data source. The data source is no longer valid + Unable to create columns for the data source. The data source is no longer valid + + + + Disable Adding + Disable Adding + + + + Disable Column Reordering + Disable Column Reordering + + + + Disable Deleting + Disable Deleting + + + + Disable Editing + Disable Editing + + + + The name {0} is already in use by another column. + The name {0} is already in use by another column. + + + + Edit Columns + Edit Columns + + + + &Edit Columns... + &Edit Columns... + + + + Enable Adding + Enable Adding + + + + Enable Adding + Enable Adding + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Deleting + Enable Deleting + + + + Enable Deleting + Enable Deleting + + + + Enable Editing + Enable Editing + + + + Enable Editing + Enable Editing + + + + &Properties + &Properties + + + + Unbound Column &Properties + Unbound Column &Properties + + Cancel Anuluj + + Close + Close + + OK OK @@ -656,6 +791,91 @@ Kolekcji elementów nie można modyfikować, gdy ustawiona jest właściwość DataSource. + + Data binding editor + Edytor powiązań danych + + + + Add new Object Data Source... + Dodaj nowe źródło danych obiektu... + + + + Click the 'Add Project Data Source...' link to connect to data. + Kliknij łącze 'Dodaj źródło danych projektu...', aby połączyć się z danymi. + + + + Currently data bound to '{0}'. + Obecnie dane są powiązane z '{0}'. + + + + Select a BindingSource to bind to. + Wybierz źródło BindingSource, z którym chcesz powiązać dane. + + + + Select a data source under 'Other Data Sources' to connect to data. + Wybierz źródło danych z listy 'Inne źródła danych', aby połączyć się z danymi. + + + + Select a data member to bind to. + Wybierz składową danych, z którą chcesz powiązać dane. + + + + Contains all form components that implement IList, IListSource or Array. + Zawiera wszystkie składniki formularza, w których są implementowane elementy IList, IListSource lub Array. + + + + Selecting 'None' clears the current data binding. + Wybór opcji 'Brak' powoduje usunięcie bieżącego powiązania danych. + + + + Contains all project data sources and local form list instances. + Zawiera wszystkie źródła danych projektów i lokalne wystąpienia listy formularzy. + + + + Contains all project data sources. + Zawiera wszystkie źródła danych projektu. + + + + Contains project data sources belonging to this namespace. + Zawiera źródła danych projektu należące do tej przestrzeni nazw. + + + + {0} List Instances + Wystąpienia listy {0} + + + + None + Brak + + + + Other Data Sources + Inne źródła danych + + + + Project Data Sources + Źródła danych projektu + + + + Bindable data sources and data members + Źródła danych i składowe danych do powiązania + + Could not convert value '{0}' to the type '{1}'. Nie można konwertować wartości '{0}' na typ '{1}'. @@ -905,16 +1125,31 @@ Wskazuje nazwę używaną w kodzie do określania obiektu. + + Dock Fill in Form + Zadokuj z wypełnieniem w formularzu + + Dock in Parent Container Zadokuj w kontenerze nadrzędnym + + Dock Fill in UserControl + Zadokuj z wypełnieniem w formancie UserControl + + Horizontal Splitter Orientation. Pozioma orientacja rozdzielacza. + + Re-parent Controls + Ponownie określ formanty nadrzędne + + Undock in Parent Container Oddokuj w kontenerze nadrzędnym @@ -1080,6 +1315,36 @@ Edytor kolekcji obrazów + + Opens the Images collection editor + Otwiera edytora kolekcji obrazów + + + + Choose images + Wybierz obrazy + + + + Changes the bit depth images imported into this ImageList are stored at + Zmienia lokalizację, w której są przechowywane obrazy z głębią bitową importowane do tej listy ImageList + + + + Image Bit Depth + Głębia bitowa obrazu + + + + Changes the size images imported into this ImageList are stored at + Zmienia lokalizację, w której są przechowywane obrazy o określonych rozmiarach importowane do tej listy ImageList + + + + Image Size + Rozmiar obrazu + + Chooses an ImageList to use with this TreeView Wybiera listę ImageList do użycia w tym widoku TreeView @@ -1712,6 +1977,181 @@ Naciśnij klawisze Ctrl+Enter, aby zaakceptować tekst. {0} [obcięto pozostałą część ciągu]"; + + Add Tab + Dodaj kartę + + + + Add tab to '{0}' + Dodaj kartę do '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Nie można dodać '{0}' do elementu TabControl. Tylko elementy TabPage mogą być bezpośrednio dodawane do elementów TabControl. + + + + Remove Tab + Usuń kartę + + + + Remove tab '{0}' from '{1}' + Usuń kartę '{0}' z '{1}' + + + + A&bsolute + &Bezwzględna + + + + &Add Column + &Dodaj kolumnę + + + + Add Column on {0} + Dodaj kolumnę z {0} + + + + &Add + &Dodaj + + + + Add Ro&w + &Dodaj wiersz + + + + Add Row on {0} + Dodaj wiersz z {0} + + + + A&utoSize + &AutoSize + + + + Change SizeType on {0} + Zmień SizeType z {0} + + + + Clearing Anchor property of {0} for {1} + Czyszczenie właściwości Anchor {0} dla {1} + + + + Clearing Dock property of {0} for {1} + Czyszczenie właściwości Dock {0} dla {1} + + + + &Column + &Kolumna + + + + C&opy TableLayoutPanel + &Kopiuj TableLayoutPanel + + + + &Cut TableLayoutPanel + &Wytnij TableLayoutPanel + + + + &Delete TableLayoutPanel + &Usuń TableLayoutPanel + + + + {0} swapped with {1} + {0} zamieniono z {1} + + + + &Delete + &Usuń + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Edytuj wiersze i kolumny... + + + + &Insert + &Wstaw + + + + {0} must be greater than zero. + Wartość {0} musi być większa od zera. + + + + SizeMode + SizeMode + + + + &Percentage + &Wartość procentowa + + + + Remove Last Colu&mn + &Usuń ostatnią kolumnę + + + + Remove Column on {0} + Usuń kolumnę z {0} + + + + Remo&ve Last Row + &Usuń ostatni wiersz + + + + Remove Row on {0} + Usuń wiersz z {0} + + + + &Row + &Wiersz + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Nie można utworzyć dodatkowych wierszy ani kolumn. Obiekt TableLayoutPanel jest zapełniony, a właściwość GrowStyle ma wartość „FixedSize”. + + + + Resizing {0} within {1} + Zmienianie rozmiaru {0} w {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + Obiektu TableLayoutPanel nie można rozwinąć w celu pomieszczenia formantu, ponieważ właściwość GrowStyle panelu ma ustawioną wartość FixedSize. + + Dock: Zadokuj: @@ -1757,6 +2197,56 @@ Naciśnij klawisze Ctrl+Enter, aby zaakceptować tekst. Wartości AllowItemReorder i AllowDrop nie mogą być jednocześnie prawdziwe. + + Bottom + Dół + + + + Toggles the participation of BottomToolStripPanel in runtime dragging of ToolStrip. + Włącza/wyłącza udział elementu BottomToolStripPanel w przeciąganiu elementu ToolStrip podczas pracy. + + + + Left + Lewa + + + + Toggles the participation of LeftToolStripPanel in runtime dragging of ToolStrip. + Włącza/wyłącza udział elementu LeftToolStripPanel w przeciąganiu elementu ToolStrip podczas pracy. + + + + Right + Prawa + + + + Toggles the participation of RightToolStripPanel in runtime dragging of ToolStrip. + Włącza/wyłącza udział elementu RightToolStripPanel w przeciąganiu elementu ToolStrip podczas pracy. + + + + Show + Pokaż + + + + Top + Góra + + + + Toggles the participation of TopToolStripPanel in runtime dragging of ToolStrip. + Włącza/wyłącza udział elementu TopToolStripPanel w przeciąganiu elementu ToolStrip podczas pracy. + + + + Panel Visibility + Widoczność panelu + + ToolStrip New Item create Transaction. Operacja tworzenia nowego elementu ToolStrip. @@ -1862,6 +2352,11 @@ Naciśnij klawisze Ctrl+Enter, aby zaakceptować tekst. Operacja przekształcania właściwości ToolStripItem. + + Unsupported Dock + Nieobsługiwany element Dock + + '{0}' '{0}' diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf index ac10f0151d3..ec32e726e52 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf @@ -2,6 +2,11 @@ + + {0} Reparent Controls Transaction. + {0} Transação de Controles de Reassociação ao Pai. + + Could not create ActiveX control '{0}' because it is not properly registered. Não foi possível criar o controle ActiveX '{0}' porque ele não está registrado corretamente. @@ -227,6 +232,11 @@ Visualização Selecionada + + Choose Icon... + Escolher Ícone... + + Select the image displayed in the PictureBox Selecionar a imagem exibida em PictureBox @@ -641,11 +651,136 @@ pesquisas de recursos que usam essa classe de recurso de tipo de alta segurança. + + Add Column + Add Column + + + + &Add Column... + &Add Column... + + + + Bound Column &Properties + Bound Column &Properties + + + + Choose Data Source: + Choose Data Source: + + + + {0} DataSource changed + {0} DataSource changed + + + + The DataGridViewColumn type. + The DataGridViewColumn type. + + + + Unable to create columns for the data source. The data source is no longer valid + Unable to create columns for the data source. The data source is no longer valid + + + + Disable Adding + Disable Adding + + + + Disable Column Reordering + Disable Column Reordering + + + + Disable Deleting + Disable Deleting + + + + Disable Editing + Disable Editing + + + + The name {0} is already in use by another column. + The name {0} is already in use by another column. + + + + Edit Columns + Edit Columns + + + + &Edit Columns... + &Edit Columns... + + + + Enable Adding + Enable Adding + + + + Enable Adding + Enable Adding + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Deleting + Enable Deleting + + + + Enable Deleting + Enable Deleting + + + + Enable Editing + Enable Editing + + + + Enable Editing + Enable Editing + + + + &Properties + &Properties + + + + Unbound Column &Properties + Unbound Column &Properties + + Cancel Cancelar + + Close + Close + + OK OK @@ -656,6 +791,91 @@ Não é possível modificar a coleção de itens quando a propriedade DataSource está definida. + + Data binding editor + Editor de associação de dados + + + + Add new Object Data Source... + Adicionar nova Fonte de Dados Objeto... + + + + Click the 'Add Project Data Source...' link to connect to data. + Clique no link 'Adicionar Fonte de Dados do Projeto...' para estabelecer conexão com os dados. + + + + Currently data bound to '{0}'. + Dados atualmente associados a '{0}'. + + + + Select a BindingSource to bind to. + Selecione uma BindingSource para ligar. + + + + Select a data source under 'Other Data Sources' to connect to data. + Selecione uma fonte de dados em 'Outras Fontes de Dados' para conectar aos dados. + + + + Select a data member to bind to. + Selecione um associado de dados para ligar. + + + + Contains all form components that implement IList, IListSource or Array. + Contém todos os componentes do formulário que implementam IList, IListSource ou Array. + + + + Selecting 'None' clears the current data binding. + A seleção de 'None' limpa a associação de dados atual. + + + + Contains all project data sources and local form list instances. + Contém todas as fontes de dados do projeto e as instâncias de lista de formulários locais. + + + + Contains all project data sources. + Contém todas as fontes de dados do projeto. + + + + Contains project data sources belonging to this namespace. + Contém fontes de dados do projeto pertencentes a esse namespace. + + + + {0} List Instances + {0} Instâncias de Lista + + + + None + Nenhum + + + + Other Data Sources + Outras Fontes de Dados + + + + Project Data Sources + Fontes de Dados do Projeto + + + + Bindable data sources and data members + Fontes e associados de dados vinculáveis + + Could not convert value '{0}' to the type '{1}'. Não foi possível converter o valor '{0}' no tipo '{1}'. @@ -905,16 +1125,31 @@ Indica o nome usado no código para identificar o objeto. + + Dock Fill in Form + Dock Fill no Formulário + + Dock in Parent Container Encaixar no Contêiner Pai + + Dock Fill in UserControl + Dock Fill em UserControl + + Horizontal Splitter Orientation. Orientação Horizontal do Divisor. + + Re-parent Controls + Especificar Novamente o Pai dos Controles + + Undock in Parent Container Desencaixar do Contêiner Pai @@ -1080,6 +1315,36 @@ Editor de Coleção de Imagens + + Opens the Images collection editor + Abre o Editor de coleção de imagens + + + + Choose images + Escolher imagens + + + + Changes the bit depth images imported into this ImageList are stored at + Altera a intensidade de bits com a qual as imagens importadas para essa ImageList são armazenadas + + + + Image Bit Depth + Intensidade de bits da imagem + + + + Changes the size images imported into this ImageList are stored at + Altera o tamanho com o qual as imagens importadas para essa ImageList são armazenadas + + + + Image Size + Tamanho da Imagem + + Chooses an ImageList to use with this TreeView Escolhe uma ImageList para usar com esse TreeView @@ -1712,6 +1977,181 @@ Pressione Ctrl+Enter para aceitar Texto. {0} [o restante da cadeia de caracteres foi truncado]"; + + Add Tab + Adicionar Guia + + + + Add tab to '{0}' + Adicionar guia a '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Não é possível adicionar '{0}' a TabControl. Somente TabPages pode ser diretamente adicionado a TabControls. + + + + Remove Tab + Remover Guia + + + + Remove tab '{0}' from '{1}' + Remover guia '{0}' de '{1}' + + + + A&bsolute + A&bsoluto + + + + &Add Column + &Adicionar Coluna + + + + Add Column on {0} + Adicionar Coluna a {0} + + + + &Add + &Adicionar + + + + Add Ro&w + Adicionar Li&nha + + + + Add Row on {0} + Adicionar Linha a {0} + + + + A&utoSize + Dimensionamento A&utomático + + + + Change SizeType on {0} + Alterar SizeType em {0} + + + + Clearing Anchor property of {0} for {1} + Limpando a propriedade Anchor de {0} para {1} + + + + Clearing Dock property of {0} for {1} + Limpando a propriedade Dock de {0} para {1} + + + + &Column + &Coluna + + + + C&opy TableLayoutPanel + C&opiar TableLayoutPanel + + + + &Cut TableLayoutPanel + Recor&tar TableLayoutPanel + + + + &Delete TableLayoutPanel + &Excluir TableLayoutPanel + + + + {0} swapped with {1} + {0} trocado por {1} + + + + &Delete + &Excluir + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Editar Linhas e Colunas... + + + + &Insert + &Inserir + + + + {0} must be greater than zero. + {0} deve ser maior que zero. + + + + SizeMode + SizeMode + + + + &Percentage + &Porcentagem + + + + Remove Last Colu&mn + Remover Última Colu&na + + + + Remove Column on {0} + Remover Coluna em {0} + + + + Remo&ve Last Row + Remo&ver Última Linha + + + + Remove Row on {0} + Remover Linha em {0} + + + + &Row + &Linha + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Não é possível criar Colunas ou Linhas adicionais. TableLayoutPanel está cheio e GrowDirection é 'FixedSize'. + + + + Resizing {0} within {1} + Redimensionando {0} em {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel não pode se expandir para conter o controle, pois a propriedade GrowStyle do painel está definida como 'FixedSize'. + + Dock: Encaixar: @@ -1757,6 +2197,56 @@ Pressione Ctrl+Enter para aceitar Texto. AllowItemReorder e AllowDrop não podem ser verdadeiros. + + Bottom + Inferior + + + + Toggles the participation of BottomToolStripPanel in runtime dragging of ToolStrip. + Alterna a participação de BottomToolStripPanel ao arrastar ToolStrip em tempo de execução. + + + + Left + Esquerda + + + + Toggles the participation of LeftToolStripPanel in runtime dragging of ToolStrip. + Alterna a participação de LeftToolStripPanel ao arrastar ToolStrip em tempo de execução. + + + + Right + Direita + + + + Toggles the participation of RightToolStripPanel in runtime dragging of ToolStrip. + Alterna a participação de RightToolStripPanel ao arrastar ToolStrip em tempo de execução. + + + + Show + Mostrar + + + + Top + Superior + + + + Toggles the participation of TopToolStripPanel in runtime dragging of ToolStrip. + Alterna a participação de TopToolStripPanel ao arrastar ToolStrip em tempo de execução. + + + + Panel Visibility + Visibilidade do Painel + + ToolStrip New Item create Transaction. Transação de criação de Novo Item de ToolStrip. @@ -1862,6 +2352,11 @@ Pressione Ctrl+Enter para aceitar Texto. Transação de Metamorfose de ToolStripItem. + + Unsupported Dock + Dock sem suporte + + '{0}' '{0}' diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf index f5dfc4a8749..d2c1901ac6d 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf @@ -2,6 +2,11 @@ + + {0} Reparent Controls Transaction. + Транзакция переподчиненных элементов управления {0}. + + Could not create ActiveX control '{0}' because it is not properly registered. Невозможно создать элемент управления ActiveX '{0}', так как он не был должным образом зарегистрирован. @@ -227,6 +232,11 @@ Выборочный предварительный просмотр + + Choose Icon... + Выбрать значок... + + Select the image displayed in the PictureBox Выберите изображение, отображаемое в поле PictureBox @@ -641,11 +651,136 @@ поиск ресурса с помощью этого класса ресурса со строгой типизацией. + + Add Column + Add Column + + + + &Add Column... + &Add Column... + + + + Bound Column &Properties + Bound Column &Properties + + + + Choose Data Source: + Choose Data Source: + + + + {0} DataSource changed + {0} DataSource changed + + + + The DataGridViewColumn type. + The DataGridViewColumn type. + + + + Unable to create columns for the data source. The data source is no longer valid + Unable to create columns for the data source. The data source is no longer valid + + + + Disable Adding + Disable Adding + + + + Disable Column Reordering + Disable Column Reordering + + + + Disable Deleting + Disable Deleting + + + + Disable Editing + Disable Editing + + + + The name {0} is already in use by another column. + The name {0} is already in use by another column. + + + + Edit Columns + Edit Columns + + + + &Edit Columns... + &Edit Columns... + + + + Enable Adding + Enable Adding + + + + Enable Adding + Enable Adding + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Deleting + Enable Deleting + + + + Enable Deleting + Enable Deleting + + + + Enable Editing + Enable Editing + + + + Enable Editing + Enable Editing + + + + &Properties + &Properties + + + + Unbound Column &Properties + Unbound Column &Properties + + Cancel Отмена + + Close + Close + + OK ОК @@ -656,6 +791,91 @@ Изменение коллекции элементов невозможно, если задано свойство DataSource. + + Data binding editor + Редактор привязки данных + + + + Add new Object Data Source... + Добавить новый источник данных объекта... + + + + Click the 'Add Project Data Source...' link to connect to data. + Щелкните ссылку 'Добавить источник данных проекта...', чтобы установить связь с данными. + + + + Currently data bound to '{0}'. + В данный момент данные привязаны к '{0}'. + + + + Select a BindingSource to bind to. + Выберите источник BindingSource для привязки. + + + + Select a data source under 'Other Data Sources' to connect to data. + Выберите источник данных в разделе 'Другие источники данных', чтобы установить связь с данными. + + + + Select a data member to bind to. + Выберите член данных для привязки. + + + + Contains all form components that implement IList, IListSource or Array. + Содержит все компоненты форм, в которых реализованы объекты IList, IListSource или массив. + + + + Selecting 'None' clears the current data binding. + Выбор значения 'Нет' отменяет текущую привязку данных. + + + + Contains all project data sources and local form list instances. + Содержит все источники данных проекта и локальные экземпляры списка форм. + + + + Contains all project data sources. + Содержит все источники данных проекта. + + + + Contains project data sources belonging to this namespace. + Содержит источники данных проекта, принадлежащие этому пространству имен. + + + + {0} List Instances + {0} Экземпляры списка + + + + None + Нет + + + + Other Data Sources + Другие источники данных + + + + Project Data Sources + Источники данных проекта + + + + Bindable data sources and data members + Привязываемые источники данных и члены данных + + Could not convert value '{0}' to the type '{1}'. Невозможно преобразовать значение '{0}' в тип '{1}'. @@ -905,16 +1125,31 @@ Указывает имя, используемое в коде для идентификации объекта. + + Dock Fill in Form + Заполнение дока в форме + + Dock in Parent Container Закрепить в родительском контейнере + + Dock Fill in UserControl + Заполнение дока в UserControl + + Horizontal Splitter Orientation. Горизонтальная ориентация разделителя + + Re-parent Controls + Повторно указать родителей для элементов управления + + Undock in Parent Container Открепить в родительском контейнере @@ -1080,6 +1315,36 @@ Редактор коллекции изображений + + Opens the Images collection editor + Открывает редактор коллекции изображений + + + + Choose images + Выберите изображения + + + + Changes the bit depth images imported into this ImageList are stored at + Меняет разрядность, в которой хранятся изображения, импортированные в этот ImageList + + + + Image Bit Depth + Разрядность изображения + + + + Changes the size images imported into this ImageList are stored at + Меняет размер, в котором хранятся изображения, импортированные в этот ImageList + + + + Image Size + Размер изображения + + Chooses an ImageList to use with this TreeView Выбирает ImageList для использования с этим TreeView @@ -1712,6 +1977,181 @@ Press Ctrl+Enter to accept Text. {0} [остаток строки усечен]"; + + Add Tab + Добавить вкладку + + + + Add tab to '{0}' + Добавить вкладку в '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Невозможно добавить {0} к TabControl. К TabControls могут напрямую добавляться только TabPage. + + + + Remove Tab + Удалить вкладку + + + + Remove tab '{0}' from '{1}' + Удалить вкладку "{0}" из "{1}" + + + + A&bsolute + А&бсолютный + + + + &Add Column + Добави&ть столбец + + + + Add Column on {0} + Добавить столбец в {0} + + + + &Add + До&бавить + + + + Add Ro&w + Добав&ить строку + + + + Add Row on {0} + Добавить строку в {0} + + + + A&utoSize + Автора&змер + + + + Change SizeType on {0} + Изменить SizeType в {0} + + + + Clearing Anchor property of {0} for {1} + Очистка свойства Anchor из {0} для {1} + + + + Clearing Dock property of {0} for {1} + Очистка свойства Dock из {0} для {1} + + + + &Column + &Столбец + + + + C&opy TableLayoutPanel + Коп&ировать TableLayoutPanel + + + + &Cut TableLayoutPanel + В&ырезать TableLayoutPanel + + + + &Delete TableLayoutPanel + &Удалить TableLayoutPanel + + + + {0} swapped with {1} + {0} заменяется на {1} + + + + &Delete + &Удалить + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Правка строк и столбцов... + + + + &Insert + &Вставка + + + + {0} must be greater than zero. + Значение {0} должно быть больше нуля. + + + + SizeMode + SizeMode + + + + &Percentage + Проце&нт + + + + Remove Last Colu&mn + Удалить последний сто&лбец + + + + Remove Column on {0} + Удалить столбец в {0} + + + + Remo&ve Last Row + Удалит&ь последнюю строку + + + + Remove Row on {0} + Удалить строку в {0} + + + + &Row + &Строка + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Не удается создать дополнительные элементы Rows или Columns. TableLayoutPanel заполнена, а для параметра GrowStyle задано значение FixedSize. + + + + Resizing {0} within {1} + Изменение размера {0} в {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel нельзя расширить, чтобы включить данный элемент, поскольку для свойства GrowStyle данной панели задано значение FixedSize. + + Dock: Закрепить: @@ -1757,6 +2197,56 @@ Press Ctrl+Enter to accept Text. AllowItemReorder и AllowDrop не могут одновременно иметь значение true. + + Bottom + По нижнему краю + + + + Toggles the participation of BottomToolStripPanel in runtime dragging of ToolStrip. + Включает и выключает участие BottomToolStripPanel в перетаскивании ToolStrip во время выполнения. + + + + Left + По левому краю + + + + Toggles the participation of LeftToolStripPanel in runtime dragging of ToolStrip. + Включает и выключает участие LeftToolStripPanel в перетаскивании ToolStrip во время выполнения. + + + + Right + По правому краю + + + + Toggles the participation of RightToolStripPanel in runtime dragging of ToolStrip. + Включает и выключает участие RightToolStripPanel в перетаскивании ToolStrip во время выполнения. + + + + Show + Показать + + + + Top + По верхнему краю + + + + Toggles the participation of TopToolStripPanel in runtime dragging of ToolStrip. + Включает и выключает участие TopToolStripPanel в перетаскивании ToolStrip во время выполнения. + + + + Panel Visibility + Видимость панели + + ToolStrip New Item create Transaction. Новый элемент ToolStrip создает транзакцию. @@ -1862,6 +2352,11 @@ Press Ctrl+Enter to accept Text. Транзакция преобразования ToolStripItem + + Unsupported Dock + Неподдерживаемое свойство Dock + + '{0}' "{0}" diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf index da1b54851e9..e7a1f412f04 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf @@ -2,6 +2,11 @@ + + {0} Reparent Controls Transaction. + {0} Yeniden Üst Öğe İşlemi Yap. + + Could not create ActiveX control '{0}' because it is not properly registered. Uygun şekilde kayıtlı olmadığından '{0}' öğesinde ActiveX denetimi oluşturulamadı. @@ -227,6 +232,11 @@ Seçili Önizleme + + Choose Icon... + Simge Seç... + + Select the image displayed in the PictureBox PictureBox içinde gösterilen görüntüyü seçin @@ -641,11 +651,136 @@ türü kesin olarak belirtilmiş bu kaynak sınıfını kullanan kaynak aramaları. + + Add Column + Add Column + + + + &Add Column... + &Add Column... + + + + Bound Column &Properties + Bound Column &Properties + + + + Choose Data Source: + Choose Data Source: + + + + {0} DataSource changed + {0} DataSource changed + + + + The DataGridViewColumn type. + The DataGridViewColumn type. + + + + Unable to create columns for the data source. The data source is no longer valid + Unable to create columns for the data source. The data source is no longer valid + + + + Disable Adding + Disable Adding + + + + Disable Column Reordering + Disable Column Reordering + + + + Disable Deleting + Disable Deleting + + + + Disable Editing + Disable Editing + + + + The name {0} is already in use by another column. + The name {0} is already in use by another column. + + + + Edit Columns + Edit Columns + + + + &Edit Columns... + &Edit Columns... + + + + Enable Adding + Enable Adding + + + + Enable Adding + Enable Adding + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Deleting + Enable Deleting + + + + Enable Deleting + Enable Deleting + + + + Enable Editing + Enable Editing + + + + Enable Editing + Enable Editing + + + + &Properties + &Properties + + + + Unbound Column &Properties + Unbound Column &Properties + + Cancel İptal + + Close + Close + + OK Tamam @@ -656,6 +791,91 @@ DataSource özelliği ayarlandığında öğeler koleksiyonu değiştirilemez. + + Data binding editor + Veri bağlama düzenleyicisi + + + + Add new Object Data Source... + Yeni Nesne Veri Kaynağı Ekle... + + + + Click the 'Add Project Data Source...' link to connect to data. + Verilere bağlanmak için 'Proje Veri Kaynağı Ekle...' bağlantısını tıklatın. + + + + Currently data bound to '{0}'. + Şu anda veriler '{0}' ile bağlı durumda. + + + + Select a BindingSource to bind to. + Bağlamak üzere BindingSource seçin. + + + + Select a data source under 'Other Data Sources' to connect to data. + Verilere bağlanmak için 'Diğer Veri Kaynakları' altında veri kaynağını seçin. + + + + Select a data member to bind to. + Bağlanacak veri üyesini seçin. + + + + Contains all form components that implement IList, IListSource or Array. + IList, IListSource veya Array uygulayan tüm form bileşenlerini içerir. + + + + Selecting 'None' clears the current data binding. + 'Yok' seçildiğinde geçerli veri bağlaması temizlenir. + + + + Contains all project data sources and local form list instances. + Tüm proje veri kaynaklarını ve yerel form listesi örneklerini içerir. + + + + Contains all project data sources. + Tüm proje veri kaynaklarını içerir. + + + + Contains project data sources belonging to this namespace. + Bu ad alanına ait olan proje veri kaynaklarını içerir. + + + + {0} List Instances + {0} Liste Örnekleri + + + + None + Hiçbiri + + + + Other Data Sources + Diğer Veri Kaynakları + + + + Project Data Sources + Proje Veri Kaynakları + + + + Bindable data sources and data members + Bağlanabilir veri kaynakları ve veri üyeleri + + Could not convert value '{0}' to the type '{1}'. '{0}' değeri '{1}' türüne dönüştürülemedi. @@ -905,16 +1125,31 @@ Nesneyi tanımlamak üzere kodda kullanılan adı gösterir. + + Dock Fill in Form + Formda Dolguyu Yerleştir + + Dock in Parent Container Ana Kapsayıcıda Yerleştir + + Dock Fill in UserControl + UserControl'da Dolguyu Yerleştir + + Horizontal Splitter Orientation. Yatay Bölümlendirici Yönü. + + Re-parent Controls + Denetimlere Yeniden Üst Öğe Belirle + + Undock in Parent Container Ana Kapsayıcıda Yerinden Çıkar @@ -1080,6 +1315,36 @@ Görüntüler Koleksiyonu Düzenleyicisi + + Opens the Images collection editor + Görüntüler koleksiyonu düzenleyicisini açar + + + + Choose images + Görüntüleri seç + + + + Changes the bit depth images imported into this ImageList are stored at + Bu ImageList'e içeri aktarılan görüntülerde yapılan bit derinliği değişikliklerinin depolandığı yer + + + + Image Bit Depth + Görüntü Bit Derinliği + + + + Changes the size images imported into this ImageList are stored at + Bu ImageList'e içeri aktarılan görüntülerde yapılan boyut değişikliklerinin depolandığı yer + + + + Image Size + Resim Boyutu + + Chooses an ImageList to use with this TreeView Bu TreeView'la kullanılacak ImageList'i seçer @@ -1712,6 +1977,181 @@ Metni kabul etmek için Ctrl+Enter tuşlarına basın. {0} [dizenin kalan bölümü kesildi]"; + + Add Tab + Sekme Ekle + + + + Add tab to '{0}' + {0}' öğesine sekme ekle + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + '{0}', TabControl'e eklenemez. Yalnızca TabPage'ler TabControl'lere doğrudan eklenebilir. + + + + Remove Tab + Sekmeyi Kaldır + + + + Remove tab '{0}' from '{1}' + '{0}' sekmesini '{1}' öğesinden kaldır + + + + A&bsolute + &Mutlak + + + + &Add Column + &Sütun Ekle + + + + Add Column on {0} + Sütun Ekle: {0} + + + + &Add + &Ekle + + + + Add Ro&w + S&atır Ekle + + + + Add Row on {0} + Satır Ekle: {0} + + + + A&utoSize + &Otomatik Boyut + + + + Change SizeType on {0} + SizeType'ı Değiştir: {0} + + + + Clearing Anchor property of {0} for {1} + {0} Anchor özelliği {1} için temizleniyor + + + + Clearing Dock property of {0} for {1} + {0} Dock özelliği {1} için temizleniyor + + + + &Column + &Sütun + + + + C&opy TableLayoutPanel + &TableLayoutPanel Kopyala + + + + &Cut TableLayoutPanel + TableLayoutPanel &Kes + + + + &Delete TableLayoutPanel + TableLayoutPanel &Sil + + + + {0} swapped with {1} + {0}, {1} ile değiştirildi + + + + &Delete + &Sil + + + + 0 + 0 + + + + &Edit Rows and Columns... + S&ütunları ve Satırları Düzenle... + + + + &Insert + &Ekle + + + + {0} must be greater than zero. + {0}, sıfırdan büyük olmalıdır. + + + + SizeMode + SizeMode + + + + &Percentage + Yü&zde + + + + Remove Last Colu&mn + S&on Sütunu Kaldır + + + + Remove Column on {0} + Sütunu Kaldır: {0} + + + + Remo&ve Last Row + So&n Satırı Kaldır + + + + Remove Row on {0} + Satırı Kaldır: {0} + + + + &Row + &Satır + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Ek Satır veya Sütun oluşturulamıyor. TableLayoutPanel dolu ve GrowStyle 'FixedSize'. + + + + Resizing {0} within {1} + {1} için {0} yeniden boyutlandırılıyor + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + Panelin GrowStyle özelliği 'FixedSize' olarak ayarlandığından, TableLayoutPanel denetimi içerecek şekilde genişletilemiyor. + + Dock: Yerleştir: @@ -1757,6 +2197,56 @@ Metni kabul etmek için Ctrl+Enter tuşlarına basın. Hem AllowItemReorder hem de AllowDrop True olamaz. + + Bottom + Alt + + + + Toggles the participation of BottomToolStripPanel in runtime dragging of ToolStrip. + Çalışma zamanı ToolStrip sürükleme işlemine BottomToolStripPanel katılımında geçiş yapar. + + + + Left + Sol + + + + Toggles the participation of LeftToolStripPanel in runtime dragging of ToolStrip. + Çalışma zamanı ToolStrip sürükleme işlemine LeftToolStripPanel katılımında geçiş yapar. + + + + Right + Sağ + + + + Toggles the participation of RightToolStripPanel in runtime dragging of ToolStrip. + Çalışma zamanı ToolStrip sürükleme işlemine RightToolStripPanel katılımında geçiş yapar. + + + + Show + Göster + + + + Top + Üst + + + + Toggles the participation of TopToolStripPanel in runtime dragging of ToolStrip. + Çalışma zamanı ToolStrip sürükleme işlemine TopToolStripPanel katılımında geçiş yapar. + + + + Panel Visibility + Pano Görünürlüğü + + ToolStrip New Item create Transaction. ToolStrip New Item oluşturma İşlemi. @@ -1862,6 +2352,11 @@ Metni kabul etmek için Ctrl+Enter tuşlarına basın. ToolStripItem Şekillendirme İşlemi. + + Unsupported Dock + Desteklenmeyen Yerleştirme + + '{0}' '{0}' diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf index 9149586cb2d..a6769d1e012 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf @@ -2,6 +2,11 @@ + + {0} Reparent Controls Transaction. + {0} 重定父级控制事务。 + + Could not create ActiveX control '{0}' because it is not properly registered. ActiveX 控件“{0}”未正确注册,因此未能创建该控件。 @@ -227,6 +232,11 @@ 所选预览 + + Choose Icon... + 选择图标... + + Select the image displayed in the PictureBox 选择在 PictureBox 中显示的图像 @@ -641,11 +651,136 @@ 使用此强类型资源类的资源查找。 + + Add Column + Add Column + + + + &Add Column... + &Add Column... + + + + Bound Column &Properties + Bound Column &Properties + + + + Choose Data Source: + Choose Data Source: + + + + {0} DataSource changed + {0} DataSource changed + + + + The DataGridViewColumn type. + The DataGridViewColumn type. + + + + Unable to create columns for the data source. The data source is no longer valid + Unable to create columns for the data source. The data source is no longer valid + + + + Disable Adding + Disable Adding + + + + Disable Column Reordering + Disable Column Reordering + + + + Disable Deleting + Disable Deleting + + + + Disable Editing + Disable Editing + + + + The name {0} is already in use by another column. + The name {0} is already in use by another column. + + + + Edit Columns + Edit Columns + + + + &Edit Columns... + &Edit Columns... + + + + Enable Adding + Enable Adding + + + + Enable Adding + Enable Adding + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Deleting + Enable Deleting + + + + Enable Deleting + Enable Deleting + + + + Enable Editing + Enable Editing + + + + Enable Editing + Enable Editing + + + + &Properties + &Properties + + + + Unbound Column &Properties + Unbound Column &Properties + + Cancel 取消 + + Close + Close + + OK 确定 @@ -656,6 +791,91 @@ 设置 DataSource 属性后无法修改项集合。 + + Data binding editor + 数据绑定编辑器 + + + + Add new Object Data Source... + 添加新的对象数据源... + + + + Click the 'Add Project Data Source...' link to connect to data. + 单击“添加项目数据源...”链接以连接到数据。 + + + + Currently data bound to '{0}'. + 数据当前绑定到“{0}”。 + + + + Select a BindingSource to bind to. + 选择要绑定到的 BindingSource。 + + + + Select a data source under 'Other Data Sources' to connect to data. + 选择“其他数据源”下的某个数据源以连接到数据。 + + + + Select a data member to bind to. + 选择要绑定到的数据成员。 + + + + Contains all form components that implement IList, IListSource or Array. + 包含实现 IList、IListSource 或数组的所有窗体组件。 + + + + Selecting 'None' clears the current data binding. + 选择“无”将清除当前数据绑定。 + + + + Contains all project data sources and local form list instances. + 包含所有项目数据源和本地窗体列表实例。 + + + + Contains all project data sources. + 包含所有项目数据源。 + + + + Contains project data sources belonging to this namespace. + 包含属于此命名空间的项目数据源。 + + + + {0} List Instances + {0} 列表实例 + + + + None + + + + + Other Data Sources + 其他数据源 + + + + Project Data Sources + 项目数据源 + + + + Bindable data sources and data members + 可绑定数据源和数据成员 + + Could not convert value '{0}' to the type '{1}'. 未能将值“{0}”转换为类型“{1}”。 @@ -905,16 +1125,31 @@ 指示代码中用来标识该对象的名称。 + + Dock Fill in Form + 在窗体中停靠填充 + + Dock in Parent Container 在父容器中停靠 + + Dock Fill in UserControl + 在 UserControl 中停靠填充 + + Horizontal Splitter Orientation. 水平拆分器方向。 + + Re-parent Controls + 重定父级控件 + + Undock in Parent Container 取消在父容器中停靠 @@ -1080,6 +1315,36 @@ 图像集合编辑器 + + Opens the Images collection editor + 打开图像集合编辑器 + + + + Choose images + 选择图像 + + + + Changes the bit depth images imported into this ImageList are stored at + 更改在存储导入到此 ImageList 中的图像时所用的位深度 + + + + Image Bit Depth + 图像位深度 + + + + Changes the size images imported into this ImageList are stored at + 更改在存储导入此 ImageList 中的图像时的所用大小 + + + + Image Size + 图像大小 + + Chooses an ImageList to use with this TreeView 选择要与此 TreeView 一起使用的 ImageList @@ -1712,6 +1977,181 @@ Press Ctrl+Enter to accept Text. {0} [字符串的其余部分已截断]"; + + Add Tab + 添加选项卡 + + + + Add tab to '{0}' + 将选项卡添加到“{0}” + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + 无法将“{0}”添加到 TabControl。只有 TabPages 才能直接添加到 TabControls。 + + + + Remove Tab + 移除选项卡 + + + + Remove tab '{0}' from '{1}' + 将选项卡“{0}”从“{1}”中移除 + + + + A&bsolute + 绝对(&B) + + + + &Add Column + 添加列(&A) + + + + Add Column on {0} + 在 {0} 上添加列 + + + + &Add + 添加(&A) + + + + Add Ro&w + 添加行(&W) + + + + Add Row on {0} + 在 {0} 上添加行 + + + + A&utoSize + 自动调整大小(&U) + + + + Change SizeType on {0} + 更改 {0} 上的 SizeType + + + + Clearing Anchor property of {0} for {1} + 清除 {1} 的 {0} 的 Anchor 属性 + + + + Clearing Dock property of {0} for {1} + 清除 {1} 的 {0} 的 Dock 属性 + + + + &Column + 列(&C) + + + + C&opy TableLayoutPanel + 复制 TableLayoutPanel(&O) + + + + &Cut TableLayoutPanel + 剪切 TableLayoutPanel(&C) + + + + &Delete TableLayoutPanel + 删除 TableLayoutPanel(&D) + + + + {0} swapped with {1} + 与 {1} 交换的 {0} + + + + &Delete + 删除(&D) + + + + 0 + 0 + + + + &Edit Rows and Columns... + 编辑行和列(&E)... + + + + &Insert + 插入(&I) + + + + {0} must be greater than zero. + {0} 必须大于零。 + + + + SizeMode + SizeMode + + + + &Percentage + 百分比(&P) + + + + Remove Last Colu&mn + 移除最后一列(&M) + + + + Remove Column on {0} + 移除 {0} 上的列 + + + + Remo&ve Last Row + 移除最后一行(&V) + + + + Remove Row on {0} + 移除 {0} 上的行 + + + + &Row + 行(&R) + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + 无法创建更多行或列。TableLayoutPanel 已满并且 GrowStyle 为“FixedSize”。 + + + + Resizing {0} within {1} + 在 {1} 内调整 {0} 的大小 + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel 无法扩展以包含该控件,因为该面板的 GrowStyle 属性设置为“FixedSize”。 + + Dock: 停靠: @@ -1757,6 +2197,56 @@ Press Ctrl+Enter to accept Text. AllowItemReorder 和 AllowDrop 不能同时为 True。 + + Bottom + + + + + Toggles the participation of BottomToolStripPanel in runtime dragging of ToolStrip. + 切换在运行时拖动 ToolStrip 的过程中 BottomToolStripPanel 的参与状态。 + + + + Left + + + + + Toggles the participation of LeftToolStripPanel in runtime dragging of ToolStrip. + 切换在运行时拖动 ToolStrip 的过程中 LeftToolStripPanel 的参与状态。 + + + + Right + + + + + Toggles the participation of RightToolStripPanel in runtime dragging of ToolStrip. + 切换在运行时拖动 ToolStrip 的过程中 RightToolStripPanel 的参与状态。 + + + + Show + 显示 + + + + Top + + + + + Toggles the participation of TopToolStripPanel in runtime dragging of ToolStrip. + 切换在运行时拖动 ToolStrip 的过程中 TopToolStripPanel 的参与状态。 + + + + Panel Visibility + 面板可见性 + + ToolStrip New Item create Transaction. ToolStrip 新项创建事务。 @@ -1862,6 +2352,11 @@ Press Ctrl+Enter to accept Text. ToolStripItem 变形事务。 + + Unsupported Dock + 不支持的停靠 + + '{0}' “{0}” diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf index 061133a38e0..01a3e3c9cc1 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf @@ -2,6 +2,11 @@ + + {0} Reparent Controls Transaction. + {0}重設控制項父代交易。 + + Could not create ActiveX control '{0}' because it is not properly registered. 因為尚未正確註冊,所以無法建立 ActiveX 控制項 '{0}'。 @@ -227,6 +232,11 @@ 已選取預覽 + + Choose Icon... + 選擇圖示... + + Select the image displayed in the PictureBox 選取 PictureBox 中顯示的影像 @@ -641,11 +651,136 @@ 使用這個強型別資源類別的資源查閱。 + + Add Column + Add Column + + + + &Add Column... + &Add Column... + + + + Bound Column &Properties + Bound Column &Properties + + + + Choose Data Source: + Choose Data Source: + + + + {0} DataSource changed + {0} DataSource changed + + + + The DataGridViewColumn type. + The DataGridViewColumn type. + + + + Unable to create columns for the data source. The data source is no longer valid + Unable to create columns for the data source. The data source is no longer valid + + + + Disable Adding + Disable Adding + + + + Disable Column Reordering + Disable Column Reordering + + + + Disable Deleting + Disable Deleting + + + + Disable Editing + Disable Editing + + + + The name {0} is already in use by another column. + The name {0} is already in use by another column. + + + + Edit Columns + Edit Columns + + + + &Edit Columns... + &Edit Columns... + + + + Enable Adding + Enable Adding + + + + Enable Adding + Enable Adding + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Column Reordering + Enable Column Reordering + + + + Enable Deleting + Enable Deleting + + + + Enable Deleting + Enable Deleting + + + + Enable Editing + Enable Editing + + + + Enable Editing + Enable Editing + + + + &Properties + &Properties + + + + Unbound Column &Properties + Unbound Column &Properties + + Cancel 取消 + + Close + Close + + OK 確定 @@ -656,6 +791,91 @@ 已設定 DataSource 屬性時,無法修改項目集合。 + + Data binding editor + 資料繫結編輯器 + + + + Add new Object Data Source... + 新增物件資料來源... + + + + Click the 'Add Project Data Source...' link to connect to data. + 按一下 [加入專案資料來源...] 連結可連接至資料。 + + + + Currently data bound to '{0}'. + 目前資料是繫結至 '{0}'。 + + + + Select a BindingSource to bind to. + 選取要繫結的目標 BindingSource。 + + + + Select a data source under 'Other Data Sources' to connect to data. + 在 [其他資料來源] 下選取要連接到資料的資料來源。 + + + + Select a data member to bind to. + 選取要繫結的目標資料成員。 + + + + Contains all form components that implement IList, IListSource or Array. + 含有實作 IList、IListSource 或 Array 的所有表單元件。 + + + + Selecting 'None' clears the current data binding. + 選取 [無] 會清除目前的資料繫結。 + + + + Contains all project data sources and local form list instances. + 含有所有專案資料來源和本機表單清單的執行個體。 + + + + Contains all project data sources. + 含有所有專案資料來源。 + + + + Contains project data sources belonging to this namespace. + 含有屬於這個命名空間的專案資料來源。 + + + + {0} List Instances + {0} 清單執行個體 + + + + None + + + + + Other Data Sources + 其他資料來源 + + + + Project Data Sources + 專案資料來源 + + + + Bindable data sources and data members + 可繫結的資料來源和資料成員 + + Could not convert value '{0}' to the type '{1}'. 無法將值 '{0}' 轉換為類型 '{1}'。 @@ -905,16 +1125,31 @@ 表示於程式碼中用於辨識物件的名稱。 + + Dock Fill in Form + 停駐填滿表單 + + Dock in Parent Container 停駐於父容器中 + + Dock Fill in UserControl + 停駐填滿 UserControl + + Horizontal Splitter Orientation. 水平的分隔器方向。 + + Re-parent Controls + 重設控制項父代 + + Undock in Parent Container 取消停駐於父容器中 @@ -1080,6 +1315,36 @@ 影像集合編輯器 + + Opens the Images collection editor + 開啟影像集合編輯器 + + + + Choose images + 選擇影像 + + + + Changes the bit depth images imported into this ImageList are stored at + 匯入這個 ImageList 的位元深度影像的變更是儲存在 + + + + Image Bit Depth + 影像位元深度 + + + + Changes the size images imported into this ImageList are stored at + 匯入這個 ImageList 的大小影像的變更是儲存在 + + + + Image Size + 影像大小 + + Chooses an ImageList to use with this TreeView 選擇要配合這個 TreeView 使用的 ImageList @@ -1712,6 +1977,181 @@ Press Ctrl+Enter to accept Text. {0} [字串的其餘部分已遭截斷]"; + + Add Tab + 加入索引標籤 + + + + Add tab to '{0}' + 將索引標籤加入 '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + 無法將 '{0}' 加入 TabControl。只能將 TabPages 直接加入 TabControls。 + + + + Remove Tab + 移除索引標籤 + + + + Remove tab '{0}' from '{1}' + 移除 '{1}' 中的索引標籤 '{0}' + + + + A&bsolute + 絕對(&B) + + + + &Add Column + 加入資料行(&A) + + + + Add Column on {0} + 在 {0} 上加入資料行 + + + + &Add + 加入(&A) + + + + Add Ro&w + 加入資料列(&W) + + + + Add Row on {0} + 在 {0} 上加入資料列 + + + + A&utoSize + 自動調整(&U) + + + + Change SizeType on {0} + 在 {0} 上變更 SizeType + + + + Clearing Anchor property of {0} for {1} + 對 {1} 清除 {0} 的 Anchor 屬性 + + + + Clearing Dock property of {0} for {1} + 對 {1} 清除 {0} 的 Dock 屬性 + + + + &Column + 資料行(&C) + + + + C&opy TableLayoutPanel + 複製 TableLayoutPanel(&O) + + + + &Cut TableLayoutPanel + 剪下 TableLayoutPanel(&C) + + + + &Delete TableLayoutPanel + 刪除 TableLayoutPanel(&D) + + + + {0} swapped with {1} + {0} 與 {1} 調換 + + + + &Delete + 刪除(&D) + + + + 0 + 0 + + + + &Edit Rows and Columns... + 編輯資料列與資料行(&E)... + + + + &Insert + 插入(&I) + + + + {0} must be greater than zero. + {0} 必須大於零。 + + + + SizeMode + SizeMode + + + + &Percentage + 百分比(&P) + + + + Remove Last Colu&mn + 移除最後一個資料行(&M) + + + + Remove Column on {0} + 在 {0} 上移除資料行 + + + + Remo&ve Last Row + 移除最後一個資料列(&V) + + + + Remove Row on {0} + 在 {0} 上移除資料列 + + + + &Row + 資料列(&R) + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + 無法建立其他資料列或資料行。TableLayoutPanel 已滿而且 GrowStyle 為 'FixedSize'。 + + + + Resizing {0} within {1} + 在 {1} 內重新調整 {0} 的大小 + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + 無法擴充 TableLayoutPanel 來包含控制項,因為面板的 GrowStyle 屬性已設定為 'FixedSize'。 + + Dock: Dock: @@ -1757,6 +2197,56 @@ Press Ctrl+Enter to accept Text. AllowItemReorder 和 AllowDrop 不能同時為 true。 + + Bottom + + + + + Toggles the participation of BottomToolStripPanel in runtime dragging of ToolStrip. + 切換 BottomToolStripPanel 參與在執行階段拖曳 ToolStrip。 + + + + Left + + + + + Toggles the participation of LeftToolStripPanel in runtime dragging of ToolStrip. + 切換 LeftToolStripPanel 參與在執行階段拖曳 ToolStrip。 + + + + Right + + + + + Toggles the participation of RightToolStripPanel in runtime dragging of ToolStrip. + 切換 RightToolStripPanel 參與在執行階段拖曳 ToolStrip。 + + + + Show + 顯示 + + + + Top + + + + + Toggles the participation of TopToolStripPanel in runtime dragging of ToolStrip. + 切換 TopToolStripPanel 參與在執行階段拖曳 ToolStrip。 + + + + Panel Visibility + 面板可見度 + + ToolStrip New Item create Transaction. ToolStrip 新項目建立異動。 @@ -1862,6 +2352,11 @@ Press Ctrl+Enter to accept Text. ToolStripItem 變形異動。 + + Unsupported Dock + 不支援的停駐 + + '{0}' '{0}' diff --git a/src/System.Windows.Forms.Design/src/SRCategoryAttribute.cs b/src/System.Windows.Forms.Design/src/SRCategoryAttribute.cs index 62d138fb81d..fb03dfce7f6 100644 --- a/src/System.Windows.Forms.Design/src/SRCategoryAttribute.cs +++ b/src/System.Windows.Forms.Design/src/SRCategoryAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/SRDescriptionAttribute.cs b/src/System.Windows.Forms.Design/src/SRDescriptionAttribute.cs index efda5569afa..6a6d1a9173e 100644 --- a/src/System.Windows.Forms.Design/src/SRDescriptionAttribute.cs +++ b/src/System.Windows.Forms.Design/src/SRDescriptionAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/SRDisplayNameAttribute.cs b/src/System.Windows.Forms.Design/src/SRDisplayNameAttribute.cs index c2f80737553..4c3b4f4fa6f 100644 --- a/src/System.Windows.Forms.Design/src/SRDisplayNameAttribute.cs +++ b/src/System.Windows.Forms.Design/src/SRDisplayNameAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System.Windows.Forms.Design.csproj b/src/System.Windows.Forms.Design/src/System.Windows.Forms.Design.csproj index 5288230c668..06c562ef8c0 100644 --- a/src/System.Windows.Forms.Design/src/System.Windows.Forms.Design.csproj +++ b/src/System.Windows.Forms.Design/src/System.Windows.Forms.Design.csproj @@ -49,15 +49,16 @@ System.Windows.Forms.Design + + System.ComponentModel.Design + colordlg.data - + @@ -84,6 +85,12 @@ System.Windows.Forms.Design.%(FileName) + + System.Windows.Forms.Design.%(FileName).bmp + + + System.Windows.Forms.Design.Behavior.%(FileName) + diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ActiveDesignSurfaceChangedEventArgs.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ActiveDesignSurfaceChangedEventArgs.cs index 3ed38f94f33..aee2a1b0fef 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ActiveDesignSurfaceChangedEventArgs.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ActiveDesignSurfaceChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ActiveDesignSurfaceChangedEventHandler.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ActiveDesignSurfaceChangedEventHandler.cs index 81b71e8eeff..d7f60615505 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ActiveDesignSurfaceChangedEventHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ActiveDesignSurfaceChangedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ArrayEditor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ArrayEditor.cs index 88f0b35a7e7..4dae46182b6 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ArrayEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ArrayEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/BinaryEditor.BinaryUI.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/BinaryEditor.BinaryUI.cs index 85d88a2bc44..2d828a2db9d 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/BinaryEditor.BinaryUI.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/BinaryEditor.BinaryUI.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms; @@ -95,7 +94,7 @@ private void RadioUnicode_checkedChanged(object? source, EventArgs e) private void ButtonOK_click(object? source, EventArgs e) { - object? localValue = _value; + object localValue = _value!; ConvertToValue(_byteViewer.GetBytes(), ref localValue); _value = localValue; } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/BinaryEditor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/BinaryEditor.cs index ba2d45d79fa..34cb3fd189a 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/BinaryEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/BinaryEditor.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Drawing.Design; using System.Text; @@ -17,21 +14,27 @@ namespace System.ComponentModel.Design; public sealed partial class BinaryEditor : UITypeEditor { private const string HELP_KEYWORD = "System.ComponentModel.Design.BinaryEditor"; - private ITypeDescriptorContext _context; - private BinaryUI _binaryUI; + private ITypeDescriptorContext? _context; + private BinaryUI? _binaryUI; - internal object GetService(Type serviceType) + internal object? GetService(Type serviceType) { if (_context is null) { return null; } - return _context.TryGetService(out IDesignerHost designerhost) + return _context.TryGetService(out IDesignerHost? designerhost) ? designerhost.GetService(serviceType) : _context.GetService(serviceType); } + private bool TryGetService([NotNullWhen(true)] out T? service) where T : class + { + service = GetService(typeof(T)) as T; + return service is not null; + } + /// /// Converts the given object to an array of bytes to be manipulated by the editor. The default implementation /// of this supports byte[] and objects. @@ -56,7 +59,7 @@ internal static byte[] ConvertToBytes(object value) { int size = stringValue.Length * 2; byte[] buffer = new byte[size]; - Encoding.Unicode.GetBytes(stringValue.ToCharArray(), 0, size / 2, buffer, 0); + Encoding.Unicode.GetBytes(stringValue.AsSpan(), buffer.AsSpan()); return buffer; } @@ -89,7 +92,7 @@ internal static void ConvertToValue(byte[] bytes, ref object value) } } - public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) + public override object? EditValue(ITypeDescriptorContext? context, IServiceProvider provider, object? value) { if (provider is null) { @@ -98,7 +101,7 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide _context = context; - if (!provider.TryGetService(out IWindowsFormsEditorService editorService)) + if (!provider.TryGetService(out IWindowsFormsEditorService? editorService)) { return value; } @@ -118,11 +121,11 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide } /// - public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.Modal; + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext? context) => UITypeEditorEditStyle.Modal; internal void ShowHelp() { - if (GetService(typeof(IHelpService)) is IHelpService helpService) + if (TryGetService(out IHelpService? helpService)) { helpService.ShowHelpFromKeyword(HELP_KEYWORD); } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ByteViewer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ByteViewer.cs index 1e07283dc5c..737d6b6472f 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ByteViewer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ByteViewer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -37,8 +36,8 @@ public class ByteViewer : TableLayoutPanel private const int DUMP_START_X = HEX_START_X + HEX_WIDTH + HEX_DUMP_GAP; private const int SCROLLBAR_START_X = DUMP_START_X + DUMP_WIDTH + HEX_DUMP_GAP; - private static readonly Font ADDRESS_FONT = new Font("Microsoft Sans Serif", 8.0f); - private static readonly Font HEXDUMP_FONT = new Font("Courier New", 8.0f); + private static readonly Font ADDRESS_FONT = new("Microsoft Sans Serif", 8.0f); + private static readonly Font HEXDUMP_FONT = new("Courier New", 8.0f); private int SCROLLBAR_HEIGHT; private int SCROLLBAR_WIDTH; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CodeMarkerEvent.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CodeMarkerEvent.cs index 229d7bf8895..07645332021 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CodeMarkerEvent.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CodeMarkerEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.CollectionEditorCollectionForm.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.CollectionEditorCollectionForm.cs index 9369cae3662..0f20a55024d 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.CollectionEditorCollectionForm.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.CollectionEditorCollectionForm.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.CollectionForm.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.CollectionForm.cs index c10d96c9b37..6a12cc0f987 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.CollectionForm.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.CollectionForm.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.FilterListBox.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.FilterListBox.cs index cbf749a6ca5..be2709784cf 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.FilterListBox.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.FilterListBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.PropertyGridSite.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.PropertyGridSite.cs index 92991b668f1..7637dfcf7f7 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.PropertyGridSite.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.PropertyGridSite.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.SplitButton.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.SplitButton.cs index 73284a895e9..14d752420c7 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.SplitButton.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.SplitButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.cs index 58a0e0f7c91..cbbcbaefa26 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.CDDesignerCommandSet.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.CDDesignerCommandSet.cs index 4b441dbcf32..3473b3cc5fb 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.CDDesignerCommandSet.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.CDDesignerCommandSet.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.ShadowPropertyCollection.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.ShadowPropertyCollection.cs index b01b0edb6c0..c365b852dd4 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.ShadowPropertyCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.ShadowPropertyCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.cs index bca41b31431..96ec10b1061 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ComponentDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -35,6 +34,24 @@ public partial class ComponentDesigner : ITreeDesigner, IDesignerFilter, ICompon /// public virtual ICollection AssociatedComponents => Array.Empty(); + private protected virtual void UpdateTextualDefaultProperty() + { + var component = Component; + if (component?.Site is { } site) + { + PropertyDescriptor defaultProperty = TypeDescriptor.GetDefaultProperty(component); + if (!(defaultProperty is not null && defaultProperty.PropertyType.Equals(typeof(string)))) + { + return; + } + + if (defaultProperty.GetValue(component) is string currentValue && string.IsNullOrEmpty(currentValue)) + { + defaultProperty.SetValue(component, site.Name); + } + } + } + internal virtual bool CanBeAssociatedWith(IDesigner parentDesigner) => true; /// @@ -49,6 +66,9 @@ protected bool Inherited } } + internal bool IsInheritedReadOnly + => InheritanceAttribute.InheritanceLevel == InheritanceLevel.InheritedReadOnly; + /// /// This property provides a generic mechanism for discovering parent relationships within designers, /// and is used by ComponentDesigner's ITreeDesigner interface implementation. This property @@ -123,6 +143,15 @@ public virtual void InitializeNewComponent(IDictionary defaultValues) { // execute legacy code InitializeNonDefault(); + + // Note: This was originally an obsoleted API called OnSetComponentDefaults(). The + // default behavior of this API was to set the the default property to the component's + // site name, if the property was a string and null or empty. We've removed the API + // but preserved the same behavior, now controlled by SetTextualDefaultProperty. + if (SetTextualDefaultProperty) + { + UpdateTextualDefaultProperty(); + } } void IDesignerFilter.PostFilterAttributes(IDictionary attributes) => PostFilterAttributes(attributes); @@ -147,6 +176,12 @@ public virtual void InitializeNewComponent(IDictionary defaultValues) /// public virtual DesignerVerbCollection Verbs => _verbs ??= new DesignerVerbCollection(); + /// + /// Controls whether the default property of is automatically set + /// to on creation. The default is . + /// + protected virtual bool SetTextualDefaultProperty => true; + ICollection ITreeDesigner.Children { get diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DataSourceDescriptor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DataSourceDescriptor.cs new file mode 100644 index 00000000000..9e8e6891776 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DataSourceDescriptor.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Drawing; + +namespace System.ComponentModel.Design; + +public abstract class DataSourceDescriptor +{ + public abstract string Name { get; } + + public abstract Bitmap Image { get; } + + public abstract string TypeName { get; } + + public abstract bool IsDesignable { get; } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DataSourceDescriptorCollection.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DataSourceDescriptorCollection.cs new file mode 100644 index 00000000000..e91af842e5b --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DataSourceDescriptorCollection.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections; + +namespace System.ComponentModel.Design; + +public class DataSourceDescriptorCollection : CollectionBase +{ + public DataSourceDescriptorCollection() : base() + { + } + + public int Add(DataSourceDescriptor value) => List.Add(value); + + public int IndexOf(DataSourceDescriptor value) => List.IndexOf(value); + + public void Insert(int index, DataSourceDescriptor value) => List.Insert(index, value); + + public bool Contains(DataSourceDescriptor value) => List.Contains(value); + + public void CopyTo(DataSourceDescriptor[] array, int index) => List.CopyTo(array, index); + + public void Remove(DataSourceDescriptor value) => List.Remove(value); + + public DataSourceDescriptor? this[int index] + { + get => List[index] as DataSourceDescriptor; + set => List[index] = value; + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DataSourceGroup.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DataSourceGroup.cs new file mode 100644 index 00000000000..050148344fa --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DataSourceGroup.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Drawing; + +namespace System.ComponentModel.Design; + +public abstract class DataSourceGroup +{ + public abstract string Name { get; } + + public abstract Bitmap Image { get; } + + public abstract DataSourceDescriptorCollection DataSources { get; } + + public abstract bool IsDefault { get; } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DataSourceGroupCollection.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DataSourceGroupCollection.cs new file mode 100644 index 00000000000..356c73025b3 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DataSourceGroupCollection.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections; + +namespace System.ComponentModel.Design; + +public class DataSourceGroupCollection : CollectionBase +{ + public DataSourceGroupCollection() : base() + { + } + + public int Add(DataSourceGroup value) => List.Add(value); + + public int IndexOf(DataSourceGroup value) => List.IndexOf(value); + + public void Insert(int index, DataSourceGroup value) => List.Insert(index, value); + + public bool Contains(DataSourceGroup value) => List.Contains(value); + + public void CopyTo(DataSourceGroup[] array, int index) => List.CopyTo(array, index); + + public void Remove(DataSourceGroup value) => List.Remove(value); + + public DataSourceGroup? this[int index] + { + get => List[index] as DataSourceGroup; + + set => List[index] = value; + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DataSourceProviderService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DataSourceProviderService.cs new file mode 100644 index 00000000000..e20c2373b00 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DataSourceProviderService.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; +using System.Windows.Forms; + +namespace System.ComponentModel.Design; + +[Guid("ABE5C1F0-C96E-40c4-A22D-4A5CEC899BDC")] +public abstract class DataSourceProviderService +{ + public abstract bool SupportsAddNewDataSource { get; } + + public abstract bool SupportsConfigureDataSource { get; } + + public abstract DataSourceGroupCollection GetDataSources(); + + public abstract DataSourceGroup InvokeAddNewDataSource(IWin32Window parentWindow, FormStartPosition startPosition); + + public abstract bool InvokeConfigureDataSource(IWin32Window parentWindow, FormStartPosition startPosition, DataSourceDescriptor dataSourceDescriptor); + + public abstract object AddDataSourceInstance(IDesignerHost host, DataSourceDescriptor dataSourceDescriptor); + + public abstract void NotifyDataSourceComponentAdded(object dsc); +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DateTimeEditor.DateTimeUI.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DateTimeEditor.DateTimeUI.cs index da560daeed6..b0b352dab00 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DateTimeEditor.DateTimeUI.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DateTimeEditor.DateTimeUI.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DateTimeEditor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DateTimeEditor.cs index 6fd5db425d3..6075b6e0459 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DateTimeEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DateTimeEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurface.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurface.cs index 12fa1d8581a..f031a366bde 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurface.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurface.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceCollection.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceCollection.cs index 73f7e3567ca..e1187d2aa26 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceEvent.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceEvent.cs index c7a19feaf28..1661d24a9e5 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceEvent.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceManager.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceManager.cs index ba69f2812d1..9de98ab475d 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceManager.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; @@ -272,7 +271,7 @@ public DesignSurface CreateDesignSurface(IServiceProvider parentProvider) /// Creates an instance of a design surface. This can be /// overridden to provide a derived version of DesignSurface. /// - protected virtual DesignSurface CreateDesignSurfaceCore(IServiceProvider parentProvider) => new DesignSurface(parentProvider); + protected virtual DesignSurface CreateDesignSurfaceCore(IServiceProvider parentProvider) => new(parentProvider); /// /// Disposes the designer application. diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceServiceContainer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceServiceContainer.cs index 1995219bedd..c80cfdf5cb6 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceServiceContainer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceServiceContainer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionHeaderItem.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionHeaderItem.cs index 7bacca21028..578e2ddcb4c 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionHeaderItem.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionHeaderItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionItem.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionItem.cs index 81db55e69c5..c0abd086c72 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionItem.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Collections.Specialized; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionItemCollection.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionItemCollection.cs index 1fbf2462f5e..664bdc0d058 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionItemCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionItemCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionList.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionList.cs index 02225970f5f..c46662cf2ad 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionList.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListCollection.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListCollection.cs index 64f9b9f11dc..2d50b8a66a7 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; @@ -25,7 +24,7 @@ public DesignerActionList? this[int index] public int Add(DesignerActionList? value) => List.Add(value); - public void AddRange(DesignerActionList?[] value) + public void AddRange(params DesignerActionList?[] value) { ArgumentNullException.ThrowIfNull(value); diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedEventArgs.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedEventArgs.cs index 4408f21b784..250728f42ae 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedEventArgs.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedEventHandler.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedEventHandler.cs index eabb67e291a..2eec684ceef 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedEventHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedType.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedType.cs index 27ccac16097..d45728481b0 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedType.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionListsChangedType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionMethodItem.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionMethodItem.cs index 7b90ad47c03..4270557c2b4 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionMethodItem.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionMethodItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.CheckBoxPropertyLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.CheckBoxPropertyLine.cs index e425d73af76..16483065017 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.CheckBoxPropertyLine.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.CheckBoxPropertyLine.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Drawing; using System.Windows.Forms; @@ -13,14 +10,10 @@ internal sealed partial class DesignerActionPanel { private sealed class CheckBoxPropertyLine : PropertyLine { - private CheckBox _checkBox; + private readonly CheckBox _checkBox; - public CheckBoxPropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + private CheckBoxPropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) - { - } - - protected override void AddControls(List controls) { _checkBox = new CheckBox { @@ -32,10 +25,10 @@ protected override void AddControls(List controls) }; _checkBox.CheckedChanged += new EventHandler(OnCheckBoxCheckedChanged); - controls.Add(_checkBox); + AddedControls.Add(_checkBox); } - public sealed override void Focus() => _checkBox.Focus(); + public override void Focus() => _checkBox.Focus(); public override Size LayoutControls(int top, int width, bool measureOnly) { @@ -49,14 +42,14 @@ public override Size LayoutControls(int top, int width, bool measureOnly) return checkBoxPreferredSize + new Size(LineLeftMargin + LineRightMargin, LineVerticalPadding); } - private void OnCheckBoxCheckedChanged(object sender, EventArgs e) + private void OnCheckBoxCheckedChanged(object? sender, EventArgs e) { SetValue(_checkBox.Checked); } protected override void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int currentTabIndex) { - _checkBox.Text = StripAmpersands(PropertyItem.DisplayName); + _checkBox.Text = StripAmpersands(PropertyItem!.DisplayName); _checkBox.AccessibleDescription = PropertyItem.Description; _checkBox.TabIndex = currentTabIndex++; @@ -65,7 +58,17 @@ protected override void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int curre protected override void OnValueChanged() { - _checkBox.Checked = (bool)Value; + _checkBox.Checked = (bool)Value!; + } + + public sealed class Info(DesignerActionList list, DesignerActionPropertyItem item) : PropertyLineInfo(list, item) + { + public override Line CreateLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + { + return new CheckBoxPropertyLine(serviceProvider, actionPanel); + } + + public override Type LineType => typeof(CheckBoxPropertyLine); } } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.DesignerActionPanelHeaderItem.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.DesignerActionPanelHeaderItem.cs index 3ab334c75f1..70b7993892d 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.DesignerActionPanelHeaderItem.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.DesignerActionPanelHeaderItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; @@ -8,16 +7,11 @@ internal sealed partial class DesignerActionPanel { private sealed class DesignerActionPanelHeaderItem : DesignerActionItem { - private readonly string _subtitle; - - public DesignerActionPanelHeaderItem(string title, string subtitle) : base(title, null, null) + public DesignerActionPanelHeaderItem(string title, string? subtitle) : base(title, null, null) { - _subtitle = subtitle; + Subtitle = subtitle; } - public string Subtitle - { - get => _subtitle; - } + public string? Subtitle { get; } } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.EditorButton.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.EditorButton.cs index dd6bbe4c326..528bb9b2d79 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.EditorButton.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.EditorButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Imaging; @@ -18,7 +17,6 @@ internal sealed class EditorButton : Button { private bool _mouseOver; private bool _mouseDown; - private bool _ellipsis; protected override void OnMouseDown(MouseEventArgs e) { @@ -52,16 +50,12 @@ protected override void OnMouseUp(MouseEventArgs e) } } - public bool Ellipsis - { - get => _ellipsis; - set => _ellipsis = value; - } + public bool Ellipsis { get; set; } protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; - if (_ellipsis) + if (Ellipsis) { PushButtonState buttonState = PushButtonState.Normal; if (_mouseDown) @@ -162,7 +156,7 @@ protected override void OnPaint(PaintEventArgs e) } finally { - icon?.Dispose(); + icon.Dispose(); } } catch diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.FlyoutDialog.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.FlyoutDialog.cs index a2adb6d4cea..63549bdf229 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.FlyoutDialog.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.FlyoutDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.cs index f906d17b0d0..41770a69603 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Drawing; using System.Drawing.Design; @@ -16,17 +13,22 @@ internal sealed partial class DesignerActionPanel { private sealed partial class EditorPropertyLine : TextBoxPropertyLine, IWindowsFormsEditorService, IServiceProvider { - private EditorButton _button; - private UITypeEditor _editor; + private readonly EditorButton _button; + private UITypeEditor? _editor; private bool _hasSwatch; - private Image _swatch; - private FlyoutDialog _dropDownHolder; + private Image? _swatch; + private FlyoutDialog? _dropDownHolder; private bool _ignoreNextSelectChange; private bool _ignoreDropDownValue; - public EditorPropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + private EditorPropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) { + _button = new EditorButton(); + _button.Click += new EventHandler(OnButtonClick); + _button.GotFocus += new EventHandler(OnButtonGotFocus); + + AddedControls.Add(_button); } private unsafe void ActivateDropDown() @@ -35,7 +37,7 @@ private unsafe void ActivateDropDown() { try { - object newValue = _editor.EditValue(TypeDescriptorContext, this, Value); + object? newValue = _editor.EditValue(TypeDescriptorContext, this, Value); SetValue(newValue); } catch (Exception ex) @@ -54,12 +56,12 @@ private unsafe void ActivateDropDown() listBox.SelectedIndexChanged += new EventHandler(OnListBoxSelectedIndexChanged); listBox.KeyDown += new KeyEventHandler(OnListBoxKeyDown); - TypeConverter.StandardValuesCollection standardValues = GetStandardValues(); + TypeConverter.StandardValuesCollection? standardValues = GetStandardValues(); if (standardValues is not null) { foreach (object o in standardValues) { - string newItem = PropertyDescriptor.Converter.ConvertToString(TypeDescriptorContext, CultureInfo.CurrentCulture, o); + string newItem = PropertyDescriptor.Converter.ConvertToString(TypeDescriptorContext, CultureInfo.CurrentCulture, o)!; listBox.Items.Add(newItem); if ((o is not null) && o.Equals(Value)) @@ -123,17 +125,6 @@ private unsafe void ActivateDropDown() } } - protected override void AddControls(List controls) - { - base.AddControls(controls); - - _button = new EditorButton(); - _button.Click += new EventHandler(OnButtonClick); - _button.GotFocus += new EventHandler(OnButtonGotFocus); - - controls.Add(_button); - } - private void CloseDropDown() { if (_dropDownHolder is not null) @@ -188,12 +179,12 @@ public override Size LayoutControls(int top, int width, bool measureOnly) return size; } - private void OnButtonClick(object sender, EventArgs e) + private void OnButtonClick(object? sender, EventArgs e) { ActivateDropDown(); } - private void OnButtonGotFocus(object sender, EventArgs e) + private void OnButtonGotFocus(object? sender, EventArgs e) { if (!_button.Ellipsis) { @@ -201,7 +192,7 @@ private void OnButtonGotFocus(object sender, EventArgs e) } } - private void OnListBoxKeyDown(object sender, KeyEventArgs e) + private void OnListBoxKeyDown(object? sender, KeyEventArgs e) { // Always respect the enter key and F4 if (e.KeyData == Keys.Enter) @@ -217,7 +208,7 @@ private void OnListBoxKeyDown(object sender, KeyEventArgs e) } } - private void OnListBoxSelectedIndexChanged(object sender, EventArgs e) + private void OnListBoxSelectedIndexChanged(object? sender, EventArgs e) { // If we're ignoring this selected index change, do nothing if (_ignoreNextSelectChange) @@ -232,7 +223,7 @@ private void OnListBoxSelectedIndexChanged(object sender, EventArgs e) protected override void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int currentTabIndex) { - _editor = (UITypeEditor)PropertyDescriptor.GetEditor(typeof(UITypeEditor)); + _editor = PropertyDescriptor.GetEditor(); base.OnPropertyTaskItemUpdated(toolTip, ref currentTabIndex); @@ -248,11 +239,11 @@ protected override void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int curre if (_button.Ellipsis) { - EditControl.AccessibleRole = (IsReadOnly() ? AccessibleRole.StaticText : AccessibleRole.Text); + EditControl!.AccessibleRole = (IsReadOnly() ? AccessibleRole.StaticText : AccessibleRole.Text); } else { - EditControl.AccessibleRole = (IsReadOnly() ? AccessibleRole.DropList : AccessibleRole.ComboBox); + EditControl!.AccessibleRole = (IsReadOnly() ? AccessibleRole.DropList : AccessibleRole.ComboBox); } _button.TabStop = _button.Ellipsis; @@ -263,13 +254,13 @@ protected override void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int curre _button.AccessibleName = EditControl.AccessibleName; } - protected override void OnReadOnlyTextBoxLabelClick(object sender, MouseEventArgs e) + protected override void OnReadOnlyTextBoxLabelClick(object? sender, MouseEventArgs e) { base.OnReadOnlyTextBoxLabelClick(sender, e); if (e.Button == MouseButtons.Left) { - if (ActionPanel.DropDownActive) + if (ActionPanel._dropDownActive) { _ignoreDropDownValue = true; CloseDropDown(); @@ -306,7 +297,7 @@ public override void PaintLine(Graphics g, int lineWidth, int lineHeight) Rectangle rect = new Rectangle(1, 1, width - 2, height - 2); using (Graphics swatchGraphics = Graphics.FromImage(_swatch)) { - _editor.PaintValue(Value, swatchGraphics, rect); + _editor!.PaintValue(Value, swatchGraphics, rect); swatchGraphics.DrawRectangle(SystemPens.ControlDark, new Rectangle(0, 0, width - 1, height - 1)); } } @@ -321,11 +312,11 @@ protected internal override bool ProcessDialogKey(Keys keyData) // VS is going to eat the F4 in PreProcessMessage, preventing it from ever // getting to an OnKeyDown on this control. Doing it here also allow to not // hook up to multiple events for each button. - if (!_button.Focused && !_button.Ellipsis) + if (_button is { Focused: false, Ellipsis: false }) { - if ((keyData == (Keys.Alt | Keys.Down)) || (keyData == (Keys.Alt | Keys.Up)) || (keyData == Keys.F4)) + if (keyData is (Keys.Alt | Keys.Down) or (Keys.Alt | Keys.Up) or Keys.F4) { - if (!ActionPanel.DropDownActive) + if (!ActionPanel._dropDownActive) { ActivateDropDown(); } @@ -427,7 +418,7 @@ void IWindowsFormsEditorService.DropDownControl(Control control) DialogResult IWindowsFormsEditorService.ShowDialog(Form dialog) { - IUIService uiService = (IUIService)ServiceProvider.GetService(typeof(IUIService)); + IUIService? uiService = ServiceProvider.GetService(); if (uiService is not null) { return uiService.ShowDialog(dialog); @@ -438,7 +429,7 @@ DialogResult IWindowsFormsEditorService.ShowDialog(Form dialog) #endregion #region IServiceProvider implementation - object IServiceProvider.GetService(Type serviceType) + object? IServiceProvider.GetService(Type serviceType) { // Inject this class as the IWindowsFormsEditorService // so drop-down custom editors can work @@ -481,5 +472,15 @@ protected override bool ProcessDialogKey(Keys keyData) return base.ProcessDialogKey(keyData); } } + + public new sealed class Info(DesignerActionList list, DesignerActionPropertyItem item) : PropertyLineInfo(list, item) + { + public override Line CreateLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + { + return new EditorPropertyLine(serviceProvider, actionPanel); + } + + public override Type LineType => typeof(EditorPropertyLine); + } } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.HeaderLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.HeaderLine.cs index 29a4ee2ff1e..6ef4674f56d 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.HeaderLine.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.HeaderLine.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; @@ -10,10 +9,21 @@ internal sealed partial class DesignerActionPanel { private sealed class HeaderLine : TextLine { - public HeaderLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) + private HeaderLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) { } - protected override Font GetFont() => new Font(ActionPanel.Font, FontStyle.Bold); + protected override Font GetFont() => new(ActionPanel.Font, FontStyle.Bold); + + public new sealed class Info(DesignerActionList list, DesignerActionTextItem item) : StandardLineInfo(list) + { + public override DesignerActionTextItem Item { get; } = item; + public override Line CreateLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + { + return new HeaderLine(serviceProvider, actionPanel); + } + + public override Type LineType => typeof(HeaderLine); + } } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.Line.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.Line.cs index d7722f085ff..2db767378da 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.Line.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.Line.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Drawing; using System.Windows.Forms; @@ -13,44 +10,32 @@ internal sealed partial class DesignerActionPanel { private abstract class Line { - private readonly DesignerActionPanel _actionPanel; - private List _addedControls; - private readonly IServiceProvider _serviceProvider; + protected readonly List AddedControls = new(); - public Line(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + protected Line(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) { - _serviceProvider = serviceProvider; - _actionPanel = actionPanel.OrThrowIfNull(); + ServiceProvider = serviceProvider; + ActionPanel = actionPanel.OrThrowIfNull(); } - protected DesignerActionPanel ActionPanel - { - get => _actionPanel; - } + protected DesignerActionPanel ActionPanel { get; } public abstract string FocusId { get; } - protected IServiceProvider ServiceProvider - { - get => _serviceProvider; - } - - protected abstract void AddControls(List controls); + protected IServiceProvider ServiceProvider { get; } internal List GetControls() { - _addedControls = new List(); - AddControls(_addedControls); // Tag all the controls with the Line so we know who owns it - foreach (Control c in _addedControls) + foreach (Control c in AddedControls) { c.Tag = this; } - return _addedControls; + return AddedControls; } public abstract void Focus(); @@ -65,14 +50,13 @@ public virtual void PaintLine(Graphics g, int lineWidth, int lineHeight) internal void RemoveControls(ControlCollection controls) { - for (int i = 0; i < _addedControls.Count; i++) + foreach (Control c in AddedControls) { - Control c = _addedControls[i]; c.Tag = null; controls.Remove(c); } } - internal abstract void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex); + internal abstract void UpdateActionItem(LineInfo lineInfo, ToolTip toolTip, ref int currentTabIndex); } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.LineInfo.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.LineInfo.cs index db2f93bd0ee..ff78a252688 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.LineInfo.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.LineInfo.cs @@ -1,23 +1,21 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; internal sealed partial class DesignerActionPanel { - private class LineInfo + private abstract class LineInfo { - public Line Line; - public DesignerActionItem Item; - public DesignerActionList List; + public abstract DesignerActionItem? Item { get; } - public LineInfo(DesignerActionList list, DesignerActionItem item, Line line) - { - Debug.Assert(line is not null); - Line = line; - Item = item; - List = list; - } + public abstract Line CreateLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel); + public abstract Type LineType { get; } + } + + private abstract class StandardLineInfo(DesignerActionList list) : LineInfo + { + public abstract override DesignerActionItem Item { get; } + public DesignerActionList List { get; } = list; } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.MethodLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.MethodLine.cs index 7afc366f5a7..93aedd5b60e 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.MethodLine.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.MethodLine.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Drawing; using System.Reflection; @@ -14,19 +11,10 @@ internal sealed partial class DesignerActionPanel { private sealed class MethodLine : Line { - private DesignerActionList _actionList; - private DesignerActionMethodItem _methodItem; - private MethodItemLinkLabel _linkLabel; - public MethodLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) - { - } - - public sealed override string FocusId - { - get => $"METHOD:{_actionList.GetType().FullName}.{_methodItem.MemberName}"; - } - - protected override void AddControls(List controls) + private DesignerActionList? _actionList; + private DesignerActionMethodItem? _methodItem; + private readonly MethodItemLinkLabel _linkLabel; + private MethodLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) { _linkLabel = new MethodItemLinkLabel { @@ -40,10 +28,12 @@ protected override void AddControls(List controls) VisitedLinkColor = ActionPanel.LinkColor }; _linkLabel.LinkClicked += new LinkLabelLinkClickedEventHandler(OnLinkLabelLinkClicked); - controls.Add(_linkLabel); + AddedControls.Add(_linkLabel); } - public sealed override void Focus() + public override string FocusId => $"METHOD:{_actionList!.GetType().FullName}.{_methodItem!.MemberName}"; + + public override void Focus() { _linkLabel.Focus(); } @@ -60,19 +50,19 @@ public override Size LayoutControls(int top, int width, bool measureOnly) return linkLabelSize + new Size(LineLeftMargin + LineRightMargin, LineVerticalPadding); } - private void OnLinkLabelLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + private void OnLinkLabelLinkClicked(object? sender, LinkLabelLinkClickedEventArgs e) { Debug.Assert(!ActionPanel.InMethodInvoke, "Nested method invocation"); ActionPanel.InMethodInvoke = true; try { - _methodItem.Invoke(); + _methodItem!.Invoke(); } catch (Exception ex) { if (ex is TargetInvocationException) { - ex = ex.InnerException; + ex = ex.InnerException!; } //NOTE: We had code to rethrow if this was one of [NullReferenceException, StackOverflowException, OutOfMemoryException, @@ -80,7 +70,7 @@ private void OnLinkLabelLinkClicked(object sender, LinkLabelLinkClickedEventArgs //NullRef and OutOfMemory really shouldn't be caught. Out of these, OOM is the most correct one to call, but OOM is //thrown by GDI+ for pretty much any problem, so isn't reliable as an actual indicator that you're out of memory. If //you really are out of memory, it's very likely you'll get another OOM shortly. - ActionPanel.ShowError(string.Format(SR.DesignerActionPanel_ErrorInvokingAction, _methodItem.DisplayName, Environment.NewLine + ex.Message)); + ActionPanel.ShowError(string.Format(SR.DesignerActionPanel_ErrorInvokingAction, _methodItem!.DisplayName, Environment.NewLine + ex.Message)); } finally { @@ -88,13 +78,14 @@ private void OnLinkLabelLinkClicked(object sender, LinkLabelLinkClickedEventArgs } } - internal override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex) + internal override void UpdateActionItem(LineInfo lineInfo, ToolTip toolTip, ref int currentTabIndex) { - _actionList = actionList; - _methodItem = (DesignerActionMethodItem)actionItem; + Info info = (Info)lineInfo; + _actionList = info.List; + _methodItem = info.Item; toolTip.SetToolTip(_linkLabel, _methodItem.Description); _linkLabel.Text = StripAmpersands(_methodItem.DisplayName); - _linkLabel.AccessibleDescription = actionItem.Description; + _linkLabel.AccessibleDescription = _methodItem.Description; _linkLabel.TabIndex = currentTabIndex++; } @@ -116,5 +107,16 @@ protected override bool ProcessDialogKey(Keys keyData) return base.ProcessDialogKey(keyData); } } + + public sealed class Info(DesignerActionList list, DesignerActionMethodItem item) : StandardLineInfo(list) + { + public override DesignerActionMethodItem Item { get; } = item; + public override Line CreateLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + { + return new MethodLine(serviceProvider, actionPanel); + } + + public override Type LineType => typeof(MethodLine); + } } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.PanelHeaderLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.PanelHeaderLine.cs index f98952029cd..e19cc5974fc 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.PanelHeaderLine.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.PanelHeaderLine.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Drawing; using System.Windows.Forms; @@ -13,25 +10,16 @@ internal sealed partial class DesignerActionPanel { private sealed class PanelHeaderLine : Line { - private DesignerActionList _actionList; - private DesignerActionPanelHeaderItem _panelHeaderItem; - private Label _titleLabel; - private Label _subtitleLabel; + private DesignerActionPanelHeaderItem? _panelHeaderItem; + private readonly Label _titleLabel; + private readonly Label _subtitleLabel; private bool _formActive; - public PanelHeaderLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + private PanelHeaderLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) { actionPanel.FontChanged += new EventHandler(OnParentControlFontChanged); - } - - public sealed override string FocusId - { - get => string.Empty; - } - protected override void AddControls(List controls) - { _titleLabel = new Label { BackColor = Color.Transparent, @@ -48,15 +36,17 @@ protected override void AddControls(List controls) UseMnemonic = false }; - controls.Add(_titleLabel); - controls.Add(_subtitleLabel); + AddedControls.Add(_titleLabel); + AddedControls.Add(_subtitleLabel); // TODO: Need to figure out how to unhook these events. Perhaps have Initialize() and Cleanup() methods. ActionPanel.FormActivated += new EventHandler(OnFormActivated); ActionPanel.FormDeactivate += new EventHandler(OnFormDeactivate); } - public sealed override void Focus() + public override string FocusId => string.Empty; + + public override void Focus() { Debug.Fail("Should never try to focus a PanelHeaderLine"); } @@ -65,7 +55,7 @@ public override Size LayoutControls(int top, int width, bool measureOnly) { Size titleSize = _titleLabel.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)); Size subtitleSize = Size.Empty; - if (!string.IsNullOrEmpty(_panelHeaderItem.Subtitle)) + if (!string.IsNullOrEmpty(_panelHeaderItem!.Subtitle)) { subtitleSize = _subtitleLabel.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)); } @@ -84,7 +74,7 @@ public override Size LayoutControls(int top, int width, bool measureOnly) return new Size(newWidth + 2, newHeight + 1); } - private void OnFormActivated(object sender, EventArgs e) + private void OnFormActivated(object? sender, EventArgs e) { // TODO: Figure out better rect _formActive = true; @@ -92,25 +82,22 @@ private void OnFormActivated(object sender, EventArgs e) //ActionPanel.Invalidate(new Rectangle(EditRegionLocation, EditRegionSize), false); } - private void OnFormDeactivate(object sender, EventArgs e) + private void OnFormDeactivate(object? sender, EventArgs e) { // TODO: Figure out better rect _formActive = false; ActionPanel.Invalidate(); } - private void OnParentControlFontChanged(object sender, EventArgs e) + private void OnParentControlFontChanged(object? sender, EventArgs e) { - if (_titleLabel is not null && _subtitleLabel is not null) - { - _titleLabel.Font = new Font(ActionPanel.Font, FontStyle.Bold); - _subtitleLabel.Font = ActionPanel.Font; - } + _titleLabel.Font = new Font(ActionPanel.Font, FontStyle.Bold); + _subtitleLabel.Font = ActionPanel.Font; } public override void PaintLine(Graphics g, int lineWidth, int lineHeight) { - Color backColor = (_formActive || ActionPanel.DropDownActive) ? ActionPanel.TitleBarColor : ActionPanel.TitleBarUnselectedColor; + Color backColor = (_formActive || ActionPanel._dropDownActive) ? ActionPanel.TitleBarColor : ActionPanel.TitleBarUnselectedColor; using (SolidBrush b = new SolidBrush(backColor)) { g.FillRectangle(b, 1, 1, lineWidth - 2, lineHeight - 1); @@ -123,10 +110,10 @@ public override void PaintLine(Graphics g, int lineWidth, int lineHeight) } } - internal override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex) + internal override void UpdateActionItem(LineInfo lineInfo, ToolTip toolTip, ref int currentTabIndex) { - _actionList = actionList; - _panelHeaderItem = (DesignerActionPanelHeaderItem)actionItem; + Info info = (Info)lineInfo; + _panelHeaderItem = info.Item; _titleLabel.Text = _panelHeaderItem.DisplayName; _titleLabel.TabIndex = currentTabIndex++; @@ -137,5 +124,16 @@ internal override void UpdateActionItem(DesignerActionList actionList, DesignerA // Force the font to update OnParentControlFontChanged(null, EventArgs.Empty); } + + public sealed class Info(DesignerActionPanelHeaderItem item) : LineInfo + { + public override DesignerActionPanelHeaderItem Item { get; } = item; + public override Line CreateLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + { + return new PanelHeaderLine(serviceProvider, actionPanel); + } + + public override Type LineType => typeof(PanelHeaderLine); + } } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.PropertyLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.PropertyLine.cs index 280d36689d3..707ecbfe7ab 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.PropertyLine.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.PropertyLine.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Globalization; using System.Reflection; @@ -14,59 +11,32 @@ internal sealed partial class DesignerActionPanel { private abstract class PropertyLine : Line { - private DesignerActionList _actionList; - private DesignerActionPropertyItem _propertyItem; - private object _value; + private DesignerActionList? _actionList; private bool _pushingValue; - private PropertyDescriptor _propDesc; - private ITypeDescriptorContext _typeDescriptorContext; + private PropertyDescriptor? _propDesc; + private ITypeDescriptorContext? _typeDescriptorContext; - public PropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) + protected PropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) { } - public sealed override string FocusId - { - get => $"PROPERTY:{_actionList.GetType().FullName}.{_propertyItem.MemberName}"; - } - - protected PropertyDescriptor PropertyDescriptor - { - get - { - _propDesc ??= TypeDescriptor.GetProperties(_actionList)[_propertyItem.MemberName]; - - return _propDesc; - } - } + public sealed override string FocusId => $"PROPERTY:{_actionList!.GetType().FullName}.{PropertyItem!.MemberName}"; - protected DesignerActionPropertyItem PropertyItem - { - get => _propertyItem; - } + protected PropertyDescriptor PropertyDescriptor => _propDesc ??= TypeDescriptor.GetProperties(_actionList!)[PropertyItem!.MemberName]!; - protected ITypeDescriptorContext TypeDescriptorContext - { - get - { - _typeDescriptorContext ??= new TypeDescriptorContext(ServiceProvider, PropertyDescriptor, _actionList); + protected DesignerActionPropertyItem? PropertyItem { get; private set; } - return _typeDescriptorContext; - } - } + protected ITypeDescriptorContext TypeDescriptorContext => _typeDescriptorContext ??= new TypeDescriptorContext(ServiceProvider, PropertyDescriptor, _actionList!); - protected object Value - { - get => _value; - } + protected object? Value { get; private set; } protected abstract void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int currentTabIndex); protected abstract void OnValueChanged(); - protected void SetValue(object newValue) + protected void SetValue(object? newValue) { - if (_pushingValue || ActionPanel.DropDownActive) + if (_pushingValue || ActionPanel._dropDownActive) { return; } @@ -86,7 +56,7 @@ protected void SetValue(object newValue) // If we can't convert it, show an error if (!PropertyDescriptor.Converter.CanConvertFrom(_typeDescriptorContext, valueType)) { - ActionPanel.ShowError(string.Format(SR.DesignerActionPanel_CouldNotConvertValue, newValue, _propDesc.PropertyType)); + ActionPanel.ShowError(string.Format(SR.DesignerActionPanel_CouldNotConvertValue, newValue, _propDesc!.PropertyType)); return; } else @@ -97,11 +67,11 @@ protected void SetValue(object newValue) } } - if (!Equals(_value, newValue)) + if (!Equals(Value, newValue)) { PropertyDescriptor.SetValue(_actionList, newValue); // Update the value we're caching - _value = PropertyDescriptor.GetValue(_actionList); + Value = PropertyDescriptor.GetValue(_actionList); OnValueChanged(); } } @@ -109,7 +79,7 @@ protected void SetValue(object newValue) { if (e is TargetInvocationException) { - e = e.InnerException; + e = e.InnerException!; } ActionPanel.ShowError(string.Format(SR.DesignerActionPanel_ErrorSettingValue, newValue, PropertyDescriptor.Name, e.Message)); @@ -120,13 +90,14 @@ protected void SetValue(object newValue) } } - internal sealed override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex) + internal sealed override void UpdateActionItem(LineInfo lineInfo, ToolTip toolTip, ref int currentTabIndex) { - _actionList = actionList; - _propertyItem = (DesignerActionPropertyItem)actionItem; + PropertyLineInfo info = (PropertyLineInfo)lineInfo; + _actionList = info.List; + PropertyItem = info.Item; _propDesc = null; _typeDescriptorContext = null; - _value = PropertyDescriptor.GetValue(actionList); + Value = PropertyDescriptor.GetValue(info.List); OnPropertyTaskItemUpdated(toolTip, ref currentTabIndex); _pushingValue = true; try @@ -138,5 +109,10 @@ internal sealed override void UpdateActionItem(DesignerActionList actionList, De _pushingValue = false; } } + + public abstract class PropertyLineInfo(DesignerActionList list, DesignerActionPropertyItem item) : StandardLineInfo(list) + { + public override DesignerActionPropertyItem Item { get; } = item; + } } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.SeparatorLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.SeparatorLine.cs index 1aa6ee69246..6fc65a65406 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.SeparatorLine.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.SeparatorLine.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms; @@ -11,30 +10,18 @@ internal sealed partial class DesignerActionPanel { private sealed class SeparatorLine : Line { - private readonly bool _isSubSeparator; - public SeparatorLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : this(serviceProvider, actionPanel, false) + private SeparatorLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel, bool isSubSeparator) : base(serviceProvider, actionPanel) { + IsSubSeparator = isSubSeparator; } - public SeparatorLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel, bool isSubSeparator) : base(serviceProvider, actionPanel) - { - _isSubSeparator = isSubSeparator; - } + public override string FocusId => string.Empty; - public sealed override string FocusId - { - get => string.Empty; - } - - public bool IsSubSeparator => _isSubSeparator; - - protected override void AddControls(List controls) - { - } + public bool IsSubSeparator { get; } public sealed override void Focus() => Debug.Fail("Should never try to focus a SeparatorLine"); - public override Size LayoutControls(int top, int width, bool measureOnly) => new Size(MinimumWidth, 1); + public override Size LayoutControls(int top, int width, bool measureOnly) => new(MinimumWidth, 1); public override void PaintLine(Graphics g, int lineWidth, int lineHeight) { @@ -44,8 +31,20 @@ public override void PaintLine(Graphics g, int lineWidth, int lineHeight) } } - internal override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex) + internal override void UpdateActionItem(LineInfo lineInfo, ToolTip toolTip, ref int currentTabIndex) + { + } + + public sealed class Info(bool isSubSeparator = false) : LineInfo { + private readonly bool _isSubSeparator = isSubSeparator; + public override DesignerActionItem? Item => null; + public override Line CreateLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + { + return new SeparatorLine(serviceProvider, actionPanel, _isSubSeparator); + } + + public override Type LineType => typeof(SeparatorLine); } } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextBoxPropertyLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextBoxPropertyLine.cs index f1fe2fa6e10..3ffac325f45 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextBoxPropertyLine.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextBoxPropertyLine.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Drawing; using System.Windows.Forms; @@ -13,42 +10,16 @@ internal sealed partial class DesignerActionPanel { private class TextBoxPropertyLine : PropertyLine { - private TextBox _textBox; - private EditorLabel _readOnlyTextBoxLabel; - private Control _editControl; - private Label _label; + private readonly TextBox _textBox; + private readonly EditorLabel _readOnlyTextBoxLabel; + private readonly Label _label; private int _editXPos; private bool _textBoxDirty; private Point _editRegionLocation; - private Point _editRegionRelativeLocation; private Size _editRegionSize; - public TextBoxPropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + protected TextBoxPropertyLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) - { - } - - protected Control EditControl - { - get => _editControl; - } - - protected Point EditRegionLocation - { - get => _editRegionLocation; - } - - protected Point EditRegionRelativeLocation - { - get => _editRegionRelativeLocation; - } - - protected Size EditRegionSize - { - get => _editRegionSize; - } - - protected override void AddControls(List controls) { _label = new Label { @@ -82,14 +53,22 @@ protected override void AddControls(List controls) _textBox.KeyDown += new KeyEventHandler(OnTextBoxKeyDown); _textBox.LostFocus += new EventHandler(OnTextBoxLostFocus); - controls.Add(_readOnlyTextBoxLabel); - controls.Add(_textBox); - controls.Add(_label); + AddedControls.Add(_readOnlyTextBoxLabel); + AddedControls.Add(_textBox); + AddedControls.Add(_label); } + protected Control? EditControl { get; private set; } + + protected Point EditRegionLocation => _editRegionLocation; + + protected Point EditRegionRelativeLocation { get; private set; } + + protected Size EditRegionSize => _editRegionSize; + public sealed override void Focus() { - _editControl.Focus(); + EditControl!.Focus(); } internal int GetEditRegionXPos() @@ -121,21 +100,17 @@ public override Size LayoutControls(int top, int width, bool measureOnly) if (!measureOnly) { _editRegionLocation = new Point(editRegionXPos, top + TextBoxTopPadding); - _editRegionRelativeLocation = new Point(editRegionXPos, TextBoxTopPadding); + EditRegionRelativeLocation = new Point(editRegionXPos, TextBoxTopPadding); _editRegionSize = new Size(EditInputWidth + textBoxWidthBonus, textBoxPreferredHeight + TextBoxLineInnerPadding * 2); _label.Location = new Point(LineLeftMargin, top); int labelPreferredWidth = _label.GetPreferredSize(new Size(int.MaxValue, int.MaxValue)).Width; _label.Size = new Size(labelPreferredWidth, height); - int specialPadding = 0; - if (_editControl is TextBox) - { - specialPadding = 2; - } + int specialPadding = EditControl is TextBox ? 2 : 0; - _editControl.Location = new Point(_editRegionLocation.X + GetTextBoxLeftPadding(textBoxPreferredHeight) + 1 + specialPadding, _editRegionLocation.Y + TextBoxLineInnerPadding + 1); - _editControl.Width = _editRegionSize.Width - GetTextBoxRightPadding(textBoxPreferredHeight) - GetTextBoxLeftPadding(textBoxPreferredHeight) - specialPadding; - _editControl.Height = _editRegionSize.Height - TextBoxLineInnerPadding * 2 - 1; + EditControl!.Location = new Point(_editRegionLocation.X + GetTextBoxLeftPadding(textBoxPreferredHeight) + 1 + specialPadding, _editRegionLocation.Y + TextBoxLineInnerPadding + 1); + EditControl.Width = _editRegionSize.Width - GetTextBoxRightPadding(textBoxPreferredHeight) - GetTextBoxLeftPadding(textBoxPreferredHeight) - specialPadding; + EditControl.Height = _editRegionSize.Height - TextBoxLineInnerPadding * 2 - 1; } return new Size(width, height); @@ -145,7 +120,7 @@ public override Size LayoutControls(int top, int width, bool measureOnly) protected override void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int currentTabIndex) { - _label.Text = StripAmpersands(PropertyItem.DisplayName); + _label.Text = StripAmpersands(PropertyItem!.DisplayName); _label.TabIndex = currentTabIndex++; toolTip.SetToolTip(_label, PropertyItem.Description); _textBoxDirty = false; @@ -156,7 +131,7 @@ protected override void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int curre _textBox.Visible = false; // REVIEW: Setting Visible to false doesn't seem to work, so position far away _textBox.Location = new Point(int.MaxValue, int.MaxValue); - _editControl = _readOnlyTextBoxLabel; + EditControl = _readOnlyTextBoxLabel; } else { @@ -164,16 +139,16 @@ protected override void OnPropertyTaskItemUpdated(ToolTip toolTip, ref int curre // REVIEW: Setting Visible to false doesn't seem to work, so position far away _readOnlyTextBoxLabel.Location = new Point(int.MaxValue, int.MaxValue); _textBox.Visible = true; - _editControl = _textBox; + EditControl = _textBox; } - _editControl.AccessibleDescription = PropertyItem.Description; - _editControl.AccessibleName = StripAmpersands(PropertyItem.DisplayName); - _editControl.TabIndex = currentTabIndex++; - _editControl.BringToFront(); + EditControl.AccessibleDescription = PropertyItem.Description; + EditControl.AccessibleName = StripAmpersands(PropertyItem.DisplayName); + EditControl.TabIndex = currentTabIndex++; + EditControl.BringToFront(); } - protected virtual void OnReadOnlyTextBoxLabelClick(object sender, MouseEventArgs e) + protected virtual void OnReadOnlyTextBoxLabelClick(object? sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { @@ -181,19 +156,19 @@ protected virtual void OnReadOnlyTextBoxLabelClick(object sender, MouseEventArgs } } - private void OnReadOnlyTextBoxLabelEnter(object sender, EventArgs e) + private void OnReadOnlyTextBoxLabelEnter(object? sender, EventArgs e) { _readOnlyTextBoxLabel.ForeColor = SystemColors.HighlightText; _readOnlyTextBoxLabel.BackColor = SystemColors.Highlight; } - private void OnReadOnlyTextBoxLabelLeave(object sender, EventArgs e) + private void OnReadOnlyTextBoxLabelLeave(object? sender, EventArgs e) { _readOnlyTextBoxLabel.ForeColor = SystemColors.WindowText; _readOnlyTextBoxLabel.BackColor = SystemColors.Window; } - protected TypeConverter.StandardValuesCollection GetStandardValues() + protected TypeConverter.StandardValuesCollection? GetStandardValues() { TypeConverter converter = PropertyDescriptor.Converter; if (converter is not null && @@ -211,7 +186,7 @@ private void OnEditControlKeyDown(KeyEventArgs e) { e.Handled = true; // Try to find the existing value and then pick the one after it - TypeConverter.StandardValuesCollection standardValues = GetStandardValues(); + TypeConverter.StandardValuesCollection? standardValues = GetStandardValues(); if (standardValues is not null) { for (int i = 0; i < standardValues.Count; i++) @@ -241,7 +216,7 @@ private void OnEditControlKeyDown(KeyEventArgs e) { e.Handled = true; // Try to find the existing value and then pick the one before it - TypeConverter.StandardValuesCollection standardValues = GetStandardValues(); + TypeConverter.StandardValuesCollection? standardValues = GetStandardValues(); if (standardValues is not null) { for (int i = 0; i < standardValues.Count; i++) @@ -268,15 +243,15 @@ private void OnEditControlKeyDown(KeyEventArgs e) } } - private void OnReadOnlyTextBoxLabelKeyDown(object sender, KeyEventArgs e) + private void OnReadOnlyTextBoxLabelKeyDown(object? sender, KeyEventArgs e) { // Delegate the rest of the processing to a common helper OnEditControlKeyDown(e); } - private void OnTextBoxKeyDown(object sender, KeyEventArgs e) + private void OnTextBoxKeyDown(object? sender, KeyEventArgs e) { - if (ActionPanel.DropDownActive) + if (ActionPanel._dropDownActive) { return; } @@ -292,9 +267,9 @@ private void OnTextBoxKeyDown(object sender, KeyEventArgs e) OnEditControlKeyDown(e); } - private void OnTextBoxLostFocus(object sender, EventArgs e) + private void OnTextBoxLostFocus(object? sender, EventArgs e) { - if (ActionPanel.DropDownActive) + if (ActionPanel._dropDownActive) { return; } @@ -302,9 +277,9 @@ private void OnTextBoxLostFocus(object sender, EventArgs e) UpdateValue(); } - private void OnTextBoxTextChanged(object sender, EventArgs e) => _textBoxDirty = true; + private void OnTextBoxTextChanged(object? sender, EventArgs e) => _textBoxDirty = true; - protected override void OnValueChanged() => _editControl.Text = PropertyDescriptor.Converter.ConvertToString(TypeDescriptorContext, Value); + protected override void OnValueChanged() => EditControl!.Text = PropertyDescriptor.Converter.ConvertToString(TypeDescriptorContext, Value); public override void PaintLine(Graphics g, int lineWidth, int lineHeight) { @@ -330,7 +305,7 @@ private void UpdateValue() { if (_textBoxDirty) { - SetValue(_editControl.Text); + SetValue(EditControl!.Text); _textBoxDirty = false; } } @@ -359,8 +334,7 @@ protected override void OnGotFocus(EventArgs e) protected override bool IsInputKey(Keys keyData) { - if (keyData == Keys.Down || - keyData == Keys.Up) + if (keyData is Keys.Down or Keys.Up) { return true; } @@ -375,11 +349,18 @@ public EditorLabelAccessibleObject(EditorLabel owner) { } - public override string Value - { - get => Owner.Text; - } + public override string Value => Owner!.Text; } } + + public sealed class Info(DesignerActionList list, DesignerActionPropertyItem item) : PropertyLineInfo(list, item) + { + public override Line CreateLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + { + return new TextBoxPropertyLine(serviceProvider, actionPanel); + } + + public override Type LineType => typeof(TextBoxPropertyLine); + } } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextLine.cs index 5b45d3e2afb..eeeb2718445 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextLine.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextLine.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Drawing; using System.Windows.Forms; @@ -13,32 +10,25 @@ internal sealed partial class DesignerActionPanel { private class TextLine : Line { - private Label _label; - private DesignerActionTextItem _textItem; + private readonly Label _label; + private DesignerActionTextItem? _textItem; - public TextLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + protected TextLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) : base(serviceProvider, actionPanel) { actionPanel.FontChanged += new EventHandler(OnParentControlFontChanged); - } - - public sealed override string FocusId - { - get => string.Empty; - } - - protected override void AddControls(List controls) - { _label = new Label { BackColor = Color.Transparent, ForeColor = ActionPanel.LabelForeColor, TextAlign = ContentAlignment.MiddleLeft, - UseMnemonic = false + UseMnemonic = false, }; - controls.Add(_label); + AddedControls.Add(_label); } + public sealed override string FocusId => string.Empty; + public sealed override void Focus() { Debug.Fail("Should never try to focus a TextLine"); @@ -56,9 +46,9 @@ public override Size LayoutControls(int top, int width, bool measureOnly) return labelSize + new Size(LineLeftMargin + LineRightMargin, LineVerticalPadding); } - private void OnParentControlFontChanged(object sender, EventArgs e) + private void OnParentControlFontChanged(object? sender, EventArgs e) { - if (_label is not null && _label.Font is not null) + if (_label.Font is not null) { _label.Font = GetFont(); } @@ -69,13 +59,25 @@ protected virtual Font GetFont() return ActionPanel.Font; } - internal override void UpdateActionItem(DesignerActionList actionList, DesignerActionItem actionItem, ToolTip toolTip, ref int currentTabIndex) + internal override void UpdateActionItem(LineInfo lineInfo, ToolTip toolTip, ref int currentTabIndex) { - _textItem = (DesignerActionTextItem)actionItem; + Info info = (Info)lineInfo; + _textItem = info.Item; _label.Text = StripAmpersands(_textItem.DisplayName); _label.Font = GetFont(); _label.TabIndex = currentTabIndex++; toolTip.SetToolTip(_label, _textItem.Description); } + + public sealed class Info(DesignerActionList list, DesignerActionTextItem item) : StandardLineInfo(list) + { + public override DesignerActionTextItem Item { get; } = item; + public override Line CreateLine(IServiceProvider serviceProvider, DesignerActionPanel actionPanel) + { + return new TextLine(serviceProvider, actionPanel); + } + + public override Type LineType => typeof(TextLine); + } } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TypeDescriptorContext.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TypeDescriptorContext.cs index ac45b5603a9..4f161d215e1 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TypeDescriptorContext.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TypeDescriptorContext.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable namespace System.ComponentModel.Design; @@ -11,31 +8,29 @@ internal sealed partial class DesignerActionPanel internal sealed class TypeDescriptorContext : ITypeDescriptorContext { private readonly IServiceProvider _serviceProvider; - private readonly PropertyDescriptor _propertyDescriptor; - private readonly object _instance; public TypeDescriptorContext(IServiceProvider serviceProvider, PropertyDescriptor propertyDescriptor, object instance) { _serviceProvider = serviceProvider; - _propertyDescriptor = propertyDescriptor; - _instance = instance; + PropertyDescriptor = propertyDescriptor; + Instance = instance; } - private IComponentChangeService ComponentChangeService => _serviceProvider.GetService(); + private IComponentChangeService? ComponentChangeService => _serviceProvider.GetService(); - public IContainer Container => _serviceProvider.GetService(); + public IContainer? Container => _serviceProvider.GetService(); - public object Instance => _instance; + public object Instance { get; } - public PropertyDescriptor PropertyDescriptor => _propertyDescriptor; + public PropertyDescriptor PropertyDescriptor { get; } - public object GetService(Type serviceType) => _serviceProvider.GetService(serviceType); + public object? GetService(Type serviceType) => _serviceProvider.GetService(serviceType); public bool OnComponentChanging() { try { - ComponentChangeService?.OnComponentChanging(_instance, _propertyDescriptor); + ComponentChangeService?.OnComponentChanging(Instance, PropertyDescriptor); return true; } catch (CheckoutException ce) when (ce == CheckoutException.Canceled) @@ -44,6 +39,6 @@ public bool OnComponentChanging() } } - public void OnComponentChanged() => ComponentChangeService?.OnComponentChanged(_instance, _propertyDescriptor); + public void OnComponentChanged() => ComponentChangeService?.OnComponentChanged(Instance, PropertyDescriptor); } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs index c54862bbdfe..ee5e523a1a3 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs @@ -1,11 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Collections; -using System.Collections.Specialized; using System.Drawing; using System.Drawing.Design; using System.Drawing.Drawing2D; @@ -17,8 +13,8 @@ namespace System.ComponentModel.Design; internal sealed partial class DesignerActionPanel : ContainerControl { - private static readonly object s_eventFormActivated = new object(); - private static readonly object s_eventFormDeactivate = new object(); + private static readonly object s_eventFormActivated = new(); + private static readonly object s_eventFormDeactivate = new(); private const int EditInputWidth = 150; // The static size of edit controls private const int ListBoxMaximumHeight = 200; // The maximum height of a dropdown listbox @@ -39,25 +35,13 @@ internal sealed partial class DesignerActionPanel : ContainerControl private const int PanelHeaderHorizontalPadding = 5; // Horizontal padding within the header of the panel private const int TextBoxHeightFixup = 2; // Countereffects the fix for VSWhidbey 359726 - we relied on the broken behavior before - private CommandID[] _filteredCommandIDs; + private CommandID[]? _filteredCommandIDs; private readonly ToolTip _toolTip; private readonly List _lines; private readonly List _lineYPositions; private readonly List _lineHeights; - private readonly Color _gradientLightColor = SystemColors.Control; - private readonly Color _gradientDarkColor = SystemColors.Control; - private readonly Color _titleBarColor = SystemColors.ActiveCaption; - private readonly Color _titleBarUnselectedColor = SystemColors.InactiveCaption; - private readonly Color _titleBarTextColor = SystemColors.ActiveCaptionText; - private readonly Color _separatorColor = SystemColors.ControlDark; - private readonly Color _borderColor = SystemColors.ActiveBorder; - private readonly Color _linkColor = SystemColors.HotTrack; - private readonly Color _activeLinkColor = SystemColors.HotTrack; - private readonly Color _labelForeColor = SystemColors.ControlText; - private readonly IServiceProvider _serviceProvider; - private bool _inMethodInvoke; private bool _updatingTasks; private bool _dropDownActive; @@ -75,194 +59,131 @@ public DesignerActionPanel(IServiceProvider serviceProvider) _lineYPositions = new List(); _toolTip = new ToolTip(); // Try to get the font from the IUIService, otherwise, use the default - IUIService uiService = (IUIService)ServiceProvider.GetService(typeof(IUIService)); + IUIService? uiService = _serviceProvider.GetService(); if (uiService is not null) { - Font = (Font)uiService.Styles["DialogFont"]; - if (uiService.Styles["VsColorPanelGradientDark"] is Color) + Font = (Font)uiService.Styles["DialogFont"]!; + if (uiService.Styles["VsColorPanelGradientDark"] is Color vsColorPanelGradientDarkColor) { - _gradientDarkColor = (Color)uiService.Styles["VsColorPanelGradientDark"]; + GradientDarkColor = vsColorPanelGradientDarkColor; } - if (uiService.Styles["VsColorPanelGradientLight"] is Color) + if (uiService.Styles["VsColorPanelGradientLight"] is Color vsColorPanelGradientLight) { - _gradientLightColor = (Color)uiService.Styles["VsColorPanelGradientLight"]; + GradientLightColor = vsColorPanelGradientLight; } - if (uiService.Styles["VsColorPanelHyperLink"] is Color) + if (uiService.Styles["VsColorPanelHyperLink"] is Color vsColorPanelHyperLink) { - _linkColor = (Color)uiService.Styles["VsColorPanelHyperLink"]; + LinkColor = vsColorPanelHyperLink; } - if (uiService.Styles["VsColorPanelHyperLinkPressed"] is Color) + if (uiService.Styles["VsColorPanelHyperLinkPressed"] is Color vsColorPanelHyperLinkPressed) { - _activeLinkColor = (Color)uiService.Styles["VsColorPanelHyperLinkPressed"]; + ActiveLinkColor = vsColorPanelHyperLinkPressed; } - if (uiService.Styles["VsColorPanelTitleBar"] is Color) + if (uiService.Styles["VsColorPanelTitleBar"] is Color vsColorPanelTitleBar) { - _titleBarColor = (Color)uiService.Styles["VsColorPanelTitleBar"]; + TitleBarColor = vsColorPanelTitleBar; } - if (uiService.Styles["VsColorPanelTitleBarUnselected"] is Color) + if (uiService.Styles["VsColorPanelTitleBarUnselected"] is Color vsColorPanelTitleBarUnselected) { - _titleBarUnselectedColor = (Color)uiService.Styles["VsColorPanelTitleBarUnselected"]; + TitleBarUnselectedColor = vsColorPanelTitleBarUnselected; } - if (uiService.Styles["VsColorPanelTitleBarText"] is Color) + if (uiService.Styles["VsColorPanelTitleBarText"] is Color vsColorPanelTitleBarText) { - _titleBarTextColor = (Color)uiService.Styles["VsColorPanelTitleBarText"]; + TitleBarTextColor = vsColorPanelTitleBarText; } - if (uiService.Styles["VsColorPanelBorder"] is Color) + if (uiService.Styles["VsColorPanelBorder"] is Color vsColorPanelBorder) { - _borderColor = (Color)uiService.Styles["VsColorPanelBorder"]; + BorderColor = vsColorPanelBorder; } - if (uiService.Styles["VsColorPanelSeparator"] is Color) + if (uiService.Styles["VsColorPanelSeparator"] is Color vsColorPanelSeparator) { - _separatorColor = (Color)uiService.Styles["VsColorPanelSeparator"]; + SeparatorColor = vsColorPanelSeparator; } - if (uiService.Styles["VsColorPanelText"] is Color) + if (uiService.Styles["VsColorPanelText"] is Color vsColorPanelText) { - _labelForeColor = (Color)uiService.Styles["VsColorPanelText"]; + LabelForeColor = vsColorPanelText; } } MinimumSize = new Size(150, 0); } - public Color ActiveLinkColor - { - get => _activeLinkColor; - } + public Color ActiveLinkColor { get; } = SystemColors.HotTrack; - public Color BorderColor - { - get => _borderColor; - } - - private bool DropDownActive - { - get => _dropDownActive; - } + public Color BorderColor { get; } = SystemColors.ActiveBorder; /// /// Returns the list of commands that should be filtered by the form that hosts this panel. This is done so that these specific commands will not get passed on to VS, and can instead be handled by the panel itself. /// - public CommandID[] FilteredCommandIDs - { - get - { - _filteredCommandIDs ??= new CommandID[] - { - StandardCommands.Copy, - StandardCommands.Cut, - StandardCommands.Delete, - StandardCommands.F1Help, - StandardCommands.Paste, - StandardCommands.Redo, - StandardCommands.SelectAll, - StandardCommands.Undo, - MenuCommands.KeyCancel, - MenuCommands.KeyReverseCancel, - MenuCommands.KeyDefaultAction, - MenuCommands.KeyEnd, - MenuCommands.KeyHome, - MenuCommands.KeyMoveDown, - MenuCommands.KeyMoveLeft, - MenuCommands.KeyMoveRight, - MenuCommands.KeyMoveUp, - MenuCommands.KeyNudgeDown, - MenuCommands.KeyNudgeHeightDecrease, - MenuCommands.KeyNudgeHeightIncrease, - MenuCommands.KeyNudgeLeft, - MenuCommands.KeyNudgeRight, - MenuCommands.KeyNudgeUp, - MenuCommands.KeyNudgeWidthDecrease, - MenuCommands.KeyNudgeWidthIncrease, - MenuCommands.KeySizeHeightDecrease, - MenuCommands.KeySizeHeightIncrease, - MenuCommands.KeySizeWidthDecrease, - MenuCommands.KeySizeWidthIncrease, - MenuCommands.KeySelectNext, - MenuCommands.KeySelectPrevious, - MenuCommands.KeyShiftEnd, - MenuCommands.KeyShiftHome, - }; - - return _filteredCommandIDs; - } - } + public CommandID[] FilteredCommandIDs => + _filteredCommandIDs ??= new CommandID[] + { + StandardCommands.Copy, + StandardCommands.Cut, + StandardCommands.Delete, + StandardCommands.F1Help, + StandardCommands.Paste, + StandardCommands.Redo, + StandardCommands.SelectAll, + StandardCommands.Undo, + MenuCommands.KeyCancel, + MenuCommands.KeyReverseCancel, + MenuCommands.KeyDefaultAction, + MenuCommands.KeyEnd, + MenuCommands.KeyHome, + MenuCommands.KeyMoveDown, + MenuCommands.KeyMoveLeft, + MenuCommands.KeyMoveRight, + MenuCommands.KeyMoveUp, + MenuCommands.KeyNudgeDown, + MenuCommands.KeyNudgeHeightDecrease, + MenuCommands.KeyNudgeHeightIncrease, + MenuCommands.KeyNudgeLeft, + MenuCommands.KeyNudgeRight, + MenuCommands.KeyNudgeUp, + MenuCommands.KeyNudgeWidthDecrease, + MenuCommands.KeyNudgeWidthIncrease, + MenuCommands.KeySizeHeightDecrease, + MenuCommands.KeySizeHeightIncrease, + MenuCommands.KeySizeWidthDecrease, + MenuCommands.KeySizeWidthIncrease, + MenuCommands.KeySelectNext, + MenuCommands.KeySelectPrevious, + MenuCommands.KeyShiftEnd, + MenuCommands.KeyShiftHome, + }; /// /// Gets the Line that currently has input focus. /// - private Line FocusedLine - { - get - { - Control activeControl = ActiveControl; - if (activeControl is not null) - { - return activeControl.Tag as Line; - } + private Line? FocusedLine => ActiveControl?.Tag as Line; - return null; - } - } + public Color GradientDarkColor { get; } = SystemColors.Control; - public Color GradientDarkColor - { - get => _gradientDarkColor; - } + public Color GradientLightColor { get; } = SystemColors.Control; - public Color GradientLightColor - { - get => _gradientLightColor; - } + public bool InMethodInvoke { get; internal set; } - public bool InMethodInvoke - { - get => _inMethodInvoke; - internal set => _inMethodInvoke = value; - } + public Color LinkColor { get; } = SystemColors.HotTrack; - public Color LinkColor - { - get => _linkColor; - } + public Color SeparatorColor { get; } = SystemColors.ControlDark; - public Color SeparatorColor - { - get => _separatorColor; - } - - private IServiceProvider ServiceProvider - { - get => _serviceProvider; - } - - public Color TitleBarColor - { - get => _titleBarColor; - } + public Color TitleBarColor { get; } = SystemColors.ActiveCaption; - public Color TitleBarTextColor - { - get => _titleBarTextColor; - } + public Color TitleBarTextColor { get; } = SystemColors.ActiveCaptionText; - public Color TitleBarUnselectedColor - { - get => _titleBarUnselectedColor; - } + public Color TitleBarUnselectedColor { get; } = SystemColors.InactiveCaption; - public Color LabelForeColor - { - get => _labelForeColor; - } + public Color LabelForeColor { get; } = SystemColors.ControlText; /// /// Helper event so that Lines can be notified of this event. @@ -282,20 +203,18 @@ private event EventHandler FormDeactivate remove => Events.RemoveHandler(s_eventFormDeactivate, value); } - private static void AddToCategories(LineInfo lineInfo, ListDictionary categories) + private static void AddToCategories(StandardLineInfo lineInfo, Dictionary>> categories) { - string categoryName = lineInfo.Item.Category; + string? categoryName = lineInfo.Item.Category; categoryName ??= string.Empty; - ListDictionary category = (ListDictionary)categories[categoryName]; - if (category is null) + if (!categories.TryGetValue(categoryName, out Dictionary>? category)) { - category = new ListDictionary(); + category = new Dictionary>(); categories.Add(categoryName, category); } - List categoryList = (List)category[lineInfo.List]; - if (categoryList is null) + if (!category.TryGetValue(lineInfo.List, out List? categoryList)) { categoryList = new List(); category.Add(lineInfo.List, categoryList); @@ -324,7 +243,7 @@ public static Point ComputePreferredDesktopLocation(Rectangle rectangleAnchor, S } } - bool fBelowAnchor = (fRightOfAnchor ? true : false); + bool fBelowAnchor = fRightOfAnchor; bool fAlignToScreenTop = false; if (fBelowAnchor) { @@ -483,7 +402,7 @@ private static bool IsReadOnlyProperty(PropertyDescriptor pd) return true; } - return (pd.ComponentType.GetProperty(pd.Name).GetSetMethod() is null); + return (pd.ComponentType.GetProperty(pd.Name)!.GetSetMethod() is null); } protected override void OnFontChanged(EventArgs e) @@ -495,10 +414,10 @@ protected override void OnFontChanged(EventArgs e) private void OnFormActivated(object sender, EventArgs e) { - ((EventHandler)Events[s_eventFormActivated])?.Invoke(sender, e); + ((EventHandler?)Events[s_eventFormActivated])?.Invoke(sender, e); } - private void OnFormClosing(object sender, CancelEventArgs e) + private void OnFormClosing(object? sender, CancelEventArgs e) { if (!e.Cancel && TopLevelControl is not null) { @@ -513,7 +432,7 @@ private void OnFormClosing(object sender, CancelEventArgs e) private void OnFormDeactivate(object sender, EventArgs e) { - ((EventHandler)Events[s_eventFormDeactivate])?.Invoke(sender, e); + ((EventHandler?)Events[s_eventFormDeactivate])?.Invoke(sender, e); } protected override void OnHandleCreated(EventArgs e) @@ -603,7 +522,7 @@ protected override void OnRightToLeftChanged(EventArgs e) protected override bool ProcessDialogKey(Keys keyData) { // TODO: RightToLeft management for left/right arrow keys (from old DesignerActionPanel) - Line focusedLine = FocusedLine; + Line? focusedLine = FocusedLine; if (focusedLine is not null) { if (focusedLine.ProcessDialogKey(keyData)) @@ -621,7 +540,7 @@ protected override bool ProcessTabKey(bool forward) return (SelectNextControl(ActiveControl, forward, true, true, true)); } - private void ProcessLists(DesignerActionListCollection lists, ListDictionary categories) + private void ProcessLists(DesignerActionListCollection? lists, Dictionary>> categories) { if (lists is null) { @@ -642,7 +561,7 @@ private void ProcessLists(DesignerActionListCollection lists, ListDictionary cat continue; } - LineInfo lineInfo = ProcessTaskItem(list, item); + StandardLineInfo? lineInfo = ProcessTaskItem(list, item); if (lineInfo is null) { continue; @@ -650,7 +569,7 @@ private void ProcessLists(DesignerActionListCollection lists, ListDictionary cat AddToCategories(lineInfo, categories); // Process lists from related component - IComponent relatedComponent = null; + IComponent? relatedComponent = null; if (item is DesignerActionPropertyItem propItem) { relatedComponent = propItem.RelatedComponent; @@ -665,10 +584,10 @@ private void ProcessLists(DesignerActionListCollection lists, ListDictionary cat if (relatedComponent is not null) { - IEnumerable relatedLineInfos = ProcessRelatedTaskItems(relatedComponent); + IEnumerable? relatedLineInfos = ProcessRelatedTaskItems(relatedComponent); if (relatedLineInfos is not null) { - foreach (LineInfo relatedLineInfo in relatedLineInfos) + foreach (StandardLineInfo relatedLineInfo in relatedLineInfos) { AddToCategories(relatedLineInfo, categories); } @@ -680,12 +599,12 @@ private void ProcessLists(DesignerActionListCollection lists, ListDictionary cat } } - private IEnumerable ProcessRelatedTaskItems(IComponent relatedComponent) + private IEnumerable ProcessRelatedTaskItems(IComponent relatedComponent) { // Add the related tasks Debug.Assert(relatedComponent is not null); - DesignerActionListCollection relatedLists = null; - DesignerActionService actionService = (DesignerActionService)ServiceProvider.GetService(typeof(DesignerActionService)); + DesignerActionListCollection? relatedLists = null; + DesignerActionService? actionService = _serviceProvider.GetService(); if (actionService is not null) { relatedLists = actionService.GetComponentActions(relatedComponent); @@ -693,20 +612,17 @@ private IEnumerable ProcessRelatedTaskItems(IComponent relatedComponen else { // Try to use the component's service provider if it exists so that we end up getting the right IDesignerHost. - IServiceProvider serviceProvider = relatedComponent.Site; - serviceProvider ??= ServiceProvider; + IServiceProvider? serviceProvider = relatedComponent.Site; + serviceProvider ??= _serviceProvider; - IDesignerHost host = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost)); - if (host is not null) + IDesignerHost? host = serviceProvider.GetService(); + if (host?.GetDesigner(relatedComponent) is ComponentDesigner componentDesigner) { - if (host.GetDesigner(relatedComponent) is ComponentDesigner componentDesigner) - { - relatedLists = componentDesigner.ActionLists; - } + relatedLists = componentDesigner.ActionLists; } } - List lineInfos = new List(); + List lineInfos = new List(); if (relatedLists is not null) { @@ -723,7 +639,7 @@ private IEnumerable ProcessRelatedTaskItems(IComponent relatedComponen { if (relatedItem.AllowAssociate) { - LineInfo lineInfo = ProcessTaskItem(relatedList, relatedItem); + StandardLineInfo? lineInfo = ProcessTaskItem(relatedList, relatedItem); if (lineInfo is not null) { lineInfos.Add(lineInfo); @@ -739,60 +655,55 @@ private IEnumerable ProcessRelatedTaskItems(IComponent relatedComponen return lineInfos; } - private LineInfo ProcessTaskItem(DesignerActionList list, DesignerActionItem item) + private StandardLineInfo? ProcessTaskItem(DesignerActionList list, DesignerActionItem item) { - Line newLine; - if (item is DesignerActionMethodItem) + if (item is DesignerActionMethodItem methodItem) { - newLine = new MethodLine(_serviceProvider, this); + return new MethodLine.Info(list, methodItem); } else if (item is DesignerActionPropertyItem pti) { - PropertyDescriptor pd = TypeDescriptor.GetProperties(list)[pti.MemberName]; + PropertyDescriptor? pd = TypeDescriptor.GetProperties(list)[pti.MemberName]; if (pd is null) { throw new InvalidOperationException(string.Format(SR.DesignerActionPanel_CouldNotFindProperty, pti.MemberName, list.GetType().FullName)); } TypeDescriptorContext context = new TypeDescriptorContext(_serviceProvider, pd, list); - UITypeEditor editor = (UITypeEditor)pd.GetEditor(typeof(UITypeEditor)); bool standardValuesSupported = pd.Converter.GetStandardValuesSupported(context); - if (editor is null) + if (pd.TryGetEditor(out UITypeEditor? _)) { - if (pd.PropertyType == typeof(bool)) - { - if (IsReadOnlyProperty(pd)) - { - newLine = new TextBoxPropertyLine(_serviceProvider, this); - } - else - { - newLine = new CheckBoxPropertyLine(_serviceProvider, this); - } - } - else if (standardValuesSupported) + return new EditorPropertyLine.Info(list, pti); + } + else if (pd.PropertyType == typeof(bool)) + { + if (IsReadOnlyProperty(pd)) { - newLine = new EditorPropertyLine(_serviceProvider, this); + return new TextBoxPropertyLine.Info(list, pti); } else { - newLine = new TextBoxPropertyLine(_serviceProvider, this); + return new CheckBoxPropertyLine.Info(list, pti); } } + else if (standardValuesSupported) + { + return new EditorPropertyLine.Info(list, pti); + } else { - newLine = new EditorPropertyLine(_serviceProvider, this); + return new TextBoxPropertyLine.Info(list, pti); } } - else if (item is DesignerActionTextItem) + else if (item is DesignerActionTextItem textItem) { if (item is DesignerActionHeaderItem) { - newLine = new HeaderLine(_serviceProvider, this); + return new HeaderLine.Info(list, textItem); } else { - newLine = new TextLine(_serviceProvider, this); + return new TextLine.Info(list, textItem); } } else @@ -800,8 +711,6 @@ private LineInfo ProcessTaskItem(DesignerActionList list, DesignerActionItem ite // Ignore unknown items return null; } - - return new LineInfo(list, item, newLine); } private void SetDropDownActive(bool active) @@ -811,7 +720,7 @@ private void SetDropDownActive(bool active) private void ShowError(string errorMessage) { - IUIService uiService = (IUIService)ServiceProvider.GetService(typeof(IUIService)); + IUIService? uiService = _serviceProvider.GetService(); if (uiService is not null) { uiService.ShowError(errorMessage); @@ -834,7 +743,7 @@ private void ShowError(string errorMessage) /// - Convert "&x" to "x" /// - An ampersand by itself at the end of a string is displayed as-is /// - private static string StripAmpersands(string s) + private static string StripAmpersands(string? s) { if (string.IsNullOrEmpty(s)) { @@ -884,7 +793,7 @@ private void UpdateEditXPos() } } - public void UpdateTasks(DesignerActionListCollection actionLists, DesignerActionListCollection serviceActionLists, string title, string subtitle) + public void UpdateTasks(DesignerActionListCollection actionLists, DesignerActionListCollection serviceActionLists, string title, string? subtitle) { _updatingTasks = true; SuspendLayout(); @@ -895,24 +804,24 @@ public void UpdateTasks(DesignerActionListCollection actionLists, DesignerAction // Store the focus state string focusId = string.Empty; - Line focusedLine = FocusedLine; + Line? focusedLine = FocusedLine; if (focusedLine is not null) { focusId = focusedLine.FocusId; } // Merge the categories from the lists and create controls for each of the items - ListDictionary categories = new ListDictionary(); + Dictionary>> categories = new(); ProcessLists(actionLists, categories); ProcessLists(serviceActionLists, categories); // Create a flat list of lines w/ separators List newLines = new List { // Always add a special line for the header - new LineInfo(null, new DesignerActionPanelHeaderItem(title, subtitle), new PanelHeaderLine(_serviceProvider, this)) + new PanelHeaderLine.Info(new DesignerActionPanelHeaderItem(title, subtitle)) }; int categoriesIndex = 0; - foreach (ListDictionary category in categories.Values) + foreach (Dictionary> category in categories.Values) { int categoryIndex = 0; foreach (List categoryList in category.Values) @@ -926,7 +835,7 @@ public void UpdateTasks(DesignerActionListCollection actionLists, DesignerAction // Add a sub-separator if (categoryIndex < category.Count) { - newLines.Add(new LineInfo(null, null, new SeparatorLine(_serviceProvider, this, true))); + newLines.Add(new SeparatorLine.Info(true)); } } @@ -934,7 +843,7 @@ public void UpdateTasks(DesignerActionListCollection actionLists, DesignerAction // Add a separator if (categoriesIndex < categories.Count) { - newLines.Add(new LineInfo(null, null, new SeparatorLine(_serviceProvider, this))); + newLines.Add(new SeparatorLine.Info()); } } @@ -943,16 +852,15 @@ public void UpdateTasks(DesignerActionListCollection actionLists, DesignerAction for (int i = 0; i < newLines.Count; i++) { LineInfo newLineInfo = newLines[i]; - Line newLine = newLineInfo.Line; // See if we can update an old line bool updated = false; if (i < _lines.Count) { Line oldLine = _lines[i]; - if (oldLine.GetType() == newLine.GetType()) + if (oldLine.GetType() == newLineInfo.LineType) { - oldLine.UpdateActionItem(newLineInfo.List, newLineInfo.Item, _toolTip, ref currentTabIndex); + oldLine.UpdateActionItem(newLineInfo, _toolTip, ref currentTabIndex); updated = true; } else @@ -965,12 +873,13 @@ public void UpdateTasks(DesignerActionListCollection actionLists, DesignerAction if (!updated) { // Add the new controls + Line newLine = newLineInfo.CreateLine(_serviceProvider, this); + Debug.Assert(newLine.GetType() == newLineInfo.LineType); List newControlList = newLine.GetControls(); - Control[] controls = new Control[newControlList.Count]; - newControlList.CopyTo(controls); + Control[] controls = newControlList.ToArray(); Controls.AddRange(controls); - newLine.UpdateActionItem(newLineInfo.List, newLineInfo.Item, _toolTip, ref currentTabIndex); + newLine.UpdateActionItem(newLineInfo, _toolTip, ref currentTabIndex); _lines.Insert(i, newLine); } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPropertyItem.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPropertyItem.cs index 6f948363821..81c97216efd 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPropertyItem.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPropertyItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionService.cs index 6bd0fcfca5a..2b6c830674e 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionService.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Windows.Forms.Design; @@ -14,9 +11,9 @@ namespace System.ComponentModel.Design; public class DesignerActionService : IDisposable { private readonly Dictionary _designerActionLists; // this is how we store 'em. Syntax: key = object, value = DesignerActionListCollection - private DesignerActionListsChangedEventHandler _designerActionListsChanged; - private readonly IServiceProvider _serviceProvider; // standard service provider - private readonly ISelectionService _selSvc; // selection service + private DesignerActionListsChangedEventHandler? _designerActionListsChanged; + private readonly IServiceProvider? _serviceProvider; // standard service provider + private readonly ISelectionService? _selSvc; // selection service private readonly HashSet _componentToVerbsEventHookedUp; //Hashset of components which have events hooked up. // Guard against ReEntrant Code. The Infragistics TabControlDesigner, Sets the Commands Status when the Verbs property is accessed. This property is used in the OnVerbStatusChanged code here and hence causes recursion leading to Stack Overflow Exception. private bool _reEntrantCode; @@ -24,22 +21,20 @@ public class DesignerActionService : IDisposable /// /// Standard constructor. A Service Provider is necessary for monitoring selection and component changes. /// - public DesignerActionService(IServiceProvider serviceProvider) + public DesignerActionService(IServiceProvider? serviceProvider) { if (serviceProvider is not null) { _serviceProvider = serviceProvider; - if (serviceProvider.GetService(typeof(IDesignerHost)) is IDesignerHost host) - { - host.AddService(typeof(DesignerActionService), this); - } + IDesignerHost? host = serviceProvider.GetService(); + host?.AddService(typeof(DesignerActionService), this); if (serviceProvider.GetService(typeof(IComponentChangeService)) is IComponentChangeService cs) { cs.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); } - _selSvc = serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService; + _selSvc = serviceProvider.GetService(); } _designerActionLists = new(); @@ -49,7 +44,7 @@ public DesignerActionService(IServiceProvider serviceProvider) /// /// This event is thrown whenever a DesignerActionList is removed or added for any object. /// - public event DesignerActionListsChangedEventHandler DesignerActionListsChanged + public event DesignerActionListsChangedEventHandler? DesignerActionListsChanged { add => _designerActionListsChanged += value; remove => _designerActionListsChanged -= value; @@ -63,7 +58,7 @@ public void Add(IComponent comp, DesignerActionListCollection designerActionList ArgumentNullException.ThrowIfNull(comp); ArgumentNullException.ThrowIfNull(designerActionListCollection); - if (_designerActionLists.TryGetValue(comp, out DesignerActionListCollection dhlc)) + if (_designerActionLists.TryGetValue(comp, out DesignerActionListCollection? dhlc)) { dhlc.AddRange(designerActionListCollection); } @@ -101,7 +96,7 @@ public void Clear() _designerActionLists.Clear(); // Fire our DesignerActionsChanged event for each comp we just removed. - foreach (Component comp in compsRemoved) + foreach (IComponent comp in compsRemoved) { OnDesignerActionListsChanged(new(comp, DesignerActionListsChangedType.ActionListsRemoved, GetComponentActions(comp))); } @@ -128,10 +123,8 @@ protected virtual void Dispose(bool disposing) { if (disposing && _serviceProvider is not null) { - if (_serviceProvider.GetService(typeof(IDesignerHost)) is IDesignerHost host) - { - host.RemoveService(typeof(DesignerActionService)); - } + IDesignerHost? host = _serviceProvider.GetService(); + host?.RemoveService(typeof(DesignerActionService)); if (_serviceProvider.GetService(typeof(IComponentChangeService)) is IComponentChangeService cs) { @@ -172,68 +165,66 @@ protected virtual void GetComponentDesignerActions(IComponent component, Designe ArgumentNullException.ThrowIfNull(component); ArgumentNullException.ThrowIfNull(actionLists); - if (component.Site is IServiceContainer sc) + IServiceContainer? sc = component.Site as IServiceContainer; + if (sc.TryGetService(out DesignerCommandSet? dcs)) { - if (sc.GetService(typeof(DesignerCommandSet)) is DesignerCommandSet dcs) + DesignerActionListCollection? pullCollection = dcs.ActionLists; + if (pullCollection is not null) { - DesignerActionListCollection pullCollection = dcs.ActionLists; - if (pullCollection is not null) - { - actionLists.AddRange(pullCollection); - } + actionLists.AddRange(pullCollection); + } - // if we don't find any, add the verbs for this component there... - if (actionLists.Count == 0) + // if we don't find any, add the verbs for this component there... + if (actionLists.Count == 0) + { + DesignerVerbCollection? verbs = dcs.Verbs; + if (verbs is not null && verbs.Count != 0) { - DesignerVerbCollection verbs = dcs.Verbs; - if (verbs is not null && verbs.Count != 0) - { - List verbsArray = new(); - bool hookupEvents = _componentToVerbsEventHookedUp.Add(component); + List verbsArray = new(); + bool hookupEvents = _componentToVerbsEventHookedUp.Add(component); - foreach (DesignerVerb verb in verbs) + foreach (DesignerVerb verb in verbs) + { + if (verb is null) { - if (verb is null) - { - continue; - } - - if (hookupEvents) - { - verb.CommandChanged += new EventHandler(OnVerbStatusChanged); - } + continue; + } - if (verb.Enabled && verb.Visible) - { - verbsArray.Add(verb); - } + if (hookupEvents) + { + verb.CommandChanged += new EventHandler(OnVerbStatusChanged); } - if (verbsArray.Count != 0) + if (verb.Enabled && verb.Visible) { - actionLists.Add(new DesignerActionVerbList(verbsArray.ToArray())); + verbsArray.Add(verb); } } + + if (verbsArray.Count != 0) + { + actionLists.Add(new DesignerActionVerbList(verbsArray.ToArray())); + } } + } - // remove all the ones that are empty... ie GetSortedActionList returns nothing. we might waste some time doing this twice but don't have much of a choice here... the panel is not yet displayed and we want to know if a non empty panel is present... - // NOTE: We do this AFTER the verb check that way to disable auto verb upgrading you can just return an empty actionlist collection - if (pullCollection is not null) + // remove all the ones that are empty... ie GetSortedActionList returns nothing. we might waste some time doing this twice but don't have much of a choice here... the panel is not yet displayed and we want to know if a non empty panel is present... + // NOTE: We do this AFTER the verb check that way to disable auto verb upgrading you can just return an empty actionlist collection + if (pullCollection is not null) + { + foreach (DesignerActionList actionList in pullCollection) { - foreach (DesignerActionList actionList in pullCollection) + DesignerActionItemCollection? collection = actionList?.GetSortedActionItems(); + if (collection is null || collection.Count == 0) { - DesignerActionItemCollection collection = actionList?.GetSortedActionItems(); - if (collection is null || collection.Count == 0) - { - actionLists.Remove(actionList); - } + actionLists.Remove(actionList); } } } } } - private void OnVerbStatusChanged(object sender, EventArgs args) + private void OnVerbStatusChanged(object? sender, EventArgs args) { if (!_reEntrantCode) { @@ -244,12 +235,12 @@ private void OnVerbStatusChanged(object sender, EventArgs args) { if (comp.Site is IServiceContainer sc) { - DesignerCommandSet dcs = (DesignerCommandSet)sc.GetService(typeof(DesignerCommandSet)); - foreach (DesignerVerb verb in dcs.Verbs) + DesignerCommandSet dcs = (DesignerCommandSet)sc.GetService(typeof(DesignerCommandSet))!; + foreach (DesignerVerb verb in dcs.Verbs!) { if (verb == sender) { - DesignerActionUIService dapUISvc = (DesignerActionUIService)sc.GetService(typeof(DesignerActionUIService)); + DesignerActionUIService? dapUISvc = sc.GetService(); dapUISvc?.Refresh(comp); // we need to refresh, a verb on the current panel has changed its state } } @@ -268,13 +259,13 @@ protected virtual void GetComponentServiceActions(IComponent component, Designer ArgumentNullException.ThrowIfNull(component); ArgumentNullException.ThrowIfNull(actionLists); - if (_designerActionLists.TryGetValue(component, out DesignerActionListCollection pushCollection)) + if (_designerActionLists.TryGetValue(component, out DesignerActionListCollection? pushCollection)) { actionLists.AddRange(pushCollection); // remove all the ones that are empty... ie GetSortedActionList returns nothing. we might waste some time doing this twice but don't have much of a choice here... the panel is not yet displayed and we want to know if a non empty panel is present... foreach (DesignerActionList actionList in pushCollection) { - DesignerActionItemCollection collection = actionList?.GetSortedActionItems(); + DesignerActionItemCollection? collection = actionList?.GetSortedActionItems(); if (collection is null || collection.Count == 0) { actionLists.Remove(actionList); @@ -286,9 +277,9 @@ protected virtual void GetComponentServiceActions(IComponent component, Designer /// /// We hook the OnComponentRemoved event so we can clean up all associated actions. /// - private void OnComponentRemoved(object source, ComponentEventArgs ce) + private void OnComponentRemoved(object? source, ComponentEventArgs ce) { - Remove(ce.Component); + Remove(ce.Component!); } /// @@ -322,7 +313,7 @@ public void Remove(DesignerActionList actionList) //find the associated component foreach (IComponent comp in _designerActionLists.Keys) { - if (_designerActionLists.TryGetValue(comp, out DesignerActionListCollection dacl) && dacl.Contains(actionList)) + if (_designerActionLists.TryGetValue(comp, out DesignerActionListCollection? dacl) && dacl.Contains(actionList)) { Remove(comp, actionList); break; @@ -338,7 +329,7 @@ public void Remove(IComponent comp, DesignerActionList actionList) ArgumentNullException.ThrowIfNull(comp); ArgumentNullException.ThrowIfNull(actionList); - if (!_designerActionLists.TryGetValue(comp, out DesignerActionListCollection actionLists) || !actionLists.Contains(actionList)) + if (!_designerActionLists.TryGetValue(comp, out DesignerActionListCollection? actionLists) || !actionLists.Contains(actionList)) { return; } @@ -364,20 +355,18 @@ public void Remove(IComponent comp, DesignerActionList actionList) } } - internal event DesignerActionUIStateChangeEventHandler DesignerActionUIStateChange + internal event DesignerActionUIStateChangeEventHandler? DesignerActionUIStateChange { add { - DesignerActionUIService dapUISvc = (DesignerActionUIService)_serviceProvider.GetService(typeof(DesignerActionUIService)); - if (dapUISvc is not null) + if (_serviceProvider.TryGetService(out DesignerActionUIService? dapUISvc)) { dapUISvc.DesignerActionUIStateChange += value; } } remove { - DesignerActionUIService dapUISvc = (DesignerActionUIService)_serviceProvider.GetService(typeof(DesignerActionUIService)); - if (dapUISvc is not null) + if (_serviceProvider.TryGetService(out DesignerActionUIService? dapUISvc)) { dapUISvc.DesignerActionUIStateChange -= value; } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionTextItem.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionTextItem.cs index df6e7e44d6c..a59b998399a 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionTextItem.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionTextItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.DesignerActionToolStripDropDown.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.DesignerActionToolStripDropDown.cs index 28eb3d6d1e9..15045e2b49c 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.DesignerActionToolStripDropDown.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.DesignerActionToolStripDropDown.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.cs index 6fa1a5b7856..df704d766d3 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Drawing; using System.Windows.Forms; @@ -24,7 +21,7 @@ namespace System.ComponentModel.Design; /// internal partial class DesignerActionUI : IDisposable { - private static readonly TraceSwitch s_designerActionPanelTraceSwitch = new TraceSwitch("DesignerActionPanelTrace", "DesignerActionPanel tracing"); + private static readonly TraceSwitch s_designerActionPanelTraceSwitch = new("DesignerActionPanelTrace", "DesignerActionPanel tracing"); private Adorner _designerActionAdorner; //used to add designeraction-related glyphs private IServiceProvider _serviceProvider; //standard service provider @@ -32,29 +29,27 @@ internal partial class DesignerActionUI : IDisposable private DesignerActionService _designerActionService; //this is how all designeractions will be managed private DesignerActionUIService _designerActionUIService; //this is how all designeractions UI elements will be managed private BehaviorService _behaviorService; //this is how all of our UI is implemented (glyphs, behaviors, etc...) - private readonly IMenuCommandService _menuCommandService; - private DesignerActionKeyboardBehavior _dapkb; //out keyboard behavior + private DesignerActionKeyboardBehavior? _dapkb; //out keyboard behavior private readonly Dictionary _componentToGlyph; //used for quick reference between components and our glyphs private Control _marshalingControl; //used to invoke events on our main gui thread - private IComponent _lastPanelComponent; + private IComponent? _lastPanelComponent; - private readonly IUIService _uiService; - private readonly IWin32Window _mainParentWindow; - internal DesignerActionToolStripDropDown designerActionHost; + private readonly IWin32Window? _mainParentWindow; + internal DesignerActionToolStripDropDown? designerActionHost; - private readonly MenuCommand _cmdShowDesignerActions; //used to respond to the Alt+Shift+F10 command + private readonly MenuCommand? _cmdShowDesignerActions; //used to respond to the Alt+Shift+F10 command private bool _inTransaction; - private IComponent _relatedComponentTransaction; - private DesignerActionGlyph _relatedGlyphTransaction; + private IComponent? _relatedComponentTransaction; + private DesignerActionGlyph? _relatedGlyphTransaction; private readonly bool _disposeActionService; private readonly bool _disposeActionUIService; private bool _cancelClose; private delegate void ActionChangedEventHandler(object sender, DesignerActionListsChangedEventArgs e); #if DEBUG - internal static readonly TraceSwitch DropDownVisibilityDebug = new TraceSwitch("DropDownVisibilityDebug", "Debug ToolStrip Selection code"); + internal static readonly TraceSwitch DropDownVisibilityDebug = new("DropDownVisibilityDebug", "Debug ToolStrip Selection code"); #else - internal static readonly TraceSwitch DropDownVisibilityDebug; + internal static readonly TraceSwitch? DropDownVisibilityDebug; #endif /// /// Constructor that takes a service provider. This is needed to establish references to the BehaviorService and SelectionService, as well as spin-up the DesignerActionService. @@ -63,9 +58,9 @@ public DesignerActionUI(IServiceProvider serviceProvider, Adorner containerAdorn { _serviceProvider = serviceProvider; _designerActionAdorner = containerAdorner; - _behaviorService = (BehaviorService)serviceProvider.GetService(typeof(BehaviorService)); - _menuCommandService = (IMenuCommandService)serviceProvider.GetService(typeof(IMenuCommandService)); - _selSvc = (ISelectionService)serviceProvider.GetService(typeof(ISelectionService)); + _behaviorService = serviceProvider.GetService()!; + IMenuCommandService? menuCommandService = serviceProvider.GetService(); + _selSvc = serviceProvider.GetService()!; if (_behaviorService is null || _selSvc is null) { Debug.Fail("Either BehaviorService or ISelectionService is null, cannot continue."); @@ -73,16 +68,22 @@ public DesignerActionUI(IServiceProvider serviceProvider, Adorner containerAdorn } //query for our DesignerActionService - _designerActionService = (DesignerActionService)serviceProvider.GetService(typeof(DesignerActionService)); - if (_designerActionService is null) + if (serviceProvider.GetService() is { } designerActionService) + { + _designerActionService = designerActionService; + } + else { //start the service _designerActionService = new DesignerActionService(serviceProvider); _disposeActionService = true; } - _designerActionUIService = (DesignerActionUIService)serviceProvider.GetService(typeof(DesignerActionUIService)); - if (_designerActionUIService is null) + if (serviceProvider.GetService() is { } designerActionUIService) + { + _designerActionUIService = designerActionUIService; + } + else { _designerActionUIService = new DesignerActionUIService(serviceProvider); _disposeActionUIService = true; @@ -92,22 +93,22 @@ public DesignerActionUI(IServiceProvider serviceProvider, Adorner containerAdorn _designerActionService.DesignerActionListsChanged += new DesignerActionListsChangedEventHandler(OnDesignerActionsChanged); _lastPanelComponent = null; - IComponentChangeService cs = (IComponentChangeService)serviceProvider.GetService(typeof(IComponentChangeService)); + IComponentChangeService? cs = serviceProvider.GetService(); if (cs is not null) { cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); } - if (_menuCommandService is not null) + if (menuCommandService is not null) { _cmdShowDesignerActions = new MenuCommand(new EventHandler(OnKeyShowDesignerActions), MenuCommands.KeyInvokeSmartTag); - _menuCommandService.AddCommand(_cmdShowDesignerActions); + menuCommandService.AddCommand(_cmdShowDesignerActions); } - _uiService = (IUIService)serviceProvider.GetService(typeof(IUIService)); - if (_uiService is not null) + IUIService? uiService = serviceProvider.GetService(); + if (uiService is not null) { - _mainParentWindow = _uiService.GetDialogOwnerWindow(); + _mainParentWindow = uiService.GetDialogOwnerWindow(); } _componentToGlyph = new(); @@ -124,12 +125,12 @@ public void Dispose() if (_marshalingControl is not null) { _marshalingControl.Dispose(); - _marshalingControl = null; + _marshalingControl = null!; } if (_serviceProvider is not null) { - IComponentChangeService cs = (IComponentChangeService)_serviceProvider.GetService(typeof(IComponentChangeService)); + IComponentChangeService? cs = _serviceProvider.GetService(); if (cs is not null) { cs.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged); @@ -137,14 +138,14 @@ public void Dispose() if (_cmdShowDesignerActions is not null) { - IMenuCommandService mcs = (IMenuCommandService)_serviceProvider.GetService(typeof(IMenuCommandService)); + IMenuCommandService? mcs = _serviceProvider.GetService(); mcs?.RemoveCommand(_cmdShowDesignerActions); } } - _serviceProvider = null; - _behaviorService = null; - _selSvc = null; + _serviceProvider = null!; + _behaviorService = null!; + _selSvc = null!; if (_designerActionService is not null) { _designerActionService.DesignerActionListsChanged -= new DesignerActionListsChangedEventHandler(OnDesignerActionsChanged); @@ -154,7 +155,7 @@ public void Dispose() } } - _designerActionService = null; + _designerActionService = null!; if (_designerActionUIService is not null) { @@ -165,19 +166,19 @@ public void Dispose() } } - _designerActionUIService = null; - _designerActionAdorner = null; + _designerActionUIService = null!; + _designerActionAdorner = null!; } - public DesignerActionGlyph GetDesignerActionGlyph(IComponent comp) + public DesignerActionGlyph? GetDesignerActionGlyph(IComponent comp) { return GetDesignerActionGlyph(comp, null); } - internal DesignerActionGlyph GetDesignerActionGlyph(IComponent comp, DesignerActionListCollection dalColl) + internal DesignerActionGlyph? GetDesignerActionGlyph(IComponent comp, DesignerActionListCollection? dalColl) { // check this component origin, this class or is it readonly because inherited... - InheritanceAttribute attribute = (InheritanceAttribute)TypeDescriptor.GetAttributes(comp)[typeof(InheritanceAttribute)]; + InheritanceAttribute? attribute = (InheritanceAttribute?)TypeDescriptor.GetAttributes(comp)[typeof(InheritanceAttribute)]; if (attribute == InheritanceAttribute.InheritedReadOnly) { // only do it if we can change the control... return null; @@ -188,8 +189,7 @@ internal DesignerActionGlyph GetDesignerActionGlyph(IComponent comp, DesignerAct if (dalColl is not null && dalColl.Count > 0) { - DesignerActionGlyph dag = null; - if (!_componentToGlyph.ContainsKey(comp)) + if (!_componentToGlyph.TryGetValue(comp, out DesignerActionGlyph? dag)) { DesignerActionBehavior dab = new DesignerActionBehavior(_serviceProvider, comp, dalColl, this); @@ -212,23 +212,17 @@ internal DesignerActionGlyph GetDesignerActionGlyph(IComponent comp, DesignerAct //if the related comp is a control, then this shortcut will be off its bounds dag ??= new DesignerActionGlyph(dab, _designerActionAdorner); - if (dag is not null) - { - //store off this relationship - _componentToGlyph[comp] = dag; - } + //store off this relationship + _componentToGlyph[comp] = dag; } else { - if (_componentToGlyph.TryGetValue(comp, out dag)) + if (dag.Behavior is DesignerActionBehavior behavior) { - if (dag.Behavior is DesignerActionBehavior behavior) - { - behavior.ActionLists = dalColl; - } - - dag.Invalidate(); // need to invalidate here too, someone could have called refresh too soon, causing the glyph to get created in the wrong place + behavior.ActionLists = dalColl; } + + dag.Invalidate(); // need to invalidate here too, someone could have called refresh too soon, causing the glyph to get created in the wrong place } return dag; @@ -244,7 +238,7 @@ internal DesignerActionGlyph GetDesignerActionGlyph(IComponent comp, DesignerAct /// /// We monitor this event so we can update smart tag locations when controls move. /// - private void OnComponentChanged(object source, ComponentChangedEventArgs ce) + private void OnComponentChanged(object? source, ComponentChangedEventArgs ce) { //validate event args if (ce.Component is null || ce.Member is null || !IsDesignerActionPanelVisible) @@ -259,7 +253,7 @@ private void OnComponentChanged(object source, ComponentChangedEventArgs ce) } //if something changed on a component we have actions associated with then invalidate all (repaint & reposition) - if (_componentToGlyph.TryGetValue(ce.Component, out DesignerActionGlyph glyph)) + if (_componentToGlyph.TryGetValue(ce.Component, out DesignerActionGlyph? glyph)) { glyph.Invalidate(); @@ -278,7 +272,7 @@ private void OnComponentChanged(object source, ComponentChangedEventArgs ce) } } - private void RecreatePanel(IComponent comp) + private void RecreatePanel(IComponent? comp) { if (_inTransaction || comp != _selSvc.PrimarySelection) { // we only ever need to do that when the comp is the primary selection @@ -303,16 +297,16 @@ private void RecreatePanel(IComponent comp) } } - RecreateInternal(comp); + RecreateInternal(comp!); } - private void DesignerTransactionClosed(object sender, DesignerTransactionCloseEventArgs e) + private void DesignerTransactionClosed(object? sender, DesignerTransactionCloseEventArgs e) { if (e.LastTransaction && _relatedComponentTransaction is not null) { // surprise surprise we can get multiple even with e.LastTransaction set to true, even though we unhook here this is because the list on which we enumerate (the event handler list) is copied before it's enumerated on which means that if the undo engine for example creates and commit a transaction during the OnCancel of another completed transaction we will get this twice. So we have to check also for relatedComponentTransaction is not null _inTransaction = false; - IDesignerHost host = _serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost; + IDesignerHost host = _serviceProvider.GetService()!; host.TransactionClosed -= new DesignerTransactionCloseEventHandler(DesignerTransactionClosed); RecreateInternal(_relatedComponentTransaction); _relatedComponentTransaction = null; @@ -321,7 +315,7 @@ private void DesignerTransactionClosed(object sender, DesignerTransactionCloseEv private void RecreateInternal(IComponent comp) { - DesignerActionGlyph glyph = GetDesignerActionGlyph(comp); + DesignerActionGlyph? glyph = GetDesignerActionGlyph(comp); if (glyph is not null) { VerifyGlyphIsInAdorner(glyph); @@ -336,21 +330,18 @@ private void RecreatePanel(Glyph glyphWithPanelToRegen) // we don't want to do anything if the panel is not visible if (!IsDesignerActionPanelVisible) { - Debug.WriteLineIf(DropDownVisibilityDebug.TraceVerbose, "[DesignerActionUI.RecreatePanel] panel is not visible, bail"); + DropDownVisibilityDebug.TraceVerbose("[DesignerActionUI.RecreatePanel] panel is not visible, bail"); return; } //recreate a designeraction panel - if (glyphWithPanelToRegen is not null) + if (glyphWithPanelToRegen.Behavior is DesignerActionBehavior behaviorWithPanelToRegen) { - if (glyphWithPanelToRegen.Behavior is DesignerActionBehavior behaviorWithPanelToRegen) - { - Debug.Assert(behaviorWithPanelToRegen.RelatedComponent is not null, "could not find related component for this refresh"); - DesignerActionPanel dap = designerActionHost.CurrentPanel; // WE DO NOT RECREATE THE WHOLE THING / WE UPDATE THE TASKS - should flicker less - dap.UpdateTasks(behaviorWithPanelToRegen.ActionLists, new DesignerActionListCollection(), string.Format(SR.DesignerActionPanel_DefaultPanelTitle, - behaviorWithPanelToRegen.RelatedComponent.GetType().Name), null); - designerActionHost.UpdateContainerSize(); - } + Debug.Assert(behaviorWithPanelToRegen.RelatedComponent is not null, "could not find related component for this refresh"); + DesignerActionPanel dap = designerActionHost.CurrentPanel; // WE DO NOT RECREATE THE WHOLE THING / WE UPDATE THE TASKS - should flicker less + dap.UpdateTasks(behaviorWithPanelToRegen.ActionLists, new DesignerActionListCollection(), string.Format(SR.DesignerActionPanel_DefaultPanelTitle, + behaviorWithPanelToRegen.RelatedComponent.GetType().Name), null); + designerActionHost.UpdateContainerSize(); } } @@ -358,7 +349,7 @@ private void VerifyGlyphIsInAdorner(DesignerActionGlyph glyph) { if (glyph.IsInComponentTray) { - ComponentTray compTray = _serviceProvider.GetService(typeof(ComponentTray)) as ComponentTray; + ComponentTray compTray = _serviceProvider.GetService()!; if (compTray.SelectionGlyphs is not null && !compTray.SelectionGlyphs.Contains(glyph)) { compTray.SelectionGlyphs.Insert(0, glyph); @@ -366,7 +357,7 @@ private void VerifyGlyphIsInAdorner(DesignerActionGlyph glyph) } else { - if (_designerActionAdorner is not null && _designerActionAdorner.Glyphs is not null && !_designerActionAdorner.Glyphs.Contains(glyph)) + if (_designerActionAdorner?.Glyphs is not null && !_designerActionAdorner.Glyphs.Contains(glyph)) { _designerActionAdorner.Glyphs.Insert(0, glyph); } @@ -389,11 +380,11 @@ private void OnDesignerActionsChanged(object sender, DesignerActionListsChangedE private void OnDesignerActionUIStateChange(object sender, DesignerActionUIStateChangeEventArgs e) { - IComponent comp = e.RelatedObject as IComponent; + IComponent? comp = e.RelatedObject as IComponent; Debug.Assert(comp is not null || e.ChangeType == DesignerActionUIStateChangeType.Hide, "related object is not an IComponent, something is wrong here..."); if (comp is not null) { - DesignerActionGlyph relatedGlyph = GetDesignerActionGlyph(comp); + DesignerActionGlyph? relatedGlyph = GetDesignerActionGlyph(comp); if (relatedGlyph is not null) { if (e.ChangeType == DesignerActionUIStateChangeType.Show) @@ -413,7 +404,7 @@ private void OnDesignerActionUIStateChange(object sender, DesignerActionUIStateC else if (e.ChangeType == DesignerActionUIStateChangeType.Refresh) { relatedGlyph.Invalidate(); - RecreatePanel((IComponent)e.RelatedObject); + RecreatePanel((IComponent?)e.RelatedObject); } } } @@ -431,7 +422,7 @@ private void OnDesignerActionUIStateChange(object sender, DesignerActionUIStateC /// private void OnInvokedDesignerActionChanged(object sender, DesignerActionListsChangedEventArgs e) { - DesignerActionGlyph g = null; + DesignerActionGlyph? g = null; if (e.ChangeType == DesignerActionListsChangedType.ActionListsAdded) { if (e.RelatedObject is not IComponent relatedComponent) @@ -440,7 +431,7 @@ private void OnInvokedDesignerActionChanged(object sender, DesignerActionListsCh return; } - IComponent primSel = _selSvc.PrimarySelection as IComponent; + IComponent? primSel = _selSvc.PrimarySelection as IComponent; if (primSel == e.RelatedObject) { g = GetDesignerActionGlyph(relatedComponent, e.ActionLists); @@ -455,7 +446,7 @@ private void OnInvokedDesignerActionChanged(object sender, DesignerActionListsCh } } - if (e.ChangeType == DesignerActionListsChangedType.ActionListsRemoved && e.ActionLists.Count == 0) + if (e.ChangeType == DesignerActionListsChangedType.ActionListsRemoved && e.ActionLists!.Count == 0) { //only remove our glyph if there are no more DesignerActions associated with it. RemoveActionGlyph(e.RelatedObject); @@ -470,7 +461,7 @@ private void OnInvokedDesignerActionChanged(object sender, DesignerActionListsCh /// /// Called when our KeyShowDesignerActions menu command is fired (a.k.a. Alt+Shift+F10) - we will find the primary selection, see if it has designer actions, and if so - show the menu. /// - private void OnKeyShowDesignerActions(object sender, EventArgs e) + private void OnKeyShowDesignerActions(object? sender, EventArgs e) { ShowDesignerActionPanelForPrimarySelection(); } @@ -484,28 +475,25 @@ internal bool ShowDesignerActionPanelForPrimarySelection() return false; } - object primarySelection = _selSvc.PrimarySelection; + object? primarySelection = _selSvc.PrimarySelection; //verify that we have obtained a valid component with designer actions - if (primarySelection is null || !_componentToGlyph.TryGetValue(primarySelection, out DesignerActionGlyph glyph)) + if (primarySelection is null || !_componentToGlyph.TryGetValue(primarySelection, out DesignerActionGlyph? glyph)) { return false; } - if (glyph is not null && glyph.Behavior is DesignerActionBehavior) + if (glyph.Behavior is DesignerActionBehavior behavior) + // show the menu { - // show the menu - if (glyph.Behavior is DesignerActionBehavior behavior) + if (!IsDesignerActionPanelVisible) { - if (!IsDesignerActionPanelVisible) - { - behavior.ShowUI(glyph); - return true; - } - else - { - behavior.HideUI(); - return false; - } + behavior.ShowUI(glyph); + return true; + } + else + { + behavior.HideUI(); + return false; } } @@ -515,7 +503,7 @@ internal bool ShowDesignerActionPanelForPrimarySelection() /// /// When all the DesignerActions have been removed for a particular object, we remove any UI (glyphs) that we may have been managing. /// - internal void RemoveActionGlyph(object relatedObject) + internal void RemoveActionGlyph(object? relatedObject) { if (relatedObject is null) { @@ -527,16 +515,13 @@ internal void RemoveActionGlyph(object relatedObject) HideDesignerActionPanel(); } - if (!_componentToGlyph.TryGetValue(relatedObject, out DesignerActionGlyph glyph)) + if (!_componentToGlyph.TryGetValue(relatedObject, out DesignerActionGlyph? glyph)) { return; } // Check ComponentTray first - if (_serviceProvider.GetService(typeof(ComponentTray)) is ComponentTray compTray && compTray.SelectionGlyphs is not null) - { - compTray.SelectionGlyphs.Remove(glyph); - } + _serviceProvider.GetService()?.SelectionGlyphs?.Remove(glyph); _designerActionAdorner.Glyphs.Remove(glyph); _componentToGlyph.Remove(relatedObject); @@ -549,12 +534,11 @@ internal void RemoveActionGlyph(object relatedObject) } } - private void InvalidateGlyphOnLastTransaction(object sender, DesignerTransactionCloseEventArgs e) + private void InvalidateGlyphOnLastTransaction(object? sender, DesignerTransactionCloseEventArgs e) { if (e.LastTransaction) { - IDesignerHost host = (_serviceProvider is not null) ? _serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost : null; - if (host is not null) + if (_serviceProvider.TryGetService(out IDesignerHost? host)) { host.TransactionClosed -= new DesignerTransactionCloseEventHandler(InvalidateGlyphOnLastTransaction); } @@ -573,40 +557,41 @@ internal void HideDesignerActionPanel() } } + [MemberNotNullWhen(true, nameof(designerActionHost))] internal bool IsDesignerActionPanelVisible { get => (designerActionHost is not null && designerActionHost.Visible); } - internal IComponent LastPanelComponent + internal IComponent? LastPanelComponent { get => (IsDesignerActionPanelVisible ? _lastPanelComponent : null); } - private void ToolStripDropDown_Closing(object sender, ToolStripDropDownClosingEventArgs e) + private void ToolStripDropDown_Closing(object? sender, ToolStripDropDownClosingEventArgs e) { if (_cancelClose || e.Cancel) { e.Cancel = true; - Debug.WriteLineIf(DropDownVisibilityDebug.TraceVerbose, "[DesignerActionUI.toolStripDropDown_Closing] cancelClose true, bail"); + DropDownVisibilityDebug.TraceVerbose("[DesignerActionUI.toolStripDropDown_Closing] cancelClose true, bail"); return; } if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked) { e.Cancel = true; - Debug.WriteLineIf(DropDownVisibilityDebug.TraceVerbose, $"[DesignerActionUI.toolStripDropDown_Closing] ItemClicked: e.Cancel set to: {e.Cancel}"); + DropDownVisibilityDebug.TraceVerbose($"[DesignerActionUI.toolStripDropDown_Closing] ItemClicked: e.Cancel set to: {e.Cancel}"); } if (e.CloseReason == ToolStripDropDownCloseReason.Keyboard) { e.Cancel = false; - Debug.WriteLineIf(DropDownVisibilityDebug.TraceVerbose, $"[DesignerActionUI.toolStripDropDown_Closing] Keyboard: e.Cancel set to: {e.Cancel}"); + DropDownVisibilityDebug.TraceVerbose($"[DesignerActionUI.toolStripDropDown_Closing] Keyboard: e.Cancel set to: {e.Cancel}"); } if (e.Cancel == false) { // we WILL disappear - Debug.WriteLineIf(DropDownVisibilityDebug.TraceVerbose, "[DesignerActionUI.toolStripDropDown_Closing] Closing..."); + DropDownVisibilityDebug.TraceVerbose("[DesignerActionUI.toolStripDropDown_Closing] Closing..."); Debug.Assert(_lastPanelComponent is not null, "last panel component should not be null here... " + "(except if you're currently debugging VS where deactivation messages in the middle of the pump can mess up everything...)"); if (_lastPanelComponent is null) @@ -616,12 +601,12 @@ private void ToolStripDropDown_Closing(object sender, ToolStripDropDownClosingEv // if we're actually closing get the coordinate of the last message, the one causing us to close, is it within the glyph coordinate. if it is that mean that someone just clicked back from the panel, on VS, but ON THE GLYPH, that means that he actually wants to close it. The activation change is going to do that for us but we should NOT reopen right away because he clicked on the glyph... this code is here to prevent this... Point point = DesignerUtils.LastCursorPoint; - if (_componentToGlyph.TryGetValue(_lastPanelComponent, out DesignerActionGlyph currentGlyph)) + if (_componentToGlyph.TryGetValue(_lastPanelComponent, out DesignerActionGlyph? currentGlyph)) { Point glyphCoord = GetGlyphLocationScreenCoord(_lastPanelComponent, currentGlyph); if ((new Rectangle(glyphCoord, new Size(currentGlyph.Bounds.Width, currentGlyph.Bounds.Height))).Contains(point)) { - DesignerActionBehavior behavior = currentGlyph.Behavior as DesignerActionBehavior; + DesignerActionBehavior behavior = (DesignerActionBehavior)currentGlyph.Behavior!; behavior.IgnoreNextMouseUp = true; } @@ -631,12 +616,12 @@ private void ToolStripDropDown_Closing(object sender, ToolStripDropDownClosingEv _lastPanelComponent = null; // panel is going away, pop the behavior that's on the stack... Debug.Assert(_dapkb is not null, "why is dapkb null?"); - Behavior popBehavior = _behaviorService.PopBehavior(_dapkb); + Behavior popBehavior = _behaviorService.PopBehavior(_dapkb!); Debug.Assert(popBehavior is DesignerActionKeyboardBehavior, "behavior returned is of the wrong kind?"); } } - internal Point UpdateDAPLocation(IComponent component, DesignerActionGlyph glyph) + internal Point UpdateDAPLocation(IComponent? component, DesignerActionGlyph? glyph) { component ??= _lastPanelComponent; @@ -675,14 +660,14 @@ private Point GetGlyphLocationScreenCoord(IComponent relatedComponent, Glyph gly } //ISSUE: we can't have this special cased here - we should find a more generic approach to solving this problem - else if (relatedComponent is ToolStripItem) + else if (relatedComponent is ToolStripItem item) { - if (relatedComponent is ToolStripItem item && item.Owner is not null) + if (item.Owner is not null) { glyphLocationScreenCoord = _behaviorService.AdornerWindowPointToScreen(glyph.Bounds.Location); } } - else if (relatedComponent is IComponent) + else { if (_serviceProvider.GetService(typeof(ComponentTray)) is ComponentTray compTray) { @@ -724,7 +709,7 @@ internal void ShowDesignerActionPanel(IComponent relatedComponent, DesignerActio if (_mainParentWindow is not null && _mainParentWindow.Handle != IntPtr.Zero) { Debug.WriteLineIf(s_designerActionPanelTraceSwitch.TraceVerbose, "Assigning owner to mainParentWindow"); - Debug.WriteLineIf(DropDownVisibilityDebug.TraceVerbose, "Assigning owner to mainParentWindow"); + DropDownVisibilityDebug.TraceVerbose("Assigning owner to mainParentWindow"); PInvoke.SetWindowLong( designerActionHost, WINDOW_LONG_PTR_INDEX.GWL_HWNDPARENT, @@ -745,7 +730,7 @@ internal void ShowDesignerActionPanel(IComponent relatedComponent, DesignerActio } } - private void OnShowComplete(object sender, EventArgs e) + private void OnShowComplete(object? sender, EventArgs e) { _cancelClose = false; // force the panel to be the active window - for some reason someone else could have forced VS to become active for real while we were ignoring close. This might be bad cause we'd be in a bad state. diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIService.cs index e6e7e5dc4c7..25ef75352de 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIService.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Windows.Forms.Design.Behavior; @@ -10,9 +7,9 @@ namespace System.ComponentModel.Design; public sealed class DesignerActionUIService : IDisposable { - private DesignerActionUIStateChangeEventHandler _designerActionUIStateChangedEventHandler; - private readonly IServiceProvider _serviceProvider; //standard service provider - private readonly DesignerActionService _designerActionService; + private DesignerActionUIStateChangeEventHandler? _designerActionUIStateChangedEventHandler; + private readonly IServiceProvider? _serviceProvider; //standard service provider + private readonly DesignerActionService? _designerActionService; internal DesignerActionUIService(IServiceProvider serviceProvider) { @@ -20,9 +17,9 @@ internal DesignerActionUIService(IServiceProvider serviceProvider) if (serviceProvider is not null) { _serviceProvider = serviceProvider; - IDesignerHost host = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost)); + IDesignerHost host = serviceProvider.GetService()!; host.AddService(typeof(DesignerActionUIService), this); - _designerActionService = serviceProvider.GetService(typeof(DesignerActionService)) as DesignerActionService; + _designerActionService = serviceProvider.GetService(); Debug.Assert(_designerActionService is not null, "we should have created and registered the DAService first"); } } @@ -34,7 +31,7 @@ public void Dispose() { if (_serviceProvider is not null) { - IDesignerHost host = (IDesignerHost)_serviceProvider.GetService(typeof(IDesignerHost)); + IDesignerHost? host = _serviceProvider.GetService(); host?.RemoveService(typeof(DesignerActionUIService)); } } @@ -42,18 +39,18 @@ public void Dispose() /// /// This event is thrown whenever a request is made to show/hide the UI. /// - public event DesignerActionUIStateChangeEventHandler DesignerActionUIStateChange + public event DesignerActionUIStateChangeEventHandler? DesignerActionUIStateChange { add => _designerActionUIStateChangedEventHandler += value; remove => _designerActionUIStateChangedEventHandler -= value; } - public void HideUI(IComponent component) + public void HideUI(IComponent? component) { OnDesignerActionUIStateChange(new DesignerActionUIStateChangeEventArgs(component, DesignerActionUIStateChangeType.Hide)); } - public void ShowUI(IComponent component) + public void ShowUI(IComponent? component) { OnDesignerActionUIStateChange(new DesignerActionUIStateChangeEventArgs(component, DesignerActionUIStateChangeType.Show)); } @@ -61,7 +58,7 @@ public void ShowUI(IComponent component) /// /// Refreshes the designer action glyph as well as designer action panels. /// - public void Refresh(IComponent component) + public void Refresh(IComponent? component) { OnDesignerActionUIStateChange(new DesignerActionUIStateChangeEventArgs(component, DesignerActionUIStateChangeType.Refresh)); } @@ -77,29 +74,23 @@ private void OnDesignerActionUIStateChange(DesignerActionUIStateChangeEventArgs public bool ShouldAutoShow(IComponent component) { // Check the designer options... - if (_serviceProvider is not null) + if (_serviceProvider.TryGetService(out DesignerOptionService? opts)) { - if (_serviceProvider.GetService(typeof(DesignerOptionService)) is DesignerOptionService opts) + PropertyDescriptor? p = opts.Options.Properties["ObjectBoundSmartTagAutoShow"]; + if (p is not null && p.TryGetValue(null, out bool isObjectBoundSmartTagAutoShow) && !isObjectBoundSmartTagAutoShow) { - PropertyDescriptor p = opts.Options.Properties["ObjectBoundSmartTagAutoShow"]; - if (p is not null && p.PropertyType == typeof(bool) && !(bool)p.GetValue(null)) - { - return false; - } + return false; } } - if (_designerActionService is not null) + DesignerActionListCollection? coll = _designerActionService?.GetComponentActions(component); + if (coll is not null && coll.Count > 0) { - DesignerActionListCollection coll = _designerActionService.GetComponentActions(component); - if (coll is not null && coll.Count > 0) + for (int i = 0; i < coll.Count; i++) { - for (int i = 0; i < coll.Count; i++) + if (coll[i]!.AutoShow) { - if (coll[i].AutoShow) - { - return true; - } + return true; } } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIStateChangeEventArgs.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIStateChangeEventArgs.cs index 3012cd18f45..037d248b3db 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIStateChangeEventArgs.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIStateChangeEventArgs.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable namespace System.ComponentModel.Design; @@ -14,7 +11,7 @@ public class DesignerActionUIStateChangeEventArgs : EventArgs /// /// Constructor that requires the object in question, the type of change and the remaining actionlists left for the object on the related object. /// - public DesignerActionUIStateChangeEventArgs(object relatedObject, DesignerActionUIStateChangeType changeType) + public DesignerActionUIStateChangeEventArgs(object? relatedObject, DesignerActionUIStateChangeType changeType) { RelatedObject = relatedObject; ChangeType = changeType; @@ -23,7 +20,7 @@ public DesignerActionUIStateChangeEventArgs(object relatedObject, DesignerAction /// /// The object this change is related to. /// - public object RelatedObject { get; } + public object? RelatedObject { get; } /// /// The type of changed that caused the related event to be thrown. diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIStateChangeEventHandler.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIStateChangeEventHandler.cs index 97db42d14d2..73dd88ee152 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIStateChangeEventHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIStateChangeEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIStateChangeType.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIStateChangeType.cs index af2cc5edada..7f810ee824c 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIStateChangeType.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUIStateChangeType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerCommandSet.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerCommandSet.cs index 033e23670cf..e92e0a56828 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerCommandSet.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerCommandSet.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerEventService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerEventService.cs index ca0d423765f..7865a9360c2 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerEventService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerEventService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; @@ -12,10 +11,10 @@ namespace System.ComponentModel.Design; /// internal sealed class DesignerEventService : IDesignerEventService { - private static readonly object s_eventActiveDesignerChanged = new object(); - private static readonly object s_eventDesignerCreated = new object(); - private static readonly object s_eventDesignerDisposed = new object(); - private static readonly object s_eventSelectionChanged = new object(); + private static readonly object s_eventActiveDesignerChanged = new(); + private static readonly object s_eventDesignerCreated = new(); + private static readonly object s_eventDesignerDisposed = new(); + private static readonly object s_eventSelectionChanged = new(); private List? _designerList; // read write list used as data for the collection private DesignerCollection? _designerCollection; // public read only view of the above list diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.DesignerHostTransaction.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.DesignerHostTransaction.cs index bdaa170dce4..0d878420241 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.DesignerHostTransaction.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.DesignerHostTransaction.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.Site.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.Site.cs index 457b391be42..8da9510bfd9 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.Site.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.Site.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.cs index 9dedba779a3..1f0ea96ac31 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Collections.Specialized; @@ -23,22 +22,22 @@ internal sealed partial class DesignerHost : Container, IDesignerLoaderHost2, ID private static readonly Type[] s_defaultServices = new Type[] { typeof(IDesignerHost), typeof(IContainer), typeof(IComponentChangeService), typeof(IDesignerLoaderHost2) }; // IDesignerHost events - private static readonly object s_eventActivated = new object(); // Designer has been activated - private static readonly object s_eventDeactivated = new object(); // Designer has been deactivated - private static readonly object s_eventLoadComplete = new object(); // Loading has been completed - private static readonly object s_eventTransactionClosed = new object(); // The last transaction has been closed - private static readonly object s_eventTransactionClosing = new object(); // The last transaction is about to be closed - private static readonly object s_eventTransactionOpened = new object(); // The first transaction has been opened - private static readonly object s_eventTransactionOpening = new object(); // The first transaction is about to be opened + private static readonly object s_eventActivated = new(); // Designer has been activated + private static readonly object s_eventDeactivated = new(); // Designer has been deactivated + private static readonly object s_eventLoadComplete = new(); // Loading has been completed + private static readonly object s_eventTransactionClosed = new(); // The last transaction has been closed + private static readonly object s_eventTransactionClosing = new(); // The last transaction is about to be closed + private static readonly object s_eventTransactionOpened = new(); // The first transaction has been opened + private static readonly object s_eventTransactionOpening = new(); // The first transaction is about to be opened // IComponentChangeService events - private static readonly object s_eventComponentAdding = new object(); // A component is about to be added to the container - private static readonly object s_eventComponentAdded = new object(); // A component was just added to the container - private static readonly object s_eventComponentChanging = new object(); // A component is about to be changed - private static readonly object s_eventComponentChanged = new object(); // A component has changed - private static readonly object s_eventComponentRemoving = new object(); // A component is about to be removed from the container - private static readonly object s_eventComponentRemoved = new object(); // A component has been removed from the container - private static readonly object s_eventComponentRename = new object(); // A component has been renamed + private static readonly object s_eventComponentAdding = new(); // A component is about to be added to the container + private static readonly object s_eventComponentAdded = new(); // A component was just added to the container + private static readonly object s_eventComponentChanging = new(); // A component is about to be changed + private static readonly object s_eventComponentChanged = new(); // A component has changed + private static readonly object s_eventComponentRemoving = new(); // A component is about to be removed from the container + private static readonly object s_eventComponentRemoved = new(); // A component has been removed from the container + private static readonly object s_eventComponentRename = new(); // A component has been renamed // Member variables private BitVector32 _state; // state for this host @@ -53,7 +52,7 @@ internal sealed partial class DesignerHost : Container, IDesignerLoaderHost2, ID private List? _savedSelection; // set of selected components names saved across reloads private HostDesigntimeLicenseContext? _licenseCtx; private IDesignerEventService? _designerEventService; - private static readonly object s_selfLock = new object(); + private static readonly object s_selfLock = new(); private bool _ignoreErrorsDuringReload; private TypeDescriptionProviderService? _typeService; private bool _typeServiceChecked; @@ -61,7 +60,7 @@ internal sealed partial class DesignerHost : Container, IDesignerLoaderHost2, ID public DesignerHost(DesignSurface surface) { _surface = surface; - _state = default(BitVector32); + _state = default; _designers = new(); _events = new EventHandlerList(); diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DisplayMode.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DisplayMode.cs index 923c16ce052..c97b9e72830 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DisplayMode.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DisplayMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.EventPropertyDescriptor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.EventPropertyDescriptor.cs index 37367fb6b8f..17a6d85d67e 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.EventPropertyDescriptor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.EventPropertyDescriptor.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Collections; using System.Globalization; @@ -22,7 +19,7 @@ public abstract partial class EventBindingService private class EventPropertyDescriptor : PropertyDescriptor { private readonly EventBindingService _eventService; - private TypeConverter _converter; + private TypeConverter? _converter; /// /// Creates a new EventPropertyDescriptor. @@ -51,15 +48,7 @@ internal EventPropertyDescriptor(EventDescriptor eventDesc, EventBindingService /// /// Retrieves the type converter for this property. /// - public override TypeConverter Converter - { - get - { - _converter ??= new EventConverter(Event); - - return _converter; - } - } + public override TypeConverter Converter => _converter ??= new EventConverter(Event); /// /// Retrieves the event descriptor we are representing. @@ -69,7 +58,7 @@ public override TypeConverter Converter /// /// Indicates whether this property is read only. /// - public override bool IsReadOnly => Attributes[typeof(ReadOnlyAttribute)].Equals(ReadOnlyAttribute.Yes); + public override bool IsReadOnly => Attributes[typeof(ReadOnlyAttribute)]!.Equals(ReadOnlyAttribute.Yes); /// /// Retrieves the type of the property. @@ -81,29 +70,22 @@ public override TypeConverter Converter /// invoking the getXXX method. An exception in the getXXX /// method will pass through. /// - public override object GetValue(object component) + public override object? GetValue(object? component) { ArgumentNullException.ThrowIfNull(component); // We must locate the sited component, because we store data on the dictionary // service for the component. - ISite site = null; - - if (component is IComponent) - { - site = ((IComponent)component).Site; - } + ISite? site = (component as IComponent)?.Site; if (site is null) { - if (_eventService._provider.GetService(typeof(IReferenceService)) is IReferenceService rs) - { - IComponent baseComponent = rs.GetComponent(component); + IReferenceService? rs = _eventService._provider.GetService(); + IComponent? baseComponent = rs?.GetComponent(component); - if (baseComponent is not null) - { - site = baseComponent.Site; - } + if (baseComponent is not null) + { + site = baseComponent.Site; } } @@ -113,7 +95,7 @@ public override object GetValue(object component) return null; } - IDictionaryService ds = (IDictionaryService)site.GetService(typeof(IDictionaryService)); + IDictionaryService? ds = site.GetService(); if (ds is null) { @@ -121,7 +103,7 @@ public override object GetValue(object component) return null; } - return (string)ds.GetValue(new ReferenceEventClosure(component, this)); + return (string?)ds.GetValue(new ReferenceEventClosure(component, this)); } /// @@ -142,7 +124,7 @@ public override object GetValue(object component) /// property so that getXXX following a setXXX should return the value /// passed in if no exception was thrown in the setXXX call. /// - public override void SetValue(object component, object value) + public override void SetValue(object? component, object? value) { // Argument, state checking. Is it ok to set this event? if (IsReadOnly) @@ -153,7 +135,9 @@ public override void SetValue(object component, object value) }; } - if (value is not null and not string) + string? name = value as string; + + if (value is not null && name is null) { throw new ArgumentException(string.Format(SR.EventBindingServiceBadArgType, Name, nameof(String))) { @@ -161,8 +145,6 @@ public override void SetValue(object component, object value) }; } - string name = (string)value; - if (name is not null && name.Length == 0) { name = null; @@ -170,16 +152,11 @@ public override void SetValue(object component, object value) // Obtain the site for the component. Note that this can be a site // to a parent component if we can get to the reference service. - ISite site = null; + ISite? site = (component as IComponent)?.Site; - if (component is IComponent component1) + if (site is null && _eventService._provider.TryGetService(out IReferenceService? referenceService)) { - site = component1.Site; - } - - if (site is null && _eventService._provider.TryGetService(out IReferenceService referenceService)) - { - IComponent baseComponent = referenceService.GetComponent(component); + IComponent? baseComponent = referenceService.GetComponent(component!); if (baseComponent is not null) { @@ -196,7 +173,7 @@ public override void SetValue(object component, object value) } // The dictionary service is where we store the actual event method name. - if (!site.TryGetService(out IDictionaryService dictionaryService)) + if (!site.TryGetService(out IDictionaryService? dictionaryService)) { throw new InvalidOperationException(string.Format(SR.EventBindingServiceMissingService, nameof(IDictionaryService))) { @@ -205,8 +182,8 @@ public override void SetValue(object component, object value) } // Get the old method name, ensure that they are different, and then continue. - ReferenceEventClosure key = new(component, this); - string oldName = (string)dictionaryService.GetValue(key); + ReferenceEventClosure key = new(component!, this); + string? oldName = (string?)dictionaryService.GetValue(key); if (ReferenceEquals(oldName, name)) { @@ -227,9 +204,9 @@ public override void SetValue(object component, object value) // If there is a designer host, create a transaction so there is a // nice name for this change. We don't want a name like // "Change property 'Click', because to users, this isn't a property. - DesignerTransaction transaction = null; + DesignerTransaction? transaction = null; - if (site.TryGetService(out IDesignerHost host)) + if (site.TryGetService(out IDesignerHost? host)) { transaction = host.CreateTransaction(string.Format(SR.EventBindingServiceSetValue, site.Name, name)); } @@ -239,12 +216,12 @@ public override void SetValue(object component, object value) // The names are different. Fire a changing event to make // sure it's OK to perform the change. - if (site.TryGetService(out IComponentChangeService changeService)) + if (site.TryGetService(out IComponentChangeService? changeService)) { try { - changeService.OnComponentChanging(component, this); - changeService.OnComponentChanging(component, Event); + changeService.OnComponentChanging(component!, this); + changeService.OnComponentChanging(component!, Event); } catch (CheckoutException coEx) when (coEx == CheckoutException.Canceled) { @@ -257,20 +234,20 @@ public override void SetValue(object component, object value) // the new one actually succeeded. if (name is not null) { - _eventService.UseMethod((IComponent)component, Event, name); + _eventService.UseMethod((IComponent)component!, Event, name); } if (oldName is not null) { - _eventService.FreeMethod((IComponent)component, Event, oldName); + _eventService.FreeMethod((IComponent)component!, Event, oldName); } dictionaryService.SetValue(key, name); if (changeService is not null) { - changeService.OnComponentChanged(component, Event); - changeService.OnComponentChanged(component, this, oldName, name); + changeService.OnComponentChanged(component!, Event); + changeService.OnComponentChanged(component!, this, oldName, name); } OnValueChanged(component, EventArgs.Empty); @@ -279,10 +256,7 @@ public override void SetValue(object component, object value) } finally { - if (transaction is not null) - { - ((IDisposable)transaction).Dispose(); - } + ((IDisposable?)transaction)?.Dispose(); } } @@ -317,7 +291,7 @@ internal EventConverter(EventDescriptor evt) /// Determines if this converter can convert an object in the given source /// type to the native type of the converter. /// - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) { if (sourceType == typeof(string)) { @@ -330,7 +304,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceT /// /// Determines if this converter can convert an object to the given destination type. /// - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) { if (destinationType == typeof(string)) { @@ -343,24 +317,14 @@ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinati /// /// Converts the given object to the converter's native type. /// - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object? value) { - if (value is null) + return value switch { - return value; - } - - if (value is string) - { - if (((string)value).Length == 0) - { - return null; - } - - return value; - } - - return base.ConvertFrom(context, culture, value); + null or string { Length: 0 } => null, + string => value, + _ => base.ConvertFrom(context, culture, value) + }; } /// @@ -370,7 +334,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c /// type is string. If this cannot convert to the destination type, this will /// throw a NotSupportedException. /// - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) { if (destinationType == typeof(string)) { @@ -386,26 +350,16 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul /// will return null if the data type does not support a /// standard set of values. /// - public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) + public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context) { // We cannot cache this because it depends on the contents of the source file. - string[] eventMethods = null; + string[]? eventMethods = null; - if (context is not null) + if (context.TryGetService(out IEventBindingService? ebs)) { - IEventBindingService ebs = (IEventBindingService)context.GetService(typeof(IEventBindingService)); - - if (ebs is not null) - { - ICollection methods = ebs.GetCompatibleMethods(_evt); - eventMethods = new string[methods.Count]; - int i = 0; - - foreach (string s in methods) - { - eventMethods[i++] = s; - } - } + ICollection methods = ebs.GetCompatibleMethods(_evt); + eventMethods = new string[methods.Count]; + methods.CopyTo(eventMethods, 0); } return new StandardValuesCollection(eventMethods); @@ -419,13 +373,13 @@ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContex /// then there are other valid values besides the list of /// standard values GetStandardValues provides. /// - public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) => false; + public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context) => false; /// /// Determines if this object supports a standard set of values /// that can be picked from a list. /// - public override bool GetStandardValuesSupported(ITypeDescriptorContext context) => true; + public override bool GetStandardValuesSupported(ITypeDescriptorContext? context) => true; } /// @@ -449,7 +403,7 @@ public override int GetHashCode() return _reference.GetHashCode() * _propertyDescriptor.GetHashCode(); } - public override bool Equals(object otherClosure) + public override bool Equals(object? otherClosure) { if (otherClosure is ReferenceEventClosure typedClosure) { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.cs index 963b4437368..55d93021f6b 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/EventBindingService.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Collections; using System.Reflection; @@ -17,9 +14,9 @@ namespace System.ComponentModel.Design; public abstract partial class EventBindingService : IEventBindingService { private readonly IServiceProvider _provider; - private IComponent _showCodeComponent; - private EventDescriptor _showCodeEventDescriptor; - private string _showCodeMethodName; + private IComponent? _showCodeComponent; + private EventDescriptor? _showCodeEventDescriptor; + private string? _showCodeMethodName; /// /// You must provide a service provider to the binding @@ -60,7 +57,7 @@ protected virtual void FreeMethod(IComponent component, EventDescriptor e, strin /// /// Gets the requested service from our service provider. /// - protected object GetService(Type serviceType) => _provider?.GetService(serviceType); + protected object? GetService(Type serviceType) => _provider.GetService(serviceType); /// /// Shows the user code. This method does not show any @@ -131,29 +128,24 @@ ICollection IEventBindingService.GetCompatibleMethods(EventDescriptor e) /// For properties that are representing events, this will return the event /// that the property represents. /// - EventDescriptor IEventBindingService.GetEvent(PropertyDescriptor property) + EventDescriptor? IEventBindingService.GetEvent(PropertyDescriptor property) { - if (property is EventPropertyDescriptor) - { - return ((EventPropertyDescriptor)property).Event; - } - - return null; + return (property as EventPropertyDescriptor)?.Event; } /// /// Returns true if the given event has a generic argument or return value in its raise method. /// - private static bool HasGenericArgument(EventDescriptor ed) + private static bool HasGenericArgument([NotNullWhen(true)] EventDescriptor? ed) { if (ed is null || ed.ComponentType is null) { return false; } - EventInfo evInfo = ed.ComponentType.GetEvent(ed.Name); + EventInfo? evInfo = ed.ComponentType.GetEvent(ed.Name); - if (evInfo is null || !evInfo.EventHandlerType.IsGenericType) + if (evInfo is null || !evInfo.EventHandlerType!.IsGenericType) { return false; } @@ -192,7 +184,7 @@ PropertyDescriptorCollection IEventBindingService.GetEventProperties(EventDescri continue; } - PropertyDescriptor prop = new EventPropertyDescriptor(events[i], this); + PropertyDescriptor prop = new EventPropertyDescriptor(events[i]!, this); props.Add(prop); } @@ -239,7 +231,7 @@ bool IEventBindingService.ShowCode(IComponent component, EventDescriptor e) ArgumentNullException.ThrowIfNull(e); PropertyDescriptor prop = ((IEventBindingService)this).GetEventProperty(e); - string methodName = (string)prop.GetValue(component); + string? methodName = (string?)prop.GetValue(component); if (methodName is null) { @@ -259,13 +251,13 @@ bool IEventBindingService.ShowCode(IComponent component, EventDescriptor e) /// Displays the user code for the given event. This will return true if the user /// code could be displayed, or false otherwise. /// - private void ShowCodeIdle(object sender, EventArgs e) + private void ShowCodeIdle(object? sender, EventArgs e) { Application.Idle -= new EventHandler(ShowCodeIdle); try { - ShowCode(_showCodeComponent, _showCodeEventDescriptor, _showCodeMethodName); + ShowCode(_showCodeComponent!, _showCodeEventDescriptor!, _showCodeMethodName!); } finally { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ExceptionCollection.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ExceptionCollection.cs index aecaabe9883..1b917240c35 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ExceptionCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ExceptionCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Runtime.Serialization; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ExtenderProviderService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ExtenderProviderService.cs index fcf135652de..f5d5323f21b 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ExtenderProviderService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ExtenderProviderService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/FlowLayoutPanelDesigner.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/FlowLayoutPanelDesigner.cs new file mode 100644 index 00000000000..0fd1a248165 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/FlowLayoutPanelDesigner.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Drawing; + +namespace System.Windows.Forms.Design; + +internal partial class FlowLayoutPanelDesigner +{ + private struct ChildInfo + { + /// + /// Represents the bounds (including margins) of a child - used for hit testing. + /// + public Rectangle MarginBounds; + + /// + /// Bounds of the control -- used for drawing the IBar. + /// + public Rectangle ControlBounds; + + /// + /// Is this child in the selection collection? + /// + public bool InSelectionCollection; + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/HostDesigntimeLicenseContext.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/HostDesigntimeLicenseContext.cs index a5a7ebedbe9..7de5dc240b2 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/HostDesigntimeLicenseContext.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/HostDesigntimeLicenseContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/IMultitargetHelperService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/IMultitargetHelperService.cs index 1b348a09e6c..7dee0975a04 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/IMultitargetHelperService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/IMultitargetHelperService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritanceService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritanceService.cs index 274737ba173..499be2c9ab3 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritanceService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritanceService.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel.Design.Serialization; using System.Reflection; @@ -16,11 +13,11 @@ namespace System.ComponentModel.Design; /// public class InheritanceService : IInheritanceService, IDisposable { - private static readonly TraceSwitch s_inheritanceServiceSwitch = new TraceSwitch("InheritanceService", "InheritanceService : Debug inheritance scan."); + private static readonly TraceSwitch s_inheritanceServiceSwitch = new("InheritanceService", "InheritanceService : Debug inheritance scan."); private Dictionary _inheritedComponents; // While we're adding an inherited component, we must be wary of components that the inherited component adds as a result of being sited. These are treated as inherited as well. To track these, we keep track of the component we're currently adding as well as it's inheritance attribute. During the add, we sync IComponentAdding events and push in the component - private IComponent _addingComponent; - private InheritanceAttribute _addingAttribute; + private IComponent? _addingComponent; + private InheritanceAttribute? _addingAttribute; /// /// Initializes a new instance of the class. @@ -43,7 +40,7 @@ protected virtual void Dispose(bool disposing) if (disposing && _inheritedComponents is not null) { _inheritedComponents.Clear(); - _inheritedComponents = null; + _inheritedComponents = null!; } } @@ -58,7 +55,7 @@ public void AddInheritedComponents(IComponent component, IContainer container) /// /// Adds inherited components to the . /// - protected virtual void AddInheritedComponents(Type type, IComponent component, IContainer container) + protected virtual void AddInheritedComponents(Type? type, IComponent component, IContainer container) { // We get out now if this component type is not assignable from IComponent. We only walk down to the component level. if (type is null || !typeof(IComponent).IsAssignableFrom(type)) @@ -68,14 +65,14 @@ protected virtual void AddInheritedComponents(Type type, IComponent component, I Debug.WriteLineIf(s_inheritanceServiceSwitch.TraceVerbose, $"Searching for inherited components on '{type.FullName}'."); Debug.Indent(); - ISite site = component.Site; - IComponentChangeService cs = null; - INameCreationService ncs = null; + ISite? site = component.Site; + IComponentChangeService? cs = null; + INameCreationService? ncs = null; if (site is not null) { - ncs = (INameCreationService)site.GetService(typeof(INameCreationService)); - cs = (IComponentChangeService)site.GetService(typeof(IComponentChangeService)); + ncs = site.GetService(); + cs = site.GetService(); if (cs is not null) { cs.ComponentAdding += new ComponentEventHandler(OnComponentAdding); @@ -89,9 +86,8 @@ protected virtual void AddInheritedComponents(Type type, IComponent component, I Type reflect = TypeDescriptor.GetReflectionType(type); FieldInfo[] fields = reflect.GetFields(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic); Debug.WriteLineIf(s_inheritanceServiceSwitch.TraceVerbose, $"...found {fields.Length} fields."); - for (int i = 0; i < fields.Length; i++) + foreach (FieldInfo field in fields) { - FieldInfo field = fields[i]; string name = field.Name; // Get out now if this field is not assignable from IComponent. @@ -106,7 +102,7 @@ protected virtual void AddInheritedComponents(Type type, IComponent component, I Debug.Assert(!field.IsStatic, "Instance binding shouldn't have found this field"); // If the value of the field is null, then don't mess with it. If it wasn't assigned when our base class was created then we can't really use it. - object value = field.GetValue(component); + object? value = field.GetValue(component); if (value is null) { Debug.WriteLineIf(s_inheritanceServiceSwitch.TraceVerbose, $"...skipping {name}: Contains NULL"); @@ -123,7 +119,7 @@ protected virtual void AddInheritedComponents(Type type, IComponent component, I Debug.Assert(fieldAttrs[0] is AccessedThroughPropertyAttribute, "Reflection bug: GetCustomAttributes(type) didn't discriminate by type"); AccessedThroughPropertyAttribute propAttr = (AccessedThroughPropertyAttribute)fieldAttrs[0]; - PropertyInfo fieldProp = reflect.GetProperty(propAttr.PropertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + PropertyInfo? fieldProp = reflect.GetProperty(propAttr.PropertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Debug.Assert(fieldProp is not null, "Field declared with AccessedThroughPropertyAttribute has no associated property"); Debug.Assert(fieldProp.PropertyType == field.FieldType, "Field declared with AccessedThroughPropertyAttribute is associated with a property with a different return type."); @@ -136,7 +132,7 @@ protected virtual void AddInheritedComponents(Type type, IComponent component, I } // We never access the set for the property, so we can concentrate on just the get method. - member = fieldProp.GetGetMethod(true); + member = fieldProp.GetGetMethod(true)!; Debug.Assert(member is not null, "GetGetMethod for property didn't return a method, but CanRead is true"); name = propAttr.PropertyName; } @@ -186,44 +182,43 @@ protected virtual void AddInheritedComponents(Type type, IComponent component, I // We only get values via IComponent Keys and don't expose any other behaviors. // So only use IComponent as a key. - bool notPresent = false; if (value is IComponent compValue) { - notPresent = !_inheritedComponents.ContainsKey(compValue); + bool notPresent = !_inheritedComponents.ContainsKey(compValue); _inheritedComponents[compValue] = attr; - } - if (!ignoreMember && notPresent) - { - Debug.WriteLineIf(s_inheritanceServiceSwitch.TraceVerbose, $"Adding {name} to container."); - try + if (!ignoreMember && notPresent) { - _addingComponent = (IComponent)value; - _addingAttribute = attr; - - // Lets make sure this is a valid name - if (ncs is null || ncs.IsValidName(name)) + Debug.WriteLineIf(s_inheritanceServiceSwitch.TraceVerbose, $"Adding {name} to container."); + try { - try + _addingComponent = compValue; + _addingAttribute = attr; + + // Lets make sure this is a valid name + if (ncs is null || ncs.IsValidName(name)) { - container.Add((IComponent)value, name); - } - catch - { // We do not always control the base components, and there could be a lot of rogue base components. If there are exceptions when adding them, lets just ignore and continue. + try + { + container.Add(compValue, name); + } + catch + { // We do not always control the base components, and there could be a lot of rogue base components. If there are exceptions when adding them, lets just ignore and continue. + } } } - } - finally - { - _addingComponent = null; - _addingAttribute = null; + finally + { + _addingComponent = null; + _addingAttribute = null; + } } } Debug.Unindent(); } - type = type.BaseType; + type = type.BaseType!; } } finally @@ -240,7 +235,7 @@ protected virtual void AddInheritedComponents(Type type, IComponent component, I /// /// Indicates the inherited members to ignore. /// - protected virtual bool IgnoreInheritedMember(MemberInfo member, IComponent component) + protected virtual bool IgnoreInheritedMember(MemberInfo member, IComponent? component) { // Our default implementation ignores all private or assembly members. if (member is FieldInfo field) @@ -260,29 +255,30 @@ protected virtual bool IgnoreInheritedMember(MemberInfo member, IComponent compo /// Gets the inheritance attribute of the specified component. /// public InheritanceAttribute GetInheritanceAttribute(IComponent component) - => _inheritedComponents.TryGetValue(component, out InheritanceAttribute attr) + => _inheritedComponents.TryGetValue(component, out InheritanceAttribute? attr) ? attr : InheritanceAttribute.Default; - private void OnComponentAdding(object sender, ComponentEventArgs ce) + private void OnComponentAdding(object? sender, ComponentEventArgs ce) { if (_addingComponent is not null && _addingComponent != ce.Component) { Debug.WriteLineIf(s_inheritanceServiceSwitch.TraceVerbose, $"Adding component... {ce.Component}"); - _inheritedComponents[ce.Component] = InheritanceAttribute.InheritedReadOnly; + _inheritedComponents[ce.Component!] = InheritanceAttribute.InheritedReadOnly; // If this component is being added to a nested container of addingComponent, it should get the same inheritance level. if (sender is INestedContainer nested && nested.Owner == _addingComponent) { - _inheritedComponents[ce.Component] = _addingAttribute; + _inheritedComponents[ce.Component!] = _addingAttribute!; } } } - private static Type GetReflectionTypeFromTypeHelper(Type type) + [return: NotNullIfNotNull(nameof(type))] + private static Type? GetReflectionTypeFromTypeHelper(Type? type) { if (type is not null) { - TypeDescriptionProvider targetProvider = GetTargetFrameworkProviderForType(type); + TypeDescriptionProvider? targetProvider = GetTargetFrameworkProviderForType(type); if (targetProvider is not null) { if (targetProvider.IsSupportedType(type)) @@ -295,17 +291,8 @@ private static Type GetReflectionTypeFromTypeHelper(Type type) return type; } - private static TypeDescriptionProvider GetTargetFrameworkProviderForType(Type type) + private static TypeDescriptionProvider? GetTargetFrameworkProviderForType(Type type) { - IDesignerSerializationManager manager = DocumentDesigner.manager; - if (manager is not null) - { - if (manager.GetService(typeof(TypeDescriptionProviderService)) is TypeDescriptionProviderService service) - { - return service.GetProvider(type); - } - } - - return null; + return DocumentDesigner.manager?.GetService()?.GetProvider(type); } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritedPropertyDescriptor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritedPropertyDescriptor.cs index cc9a3294af1..811df6cf9de 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritedPropertyDescriptor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritedPropertyDescriptor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -18,7 +17,7 @@ internal sealed class InheritedPropertyDescriptor : PropertyDescriptor { private PropertyDescriptor propertyDescriptor; private object _defaultValue; - private static readonly object s_noDefault = new object(); + private static readonly object s_noDefault = new(); private bool _initShouldSerialize; private object _originalValue; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/LoadedEventArgs.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/LoadedEventArgs.cs index d59ae9e364a..5471bb5cc99 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/LoadedEventArgs.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/LoadedEventArgs.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Collections; @@ -16,7 +13,7 @@ public sealed class LoadedEventArgs : EventArgs /// /// Creates a new LoadedEventArgs object. /// - public LoadedEventArgs(bool succeeded, ICollection errors) + public LoadedEventArgs(bool succeeded, ICollection? errors) { HasSucceeded = succeeded; Errors = errors ?? Array.Empty(); diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/LoadedEventHandler.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/LoadedEventHandler.cs index e5729c92b72..bb6b0be1a76 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/LoadedEventHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/LoadedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandService.cs index 906413b5302..e454f33a02a 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -26,7 +25,7 @@ public class MenuCommandService : IMenuCommandService, IDisposable private List _globalVerbs; private ISelectionService _selectionService; - internal static TraceSwitch MENUSERVICE = new TraceSwitch("MENUSERVICE", "MenuCommandService: Track menu command routing"); + internal static TraceSwitch MENUSERVICE = new("MENUSERVICE", "MenuCommandService: Track menu command routing"); // This is the set of verbs we offer through the Verbs property. // It consists of the global verbs + any verbs that the currently diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventArgs.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventArgs.cs index cc5c1e79df4..7e181ef779e 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventArgs.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventHandler.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventHandler.cs index 82b8832da7d..41a7727fdab 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedType.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedType.cs index 9519875aa2f..eaaa3bddf5f 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedType.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandsChangedType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.MultilineStringEditorUI.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.MultilineStringEditorUI.cs index 3e24c323dab..c2f74f6d4b5 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.MultilineStringEditorUI.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.MultilineStringEditorUI.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.OleCallback.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.OleCallback.cs index 5fb2dcbaac8..37ba309304d 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.OleCallback.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.OleCallback.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.cs index 7cbb620047f..4d7d7d2924f 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MultilineStringEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing.Design; using System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ObjectSelectorEditor.Selector.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ObjectSelectorEditor.Selector.cs index 1f5257e2796..fdbd42bac36 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ObjectSelectorEditor.Selector.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ObjectSelectorEditor.Selector.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Windows.Forms; using System.Windows.Forms.Design; @@ -15,7 +12,7 @@ public abstract partial class ObjectSelectorEditor public class Selector : TreeView { private readonly ObjectSelectorEditor _editor; - private IWindowsFormsEditorService _editorService; + private IWindowsFormsEditorService? _editorService; public bool clickSeen; /// @@ -41,7 +38,7 @@ public Selector(ObjectSelectorEditor editor) /// Adds a Node with given label and value to the parent, provided the parent is not null; /// Otherwise, adds that node to the Nodes TreeNodeCollection. Returns the new node. /// - public SelectorNode AddNode(string label, object value, SelectorNode parent) + public SelectorNode AddNode(string? label, object? value, SelectorNode? parent) { SelectorNode newNode = new(label, value); @@ -64,7 +61,7 @@ private bool ChooseSelectedNodeIfEqual() { if (_editor is not null && _editorService is not null) { - _editor.SetValue(((SelectorNode)SelectedNode).value); + _editor.SetValue(((SelectorNode)SelectedNode!).value); if (_editor.EqualsToValue(((SelectorNode)SelectedNode).value)) { _editorService.CloseDropDown(); @@ -84,7 +81,7 @@ public void Clear() Nodes.Clear(); } - protected void OnAfterSelect(object sender, TreeViewEventArgs e) + protected void OnAfterSelect(object? sender, TreeViewEventArgs e) { if (clickSeen) { @@ -109,7 +106,7 @@ protected override void OnKeyDown(KeyEventArgs e) case Keys.Escape: _editor.SetValue(_editor.prevValue); e.Handled = true; - _editorService.CloseDropDown(); + _editorService!.CloseDropDown(); break; } @@ -139,27 +136,19 @@ protected override void OnNodeMouseClick(TreeNodeMouseClickEventArgs e) base.OnNodeMouseClick(e); } - public bool SetSelection(object value, TreeNodeCollection nodes) + public bool SetSelection(object? value, TreeNodeCollection? nodes) { - TreeNode[] treeNodes; + nodes ??= Nodes; - if (nodes is null) - { - treeNodes = new TreeNode[Nodes.Count]; - Nodes.CopyTo(treeNodes, 0); - } - else - { - treeNodes = new TreeNode[nodes.Count]; - nodes.CopyTo(treeNodes, 0); - } - - int length = treeNodes.Length; + int length = nodes.Count; if (length == 0) { return false; } + TreeNode[] treeNodes = new TreeNode[length]; + nodes.CopyTo(treeNodes, 0); + for (int i = 0; i < length; i++) { if (((SelectorNode)treeNodes[i]).value == value) @@ -186,7 +175,7 @@ public bool SetSelection(object value, TreeNodeCollection nodes) /// /// Sets the internal IWindowsFormsEditorService to the given edSvc, and calls SetSelection on the given value /// - public void Start(IWindowsFormsEditorService edSvc, object value) + public void Start(IWindowsFormsEditorService edSvc, object? value) { _editorService = edSvc; clickSeen = false; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ObjectSelectorEditor.SelectorNode.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ObjectSelectorEditor.SelectorNode.cs index dd49357e717..760632b9904 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ObjectSelectorEditor.SelectorNode.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ObjectSelectorEditor.SelectorNode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; @@ -15,7 +14,7 @@ public class SelectorNode : TreeNode /// /// Sets label and value to given. /// - public SelectorNode(string label, object? value) : base(label) + public SelectorNode(string? label, object? value) : base(label) { this.value = value; } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ObjectSelectorEditor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ObjectSelectorEditor.cs index fa2015b229b..d27a52228b6 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ObjectSelectorEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ObjectSelectorEditor.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Drawing.Design; using System.Windows.Forms; @@ -13,9 +10,9 @@ namespace System.ComponentModel.Design; public abstract partial class ObjectSelectorEditor : UITypeEditor { public bool SubObjectSelector; - protected object prevValue; - protected object currValue; - private Selector _selector; + protected object? prevValue; + protected object? currValue; + private Selector? _selector; public ObjectSelectorEditor() { @@ -27,9 +24,9 @@ public ObjectSelectorEditor(bool subObjectSelector) } /// - public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) + public override object? EditValue(ITypeDescriptorContext? context, IServiceProvider provider, object? value) { - if (!provider.TryGetService(out IWindowsFormsEditorService editorService)) + if (!provider.TryGetService(out IWindowsFormsEditorService? editorService)) { return value; } @@ -73,13 +70,13 @@ public static void ApplyTreeViewThemeStyles(TreeView treeView) PInvoke.SendMessage(hwnd, PInvoke.TVM_SETEXTENDEDSTYLE, (WPARAM)0, (LPARAM)(uint)exstyle); } - public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.DropDown; + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext? context) => UITypeEditorEditStyle.DropDown; - protected internal bool EqualsToValue(object value) => value == currValue; + protected internal bool EqualsToValue(object? value) => value == currValue; - protected virtual void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider) + protected virtual void FillTreeWithData(Selector selector, ITypeDescriptorContext? context, IServiceProvider provider) => selector.Clear(); /// - public virtual void SetValue(object value) => currValue = value; + public virtual void SetValue(object? value) => currValue = value; } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ProjectTargetFrameworkAttribute.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ProjectTargetFrameworkAttribute.cs index 878444b6112..a3a1359dc7a 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ProjectTargetFrameworkAttribute.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ProjectTargetFrameworkAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ReferenceService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ReferenceService.cs index bc49eed9549..9f09bb3ca47 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ReferenceService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ReferenceService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SelectionService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SelectionService.cs index 99227ccddc0..457cdd3060b 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SelectionService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SelectionService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Collections.Specialized; @@ -26,8 +25,8 @@ internal sealed class SelectionService : ISelectionService, IDisposable private static readonly int s_stateTransactionChange = BitVector32.CreateMask(s_stateTransaction); // Component change occurred while in a transaction // ISelectionService events - private static readonly object s_eventSelectionChanging = new object(); - private static readonly object s_eventSelectionChanged = new object(); + private static readonly object s_eventSelectionChanging = new(); + private static readonly object s_eventSelectionChanged = new(); // Member variables private IServiceProvider _provider; // The service provider diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/BasicDesignerLoader.ReloadOptions.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/BasicDesignerLoader.ReloadOptions.cs index 431ccb6308b..98eead2e422 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/BasicDesignerLoader.ReloadOptions.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/BasicDesignerLoader.ReloadOptions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/BasicDesignerLoader.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/BasicDesignerLoader.cs index 41373f477ab..84883a47dc3 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/BasicDesignerLoader.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/BasicDesignerLoader.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Collections; using System.Collections.Specialized; @@ -35,15 +32,15 @@ public abstract partial class BasicDesignerLoader : DesignerLoader, IDesignerLoa // State for the designer loader. private BitVector32 _state; - private IDesignerLoaderHost _host; + private IDesignerLoaderHost? _host; private int _loadDependencyCount; - private string _baseComponentClassName; + private string? _baseComponentClassName; private bool _hostInitialized; private bool _loading; // State for serialization. - private DesignerSerializationManager _serializationManager; - private IDisposable _serializationSession; + private DesignerSerializationManager? _serializationManager; + private IDisposable? _serializationSession; /// /// Creates a new BasicDesignerLoader @@ -103,7 +100,7 @@ protected IDesignerLoaderHost LoaderHost /// Provides an object whose public properties will be made available to the designer serialization manager's /// Properties property. The default value of this property is null. /// - protected object PropertyProvider + protected object? PropertyProvider { get { @@ -169,21 +166,13 @@ public override void BeginLoad(IDesignerLoaderHost host) // Add our services. We do IDesignerSerializationManager separate because // it is not something the user can replace. - DesignSurfaceServiceContainer dsc = GetService(typeof(DesignSurfaceServiceContainer)) as DesignSurfaceServiceContainer; - - if (dsc is not null) + if (TryGetService(out DesignSurfaceServiceContainer? dsc)) { dsc.AddFixedService(typeof(IDesignerSerializationManager), _serializationManager); } else { - IServiceContainer sc = GetService(typeof(IServiceContainer)) as IServiceContainer; - - if (sc is null) - { - ThrowMissingService(typeof(IServiceContainer)); - } - + IServiceContainer sc = GetRequiredService(); sc.AddService(typeof(IDesignerSerializationManager), _serializationManager); } @@ -199,8 +188,8 @@ public override void BeginLoad(IDesignerLoaderHost host) // // StartTimingMark(); bool successful = true; - List localErrorList = null; - IDesignerLoaderService ls = GetService(typeof(IDesignerLoaderService)) as IDesignerLoaderService; + List? localErrorList = null; + IDesignerLoaderService? ls = GetService(); try { @@ -214,13 +203,13 @@ public override void BeginLoad(IDesignerLoaderHost host) OnBeginLoad(); } - PerformLoad(_serializationManager); + PerformLoad(_serializationManager!); } catch (Exception e) { while (e is TargetInvocationException) { - e = e.InnerException; + e = e.InnerException!; } localErrorList = new() { e }; @@ -254,9 +243,8 @@ public override void Dispose() } UnloadDocument(); - IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); - if (cs is not null) + if (TryGetService(out IComponentChangeService? cs)) { cs.ComponentAdded -= new ComponentEventHandler(OnComponentAdded); cs.ComponentAdding -= new ComponentEventHandler(OnComponentAdding); @@ -294,21 +282,21 @@ public override void Flush() } _state[s_stateFlushInProgress] = true; - Cursor oldCursor = Cursor.Current; + Cursor? oldCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; try { - IDesignerLoaderHost host = _host; + IDesignerLoaderHost? host = _host; Debug.Assert(host is not null, "designer loader was asked to flush after it has been disposed."); // If the host has a null root component, it probably failed // its last load. In that case, there is nothing to flush. bool shouldChangeModified = true; - if (host is not null && host.RootComponent is not null) + if (host?.RootComponent is not null) { - using (_serializationManager.CreateSession()) + using (_serializationManager!.CreateSession()) { try { @@ -348,9 +336,9 @@ public override void Flush() /// /// Helper method that gives access to the service provider. /// - protected object GetService(Type serviceType) + protected object? GetService(Type serviceType) { - object service = null; + object? service = null; if (_host is not null) { @@ -360,6 +348,29 @@ protected object GetService(Type serviceType) return service; } + private protected T? GetService() where T : class + => GetService(typeof(T)) as T; + + private protected bool TryGetService([NotNullWhen(true)] out T? service) where T : class + { + service = GetService(); + return service is not null; + } + + /// + /// Simple helper routine that will throw an exception if we need a service, but cannot get + /// to it. You should only throw for missing services that are absolutely essential for + /// operation. If there is a way to gracefully degrade, then you should do it. + /// + private protected T GetRequiredService() where T : class + { + return GetService() ?? + throw new InvalidOperationException(string.Format(SR.BasicDesignerLoaderMissingService, typeof(T).Name)) + { + HelpLink = SR.BasicDesignerLoaderMissingService + }; + } + /// /// This method is called immediately after the first time /// BeginLoad is invoked. This is an appropriate place to @@ -394,26 +405,25 @@ protected object GetService(Type serviceType) /// protected virtual void OnBeginLoad() { - _serializationSession = _serializationManager.CreateSession(); + _serializationSession = _serializationManager!.CreateSession(); _state[s_stateLoaded] = false; // Make sure that we're removed any event sinks we added after we finished the load. // Make sure that we're removed any event sinks we added after we finished the load. EnableComponentNotification(false); - IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); - if (cs is null) + if (!TryGetService(out IComponentChangeService? componentChangeService)) { return; } - cs.ComponentAdded -= new ComponentEventHandler(OnComponentAdded); - cs.ComponentAdding -= new ComponentEventHandler(OnComponentAdding); - cs.ComponentRemoving -= new ComponentEventHandler(OnComponentRemoving); - cs.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); - cs.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged); - cs.ComponentChanging -= new ComponentChangingEventHandler(OnComponentChanging); - cs.ComponentRename -= new ComponentRenameEventHandler(OnComponentRename); + componentChangeService.ComponentAdded -= new ComponentEventHandler(OnComponentAdded); + componentChangeService.ComponentAdding -= new ComponentEventHandler(OnComponentAdding); + componentChangeService.ComponentRemoving -= new ComponentEventHandler(OnComponentRemoving); + componentChangeService.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); + componentChangeService.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged); + componentChangeService.ComponentChanging -= new ComponentChangingEventHandler(OnComponentChanging); + componentChangeService.ComponentRename -= new ComponentRenameEventHandler(OnComponentRename); } /// @@ -448,7 +458,7 @@ protected virtual void OnBeginUnload() /// /// This is called whenever a new component is added to the design surface. /// - private void OnComponentAdded(object sender, ComponentEventArgs e) + private void OnComponentAdded(object? sender, ComponentEventArgs e) { // We check the loader host here. We do not actually listen to // this event until the loader has finished loading but if we @@ -463,7 +473,7 @@ private void OnComponentAdded(object sender, ComponentEventArgs e) /// /// This is called right before a component is added to the design surface. /// - private void OnComponentAdding(object sender, ComponentEventArgs e) + private void OnComponentAdding(object? sender, ComponentEventArgs e) { // We check the loader host here. We do not actually listen to // this event until the loader has finished loading but if we @@ -478,7 +488,7 @@ private void OnComponentAdding(object sender, ComponentEventArgs e) /// /// This is called whenever a component on the design surface changes. /// - private void OnComponentChanged(object sender, ComponentChangedEventArgs e) + private void OnComponentChanged(object? sender, ComponentChangedEventArgs e) { // We check the loader host here. We do not actually listen to // this event until the loader has finished loading but if we @@ -493,7 +503,7 @@ private void OnComponentChanged(object sender, ComponentChangedEventArgs e) /// /// This is called right before a component on the design surface changes. /// - private void OnComponentChanging(object sender, ComponentChangingEventArgs e) + private void OnComponentChanging(object? sender, ComponentChangingEventArgs e) { // We check the loader host here. We do not actually listen to // this event until the loader has finished loading but if we @@ -508,7 +518,7 @@ private void OnComponentChanging(object sender, ComponentChangingEventArgs e) /// /// This is called whenever a component is removed from the design surface. /// - private void OnComponentRemoved(object sender, ComponentEventArgs e) + private void OnComponentRemoved(object? sender, ComponentEventArgs e) { // We check the loader host here. We do not actually listen to // this event until the loader has finished loading but if we @@ -523,7 +533,7 @@ private void OnComponentRemoved(object sender, ComponentEventArgs e) /// /// This is called right before a component is removed from the design surface. /// - private void OnComponentRemoving(object sender, ComponentEventArgs e) + private void OnComponentRemoving(object? sender, ComponentEventArgs e) { // We check the loader host here. We do not actually listen to // this event until the loader has finished loading but if we @@ -540,7 +550,7 @@ private void OnComponentRemoving(object sender, ComponentEventArgs e) /// and then whack the component declaration. At the next code gen /// cycle we will recreate the declaration. /// - private void OnComponentRename(object sender, ComponentRenameEventArgs e) + private void OnComponentRename(object? sender, ComponentRenameEventArgs e) { // We check the loader host here. We do not actually listen to // this event until the loader has finished loading but if we @@ -558,7 +568,7 @@ private void OnComponentRename(object sender, ComponentRenameEventArgs e) /// someone else has modified the contents of our buffer. If so, we /// ask the designer to reload. /// - private void OnDesignerActivate(object sender, EventArgs e) + private void OnDesignerActivate(object? sender, EventArgs e) { _state[s_stateActiveDocument] = true; @@ -592,7 +602,7 @@ private void OnDesignerActivate(object sender, EventArgs e) /// Called when this document loses activation. We just remember this /// for later. /// - private void OnDesignerDeactivate(object sender, EventArgs e) => _state[s_stateActiveDocument] = false; + private void OnDesignerDeactivate(object? sender, EventArgs e) => _state[s_stateActiveDocument] = false; /// /// This method should be called by the designer loader service @@ -606,20 +616,19 @@ private void OnDesignerActivate(object sender, EventArgs e) /// indirectly by calling DependentLoadComplete if IDesignerLoaderService /// is available, or directly if it is not. /// - protected virtual void OnEndLoad(bool successful, ICollection errors) + protected virtual void OnEndLoad(bool successful, ICollection? errors) { //we don't want successful to be true here if there were load errors. //this may allow a situation where we have a dirtied WSOD and might allow //a user to save a partially loaded designer docdata. successful = successful && (errors is null || errors.Count == 0) - && (_serializationManager.Errors is null + && (_serializationManager!.Errors is null || _serializationManager.Errors.Count == 0); try { _state[s_stateLoaded] = true; - IDesignerLoaderHost2 lh2 = GetService(typeof(IDesignerLoaderHost2)) as IDesignerLoaderHost2; - if (!successful && (lh2 is null || !lh2.IgnoreErrorsDuringReload)) + if (!successful && !(TryGetService(out IDesignerLoaderHost2? lh2) && lh2.IgnoreErrorsDuringReload)) { // Can we even show the Continue Ignore errors in DTEL? if (lh2 is not null) @@ -641,15 +650,15 @@ protected virtual void OnEndLoad(bool successful, ICollection errors) { foreach (object err in errors) { - _serializationManager.Errors.Add(err); + _serializationManager!.Errors!.Add(err); } } - errors = _serializationManager.Errors; + errors = _serializationManager!.Errors; } finally { - _serializationSession.Dispose(); + _serializationSession!.Dispose(); _serializationSession = null; } @@ -657,23 +666,22 @@ protected virtual void OnEndLoad(bool successful, ICollection errors) { // After a successful load we will want to monitor a bunch of events so we know when // to make the loader modified. - IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); - if (cs is not null) + if (TryGetService(out IComponentChangeService? componentChangeService)) { - cs.ComponentAdded += new ComponentEventHandler(OnComponentAdded); - cs.ComponentAdding += new ComponentEventHandler(OnComponentAdding); - cs.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving); - cs.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); - cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); - cs.ComponentChanging += new ComponentChangingEventHandler(OnComponentChanging); - cs.ComponentRename += new ComponentRenameEventHandler(OnComponentRename); + componentChangeService.ComponentAdded += new ComponentEventHandler(OnComponentAdded); + componentChangeService.ComponentAdding += new ComponentEventHandler(OnComponentAdding); + componentChangeService.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving); + componentChangeService.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); + componentChangeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); + componentChangeService.ComponentChanging += new ComponentChangingEventHandler(OnComponentChanging); + componentChangeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename); } EnableComponentNotification(true); } - LoaderHost.EndLoad(_baseComponentClassName, successful, errors); + LoaderHost.EndLoad(_baseComponentClassName!, successful, errors); // if we got errors in the load, set ourselves as modified so we'll regen code. If this fails, we don't // care; the Modified bit was only a hint. @@ -708,7 +716,7 @@ protected virtual void OnModifying() /// the reload actually happens. Here we unload our part of the loader /// and get us ready for the pending reload. /// - private void OnIdle(object sender, EventArgs e) + private void OnIdle(object? sender, EventArgs e) { Application.Idle -= new EventHandler(OnIdle); @@ -720,8 +728,8 @@ private void OnIdle(object sender, EventArgs e) _state[s_stateReloadAtIdle] = false; //check to see if we are actually the active document. - DesignSurfaceManager mgr = (DesignSurfaceManager)GetService(typeof(DesignSurfaceManager)); - DesignSurface thisSurface = (DesignSurface)GetService(typeof(DesignSurface)); + DesignSurfaceManager? mgr = GetService(); + DesignSurface? thisSurface = GetService(); Debug.Assert(mgr is not null && thisSurface is not null); if (mgr is not null && thisSurface is not null) @@ -834,7 +842,7 @@ protected void Reload(ReloadOptions flags) /// protected virtual void ReportFlushErrors(ICollection errors) { - object lastError = null; + object? lastError = null; foreach (object e in errors) { @@ -848,7 +856,7 @@ protected virtual void ReportFlushErrors(ICollection errors) return; } - Exception ex = lastError as Exception; + Exception? ex = lastError as Exception; ex ??= new InvalidOperationException(lastError.ToString()); @@ -869,19 +877,6 @@ protected void SetBaseComponentClassName(string name) _baseComponentClassName = name; } - /// - /// Simple helper routine that will throw an exception if we need a service, but cannot get - /// to it. You should only throw for missing services that are absolutely essential for - /// operation. If there is a way to gracefully degrade, then you should do it. - /// - private static void ThrowMissingService(Type serviceType) - { - Exception ex = new InvalidOperationException(string.Format(SR.BasicDesignerLoaderMissingService, serviceType.Name)); - ex.HelpLink = SR.BasicDesignerLoaderMissingService; - - throw ex; - } - /// /// This method will be called when the document is to be unloaded. It /// does not dispose us, but it gets us ready for a dispose or a reload. @@ -919,7 +914,7 @@ void IDesignerLoaderService.AddLoadDependency() /// a successful load, or a collection of exceptions that indicate the /// reason(s) for failure. /// - void IDesignerLoaderService.DependentLoadComplete(bool successful, ICollection errorCollection) + void IDesignerLoaderService.DependentLoadComplete(bool successful, ICollection? errorCollection) { if (_loadDependencyCount == 0) { @@ -948,7 +943,7 @@ void IDesignerLoaderService.DependentLoadComplete(bool successful, ICollection e // Otherwise, add these errors to the serialization manager. foreach (object err in errorCollection) { - _serializationManager.Errors.Add(err); + _serializationManager!.Errors.Add(err); } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationService.cs index d207af8fb66..7120807feb2 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -176,7 +175,7 @@ public override void DeserializeTo(SerializationStore store, IContainer containe private sealed class CodeDomSerializationStore : SerializationStore, ISerializable { #if DEBUG - private static readonly TraceSwitch s_trace = new TraceSwitch("ComponentSerializationService", "Trace component serialization"); + private static readonly TraceSwitch s_trace = new("ComponentSerializationService", "Trace component serialization"); #else #pragma warning disable CS0649 private static readonly TraceSwitch s_trace; @@ -607,12 +606,12 @@ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext contex /// private class ComponentListCodeDomSerializer : CodeDomSerializer { - internal static ComponentListCodeDomSerializer s_instance = new ComponentListCodeDomSerializer(); + internal static ComponentListCodeDomSerializer s_instance = new(); private Hashtable _statementsTable; private Dictionary> _expressions; private Hashtable _objectState; // only used during deserialization private bool _applyDefaults = true; - private readonly Hashtable _nameResolveGuard = new Hashtable(); + private readonly Hashtable _nameResolveGuard = new(); public override object Deserialize(IDesignerSerializationManager manager, object state) { @@ -1464,7 +1463,7 @@ object IServiceProvider.GetService(Type serviceType) private class PassThroughSerializationManager : IDesignerSerializationManager { - private readonly Hashtable _resolved = new Hashtable(); + private readonly Hashtable _resolved = new(); private readonly DesignerSerializationManager _manager; private ResolveNameEventHandler _resolveNameEventHandler; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifierConverter.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifierConverter.cs index d86708d1e73..36fe5e0e645 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifierConverter.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifierConverter.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.CodeDom; using System.CodeDom.Compiler; @@ -20,57 +17,44 @@ private class ModifierConverter : TypeConverter /// convert an object in the given source type to the native type of the converter /// using the context. /// - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) => GetConverter(context).CanConvertFrom(context, sourceType); /// /// Gets a value indicating whether this converter can /// convert an object to the given destination type using the context. /// - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) => GetConverter(context).CanConvertTo(context, destinationType); /// /// Converts the given object to the converter's native type. /// - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) => GetConverter(context).ConvertFrom(context, culture, value); /// /// Converts the given value object to /// the specified destination type using the specified context and arguments. /// - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) => GetConverter(context).ConvertTo(context, culture, value, destinationType); /// /// Re-creates an given a set of property values for the /// object. /// - public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) + public override object? CreateInstance(ITypeDescriptorContext? context, IDictionary propertyValues) => GetConverter(context).CreateInstance(context, propertyValues); /// /// Returns the type converter for the member attributes enum. We search the context /// for a code dom provider that can provide us more information. /// - private static TypeConverter GetConverter(ITypeDescriptorContext context) + private static TypeConverter GetConverter(ITypeDescriptorContext? context) { - TypeConverter modifierConverter = null; - - if (context is not null) - { - CodeDomProvider provider = (CodeDomProvider)context.GetService(typeof(CodeDomProvider)); - - if (provider is not null) - { - modifierConverter = provider.GetConverter(typeof(MemberAttributes)); - } - } - - modifierConverter ??= TypeDescriptor.GetConverter(typeof(MemberAttributes)); - - return modifierConverter; + TypeConverter? modifierConverter = context?.GetService()?.GetConverter(typeof(MemberAttributes)); + return modifierConverter ?? TypeDescriptor.GetConverter(typeof(MemberAttributes)); } /// @@ -78,7 +62,7 @@ private static TypeConverter GetConverter(ITypeDescriptorContext context) /// call to to create a new value, /// using the specified context. /// - public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) + public override bool GetCreateInstanceSupported(ITypeDescriptorContext? context) => GetConverter(context).GetCreateInstanceSupported(context); /// @@ -86,7 +70,7 @@ public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) /// the type of array specified by the value parameter using the specified context and /// attributes. /// - public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) + public override PropertyDescriptorCollection? GetProperties(ITypeDescriptorContext? context, object value, Attribute[]? attributes) => GetConverter(context).GetProperties(context, value, attributes); /// @@ -94,17 +78,17 @@ public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContex /// whether this object supports properties using the /// specified context. /// - public override bool GetPropertiesSupported(ITypeDescriptorContext context) + public override bool GetPropertiesSupported(ITypeDescriptorContext? context) => GetConverter(context).GetPropertiesSupported(context); /// /// Gets a collection of standard values for the data type this type converter is /// designed for. /// - public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) + public override StandardValuesCollection? GetStandardValues(ITypeDescriptorContext? context) { // We restrict the set of standard values to those within the access mask. - StandardValuesCollection values = GetConverter(context).GetStandardValues(context); + StandardValuesCollection? values = GetConverter(context).GetStandardValues(context); if (values is not null && values.Count > 0) { @@ -143,7 +127,7 @@ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContex /// is an exclusive /// list of possible values, using the specified context. /// - public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) + public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context) => GetConverter(context).GetStandardValuesExclusive(context); /// @@ -152,14 +136,14 @@ public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) /// supports a standard set of values that can be picked /// from a list using the specified context. /// - public override bool GetStandardValuesSupported(ITypeDescriptorContext context) + public override bool GetStandardValuesSupported(ITypeDescriptorContext? context) => GetConverter(context).GetStandardValuesSupported(context); /// /// Gets /// a value indicating whether the given value object is valid for this type. /// - public override bool IsValid(ITypeDescriptorContext context, object value) + public override bool IsValid(ITypeDescriptorContext? context, object? value) => GetConverter(context).IsValid(context, value); } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifiersExtenderProvider.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifiersExtenderProvider.cs index 3bba5d0d002..c17549f3b33 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifiersExtenderProvider.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifiersExtenderProvider.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.CodeDom; using System.Windows.Forms; @@ -18,7 +15,7 @@ public abstract partial class CodeDomDesignerLoader [ProvideProperty("GenerateMember", typeof(IComponent))] private class ModifiersExtenderProvider : IExtenderProvider { - private IDesignerHost _host; + private IDesignerHost? _host; /// /// Determines if ths extender provider can extend the given object. We extend @@ -26,13 +23,13 @@ private class ModifiersExtenderProvider : IExtenderProvider /// public bool CanExtend(object o) { - if (!(o is IComponent c)) + if (o is not IComponent component) { return false; } // We don't add modifiers to the base component. - IComponent baseComponent = GetBaseComponent(c); + IComponent? baseComponent = GetBaseComponent(component); if (o == baseComponent) { @@ -41,7 +38,7 @@ public bool CanExtend(object o) // Now see if this object is inherited. If so, then we don't want to // extend. - if (!TypeDescriptor.GetAttributes(o)[typeof(InheritanceAttribute)].Equals(InheritanceAttribute.NotInherited)) + if (!TypeDescriptor.GetAttributes(o)[typeof(InheritanceAttribute)]!.Equals(InheritanceAttribute.NotInherited)) { return false; } @@ -49,31 +46,11 @@ public bool CanExtend(object o) return true; } - private IComponent GetBaseComponent(IComponent c) + private IComponent? GetBaseComponent(IComponent component) { - IComponent baseComponent = null; - - if (c is null) - { - return null; - } + _host ??= component.Site?.GetService(); - if (_host is null) - { - ISite site = c.Site; - - if (site is not null) - { - _host = (IDesignerHost)site.GetService(typeof(IDesignerHost)); - } - } - - if (_host is not null) - { - baseComponent = _host.RootComponent; - } - - return baseComponent; + return _host?.RootComponent; } /// @@ -89,22 +66,11 @@ private IComponent GetBaseComponent(IComponent c) [HelpKeyword("Designer_GenerateMember")] public static bool GetGenerateMember(IComponent comp) { - ISite site = comp.Site; - - if (site is null) + if (comp.Site.TryGetService(out IDictionaryService? dictionary)) { - return true; - } - - IDictionaryService dictionary = (IDictionaryService)site.GetService(typeof(IDictionaryService)); - - if (dictionary is not null) - { - object value = dictionary.GetValue("GenerateMember"); - - if (value is bool) + if (dictionary.GetValue("GenerateMember") is bool value) { - return (bool)value; + return value; } } @@ -126,31 +92,20 @@ public static bool GetGenerateMember(IComponent comp) [HelpKeyword("Designer_Modifiers")] public static MemberAttributes GetModifiers(IComponent comp) { - ISite site = comp.Site; - - if (site is not null) + if (comp.Site.TryGetService(out IDictionaryService? dictionary)) { - IDictionaryService dictionary = (IDictionaryService)site.GetService(typeof(IDictionaryService)); - - if (dictionary is not null) + if (dictionary.GetValue("Modifiers") is MemberAttributes value) { - object value = dictionary.GetValue("Modifiers"); - - if (value is MemberAttributes) - { - return (MemberAttributes)value; - } + return value; } } // Check to see if someone offered up a "DefaultModifiers" property so we can // decide a default. - PropertyDescriptorCollection props = TypeDescriptor.GetProperties(comp); - PropertyDescriptor prop = props["DefaultModifiers"]; - - if (prop is not null && prop.PropertyType == typeof(MemberAttributes)) + if (TypeDescriptorHelper.TryGetPropertyValue(comp, "DefaultModifiers", + out MemberAttributes memberAttributes)) { - return (MemberAttributes)prop.GetValue(comp); + return memberAttributes; } return MemberAttributes.Private; @@ -164,14 +119,14 @@ public static MemberAttributes GetModifiers(IComponent comp) /// public static void SetGenerateMember(IComponent comp, bool generate) { - ISite site = comp.Site; + ISite? site = comp.Site; if (site is null) { return; } - IDictionaryService dictionary = (IDictionaryService)site.GetService(typeof(IDictionaryService)); + IDictionaryService? dictionary = site.GetService(); bool oldValue = GetGenerateMember(comp); dictionary?.SetValue("GenerateMember", generate); @@ -184,9 +139,10 @@ public static void SetGenerateMember(IComponent comp, bool generate) return; } - string compName = site.Name; + string? compName = site.Name; + CodeTypeDeclaration? typeDecl = site.GetService(); - if (!(site.GetService(typeof(CodeTypeDeclaration)) is CodeTypeDeclaration typeDecl) || compName is null) + if (typeDecl is null || compName is null) { return; } @@ -209,16 +165,10 @@ public static void SetGenerateMember(IComponent comp, bool generate) /// public static void SetModifiers(IComponent comp, MemberAttributes modifiers) { - ISite site = comp.Site; - - if (site is null) + if (comp.Site.TryGetService(out IDictionaryService? dictionary)) { - return; + dictionary.SetValue("Modifiers", modifiers); } - - IDictionaryService dictionary = (IDictionaryService)site.GetService(typeof(IDictionaryService)); - - dictionary?.SetValue("Modifiers", modifiers); } } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifiersInheritedExtenderProvider.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifiersInheritedExtenderProvider.cs index 50273d09b5c..962129ffdfd 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifiersInheritedExtenderProvider.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.ModifiersInheritedExtenderProvider.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.CodeDom; using System.Reflection; @@ -19,7 +16,7 @@ public abstract partial class CodeDomDesignerLoader [ProvideProperty("Modifiers", typeof(IComponent))] private class ModifiersInheritedExtenderProvider : IExtenderProvider { - private IDesignerHost _host; + private IDesignerHost? _host; /// /// Determines if ths extender provider can extend the given object. We extend @@ -27,13 +24,13 @@ private class ModifiersInheritedExtenderProvider : IExtenderProvider /// public bool CanExtend(object o) { - if (!(o is IComponent c)) + if (o is not IComponent component) { return false; } // We don't add modifiers to the base component. - IComponent baseComponent = GetBaseComponent(c); + IComponent? baseComponent = GetBaseComponent(component); if (o == baseComponent) { @@ -43,7 +40,7 @@ public bool CanExtend(object o) // Now see if this object is inherited. If so, then we are interested in it. AttributeCollection attributes = TypeDescriptor.GetAttributes(o); - if (!attributes[typeof(InheritanceAttribute)].Equals(InheritanceAttribute.NotInherited)) + if (!attributes[typeof(InheritanceAttribute)]!.Equals(InheritanceAttribute.NotInherited)) { return true; } @@ -51,31 +48,16 @@ public bool CanExtend(object o) return false; } - private IComponent GetBaseComponent(IComponent c) + private IComponent? GetBaseComponent(IComponent? component) { - IComponent baseComponent = null; - - if (c is null) + if (component is null) { return null; } - if (_host is null) - { - ISite site = c.Site; + _host ??= component.Site?.GetService(); - if (site is not null) - { - _host = (IDesignerHost)site.GetService(typeof(IDesignerHost)); - } - } - - if (_host is not null) - { - baseComponent = _host.RootComponent; - } - - return baseComponent; + return _host?.RootComponent; } /// @@ -92,24 +74,19 @@ private IComponent GetBaseComponent(IComponent c) [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public MemberAttributes GetModifiers(IComponent comp) { - IComponent baseComponent = GetBaseComponent(comp); + IComponent? baseComponent = GetBaseComponent(comp); Debug.Assert(baseComponent is not null, "Root component was null"); Type baseType = baseComponent.GetType(); - ISite site = comp.Site; - - if (site is null) - { - return MemberAttributes.Private; - } + ISite? site = comp.Site; - string name = site.Name; + string? name = site?.Name; if (name is null) { return MemberAttributes.Private; } - FieldInfo field = TypeDescriptor.GetReflectionType(baseType).GetField(name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); + FieldInfo? field = TypeDescriptor.GetReflectionType(baseType).GetField(name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); if (field is not null) { @@ -134,31 +111,29 @@ public MemberAttributes GetModifiers(IComponent comp) // Visual Basic uses a property called Foo and generates a field called _Foo. We need to check the // visibility of this accessor to fix the modifiers up. - PropertyInfo prop = TypeDescriptor.GetReflectionType(baseType).GetProperty(name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); - MethodInfo[] accessors = prop?.GetAccessors(true); - if (accessors is null || accessors.Length == 0 || accessors[0] is null) + PropertyInfo? prop = TypeDescriptor.GetReflectionType(baseType).GetProperty(name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); + MethodInfo?[]? accessors = prop?.GetAccessors(true); + if (accessors is not [MethodInfo methodInfo, ..]) { return MemberAttributes.Private; } - MethodInfo mi = accessors[0]; - - if (mi.IsPrivate) + if (methodInfo.IsPrivate) return MemberAttributes.Private; - if (mi.IsPublic) + if (methodInfo.IsPublic) return MemberAttributes.Public; - if (mi.IsFamily) + if (methodInfo.IsFamily) return MemberAttributes.Family; - if (mi.IsAssembly) + if (methodInfo.IsAssembly) return MemberAttributes.Assembly; - if (mi.IsFamilyOrAssembly) + if (methodInfo.IsFamilyOrAssembly) return MemberAttributes.FamilyOrAssembly; - if (mi.IsFamilyAndAssembly) + if (methodInfo.IsFamilyAndAssembly) return MemberAttributes.FamilyAndAssembly; return MemberAttributes.Private; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.cs index 8c53a74bcf9..ef8471cecc3 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.CodeDom; using System.CodeDom.Compiler; @@ -31,31 +28,31 @@ namespace System.ComponentModel.Design.Serialization; /// public abstract partial class CodeDomDesignerLoader : BasicDesignerLoader, INameCreationService, IDesignerSerializationService { - private static readonly TraceSwitch s_traceCDLoader = new TraceSwitch("CodeDomDesignerLoader", "Trace CodeDomDesignerLoader"); + private static readonly TraceSwitch s_traceCDLoader = new("CodeDomDesignerLoader", "Trace CodeDomDesignerLoader"); private static readonly int s_stateCodeDomDirty = BitVector32.CreateMask(); // True if the code dom tree is dirty, meaning it must be integrated back with the code file. private static readonly int s_stateCodeParserChecked = BitVector32.CreateMask(s_stateCodeDomDirty); // True if we have searched for a parser. private static readonly int s_stateOwnTypeResolution = BitVector32.CreateMask(s_stateCodeParserChecked); // True if we have added our own type resolution service // State for the designer loader. private BitVector32 _state; - private IExtenderProvider[] _extenderProviders; - private IExtenderProviderService _extenderProviderService; + private IExtenderProvider[]? _extenderProviders; + private IExtenderProviderService? _extenderProviderService; // State for the code dom parser / generator - private ICodeGenerator _codeGenerator; + private ICodeGenerator? _codeGenerator; // The following fields are setup by EnsureDocument and deleted by ClearDocument. - private CodeDomSerializer _rootSerializer; - private TypeCodeDomSerializer _typeSerializer; - private CodeCompileUnit _documentCompileUnit; - private CodeNamespace _documentNamespace; - private CodeTypeDeclaration _documentType; + private CodeDomSerializer? _rootSerializer; + private TypeCodeDomSerializer? _typeSerializer; + private CodeCompileUnit? _documentCompileUnit; + private CodeNamespace? _documentNamespace; + private CodeTypeDeclaration? _documentType; /// /// This abstract property returns the code dom provider that should /// be used by this designer loader. /// - protected abstract CodeDomProvider CodeDomProvider { get; } + protected abstract CodeDomProvider? CodeDomProvider { get; } /// /// The TypeResolutionService property returns a type resolution service that the code dom @@ -64,7 +61,7 @@ public abstract partial class CodeDomDesignerLoader : BasicDesignerLoader, IName /// is non-null. While the type resolution service is optional in many scenarios, it is required for /// code interpretation because source code contains type names, but no assembly references. /// - protected abstract ITypeResolutionService TypeResolutionService { get; } + protected abstract ITypeResolutionService? TypeResolutionService { get; } /// /// This is the reverse of EnsureDocument. It clears the document state which will @@ -92,13 +89,13 @@ private void ClearDocument() /// public override void Dispose() { - if (GetService(typeof(IComponentChangeService)) is IComponentChangeService cs) + if (TryGetService(out IComponentChangeService? componentChangeService)) { - cs.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); - cs.ComponentRename -= new ComponentRenameEventHandler(OnComponentRename); + componentChangeService.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); + componentChangeService.ComponentRename -= new ComponentRenameEventHandler(OnComponentRename); } - if (GetService(typeof(IDesignerHost)) is IDesignerHost host) + if (TryGetService(out IDesignerHost? host)) { host.RemoveService(typeof(INameCreationService)); host.RemoveService(typeof(IDesignerSerializationService)); @@ -113,9 +110,9 @@ public override void Dispose() if (_extenderProviderService is not null) { - foreach (IExtenderProvider p in _extenderProviders) + foreach (IExtenderProvider provider in _extenderProviders!) { - _extenderProviderService.RemoveExtenderProvider(p); + _extenderProviderService.RemoveExtenderProvider(provider); } } @@ -126,9 +123,9 @@ public override void Dispose() /// /// Internal debug method to dump a code dom tree to text. /// - internal static void DumpTypeDeclaration(CodeTypeDeclaration typeDecl) + internal static void DumpTypeDeclaration(CodeTypeDeclaration? typeDeclaration) { - if (typeDecl is null || !s_traceCDLoader.TraceVerbose) + if (typeDeclaration is null || !s_traceCDLoader.TraceVerbose) { return; } @@ -138,7 +135,7 @@ internal static void DumpTypeDeclaration(CodeTypeDeclaration typeDecl) try { - codeGenerator.GenerateCodeFromType(typeDecl, sw, null); + codeGenerator.GenerateCodeFromType(typeDeclaration, sw, null!); } catch (Exception ex) { @@ -148,9 +145,9 @@ internal static void DumpTypeDeclaration(CodeTypeDeclaration typeDecl) // spit this line by line so it respects the indent. StringReader sr = new StringReader(sw.ToString()); - for (string ln = sr.ReadLine(); ln is not null; ln = sr.ReadLine()) + for (string? line = sr.ReadLine(); line is not null; line = sr.ReadLine()) { - Debug.WriteLine(ln); + Debug.WriteLine(line); } } #endif @@ -162,9 +159,9 @@ private static bool HasRootDesignerAttribute(Type t) for (int i = 0; i < attributes.Count; i++) { - if (attributes[i] is DesignerAttribute da) + if (attributes[i] is DesignerAttribute designerAttribute) { - Type attributeBaseType = Type.GetType(da.DesignerBaseTypeName); + Type? attributeBaseType = Type.GetType(designerAttribute.DesignerBaseTypeName); if (attributeBaseType is not null && attributeBaseType == typeof(IRootDesigner)) { @@ -187,6 +184,8 @@ private static bool HasRootDesignerAttribute(Type t) /// will throw a human readable exception if any part of the /// process fails. /// + [MemberNotNull(nameof(_documentCompileUnit))] + [MemberNotNull(nameof(_documentType))] private void EnsureDocument(IDesignerSerializationManager manager) { Debug.Assert(manager is not null, "Should pass a serialization manager into EnsureDocument"); @@ -211,43 +210,39 @@ private void EnsureDocument(IDesignerSerializationManager manager) { // We keep track of any failures here. If we failed to find a type this // array list will contain a list of strings listing what we have tried. - List failures = null; + List? failures = null; bool firstClass = true; - if (_documentCompileUnit.UserData[typeof(InvalidOperationException)] is not null) + if (_documentCompileUnit.UserData[typeof(InvalidOperationException)] is InvalidOperationException invalidOperation) { - if (_documentCompileUnit.UserData[typeof(InvalidOperationException)] is InvalidOperationException invalidOp) - { - _documentCompileUnit = null; // not efficient but really a corner case... + _documentCompileUnit = null; // not efficient but really a corner case... - throw invalidOp; - } + throw invalidOperation; } // Look in the compile unit for a class we can load. The first one we find // that has an appropriate serializer attribute, we take. - foreach (CodeNamespace ns in _documentCompileUnit.Namespaces) + foreach (CodeNamespace codeNamespace in _documentCompileUnit.Namespaces) { - foreach (CodeTypeDeclaration typeDecl in ns.Types) + foreach (CodeTypeDeclaration typeDeclaration in codeNamespace.Types) { // Uncover the base type of this class. In case we totally fail // we document each time we were unable to load a particular class. - Type baseType = null; + Type? baseType = null; - foreach (CodeTypeReference typeRef in typeDecl.BaseTypes) + foreach (CodeTypeReference typeReference in typeDeclaration.BaseTypes) { - Type t = LoaderHost.GetType(CodeDomSerializerBase.GetTypeNameFromCodeTypeReference(manager, typeRef)); - - if (t is not null && !(t.IsInterface)) - { - baseType = t; - break; - } + Type? t = LoaderHost.GetType(CodeDomSerializerBase.GetTypeNameFromCodeTypeReference(manager, typeReference)); if (t is null) { failures ??= new(); - failures.Add(string.Format(SR.CodeDomDesignerLoaderDocumentFailureTypeNotFound, typeDecl.Name, typeRef.BaseType)); + failures.Add(string.Format(SR.CodeDomDesignerLoaderDocumentFailureTypeNotFound, typeDeclaration.Name, typeReference.BaseType)); + } + else if (!t.IsInterface) + { + baseType = t; + break; } } @@ -263,14 +258,14 @@ private void EnsureDocument(IDesignerSerializationManager manager) // Walk the member attributes for this type, looking for an appropriate serializer attribute. AttributeCollection attributes = TypeDescriptor.GetAttributes(baseType); - foreach (Attribute attr in attributes) + foreach (Attribute attribute in attributes) { - if (attr is RootDesignerSerializerAttribute ra) + if (attribute is RootDesignerSerializerAttribute serializerAttribute) { // This serializer must support a CodeDomSerializer or we're not interested. - if (ra.SerializerBaseTypeName is not null && LoaderHost.GetType(ra.SerializerBaseTypeName) == typeof(CodeDomSerializer)) + if (serializerAttribute.SerializerBaseTypeName is not null && LoaderHost.GetType(serializerAttribute.SerializerBaseTypeName) == typeof(CodeDomSerializer)) { - Type serializerType = LoaderHost.GetType(ra.SerializerTypeName); + Type? serializerType = LoaderHost.GetType(serializerAttribute.SerializerTypeName!); if (serializerType is not null) { @@ -278,12 +273,12 @@ private void EnsureDocument(IDesignerSerializationManager manager) if (firstClass) { - _rootSerializer = (CodeDomSerializer)Activator.CreateInstance(serializerType, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance, null, null, null); + _rootSerializer = (CodeDomSerializer?)Activator.CreateInstance(serializerType, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance, binder: null, args: null, culture: null); break; } else { - throw new InvalidOperationException(string.Format(SR.CodeDomDesignerLoaderSerializerTypeNotFirstType, typeDecl.Name)); + throw new InvalidOperationException(string.Format(SR.CodeDomDesignerLoaderSerializerTypeNotFirstType, typeDeclaration.Name)); } } } @@ -294,14 +289,14 @@ private void EnsureDocument(IDesignerSerializationManager manager) //that cannot be designed. if (_rootSerializer is null && HasRootDesignerAttribute(baseType)) { - _typeSerializer = manager.GetSerializer(baseType, typeof(TypeCodeDomSerializer)) as TypeCodeDomSerializer; + _typeSerializer = manager.GetSerializer(baseType); if (!firstClass && _typeSerializer is not null) { _typeSerializer = null; _documentCompileUnit = null; - throw new InvalidOperationException(string.Format(SR.CodeDomDesignerLoaderSerializerTypeNotFirstType, typeDecl.Name)); + throw new InvalidOperationException(string.Format(SR.CodeDomDesignerLoaderSerializerTypeNotFirstType, typeDeclaration.Name)); } } @@ -312,11 +307,11 @@ private void EnsureDocument(IDesignerSerializationManager manager) if (foundAttribute) { - failures.Add(string.Format(SR.CodeDomDesignerLoaderDocumentFailureTypeDesignerNotInstalled, typeDecl.Name, baseType.FullName)); + failures.Add(string.Format(SR.CodeDomDesignerLoaderDocumentFailureTypeDesignerNotInstalled, typeDeclaration.Name, baseType.FullName)); } else { - failures.Add(string.Format(SR.CodeDomDesignerLoaderDocumentFailureTypeNotDesignable, typeDecl.Name, baseType.FullName)); + failures.Add(string.Format(SR.CodeDomDesignerLoaderDocumentFailureTypeNotDesignable, typeDeclaration.Name, baseType.FullName)); } } } @@ -324,8 +319,8 @@ private void EnsureDocument(IDesignerSerializationManager manager) // If we found a serializer, then we're done. Save this type and namespace for later use. if (_rootSerializer is not null || _typeSerializer is not null) { - _documentNamespace = ns; - _documentType = typeDecl; + _documentNamespace = codeNamespace; + _documentType = typeDeclaration; break; } @@ -379,13 +374,15 @@ private void EnsureDocument(IDesignerSerializationManager manager) /// tree stored in _documentCompileUnit. This returns true if any changes /// were made to the tree. /// + [MemberNotNull(nameof(_documentCompileUnit))] + [MemberNotNull(nameof(_documentType))] private bool IntegrateSerializedTree(IDesignerSerializationManager manager, CodeTypeDeclaration newDecl) { EnsureDocument(manager); - CodeTypeDeclaration docDecl = _documentType; + CodeTypeDeclaration docDeclaration = _documentType; bool caseInsensitive = false; bool codeDomDirty = false; - CodeDomProvider provider = CodeDomProvider; + CodeDomProvider? provider = CodeDomProvider; if (provider is not null) { @@ -393,15 +390,15 @@ private bool IntegrateSerializedTree(IDesignerSerializationManager manager, Code } // Update the class name of the code type, in case it is different. - if (!string.Equals(docDecl.Name, newDecl.Name, caseInsensitive ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal)) + if (!string.Equals(docDeclaration.Name, newDecl.Name, caseInsensitive ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal)) { - docDecl.Name = newDecl.Name; + docDeclaration.Name = newDecl.Name; codeDomDirty = true; } - if (!docDecl.Attributes.Equals(newDecl.Attributes)) + if (!docDeclaration.Attributes.Equals(newDecl.Attributes)) { - docDecl.Attributes = newDecl.Attributes; + docDeclaration.Attributes = newDecl.Attributes; codeDomDirty = true; } @@ -413,28 +410,20 @@ private bool IntegrateSerializedTree(IDesignerSerializationManager manager, Code bool lockField = false; int methodInsertLocation = 0; bool lockMethod = false; - Dictionary docMemberHash = new(docDecl.Members.Count, caseInsensitive + Dictionary docMemberHash = new(docDeclaration.Members.Count, caseInsensitive ? StringComparer.InvariantCultureIgnoreCase : StringComparer.InvariantCulture); - int memberCount = docDecl.Members.Count; + int memberCount = docDeclaration.Members.Count; for (int i = 0; i < memberCount; i++) { - CodeTypeMember member = docDecl.Members[i]; - string memberName; - - if (member is CodeConstructor) - { - memberName = ".ctor"; - } - else if (member is CodeTypeConstructor) - { - memberName = ".cctor"; - } - else + CodeTypeMember member = docDeclaration.Members[i]; + string memberName = member switch { - memberName = member.Name; - } + CodeConstructor => ".ctor", + CodeTypeConstructor => ".cctor", + _ => member.Name, + }; docMemberHash[memberName] = i; @@ -479,7 +468,7 @@ private bool IntegrateSerializedTree(IDesignerSerializationManager manager, Code string memberName = member is CodeConstructor ? ".ctor" : member.Name; if (docMemberHash.TryGetValue(memberName, out int slot)) { - CodeTypeMember existingMember = docDecl.Members[slot]; + CodeTypeMember existingMember = docDeclaration.Members[slot]; if (existingMember == member) { @@ -497,7 +486,7 @@ private bool IntegrateSerializedTree(IDesignerSerializationManager manager, Code } else { - docDecl.Members[slot] = member; + docDeclaration.Members[slot] = member; } } else @@ -523,7 +512,7 @@ private bool IntegrateSerializedTree(IDesignerSerializationManager manager, Code } else { - docDecl.Members[slot] = member; + docDeclaration.Members[slot] = member; } codeDomDirty = true; @@ -539,13 +528,13 @@ private bool IntegrateSerializedTree(IDesignerSerializationManager manager, Code { if (member is CodeMemberField) { - if (fieldInsertLocation >= docDecl.Members.Count) + if (fieldInsertLocation >= docDeclaration.Members.Count) { - docDecl.Members.Add(member); + docDeclaration.Members.Add(member); } else { - docDecl.Members.Insert(fieldInsertLocation, member); + docDeclaration.Members.Insert(fieldInsertLocation, member); } fieldInsertLocation++; @@ -554,13 +543,13 @@ private bool IntegrateSerializedTree(IDesignerSerializationManager manager, Code } else if (member is CodeMemberMethod) { - if (methodInsertLocation >= docDecl.Members.Count) + if (methodInsertLocation >= docDeclaration.Members.Count) { - docDecl.Members.Add(member); + docDeclaration.Members.Add(member); } else { - docDecl.Members.Insert(methodInsertLocation, member); + docDeclaration.Members.Insert(methodInsertLocation, member); } methodInsertLocation++; @@ -569,7 +558,7 @@ private bool IntegrateSerializedTree(IDesignerSerializationManager manager, Code else { // For rare members, just add them to the end. - docDecl.Members.Add(member); + docDeclaration.Members.Add(member); codeDomDirty = true; } } @@ -597,22 +586,20 @@ protected override void Initialize() // The code dom designer loader requires a working ITypeResolutionService to // function. See if someone added one already, and if not, provide // our own. - if (GetService(typeof(ITypeResolutionService)) is null) + if (!TryGetService(out ITypeResolutionService? typeResolutionService)) { - ITypeResolutionService trs = TypeResolutionService; + typeResolutionService = TypeResolutionService; - if (trs is null) + if (typeResolutionService is null) { throw new InvalidOperationException(SR.CodeDomDesignerLoaderNoTypeResolution); } - LoaderHost.AddService(typeof(ITypeResolutionService), trs); + LoaderHost.AddService(typeof(ITypeResolutionService), typeResolutionService); _state[s_stateOwnTypeResolution] = true; } - _extenderProviderService = GetService(typeof(IExtenderProviderService)) as IExtenderProviderService; - - if (_extenderProviderService is not null) + if (TryGetService(out _extenderProviderService)) { _extenderProviders = new IExtenderProvider[] { @@ -649,7 +636,7 @@ protected override bool IsReloadNeeded() // If we can't get to a code dom provider, or if that provider doesn't // implement ICodeDomDesignerReload, we can't optimize the reload, so we // just assume it is needed. - if (!(CodeDomProvider is ICodeDomDesignerReload reloader)) + if (CodeDomProvider is not ICodeDomDesignerReload reloader) { return true; } @@ -663,7 +650,7 @@ protected override bool IsReloadNeeded() try { ClearDocument(); - EnsureDocument(GetService(typeof(IDesignerSerializationManager)) as IDesignerSerializationManager); + EnsureDocument(GetService()!); } catch { @@ -698,12 +685,11 @@ protected override bool IsReloadNeeded() protected override void OnBeginLoad() { // Make sure that we're removed any event sinks we added after we finished the load. - IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); - if (cs is not null) + if (TryGetService(out IComponentChangeService? componentChangeService)) { - cs.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); - cs.ComponentRename -= new ComponentRenameEventHandler(OnComponentRename); + componentChangeService.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); + componentChangeService.ComponentRename -= new ComponentRenameEventHandler(OnComponentRename); } base.OnBeginLoad(); @@ -725,9 +711,9 @@ protected override void OnBeginUnload() /// /// This is called whenever a component is removed from the design surface. /// - private void OnComponentRemoved(object sender, ComponentEventArgs e) + private void OnComponentRemoved(object? sender, ComponentEventArgs e) { - string name = e.Component.Site.Name; + string? name = e.Component!.Site!.Name; RemoveDeclaration(name); } @@ -736,15 +722,15 @@ private void OnComponentRemoved(object sender, ComponentEventArgs e) /// and then whack the component declaration. At the next code gen /// cycle we will recreate the declaration. /// - private void OnComponentRename(object sender, ComponentRenameEventArgs e) + private void OnComponentRename(object? sender, ComponentRenameEventArgs e) { - OnComponentRename(e.Component, e.OldName, e.NewName); + OnComponentRename(e.Component!, e.OldName, e.NewName); } /// /// Callback to create our demand-created services. /// - private object OnCreateService(IServiceContainer container, Type serviceType) + private object? OnCreateService(IServiceContainer container, Type serviceType) { if (serviceType == typeof(ComponentSerializationService)) { @@ -768,7 +754,7 @@ private object OnCreateService(IServiceContainer container, Type serviceType) /// indirectly by calling DependentLoadComplete if IDesignerLoaderService /// is available, or directly if it is not. /// - protected override void OnEndLoad(bool successful, ICollection errors) + protected override void OnEndLoad(bool successful, ICollection? errors) { base.OnEndLoad(successful, errors); @@ -779,9 +765,7 @@ protected override void OnEndLoad(bool successful, ICollection errors) // After a successful load we will want to monitor a bunch of events so we know when // to make the loader dirty. - IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); - - if (cs is null) + if (!TryGetService(out IComponentChangeService? cs)) { return; } @@ -802,7 +786,7 @@ protected override void OnEndLoad(bool successful, ICollection errors) /// protected override void PerformFlush(IDesignerSerializationManager manager) { - CodeTypeDeclaration typeDecl = null; + CodeTypeDeclaration? typeDeclaration = null; // Ask the serializer for the root component to serialize. This should return // a CodeTypeDeclaration, which we will plug into our existing code DOM tree. @@ -810,18 +794,18 @@ protected override void PerformFlush(IDesignerSerializationManager manager) if (_rootSerializer is not null) { - typeDecl = _rootSerializer.Serialize(manager, LoaderHost.RootComponent) as CodeTypeDeclaration; - Debug.Assert(typeDecl is not null, "Root CodeDom serializer must return a CodeTypeDeclaration"); + typeDeclaration = _rootSerializer.Serialize(manager, LoaderHost.RootComponent) as CodeTypeDeclaration; + Debug.Assert(typeDeclaration is not null, "Root CodeDom serializer must return a CodeTypeDeclaration"); } else if (_typeSerializer is not null) { - typeDecl = _typeSerializer.Serialize(manager, LoaderHost.RootComponent, LoaderHost.Container.Components); + typeDeclaration = _typeSerializer.Serialize(manager, LoaderHost.RootComponent, LoaderHost.Container.Components); } #if DEBUG if (s_traceCDLoader.TraceVerbose) { Debug.WriteLine("****************** Pre-integrated tree **********************"); - DumpTypeDeclaration(typeDecl); + DumpTypeDeclaration(typeDeclaration); EnsureDocument(manager); Debug.WriteLine("****************** Live tree **********************"); DumpTypeDeclaration(_documentType); @@ -831,7 +815,7 @@ protected override void PerformFlush(IDesignerSerializationManager manager) // Now we must integrate the code DOM tree from the serializer with // our own tree. If changes were made to the tree this will // return true. - if (typeDecl is not null && IntegrateSerializedTree(manager, typeDecl)) + if (typeDeclaration is not null && IntegrateSerializedTree(manager, typeDeclaration)) { #if DEBUG if (s_traceCDLoader.TraceVerbose) @@ -873,7 +857,7 @@ protected override void PerformLoad(IDesignerSerializationManager manager) } else { - _typeSerializer.Deserialize(manager, _documentType); + _typeSerializer!.Deserialize(manager, _documentType); } SetBaseComponentClassName($"{_documentNamespace.Name}.{_documentType.Name}"); @@ -883,7 +867,7 @@ protected override void PerformLoad(IDesignerSerializationManager manager) /// This virtual method gets override in the VsCodeDomDesignerLoader to call the RenameElement on the /// ChangeNotificationService to rename the component name through out the project scope. /// - protected virtual void OnComponentRename(object component, string oldName, string newName) + protected virtual void OnComponentRename(object component, string? oldName, string? newName) { if (LoaderHost.RootComponent == component) { @@ -904,8 +888,8 @@ protected virtual void OnComponentRename(object component, string oldName, strin for (int i = 0; i < members.Count; i++) { - if (members[i] is CodeMemberField && members[i].Name.Equals(oldName) - && ((CodeMemberField)members[i]).Type.BaseType.Equals(TypeDescriptor.GetClassName(component))) + if (members[i] is CodeMemberField field && members[i].Name.Equals(oldName) + && field.Type.BaseType.Equals(TypeDescriptor.GetClassName(component))) { members[i].Name = newName; break; @@ -917,7 +901,7 @@ protected virtual void OnComponentRename(object component, string oldName, strin /// This is called when a component is deleted or renamed. We remove /// the component's declaration here, if it exists. /// - private void RemoveDeclaration(string name) + private void RemoveDeclaration(string? name) { if (_documentType is null) { @@ -936,19 +920,6 @@ private void RemoveDeclaration(string name) } } - /// - /// Simple helper routine that will throw an exception if we need a service, but cannot get - /// to it. You should only throw for missing services that are absolutely essential for - /// operation. If there is a way to gracefully degrade, then you should do it. - /// - private static void ThrowMissingService(Type serviceType) - { - Exception ex = new InvalidOperationException(string.Format(SR.BasicDesignerLoaderMissingService, serviceType.Name)); - ex.HelpLink = SR.BasicDesignerLoaderMissingService; - - throw ex; - } - /// /// Determines of two type references are equal. /// @@ -992,7 +963,7 @@ private static bool TypesEqual(CodeTypeReference typeLeft, CodeTypeReference typ if (typeLeft.ArrayRank > 0) { - return TypesEqual(typeLeft.ArrayElementType, typeRight.ArrayElementType); + return TypesEqual(typeLeft.ArrayElementType!, typeRight.ArrayElementType!); } return true; @@ -1014,7 +985,7 @@ private static bool TypesEqual(CodeTypeReference typeLeft, CodeTypeReference typ /// ICollection IDesignerSerializationService.Deserialize(object serializationData) { - if (!(serializationData is SerializationStore)) + if (serializationData is not SerializationStore data) { Exception ex = new ArgumentException(SR.CodeDomDesignerLoaderBadSerializationObject); ex.HelpLink = SR.CodeDomDesignerLoaderBadSerializationObject; @@ -1022,14 +993,8 @@ ICollection IDesignerSerializationService.Deserialize(object serializationData) throw ex; } - ComponentSerializationService css = GetService(typeof(ComponentSerializationService)) as ComponentSerializationService; - - if (css is null) - { - ThrowMissingService(typeof(ComponentSerializationService)); - } - - return css.Deserialize((SerializationStore)serializationData, LoaderHost.Container); + ComponentSerializationService css = GetRequiredService(); + return css.Deserialize(data, LoaderHost.Container); } /// @@ -1037,17 +1002,11 @@ ICollection IDesignerSerializationService.Deserialize(object serializationData) /// stores them in an opaque serialization data object. /// The returning object fully supports runtime serialization. /// - object IDesignerSerializationService.Serialize(ICollection objects) + object IDesignerSerializationService.Serialize(ICollection? objects) { objects ??= Array.Empty(); - ComponentSerializationService css = GetService(typeof(ComponentSerializationService)) as ComponentSerializationService; - - if (css is null) - { - ThrowMissingService(typeof(ComponentSerializationService)); - } - + ComponentSerializationService css = GetRequiredService(); SerializationStore store = css.CreateStore(); using (store) @@ -1067,7 +1026,7 @@ object IDesignerSerializationService.Serialize(ICollection objects) /// an object of the given data type, so the service may /// derive a name from the data type's name. /// - string INameCreationService.CreateName(IContainer container, Type dataType) + string INameCreationService.CreateName(IContainer? container, Type dataType) { ArgumentNullException.ThrowIfNull(dataType); @@ -1092,7 +1051,7 @@ string INameCreationService.CreateName(IContainer container, Type dataType) }); // Now hash up all of the member variable names using a case insensitive hash. - CodeTypeDeclaration type = _documentType; + CodeTypeDeclaration? type = _documentType; HashSet memberHash = new(StringComparer.CurrentCultureIgnoreCase); if (type is not null) @@ -1140,7 +1099,7 @@ string INameCreationService.CreateName(IContainer container, Type dataType) // generator to ensure it's not a keyword. if (_codeGenerator is null) { - CodeDomProvider provider = CodeDomProvider; + CodeDomProvider? provider = CodeDomProvider; if (provider is not null) { @@ -1173,7 +1132,7 @@ bool INameCreationService.IsValidName(string name) if (_codeGenerator is null) { - CodeDomProvider provider = CodeDomProvider; + CodeDomProvider? provider = CodeDomProvider; if (provider is not null) { @@ -1199,7 +1158,7 @@ bool INameCreationService.IsValidName(string name) // parser, so of course there will be duplicates. if (!Loading) { - CodeTypeDeclaration type = _documentType; + CodeTypeDeclaration? type = _documentType; if (type is not null) { @@ -1248,7 +1207,7 @@ void INameCreationService.ValidateName(string name) if (_codeGenerator is null) { - CodeDomProvider provider = CodeDomProvider; + CodeDomProvider? provider = CodeDomProvider; if (provider is not null) { @@ -1287,7 +1246,7 @@ void INameCreationService.ValidateName(string name) // because during load these members are being added by the // parser, so of course there will be duplicates. bool dup = false; - CodeTypeDeclaration type = _documentType; + CodeTypeDeclaration? type = _documentType; if (type is not null) { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationModel.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationModel.cs index ac611e1aac2..2534a78227c 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationModel.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationModel.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.LanguageCultureInfoConverter.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.LanguageCultureInfoConverter.cs index 7bdcb3caba9..08f6e3c2beb 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.LanguageCultureInfoConverter.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.LanguageCultureInfoConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.LanguageExtenders.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.LanguageExtenders.cs index 01f25252fc4..07b738c2525 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.LanguageExtenders.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.LanguageExtenders.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.cs index 95118a91c4e..a5d9639ac06 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomLocalizationProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializationProvider.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializationProvider.cs index 3e9a240168a..5dc79df25e4 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializationProvider.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializationProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializer.cs index 786893c0706..25d4693cf24 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializer.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.CodeDom; @@ -15,20 +12,13 @@ namespace System.ComponentModel.Design.Serialization; [DefaultSerializationProvider(typeof(CodeDomSerializationProvider))] public class CodeDomSerializer : CodeDomSerializerBase { - private static CodeDomSerializer s_default; - private static readonly Attribute[] _runTimeFilter = new Attribute[] { DesignOnlyAttribute.No }; - private static readonly Attribute[] _designTimeFilter = new Attribute[] { DesignOnlyAttribute.Yes }; - private static readonly CodeThisReferenceExpression _thisRef = new CodeThisReferenceExpression(); - - internal static CodeDomSerializer Default - { - get - { - s_default ??= new CodeDomSerializer(); + private static CodeDomSerializer? s_default; + private static readonly Attribute[] s_runTimeFilter = { DesignOnlyAttribute.No }; + private static readonly Attribute[] s_designTimeFilter = { DesignOnlyAttribute.Yes }; + private static readonly Attribute[] s_deserializeFilter = { BrowsableAttribute.Yes }; + private static readonly CodeThisReferenceExpression s_thisRef = new(); - return s_default; - } - } + internal static CodeDomSerializer Default => s_default ??= new CodeDomSerializer(); /// /// Determines which statement group the given statement should belong to. The expression parameter @@ -36,19 +26,14 @@ internal static CodeDomSerializer Default /// of this statement. This method returns the name of the component this statement should be grouped /// with. /// - public virtual string GetTargetComponentName(CodeStatement statement, CodeExpression expression, Type targetType) + public virtual string? GetTargetComponentName(CodeStatement? statement, CodeExpression? expression, Type? targetType) { - string name = null; - if (expression is CodeVariableReferenceExpression variableReferenceEx) + return expression switch { - name = variableReferenceEx.VariableName; - } - else if (expression is CodeFieldReferenceExpression fieldReferenceEx) - { - name = fieldReferenceEx.FieldName; - } - - return name; + CodeVariableReferenceExpression variableReferenceEx => variableReferenceEx.VariableName, + CodeFieldReferenceExpression fieldReferenceEx => fieldReferenceEx.FieldName, + _ => null, + }; } /// @@ -56,9 +41,9 @@ public virtual string GetTargetComponentName(CodeStatement statement, CodeExpres /// will use the serialization manager to create objects and resolve /// data types. The root of the object graph is returned. /// - public virtual object Deserialize(IDesignerSerializationManager manager, object codeObject) + public virtual object? Deserialize(IDesignerSerializationManager manager, object codeObject) { - object instance = null; + object? instance = null; ArgumentNullException.ThrowIfNull(manager); ArgumentNullException.ThrowIfNull(codeObject); @@ -69,46 +54,40 @@ public virtual object Deserialize(IDesignerSerializationManager manager, object { instance = DeserializeExpression(manager, null, expression); } - else + else if (codeObject is CodeStatementCollection statements) { - if (codeObject is CodeStatementCollection statements) + foreach (CodeStatement element in statements) { - foreach (CodeStatement element in statements) + // If we do not yet have an instance, we will need to pick through the statements and see if we can find one. + if (instance is null) { - // If we do not yet have an instance, we will need to pick through the statements and see if we can find one. - if (instance is null) + instance = DeserializeStatementToInstance(manager, element); + if (instance is not null) { - instance = DeserializeStatementToInstance(manager, element); - if (instance is not null) + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(instance, s_deserializeFilter); + foreach (PropertyDescriptor prop in props) { - PropertyDescriptorCollection props = TypeDescriptor.GetProperties(instance, new Attribute[] { BrowsableAttribute.Yes }); - foreach (PropertyDescriptor prop in props) + if (!prop.Attributes.Contains(DesignerSerializationVisibilityAttribute.Hidden) && + prop.Attributes.Contains(DesignerSerializationVisibilityAttribute.Content) && + manager.GetSerializer(prop.PropertyType, typeof(CodeDomSerializer)) is not CollectionCodeDomSerializer) { - if (!prop.Attributes.Contains(DesignerSerializationVisibilityAttribute.Hidden) && - prop.Attributes.Contains(DesignerSerializationVisibilityAttribute.Content) && - !(manager.GetSerializer(prop.PropertyType, typeof(CodeDomSerializer)) is CollectionCodeDomSerializer)) - { - ResetBrowsableProperties(prop.GetValue(instance)); - } + ResetBrowsableProperties(prop.GetValue(instance)); } } } - else - { - DeserializeStatement(manager, element); - } } - } - else - { - if (!(codeObject is CodeStatement statement)) + else { - Debug.Fail("CodeDomSerializer::Deserialize requires a CodeExpression, CodeStatement or CodeStatementCollection to parse"); - string supportedTypes = $"{nameof(CodeExpression)}, {nameof(CodeStatement)}, {nameof(CodeStatementCollection)}"; - throw new ArgumentException(string.Format(SR.SerializerBadElementTypes, codeObject.GetType().Name, supportedTypes)); + DeserializeStatement(manager, element); } } } + else if (codeObject is not CodeStatement) + { + Debug.Fail("CodeDomSerializer::Deserialize requires a CodeExpression, CodeStatement or CodeStatementCollection to parse"); + string supportedTypes = $"{nameof(CodeExpression)}, {nameof(CodeStatement)}, {nameof(CodeStatementCollection)}"; + throw new ArgumentException(string.Format(SR.SerializerBadElementTypes, codeObject.GetType().Name, supportedTypes)); + } } return instance; @@ -120,9 +99,9 @@ public virtual object Deserialize(IDesignerSerializationManager manager, object /// resulting statement was a variable assign statement, a variable /// declaration with an init expression, or a field assign statement. /// - protected object DeserializeStatementToInstance(IDesignerSerializationManager manager, CodeStatement statement) + protected object? DeserializeStatementToInstance(IDesignerSerializationManager manager, CodeStatement statement) { - object instance = null; + object? instance = null; if (statement is CodeAssignStatement assign) { if (assign.Left is CodeFieldReferenceExpression fieldRef) @@ -130,20 +109,17 @@ protected object DeserializeStatementToInstance(IDesignerSerializationManager ma Trace(TraceLevel.Verbose, $"Assigning instance to field {fieldRef.FieldName}"); instance = DeserializeExpression(manager, fieldRef.FieldName, assign.Right); } + else if (assign.Left is CodeVariableReferenceExpression varRef) + { + Trace(TraceLevel.Verbose, $"Assigning instance to variable {varRef.VariableName}"); + instance = DeserializeExpression(manager, varRef.VariableName, assign.Right); + } else { - if (assign.Left is CodeVariableReferenceExpression varRef) - { - Trace(TraceLevel.Verbose, $"Assigning instance to variable {varRef.VariableName}"); - instance = DeserializeExpression(manager, varRef.VariableName, assign.Right); - } - else - { - DeserializeStatement(manager, assign); - } + DeserializeStatement(manager, assign); } } - else if (statement is CodeVariableDeclarationStatement varDecl && varDecl.InitExpression is not null) + else if (statement is CodeVariableDeclarationStatement { InitExpression: not null } varDecl) { Trace(TraceLevel.Verbose, $"Initializing variable declaration for variable {varDecl.Name}"); instance = DeserializeExpression(manager, varDecl.Name, varDecl.InitExpression); @@ -160,9 +136,9 @@ protected object DeserializeStatementToInstance(IDesignerSerializationManager ma /// /// Serializes the given object into a CodeDom object. /// - public virtual object Serialize(IDesignerSerializationManager manager, object value) + public virtual object? Serialize(IDesignerSerializationManager manager, object value) { - object result = null; + object? result = null; ArgumentNullException.ThrowIfNull(manager); ArgumentNullException.ThrowIfNull(value); @@ -170,31 +146,20 @@ public virtual object Serialize(IDesignerSerializationManager manager, object va { Trace(TraceLevel.Verbose, $"Type: {value.GetType().Name}"); - if (value is Type) + if (value is Type type) { - result = new CodeTypeOfExpression((Type)value); + result = new CodeTypeOfExpression(type); } else { bool isComplete = false; - bool isPreset; - CodeExpression expression = SerializeCreationExpression(manager, value, out bool isCompleteExpression); + CodeExpression? expression = SerializeCreationExpression(manager, value, out bool isCompleteExpression); // if the object is not a component we will honor the return value from SerializeCreationExpression. For compat reasons we ignore the value if the object is a component. - if (!(value is IComponent)) + if (value is not IComponent) { isComplete = isCompleteExpression; } - // We need to find out if SerializeCreationExpression returned a preset expression. - if (manager.Context[typeof(ExpressionContext)] is ExpressionContext ctx && ReferenceEquals(ctx.PresetValue, value)) - { - isPreset = true; - } - else - { - isPreset = false; - } - TraceIf(TraceLevel.Verbose, expression is null, "Unable to create object; aborting."); // Short circuit common cases if (expression is not null) @@ -209,28 +174,30 @@ public virtual object Serialize(IDesignerSerializationManager manager, object va // Ok, we have an incomplete expression. That means we've created the object but we will need to set properties on it to configure it. Therefore, we need to have a variable reference to it unless we were given a preset expression already. CodeStatementCollection statements = new CodeStatementCollection(); + // We need to find out if SerializeCreationExpression returned a preset expression. + bool isPreset = manager.TryGetContext(out ExpressionContext? ctx) && ReferenceEquals(ctx.PresetValue, value); + if (isPreset) { SetExpression(manager, value, expression, true); } else { - CodeExpression variableReference; string varName = GetUniqueName(manager, value); - string varTypeName = TypeDescriptor.GetClassName(value); + string? varTypeName = TypeDescriptor.GetClassName(value); - CodeVariableDeclarationStatement varDecl = new CodeVariableDeclarationStatement(varTypeName, varName); + CodeVariableDeclarationStatement varDecl = new CodeVariableDeclarationStatement(varTypeName!, varName); Trace(TraceLevel.Verbose, $"Generating local : {varName}"); varDecl.InitExpression = expression; statements.Add(varDecl); - variableReference = new CodeVariableReferenceExpression(varName); + CodeExpression variableReference = new CodeVariableReferenceExpression(varName); SetExpression(manager, value, variableReference); } // Finally, we need to walk properties and events for this object - SerializePropertiesToResources(manager, statements, value, _designTimeFilter); - SerializeProperties(manager, statements, value, _runTimeFilter); - SerializeEvents(manager, statements, value, _runTimeFilter); + SerializePropertiesToResources(manager, statements, value, s_designTimeFilter); + SerializeProperties(manager, statements, value, s_runTimeFilter); + SerializeEvents(manager, statements, value, s_runTimeFilter); result = statements; } } @@ -243,9 +210,9 @@ public virtual object Serialize(IDesignerSerializationManager manager, object va /// /// Serializes the given object into a CodeDom object. /// - public virtual object SerializeAbsolute(IDesignerSerializationManager manager, object value) + public virtual object? SerializeAbsolute(IDesignerSerializationManager manager, object value) { - object data; + object? data; SerializeAbsoluteContext abs = new SerializeAbsoluteContext(); manager.Context.Push(abs); try @@ -272,7 +239,7 @@ public virtual CodeStatementCollection SerializeMember(IDesignerSerializationMan CodeStatementCollection statements = new CodeStatementCollection(); // See if we have an existing expression for this member. If not, fabricate one - CodeExpression expression = GetExpression(manager, owningObject); + CodeExpression? expression = GetExpression(manager, owningObject); if (expression is null) { string name = GetUniqueName(manager, owningObject); @@ -284,16 +251,13 @@ public virtual CodeStatementCollection SerializeMember(IDesignerSerializationMan { SerializeProperty(manager, statements, owningObject, property); } + else if (member is EventDescriptor evt) + { + SerializeEvent(manager, statements, owningObject, evt); + } else { - if (member is EventDescriptor evt) - { - SerializeEvent(manager, statements, owningObject, evt); - } - else - { - throw new NotSupportedException(string.Format(SR.SerializerMemberTypeNotSerializable, member.GetType().FullName)); - } + throw new NotSupportedException(string.Format(SR.SerializerMemberTypeNotSerializable, member.GetType().FullName)); } return statements; @@ -333,9 +297,9 @@ public virtual CodeStatementCollection SerializeMemberAbsolute(IDesignerSerializ /// of a statement. /// [Obsolete("This method has been deprecated. Use SerializeToExpression or GetExpression instead. https://go.microsoft.com/fwlink/?linkid=14202")] - protected CodeExpression SerializeToReferenceExpression(IDesignerSerializationManager manager, object value) + protected CodeExpression? SerializeToReferenceExpression(IDesignerSerializationManager manager, object value) { - CodeExpression expression = null; + CodeExpression? expression = null; using (TraceScope($"CodeDomSerializer::{nameof(SerializeToReferenceExpression)}")) { // First - try GetExpression @@ -343,11 +307,11 @@ protected CodeExpression SerializeToReferenceExpression(IDesignerSerializationMa // Next, we check for a named IComponent, and return a reference to it. if (expression is null && value is IComponent) { - string name = manager.GetName(value); + string? name = manager.GetName(value); bool referenceName = false; if (name is null) { - IReferenceService referenceService = (IReferenceService)manager.GetService(typeof(IReferenceService)); + IReferenceService? referenceService = manager.GetService(); if (referenceService is not null) { name = referenceService.GetName(value); @@ -359,20 +323,22 @@ protected CodeExpression SerializeToReferenceExpression(IDesignerSerializationMa { Trace(TraceLevel.Verbose, $"Object is reference ({name}) Creating reference expression"); // Check to see if this is a reference to the root component. If it is, then use "this". - RootContext root = (RootContext)manager.Context[typeof(RootContext)]; - if (root is not null && root.Value == value) + if (manager.TryGetContext(out RootContext? root) && root.Value == value) { expression = root.Expression; } - else if (referenceName && name.IndexOf('.') != -1) - { - // if it's a reference name with a dot, we've actually got a property here... - int dotIndex = name.IndexOf('.'); - expression = new CodePropertyReferenceExpression(new CodeFieldReferenceExpression(_thisRef, name.Substring(0, dotIndex)), name.Substring(dotIndex + 1)); - } else { - expression = new CodeFieldReferenceExpression(_thisRef, name); + int dotIndex = name.IndexOf('.'); + if (referenceName && dotIndex != -1) + { + // if it's a reference name with a dot, we've actually got a property here... + expression = new CodePropertyReferenceExpression(new CodeFieldReferenceExpression(s_thisRef, name.Substring(0, dotIndex)), name.Substring(dotIndex + 1)); + } + else + { + expression = new CodeFieldReferenceExpression(s_thisRef, name); + } } } } @@ -381,7 +347,7 @@ protected CodeExpression SerializeToReferenceExpression(IDesignerSerializationMa return expression; } - private static void ResetBrowsableProperties(object instance) + private static void ResetBrowsableProperties(object? instance) { if (instance is null) { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.TraceIfInterpolatedStringHandler.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.TraceIfInterpolatedStringHandler.cs index 7cb71a2ddd2..91ec5cee610 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.TraceIfInterpolatedStringHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.TraceIfInterpolatedStringHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Text; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.TraceInterpolatedStringHandler.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.TraceInterpolatedStringHandler.cs index d68c981fc09..09b3f653dd4 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.TraceInterpolatedStringHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.TraceInterpolatedStringHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Text; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.cs index c9b2b3e0dcf..5beb904d73b 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; using System.Collections; @@ -20,7 +19,7 @@ namespace System.ComponentModel.Design.Serialization; public abstract partial class CodeDomSerializerBase { private static readonly Attribute[] runTimeProperties = new Attribute[] { DesignOnlyAttribute.No }; - private static readonly TraceSwitch traceSerialization = new TraceSwitch("DesignerSerialization", "Trace design time serialization"); + private static readonly TraceSwitch traceSerialization = new("DesignerSerialization", "Trace design time serialization"); #pragma warning disable CS0649 private static Stack? traceScope; #pragma warning restore CS0649 @@ -581,7 +580,7 @@ private void DeserializeAssignStatement(IDesignerSerializationManager manager, C { // Since we're doing an assignment into something, we need to know what that something is. It can be a property, a variable, or a member. Anything else is invalid. //Perf: is -> as changes, change ordering based on possibility of occurrence - CodeExpression? expression = statement.Left; + CodeExpression expression = statement.Left; Trace(TraceLevel.Verbose, "Processing LHS"); if (expression is CodePropertyReferenceExpression propertyReferenceEx) @@ -2574,7 +2573,7 @@ protected void SerializeResourceInvariant(IDesignerSerializationManager manager, object? result = null; try { - result = serializer.Serialize(manager, value); + result = serializer.Serialize(manager, value!); } finally { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerException.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerException.cs index e89f8eb38a9..a77297e0b81 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerException.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerException.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.CodeDom; using System.Runtime.Serialization; @@ -14,22 +11,22 @@ namespace System.ComponentModel.Design.Serialization; /// public class CodeDomSerializerException : SystemException { - public CodeDomSerializerException(string message, CodeLinePragma linePragma) : base(message) + public CodeDomSerializerException(string? message, CodeLinePragma? linePragma) : base(message) { LinePragma = linePragma; } - public CodeDomSerializerException(Exception ex, CodeLinePragma linePragma) : base(ex?.Message, ex) + public CodeDomSerializerException(Exception? ex, CodeLinePragma? linePragma) : base(ex?.Message, ex) { LinePragma = linePragma; } - public CodeDomSerializerException(string message, IDesignerSerializationManager manager) : base(message) + public CodeDomSerializerException(string? message, IDesignerSerializationManager manager) : base(message) { ArgumentNullException.ThrowIfNull(manager); } - public CodeDomSerializerException(Exception ex, IDesignerSerializationManager manager) : base(ex?.Message, ex) + public CodeDomSerializerException(Exception? ex, IDesignerSerializationManager manager) : base(ex?.Message, ex) { ArgumentNullException.ThrowIfNull(manager); } @@ -37,7 +34,7 @@ public CodeDomSerializerException(Exception ex, IDesignerSerializationManager ma /// /// Gets the line pragma object that is related to this error. /// - public CodeLinePragma LinePragma { get; } + public CodeLinePragma? LinePragma { get; } [Obsolete(DiagnosticId = "SYSLIB0051")] public override void GetObjectData(SerializationInfo info, StreamingContext context) diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeMethodMap.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeMethodMap.cs index 941485b9517..83c62be8827 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeMethodMap.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeMethodMap.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CollectionCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CollectionCodeDomSerializer.cs index 928a5d464cc..a82aa03c151 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CollectionCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CollectionCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentCache.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentCache.cs index cfd62ce5859..8587bb41679 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentCache.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentCache.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentCodeDomSerializer.cs index 8f1721734cb..be4e184e463 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentTypeCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentTypeCodeDomSerializer.cs index fd32e9f29e9..ed1709a353a 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentTypeCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentTypeCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -13,7 +12,7 @@ namespace System.ComponentModel.Design.Serialization; /// internal class ComponentTypeCodeDomSerializer : TypeCodeDomSerializer { - private static readonly object _initMethodKey = new object(); + private static readonly object _initMethodKey = new(); private const string _initMethodName = "InitializeComponent"; private static ComponentTypeCodeDomSerializer s_default; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ContainerCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ContainerCodeDomSerializer.cs index cdaa48c4c77..c52006f1bb5 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ContainerCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ContainerCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/DesignerSerializationManager.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/DesignerSerializationManager.cs index 332b31a6689..458c0a03f30 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/DesignerSerializationManager.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/DesignerSerializationManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Reflection; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EnumCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EnumCodeDomSerializer.cs index a00c7dbbe3a..287512fb398 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EnumCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EnumCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EventMemberCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EventMemberCodeDomSerializer.cs index d3d52a38158..a70ba59c277 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EventMemberCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EventMemberCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -14,7 +13,7 @@ namespace System.ComponentModel.Design.Serialization; /// internal sealed class EventMemberCodeDomSerializer : MemberCodeDomSerializer { - private static readonly CodeThisReferenceExpression _thisRef = new CodeThisReferenceExpression(); + private static readonly CodeThisReferenceExpression _thisRef = new(); private static EventMemberCodeDomSerializer s_default; internal static EventMemberCodeDomSerializer Default diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionContext.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionContext.cs index b774be6e8cf..18eea4247eb 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionContext.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionTable.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionTable.cs index f2df4d02273..7b057b11cb4 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionTable.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ExpressionTable.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ICodeDomDesignerReload.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ICodeDomDesignerReload.cs index 1b1425d1dac..20b73940115 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ICodeDomDesignerReload.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ICodeDomDesignerReload.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/LocalizationCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/LocalizationCodeDomSerializer.cs index 9b3869f6755..b2e5e279450 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/LocalizationCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/LocalizationCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; using System.Resources; @@ -147,7 +146,7 @@ private static bool EmitApplyMethod(IDesignerSerializationManager manager, objec } return callExistingSerializer - ? _currentSerializer?.Serialize(manager, value) + ? _currentSerializer?.Serialize(manager, value!) : SerializeToResourceExpression(manager, value); } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/MemberCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/MemberCodeDomSerializer.cs index ea57707155b..b88176576f7 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/MemberCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/MemberCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/PrimitiveCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/PrimitiveCodeDomSerializer.cs index 6b25093d86c..e2e06e09ab1 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/PrimitiveCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/PrimitiveCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/PropertyMemberCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/PropertyMemberCodeDomSerializer.cs index b2708d1d70c..e755bd1296f 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/PropertyMemberCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/PropertyMemberCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourceCodeDomSerializer.SerializationResourceManager.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourceCodeDomSerializer.SerializationResourceManager.cs index a9fda53c87f..8330c419c91 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourceCodeDomSerializer.SerializationResourceManager.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourceCodeDomSerializer.SerializationResourceManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -19,7 +18,6 @@ internal partial class ResourceCodeDomSerializer /// internal class SerializationResourceManager : ComponentResourceManager { - private static readonly Dictionary s_resourceSetSentinel = new Dictionary(); private readonly IDesignerSerializationManager _manager; private bool _checkedLocalizationLanguage; private CultureInfo _localizationLanguage; @@ -228,7 +226,7 @@ private CompareValue CompareWithParentValue(CultureInfo culture, string name, ob Dictionary resourceSet = GetResourceSet(culture); if (resourceSet is not null && resourceSet.TryGetValue(name, out object parentValue)) { - return !parentValue.Equals(value) || parentValue is null ? CompareValue.Different : CompareValue.Same; + return parentValue is null || !parentValue.Equals(value) ? CompareValue.Different : CompareValue.Same; } else if (culture.Equals(CultureInfo.InvariantCulture)) { @@ -391,8 +389,7 @@ public object GetObject(string resourceName, bool forceInvariant) private Dictionary GetResourceSet(CultureInfo culture) { Debug.Assert(culture is not null, "null parameter"); - Dictionary resourceSet = null; - if (!ResourceTable.TryGetValue(culture, out Dictionary objRs)) + if (!ResourceTable.TryGetValue(culture, out Dictionary resourceSet)) { IResourceService resSvc = (IResourceService)_manager.GetService(typeof(IResourceService)); TraceIf(TraceLevel.Error, resSvc is null, "IResourceService is not available. We will not be able to load resources."); @@ -409,24 +406,15 @@ private Dictionary GetResourceSet(CultureInfo culture) { reader.Close(); } - - ResourceTable[culture] = resourceSet; } - else + else if (culture.Equals(CultureInfo.InvariantCulture)) { - // Provide a sentinel so we don't repeatedly ask for the same resource. If this is the invariant culture, always provide one. - ResourceTable[culture] = culture.Equals(CultureInfo.InvariantCulture) - ? new Dictionary() : s_resourceSetSentinel; + // If this is the invariant culture, always provide a resource set. + resourceSet = new Dictionary(); } - } - } - else - { - resourceSet = objRs; - if (resourceSet is null) - { - // the resourceSets hash table may contain our "this" pointer as a sentinel value - Debug.Assert(objRs == s_resourceSetSentinel, $"unknown object in resourceSets: {objRs}"); + + // resourceSet may be null here. We add it to the cache anyway as a sentinel so we don't repeatedly ask for the same resource. + ResourceTable[culture] = resourceSet; } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourceCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourceCodeDomSerializer.cs index db4087a10e8..3d79f76129d 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourceCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourceCodeDomSerializer.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.CodeDom; using System.Collections; @@ -25,42 +22,27 @@ namespace System.ComponentModel.Design.Serialization; /// internal partial class ResourceCodeDomSerializer : CodeDomSerializer { - private static ResourceCodeDomSerializer s_defaultSerializer; + private static ResourceCodeDomSerializer? s_defaultSerializer; /// /// Retrieves a default static instance of this serializer. /// - internal static new ResourceCodeDomSerializer Default - { - get - { - s_defaultSerializer ??= new ResourceCodeDomSerializer(); + internal static new ResourceCodeDomSerializer Default => s_defaultSerializer ??= new ResourceCodeDomSerializer(); - return s_defaultSerializer; - } - } - - public override string GetTargetComponentName(CodeStatement statement, CodeExpression expression, Type type) + public override string? GetTargetComponentName(CodeStatement? statement, CodeExpression? expression, Type? type) { - string name = null; - if (statement is CodeExpressionStatement expStatement) + string? name = null; + if (statement is CodeExpressionStatement { Expression: CodeMethodInvokeExpression methodInvokeEx }) { - if (expStatement.Expression is CodeMethodInvokeExpression methodInvokeEx) + if (string.Equals(methodInvokeEx.Method?.MethodName, "ApplyResources", StringComparison.OrdinalIgnoreCase)) { - if (methodInvokeEx.Method is CodeMethodReferenceExpression methodReferenceEx && - string.Equals(methodReferenceEx.MethodName, "ApplyResources", StringComparison.OrdinalIgnoreCase) && - methodInvokeEx.Parameters.Count > 0) + name = methodInvokeEx.Parameters switch { // We've found a call to the ApplyResources method on a ComponentResourceManager object. now we just need to figure out which component ApplyResources is being called for, and put it into that component's bucket. - if (methodInvokeEx.Parameters[0] is CodeFieldReferenceExpression fieldReferenceEx && fieldReferenceEx.TargetObject is CodeThisReferenceExpression) - { - name = fieldReferenceEx.FieldName; - } - else if (methodInvokeEx.Parameters[0] is CodeVariableReferenceExpression variableReferenceEx) - { - name = variableReferenceEx.VariableName; - } - } + [CodeFieldReferenceExpression { TargetObject: CodeThisReferenceExpression } fieldReferenceEx, ..] => fieldReferenceEx.FieldName, + [CodeVariableReferenceExpression variableReferenceEx, ..] => variableReferenceEx.VariableName, + _ => null + }; } } @@ -75,17 +57,14 @@ public override string GetTargetComponentName(CodeStatement statement, CodeExpre /// /// This is the name of the resource manager object we declare on the component surface. /// - private static string ResourceManagerName - { - get => "resources"; - } + private const string ResourceManagerName = "resources"; /// /// Deserializes the given CodeDom object into a real object. This will use the serialization manager to create objects and resolve data types. The root of the object graph is returned. /// - public override object Deserialize(IDesignerSerializationManager manager, object codeObject) + public override object? Deserialize(IDesignerSerializationManager manager, object codeObject) { - object instance = null; + object? instance = null; ArgumentNullException.ThrowIfNull(manager); ArgumentNullException.ThrowIfNull(codeObject); @@ -97,44 +76,38 @@ public override object Deserialize(IDesignerSerializationManager manager, object { instance = DeserializeExpression(manager, null, expression); } - else + else if (codeObject is CodeStatementCollection statements) { - if (codeObject is CodeStatementCollection statements) + foreach (CodeStatement element in statements) { - foreach (CodeStatement element in statements) + // We create the resource manager ourselves here because it's not just a straight parse of the code. Do special parsing of the resources statement + if (element is CodeVariableDeclarationStatement statement) { - // We create the resource manager ourselves here because it's not just a straight parse of the code. Do special parsing of the resources statement - if (element is CodeVariableDeclarationStatement statement) + TraceIf(TraceLevel.Warning, !statement.Name.Equals(ResourceManagerName), "WARNING: Resource manager serializer being invoked to deserialize a collection we didn't create."); + if (statement.Name.Equals(ResourceManagerName)) { - TraceIf(TraceLevel.Warning, !statement.Name.Equals(ResourceManagerName), "WARNING: Resource manager serializer being invoked to deserialize a collection we didn't create."); - if (statement.Name.Equals(ResourceManagerName)) - { - instance = CreateResourceManager(manager); - } + instance = CreateResourceManager(manager); + } + } + else + { + // If we do not yet have an instance, we will need to pick through the statements and see if we can find one. + if (instance is null) + { + instance = DeserializeStatementToInstance(manager, element); } else { - // If we do not yet have an instance, we will need to pick through the statements and see if we can find one. - if (instance is null) - { - instance = DeserializeStatementToInstance(manager, element); - } - else - { - DeserializeStatement(manager, element); - } + DeserializeStatement(manager, element); } } } - else - { - if (!(codeObject is CodeStatement statement)) - { - Debug.Fail("ResourceCodeDomSerializer::Deserialize requires a CodeExpression, CodeStatement or CodeStatementCollection to parse"); - string supportedTypes = $"{nameof(CodeExpression)}, {nameof(CodeStatement)}, {nameof(CodeStatementCollection)}"; - throw new ArgumentException(string.Format(SR.SerializerBadElementTypes, codeObject.GetType().Name, supportedTypes)); - } - } + } + else if (codeObject is not CodeStatement) + { + Debug.Fail("ResourceCodeDomSerializer::Deserialize requires a CodeExpression, CodeStatement or CodeStatementCollection to parse"); + string supportedTypes = $"{nameof(CodeExpression)}, {nameof(CodeStatement)}, {nameof(CodeStatementCollection)}"; + throw new ArgumentException(string.Format(SR.SerializerBadElementTypes, codeObject.GetType().Name, supportedTypes)); } } @@ -158,7 +131,7 @@ private static SerializationResourceManager CreateResourceManager(IDesignerSeria /// /// This method is invoked during deserialization to obtain an instance of an object. When this is called, an instance of the requested type should be returned. Our implementation provides a design time resource manager. /// - protected override object DeserializeInstance(IDesignerSerializationManager manager, Type type, object[] parameters, string name, bool addToContainer) + protected override object DeserializeInstance(IDesignerSerializationManager manager, Type type, object?[]? parameters, string? name, bool addToContainer) { ArgumentNullException.ThrowIfNull(manager); ArgumentNullException.ThrowIfNull(type); @@ -177,7 +150,7 @@ protected override object DeserializeInstance(IDesignerSerializationManager mana /// /// Deserializes the given CodeDom object into a real object. This will use the serialization manager to create objects and resolve data types. It uses the invariant resource blob to obtain resources. /// - public static object DeserializeInvariant(IDesignerSerializationManager manager, string resourceName) + public static object? DeserializeInvariant(IDesignerSerializationManager manager, string resourceName) { SerializationResourceManager resources = GetResourceManager(manager); return resources.GetObject(resourceName, true); @@ -186,11 +159,11 @@ public static object DeserializeInvariant(IDesignerSerializationManager manager, /// /// Try to discover the data type we should apply a cast for. To do this, we first search the context stack for an ExpressionContext to decrypt, and if we fail that we try the actual object. If we can't find a cast type we return null. /// - private static Type GetCastType(IDesignerSerializationManager manager, object value) + [return: NotNullIfNotNull(nameof(value))] + private static Type? GetCastType(IDesignerSerializationManager manager, object? value) { // Is there an ExpressionContext we can work with? - ExpressionContext tree = (ExpressionContext)manager.Context[typeof(ExpressionContext)]; - if (tree is not null) + if (manager.TryGetContext(out ExpressionContext? tree)) { return tree.ExpressionType; } @@ -201,7 +174,7 @@ private static Type GetCastType(IDesignerSerializationManager manager, object va Type castTo = value.GetType(); while (!castTo.IsPublic && !castTo.IsNestedPublic) { - castTo = castTo.BaseType; + castTo = castTo.BaseType!; } return castTo; @@ -215,7 +188,7 @@ private static Type GetCastType(IDesignerSerializationManager manager, object va /// /// Retrieves a dictionary enumerator for the requested culture, or null if no resources for that culture exist. /// - public static IDictionaryEnumerator GetEnumerator(IDesignerSerializationManager manager, CultureInfo culture) + public static IDictionaryEnumerator? GetEnumerator(IDesignerSerializationManager manager, CultureInfo culture) { SerializationResourceManager resources = GetResourceManager(manager); return resources.GetEnumerator(culture); @@ -224,7 +197,7 @@ public static IDictionaryEnumerator GetEnumerator(IDesignerSerializationManager /// /// Retrieves a dictionary enumerator for the requested culture, or null if no resources for that culture exist. /// - public static IDictionaryEnumerator GetMetadataEnumerator(IDesignerSerializationManager manager) + public static IDictionaryEnumerator? GetMetadataEnumerator(IDesignerSerializationManager manager) { SerializationResourceManager resources = GetResourceManager(manager); return resources.GetMetadataEnumerator(); @@ -235,7 +208,7 @@ public static IDictionaryEnumerator GetMetadataEnumerator(IDesignerSerialization /// private static SerializationResourceManager GetResourceManager(IDesignerSerializationManager manager) { - if (!(manager.Context[typeof(SerializationResourceManager)] is SerializationResourceManager sm)) + if (!manager.TryGetContext(out SerializationResourceManager? sm)) { sm = new SerializationResourceManager(manager); manager.Context.Append(sm); @@ -265,7 +238,7 @@ public object Serialize(IDesignerSerializationManager manager, object value, boo /// /// Serializes the given object into a CodeDom object. This expects the following values to be available on the context stack: A CodeStatementCollection that we can add our resource declaration to, if necessary. An ExpressionContext that contains the property, field or method that is being serialized, along with the object being serialized. We need this so we can create a unique resource name for the object. /// - public object Serialize(IDesignerSerializationManager manager, object value, bool shouldSerializeInvariant, bool ensureInvariant) + public object Serialize(IDesignerSerializationManager manager, object? value, bool shouldSerializeInvariant, bool ensureInvariant) { return Serialize(manager, value, false, shouldSerializeInvariant, ensureInvariant); } @@ -273,16 +246,15 @@ public object Serialize(IDesignerSerializationManager manager, object value, boo /// /// This performs the actual work of serialization between Serialize and SerializeInvariant. /// - private object Serialize(IDesignerSerializationManager manager, object value, bool forceInvariant, bool shouldSerializeInvariant, bool ensureInvariant) + private object Serialize(IDesignerSerializationManager manager, object? value, bool forceInvariant, bool shouldSerializeInvariant, bool ensureInvariant) { - CodeExpression expression = null; using (TraceScope("ResourceCodeDomSerializer::Serialize")) { // Resource serialization is a little inconsistent. We deserialize our own resource manager creation statement, but we will never be asked to serialize a resource manager, because it doesn't exist as a product of the design container; it is purely an artifact of serializing. Some not-so-obvious side effects of this are: // This method will never ever be called by the serialization system directly. There is no attribute or metadata that will invoke it. Instead, other serializers will call this method to see if we should serialize to resources. // We need a way to inject the local variable declaration into the method body for the resource manager if we actually do emit a resource, which we shove into the statements collection. SerializationResourceManager sm = GetResourceManager(manager); - CodeStatementCollection statements = (CodeStatementCollection)manager.Context[typeof(CodeStatementCollection)]; + CodeStatementCollection? statements = manager.GetContext(); // If this serialization resource manager has never been used to output culture-sensitive statements, then we must emit the local variable hookup. Culture invariant statements are used to save random data that is not representable in code, so there is no need to emit a declaration. if (!forceInvariant) { @@ -294,10 +266,10 @@ private object Serialize(IDesignerSerializationManager manager, object value, bo if (statements is not null) { CodeExpression[] parameters; - if (manager.Context[typeof(RootContext)] is RootContext rootCtx) + if (manager.TryGetContext(out RootContext? rootCtx)) { - string baseType = manager.GetName(rootCtx.Value); - parameters = new CodeExpression[] { new CodeTypeOfExpression(baseType) }; + string? baseType = manager.GetName(rootCtx.Value); + parameters = new CodeExpression[] { new CodeTypeOfExpression(baseType!) }; } else { @@ -327,7 +299,7 @@ private object Serialize(IDesignerSerializationManager manager, object value, bo } // Retrieve the ExpressionContext on the context stack, and save the value as a resource. - ExpressionContext tree = (ExpressionContext)manager.Context[typeof(ExpressionContext)]; + ExpressionContext? tree = manager.GetContext(); TraceIf(TraceLevel.Warning, tree is null, "No ExpressionContext on stack. We can serialize, but we cannot create a well-formed name."); string resourceName = sm.SetValue(manager, tree, value, forceInvariant, shouldSerializeInvariant, ensureInvariant, false); // Now the next step is to discover the type of the given value. If it is a string, we will invoke "GetString" Otherwise, we will invoke "GetObject" and supply a cast to the proper value. @@ -354,24 +326,16 @@ private object Serialize(IDesignerSerializationManager manager, object value, bo methodInvoke.Parameters.Add(new CodePrimitiveExpression(resourceName)); if (needCast) { - Type castTo = GetCastType(manager, value); + Type? castTo = GetCastType(manager, value); if (castTo is not null) { Trace(TraceLevel.Verbose, $"Supplying cast to {castTo.Name}"); - expression = new CodeCastExpression(castTo, methodInvoke); + return new CodeCastExpression(castTo, methodInvoke); } - else - { - expression = methodInvoke; - } - } - else - { - expression = methodInvoke; } - } - return expression; + return methodInvoke; + } } /// @@ -386,7 +350,7 @@ public object SerializeInvariant(IDesignerSerializationManager manager, object v /// /// Writes out the given metadata. /// - public void SerializeMetadata(IDesignerSerializationManager manager, string name, object value, bool shouldSerializeValue) + public void SerializeMetadata(IDesignerSerializationManager manager, string name, object? value, bool shouldSerializeValue) { using (TraceScope($"ResourceCodeDomSerializer::{nameof(SerializeMetadata)}")) { @@ -400,7 +364,7 @@ public void SerializeMetadata(IDesignerSerializationManager manager, string name /// /// Serializes the given resource value into the resource set. This does not effect the code dom values. The resource is written into the current culture. /// - public void WriteResource(IDesignerSerializationManager manager, string name, object value) + public void WriteResource(IDesignerSerializationManager manager, string name, object? value) { SetValueUsingCommonTraceScope(manager, name, value, nameof(WriteResource), false, false, true, false); } @@ -408,12 +372,12 @@ public void WriteResource(IDesignerSerializationManager manager, string name, ob /// /// Serializes the given resource value into the resource set. This does not effect the code dom values. The resource is written into the invariant culture. /// - public void WriteResourceInvariant(IDesignerSerializationManager manager, string name, object value) + public void WriteResourceInvariant(IDesignerSerializationManager manager, string name, object? value) { SetValueUsingCommonTraceScope(manager, name, value, nameof(WriteResourceInvariant), true, true, true, false); } - private static void SetValueUsingCommonTraceScope(IDesignerSerializationManager manager, string name, object value, string calleeName, + private static void SetValueUsingCommonTraceScope(IDesignerSerializationManager manager, string name, object? value, string calleeName, bool forceInvariant, bool shouldSerializeInvariant, bool ensureInvariant, bool applyingCachedResources) { using (TraceScope($"ResourceCodeDomSerializer::{calleeName}")) diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourcePropertyMemberCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourcePropertyMemberCodeDomSerializer.cs index 9b1503ba086..f7961ec59c4 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourcePropertyMemberCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourcePropertyMemberCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/RootContext.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/RootContext.cs index 1d090e14c7e..57982b68d13 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/RootContext.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/RootContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/SerializeAbsoluteContext.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/SerializeAbsoluteContext.cs index 39a961e77e3..231f4e91529 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/SerializeAbsoluteContext.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/SerializeAbsoluteContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/StatementContext.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/StatementContext.cs index 75fd56b3a7c..49cc376123d 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/StatementContext.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/StatementContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; using System.Collections; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/TypeCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/TypeCodeDomSerializer.cs index 261d7ca17a2..a0964196f8c 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/TypeCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/TypeCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -21,7 +20,7 @@ public class TypeCodeDomSerializer : CodeDomSerializerBase private IDictionary _nameTable; private Dictionary _statementTable; private static readonly Attribute[] s_designTimeFilter = new Attribute[] { DesignOnlyAttribute.Yes }; - private static readonly object s_initMethodKey = new object(); + private static readonly object s_initMethodKey = new(); private static TypeCodeDomSerializer s_default; internal static TypeCodeDomSerializer Default @@ -582,7 +581,7 @@ private void IntegrateStatements(IDesignerSerializationManager manager, object r #region OrderedStatementsCollection Class private class StatementOrderComparer : IComparer { - public static readonly StatementOrderComparer s_default = new StatementOrderComparer(); + public static readonly StatementOrderComparer s_default = new(); private StatementOrderComparer() { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SiteNestedContainer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SiteNestedContainer.cs index 240cfcde01d..737742b85f2 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SiteNestedContainer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SiteNestedContainer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ToolStripContainerActionList.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ToolStripContainerActionList.cs new file mode 100644 index 00000000000..5abe9eca78c --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ToolStripContainerActionList.cs @@ -0,0 +1,344 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Windows.Forms.Design.Behavior; + +namespace System.Windows.Forms.Design; + +/// +/// Describes the list of actions that can be performed for the ToolStripContainer control from the chrome panel. +/// +internal class ToolStripContainerActionList : DesignerActionList +{ + private readonly ToolStripContainer _toolStripContainer; + private readonly IDesignerHost? _designerHost; + private readonly IServiceProvider? _serviceProvider; + + /// + /// ToolStripContainer ActionList. + /// + public ToolStripContainerActionList(ToolStripContainer toolStripContainer) : base(toolStripContainer) + { + _toolStripContainer = toolStripContainer; + _serviceProvider = _toolStripContainer.Site; + _designerHost = _serviceProvider?.GetService(); + } + + /// + /// Helper function to get the property on the component. + /// + private static object? GetProperty(Component component, string propertyName) + { + PropertyDescriptor? getProperty = TypeDescriptor.GetProperties(component)?[propertyName]; + return getProperty?.GetValue(component); + } + + /// + /// Helper function to change the property on the component + /// + private void ChangeProperty(Component component, string propertyName, object value) + { + if (_designerHost is null) + { + return; + } + + ToolStripPanel? panel = component as ToolStripPanel; + ToolStripPanelDesigner? panelDesigner = _designerHost.GetDesigner(component) as ToolStripPanelDesigner; + + if (propertyName.Equals("Visible") && panel is not null) + { + foreach (Control control in panel.Controls) + { + PropertyDescriptor? visibleProperty = TypeDescriptor.GetProperties(control)["Visible"]; + visibleProperty?.SetValue(control, value); + } + + if (!(bool)value) + { + if (panel is not null) + { + panel.Padding = new Padding(0); + } + + if (panelDesigner?.ToolStripPanelSelectorGlyph is not null) + { + panelDesigner.ToolStripPanelSelectorGlyph.IsExpanded = false; + } + } + } + + PropertyDescriptor? changingProperty = TypeDescriptor.GetProperties(component)[propertyName]; + changingProperty?.SetValue(component, value); + + // Reset the Glyphs. + SelectionManager? selectionManager = _serviceProvider?.GetService(); + selectionManager?.Refresh(); + + // Invalidate the Window + panelDesigner?.InvalidateGlyph(); + } + + /// + /// Checks if the is dock filled. + /// + private bool IsDockFilled + { + get + { + PropertyDescriptor? dockProperty = TypeDescriptor.GetProperties(_toolStripContainer)["Dock"]; + return dockProperty is null || (DockStyle?)dockProperty.GetValue(_toolStripContainer) == DockStyle.Fill; + } + } + + /// + /// Checks if the ToolStripContainer is a child control of the designerHost's rootComponent + /// + private bool ProvideReparent + => _designerHost?.RootComponent is Control root + && _toolStripContainer.Parent == root + && IsDockFilled + && root.Controls.Count > 1; + + /// + /// Sets the Dock + /// + public void SetDockToForm() + { + if (_designerHost is null) + { + return; + } + + // Change the Parent only if its not parented to the form. + if (_designerHost.RootComponent is Control root && _toolStripContainer.Parent is not Control) + { + root.Controls.Add(_toolStripContainer); + } + + // Set the dock prop to DockStyle.Fill + if (!IsDockFilled) + { + PropertyDescriptor? dockProp = TypeDescriptor.GetProperties(_toolStripContainer)["Dock"]; + dockProp?.SetValue(_toolStripContainer, DockStyle.Fill); + } + } + + /// + /// Reparent the controls on the form. + /// + public void ReparentControls() + { + // Reparent the Controls only if the ToolStripContainer is a child of the RootComponent. + if (_designerHost?.RootComponent is not Control root + || _toolStripContainer.Parent != root + || root.Controls.Count <= 1) + { + return; + } + + Control newParent = _toolStripContainer.ContentPanel; + PropertyDescriptor? autoScrollProp = TypeDescriptor.GetProperties(newParent)["AutoScroll"]; + autoScrollProp?.SetValue(newParent, true); + + // create a transaction so this happens as an atomic unit. + DesignerTransaction? changeParent = _designerHost.CreateTransaction(string.Format(SR._0_reparent_controls_transaction, nameof(ToolStripContainer))); + + try + { + IComponentChangeService? componentChangeService = _serviceProvider?.GetService(); + Control[] childControls = new Control[root.Controls.Count]; + root.Controls.CopyTo(childControls, 0); + + foreach (Control control in childControls) + { + if (control == _toolStripContainer || control is MdiClient) + { + continue; + } + + // We should not reparent inherited Controls + var inheritanceAttribute = TypeDescriptor.GetAttributes(control)?[typeof(InheritanceAttribute)] as InheritanceAttribute; + if (inheritanceAttribute is null || inheritanceAttribute.InheritanceLevel == InheritanceLevel.InheritedReadOnly) + { + continue; + } + + newParent = control is ToolStrip ? GetParent(control) : _toolStripContainer.ContentPanel; + + PropertyDescriptor? controlsProp = TypeDescriptor.GetProperties(newParent)["Controls"]; + Control? oldParent = control.Parent; + + if (oldParent is not null) + { + componentChangeService?.OnComponentChanging(oldParent, controlsProp); + + // Remove control from the old parent + oldParent.Controls.Remove(control); + } + + componentChangeService?.OnComponentChanging(newParent, controlsProp); + + // Finally add & relocate the control with the new parent + newParent.Controls.Add(control); + + // Fire our component changed events + if (componentChangeService is not null && oldParent is not null) + { + componentChangeService.OnComponentChanged(oldParent, controlsProp, oldValue: null, newValue: null); + } + + // fire component changed on the newParent + componentChangeService?.OnComponentChanged(newParent, controlsProp, oldValue: null, newValue: null); + } + } + catch + { + if (changeParent is not null) + { + changeParent.Cancel(); + changeParent = null; + } + } + finally + { + if (changeParent is not null) + { + changeParent.Commit(); + changeParent = null; + } + + // Set the Selection on the new Parent, so that the selection is restored to the new item + ISelectionService? selectionService = _serviceProvider?.GetService(); + selectionService?.SetSelectedComponents(new IComponent[] { newParent }); + } + } + + private Control GetParent(Control control) + { + Control newParent = _toolStripContainer.ContentPanel; + DockStyle dock = control.Dock; + + foreach (Control panel in _toolStripContainer.Controls) + { + if (panel is ToolStripPanel && panel.Dock == dock) + { + newParent = panel; + break; + } + } + + return newParent; + } + + /// + /// Visibility of TopToolStripPanel. + /// + public bool TopVisible + { + get => (bool)(GetProperty(_toolStripContainer, nameof(ToolStripContainer.TopToolStripPanelVisible)) ?? false); + set + { + if (value != TopVisible) + { + ChangeProperty(_toolStripContainer, "TopToolStripPanelVisible", value); + } + } + } + + /// + /// Visibility of BottomToolStripPanel. + /// + public bool BottomVisible + { + get => (bool)(GetProperty(_toolStripContainer, nameof(ToolStripContainer.BottomToolStripPanelVisible)) ?? false); + set + { + if (value != BottomVisible) + { + ChangeProperty(_toolStripContainer, "BottomToolStripPanelVisible", value); + } + } + } + + /// + /// Visibility of LeftToolStripPanel. + /// + public bool LeftVisible + { + get => (bool)(GetProperty(_toolStripContainer, nameof(ToolStripContainer.LeftToolStripPanelVisible)) ?? false); + set + { + if (value != LeftVisible) + { + ChangeProperty(_toolStripContainer, "LeftToolStripPanelVisible", value); + } + } + } + + /// + /// Visibility of RightToolStripPanel. + /// + public bool RightVisible + { + get => (bool)(GetProperty(_toolStripContainer, nameof(ToolStripContainer.RightToolStripPanelVisible)) ?? false); + set + { + if (value != RightVisible) + { + ChangeProperty(_toolStripContainer, "RightToolStripPanelVisible", value); + } + } + } + + /// + /// Returns the control's action list items. + /// + public override DesignerActionItemCollection GetSortedActionItems() + { + DesignerActionItemCollection items = new DesignerActionItemCollection + { + new DesignerActionHeaderItem(SR.ToolStripContainerActionList_Visible, SR.ToolStripContainerActionList_Show), + new DesignerActionPropertyItem(nameof(TopVisible), + SR.ToolStripContainerActionList_Top, + SR.ToolStripContainerActionList_Show, + SR.ToolStripContainerActionList_TopDesc), + + new DesignerActionPropertyItem(nameof(BottomVisible), + SR.ToolStripContainerActionList_Bottom, + SR.ToolStripContainerActionList_Show, + SR.ToolStripContainerActionList_BottomDesc), + + new DesignerActionPropertyItem(nameof(LeftVisible), + SR.ToolStripContainerActionList_Left, + SR.ToolStripContainerActionList_Show, + SR.ToolStripContainerActionList_LeftDesc), + + new DesignerActionPropertyItem(nameof(RightVisible), + SR.ToolStripContainerActionList_Right, + SR.ToolStripContainerActionList_Show, + SR.ToolStripContainerActionList_RightDesc) + }; + + if (!IsDockFilled) + { + string displayName = _designerHost?.RootComponent is UserControl + ? SR.DesignerShortcutDockInUserControl + : SR.DesignerShortcutDockInForm; + + items.Add(new DesignerActionMethodItem( + this, + nameof(SetDockToForm), + displayName)); + } + + if (ProvideReparent) + { + items.Add(new DesignerActionMethodItem(this, nameof(ReparentControls), SR.DesignerShortcutReparentControls)); + } + + return items; + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/TypeDescriptorFilterService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/TypeDescriptorFilterService.cs index 6077c85fc9b..55f4159d148 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/TypeDescriptorFilterService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/TypeDescriptorFilterService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.UndoUnit.AddRemoveUndoEvent.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.UndoUnit.AddRemoveUndoEvent.cs new file mode 100644 index 00000000000..6daed050555 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.UndoUnit.AddRemoveUndoEvent.cs @@ -0,0 +1,98 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel.Design.Serialization; + +namespace System.ComponentModel.Design; + +public abstract partial class UndoEngine +{ + protected partial class UndoUnit + { + /// + /// This undo event handles addition and removal of components. + /// + private sealed class AddRemoveUndoEvent : UndoEvent + { + private readonly SerializationStore _serializedData; + private readonly string? _componentName; + + /// + /// Creates a new object that contains the state of the event. The last parameter, add, determines the initial mode of this event. If true, it means this event is being created in response to a component add. If false, it is being created in response to a component remove. + /// + public AddRemoveUndoEvent(UndoEngine engine, IComponent component, bool add) + { + _componentName = component.Site!.Name; + NextUndoAdds = !add; + OpenComponent = component; + + Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Creating {(add ? "Add" : "Remove")} undo event for '{_componentName}'"); + using (_serializedData = engine._serializationService.CreateStore()) + { + engine._serializationService.Serialize(_serializedData, component); + } + + // For add events, we commit as soon as we receive the event. + Committed = add; + } + + /// + /// Returns true if the add remove event has been comitted. + /// + internal bool Committed { get; private set; } + + /// + /// If this add/remove event is still open, OpenComponent will contain the component it is operating on. + /// + internal IComponent OpenComponent { get; } + + /// + /// Returns true if undoing this event will add a component. + /// + internal bool NextUndoAdds { get; private set; } + + /// + /// Commits this event. + /// + internal void Commit(UndoEngine engine) + { + if (!Committed) + { + Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Committing remove of '{_componentName}'"); + Committed = true; + } + } + + /// + /// Actually performs the undo action. + /// + public override void Undo(UndoEngine engine) + { + if (NextUndoAdds) + { + Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Adding '{_componentName}'"); + // We need to add this component. To add it, we deserialize it and then we add it to the designer host's container. + IDesignerHost host = engine.GetRequiredService(); + + engine._serializationService.DeserializeTo(_serializedData, host.Container); + } + else + { + Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Removing '{_componentName}'"); + // We need to remove this component. Take the name and match it to an object, and then ask that object to delete itself. + IDesignerHost host = engine.GetRequiredService(); + + IComponent? component = host.Container.Components[_componentName]; + + // Note: It's ok for the component to be null here. This could happen if the parent to this control is disposed first. Ex:SplitContainer + if (component is not null) + { + host.DestroyComponent(component); + } + } + + NextUndoAdds = !NextUndoAdds; + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.UndoUnit.ChangeUndoEvent.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.UndoUnit.ChangeUndoEvent.cs new file mode 100644 index 00000000000..4dfe619f924 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.UndoUnit.ChangeUndoEvent.cs @@ -0,0 +1,161 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel.Design.Serialization; + +namespace System.ComponentModel.Design; + +public abstract partial class UndoEngine +{ + protected partial class UndoUnit + { + private sealed class ChangeUndoEvent : UndoEvent + { + // Static data we hang onto about this change. + private readonly string _componentName; + private readonly MemberDescriptor? _member; + // Before and after state. Before state is built in the constructor. After state is built right before we undo for the first time. + private SerializationStore? _before; + private SerializationStore? _after; + private bool _savedAfterState; + + /// + /// Creates a new component change undo event. This event consists of a before and after snapshot of a single component. A snapshot will not be taken if a name for the component cannot be determined. + /// + public ChangeUndoEvent(UndoEngine engine, ComponentChangingEventArgs e, bool serializeBeforeState) + { + _componentName = engine.GetName(e.Component, true)!; + OpenComponent = e.Component; + _member = e.Member; + + Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Creating change undo event for '{_componentName}'"); + if (serializeBeforeState) + { + Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Saving before snapshot for change to '{_componentName}'"); + _before = Serialize(engine, OpenComponent!, _member); + } + } + + public ComponentChangingEventArgs ComponentChangingEventArgs => new(OpenComponent, _member); + + /// + /// Indicates that undoing this event may cause side effects in other objects. + /// Change events fall into this category because, for example, a change involving adding an object to one collection may have a side effect of removing it from another collection. Events with side effects are grouped at undo time so all their BeforeUndo methods are called before their Undo methods. + /// Events without side effects have their BeforeUndo called and then their Undo called immediately after. + /// + public override bool CausesSideEffects => true; + + /// + /// Returns true if the change event has been comitted. + /// + [MemberNotNullWhen(false, nameof(OpenComponent))] + public bool Committed => OpenComponent is null; + + /// + /// Returns the component this change event is currently tracking. This will return null once the change event is committed. + /// + public object? OpenComponent { get; private set; } + + /// + /// Called before Undo is called. All undo events get their BeforeUndo called, and then they all get their Undo called. This allows the undo event to examine the state of the world before other undo events mess with it. + /// + public override void BeforeUndo(UndoEngine engine) + { + if (!_savedAfterState) + { + _savedAfterState = true; + SaveAfterState(engine); + } + } + + /// + /// Determines if this + /// + public bool ContainsChange(MemberDescriptor? desc) + { + if (_member is null) + { + return true; + } + + if (desc is null) + { + return false; + } + + return desc.Equals(_member); + } + + /// + /// Commits the unit. Committing the unit saves the "after" snapshot of the unit. If commit is called multiple times only the first commit is registered. + /// + public void Commit(UndoEngine engine) + { + if (!Committed) + { + Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Committing change to '{_componentName}'"); + OpenComponent = null; + } + } + + private void SaveAfterState(UndoEngine engine) + { + Debug.Assert(_after is null, "Change undo saving state twice."); + Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Saving after snapshot for change to '{_componentName}'"); + object? component = null; + + if (engine.TryGetService(out IReferenceService? rs)) + { + component = rs.GetReference(_componentName); + } + else if (engine.TryGetService(out IDesignerHost? host)) + { + component = host.Container.Components[_componentName]; + } + + // It is OK for us to not find a component here. That can happen if our "after" state is owned by another change, like an add of the component. + if (component is not null) + { + _after = Serialize(engine, component, _member); + } + } + + private static SerializationStore Serialize(UndoEngine engine, object component, MemberDescriptor? member) + { + SerializationStore store; + using (store = engine._serializationService.CreateStore()) + { + if (member is not null && !(member.Attributes.Contains(DesignerSerializationVisibilityAttribute.Hidden))) + { + engine._serializationService.SerializeMemberAbsolute(store, component, member); + } + else + { + engine._serializationService.SerializeAbsolute(store, component); + } + } + + return store; + } + + /// + /// Performs the actual undo. AFter it finishes it will reverse the role of _before and _after + /// + public override void Undo(UndoEngine engine) + { + Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Applying changes to '{_componentName}'"); + Debug.Assert(_savedAfterState, "After state not saved. BeforeUndo was not called?"); + + if (_before is not null) + { + if (engine.TryGetService(out IDesignerHost? host)) + { + engine._serializationService.DeserializeTo(_before, host.Container); + } + } + + (_after, _before) = (_before, _after); + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.UndoUnit.RenameUndoEvent.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.UndoUnit.RenameUndoEvent.cs new file mode 100644 index 00000000000..d61affa50c0 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.UndoUnit.RenameUndoEvent.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.ComponentModel.Design; + +public abstract partial class UndoEngine +{ + protected partial class UndoUnit + { + private sealed class RenameUndoEvent : UndoEvent + { + private string? _before; + private string? _after; + + /// + /// Creates a new rename undo event. + /// + public RenameUndoEvent(string? before, string? after) + { + _before = before; + _after = after; + Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Creating rename undo event for '{_before}'->'{_after}'"); + } + + /// + /// Simply undoes a rename by setting the name back to the saved value. + /// + public override void Undo(UndoEngine engine) + { + Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Renaming '{_after}'->'{_before}'"); + IComponent? comp = engine._host.Container.Components[_after]; + if (comp is not null) + { + engine.ComponentChangeService.OnComponentChanging(comp, null); + comp.Site!.Name = _before; + (_after, _before) = (_before, _after); + } + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.UndoUnit.UndoEvent.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.UndoUnit.UndoEvent.cs new file mode 100644 index 00000000000..8bdd86806f8 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.UndoUnit.UndoEvent.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.ComponentModel.Design; + +public abstract partial class UndoEngine +{ + protected partial class UndoUnit + { + private abstract class UndoEvent + { + /// + /// Indicates that undoing this event may cause side effects in other objects. + /// Change events fall into this category because, for example, a change involving adding an object to one collection may have a side effect of removing it from another collection. + /// Events with side effects are grouped at undo time so all their BeforeUndo methods are called before their Undo methods. + /// Events without side effects have their BeforeUndo called and then their Undo called immediately after. + /// + public virtual bool CausesSideEffects => false; + + /// + /// Called before Undo is called. All undo events get their BeforeUndo called, and then they all get their Undo called. This allows the undo event to examine the state of the world before other undo events mess with it. BeforeUndo returns true if before undo was supported, and false if not. If before undo is not supported, the undo unit should be undone immediately. + /// + public virtual void BeforeUndo(UndoEngine engine) + { + } + + /// + /// Called by the undo unit when it wants to undo this bit of work. + /// + public abstract void Undo(UndoEngine engine); + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.UndoUnit.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.UndoUnit.cs new file mode 100644 index 00000000000..758a6cac223 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.UndoUnit.cs @@ -0,0 +1,493 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections; +using System.Reflection; +using System.Windows.Forms; + +namespace System.ComponentModel.Design; + +public abstract partial class UndoEngine +{ + /// + /// This class embodies a unit of undoable work. The undo engine creates an undo unit when a change to the designer is about to be made. The undo unit is responsible for tracking changes. The undo engine will call Close on the unit when it no longer needs to track changes. + /// + protected partial class UndoUnit + { + private List? _events; // the list of events we've captured + private List? _changeEvents; // the list of change events we're currently capturing. Only valid until Commit is called. + private List? _removeEvents; // the list of remove events we're currently capturing. Only valid until a matching Removed is encountered. + private List? _ignoreAddingList; // the list of objects that are currently being added. We ignore change events between adding and added. + private List? _ignoreAddedList; // the list of objects that are added. We do not serialize before state for change events that happen in the same transaction + private bool _reverse; // if true, we walk the events list from the bottom up + private readonly Dictionary? _lastSelection; // the selection as it was before we gathered undo info + + public UndoUnit(UndoEngine engine, string? name) + { + Name = name ?? string.Empty; + + Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: Creating undo unit '{Name}'"); + + UndoEngine = engine.OrThrowIfNull(); + _reverse = true; + if (UndoEngine.TryGetService(out ISelectionService? ss)) + { + ICollection selection = ss.GetSelectedComponents(); + Dictionary selectedNames = new(); + foreach (object sel in selection) + { + if (sel is IComponent { Site: ISite site }) + { + selectedNames[site.Name!] = site.Container!; + } + } + + _lastSelection = selectedNames; + } + } + + public string Name { get; } + + /// + /// This returns true if the undo unit has nothing in it to undo. The unit will be discarded. + /// + public virtual bool IsEmpty => _events is null || _events.Count == 0; + + protected UndoEngine UndoEngine { get; } + + /// + /// Adds the given event to our event list. + /// + private void AddEvent(UndoEvent e) + { + _events ??= new(); + + _events.Add(e); + } + + /// + /// Called by the undo engine when it wants to close this unit. The unit should do any final work it needs to do to close. + /// + public virtual void Close() + { + if (_changeEvents is not null) + { + foreach (ChangeUndoEvent e in _changeEvents) + { + e.Commit(UndoEngine); + } + } + + if (_removeEvents is not null) + { + foreach (AddRemoveUndoEvent e in _removeEvents) + { + e.Commit(UndoEngine); + } + } + + // At close time we are done with this list. All change events were simultaneously added to the _events list. + _changeEvents = null; + _removeEvents = null; + _ignoreAddingList = null; + _ignoreAddedList = null; + } + + /// + /// The undo engine will call this on the active undo unit in response to a component added event. + /// + public virtual void ComponentAdded(ComponentEventArgs e) + { + if (e.Component!.Site?.Container is INestedContainer) + { + // do nothing + } + else + { + AddEvent(new AddRemoveUndoEvent(UndoEngine, e.Component, true)); + } + + _ignoreAddingList?.Remove(e.Component); + + _ignoreAddedList ??= new(); + + _ignoreAddedList.Add(e.Component); + } + + /// + /// The undo engine will call this on the active undo unit in response to a component adding event. + /// + public virtual void ComponentAdding(ComponentEventArgs e) + { + _ignoreAddingList ??= new(); + + _ignoreAddingList.Add(e.Component!); + } + + private static bool ChangeEventsSymmetric( + [NotNullWhen(true)] ComponentChangingEventArgs? changing, + [NotNullWhen(true)] ComponentChangedEventArgs? changed) + { + if (changing is null || changed is null) + { + return false; + } + + return changing.Component == changed.Component && changing.Member == changed.Member; + } + + private bool CanRepositionEvent(int startIndex, ComponentChangedEventArgs e) + { + bool containsAdd = false; + bool containsRename = false; + bool containsSymmetricChange = false; + for (int i = startIndex + 1; i < _events!.Count; i++) + { + if (_events[i] is AddRemoveUndoEvent addEvt && !addEvt.NextUndoAdds) + { + containsAdd = true; + } + else if (_events[i] is ChangeUndoEvent changeEvt && ChangeEventsSymmetric(changeEvt.ComponentChangingEventArgs, e)) + { + containsSymmetricChange = true; + } + else if (_events[i] is RenameUndoEvent) + { + containsRename = true; + } + } + + return containsAdd && !containsRename && !containsSymmetricChange; + } + + /// + /// The undo engine will call this on the active undo unit in response to a component changed event. + /// + public virtual void ComponentChanged(ComponentChangedEventArgs e) + { + if (_events is not null && e is not null) + { + for (int i = 0; i < _events.Count; i++) + { + // Determine if we've located the UndoEvent which was created as a result of a corresponding ComponentChanging event. + // If so, reposition to the "Changed" spot in the list if the following is true: + // - It must be for a DSV.Content property + // - There must be a AddEvent between the Changing and Changed + // - There are no renames in between Changing and Changed. + if (_events[i] is ChangeUndoEvent ce && ChangeEventsSymmetric(ce.ComponentChangingEventArgs, e) && i != _events.Count - 1) + { + if (e.Member is not null && e.Member.Attributes.Contains(DesignerSerializationVisibilityAttribute.Content) && + CanRepositionEvent(i, e)) + { + _events.RemoveAt(i); + _events.Add(ce); + } + } + } + } + } + + /// + /// The undo engine will call this on the active undo unit in response to a component changing event. + /// + public virtual void ComponentChanging(ComponentChangingEventArgs e) + { + // If we are in the process of adding this component, ignore any changes to it. The ending "Added" event will capture the component's state. This not just an optimization. If we get a change during an add, we can have an undo order that specifies a remove, and then a change to a removed component. + if (_ignoreAddingList is not null && _ignoreAddingList.Contains(e.Component)) + { + return; + } + + _changeEvents ??= new(); + + // The site check here is done because the data team is calling us for components that are not yet sited. We end up writing them out as Guid-named locals. That's fine, except that we cannot capture after state for these types of things so we assert. + if (UndoEngine.GetName(e.Component, false) is not null) + { + // The caller provided us with a component. This is the common case. We will add a new change event provided there is not already one open for this component. + bool hasChange = false; + + for (int idx = 0; idx < _changeEvents.Count; idx++) + { + ChangeUndoEvent ce = _changeEvents[idx]; + if (ce.OpenComponent == e.Component && ce.ContainsChange(e.Member)) + { + hasChange = true; + break; + } + } + + if (!hasChange || + (e.Member?.Attributes is not null && e.Member.Attributes.Contains(DesignerSerializationVisibilityAttribute.Content))) + { +#if DEBUG + string? name = UndoEngine.GetName(e.Component, false); + + if (name is not null) + { + string memberName = e.Member?.Name ?? "(none)"; + Debug.WriteLineIf(s_traceUndo.TraceVerbose && hasChange, $"Adding second ChangeEvent for {name} Member: {memberName}"); + } + else + { + Debug.Fail("UndoEngine: GetName is failing on successive calls"); + } +#endif + ChangeUndoEvent? changeEvent = null; + bool serializeBeforeState = true; + //perf: if this object was added in this undo unit we do not want to serialize before state for ChangeEvent since undo will remove it anyway + if (_ignoreAddedList is not null && _ignoreAddedList.Contains(e.Component)) + { + serializeBeforeState = false; + } + + if (e.Component is IComponent { Site: not null }) + { + changeEvent = new ChangeUndoEvent(UndoEngine, e, serializeBeforeState); + } + else if (e.Component is not null) + { + if (GetService(typeof(IReferenceService)) is IReferenceService rs) + { + IComponent? owningComp = rs.GetComponent(e.Component); + + if (owningComp is not null) + { + changeEvent = new ChangeUndoEvent(UndoEngine, new ComponentChangingEventArgs(owningComp, null), serializeBeforeState); + } + } + } + + if (changeEvent is not null) + { + AddEvent(changeEvent); + _changeEvents.Add(changeEvent); + } + } + } + } + + /// + /// The undo engine will call this on the active undo unit in response to a component removed event. + /// + public virtual void ComponentRemoved(ComponentEventArgs e) + { + // We should gather undo state in ComponentRemoved, but by this time the component's designer has been destroyed so it's too late. Instead, we captured state in the Removing method. But, it is possible for there to be component changes to other objects that happen between removing and removed, so we need to reorder the removing event so it's positioned after any changes. + if (_events is not null && e is not null) + { + ChangeUndoEvent? changeEvt = null; + int changeIdx = -1; + for (int idx = _events.Count - 1; idx >= 0; idx--) + { + if (changeEvt is null) + { + changeEvt = _events[idx] as ChangeUndoEvent; + changeIdx = idx; + } + + if (_events[idx] is AddRemoveUndoEvent evt && evt.OpenComponent == e.Component) + { + evt.Commit(UndoEngine); + // We should only reorder events if there are change events coming between OnRemoving and OnRemoved. + // If there are other events (such as AddRemoving), the serialization done in OnComponentRemoving might refer to components that aren't available. + if (idx != _events.Count - 1 && changeEvt is not null) + { + // ensure only change change events exist between these two events + bool onlyChange = true; + for (int i = idx + 1; i < changeIdx; i++) + { + if (_events[i] is not ChangeUndoEvent) + { + onlyChange = false; + break; + } + } + + if (onlyChange) + { + // reposition event after final ComponentChangingEvent + _events.RemoveAt(idx); + _events.Insert(changeIdx, evt); + } + } + + break; + } + } + } + } + + /// + /// The undo engine will call this on the active undo unit in response to a component removing event. + /// + public virtual void ComponentRemoving(ComponentEventArgs e) + { + if (e.Component!.Site is INestedContainer) + { + return; + } + + _removeEvents ??= new(); + + try + { + AddRemoveUndoEvent evt = new AddRemoveUndoEvent(UndoEngine, e.Component, false); + AddEvent(evt); + _removeEvents.Add(evt); + } + catch (TargetInvocationException) { } + } + + /// + /// The undo engine will cal this on the active undo unit in response to a component rename event. + /// + public virtual void ComponentRename(ComponentRenameEventArgs e) => + AddEvent(new RenameUndoEvent(e.OldName, e.NewName)); + + /// + /// Returns an instance of the requested service. + /// + protected object? GetService(Type serviceType) => UndoEngine.GetService(serviceType); + + /// + /// Override for object.ToString() + /// + public override string ToString() => Name; + + /// + /// Either performs undo, or redo, depending on the state of the unit. UndoUnit initially assumes that the undoable work has already been "done", so the first call to undo will undo the work. The next call will undo the "undo", performing a redo. + /// + public void Undo() + { + Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: Performing undo '{Name}'"); + UndoUnit? savedUnit = UndoEngine._executingUnit; + UndoEngine._executingUnit = this; + DesignerTransaction? transaction = null; + try + { + if (savedUnit is null) + { + UndoEngine.OnUndoing(EventArgs.Empty); + } + + // create a transaction here so things that do work on componentchanged can ignore that while the transaction is opened...big perf win. + transaction = UndoEngine._host.CreateTransaction(); + UndoCore(); + } + catch (CheckoutException) + { + transaction!.Cancel(); + transaction = null; + throw; + } + finally + { + transaction?.Commit(); + + UndoEngine._executingUnit = savedUnit; + if (savedUnit is null) + { + UndoEngine.OnUndone(EventArgs.Empty); + } + } + } + + /// + /// The undo method invokes this method to perform the actual undo / redo work. You should never call this method directly; override it if you wish, but always call the public Undo method to perform undo work. Undo notifies the undo engine to suspend undo data gathering until this undo is completed, which prevents new undo units from being created in response to this unit doing work. + /// + protected virtual void UndoCore() + { + if (_events is not null) + { + if (_reverse) + { + // How does BeforeUndo work? You'd think you should just call this in one pass, and then call Undo in another, but you'd be wrong. The complexity arises because there are undo events that have dependencies on other undo events. There are also undo events that have side effects with respect to other events. Here are examples: + // Rename is an undo event that other undo events depend on, because they store names. It must be performed in the right order and it must be performed before any subsequent event's BeforeUndo is called. + // Property change is an undo event that may have an unknown side effect if changing the property results in other property changes (for example, reparenting a control removes the control from its former parent). A property change undo event must have all BeforeUndo methods called before any Undo method is called. To do this, we have a property on UndoEvent called CausesSideEffects. + // As we run through UndoEvents, consecutive events that return true from this property are grouped so that their BeforeUndo methods are all called before their Undo methods. For events that do not have side effects, their BeforeUndo and Undo are invoked immediately. + for (int idx = _events.Count - 1; idx >= 0; idx--) + { + int groupEndIdx = idx; + for (int groupIdx = idx; groupIdx >= 0; groupIdx--) + { + if (_events[groupIdx].CausesSideEffects) + { + groupEndIdx = groupIdx; + } + else + { + break; + } + } + + for (int beforeIdx = idx; beforeIdx >= groupEndIdx; beforeIdx--) + { + (_events[beforeIdx]).BeforeUndo(UndoEngine); + } + + for (int undoIdx = idx; undoIdx >= groupEndIdx; undoIdx--) + { + (_events[undoIdx]).Undo(UndoEngine); + } + + Debug.Assert(idx >= groupEndIdx, "We're going backwards"); + idx = groupEndIdx; + } + + // Now, if we have a selection, apply it. + if (_lastSelection is not null) + { + if (UndoEngine.TryGetService(out ISelectionService? ss)) + { + List list = new(_lastSelection.Count); + foreach ((string name, IContainer container) in _lastSelection) + { + IComponent? comp = container.Components[name]; + if (comp is not null) + { + list.Add(comp); + } + } + + ss.SetSelectedComponents(list, SelectionTypes.Replace); + } + } + } + else + { + int count = _events.Count; + for (int idx = 0; idx < count; idx++) + { + int groupEndIdx = idx; + + for (int groupIdx = idx; groupIdx < count; groupIdx++) + { + if (_events[groupIdx].CausesSideEffects) + { + groupEndIdx = groupIdx; + } + else + { + break; + } + } + + for (int beforeIdx = idx; beforeIdx <= groupEndIdx; beforeIdx++) + { + (_events[beforeIdx]).BeforeUndo(UndoEngine); + } + + for (int undoIdx = idx; undoIdx <= groupEndIdx; undoIdx++) + { + (_events[undoIdx]).Undo(UndoEngine); + } + + Debug.Assert(idx <= groupEndIdx, "We're going backwards"); + idx = groupEndIdx; + } + } + } + + _reverse = !_reverse; + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.cs index 421f262de5d..c6f18c3e4c0 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.cs @@ -1,10 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -#nullable disable - -using System.Collections; using System.ComponentModel.Design.Serialization; using System.Reflection; using System.Windows.Forms; @@ -19,20 +15,18 @@ namespace System.ComponentModel.Design; /// The UndoEngine, on the other hand, listens to change events and can create undo and redo actions automatically. /// All that is necessary to implement undo is to add these actions to an undo/redo stack and instantiate this class. /// -public abstract class UndoEngine : IDisposable +public abstract partial class UndoEngine : IDisposable { - private static readonly TraceSwitch s_traceUndo = new TraceSwitch("UndoEngine", "Trace UndoRedo"); + private static readonly TraceSwitch s_traceUndo = new("UndoEngine", "Trace UndoRedo"); private IServiceProvider _provider; private readonly Stack _unitStack; // the stack of active (non-committed) units. - private UndoUnit _executingUnit; // the unit currently executing an undo. + private UndoUnit? _executingUnit; // the unit currently executing an undo. private readonly IDesignerHost _host; private readonly ComponentSerializationService _serializationService; - private EventHandler _undoingEvent; - private EventHandler _undoneEvent; - private readonly IComponentChangeService _componentChangeService; - private Dictionary> _refToRemovedComponent; - private bool _enabled; + private EventHandler? _undoingEvent; + private EventHandler? _undoneEvent; + private Dictionary>? _refToRemovedComponent; /// /// Creates a new UndoEngine. UndoEngine requires a service provider for access to various services. The following services must be available or else UndoEngine will throw an exception: @@ -44,32 +38,29 @@ protected UndoEngine(IServiceProvider provider) { _provider = provider.OrThrowIfNull(); _unitStack = new Stack(); - _enabled = true; + Enabled = true; // Validate that all required services are available. Because undo is a passive activity we must know up front if it is going to work or not. - _host = GetRequiredService(typeof(IDesignerHost)) as IDesignerHost; - _componentChangeService = GetRequiredService(typeof(IComponentChangeService)) as IComponentChangeService; - _serializationService = GetRequiredService(typeof(ComponentSerializationService)) as ComponentSerializationService; + _host = GetRequiredService(); + ComponentChangeService = GetRequiredService(); + _serializationService = GetRequiredService(); // We need to listen to a slew of events to determine undo state. _host.TransactionOpening += new EventHandler(OnTransactionOpening); _host.TransactionClosed += new DesignerTransactionCloseEventHandler(OnTransactionClosed); - _componentChangeService.ComponentAdding += new ComponentEventHandler(OnComponentAdding); - _componentChangeService.ComponentChanging += new ComponentChangingEventHandler(OnComponentChanging); - _componentChangeService.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving); - _componentChangeService.ComponentAdded += new ComponentEventHandler(OnComponentAdded); - _componentChangeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); - _componentChangeService.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); - _componentChangeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename); + ComponentChangeService.ComponentAdding += new ComponentEventHandler(OnComponentAdding); + ComponentChangeService.ComponentChanging += new ComponentChangingEventHandler(OnComponentChanging); + ComponentChangeService.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving); + ComponentChangeService.ComponentAdded += new ComponentEventHandler(OnComponentAdded); + ComponentChangeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); + ComponentChangeService.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); + ComponentChangeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename); } /// /// This property indicates if an undo is in progress. /// - public bool UndoInProgress - { - get => _executingUnit is not null; - } + public bool UndoInProgress => _executingUnit is not null; /// /// This property returns true if the Undo engine is currently enabled. When enabled, the undo engine tracks changes made to the designer. When disabled, changes are ignored. @@ -79,16 +70,12 @@ public bool UndoInProgress /// For example, if myButton.Text was changed, and then myButton was renamed while undo was disabled, attempting to undo the text change would fail because there is no longer a control called myButton. /// Generally, you should never make changes to components with undo disabled unless you are certain to put the components back the way they were before undo was disabled. An example of this would be to replace one instance of "Button" with another, say "SuperButton", fixing up all the property values as you go. The result is a new component, but because it has the same component name and property values, undo state will still be consistent. /// - public bool Enabled - { - get => _enabled; - set => _enabled = value; - } + public bool Enabled { get; set; } /// /// This event is raised immediately before an undo action is performed. /// - public event EventHandler Undoing + public event EventHandler? Undoing { add => _undoingEvent += value; remove => _undoingEvent -= value; @@ -97,7 +84,7 @@ public event EventHandler Undoing /// /// This event is raised immediately after an undo action is performed. It will always be raised even if an exception is thrown. /// - public event EventHandler Undone + public event EventHandler? Undone { add => _undoneEvent += value; remove => _undoneEvent -= value; @@ -172,15 +159,12 @@ private void CheckPopUnit(PopUnitReason reason) /// This virtual method creates a new instance of an UndoUnit class. The default implementation just returns a new instance of UndoUnit. Those providing their own UndoEngine can derive from UndoUnit to customize the actions it performs. This is also a handy way to connect UndoEngine into an existing undo stack. /// If the primary parameter is set to true, the undo unit will eventually be passed to either the AddUndoUnit or DiscardUndoUnit methods. If the primary parameter is false, the undo unit is part of a nested transaction and will never be passed to AddUndoUnit or DiscardUndoUnit; only the encompassing unit will be passed, because the undo engine will either include or exclude the contents of the nested unit when it is closed. /// - protected virtual UndoUnit CreateUndoUnit(string name, bool primary) + protected virtual UndoUnit CreateUndoUnit(string? name, bool primary) { return new UndoUnit(this, name); } - internal IComponentChangeService ComponentChangeService - { - get => _componentChangeService; - } + internal IComponentChangeService ComponentChangeService { get; } /// /// This method is called instead of AddUndoUnit for undo units that have been canceled. For undo systems that just treat undo as a simple stack of undo units, typically you do not need to override this method. This method does give you a chance to perform any clean-up for a unit @@ -206,36 +190,30 @@ protected virtual void Dispose(bool disposing) { Debug.WriteLineIf(s_traceUndo.TraceVerbose, "UndoEngine: Disposing undo engine"); - if (_host is not null) - { - _host.TransactionOpening -= new EventHandler(OnTransactionOpening); - _host.TransactionClosed -= new DesignerTransactionCloseEventHandler(OnTransactionClosed); - } + _host.TransactionOpening -= new EventHandler(OnTransactionOpening); + _host.TransactionClosed -= new DesignerTransactionCloseEventHandler(OnTransactionClosed); - if (_componentChangeService is not null) - { - _componentChangeService.ComponentAdding -= new ComponentEventHandler(OnComponentAdding); - _componentChangeService.ComponentChanging -= new ComponentChangingEventHandler(OnComponentChanging); - _componentChangeService.ComponentRemoving -= new ComponentEventHandler(OnComponentRemoving); - _componentChangeService.ComponentAdded -= new ComponentEventHandler(OnComponentAdded); - _componentChangeService.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged); - _componentChangeService.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); - _componentChangeService.ComponentRename -= new ComponentRenameEventHandler(OnComponentRename); - } + ComponentChangeService.ComponentAdding -= new ComponentEventHandler(OnComponentAdding); + ComponentChangeService.ComponentChanging -= new ComponentChangingEventHandler(OnComponentChanging); + ComponentChangeService.ComponentRemoving -= new ComponentEventHandler(OnComponentRemoving); + ComponentChangeService.ComponentAdded -= new ComponentEventHandler(OnComponentAdded); + ComponentChangeService.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged); + ComponentChangeService.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); + ComponentChangeService.ComponentRename -= new ComponentRenameEventHandler(OnComponentRename); - _provider = null; + _provider = null!; } } /// /// Helper function to retrieve the name of an object. /// - internal string GetName(object obj, bool generateNew) + internal string? GetName(object? obj, bool generateNew) { - string componentName = null; + string? componentName = null; if (obj is not null) { - if (GetService(typeof(IReferenceService)) is IReferenceService rs) + if (TryGetService(out IReferenceService? rs)) { componentName = rs.GetName(obj); } @@ -243,7 +221,7 @@ internal string GetName(object obj, bool generateNew) { if (obj is IComponent comp) { - ISite site = comp.Site; + ISite? site = comp.Site; if (site is not null) { componentName = site.Name; @@ -254,14 +232,7 @@ internal string GetName(object obj, bool generateNew) if (componentName is null && generateNew) { - if (obj is null) - { - componentName = "(null)"; - } - else - { - componentName = obj.GetType().Name; - } + componentName = obj is null ? "(null)" : obj.GetType().Name; } return componentName; @@ -272,7 +243,7 @@ internal string GetName(object obj, bool generateNew) /// protected object GetRequiredService(Type serviceType) { - object service = GetService(serviceType); + object? service = GetService(serviceType); if (service is null) { Exception ex = new InvalidOperationException(string.Format(SR.UndoEngineMissingService, serviceType.Name)) @@ -285,22 +256,25 @@ protected object GetRequiredService(Type serviceType) return service; } + private protected T GetRequiredService() => (T)GetRequiredService(typeof(T)); + /// /// This just calls through to the service provider passed into the constructor. /// - protected object GetService(Type serviceType) + protected object? GetService(Type serviceType) { ArgumentNullException.ThrowIfNull(serviceType); - if (_provider is not null) - { - return _provider.GetService(serviceType); - } + return _provider?.GetService(serviceType); + } - return null; + private protected bool TryGetService([NotNullWhen(true)] out T? service) where T : class + { + service = GetService(typeof(T)) as T; + return service is not null; } - private void OnComponentAdded(object sender, ComponentEventArgs e) + private void OnComponentAdded(object? sender, ComponentEventArgs e) { foreach (UndoUnit unit in _unitStack) { @@ -313,10 +287,10 @@ private void OnComponentAdded(object sender, ComponentEventArgs e) } } - private void OnComponentAdding(object sender, ComponentEventArgs e) + private void OnComponentAdding(object? sender, ComponentEventArgs e) { // Open a new unit unless there is already one open or we are currently executing a unit. If we need to create a unit, we will have to fabricate a good name. - if (_enabled && _executingUnit is null && _unitStack.Count == 0) + if (Enabled && _executingUnit is null && _unitStack.Count == 0) { string name; if (e.Component is not null) @@ -338,7 +312,7 @@ private void OnComponentAdding(object sender, ComponentEventArgs e) } } - private void OnComponentChanged(object sender, ComponentChangedEventArgs e) + private void OnComponentChanged(object? sender, ComponentChangedEventArgs e) { foreach (UndoUnit unit in _unitStack) { @@ -351,24 +325,24 @@ private void OnComponentChanged(object sender, ComponentChangedEventArgs e) } } - private void OnComponentChanging(object sender, ComponentChangingEventArgs e) + private void OnComponentChanging(object? sender, ComponentChangingEventArgs e) { // Open a new unit unless there is already one open or we are currently executing a unit. If we need to create a unit, we will have to fabricate a good name. - if (_enabled && _executingUnit is null && _unitStack.Count == 0) + if (Enabled && _executingUnit is null && _unitStack.Count == 0) { string name; - if (e.Member is not null && e.Component is not null) + if (e.Component is null) { - name = string.Format(SR.UndoEngineComponentChange2, GetName(e.Component, true), e.Member.Name); + name = SR.UndoEngineComponentChange0; } - else if (e.Component is not null) + else if (e.Member is null) { name = string.Format(SR.UndoEngineComponentChange1, GetName(e.Component, true)); } else { - name = SR.UndoEngineComponentChange0; + name = string.Format(SR.UndoEngineComponentChange2, GetName(e.Component, true), e.Member.Name); } _unitStack.Push(CreateUndoUnit(name, true)); @@ -381,7 +355,7 @@ private void OnComponentChanging(object sender, ComponentChangingEventArgs e) } } - private void OnComponentRemoved(object sender, ComponentEventArgs e) + private void OnComponentRemoved(object? sender, ComponentEventArgs e) { foreach (UndoUnit unit in _unitStack) { @@ -394,21 +368,19 @@ private void OnComponentRemoved(object sender, ComponentEventArgs e) } // Now we need to raise ComponentChanged events for every component that had a reference to this removed component - if (_refToRemovedComponent is not null && _refToRemovedComponent.TryGetValue(e.Component, out List propsToUpdate) && propsToUpdate is not null && _componentChangeService is not null) + if (_refToRemovedComponent is not null && _refToRemovedComponent.Remove(e.Component!, out List? propsToUpdate)) { foreach (ReferencingComponent ro in propsToUpdate) { - _componentChangeService.OnComponentChanged(ro.component, ro.member); + ComponentChangeService.OnComponentChanged(ro.component, ro.member); } - - _refToRemovedComponent.Remove(e.Component); } } - private void OnComponentRemoving(object sender, ComponentEventArgs e) + private void OnComponentRemoving(object? sender, ComponentEventArgs e) { // Open a new unit unless there is already one open or we are currently executing a unit. If we need to create a unit, we will have to fabricate a good name. - if (_enabled && _executingUnit is null && _unitStack.Count == 0) + if (Enabled && _executingUnit is null && _unitStack.Count == 0) { string name; if (e.Component is not null) @@ -424,9 +396,9 @@ private void OnComponentRemoving(object sender, ComponentEventArgs e) } // We need to keep track of all references in the container to the deleted component so that those references can be fixed up if an undo of this "remove" occurs. - if (_enabled && _host is not null && _host.Container is not null && _componentChangeService is not null) + if (Enabled && _host is not null && _host.Container is not null && ComponentChangeService is not null) { - List propsToUpdate = null; + List? propsToUpdate = null; foreach (IComponent comp in _host.Container.Components) { if (comp == e.Component) @@ -437,11 +409,11 @@ private void OnComponentRemoving(object sender, ComponentEventArgs e) PropertyDescriptorCollection props = TypeDescriptor.GetProperties(comp); foreach (PropertyDescriptor prop in props) { - if (prop.PropertyType.IsAssignableFrom(e.Component.GetType()) && + if (prop.PropertyType.IsInstanceOfType(e.Component) && !prop.Attributes.Contains(DesignerSerializationVisibilityAttribute.Hidden) && !prop.IsReadOnly) { - object obj = null; + object? obj = null; try { obj = prop.GetValue(comp); @@ -462,7 +434,7 @@ private void OnComponentRemoving(object sender, ComponentEventArgs e) _refToRemovedComponent[e.Component] = propsToUpdate; } - _componentChangeService.OnComponentChanging(comp, prop); + ComponentChangeService.OnComponentChanging(comp, prop); propsToUpdate.Add(new ReferencingComponent(comp, prop)); } } @@ -477,10 +449,10 @@ private void OnComponentRemoving(object sender, ComponentEventArgs e) } } - private void OnComponentRename(object sender, ComponentRenameEventArgs e) + private void OnComponentRename(object? sender, ComponentRenameEventArgs e) { // Open a new unit unless there is already one open or we are currently executing a unit. If we need to create a unit, we will have to fabricate a good name. - if (_enabled && _executingUnit is null && _unitStack.Count == 0) + if (Enabled && _executingUnit is null && _unitStack.Count == 0) { string name = string.Format(SR.UndoEngineComponentRename, e.OldName, e.NewName); _unitStack.Push(CreateUndoUnit(name, true)); @@ -493,7 +465,7 @@ private void OnComponentRename(object sender, ComponentRenameEventArgs e) } } - private void OnTransactionClosed(object sender, DesignerTransactionCloseEventArgs e) + private void OnTransactionClosed(object? sender, DesignerTransactionCloseEventArgs e) { if (_executingUnit is null && _unitStack.Count > 0) { @@ -502,10 +474,10 @@ private void OnTransactionClosed(object sender, DesignerTransactionCloseEventArg } } - private void OnTransactionOpening(object sender, EventArgs e) + private void OnTransactionOpening(object? sender, EventArgs e) { // When a transaction is opened, we always push a new unit unless we're executing a unit. We can push multiple units onto the stack to handle nested transactions. - if (_enabled && _executingUnit is null) + if (Enabled && _executingUnit is null) { _unitStack.Push(CreateUndoUnit(_host.TransactionDescription, _unitStack.Count == 0)); } @@ -532,10 +504,10 @@ private enum PopUnitReason Normal, TransactionCommit, TransactionCancel, } - private struct ReferencingComponent + private readonly struct ReferencingComponent { - public IComponent component; - public MemberDescriptor member; + public readonly IComponent component; + public readonly MemberDescriptor member; public ReferencingComponent(IComponent component, MemberDescriptor member) { @@ -543,824 +515,4 @@ public ReferencingComponent(IComponent component, MemberDescriptor member) this.member = member; } } - - /// - /// This class embodies a unit of undoable work. The undo engine creates an undo unit when a change to the designer is about to be made. The undo unit is responsible for tracking changes. The undo engine will call Close on the unit when it no longer needs to track changes. - /// - protected class UndoUnit - { - private List _events; // the list of events we've captured - private List _changeEvents; // the list of change events we're currently capturing. Only valid until Commit is called. - private List _removeEvents; // the list of remove events we're currently capturing. Only valid until a matching Removed is encountered. - private List _ignoreAddingList; // the list of objects that are currently being added. We ignore change events between adding and added. - private List _ignoreAddedList; // the list of objects that are added. We do not serialize before state for change events that happen in the same transaction - private bool _reverse; // if true, we walk the events list from the bottom up - private readonly Dictionary _lastSelection; // the selection as it was before we gathered undo info - - public UndoUnit(UndoEngine engine, string name) - { - name ??= string.Empty; - - Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: Creating undo unit '{name}'"); - - Name = name; - UndoEngine = engine.OrThrowIfNull(); - _reverse = true; - if (UndoEngine.GetService(typeof(ISelectionService)) is ISelectionService ss) - { - ICollection selection = ss.GetSelectedComponents(); - Dictionary selectedNames = new(); - foreach (object sel in selection) - { - if (sel is IComponent comp && comp.Site is not null) - { - selectedNames[comp.Site.Name] = comp.Site.Container; - } - } - - _lastSelection = selectedNames; - } - } - - public string Name { get; } - - /// - /// This returns true if the undo unit has nothing in it to undo. The unit will be discarded. - /// - public virtual bool IsEmpty => _events is null || _events.Count == 0; - - protected UndoEngine UndoEngine { get; } - - /// - /// Adds the given event to our event list. - /// - private void AddEvent(UndoEvent e) - { - _events ??= new(); - - _events.Add(e); - } - - /// - /// Called by the undo engine when it wants to close this unit. The unit should do any final work it needs to do to close. - /// - public virtual void Close() - { - if (_changeEvents is not null) - { - foreach (ChangeUndoEvent e in _changeEvents) - { - e.Commit(UndoEngine); - } - } - - if (_removeEvents is not null) - { - foreach (AddRemoveUndoEvent e in _removeEvents) - { - e.Commit(UndoEngine); - } - } - - // At close time we are done with this list. All change events were simultaneously added to the _events list. - _changeEvents = null; - _removeEvents = null; - _ignoreAddingList = null; - _ignoreAddedList = null; - } - - /// - /// The undo engine will call this on the active undo unit in response to a component added event. - /// - public virtual void ComponentAdded(ComponentEventArgs e) - { - if (e.Component.Site is not null && - e.Component.Site.Container is INestedContainer) - { - // do nothing - } - else - { - AddEvent(new AddRemoveUndoEvent(UndoEngine, e.Component, true)); - } - - _ignoreAddingList?.Remove(e.Component); - - _ignoreAddedList ??= new(); - - _ignoreAddedList.Add(e.Component); - } - - /// - /// The undo engine will call this on the active undo unit in response to a component adding event. - /// - public virtual void ComponentAdding(ComponentEventArgs e) - { - _ignoreAddingList ??= new(); - - _ignoreAddingList.Add(e.Component); - } - - private static bool ChangeEventsSymmetric(ComponentChangingEventArgs changing, ComponentChangedEventArgs changed) - { - if (changing is null || changed is null) - { - return false; - } - - return changing.Component == changed.Component && changing.Member == changed.Member; - } - - private bool CanRepositionEvent(int startIndex, ComponentChangedEventArgs e) - { - bool containsAdd = false; - bool containsRename = false; - bool containsSymmetricChange = false; - for (int i = startIndex + 1; i < _events.Count; i++) - { - if (_events[i] is AddRemoveUndoEvent addEvt && !addEvt.NextUndoAdds) - { - containsAdd = true; - } - else if (_events[i] is ChangeUndoEvent changeEvt && ChangeEventsSymmetric(changeEvt.ComponentChangingEventArgs, e)) - { - containsSymmetricChange = true; - } - else if (_events[i] is RenameUndoEvent) - { - containsRename = true; - } - } - - return containsAdd && !containsRename && !containsSymmetricChange; - } - - /// - /// The undo engine will call this on the active undo unit in response to a component changed event. - /// - public virtual void ComponentChanged(ComponentChangedEventArgs e) - { - if (_events is not null && e is not null) - { - for (int i = 0; i < _events.Count; i++) - { - // Determine if we've located the UndoEvent which was created as a result of a corresponding ComponentChanging event. - // If so, reposition to the "Changed" spot in the list if the following is true: - // - It must be for a DSV.Content property - // - There must be a AddEvent between the Changing and Changed - // - There are no renames in between Changing and Changed. - if (_events[i] is ChangeUndoEvent ce && ChangeEventsSymmetric(ce.ComponentChangingEventArgs, e) && i != _events.Count - 1) - { - if (e.Member is not null && e.Member.Attributes.Contains(DesignerSerializationVisibilityAttribute.Content) && - CanRepositionEvent(i, e)) - { - _events.RemoveAt(i); - _events.Add(ce); - } - } - } - } - } - - /// - /// The undo engine will call this on the active undo unit in response to a component changing event. - /// - public virtual void ComponentChanging(ComponentChangingEventArgs e) - { - // If we are in the process of adding this component, ignore any changes to it. The ending "Added" event will capture the component's state. This not just an optimization. If we get a change during an add, we can have an undo order that specifies a remove, and then a change to a removed component. - if (_ignoreAddingList is not null && _ignoreAddingList.Contains(e.Component)) - { - return; - } - - _changeEvents ??= new(); - - // The site check here is done because the data team is calling us for components that are not yet sited. We end up writing them out as Guid-named locals. That's fine, except that we cannot capture after state for these types of things so we assert. - if (UndoEngine.GetName(e.Component, false) is not null) - { - // The caller provided us with a component. This is the common case. We will add a new change event provided there is not already one open for this component. - bool hasChange = false; - - for (int idx = 0; idx < _changeEvents.Count; idx++) - { - ChangeUndoEvent ce = _changeEvents[idx]; - if (ce.OpenComponent == e.Component && ce.ContainsChange(e.Member)) - { - hasChange = true; - break; - } - } - - if (!hasChange || - (e.Member is not null && e.Member.Attributes is not null && e.Member.Attributes.Contains(DesignerSerializationVisibilityAttribute.Content))) - { -#if DEBUG - string name = UndoEngine.GetName(e.Component, false); - string memberName = "(none)"; - if (e.Member is not null && e.Member.Name is not null) - { - memberName = e.Member.Name; - } - - if (name is not null) - { - Debug.WriteLineIf(s_traceUndo.TraceVerbose && hasChange, $"Adding second ChangeEvent for {name} Member: {memberName}"); - } - else - { - Debug.Fail("UndoEngine: GetName is failing on successive calls"); - } -#endif - ChangeUndoEvent changeEvent = null; - bool serializeBeforeState = true; - //perf: if this object was added in this undo unit we do not want to serialize before state for ChangeEvent since undo will remove it anyway - if (_ignoreAddedList is not null && _ignoreAddedList.Contains(e.Component)) - { - serializeBeforeState = false; - } - - if (e.Component is IComponent comp && comp.Site is not null) - { - changeEvent = new ChangeUndoEvent(UndoEngine, e, serializeBeforeState); - } - else if (e.Component is not null) - { - if (GetService(typeof(IReferenceService)) is IReferenceService rs) - { - IComponent owningComp = rs.GetComponent(e.Component); - - if (owningComp is not null) - { - changeEvent = new ChangeUndoEvent(UndoEngine, new ComponentChangingEventArgs(owningComp, null), serializeBeforeState); - } - } - } - - if (changeEvent is not null) - { - AddEvent(changeEvent); - _changeEvents.Add(changeEvent); - } - } - } - } - - /// - /// The undo engine will call this on the active undo unit in response to a component removed event. - /// - public virtual void ComponentRemoved(ComponentEventArgs e) - { - // We should gather undo state in ComponentRemoved, but by this time the component's designer has been destroyed so it's too late. Instead, we captured state in the Removing method. But, it is possible for there to be component changes to other objects that happen between removing and removed, so we need to reorder the removing event so it's positioned after any changes. - if (_events is not null && e is not null) - { - ChangeUndoEvent changeEvt = null; - int changeIdx = -1; - for (int idx = _events.Count - 1; idx >= 0; idx--) - { - if (changeEvt is null) - { - changeEvt = _events[idx] as ChangeUndoEvent; - changeIdx = idx; - } - - if (_events[idx] is AddRemoveUndoEvent evt && evt.OpenComponent == e.Component) - { - evt.Commit(UndoEngine); - // We should only reorder events if there are change events coming between OnRemoving and OnRemoved. - // If there are other events (such as AddRemoving), the serialization done in OnComponentRemoving might refer to components that aren't available. - if (idx != _events.Count - 1 && changeEvt is not null) - { - // ensure only change change events exist between these two events - bool onlyChange = true; - for (int i = idx + 1; i < changeIdx; i++) - { - if (!(_events[i] is ChangeUndoEvent)) - { - onlyChange = false; - break; - } - } - - if (onlyChange) - { - // reposition event after final ComponentChangingEvent - _events.RemoveAt(idx); - _events.Insert(changeIdx, evt); - } - } - - break; - } - } - } - } - - /// - /// The undo engine will call this on the active undo unit in response to a component removing event. - /// - public virtual void ComponentRemoving(ComponentEventArgs e) - { - if (e.Component.Site is not null && - e.Component.Site is INestedContainer) - { - return; - } - - _removeEvents ??= new(); - - try - { - AddRemoveUndoEvent evt = new AddRemoveUndoEvent(UndoEngine, e.Component, false); - AddEvent(evt); - _removeEvents.Add(evt); - } - catch (TargetInvocationException) { } - } - - /// - /// The undo engine will cal this on the active undo unit in response to a component rename event. - /// - public virtual void ComponentRename(ComponentRenameEventArgs e) - { - AddEvent(new RenameUndoEvent(e.OldName, e.NewName)); - } - - /// - /// Returns an instance of the requested service. - /// - protected object GetService(Type serviceType) - { - return UndoEngine.GetService(serviceType); - } - - /// - /// Override for object.ToString() - /// - public override string ToString() - { - return Name; - } - - /// - /// Either performs undo, or redo, depending on the state of the unit. UndoUnit initially assumes that the undoable work has already been "done", so the first call to undo will undo the work. The next call will undo the "undo", performing a redo. - /// - public void Undo() - { - Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: Performing undo '{Name}'"); - UndoUnit savedUnit = UndoEngine._executingUnit; - UndoEngine._executingUnit = this; - DesignerTransaction transaction = null; - try - { - if (savedUnit is null) - { - UndoEngine.OnUndoing(EventArgs.Empty); - } - - // create a transaction here so things that do work on componentchanged can ignore that while the transaction is opened...big perf win. - transaction = UndoEngine._host.CreateTransaction(); - UndoCore(); - } - catch (CheckoutException) - { - transaction.Cancel(); - transaction = null; - throw; - } - finally - { - transaction?.Commit(); - - UndoEngine._executingUnit = savedUnit; - if (savedUnit is null) - { - UndoEngine.OnUndone(EventArgs.Empty); - } - } - } - - /// - /// The undo method invokes this method to perform the actual undo / redo work. You should never call this method directly; override it if you wish, but always call the public Undo method to perform undo work. Undo notifies the undo engine to suspend undo data gathering until this undo is completed, which prevents new undo units from being created in response to this unit doing work. - /// - protected virtual void UndoCore() - { - if (_events is not null) - { - if (_reverse) - { - // How does BeforeUndo work? You'd think you should just call this in one pass, and then call Undo in another, but you'd be wrong. The complexity arises because there are undo events that have dependencies on other undo events. There are also undo events that have side effects with respect to other events. Here are examples: - // Rename is an undo event that other undo events depend on, because they store names. It must be performed in the right order and it must be performed before any subsequent event's BeforeUndo is called. - // Property change is an undo event that may have an unknown side effect if changing the property results in other property changes (for example, reparenting a control removes the control from its former parent). A property change undo event must have all BeforeUndo methods called before any Undo method is called. To do this, we have a property on UndoEvent called CausesSideEffects. - // As we run through UndoEvents, consecutive events that return true from this property are grouped so that their BeforeUndo methods are all called before their Undo methods. For events that do not have side effects, their BeforeUndo and Undo are invoked immediately. - for (int idx = _events.Count - 1; idx >= 0; idx--) - { - int groupEndIdx = idx; - for (int groupIdx = idx; groupIdx >= 0; groupIdx--) - { - if (_events[groupIdx].CausesSideEffects) - { - groupEndIdx = groupIdx; - } - else - { - break; - } - } - - for (int beforeIdx = idx; beforeIdx >= groupEndIdx; beforeIdx--) - { - (_events[beforeIdx]).BeforeUndo(UndoEngine); - } - - for (int undoIdx = idx; undoIdx >= groupEndIdx; undoIdx--) - { - (_events[undoIdx]).Undo(UndoEngine); - } - - Debug.Assert(idx >= groupEndIdx, "We're going backwards"); - idx = groupEndIdx; - } - - // Now, if we have a selection, apply it. - if (_lastSelection is not null) - { - if (UndoEngine.GetService(typeof(ISelectionService)) is ISelectionService ss) - { - List list = new(_lastSelection.Keys.Count); - foreach ((string name, IContainer container) in _lastSelection) - { - IComponent comp = container.Components[name]; - if (comp is not null) - { - list.Add(comp); - } - } - - ss.SetSelectedComponents(list, SelectionTypes.Replace); - } - } - } - else - { - int count = _events.Count; - for (int idx = 0; idx < count; idx++) - { - int groupEndIdx = idx; - - for (int groupIdx = idx; groupIdx < count; groupIdx++) - { - if (_events[groupIdx].CausesSideEffects) - { - groupEndIdx = groupIdx; - } - else - { - break; - } - } - - for (int beforeIdx = idx; beforeIdx <= groupEndIdx; beforeIdx++) - { - (_events[beforeIdx]).BeforeUndo(UndoEngine); - } - - for (int undoIdx = idx; undoIdx <= groupEndIdx; undoIdx++) - { - (_events[undoIdx]).Undo(UndoEngine); - } - - Debug.Assert(idx <= groupEndIdx, "We're going backwards"); - idx = groupEndIdx; - } - } - } - - _reverse = !_reverse; - } - - /// - /// This undo event handles addition and removal of components. - /// - private sealed class AddRemoveUndoEvent : UndoEvent - { - private readonly SerializationStore _serializedData; - private readonly string _componentName; - private bool _nextUndoAdds; - private bool _committed; - private readonly IComponent _openComponent; - - /// - /// Creates a new object that contains the state of the event. The last parameter, add, determines the initial mode of this event. If true, it means this event is being created in response to a component add. If false, it is being created in response to a component remove. - /// - public AddRemoveUndoEvent(UndoEngine engine, IComponent component, bool add) - { - _componentName = component.Site.Name; - _nextUndoAdds = !add; - _openComponent = component; - - Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Creating {(add ? "Add" : "Remove")} undo event for '{_componentName}'"); - using (_serializedData = engine._serializationService.CreateStore()) - { - engine._serializationService.Serialize(_serializedData, component); - } - - // For add events, we commit as soon as we receive the event. - _committed = add; - } - - /// - /// Returns true if the add remove event has been comitted. - /// - internal bool Committed - { - get => _committed; - } - - /// - /// If this add/remove event is still open, OpenComponent will contain the component it is operating on. - /// - internal IComponent OpenComponent - { - get => _openComponent; - } - - /// - /// Returns true if undoing this event will add a component. - /// - internal bool NextUndoAdds - { - get => _nextUndoAdds; - } - - /// - /// Commits this event. - /// - internal void Commit(UndoEngine engine) - { - if (!Committed) - { - Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Committing remove of '{_componentName}'"); - _committed = true; - } - } - - /// - /// Actually performs the undo action. - /// - public override void Undo(UndoEngine engine) - { - if (_nextUndoAdds) - { - Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Adding '{_componentName}'"); - // We need to add this component. To add it, we deserialize it and then we add it to the designer host's container. - if (engine.GetRequiredService(typeof(IDesignerHost)) is IDesignerHost host) - { - engine._serializationService.DeserializeTo(_serializedData, host.Container); - } - } - else - { - Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Removing '{_componentName}'"); - // We need to remove this component. Take the name and match it to an object, and then ask that object to delete itself. - IDesignerHost host = engine.GetRequiredService(typeof(IDesignerHost)) as IDesignerHost; - - IComponent component = host.Container.Components[_componentName]; - - // Note: It's ok for the component to be null here. This could happen if the parent to this control is disposed first. Ex:SplitContainer - if (component is not null) - { - host.DestroyComponent(component); - } - } - - _nextUndoAdds = !_nextUndoAdds; - } - } - - private sealed class ChangeUndoEvent : UndoEvent - { - // This is only valid while the change is still open. The change is committed. - private object _openComponent; - // Static data we hang onto about this change. - private readonly string _componentName; - private readonly MemberDescriptor _member; - // Before and after state. Before state is built in the constructor. After state is built right before we undo for the first time. - private SerializationStore _before; - private SerializationStore _after; - private bool _savedAfterState; - - /// - /// Creates a new component change undo event. This event consists of a before and after snapshot of a single component. A snapshot will not be taken if a name for the component cannot be determined. - /// - public ChangeUndoEvent(UndoEngine engine, ComponentChangingEventArgs e, bool serializeBeforeState) - { - _componentName = engine.GetName(e.Component, true); - _openComponent = e.Component; - _member = e.Member; - - Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Creating change undo event for '{_componentName}'"); - if (serializeBeforeState) - { - Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Saving before snapshot for change to '{_componentName}'"); - _before = Serialize(engine, _openComponent, _member); - } - } - - public ComponentChangingEventArgs ComponentChangingEventArgs - { - get => new ComponentChangingEventArgs(_openComponent, _member); - } - - /// - /// Indicates that undoing this event may cause side effects in other objects. - /// Change events fall into this category because, for example, a change involving adding an object to one collection may have a side effect of removing it from another collection. Events with side effects are grouped at undo time so all their BeforeUndo methods are called before their Undo methods. - /// Events without side effects have their BeforeUndo called and then their Undo called immediately after. - /// - public override bool CausesSideEffects { get { return true; } } - - /// - /// Returns true if the change event has been comitted. - /// - public bool Committed - { - get - { - return _openComponent is null; - } - } - - /// - /// Returns the component this change event is currently tracking. This will return null once the change event is committed. - /// - public object OpenComponent - { - get - { - return _openComponent; - } - } - - /// - /// Called before Undo is called. All undo events get their BeforeUndo called, and then they all get their Undo called. This allows the undo event to examine the state of the world before other undo events mess with it. - /// - public override void BeforeUndo(UndoEngine engine) - { - if (!_savedAfterState) - { - _savedAfterState = true; - SaveAfterState(engine); - } - } - - /// - /// Determines if this - /// - public bool ContainsChange(MemberDescriptor desc) - { - if (_member is null) - { - return true; - } - - if (desc is null) - { - return false; - } - - return desc.Equals(_member); - } - - /// - /// Commits the unit. Committing the unit saves the "after" snapshot of the unit. If commit is called multiple times only the first commit is registered. - /// - public void Commit(UndoEngine engine) - { - if (!Committed) - { - Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Committing change to '{_componentName}'"); - _openComponent = null; - } - } - - private void SaveAfterState(UndoEngine engine) - { - Debug.Assert(_after is null, "Change undo saving state twice."); - Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Saving after snapshot for change to '{_componentName}'"); - object component = null; - - if (engine.GetService(typeof(IReferenceService)) is IReferenceService rs) - { - component = rs.GetReference(_componentName); - } - else - { - if (engine.GetService(typeof(IDesignerHost)) is IDesignerHost host) - { - component = host.Container.Components[_componentName]; - } - } - - // It is OK for us to not find a component here. That can happen if our "after" state is owned by another change, like an add of the component. - if (component is not null) - { - _after = Serialize(engine, component, _member); - } - } - - private static SerializationStore Serialize(UndoEngine engine, object component, MemberDescriptor member) - { - SerializationStore store; - using (store = engine._serializationService.CreateStore()) - { - if (member is not null && !(member.Attributes.Contains(DesignerSerializationVisibilityAttribute.Hidden))) - { - engine._serializationService.SerializeMemberAbsolute(store, component, member); - } - else - { - engine._serializationService.SerializeAbsolute(store, component); - } - } - - return store; - } - - /// - /// Performs the actual undo. AFter it finishes it will reverse the role of _before and _after - /// - public override void Undo(UndoEngine engine) - { - Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Applying changes to '{_componentName}'"); - Debug.Assert(_savedAfterState, "After state not saved. BeforeUndo was not called?"); - - if (_before is not null) - { - if (engine.GetService(typeof(IDesignerHost)) is IDesignerHost host) - { - engine._serializationService.DeserializeTo(_before, host.Container); - } - } - - SerializationStore temp = _after; - _after = _before; - _before = temp; - } - } - - private sealed class RenameUndoEvent : UndoEvent - { - private string _before; - private string _after; - - /// - /// Creates a new rename undo event. - /// - public RenameUndoEvent(string before, string after) - { - _before = before; - _after = after; - Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Creating rename undo event for '{_before}'->'{_after}'"); - } - - /// - /// Simply undoes a rename by setting the name back to the saved value. - /// - public override void Undo(UndoEngine engine) - { - Debug.WriteLineIf(s_traceUndo.TraceVerbose, $"UndoEngine: ---> Renaming '{_after}'->'{_before}'"); - IComponent comp = engine._host.Container.Components[_after]; - if (comp is not null) - { - engine.ComponentChangeService.OnComponentChanging(comp, null); - comp.Site.Name = _before; - string temp = _after; - _after = _before; - _before = temp; - } - } - } - - private abstract class UndoEvent - { - /// - /// Indicates that undoing this event may cause side effects in other objects. - /// Change events fall into this category because, for example, a change involving adding an object to one collection may have a side effect of removing it from another collection. - /// Events with side effects are grouped at undo time so all their BeforeUndo methods are called before their Undo methods. - /// Events without side effects have their BeforeUndo called and then their Undo called immediately after. - /// - public virtual bool CausesSideEffects { get { return false; } } - - /// - /// Called before Undo is called. All undo events get their BeforeUndo called, and then they all get their Undo called. This allows the undo event to examine the state of the world before other undo events mess with it. BeforeUndo returns true if before undo was supported, and false if not. If before undo is not supported, the undo unit should be undone immediately. - /// - public virtual void BeforeUndo(UndoEngine engine) - { - } - - /// - /// Called by the undo unit when it wants to undo this bit of work. - /// - public abstract void Undo(UndoEngine engine); - } - } } diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/BitmapSelector.cs b/src/System.Windows.Forms.Design/src/System/Drawing/BitmapSelector.cs index b7954cae9a4..b3c4251a2d7 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/BitmapSelector.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/BitmapSelector.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/BitmapEditor.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/BitmapEditor.cs index 955d1f5e675..23410752a92 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/BitmapEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/BitmapEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Drawing.Design; @@ -11,7 +10,7 @@ namespace System.Drawing.Design; [CLSCompliant(false)] public class BitmapEditor : ImageEditor { - protected static List BitmapExtensions = new List() { "bmp", "gif", "jpg", "jpeg", "png", "ico" }; + protected static List BitmapExtensions = new() { "bmp", "gif", "jpg", "jpeg", "png", "ico" }; protected override string GetFileDialogDescription() => SR.bitmapFileDescription; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorPalette.ColorPaletteAccessibleObject.ColorCellAccessibleObject.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorPalette.ColorPaletteAccessibleObject.ColorCellAccessibleObject.cs index ffb9a31aa3b..6e80f9b1974 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorPalette.ColorPaletteAccessibleObject.ColorCellAccessibleObject.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorPalette.ColorPaletteAccessibleObject.ColorCellAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorPalette.ColorPaletteAccessibleObject.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorPalette.ColorPaletteAccessibleObject.cs index bbfc69a49e6..1fe4b316e58 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorPalette.ColorPaletteAccessibleObject.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorPalette.ColorPaletteAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorPalette.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorPalette.cs index e23118576ec..85520e32936 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorPalette.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorPalette.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorUI.ColorEditorListBox.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorUI.ColorEditorListBox.cs index 5f896faa1b5..a87def519f6 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorUI.ColorEditorListBox.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorUI.ColorEditorListBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorUI.ColorEditorTabControl.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorUI.ColorEditorTabControl.cs index 717efb99ffe..175e63c0bc1 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorUI.ColorEditorTabControl.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorUI.ColorEditorTabControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorUI.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorUI.cs index 0daa241ba9d..20d35903174 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorUI.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.ColorUI.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.CustomColorDialog.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.CustomColorDialog.cs index 835d3564a76..871b6880ddc 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.CustomColorDialog.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.CustomColorDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.StandardColorComparer.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.StandardColorComparer.cs index d27c765f376..500f6af5ddd 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.StandardColorComparer.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.StandardColorComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.SystemColorComparer.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.SystemColorComparer.cs index 57035cce8ff..5a5a0c9d998 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.SystemColorComparer.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.SystemColorComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.cs index d9f859a9840..568b8db3d56 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ColorEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ContentAlignmentEditor.ContentUI.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ContentAlignmentEditor.ContentUI.cs index a01a3fb09d6..8bd94c1ed6b 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ContentAlignmentEditor.ContentUI.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ContentAlignmentEditor.ContentUI.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ContentAlignmentEditor.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ContentAlignmentEditor.cs index 203d16f4604..2a68257f9d0 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ContentAlignmentEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ContentAlignmentEditor.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.Windows.Forms.Design; @@ -14,14 +11,14 @@ namespace System.Drawing.Design; /// public partial class ContentAlignmentEditor : UITypeEditor { - private ContentUI _contentUI; + private ContentUI? _contentUI; /// /// Edits the given object value using the editor style provided by GetEditStyle. /// - public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) + public override object? EditValue(ITypeDescriptorContext? context, IServiceProvider provider, object? value) { - if (!provider.TryGetService(out IWindowsFormsEditorService editorService)) + if (!provider.TryGetService(out IWindowsFormsEditorService? editorService)) { return value; } @@ -37,6 +34,6 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide } /// - public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext? context) => UITypeEditorEditStyle.DropDown; } diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.CursorUI.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.CursorUI.cs index 51d785450f2..aaf6d3c5b1b 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.CursorUI.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.CursorUI.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.Windows.Forms; @@ -17,8 +14,7 @@ public partial class CursorEditor /// private class CursorUI : ListBox { - private object _value; - private IWindowsFormsEditorService _editorService; + private IWindowsFormsEditorService? _editorService; private readonly TypeConverter _cursorConverter; public CursorUI() @@ -36,26 +32,26 @@ public CursorUI() // Fill the list with cursors. if (_cursorConverter.GetStandardValuesSupported()) { - foreach (object obj in _cursorConverter.GetStandardValues()) + foreach (object obj in _cursorConverter.GetStandardValues()!) { Items.Add(obj); } } } - public object Value => _value; + public object? Value { get; private set; } public void End() { _editorService = null; - _value = null; + Value = null; } protected override void OnClick(EventArgs e) { base.OnClick(e); - _value = SelectedItem; - _editorService.CloseDropDown(); + Value = SelectedItem; + _editorService!.CloseDropDown(); } protected override void OnDrawItem(DrawItemEventArgs e) @@ -65,8 +61,8 @@ protected override void OnDrawItem(DrawItemEventArgs e) if (e.Index != -1) { Cursor cursor = (Cursor)Items[e.Index]; - string text = _cursorConverter.ConvertToString(cursor); - Font font = e.Font; + string? text = _cursorConverter.ConvertToString(cursor); + Font font = e.Font!; using var brushText = e.ForeColor.GetCachedSolidBrushScope(); e.DrawBackground(); @@ -89,10 +85,10 @@ protected override bool ProcessDialogKey(Keys keyData) return base.ProcessDialogKey(keyData); } - public void Start(IWindowsFormsEditorService editorService, object value) + public void Start(IWindowsFormsEditorService editorService, object? value) { _editorService = editorService; - _value = value; + Value = value; // Select the current cursor if (value is not null) diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.cs index 2e06dbf5dff..b3a5937aba9 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.Windows.Forms.Design; @@ -15,16 +12,16 @@ namespace System.Drawing.Design; [CLSCompliant(false)] public partial class CursorEditor : UITypeEditor { - private CursorUI _cursorUI; + private CursorUI? _cursorUI; /// /// Returns true, indicating that this drop-down control can be resized. /// public override bool IsDropDownResizable => true; - public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) + public override object? EditValue(ITypeDescriptorContext? context, IServiceProvider provider, object? value) { - if (!provider.TryGetService(out IWindowsFormsEditorService editorService)) + if (!provider.TryGetService(out IWindowsFormsEditorService? editorService)) { return value; } @@ -40,5 +37,5 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide } /// - public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.DropDown; + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext? context) => UITypeEditorEditStyle.DropDown; } diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/FontEditor.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/FontEditor.cs index 915755eb6f7..9f9ba551aef 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/FontEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/FontEditor.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.Windows.Forms; @@ -16,12 +13,12 @@ namespace System.Drawing.Design; [CLSCompliant(false)] public class FontEditor : UITypeEditor { - private FontDialog _fontDialog; + private FontDialog? _fontDialog; - public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) + public override object? EditValue(ITypeDescriptorContext? context, IServiceProvider provider, object? value) { // Even though we don't use the editor service this is historically what we did. - if (!provider.TryGetService(out IWindowsFormsEditorService _)) + if (!provider.TryGetService(out IWindowsFormsEditorService? _)) { return value; } @@ -57,5 +54,5 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide return value; } - public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.Modal; + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext? context) => UITypeEditorEditStyle.Modal; } diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/FontNameEditor.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/FontNameEditor.cs index 5d0a73885c6..5627d5a2a0f 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/FontNameEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/FontNameEditor.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; @@ -15,7 +12,7 @@ public class FontNameEditor : UITypeEditor { private const float ScaleFactor = 1.5f; - private static readonly FontStyle[] s_fontStyles = new[] + private static readonly FontStyle[] s_fontStyles = { FontStyle.Regular, FontStyle.Italic, @@ -27,12 +24,12 @@ public class FontNameEditor : UITypeEditor /// /// as this editor supports the painting of a representation of an object's value. /// - public override bool GetPaintValueSupported(ITypeDescriptorContext context) => true; + public override bool GetPaintValueSupported(ITypeDescriptorContext? context) => true; /// public override void PaintValue(PaintValueEventArgs e) { - string fontName = e.Value as string; + string? fontName = e.Value as string; if (string.IsNullOrWhiteSpace(fontName)) { // Don't draw anything if we don't have a value. @@ -41,7 +38,7 @@ public override void PaintValue(PaintValueEventArgs e) try { - using var fontFamily = new FontFamily(fontName); + using FontFamily fontFamily = new(fontName); e.Graphics.FillRectangle(SystemBrushes.ActiveCaption, e.Bounds); // Believe it or not, not all font families have a "normal" face. Try normal, then italic, @@ -72,9 +69,9 @@ public override void PaintValue(PaintValueEventArgs e) private static void DrawFontSample(PaintValueEventArgs e, FontFamily fontFamily, FontStyle fontStyle) { float fontSize = e.Bounds.Height / ScaleFactor; - using var font = new Font(fontFamily, fontSize, fontStyle, GraphicsUnit.Pixel); + using Font font = new(fontFamily, fontSize, fontStyle, GraphicsUnit.Pixel); - var format = new StringFormat(StringFormatFlags.NoWrap | StringFormatFlags.NoFontFallback) + StringFormat format = new(StringFormatFlags.NoWrap | StringFormatFlags.NoFontFallback) { LineAlignment = StringAlignment.Far }; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxItemProvider.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxItemProvider.cs index c613c07d6ce..c7a010f7108 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxItemProvider.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxItemProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Drawing.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxService.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxService.cs index 5324ea2b063..9b629721319 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxService.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxUser.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxUser.cs index 6a8ecc265b9..2aadf98ea1a 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxUser.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/IToolboxUser.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/IconEditor.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/IconEditor.cs index 6fd4f26573c..cded48777cf 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/IconEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/IconEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Windows.Forms; @@ -16,7 +15,7 @@ namespace System.Drawing.Design; /// public class IconEditor : UITypeEditor { - private static readonly List s_iconExtensions = new List() { "ico" }; + private static readonly List s_iconExtensions = new() { "ico" }; private static readonly Type[] s_imageExtenders = Array.Empty(); private FileDialog? _fileDialog; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ImageEditor.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ImageEditor.cs index 391c92c9b12..402b0e14619 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ImageEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ImageEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Reflection; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/MetafileEditor.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/MetafileEditor.cs index 5a21e5aa29b..943c5a223f7 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/MetafileEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/MetafileEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing.Imaging; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/SelectionPanelBase.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/SelectionPanelBase.cs index f145843c5ad..d9063754394 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/SelectionPanelBase.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/SelectionPanelBase.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Windows.Forms; using System.Windows.Forms.Design; @@ -12,12 +9,12 @@ namespace System.Drawing.Design; internal abstract partial class SelectionPanelBase : Control { private bool _allowExit = true; - private RadioButton _checkedControl; - private IWindowsFormsEditorService _editorService; + private RadioButton? _checkedControl; + private IWindowsFormsEditorService? _editorService; protected RadioButton CheckedControl { - get => _checkedControl; + get => _checkedControl!; set { _checkedControl = value; @@ -27,7 +24,7 @@ protected RadioButton CheckedControl protected abstract ControlCollection SelectionOptions { get; } - public object Value { get; protected set; } + public object? Value { get; protected set; } public void End() { @@ -45,11 +42,11 @@ private void FocusCheckedControl() _allowExit = true; } - private void OnClick(object sender, EventArgs e) + private void OnClick(object? sender, EventArgs e) { if (_allowExit) { - CheckedControl = (RadioButton)sender; + CheckedControl = (RadioButton)sender!; UpdateValue(); Teardown(); } @@ -61,9 +58,9 @@ protected override void OnGotFocus(EventArgs e) FocusCheckedControl(); } - private void OnKeyDown(object sender, KeyEventArgs e) + private void OnKeyDown(object? sender, KeyEventArgs e) { - var radioButton = (RadioButton)sender; + var radioButton = (RadioButton)sender!; Keys key = e.KeyCode; RadioButton target; @@ -120,7 +117,7 @@ protected override bool ProcessDialogKey(Keys keyData) protected abstract void SetInitialCheckedControl(); - public void Start(IWindowsFormsEditorService edSvc, object value) + public void Start(IWindowsFormsEditorService edSvc, object? value) { foreach (RadioButton radioButton in SelectionOptions) { @@ -145,7 +142,7 @@ protected void ConfigureButtons() private void Teardown() { - _editorService.CloseDropDown(); + _editorService!.CloseDropDown(); } protected abstract void UpdateValue(); diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventArgs.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventArgs.cs index c0a6314c262..0cb355dd464 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventArgs.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventHandler.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventHandler.cs index 1b4273ee89d..bc4ffeafd39 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Drawing.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventArgs.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventArgs.cs index 29a4914689b..40f1d1e2b1d 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventArgs.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventHandler.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventHandler.cs index c7423909226..c9385c3f7c6 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxComponentsCreatingEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Drawing.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs index e29269598bb..2a1ec3fa3f7 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -18,7 +17,7 @@ namespace System.Drawing.Design; /// public class ToolboxItem : ISerializable { - private static readonly TraceSwitch s_toolboxItemPersist = new TraceSwitch("ToolboxPersisting", "ToolboxItem: write data"); + private static readonly TraceSwitch s_toolboxItemPersist = new("ToolboxPersisting", "ToolboxItem: write data"); private static bool s_isScalingInitialized; private const int ICON_DIMENSION = 16; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItemCollection.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItemCollection.cs index 3c41d4019fb..308c01573c8 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItemCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItemCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItemCreatorCallback.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItemCreatorCallback.cs index 80992f23ccc..c1d565161fb 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItemCreatorCallback.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItemCreatorCallback.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Drawing.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/SelectionPanelBase.SelectionPanelRadioButton.cs b/src/System.Windows.Forms.Design/src/System/Drawing/SelectionPanelBase.SelectionPanelRadioButton.cs index 5633889b7fa..cf319a18693 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/SelectionPanelBase.SelectionPanelRadioButton.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/SelectionPanelBase.SelectionPanelRadioButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Design/src/System/Resources/Tools/ITargetAwareCodeDomProvider.cs b/src/System.Windows.Forms.Design/src/System/Resources/Tools/ITargetAwareCodeDomProvider.cs index fc12f8ccfb6..3db34b9c89d 100644 --- a/src/System.Windows.Forms.Design/src/System/Resources/Tools/ITargetAwareCodeDomProvider.cs +++ b/src/System.Windows.Forms.Design/src/System/Resources/Tools/ITargetAwareCodeDomProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/System/Resources/Tools/StronglyTypedResourceBuilder.ResourceData.cs b/src/System.Windows.Forms.Design/src/System/Resources/Tools/StronglyTypedResourceBuilder.ResourceData.cs index c3e51cf39bd..b238ebdbac4 100644 --- a/src/System.Windows.Forms.Design/src/System/Resources/Tools/StronglyTypedResourceBuilder.ResourceData.cs +++ b/src/System.Windows.Forms.Design/src/System/Resources/Tools/StronglyTypedResourceBuilder.ResourceData.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Resources.Tools; diff --git a/src/System.Windows.Forms.Design/src/System/Resources/Tools/StronglyTypedResourceBuilder.cs b/src/System.Windows.Forms.Design/src/System/Resources/Tools/StronglyTypedResourceBuilder.cs index 23d6c1adb08..b69dbfa1c53 100644 --- a/src/System.Windows.Forms.Design/src/System/Resources/Tools/StronglyTypedResourceBuilder.cs +++ b/src/System.Windows.Forms.Design/src/System/Resources/Tools/StronglyTypedResourceBuilder.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Runtime/InteropServices/UCOMITypeLib.cs b/src/System.Windows.Forms.Design/src/System/Runtime/InteropServices/UCOMITypeLib.cs index 3d69b846ade..01342f7bf35 100644 --- a/src/System.Windows.Forms.Design/src/System/Runtime/InteropServices/UCOMITypeLib.cs +++ b/src/System.Windows.Forms.Design/src/System/Runtime/InteropServices/UCOMITypeLib.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices.ComTypes; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AdornmentType.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AdornmentType.cs index 31c5f20b53b..5fa8de7c275 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AdornmentType.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AdornmentType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.AnchorUI.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.AnchorUI.cs index 7d64a0fd730..ef1bab76269 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.AnchorUI.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.AnchorUI.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Drawing; @@ -15,56 +12,54 @@ public sealed partial class AnchorEditor /// private class AnchorUI : Control { - private readonly SpringControl bottom; - private readonly ContainerPlaceholder container = new ContainerPlaceholder(); - private readonly ControlPlaceholder control = new ControlPlaceholder(); - private readonly SpringControl left; - private readonly SpringControl right; - private readonly SpringControl[] tabOrder; - private readonly SpringControl top; - private readonly AnchorEditor editor; - private IWindowsFormsEditorService edSvc; - private AnchorStyles oldAnchor; - - public AnchorUI(AnchorEditor editor) + private readonly SpringControl _bottom; + private readonly ContainerPlaceholder _container = new(); + private readonly ControlPlaceholder _control = new(); + private readonly SpringControl _left; + private readonly SpringControl _right; + private readonly SpringControl[] _tabOrder; + private readonly SpringControl _top; + private IWindowsFormsEditorService? _editorService; + private AnchorStyles _oldAnchor; + + public AnchorUI() { - this.editor = editor; - left = new SpringControl(this) { AccessibleRole = AccessibleRole.CheckButton }; - right = new SpringControl(this) { AccessibleRole = AccessibleRole.CheckButton }; - top = new SpringControl(this) { AccessibleRole = AccessibleRole.CheckButton }; - bottom = new SpringControl(this) { AccessibleRole = AccessibleRole.CheckButton }; - tabOrder = new[] { left, top, right, bottom }; + _left = new SpringControl(this) { AccessibleRole = AccessibleRole.CheckButton }; + _right = new SpringControl(this) { AccessibleRole = AccessibleRole.CheckButton }; + _top = new SpringControl(this) { AccessibleRole = AccessibleRole.CheckButton }; + _bottom = new SpringControl(this) { AccessibleRole = AccessibleRole.CheckButton }; + _tabOrder = new[] { _left, _top, _right, _bottom }; InitializeComponent(); } - public object Value { get; private set; } + public object? Value { get; private set; } public void End() { - edSvc = null; + _editorService = null; Value = null; } public virtual AnchorStyles GetSelectedAnchor() { AnchorStyles baseVar = 0; - if (left.GetSolid()) + if (_left.IsSolid) { baseVar |= AnchorStyles.Left; } - if (top.GetSolid()) + if (_top.IsSolid) { baseVar |= AnchorStyles.Top; } - if (bottom.GetSolid()) + if (_bottom.IsSolid) { baseVar |= AnchorStyles.Bottom; } - if (right.GetSolid()) + if (_right.IsSolid) { baseVar |= AnchorStyles.Right; } @@ -81,56 +76,56 @@ internal virtual void InitializeComponent() AccessibleName = SR.AnchorEditorAccName; - container.Location = new Point(0, 0); - container.Size = new Size(90, 90); - container.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right; - - control.Location = new Point(30, 30); - control.Size = new Size(30, 30); - control.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right; - - right.Location = new Point(60, 40); - right.Size = new Size(30 - XBORDER, 10); - right.TabIndex = 2; - right.TabStop = true; - right.Anchor = AnchorStyles.Right; - right.AccessibleName = SR.AnchorEditorRightAccName; - - left.Location = new Point(XBORDER, 40); - left.Size = new Size(30 - XBORDER, 10); - left.TabIndex = 0; - left.TabStop = true; - left.Anchor = AnchorStyles.Left; - left.AccessibleName = SR.AnchorEditorLeftAccName; - - top.Location = new Point(40, YBORDER); - top.Size = new Size(10, 30 - YBORDER); - top.TabIndex = 1; - top.TabStop = true; - top.Anchor = AnchorStyles.Top; - top.AccessibleName = SR.AnchorEditorTopAccName; - - bottom.Location = new Point(40, 60); - bottom.Size = new Size(10, 30 - YBORDER); - bottom.TabIndex = 3; - bottom.TabStop = true; - bottom.Anchor = AnchorStyles.Bottom; - bottom.AccessibleName = SR.AnchorEditorBottomAccName; + _container.Location = new Point(0, 0); + _container.Size = new Size(90, 90); + _container.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right; + + _control.Location = new Point(30, 30); + _control.Size = new Size(30, 30); + _control.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right; + + _right.Location = new Point(60, 40); + _right.Size = new Size(30 - XBORDER, 10); + _right.TabIndex = 2; + _right.TabStop = true; + _right.Anchor = AnchorStyles.Right; + _right.AccessibleName = SR.AnchorEditorRightAccName; + + _left.Location = new Point(XBORDER, 40); + _left.Size = new Size(30 - XBORDER, 10); + _left.TabIndex = 0; + _left.TabStop = true; + _left.Anchor = AnchorStyles.Left; + _left.AccessibleName = SR.AnchorEditorLeftAccName; + + _top.Location = new Point(40, YBORDER); + _top.Size = new Size(10, 30 - YBORDER); + _top.TabIndex = 1; + _top.TabStop = true; + _top.Anchor = AnchorStyles.Top; + _top.AccessibleName = SR.AnchorEditorTopAccName; + + _bottom.Location = new Point(40, 60); + _bottom.Size = new Size(10, 30 - YBORDER); + _bottom.TabIndex = 3; + _bottom.TabStop = true; + _bottom.Anchor = AnchorStyles.Bottom; + _bottom.AccessibleName = SR.AnchorEditorBottomAccName; Controls.Clear(); Controls.AddRange(new Control[] { - container + _container }); - container.Controls.Clear(); - container.Controls.AddRange(new Control[] + _container.Controls.Clear(); + _container.Controls.AddRange(new Control[] { - control, - top, - left, - bottom, - right + _control, + _top, + _left, + _bottom, + _right }); ResumeLayout(false); } @@ -138,7 +133,7 @@ internal virtual void InitializeComponent() protected override void OnGotFocus(EventArgs e) { base.OnGotFocus(e); - top.Focus(); + _top.Focus(); } private void SetValue() @@ -146,22 +141,22 @@ private void SetValue() Value = GetSelectedAnchor(); } - public void Start(IWindowsFormsEditorService edSvc, object value) + public void Start(IWindowsFormsEditorService edSvc, object? value) { - this.edSvc = edSvc; + _editorService = edSvc; Value = value; - if (value is AnchorStyles) + if (value is AnchorStyles anchorStyles) { - left.SetSolid(((AnchorStyles)value & AnchorStyles.Left) == AnchorStyles.Left); - top.SetSolid(((AnchorStyles)value & AnchorStyles.Top) == AnchorStyles.Top); - bottom.SetSolid(((AnchorStyles)value & AnchorStyles.Bottom) == AnchorStyles.Bottom); - right.SetSolid(((AnchorStyles)value & AnchorStyles.Right) == AnchorStyles.Right); - oldAnchor = (AnchorStyles)value; + _left.IsSolid = (anchorStyles & AnchorStyles.Left) == AnchorStyles.Left; + _top.IsSolid = (anchorStyles & AnchorStyles.Top) == AnchorStyles.Top; + _bottom.IsSolid = (anchorStyles & AnchorStyles.Bottom) == AnchorStyles.Bottom; + _right.IsSolid = (anchorStyles & AnchorStyles.Right) == AnchorStyles.Right; + _oldAnchor = anchorStyles; } else { - oldAnchor = AnchorStyles.Top | AnchorStyles.Left; + _oldAnchor = AnchorStyles.Top | AnchorStyles.Left; } } @@ -169,10 +164,10 @@ private void Teardown(bool saveAnchor) { if (!saveAnchor) { - Value = oldAnchor; + Value = _oldAnchor; } - edSvc.CloseDropDown(); + _editorService!.CloseDropDown(); } private class ContainerPlaceholder : Control @@ -209,13 +204,13 @@ protected override void OnPaint(PaintEventArgs e) private class SpringControl : Control { - private readonly AnchorUI picker; - internal bool focused; - internal bool solid; + private readonly AnchorUI _picker; + internal bool _focused; + internal bool _solid; public SpringControl(AnchorUI picker) { - this.picker = picker ?? throw new ArgumentException(); + _picker = picker ?? throw new ArgumentException(); TabStop = true; } @@ -224,16 +219,25 @@ protected override AccessibleObject CreateAccessibilityInstance() return new SpringControlAccessibleObject(this); } - public virtual bool GetSolid() + public bool IsSolid { - return solid; + get => _solid; + set + { + if (_solid != value) + { + _solid = value; + _picker.SetValue(); + Invalidate(); + } + } } protected override void OnGotFocus(EventArgs e) { - if (!focused) + if (!_focused) { - focused = true; + _focused = true; Invalidate(); } @@ -242,9 +246,9 @@ protected override void OnGotFocus(EventArgs e) protected override void OnLostFocus(EventArgs e) { - if (focused) + if (_focused) { - focused = false; + _focused = false; Invalidate(); } @@ -253,7 +257,7 @@ protected override void OnLostFocus(EventArgs e) protected override void OnMouseDown(MouseEventArgs e) { - SetSolid(!solid); + IsSolid = !_solid; Focus(); } @@ -261,7 +265,7 @@ protected override void OnPaint(PaintEventArgs e) { Rectangle rc = ClientRectangle; - if (solid) + if (_solid) { e.Graphics.FillRectangle(SystemBrushes.ControlDark, rc); e.Graphics.DrawRectangle(SystemPens.WindowFrame, rc.X, rc.Y, rc.Width - 1, rc.Height - 1); @@ -271,7 +275,7 @@ protected override void OnPaint(PaintEventArgs e) ControlPaint.DrawFocusRectangle(e.Graphics, rc); } - if (focused) + if (_focused) { rc.Inflate(-2, -2); ControlPaint.DrawFocusRectangle(e.Graphics, rc); @@ -282,7 +286,7 @@ protected override bool ProcessDialogChar(char charCode) { if (charCode == ' ') { - SetSolid(!solid); + IsSolid = !_solid; return true; } @@ -293,25 +297,25 @@ protected override bool ProcessDialogKey(Keys keyData) { if ((keyData & Keys.KeyCode) == Keys.Return && (keyData & (Keys.Alt | Keys.Control)) == 0) { - picker.Teardown(true); + _picker.Teardown(true); return true; } if ((keyData & Keys.KeyCode) == Keys.Escape && (keyData & (Keys.Alt | Keys.Control)) == 0) { - picker.Teardown(false); + _picker.Teardown(false); return true; } if ((keyData & Keys.KeyCode) == Keys.Tab && (keyData & (Keys.Alt | Keys.Control)) == 0) { - for (int i = 0; i < picker.tabOrder.Length; i++) + for (int i = 0; i < _picker._tabOrder.Length; i++) { - if (picker.tabOrder[i] == this) + if (_picker._tabOrder[i] == this) { i += (keyData & Keys.Shift) == 0 ? 1 : -1; - i = i < 0 ? i + picker.tabOrder.Length : i % picker.tabOrder.Length; - picker.tabOrder[i].Focus(); + i = i < 0 ? i + _picker._tabOrder.Length : i % _picker._tabOrder.Length; + _picker._tabOrder[i].Focus(); break; } } @@ -322,23 +326,13 @@ protected override bool ProcessDialogKey(Keys keyData) return base.ProcessDialogKey(keyData); } - public virtual void SetSolid(bool value) - { - if (solid != value) - { - solid = value; - picker.SetValue(); - Invalidate(); - } - } - private class SpringControlAccessibleObject : ControlAccessibleObject { public SpringControlAccessibleObject(SpringControl owner) : base(owner) { } - public override string DefaultAction => ((SpringControl)Owner).GetSolid() + public override string DefaultAction => ((SpringControl)Owner!).IsSolid ? SR.AccessibleActionUncheck : SR.AccessibleActionCheck; @@ -348,7 +342,7 @@ public override AccessibleStates State { AccessibleStates state = base.State; - if (((SpringControl)Owner).GetSolid()) + if (((SpringControl)Owner!).IsSolid) { state |= AccessibleStates.Checked; } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.cs index f81c602e93c..566452fcc52 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.Drawing.Design; @@ -15,16 +12,16 @@ namespace System.Windows.Forms.Design; [CLSCompliant(false)] public sealed partial class AnchorEditor : UITypeEditor { - private AnchorUI _anchorUI; + private AnchorUI? _anchorUI; - public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) + public override object? EditValue(ITypeDescriptorContext? context, IServiceProvider provider, object? value) { - if (!provider.TryGetService(out IWindowsFormsEditorService editorService)) + if (!provider.TryGetService(out IWindowsFormsEditorService? editorService)) { return value; } - _anchorUI ??= new AnchorUI(this); + _anchorUI ??= new AnchorUI(); _anchorUI.Start(editorService, value); editorService.DropDownControl(_anchorUI); @@ -35,5 +32,5 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide } /// - public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.DropDown; + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext? context) => UITypeEditorEditStyle.DropDown; } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AxImporter.IReferenceResolver.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AxImporter.IReferenceResolver.cs new file mode 100644 index 00000000000..eed0c57e3cc --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AxImporter.IReferenceResolver.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Reflection; +using System.Runtime.InteropServices; + +namespace System.Windows.Forms.Design; + +public partial class AxImporter +{ + /// + /// Provides methods to resolve references to ActiveX libraries, COM type libraries or assemblies, + /// or managed assemblies. + /// + public interface IReferenceResolver + { + /// + /// Resolves a reference to the specified assembly. + /// + /// A fully qualified path to an assembly. + string? ResolveManagedReference(string assemName); + + /// + /// Resolves a reference to the specified type library that contains an COM component. + /// + /// A fully qualified path to an assembly. + string? ResolveComReference(UCOMITypeLib typeLib); + + /// + /// Resolves a reference to the specified assembly that contains a COM component. + /// + /// A fully qualified path to an assembly. + string? ResolveComReference(AssemblyName name); + + /// + /// Resolves a reference to the specified type library that contains an ActiveX control. + /// + /// A fully qualified path to an assembly. + string? ResolveActiveXReference(UCOMITypeLib typeLib); + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AxImporter.Options.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AxImporter.Options.cs new file mode 100644 index 00000000000..5db64c9d679 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AxImporter.Options.cs @@ -0,0 +1,90 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Reflection; + +namespace System.Windows.Forms.Design; + +public partial class AxImporter +{ + public sealed class Options + { + /// + /// The flag that controls when we sign the generated assemblies. + /// + public bool delaySign; + + /// + /// Flag that controls whether we are to generate sources for the ActiveX control wrapper. + /// + public bool genSources; + + /// + /// Regardless of which version of the library is registered, if at all, use the + /// path supplied on the command line for AxImp to generate the Windows Forms wrappers. + /// + public bool ignoreRegisteredOcx; + + /// + /// The file containing the strong name key container for the generated assemblies. + /// + public string? keyContainer; + + /// + /// The file containing the strong name key for the generated assemblies. + /// + public string? keyFile; + + /// + /// The strong name used for the generated assemblies. + /// +#pragma warning disable SYSLIB0017 // Type or member is obsolete, see https://github.com/dotnet/runtime/pull/50941 + public StrongNameKeyPair? keyPair; +#pragma warning restore SYSLIB0017 // Type or member is obsolete + + /// + /// Flag that controls whether we should output errors in the MSBuild format. + /// + public bool msBuildErrors; + + /// + /// Flag that controls whether we should show the logo. + /// + public bool noLogo; + + /// + /// The output directory for all the generated assemblies. + /// + public string? outputDirectory; + + /// + /// The path-included filename of type library containing the definition of the ActiveX control. + /// + public string? outputName; + + /// + /// The flag that controls whether we try to overwrite existing generated assemblies. + /// + public bool overwriteRCW; + + /// + /// The public key used to sign the generated assemblies. + /// + public byte[]? publicKey; + + /// + /// The object that allows us to resolve types and references needed to generate assemblies. + /// + public IReferenceResolver? references; + + /// + /// Flag that controls the output generated. + /// + public bool silentMode; + + /// + /// Flag that controls the output generated. + /// + public bool verboseMode; + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AxImporter.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AxImporter.cs index 0747e5b4727..0eb195bebe2 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AxImporter.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AxImporter.cs @@ -1,118 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable - -using System.Reflection; -using System.Runtime.InteropServices; namespace System.Windows.Forms.Design; /// /// Imports ActiveX controls and generates a wrapper that can be accessed by a designer. /// -public class AxImporter +public partial class AxImporter { public AxImporter(Options options) { throw new NotImplementedException(SR.NotImplementedByDesign); } - - public sealed class Options - { - /// - /// The flag that controls when we sign the generated assemblies. - /// - public bool delaySign; - - /// - /// Flag that controls whether we are to generate sources for the ActiveX control wrapper. - /// - public bool genSources; - - /// - /// Regardless of which version of the library is registered, if at all, use the - /// path supplied on the command line for AxImp to generate the Windows Forms wrappers. - /// - public bool ignoreRegisteredOcx; - - /// - /// The file containing the strong name key container for the generated assemblies. - /// - public string keyContainer; - - /// - /// The file containing the strong name key for the generated assemblies. - /// - public string keyFile; - - /// - /// The strong name used for the generated assemblies. - /// -#pragma warning disable SYSLIB0017 // Type or member is obsolete, see https://github.com/dotnet/runtime/pull/50941 - public StrongNameKeyPair keyPair; -#pragma warning restore SYSLIB0017 // Type or member is obsolete - - /// - /// Flag that controls whether we should output errors in the MSBuild format. - /// - public bool msBuildErrors; - - /// - /// Flag that controls whether we should show the logo. - /// - public bool noLogo; - - /// - /// The output directory for all the generated assemblies. - /// - public string outputDirectory; - - /// - /// The path-included filename of type library containing the definition of the ActiveX control. - /// - public string outputName; - - /// - /// The flag that controls whether we try to overwrite existing generated assemblies. - /// - public bool overwriteRCW; - - /// - /// The public key used to sign the generated assemblies. - /// - public byte[] publicKey; - - /// - /// The object that allows us to resolve types and references needed to generate assemblies. - /// - public IReferenceResolver references; - - /// - /// Flag that controls the output generated. - /// - public bool silentMode; - - /// - /// Flag that controls the output generated. - /// - public bool verboseMode; - } - - /// - /// The Reference Resolver service will try to look through the references it can obtain, - /// for a reference that matches the given criterion. For now, the only kind of references - /// it can look for are COM (RCW) references and ActiveX wrapper references. - /// - public interface IReferenceResolver - { - string ResolveManagedReference(string assemName); - - string ResolveComReference(UCOMITypeLib typeLib); - - string ResolveComReference(AssemblyName name); - - string ResolveActiveXReference(UCOMITypeLib typeLib); - } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BaseContextMenuStrip.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BaseContextMenuStrip.cs index ae25eefeba0..4f9cea41f76 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BaseContextMenuStrip.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BaseContextMenuStrip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Adorner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Adorner.cs index eb6bb3f5eed..3b22f272bd9 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Adorner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Adorner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/AdornerCollection.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/AdornerCollection.cs index 7bb31f44f70..77f4b6181e2 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/AdornerCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/AdornerCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -96,7 +95,7 @@ public int Add(Adorner value) /// None. /// /// - public void AddRange(Adorner[] value) + public void AddRange(params Adorner[] value) { for (int i = 0; (i < value.Length); i++) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Behavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Behavior.cs index 732989b843d..17238a55f79 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Behavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Behavior.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventArgs.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventArgs.cs index b83d0ae36a2..727f448c60c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventArgs.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventHandler.cs index 0fc2c9c2bb6..a31df9fc35f 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design.Behavior; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.MouseHook.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.MouseHook.cs index 28f8e245df2..d382c40971f 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.MouseHook.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.MouseHook.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.cs index e617573ac4d..96641808421 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; @@ -17,7 +16,7 @@ private partial class AdornerWindow : Control { private readonly BehaviorService _behaviorService; private static MouseHook? s_mouseHook; - private static readonly List s_adornerWindowList = new List(); + private static readonly List s_adornerWindowList = new(); /// /// Constructor that parents itself to the Designer Frame and hooks all @@ -318,19 +317,12 @@ protected override unsafe void WndProc(ref Message m) case PInvoke.WM_NCHITTEST: Point pt = PARAM.ToPoint(m.LParamInternal); - - var pt1 = default(Point); - pt1 = PointToClient(pt1); + Point pt1 = PointToClient(default); pt.Offset(pt1.X, pt1.Y); - if (_behaviorService.PropagateHitTest(pt) && !ProcessingDrag) - { - m.ResultInternal = (LRESULT)PInvoke.HTTRANSPARENT; - } - else - { - m.ResultInternal = (LRESULT)(int)PInvoke.HTCLIENT; - } + m.ResultInternal = _behaviorService.PropagateHitTest(pt) && !ProcessingDrag + ? (LRESULT)PInvoke.HTTRANSPARENT + : (LRESULT)(int)PInvoke.HTCLIENT; break; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.MenuCommandHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.MenuCommandHandler.cs index cb99418e97b..1750a67f57b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.MenuCommandHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.MenuCommandHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; @@ -11,7 +10,7 @@ public sealed partial class BehaviorService private class MenuCommandHandler : IMenuCommandService { private readonly BehaviorService _owner; - private readonly Stack _currentCommands = new Stack(); + private readonly Stack _currentCommands = new(); public MenuCommandHandler(BehaviorService owner, IMenuCommandService menuService) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs index 55b7ae1fc32..3fa29491a3f 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -48,7 +47,7 @@ public sealed partial class BehaviorService : IDisposable private bool _queriedSnapLines; // only query for this once since we require the user restart design sessions when this changes private readonly HashSet _dragEnterReplies; // we keep track of whether glyph has already responded to a DragEnter this D&D. private static readonly TraceSwitch s_dragDropSwitch - = new TraceSwitch("BSDRAGDROP", "Behavior service drag & drop messages"); + = new("BSDRAGDROP", "Behavior service drag & drop messages"); //test hooks for SnapLines private static MessageId WM_GETALLSNAPLINES; @@ -390,7 +389,7 @@ internal void EnableAllAdorners(bool enabled) /// /// Removes the behavior from the behavior stack /// - public Behavior? PopBehavior(Behavior behavior) + public Behavior PopBehavior(Behavior behavior) { if (_behaviorStack.Count == 0) { @@ -400,7 +399,7 @@ internal void EnableAllAdorners(bool enabled) int index = _behaviorStack.IndexOf(behavior); if (index == -1) { - Debug.Assert(false, $"Could not find the behavior to pop - did it already get popped off? {behavior}"); + Debug.Fail($"Could not find the behavior to pop - did it already get popped off? {behavior}"); return null; } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorServiceAdornerCollectionEnumerator.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorServiceAdornerCollectionEnumerator.cs index f94074cca2b..ca3cace359c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorServiceAdornerCollectionEnumerator.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorServiceAdornerCollectionEnumerator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ComponentGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ComponentGlyph.cs index e4db00544ea..79b40170104 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ComponentGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ComponentGlyph.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ContainerSelectorBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ContainerSelectorBehavior.cs index 29c22c4e3c2..227d74a02bb 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ContainerSelectorBehavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ContainerSelectorBehavior.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ContainerSelectorGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ContainerSelectorGlyph.cs index 397fcff3a41..3ec13721d56 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ContainerSelectorGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ContainerSelectorGlyph.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ControlBodyGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ControlBodyGlyph.cs index 0fb1140b7fa..c5d8f79abfd 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ControlBodyGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ControlBodyGlyph.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionBehavior.cs index 03753cc4b2e..9eb2dbed784 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionBehavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionBehavior.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.ComponentModel.Design; @@ -15,9 +12,6 @@ namespace System.Windows.Forms.Design.Behavior; /// internal sealed class DesignerActionBehavior : Behavior { - private readonly IComponent _relatedComponent; //The component we are bound to - private readonly DesignerActionUI _parentUI; //ptr to the parenting UI, used for showing menus and setting selection - private DesignerActionListCollection _actionLists; //all the shortcuts! private readonly IServiceProvider _serviceProvider; // we need to cache the service provider here to be able to create the panel with the proper arguments private bool _ignoreNextMouseUp; @@ -26,36 +20,26 @@ internal sealed class DesignerActionBehavior : Behavior /// internal DesignerActionBehavior(IServiceProvider serviceProvider, IComponent relatedComponent, DesignerActionListCollection actionLists, DesignerActionUI parentUI) { - _actionLists = actionLists; + ActionLists = actionLists; _serviceProvider = serviceProvider; - _relatedComponent = relatedComponent; - _parentUI = parentUI; + RelatedComponent = relatedComponent; + ParentUI = parentUI; } /// /// Returns the collection of DesignerActionLists this Behavior is managing. These will be dynamically updated (some can be removed, new ones can be added, etc...). /// - internal DesignerActionListCollection ActionLists - { - get => _actionLists; - set => _actionLists = value; - } + internal DesignerActionListCollection ActionLists { get; set; } /// /// Returns the parenting UI (a DesignerActionUI) /// - internal DesignerActionUI ParentUI - { - get => _parentUI; - } + internal DesignerActionUI ParentUI { get; } /// /// Returns the Component that this glyph is attached to. /// - internal IComponent RelatedComponent - { - get => _relatedComponent; - } + internal IComponent RelatedComponent { get; } /// /// Hides the designer action panel UI. @@ -80,7 +64,7 @@ internal DesignerActionPanel CreateDesignerActionPanel(IComponent relatedCompone /// internal void ShowUI(Glyph g) { - if (!(g is DesignerActionGlyph glyph)) + if (g is not DesignerActionGlyph glyph) { Debug.Fail("Why are we trying to 'showui' on a glyph that's not a DesignerActionGlyph?"); return; @@ -98,13 +82,13 @@ internal bool IgnoreNextMouseUp } } - public override bool OnMouseDoubleClick(Glyph g, MouseButtons button, Point mouseLoc) + public override bool OnMouseDoubleClick(Glyph? g, MouseButtons button, Point mouseLoc) { _ignoreNextMouseUp = true; return true; } - public override bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc) + public override bool OnMouseDown(Glyph? g, MouseButtons button, Point mouseLoc) { // we take the msg return (!ParentUI.IsDesignerActionPanelVisible); } @@ -112,7 +96,7 @@ public override bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc) /// /// In response to a MouseUp, we will either 1) select the Glyph and control if not selected, or 2) Build up our context menu representing our DesignerActions and show it. /// - public override bool OnMouseUp(Glyph g, MouseButtons button) + public override bool OnMouseUp(Glyph? g, MouseButtons button) { if (button != MouseButtons.Left || ParentUI is null) { @@ -126,23 +110,19 @@ public override bool OnMouseUp(Glyph g, MouseButtons button) } else if (!_ignoreNextMouseUp) { - if (_serviceProvider is not null) + if (_serviceProvider.TryGetService(out ISelectionService? selectionService)) { - ISelectionService selectionService = (ISelectionService)_serviceProvider.GetService(typeof(ISelectionService)); - if (selectionService is not null) + if (selectionService.PrimarySelection != RelatedComponent) { - if (selectionService.PrimarySelection != RelatedComponent) + List componentList = new List { - List componentList = new List - { - RelatedComponent - }; - selectionService.SetSelectedComponents(componentList, SelectionTypes.Primary); - } + RelatedComponent + }; + selectionService.SetSelectedComponents(componentList, SelectionTypes.Primary); } } - ShowUI(g); + ShowUI(g!); } else { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionGlyph.cs index 2f526faaf3a..a4605569a6a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionGlyph.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -222,7 +221,7 @@ public override void Paint(PaintEventArgs pe) return; } - IComponent panelComponent = behavior.ParentUI.LastPanelComponent; + IComponent? panelComponent = behavior.ParentUI.LastPanelComponent; IComponent relatedComponent = behavior.RelatedComponent; if (panelComponent is not null && panelComponent == relatedComponent) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionKeyboardBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionKeyboardBehavior.cs index f4a709a376d..da25c41647d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionKeyboardBehavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionKeyboardBehavior.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -13,7 +12,7 @@ internal sealed class DesignerActionKeyboardBehavior : Behavior private readonly DesignerActionPanel _panel; private readonly IMenuCommandService _menuService; private readonly DesignerActionUIService _daUISvc; - private static readonly Guid s_vSStandardCommandSet97 = new Guid("{5efc7975-14bc-11cf-9b2b-00aa00573819}"); + private static readonly Guid s_vSStandardCommandSet97 = new("{5efc7975-14bc-11cf-9b2b-00aa00573819}"); public DesignerActionKeyboardBehavior(DesignerActionPanel panel, IServiceProvider serviceProvider, BehaviorService behaviorService) : base(true, behaviorService) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs index b787226f9a9..9d29e4e3eb5 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -24,7 +23,7 @@ internal sealed class DragAssistanceManager private Rectangle _cachedDragRect; //used to store drag rect between erasing & waiting to render private readonly Pen _edgePen = SystemPens.Highlight; private readonly bool _disposeEdgePen; - private readonly Pen _baselinePen = new Pen(Color.Fuchsia); + private readonly Pen _baselinePen = new(Color.Fuchsia); // These are global lists of all the existing vertical and horizontal snaplineson the designer's surface excluding the targetControl. All SnapLine coords in these lists have been properly adjusted for the AdornerWindow coords. private readonly List _verticalSnapLines = new(); private readonly List _horizontalSnapLines = new(); diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DropSourceBehavior.BehaviorDataObject.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DropSourceBehavior.BehaviorDataObject.cs index 5234890119b..d7b00d7249a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DropSourceBehavior.BehaviorDataObject.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DropSourceBehavior.BehaviorDataObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DropSourceBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DropSourceBehavior.cs index 52db1957af6..c8dabc5e2b0 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DropSourceBehavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DropSourceBehavior.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Glyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Glyph.cs index 6fed203ba52..a2c73ba896a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Glyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/Glyph.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GlyphCollection.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GlyphCollection.cs index 2bb03fd8647..17ac5e22efc 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GlyphCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GlyphCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -57,7 +56,7 @@ public int Add(Glyph value) /// /// Copies the elements of an array to the end of the Behavior.GlyphCollection. /// - public void AddRange(Glyph[] value) + public void AddRange(params Glyph[] value) { for (int i = 0; i < value.Length; i += 1) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GlyphSelectionType.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GlyphSelectionType.cs index 7d783fadd35..c3d296ebce6 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GlyphSelectionType.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GlyphSelectionType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design.Behavior; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GrabHandleGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GrabHandleGlyph.cs index 1db7ddbe5ba..b3b11c7539c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GrabHandleGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GrabHandleGlyph.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GrabHandleGlyphType.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GrabHandleGlyphType.cs index 1135bb63c17..668c47b8eac 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GrabHandleGlyphType.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/GrabHandleGlyphType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design.Behavior; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedBorderGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedBorderGlyph.cs index 4ec3782a842..b53f1d9898d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedBorderGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedBorderGlyph.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedHandleGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedHandleGlyph.cs index 825d5110110..225990e8063 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedHandleGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/LockedHandleGlyph.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/MiniLockedBorderGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/MiniLockedBorderGlyph.cs index 37425c82f6a..f97520069c0 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/MiniLockedBorderGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/MiniLockedBorderGlyph.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeHandleGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeHandleGlyph.cs index 6ee84398ea3..7e7cecac47c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeHandleGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeHandleGlyph.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeSelectionBorderGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeSelectionBorderGlyph.cs index 552144622cc..73accd9b50c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeSelectionBorderGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/NoResizeSelectionBorderGlyph.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ResizeBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ResizeBehavior.cs index b8432848c26..f83fd6b40b6 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ResizeBehavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ResizeBehavior.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionBorderGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionBorderGlyph.cs index c8560b5bae6..c8dff3db842 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionBorderGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionBorderGlyph.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionBorderGlyphType.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionBorderGlyphType.cs index ebea3859b1d..e0435beb444 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionBorderGlyphType.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionBorderGlyphType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design.Behavior; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionGlyphBase.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionGlyphBase.cs index 290da7c95bd..434109c42c3 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionGlyphBase.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionGlyphBase.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionManager.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionManager.cs index 11a579370e6..d5ea6727ee4 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionManager.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SelectionManager.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.ComponentModel.Design; @@ -15,20 +12,17 @@ namespace System.Windows.Forms.Design.Behavior; /// internal sealed class SelectionManager : IDisposable { - private Adorner _selectionAdorner; //used to provide all selection glyphs - private Adorner _bodyAdorner; //used to track all body glyphs for each control private BehaviorService _behaviorService; //ptr back to our BehaviorService private IServiceProvider _serviceProvider; //standard service provider private readonly Dictionary _componentToDesigner; //used for quick look up of designers related to components private readonly Control _rootComponent; //root component being designed private ISelectionService _selSvc; //we cache the selection service for perf. private IDesignerHost _designerHost; //we cache the designerhost for perf. - private bool _needRefresh; // do we need to refresh? - private Rectangle[] _prevSelectionBounds; //used to only repaint the changing part of the selection - private object _prevPrimarySelection; //used to check if the primary selection changed - private Rectangle[] _curSelectionBounds; + private Rectangle[]? _prevSelectionBounds; //used to only repaint the changing part of the selection + private object? _prevPrimarySelection; //used to check if the primary selection changed + private Rectangle[]? _curSelectionBounds; private int _curCompIndex; - private DesignerActionUI _designerActionUI; // the "container" for all things related to the designer action (smarttags) UI + private DesignerActionUI? _designerActionUI; // the "container" for all things related to the designer action (smarttags) UI private bool _selectionChanging; //we don't want the OnSelectionChanged to be recursively called. /// @@ -41,8 +35,8 @@ public SelectionManager(IServiceProvider serviceProvider, BehaviorService behavi _behaviorService = behaviorService; _serviceProvider = serviceProvider; - _selSvc = (ISelectionService)serviceProvider.GetService(typeof(ISelectionService)); - _designerHost = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost)); + _selSvc = serviceProvider.GetService()!; + _designerHost = serviceProvider.GetService()!; if (_designerHost is null || _selSvc is null) { @@ -60,15 +54,15 @@ public SelectionManager(IServiceProvider serviceProvider, BehaviorService behavi //create and add both of our adorners, //one for selection, one for bodies - _selectionAdorner = new Adorner(); - _bodyAdorner = new Adorner(); - behaviorService.Adorners.Add(_bodyAdorner); - behaviorService.Adorners.Add(_selectionAdorner); // adding this will cause the adorner to get setup with a ptr + SelectionGlyphAdorner = new Adorner(); + BodyGlyphAdorner = new Adorner(); + behaviorService.Adorners.Add(BodyGlyphAdorner); + behaviorService.Adorners.Add(SelectionGlyphAdorner); // adding this will cause the adorner to get setup with a ptr // to the beh.svc. _componentToDesigner = new(); - IComponentChangeService cs = (IComponentChangeService)serviceProvider.GetService(typeof(IComponentChangeService)); + IComponentChangeService? cs = serviceProvider.GetService(); if (cs is not null) { cs.ComponentAdded += new ComponentEventHandler(OnComponentAdded); @@ -81,10 +75,10 @@ public SelectionManager(IServiceProvider serviceProvider, BehaviorService behavi // designeraction UI if (_designerHost.GetService(typeof(DesignerOptionService)) is DesignerOptionService options) { - PropertyDescriptor p = options.Options.Properties["UseSmartTags"]; - if (p is not null && p.PropertyType == typeof(bool) && (bool)p.GetValue(null)) + PropertyDescriptor? p = options.Options.Properties["UseSmartTags"]; + if (p is not null && p.TryGetValue(null, out bool useSmartTags) && useSmartTags) { - _designerActionUI = new DesignerActionUI(serviceProvider, _selectionAdorner); + _designerActionUI = new DesignerActionUI(serviceProvider, SelectionGlyphAdorner); behaviorService.DesignerActionUI = _designerActionUI; } } @@ -93,10 +87,7 @@ public SelectionManager(IServiceProvider serviceProvider, BehaviorService behavi /// /// Returns the Adorner that contains all the BodyGlyphs for the current selection state. /// - internal Adorner BodyGlyphAdorner - { - get => _bodyAdorner; - } + internal Adorner BodyGlyphAdorner { get; private set; } /// /// There are certain cases like Adding Item to ToolStrips through InSitu Editor, where there is @@ -106,25 +97,18 @@ internal Adorner BodyGlyphAdorner /// Since this property is checked in the TransactionClosed, the SelectionManager won't REFRESH and hence /// just eat up the refresh thus avoiding unnecessary flicker. /// - internal bool NeedRefresh - { - get => _needRefresh; - set => _needRefresh = value; - } + internal bool NeedRefresh { get; set; } /// /// Returns the Adorner that contains all the BodyGlyphs for the current selection state. /// - internal Adorner SelectionGlyphAdorner - { - get => _selectionAdorner; - } + internal Adorner SelectionGlyphAdorner { get; private set; } /// /// This method fist calls the recursive AddControlGlyphs() method. When finished, we add the final glyph(s) /// to the root comp. /// - private void AddAllControlGlyphs(Control parent, List selComps, object primarySelection) + private void AddAllControlGlyphs(Control parent, List selComps, object? primarySelection) { foreach (Control control in parent.Controls) { @@ -152,16 +136,15 @@ private void AddAllControlGlyphs(Control parent, List selComps, obje /// private void AddControlGlyphs(Control control, GlyphSelectionType selType) { - if (_componentToDesigner.TryGetValue(control, out ControlDesigner controlDesigner) && controlDesigner is not null) + if (_componentToDesigner.TryGetValue(control, out ControlDesigner? controlDesigner)) { ControlBodyGlyph bodyGlyph = controlDesigner.GetControlGlyphInternal(selType); if (bodyGlyph is not null) { - _bodyAdorner.Glyphs.Add(bodyGlyph); - if (selType == GlyphSelectionType.SelectedPrimary || - selType == GlyphSelectionType.Selected) + BodyGlyphAdorner.Glyphs.Add(bodyGlyph); + if (selType is GlyphSelectionType.SelectedPrimary or GlyphSelectionType.Selected) { - if (_curSelectionBounds[_curCompIndex] == Rectangle.Empty) + if (_curSelectionBounds![_curCompIndex] == Rectangle.Empty) { _curSelectionBounds[_curCompIndex] = bodyGlyph.Bounds; } @@ -175,19 +158,18 @@ private void AddControlGlyphs(Control control, GlyphSelectionType selType) GlyphCollection glyphs = controlDesigner.GetGlyphs(selType); if (glyphs is not null) { - _selectionAdorner.Glyphs.AddRange(glyphs); - if (selType == GlyphSelectionType.SelectedPrimary || - selType == GlyphSelectionType.Selected) + SelectionGlyphAdorner.Glyphs.AddRange(glyphs); + if (selType is GlyphSelectionType.SelectedPrimary or GlyphSelectionType.Selected) { foreach (Glyph glyph in glyphs) { - _curSelectionBounds[_curCompIndex] = Rectangle.Union(_curSelectionBounds[_curCompIndex], glyph.Bounds); + _curSelectionBounds![_curCompIndex] = Rectangle.Union(_curSelectionBounds[_curCompIndex], glyph.Bounds); } } } } - if (selType == GlyphSelectionType.SelectedPrimary || selType == GlyphSelectionType.Selected) + if (selType is GlyphSelectionType.SelectedPrimary or GlyphSelectionType.Selected) { _curCompIndex++; } @@ -202,12 +184,12 @@ public void Dispose() if (_designerHost is not null) { _designerHost.TransactionClosed -= new DesignerTransactionCloseEventHandler(OnTransactionClosed); - _designerHost = null; + _designerHost = null!; } if (_serviceProvider is not null) { - IComponentChangeService cs = (IComponentChangeService)_serviceProvider.GetService(typeof(IComponentChangeService)); + IComponentChangeService? cs = _serviceProvider.GetService(); if (cs is not null) { cs.ComponentAdded -= new ComponentEventHandler(OnComponentAdded); @@ -218,37 +200,37 @@ public void Dispose() if (_selSvc is not null) { _selSvc.SelectionChanged -= new EventHandler(OnSelectionChanged); - _selSvc = null; + _selSvc = null!; } - _serviceProvider = null; + _serviceProvider = null!; } if (_behaviorService is not null) { - _behaviorService.Adorners.Remove(_bodyAdorner); - _behaviorService.Adorners.Remove(_selectionAdorner); + _behaviorService.Adorners.Remove(BodyGlyphAdorner); + _behaviorService.Adorners.Remove(SelectionGlyphAdorner); _behaviorService.BeginDrag -= new BehaviorDragDropEventHandler(OnBeginDrag); _behaviorService.Synchronize -= new EventHandler(OnSynchronize); - _behaviorService = null; + _behaviorService = null!; } - if (_selectionAdorner is not null) + if (SelectionGlyphAdorner is not null) { - _selectionAdorner.Glyphs.Clear(); - _selectionAdorner = null; + SelectionGlyphAdorner.Glyphs.Clear(); + SelectionGlyphAdorner = null!; } - if (_bodyAdorner is not null) + if (BodyGlyphAdorner is not null) { - _bodyAdorner.Glyphs.Clear(); - _bodyAdorner = null; + BodyGlyphAdorner.Glyphs.Clear(); + BodyGlyphAdorner = null!; } if (_designerActionUI is not null) { _designerActionUI.Dispose(); - _designerActionUI = null; + _designerActionUI = null!; } } @@ -264,10 +246,10 @@ public void Refresh() /// /// When a component is added, we get the designer and add it to our hashtable for quick lookup. /// - private void OnComponentAdded(object source, ComponentEventArgs ce) + private void OnComponentAdded(object? source, ComponentEventArgs ce) { - IComponent component = ce.Component; - IDesigner designer = _designerHost.GetDesigner(component); + IComponent component = ce.Component!; + IDesigner? designer = _designerHost.GetDesigner(component); if (designer is ControlDesigner controlDesigner) { _componentToDesigner.Add(component, controlDesigner); @@ -277,11 +259,11 @@ private void OnComponentAdded(object source, ComponentEventArgs ce) /// /// Before a drag, remove all glyphs that are involved in the drag operation and any that don't allow drops. /// - private void OnBeginDrag(object source, BehaviorDragDropEventArgs e) + private void OnBeginDrag(object? source, BehaviorDragDropEventArgs e) { List dragComps = e.DragComponents.Cast().ToList(); List glyphsToRemove = new(); - foreach (ControlBodyGlyph g in _bodyAdorner.Glyphs) + foreach (ControlBodyGlyph g in BodyGlyphAdorner.Glyphs) { if (g.RelatedComponent is Control control && (dragComps.Contains(g.RelatedComponent) || !control.AllowDrop)) { @@ -291,7 +273,7 @@ private void OnBeginDrag(object source, BehaviorDragDropEventArgs e) foreach (Glyph g in glyphsToRemove) { - _bodyAdorner.Glyphs.Remove(g); + BodyGlyphAdorner.Glyphs.Remove(g); } } @@ -304,9 +286,9 @@ internal void OnBeginDrag(BehaviorDragDropEventArgs e) /// /// When a component is changed - we need to refresh the selection. /// - private void OnComponentChanged(object source, ComponentChangedEventArgs ce) + private void OnComponentChanged(object? source, ComponentChangedEventArgs ce) { - if (_selSvc.GetComponentSelected(ce.Component)) + if (_selSvc.GetComponentSelected(ce.Component!)) { if (!_designerHost.InTransaction) { @@ -322,9 +304,9 @@ private void OnComponentChanged(object source, ComponentChangedEventArgs ce) /// /// When a component is removed - we remove the key and value from our hashtable. /// - private void OnComponentRemoved(object source, ComponentEventArgs ce) + private void OnComponentRemoved(object? source, ComponentEventArgs ce) { - _componentToDesigner.Remove(ce.Component); + _componentToDesigner.Remove(ce.Component!); //remove the associated designeractionpanel _designerActionUI?.RemoveActionGlyph(ce.Component); @@ -333,12 +315,12 @@ private void OnComponentRemoved(object source, ComponentEventArgs ce) /// /// Computes the region representing the difference between the old selection and the new selection. /// - private Region DetermineRegionToRefresh(object primarySelection) + private Region DetermineRegionToRefresh(object? primarySelection) { Region toRefresh = new Region(Rectangle.Empty); Rectangle[] larger; Rectangle[] smaller; - if (_curSelectionBounds.Length >= _prevSelectionBounds.Length) + if (_curSelectionBounds!.Length >= _prevSelectionBounds!.Length) { larger = _curSelectionBounds; smaller = _prevSelectionBounds; @@ -361,10 +343,9 @@ private Region DetermineRegionToRefresh(object primarySelection) // determine which rects in the larger array need to be // included in the region to invalidate by intersecting // with rects in the smaller array. - for (int l = 0; l < larger.Length; l++) + foreach (Rectangle large in larger) { bool largeIntersected = false; - Rectangle large = larger[l]; for (int s = 0; s < smaller.Length; s++) { if (large.IntersectsWith(smaller[s])) @@ -414,7 +395,7 @@ private Region DetermineRegionToRefresh(object primarySelection) /// /// Event handler for the behaviorService's Synchronize event /// - private void OnSynchronize(object sender, EventArgs e) + private void OnSynchronize(object? sender, EventArgs e) { Refresh(); } @@ -422,7 +403,7 @@ private void OnSynchronize(object sender, EventArgs e) /// /// On every selectionchange, we remove all glyphs, get the newly selected components, and re-add all glyphs back to the Adorner. /// - private void OnSelectionChanged(object sender, EventArgs e) + private void OnSelectionChanged(object? sender, EventArgs? e) { // Note: selectionChanging would guard against a re-entrant code... // Since we don't want to be in messed up state when adding new Glyphs. @@ -430,11 +411,11 @@ private void OnSelectionChanged(object sender, EventArgs e) { _selectionChanging = true; - _selectionAdorner.Glyphs.Clear(); - _bodyAdorner.Glyphs.Clear(); + SelectionGlyphAdorner.Glyphs.Clear(); + BodyGlyphAdorner.Glyphs.Clear(); List selComps = _selSvc.GetSelectedComponents().Cast().ToList(); - object primarySelection = _selSvc.PrimarySelection; + object? primarySelection = _selSvc.PrimarySelection; //add all control glyphs to all controls on rootComp _curCompIndex = 0; @@ -447,7 +428,7 @@ private void OnSelectionChanged(object sender, EventArgs e) using Graphics g = _behaviorService.AdornerWindowGraphics; if (!toUpdate.IsEmpty(g)) { - _selectionAdorner.Invalidate(toUpdate); + SelectionGlyphAdorner.Invalidate(toUpdate); } } else @@ -464,20 +445,19 @@ private void OnSelectionChanged(object sender, EventArgs e) if (toUpdate != Rectangle.Empty) { - _selectionAdorner.Invalidate(toUpdate); + SelectionGlyphAdorner.Invalidate(toUpdate); } } else { - _selectionAdorner.Invalidate(); + SelectionGlyphAdorner.Invalidate(); } } _prevPrimarySelection = primarySelection; if (_curSelectionBounds.Length > 0) { - _prevSelectionBounds = new Rectangle[_curSelectionBounds.Length]; - Array.Copy(_curSelectionBounds, _prevSelectionBounds, _curSelectionBounds.Length); + _prevSelectionBounds = _curSelectionBounds.AsSpan().ToArray(); } else { @@ -491,7 +471,7 @@ private void OnSelectionChanged(object sender, EventArgs e) /// /// When a transaction that involves one of our components closes, refresh to reflect any changes. /// - private void OnTransactionClosed(object sender, DesignerTransactionCloseEventArgs e) + private void OnTransactionClosed(object? sender, DesignerTransactionCloseEventArgs e) { if (e.LastTransaction && NeedRefresh) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLine.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLine.cs index 4560f22f653..4b8ae26638a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLine.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLine.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design.Behavior; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLinePriority.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLinePriority.cs index dc9e6190527..e3b728adf33 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLinePriority.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLinePriority.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design.Behavior; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLineType.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLineType.cs index 4a517bea3a0..29a414d88f7 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLineType.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/SnapLineType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design.Behavior; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelBehavior.cs new file mode 100644 index 00000000000..ade1e21320c --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelBehavior.cs @@ -0,0 +1,442 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#nullable disable + +using System.Collections; +using System.ComponentModel.Design; +using System.ComponentModel; +using System.Drawing; +using System.Globalization; + +namespace System.Windows.Forms.Design.Behavior; + +internal class TableLayoutPanelBehavior : Behavior +{ + private TableLayoutPanelDesigner designer; //pointer back to our designer. + private Point lastMouseLoc; //used to track mouse movement deltas + private bool pushedBehavior; //tracks if we've pushed ourself onto the stack + private BehaviorService behaviorService; //used for bounds translation + private IServiceProvider serviceProvider; //cached to allow our behavior to get services + private TableLayoutPanelResizeGlyph tableGlyph; //the glyph being resized + private DesignerTransaction resizeTransaction; //used to make size adjustments within transaction + private PropertyDescriptor resizeProp; //cached property descriptor representing either the row or column styles + private PropertyDescriptor changedProp; //cached property descriptor that refers to the RowSTyles or ColumnStyles collection. + private TableLayoutPanel table; + private StyleHelper rightStyle; + private StyleHelper leftStyle; + private ArrayList styles; //List of the styles + private bool currentColumnStyles; // is Styles for Columns or Rows + private static readonly TraceSwitch tlpResizeSwitch = new("TLPRESIZE", "Behavior service drag & drop messages"); + + internal TableLayoutPanelBehavior(TableLayoutPanel panel, TableLayoutPanelDesigner designer, IServiceProvider serviceProvider) + { + table = panel; + this.designer = designer; + this.serviceProvider = serviceProvider; + + behaviorService = serviceProvider.GetService(typeof(BehaviorService)) as BehaviorService; + + if (behaviorService is null) + { + Debug.Fail("BehaviorService could not be found!"); + return; + } + + pushedBehavior = false; + lastMouseLoc = Point.Empty; + } + + private void FinishResize() + { + //clear state + pushedBehavior = false; + behaviorService.PopBehavior(this); + lastMouseLoc = Point.Empty; + styles = null; + + // fire ComponentChange events so this event is undoable + IComponentChangeService cs = serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService; + if (cs is not null && changedProp is not null) + { + cs.OnComponentChanged(table, changedProp, null, null); + changedProp = null; + } + + //attempt to refresh the selection + SelectionManager selManager = serviceProvider.GetService(typeof(SelectionManager)) as SelectionManager; + selManager?.Refresh(); + } + + public override void OnLoseCapture(Glyph g, EventArgs e) + { + if (pushedBehavior) + { + FinishResize(); + + // If we still have a transaction, roll it back. + if (resizeTransaction is not null) + { + DesignerTransaction t = resizeTransaction; + resizeTransaction = null; + using (t) + { + t.Cancel(); + } + } + } + } + + public override bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc) + { + //we only care about the right mouse button for resizing + if (button == MouseButtons.Left && g is TableLayoutPanelResizeGlyph) + { + tableGlyph = g as TableLayoutPanelResizeGlyph; + + //select the table + ISelectionService selSvc = serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService; + selSvc?.SetSelectedComponents(new object[] { designer.Component }, SelectionTypes.Primary); + + bool isColumn = tableGlyph.Type == TableLayoutPanelResizeGlyph.TableLayoutResizeType.Column; + + //cache some state + lastMouseLoc = mouseLoc; + resizeProp = TypeDescriptor.GetProperties(tableGlyph.Style)[isColumn ? "Width" : "Height"]; + Debug.Assert(resizeProp is not null, "Unable to get the resize property for tableGlyph's Style"); + + IComponentChangeService cs = serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService; + if (cs is not null) + { + changedProp = TypeDescriptor.GetProperties(table)[isColumn ? "ColumnStyles" : "RowStyles"]; + int[] widths = isColumn ? table.GetColumnWidths() : table.GetRowHeights(); + + if (changedProp is not null) + { + GetActiveStyleCollection(isColumn); + if (styles is not null && CanResizeStyle(widths)) + { + IDesignerHost host = serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null) + { + resizeTransaction = host.CreateTransaction(string.Format(SR.TableLayoutPanelRowColResize, (isColumn ? "Column" : "Row"), designer.Control.Site.Name)); + } + + try + { + int moveIndex = styles.IndexOf(tableGlyph.Style); + rightStyle.index = IndexOfNextStealableStyle(true /*forward*/, moveIndex, widths); + rightStyle.style = (TableLayoutStyle)styles[rightStyle.index]; + rightStyle.styleProp = TypeDescriptor.GetProperties(rightStyle.style)[isColumn ? "Width" : "Height"]; + + leftStyle.index = IndexOfNextStealableStyle(false /*backwards*/, moveIndex, widths); + leftStyle.style = (TableLayoutStyle)styles[leftStyle.index]; + leftStyle.styleProp = TypeDescriptor.GetProperties(leftStyle.style)[isColumn ? "Width" : "Height"]; + + Debug.Assert(leftStyle.styleProp is not null && rightStyle.styleProp is not null, "Couldn't find property descriptor for width or height"); + + cs.OnComponentChanging(table, changedProp); + } + catch (CheckoutException checkoutException) + { + if (CheckoutException.Canceled.Equals(checkoutException)) + { + if ((resizeTransaction is not null) && (!resizeTransaction.Canceled)) + { + resizeTransaction.Cancel(); + } + } + + throw; + } + } + else + { + return false; + } + } + } + + //push this resizebehavior + behaviorService.PushCaptureBehavior(this); + pushedBehavior = true; + } + + return false; + } + + private void GetActiveStyleCollection(bool isColumn) + { + if ((styles is null || isColumn != currentColumnStyles) && table is not null) + { + styles = new ArrayList(changedProp.GetValue(table) as TableLayoutStyleCollection); + currentColumnStyles = isColumn; + } + } + + private bool ColumnResize + { + get + { + bool ret = false; + if (tableGlyph is not null) + { + ret = tableGlyph.Type == TableLayoutPanelResizeGlyph.TableLayoutResizeType.Column; + } + + return ret; + } + } + + private bool CanResizeStyle(int[] widths) + { + bool canStealFromRight = false; + bool canStealFromLeft = false; + int moveIndex = ((IList)styles).IndexOf(tableGlyph.Style); + if (moveIndex > -1 && moveIndex != styles.Count) + { + canStealFromRight = IndexOfNextStealableStyle(true, moveIndex, widths) != -1; + canStealFromLeft = IndexOfNextStealableStyle(false, moveIndex, widths) != -1; + } + else + { + Debug.Fail("Can't find style " + moveIndex); + return false; + } + + return canStealFromRight && canStealFromLeft; + } + + private int IndexOfNextStealableStyle(bool forward, int startIndex, int[] widths) + { + int stealIndex = -1; + + if (styles is not null) + { + if (forward) + { + for (int i = startIndex + 1; ((i < styles.Count) && (i < widths.Length)); i++) + { + if (((TableLayoutStyle)styles[i]).SizeType != SizeType.AutoSize && widths[i] >= DesignerUtils.MINUMUMSTYLESIZEDRAG) + { + stealIndex = i; + break; + } + } + } + else + { + if (startIndex < widths.Length) + { + for (int i = startIndex; i >= 0; i--) + { + if (((TableLayoutStyle)styles[i]).SizeType != SizeType.AutoSize && widths[i] >= DesignerUtils.MINUMUMSTYLESIZEDRAG) + { + stealIndex = i; + break; + } + } + } + } + } + + return stealIndex; + } + + public override bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc) + { + if (pushedBehavior) + { + bool isColumn = ColumnResize; + GetActiveStyleCollection(isColumn); + if (styles is not null) + { + int rightIndex = rightStyle.index; + int leftIndex = leftStyle.index; + + int delta = isColumn ? mouseLoc.X - lastMouseLoc.X : mouseLoc.Y - lastMouseLoc.Y; + if (isColumn && table.RightToLeft == RightToLeft.Yes) + { + delta *= -1; + } + + if (delta == 0) + { + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "0 mouse delta"); + return false; + } + + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "BEGIN RESIZE"); + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "mouse delta: " + delta); + + int[] oldWidths = isColumn ? table.GetColumnWidths() : table.GetRowHeights(); + + int[] newWidths = oldWidths.Clone() as int[]; + + newWidths[rightIndex] -= delta; + newWidths[leftIndex] += delta; + + if (newWidths[rightIndex] < DesignerUtils.MINUMUMSTYLESIZEDRAG || + newWidths[leftIndex] < DesignerUtils.MINUMUMSTYLESIZEDRAG) + { + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "Bottomed out."); + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "END RESIZE\n"); + return false; + } + + // now we must renormalize our new widths into the correct sizes + table.SuspendLayout(); + + int totalPercent = 0; + + //simplest case: two absolute columns just affect each other. + if (((TableLayoutStyle)styles[rightIndex]).SizeType == SizeType.Absolute && + ((TableLayoutStyle)styles[leftIndex]).SizeType == SizeType.Absolute) + { + // VSWhidbey 465751 + // The dimensions reported by GetColumnsWidths() are different + // than the style dimensions when the TLP has borders. Instead + // of always setting the new size directly based on the reported + // sizes, we now base them on the style size if necessary. + float newRightSize = newWidths[rightIndex]; + float rightStyleSize = (float)rightStyle.styleProp.GetValue(rightStyle.style); + + if (rightStyleSize != oldWidths[rightIndex]) + { + newRightSize = Math.Max(rightStyleSize - delta, DesignerUtils.MINUMUMSTYLESIZEDRAG); + } + + float newLeftSize = newWidths[leftIndex]; + float leftStyleSize = (float)leftStyle.styleProp.GetValue(leftStyle.style); + + if (leftStyleSize != oldWidths[leftIndex]) + { + newLeftSize = Math.Max(leftStyleSize + delta, DesignerUtils.MINUMUMSTYLESIZEDRAG); + } + + rightStyle.styleProp.SetValue(rightStyle.style, newRightSize); + leftStyle.styleProp.SetValue(leftStyle.style, newLeftSize); + } + else if (((TableLayoutStyle)styles[rightIndex]).SizeType == SizeType.Percent && + ((TableLayoutStyle)styles[leftIndex]).SizeType == SizeType.Percent) + { + for (int i = 0; i < styles.Count; i++) + { + if (((TableLayoutStyle)styles[i]).SizeType == SizeType.Percent) + { + totalPercent += oldWidths[i]; + } + } + + for (int j = 0; j < 2; j++) + { + int i = j == 0 ? rightIndex : leftIndex; + float newSize = (float)newWidths[i] * 100 / (float)totalPercent; + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "NewSize " + newSize); + + PropertyDescriptor prop = TypeDescriptor.GetProperties(styles[i])[isColumn ? "Width" : "Height"]; + if (prop is not null) + { + prop.SetValue(styles[i], newSize); + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "Resizing column (per) " + i.ToString(CultureInfo.InvariantCulture) + " to " + newSize.ToString(CultureInfo.InvariantCulture)); + } + } + } + else + { +#if DEBUG + for (int i = 0; i < oldWidths.Length; i++) + { + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "Col " + i + ": Old: " + oldWidths[i] + " New: " + newWidths[i]); + } +#endif + + //mixed - just update absolute + int absIndex = ((TableLayoutStyle)styles[rightIndex]).SizeType == SizeType.Absolute ? rightIndex : leftIndex; + PropertyDescriptor prop = TypeDescriptor.GetProperties(styles[absIndex])[isColumn ? "Width" : "Height"]; + if (prop is not null) + { + // VSWhidbey 465751 + // The dimensions reported by GetColumnsWidths() are different + // than the style dimensions when the TLP has borders. Instead + // of always setting the new size directly based on the reported + // sizes, we now base them on the style size if necessary. + float newAbsSize = newWidths[absIndex]; + float curAbsStyleSize = (float)prop.GetValue(styles[absIndex]); + + if (curAbsStyleSize != oldWidths[absIndex]) + { + newAbsSize = Math.Max(absIndex == rightIndex ? curAbsStyleSize - delta : curAbsStyleSize + delta, + DesignerUtils.MINUMUMSTYLESIZEDRAG); + } + + prop.SetValue(styles[absIndex], newAbsSize); + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "Resizing column (abs) " + absIndex.ToString(CultureInfo.InvariantCulture) + " to " + newWidths[absIndex]); + } + else + { + Debug.Fail("Can't resize - no propertyescriptor for column"); + } + } + + table.ResumeLayout(true); + + // now determine if the values we pushed into the TLP + // actually had any effect. If they didn't, + // we delay updating the last mouse position so that + // next time a mouse move message comes in the delta is larger. + bool updatedSize = true; + int[] updatedWidths = isColumn ? table.GetColumnWidths() : table.GetRowHeights(); + + for (int i = 0; i < updatedWidths.Length; i++) + { + if (updatedWidths[i] == oldWidths[i] && newWidths[i] != oldWidths[i]) + { + updatedSize = false; + } + } + + if (updatedSize) + { + lastMouseLoc = mouseLoc; + } + } + else + { + lastMouseLoc = mouseLoc; + } + } + + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose && pushedBehavior, "END RESIZE\n"); + return false; + } + + public override bool OnMouseUp(Glyph g, MouseButtons button) + { + if (pushedBehavior) + { + FinishResize(); + //commit transaction + if (resizeTransaction is not null) + { + DesignerTransaction t = resizeTransaction; + resizeTransaction = null; + using (t) + { + t.Commit(); + } + + resizeProp = null; + } + } + + return false; + } + + internal struct StyleHelper + { + public int index; + public PropertyDescriptor styleProp; + public TableLayoutStyle style; + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelResizeGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelResizeGlyph.cs new file mode 100644 index 00000000000..1cdc02598c5 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelResizeGlyph.cs @@ -0,0 +1,80 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#nullable disable + +using System.Drawing; + +namespace System.Windows.Forms.Design.Behavior; + +internal class TableLayoutPanelResizeGlyph : Glyph +{ + private Rectangle bounds; + private Cursor hitTestCursor; + private TableLayoutStyle style; + private TableLayoutResizeType type; + + /// + /// This constructor caches our necessary state and determine what 'type' it is. + /// + internal TableLayoutPanelResizeGlyph(Rectangle controlBounds, TableLayoutStyle style, Cursor hitTestCursor, Behavior behavior) : base(behavior) + { + bounds = controlBounds; + this.hitTestCursor = hitTestCursor; + this.style = style; + + if (style is ColumnStyle) + { + type = TableLayoutResizeType.Column; + } + else + { + type = TableLayoutResizeType.Row; + } + } + + /// + /// Represents the bounds of the row or column line being rendered by the TableLayoutPanelDesigner. + /// + public override Rectangle Bounds => bounds; + + /// + /// Represents the Style associated with this glyph: Row or Column. + /// This is used by the behaviors resize methods to set the values. + /// + public TableLayoutStyle Style => style; + + /// + /// Used as quick check by our behavior when dragging/resizing. + /// + public TableLayoutResizeType Type => type; + + /// + /// Simply returns the proper cursor if the mouse pointer is within our cached bounds. + /// + public override Cursor GetHitTest(Point p) + { + if (bounds.Contains(p)) + { + return hitTestCursor; + } + + return null; + } + + /// + /// No painting necessary - this glyph is more of a 'hot spot' + /// + public override void Paint(PaintEventArgs pe) + { + } + + /// + /// Internal Enum defining the two different types of glyphs a TableLayoutPanel can have: column or row. + /// + public enum TableLayoutResizeType + { + Column, + Row + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolStripPanelSelectionBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolStripPanelSelectionBehavior.cs new file mode 100644 index 00000000000..7eff525599b --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolStripPanelSelectionBehavior.cs @@ -0,0 +1,319 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing; +using System.Drawing.Design; + +namespace System.Windows.Forms.Design.Behavior; + +internal sealed class ToolStripPanelSelectionBehavior : Behavior +{ + private readonly ToolStripPanel _relatedControl; + private readonly IServiceProvider _serviceProvider; + private readonly BehaviorService _behaviorService; + + private const int DefaultBounds = 25; + + internal ToolStripPanelSelectionBehavior(ToolStripPanel containerControl, IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + _behaviorService = serviceProvider.GetRequiredService(); + _relatedControl = containerControl; + } + + private static bool DragComponentContainsToolStrip(DropSourceBehavior.BehaviorDataObject? data) + { + if (data is null) + { + return false; + } + + foreach (var component in data.DragComponents) + { + if (component is ToolStrip) + { + return true; + } + } + + return false; + } + + private void ExpandPanel(bool setSelection) + { + // Change the padding to "dynamically" increase the bounds. + switch (_relatedControl.Dock) + { + case DockStyle.Top: + _relatedControl.Padding = new Padding(0, 0, 0, DefaultBounds); + break; + case DockStyle.Left: + _relatedControl.Padding = new Padding(0, 0, DefaultBounds, 0); + break; + case DockStyle.Right: + _relatedControl.Padding = new Padding(DefaultBounds, 0, 0, 0); + break; + case DockStyle.Bottom: + _relatedControl.Padding = new Padding(0, DefaultBounds, 0, 0); + break; + } + + if (setSelection) + { + ISelectionService selection = _serviceProvider.GetRequiredService(); + selection?.SetSelectedComponents(new object[] { _relatedControl }, SelectionTypes.Replace); + } + } + + /// + /// Simply clear the initial drag point, so we can start again + /// on the next mouse down. + /// + public override bool OnMouseDown(Glyph? glyph, MouseButtons button, Point screenCoordinates) + { + if (button != MouseButtons.Left || !(glyph is ToolStripPanelSelectionGlyph selectionGlyph)) + { + return false; + } + + if (!selectionGlyph.IsExpanded) + { + ExpandPanel(true); + + Rectangle oldBounds = selectionGlyph.Bounds; + selectionGlyph.IsExpanded = true; + _behaviorService.Invalidate(oldBounds); + _behaviorService.Invalidate(selectionGlyph.Bounds); + } + else + { + // Change the padding to "dynamically" increase the bounds. + _relatedControl.Padding = new Padding(0); + + Rectangle oldBounds = selectionGlyph.Bounds; + selectionGlyph.IsExpanded = false; + _behaviorService.Invalidate(oldBounds); + _behaviorService.Invalidate(selectionGlyph.Bounds); + + // Select our parent. + ISelectionService selectionService = _serviceProvider.GetRequiredService(); + Component? currentSelection = selectionService.PrimarySelection as Component; + + if (_relatedControl.Parent is not null) + { + if (currentSelection != _relatedControl.Parent) + { + selectionService?.SetSelectedComponents(new object[] { _relatedControl.Parent }, SelectionTypes.Replace); + } + else + { + Control parent = _relatedControl.Parent; + parent.PerformLayout(); + + var selectionManager = _serviceProvider.GetRequiredService(); + selectionManager.Refresh(); + + Point loc = _behaviorService.ControlToAdornerWindow(parent); + var translatedBounds = new Rectangle(loc, parent.Size); + _behaviorService.Invalidate(translatedBounds); + } + } + } + + return false; + } + + private void ReParentControls(IList controls, bool copy) + { + if (controls.Count <= 0) + { + return; + } + + // Create a transaction so this happens as an atomic unit. + var host = _serviceProvider.GetRequiredService(); + using DesignerTransaction transaction = host.CreateTransaction(GetTransactionDescription()); + + List? temp = copy ? new List() : null; + ISelectionService selectionService = _serviceProvider.GetRequiredService(); + IComponentChangeService changeService = _serviceProvider.GetRequiredService(); + + for (var i = 0; i < controls.Count; i++) + { + if (controls[0] is not ToolStrip control) + { + continue; + } + + if (copy) + { + temp!.Clear(); + temp.Add(control); + + temp = (List)DesignerUtils.CopyDragObjects(temp, _serviceProvider); + if (temp is not null) + { + control = (ToolStrip)temp[0]; + control.Visible = true; + } + } + + Control newParent = _relatedControl; + PropertyDescriptor? controlsProp = TypeDescriptor.GetProperties(newParent)["Controls"]; + Control? oldParent = control.Parent; + if (oldParent is not null && !copy) + { + changeService.OnComponentChanging(oldParent, controlsProp); + oldParent.Controls.Remove(control); + } + + changeService.OnComponentChanging(newParent, controlsProp); + + // Finally add & relocate the control with the new parent. + newParent.Controls.Add(control); + + if (oldParent is not null && !copy) + { + changeService.OnComponentChanged(oldParent, controlsProp, oldValue: null, newValue: null); + } + + changeService.OnComponentChanged(newParent, controlsProp, oldValue: null, newValue: null); + + selectionService.SetSelectedComponents( + (Collections.ICollection)control, + i == 0 ? SelectionTypes.Primary | SelectionTypes.Replace : SelectionTypes.Add); + } + + transaction.Commit(); + + string GetTransactionDescription() + { + var control = controls[0]; + + if (controls.Count == 1 && control is ToolStrip) + { + var name = TypeDescriptor.GetComponentName(control); + if (string.IsNullOrEmpty(name)) + { + name = control.GetType().Name; + } + + return string.Format( + copy ? SR.BehaviorServiceCopyControl : SR.BehaviorServiceMoveControl, + name); + } + + return string.Format( + copy ? SR.BehaviorServiceCopyControls : SR.BehaviorServiceMoveControls, + controls.Count); + } + } + + /// + /// Simply clear the initial drag point, so we can start again + /// on the next mouse down. + /// + public override void OnDragDrop(Glyph? glyph, DragEventArgs e) + { + // Expand the glyph only if ToolStrip is dragged around + var expandPanel = false; + List? components = null; + + if (e.Data is DropSourceBehavior.BehaviorDataObject data) + { + components = new List(data.DragComponents.Count); + foreach (var component in data.DragComponents) + { + components.Add((IComponent)component); + } + + foreach (IComponent dragComponent in components) + { + if (dragComponent is ToolStrip tool && tool.Parent != _relatedControl) + { + expandPanel = true; + break; + } + } + + if (expandPanel && _relatedControl.Parent is { } root) + { + try + { + root.SuspendLayout(); + ExpandPanel(false); + + if (glyph is ToolStripPanelSelectionGlyph selectionGlyph) + { + Rectangle oldBounds = selectionGlyph.Bounds; + selectionGlyph.IsExpanded = true; + _behaviorService.Invalidate(oldBounds); + _behaviorService.Invalidate(selectionGlyph.Bounds); + } + + ReParentControls(components, e.Effect == DragDropEffects.Copy); + } + finally + { + root.ResumeLayout(true); + } + } + + data.CleanupDrag(); + } + else if (e.Data is DataObject && components is null) + { + IToolboxService toolboxService = _serviceProvider.GetRequiredService(); + IDesignerHost host = _serviceProvider.GetRequiredService(); + + if (toolboxService is not null && host is not null) + { + ToolboxItem item = toolboxService.DeserializeToolboxItem(e.Data, host); + if (item.GetType(host) == typeof(ToolStrip) + || item.GetType(host) == typeof(MenuStrip) + || item.GetType(host) == typeof(StatusStrip)) + { + ToolStripPanelDesigner? panelDesigner = + host.GetDesigner(_relatedControl) is ToolStripPanelDesigner toolStripPanelDesigner + ? toolStripPanelDesigner + : null; + + if (panelDesigner is not null) + { + OleDragDropHandler oleDragDropHandler = panelDesigner.GetOleDragHandler(); + oleDragDropHandler?.CreateTool(item, _relatedControl, 0, 0, 0, 0, false, false); + } + } + } + } + } + + public override void OnDragEnter(Glyph? glyph, DragEventArgs e) + { + if (e.Data is not null) + { + e.Effect = GetEffect(e.Data); + } + + base.OnDragEnter(glyph, e); + } + + public override void OnDragOver(Glyph? glyph, DragEventArgs e) + { + if (e.Data is not null) + { + e.Effect = GetEffect(e.Data); + } + + base.OnDragOver(glyph, e); + } + + private static DragDropEffects GetEffect(IDataObject data) + => DragComponentContainsToolStrip(data as DropSourceBehavior.BehaviorDataObject) + ? Control.ModifierKeys == Keys.Control + ? DragDropEffects.Copy + : DragDropEffects.Move + : DragDropEffects.None; +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolStripPanelSelectionGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolStripPanelSelectionGlyph.cs new file mode 100644 index 00000000000..8a7d053c376 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolStripPanelSelectionGlyph.cs @@ -0,0 +1,254 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing; + +namespace System.Windows.Forms.Design.Behavior; + +internal sealed class ToolStripPanelSelectionGlyph : ControlBodyGlyph +{ + private readonly ToolStripPanel? _relatedPanel; + private readonly BehaviorService? _behaviorService; + private Rectangle _glyphBounds; + private Bitmap? _image; + private Control? _baseParent; + private bool _isExpanded; + + private const int ImageWidthOriginal = 50; + private const int ImageHeightOriginal = 6; + + private int _imageWidth = ImageWidthOriginal; + private int _imageHeight = ImageHeightOriginal; + + internal ToolStripPanelSelectionGlyph(Rectangle bounds, Cursor cursor, IComponent relatedComponent, IServiceProvider? _provider, ToolStripPanelSelectionBehavior behavior) : base(bounds, cursor, relatedComponent, behavior) + { + _relatedPanel = relatedComponent as ToolStripPanel; + _behaviorService = _provider?.GetService(); + if (_behaviorService is null) + { + return; + } + + IDesignerHost? host = _provider?.GetService(); + if (host is null) + { + return; + } + + UpdateGlyph(); + } + + public bool IsExpanded + { + get => _isExpanded; + set + { + if (value != _isExpanded) + { + _isExpanded = value; + UpdateGlyph(); + } + } + } + + public void UpdateGlyph() + { + if (_behaviorService is null) + { + return; + } + + Rectangle translatedBounds = _behaviorService.ControlRectInAdornerWindow(_relatedPanel!); + //Reset the glyph. + _glyphBounds = Rectangle.Empty; + + // Refresh the parent + ToolStripContainer? parent = _relatedPanel?.Parent as ToolStripContainer; + if (parent is not null) + { + // get the control to which ToolStripContainer is added. + _baseParent = parent.Parent; + } + + if (_image is not null) + { + _image.Dispose(); + _image = null; + } + + if (!_isExpanded) + { + CollapseGlyph(translatedBounds); + } + else + { + ExpandGlyph(translatedBounds); + } + } + + private void SetBitmap(string fileName) + { + _image = new Bitmap(typeof(ToolStripPanelSelectionGlyph), fileName); + _image.MakeTransparent(Color.Magenta); + + if (DpiHelper.IsScalingRequired) + { + Bitmap? deviceImage = null; + if (_image.Width > _image.Height) + { + _imageWidth = DpiHelper.LogicalToDeviceUnitsX(ImageWidthOriginal); + _imageHeight = DpiHelper.LogicalToDeviceUnitsY(ImageHeightOriginal); + deviceImage = DpiHelper.CreateResizedBitmap(_image, new Size(_imageWidth, _imageHeight)); + } + else + { + _imageHeight = DpiHelper.LogicalToDeviceUnitsX(ImageHeightOriginal); + _imageWidth = DpiHelper.LogicalToDeviceUnitsY(ImageWidthOriginal); + deviceImage = DpiHelper.CreateResizedBitmap(_image, new Size(_imageHeight, _imageWidth)); + } + + if (deviceImage is not null) + { + _image.Dispose(); + _image = deviceImage; + } + } + } + + private void CollapseGlyph(Rectangle bounds) + { + DockStyle? dock = _relatedPanel?.Dock; + int x = 0; + int y = 0; + + switch (dock) + { + case DockStyle.Top: + SetBitmap("TopOpen"); + x = (bounds.Width - _imageWidth) / 2; + if (x > 0) + { + _glyphBounds = new Rectangle(bounds.X + x, bounds.Y + bounds.Height, _imageWidth, _imageHeight); + } + + break; + case DockStyle.Bottom: + SetBitmap("BottomOpen"); + x = (bounds.Width - _imageWidth) / 2; + if (x > 0) + { + _glyphBounds = new Rectangle(bounds.X + x, bounds.Y - _imageHeight, _imageWidth, _imageHeight); + } + + break; + case DockStyle.Left: + SetBitmap("LeftOpen"); + y = (bounds.Height - _imageWidth) / 2; + if (y > 0) + { + _glyphBounds = new Rectangle(bounds.X + bounds.Width, bounds.Y + y, _imageHeight, _imageWidth); + } + + break; + case DockStyle.Right: + SetBitmap("RightOpen"); + y = (bounds.Height - _imageWidth) / 2; + if (y > 0) + { + _glyphBounds = new Rectangle(bounds.X - _imageHeight, bounds.Y + y, _imageHeight, _imageWidth); + } + + break; + default: + throw new NotSupportedException(SR.ToolStripPanelGlyphUnsupportedDock); + } + } + + private void ExpandGlyph(Rectangle bounds) + { + DockStyle? dock = _relatedPanel?.Dock; + int x = 0; + int y = 0; + + switch (dock) + { + case DockStyle.Top: + SetBitmap("TopClose"); + x = (bounds.Width - _imageWidth) / 2; + if (x > 0) + { + _glyphBounds = new Rectangle(bounds.X + x, bounds.Y + bounds.Height, _imageWidth, _imageHeight); + } + + break; + case DockStyle.Bottom: + SetBitmap("BottomClose"); + x = (bounds.Width - _imageWidth) / 2; + if (x > 0) + { + _glyphBounds = new Rectangle(bounds.X + x, bounds.Y - _imageHeight, _imageWidth, _imageHeight); + } + + break; + case DockStyle.Left: + SetBitmap("LeftClose"); + y = (bounds.Height - _imageWidth) / 2; + if (y > 0) + { + _glyphBounds = new Rectangle(bounds.X + bounds.Width, bounds.Y + y, _imageHeight, _imageWidth); + } + + break; + case DockStyle.Right: + SetBitmap("RightClose"); + y = (bounds.Height - _imageWidth) / 2; + if (y > 0) + { + _glyphBounds = new Rectangle(bounds.X - _imageHeight, bounds.Y + y, _imageHeight, _imageWidth); + } + + break; + default: + throw new Exception(SR.ToolStripPanelGlyphUnsupportedDock); + } + } + + /// + /// The bounds of this Glyph. + /// + public override Rectangle Bounds => _glyphBounds; + + /// + /// Simple hit test rule: if the point is contained within the bounds + /// then it is a positive hit test. + /// + public override Cursor? GetHitTest(Point p) + { + if (_behaviorService is null || _baseParent is null) + { + return null; + } + + Rectangle baseParentBounds = _behaviorService.ControlRectInAdornerWindow(_baseParent); + return _glyphBounds != Rectangle.Empty && baseParentBounds.Contains(_glyphBounds) && _glyphBounds.Contains(p) ? Cursors.Hand : null; + } + + /// + /// Very simple paint logic. + /// + public override void Paint(PaintEventArgs pe) + { + if (_behaviorService is null || _baseParent is null) + { + return; + } + + Rectangle baseParentBounds = _behaviorService.ControlRectInAdornerWindow(_baseParent); + if (_relatedPanel!.Visible && _image is not null && _glyphBounds != Rectangle.Empty && baseParentBounds.Contains(_glyphBounds)) + { + pe.Graphics.DrawImage(_image, _glyphBounds.Left, _glyphBounds.Top); + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolboxItemSnapLineBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolboxItemSnapLineBehavior.cs index 157820ff0ed..8875f3ac22a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolboxItemSnapLineBehavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolboxItemSnapLineBehavior.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolboxSnapDragDropEventArgs.SnapDirection.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolboxSnapDragDropEventArgs.SnapDirection.cs index 67f353f057d..7807b1bf9e8 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolboxSnapDragDropEventArgs.SnapDirection.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolboxSnapDragDropEventArgs.SnapDirection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design.Behavior; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolboxSnapDragDropEventArgs.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolboxSnapDragDropEventArgs.cs index 9af2a9ee368..fd1c84f3191 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolboxSnapDragDropEventArgs.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/ToolboxSnapDragDropEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BindingNavigatorDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BindingNavigatorDesigner.cs new file mode 100644 index 00000000000..1ed14582044 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BindingNavigatorDesigner.cs @@ -0,0 +1,180 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel.Design; +using System.ComponentModel; +using System.Collections; + +namespace System.Windows.Forms.Design; + +internal class BindingNavigatorDesigner : ToolStripDesigner +{ + private static readonly string[] s_itemNames = + [ + "MovePreviousItem", + "MoveFirstItem", + "MoveNextItem", + "MoveLastItem", + "AddNewItem", + "DeleteItem", + "PositionItem", + "CountItem" + ]; + + public override void Initialize(IComponent component) + { + base.Initialize(component); + + IComponentChangeService componentChangeService = GetService(); + if (componentChangeService is not null) + { + componentChangeService.ComponentRemoved += ComponentChangeService_ComponentRemoved; + componentChangeService.ComponentChanged += ComponentChangeService_ComponentChanged; + } + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + IComponentChangeService componentChangeService = GetService(); + if (componentChangeService is not null) + { + componentChangeService.ComponentRemoved -= ComponentChangeService_ComponentRemoved; + componentChangeService.ComponentChanged -= ComponentChangeService_ComponentChanged; + } + } + + base.Dispose(disposing); + } + + public override void InitializeNewComponent(IDictionary defaultValues) + { + base.InitializeNewComponent(defaultValues); + + BindingNavigator navigator = (BindingNavigator)Component; + IDesignerHost? host = Component?.Site?.GetService(); + + try + { + s_autoAddNewItems = false; // Temporarily suppress "new items go to the selected strip" behavior + navigator.SuspendLayout(); // Turn off layout while adding items + navigator.AddStandardItems(); // Let the control add its standard items (user overridable) + SiteItems(host: host, items: navigator.Items); // Recursively site and name all the items on the strip + RaiseItemsChanged(); // Make designer Undo engine aware of the newly added and sited items + navigator.ResumeLayout(); // Allow strip to lay out now + navigator.ShowItemToolTips = true; // Non-default property setting for ShowToolTips + } + finally + { + s_autoAddNewItems = true; + } + } + + private void RaiseItemsChanged() + { + BindingNavigator navigator = (BindingNavigator)Component; + IComponentChangeService componentChangeService = GetService(); + + if (componentChangeService is not null) + { + MemberDescriptor? memberDescriptor = TypeDescriptor.GetProperties(navigator)["Items"]; + componentChangeService.OnComponentChanging(component: navigator, member: memberDescriptor); + componentChangeService.OnComponentChanged(component: navigator, member: memberDescriptor, oldValue: null, newValue: null); + + foreach (string itemName in s_itemNames) + { + PropertyDescriptor? propertyDescriptor = TypeDescriptor.GetProperties(navigator)[itemName]; + + if (propertyDescriptor is not null) + { + componentChangeService.OnComponentChanging(component: navigator, member: propertyDescriptor); + componentChangeService.OnComponentChanged(component: navigator, member: propertyDescriptor, oldValue: null, newValue: null); + } + } + } + } + + private void SiteItem(IDesignerHost? host, ToolStripItem item) + { + // Skip any controls added for design-time use only + if (item is DesignerToolStripControlHost) + { + return; + } + + // Site the item in the container, giving it a unique site name based on its initial Name property + host?.Container.Add(item, DesignerUtils.GetUniqueSiteName(host, item.Name)); + + // Update the item's Name property to reflect the unique site name that it was actually given + item.Name = item?.Site?.Name; + + // Site any sub-items of this item + ToolStripDropDownItem? dropDownItem = item as ToolStripDropDownItem; + if (dropDownItem is not null && dropDownItem.HasDropDownItems) + { + SiteItems(host: host, items: dropDownItem.DropDownItems); + } + } + + private void SiteItems(IDesignerHost? host, ToolStripItemCollection items) + { + foreach (ToolStripItem item in items) + { + SiteItem(host, item); + } + } + + private void ComponentChangeService_ComponentRemoved(object? sender, ComponentEventArgs e) + { + ToolStripItem? item = e.Component as ToolStripItem; + + if (item is not null) + { + BindingNavigator navigator = (BindingNavigator)Component; + + if (item == navigator.MoveFirstItem) + { + navigator.MoveFirstItem = null; + } + else if (item == navigator.MovePreviousItem) + { + navigator.MovePreviousItem = null; + } + else if (item == navigator.MoveNextItem) + { + navigator.MoveNextItem = null; + } + else if (item == navigator.MoveLastItem) + { + navigator.MoveLastItem = null; + } + else if (item == navigator.PositionItem) + { + navigator.PositionItem = null; + } + else if (item == navigator.CountItem) + { + navigator.CountItem = null; + } + else if (item == navigator.AddNewItem) + { + navigator.AddNewItem = null; + } + else if (item == navigator.DeleteItem) + { + navigator.DeleteItem = null; + } + } + } + + private void ComponentChangeService_ComponentChanged(object? sender, ComponentChangedEventArgs e) + { + BindingNavigator navigator = (BindingNavigator)Component; + + if (e.Component is not null && e.Component == navigator.CountItem && e.Member is not null && e.Member.Name == "Text") + { + navigator.CountItemFormat = navigator.CountItem.Text ?? string.Empty; + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BindingSourceDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BindingSourceDesigner.cs new file mode 100644 index 00000000000..7b6ceca0d3e --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BindingSourceDesigner.cs @@ -0,0 +1,81 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design; + +internal class BindingSourceDesigner : ComponentDesigner +{ + private bool _bindingUpdatedByUser; + + public bool BindingUpdatedByUser + { + set => _bindingUpdatedByUser = value; + } + + public override void Initialize(IComponent component) + { + base.Initialize(component); + + IComponentChangeService componentChangeService = GetService(); + if (componentChangeService is not null) + { + componentChangeService.ComponentChanged += OnComponentChanged; + componentChangeService.ComponentRemoving += OnComponentRemoving; + } + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + IComponentChangeService componentChangeService = GetService(); + if (componentChangeService is not null) + { + componentChangeService.ComponentChanged -= OnComponentChanged; + componentChangeService.ComponentRemoving -= OnComponentRemoving; + } + } + + base.Dispose(disposing); + } + + private void OnComponentChanged(object? sender, ComponentChangedEventArgs e) + { + if (_bindingUpdatedByUser && e.Component == Component && + e.Member is not null && (e.Member.Name == "DataSource" || e.Member.Name == "DataMember")) + { + _bindingUpdatedByUser = false; + + DataSourceProviderService dataSourceProviderService = GetService(); + dataSourceProviderService?.NotifyDataSourceComponentAdded(Component); + } + } + + private void OnComponentRemoving(object? sender, ComponentEventArgs e) + { + BindingSource? bindingSource = Component as BindingSource; + if (bindingSource is not null && bindingSource.DataSource == e.Component) + { + IComponentChangeService componentChangeService = GetService(); + string previousDataMember = bindingSource.DataMember; + + PropertyDescriptorCollection propertyDescriptorCollection = TypeDescriptor.GetProperties(bindingSource); + PropertyDescriptor? propertyDescriptor = propertyDescriptorCollection?["DataMember"]; + + if (componentChangeService is not null && propertyDescriptor is not null) + { + componentChangeService.OnComponentChanging(bindingSource, propertyDescriptor); + } + + bindingSource.DataSource = null; + + if (componentChangeService is not null && propertyDescriptor is not null) + { + componentChangeService.OnComponentChanged(bindingSource, propertyDescriptor, previousDataMember, string.Empty); + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BorderSidesEditor.BorderSidesEditorUI.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BorderSidesEditor.BorderSidesEditorUI.cs index f492090fd32..c0045f6db61 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BorderSidesEditor.BorderSidesEditorUI.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BorderSidesEditor.BorderSidesEditorUI.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.Drawing; @@ -16,26 +13,26 @@ public partial class BorderSidesEditor /// private class BorderSidesEditorUI : UserControl { - private CheckBox allCheckBox; + private CheckBox _allCheckBox; - private bool allChecked; - private CheckBox bottomCheckBox; - private readonly BorderSidesEditor editor; - private CheckBox leftCheckBox; - private CheckBox noneCheckBox; - private bool noneChecked; - private object originalValue; - private CheckBox rightCheckBox; - private Label splitterLabel; + private bool _allChecked; + private CheckBox _bottomCheckBox; + private readonly BorderSidesEditor _editor; + private CheckBox _leftCheckBox; + private CheckBox _noneCheckBox; + private bool _noneChecked; + private object? _originalValue; + private CheckBox _rightCheckBox; + private Label _splitterLabel; - private TableLayoutPanel tableLayoutPanel1; - private CheckBox topCheckBox; + private TableLayoutPanel _tableLayoutPanel; + private CheckBox _topCheckBox; private bool updateCurrentValue; public BorderSidesEditorUI(BorderSidesEditor editor) { - this.editor = editor; + this._editor = editor; End(); InitializeComponent(); Size = PreferredSize; @@ -44,7 +41,7 @@ public BorderSidesEditorUI(BorderSidesEditor editor) /// /// Allows someone else to close our dropdown. /// - public IWindowsFormsEditorService EditorService + public IWindowsFormsEditorService? EditorService { get; private set; @@ -53,12 +50,12 @@ public IWindowsFormsEditorService EditorService /// /// Returns the current value of BorderSides, if nothing is selected returns BorderSides.None. /// - public object Value { get; private set; } + public object? Value { get; private set; } public void End() { EditorService = null; - originalValue = null; + _originalValue = null; Value = null; updateCurrentValue = false; } @@ -69,128 +66,136 @@ public void End() protected override void OnGotFocus(EventArgs e) { base.OnGotFocus(e); - noneCheckBox.Focus(); + _noneCheckBox.Focus(); } + [MemberNotNull(nameof(_allCheckBox))] + [MemberNotNull(nameof(_bottomCheckBox))] + [MemberNotNull(nameof(_leftCheckBox))] + [MemberNotNull(nameof(_noneCheckBox))] + [MemberNotNull(nameof(_rightCheckBox))] + [MemberNotNull(nameof(_splitterLabel))] + [MemberNotNull(nameof(_tableLayoutPanel))] + [MemberNotNull(nameof(_topCheckBox))] private void InitializeComponent() { ComponentResourceManager resources = new ComponentResourceManager(typeof(BorderSidesEditor)); - tableLayoutPanel1 = new TableLayoutPanel(); - noneCheckBox = new CheckBox(); - allCheckBox = new CheckBox(); - topCheckBox = new CheckBox(); - bottomCheckBox = new CheckBox(); - rightCheckBox = new CheckBox(); - leftCheckBox = new CheckBox(); - splitterLabel = new Label(); - tableLayoutPanel1.SuspendLayout(); + _tableLayoutPanel = new TableLayoutPanel(); + _noneCheckBox = new CheckBox(); + _allCheckBox = new CheckBox(); + _topCheckBox = new CheckBox(); + _bottomCheckBox = new CheckBox(); + _rightCheckBox = new CheckBox(); + _leftCheckBox = new CheckBox(); + _splitterLabel = new Label(); + _tableLayoutPanel.SuspendLayout(); SuspendLayout(); // // tableLayoutPanel1 // - resources.ApplyResources(tableLayoutPanel1, "tableLayoutPanel1"); - tableLayoutPanel1.AutoSizeMode = AutoSizeMode.GrowAndShrink; - tableLayoutPanel1.BackColor = SystemColors.Window; - tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle()); - tableLayoutPanel1.Controls.Add(noneCheckBox, 0, 0); - tableLayoutPanel1.Controls.Add(allCheckBox, 0, 2); - tableLayoutPanel1.Controls.Add(topCheckBox, 0, 3); - tableLayoutPanel1.Controls.Add(bottomCheckBox, 0, 4); - tableLayoutPanel1.Controls.Add(rightCheckBox, 0, 6); - tableLayoutPanel1.Controls.Add(leftCheckBox, 0, 5); - tableLayoutPanel1.Controls.Add(splitterLabel, 0, 1); - tableLayoutPanel1.Name = "tableLayoutPanel1"; - tableLayoutPanel1.RowStyles.Add(new RowStyle()); - tableLayoutPanel1.RowStyles.Add(new RowStyle()); - tableLayoutPanel1.RowStyles.Add(new RowStyle()); - tableLayoutPanel1.RowStyles.Add(new RowStyle()); - tableLayoutPanel1.RowStyles.Add(new RowStyle()); - tableLayoutPanel1.RowStyles.Add(new RowStyle()); - tableLayoutPanel1.RowStyles.Add(new RowStyle()); - tableLayoutPanel1.Margin = new Padding(0); + resources.ApplyResources(_tableLayoutPanel, "tableLayoutPanel1"); + _tableLayoutPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; + _tableLayoutPanel.BackColor = SystemColors.Window; + _tableLayoutPanel.ColumnStyles.Add(new ColumnStyle()); + _tableLayoutPanel.Controls.Add(_noneCheckBox, 0, 0); + _tableLayoutPanel.Controls.Add(_allCheckBox, 0, 2); + _tableLayoutPanel.Controls.Add(_topCheckBox, 0, 3); + _tableLayoutPanel.Controls.Add(_bottomCheckBox, 0, 4); + _tableLayoutPanel.Controls.Add(_rightCheckBox, 0, 6); + _tableLayoutPanel.Controls.Add(_leftCheckBox, 0, 5); + _tableLayoutPanel.Controls.Add(_splitterLabel, 0, 1); + _tableLayoutPanel.Name = "tableLayoutPanel1"; + _tableLayoutPanel.RowStyles.Add(new RowStyle()); + _tableLayoutPanel.RowStyles.Add(new RowStyle()); + _tableLayoutPanel.RowStyles.Add(new RowStyle()); + _tableLayoutPanel.RowStyles.Add(new RowStyle()); + _tableLayoutPanel.RowStyles.Add(new RowStyle()); + _tableLayoutPanel.RowStyles.Add(new RowStyle()); + _tableLayoutPanel.RowStyles.Add(new RowStyle()); + _tableLayoutPanel.Margin = new Padding(0); // // noneCheckBox // - resources.ApplyResources(noneCheckBox, "noneCheckBox"); - noneCheckBox.Name = "noneCheckBox"; - noneCheckBox.Margin = new Padding(3, 3, 3, 1); + resources.ApplyResources(_noneCheckBox, "noneCheckBox"); + _noneCheckBox.Name = "noneCheckBox"; + _noneCheckBox.Margin = new Padding(3, 3, 3, 1); // // allCheckBox // - resources.ApplyResources(allCheckBox, "allCheckBox"); - allCheckBox.Name = "allCheckBox"; - allCheckBox.Margin = new Padding(3, 3, 3, 1); + resources.ApplyResources(_allCheckBox, "allCheckBox"); + _allCheckBox.Name = "allCheckBox"; + _allCheckBox.Margin = new Padding(3, 3, 3, 1); // // topCheckBox // - resources.ApplyResources(topCheckBox, "topCheckBox"); - topCheckBox.Margin = new Padding(20, 1, 3, 1); - topCheckBox.Name = "topCheckBox"; + resources.ApplyResources(_topCheckBox, "topCheckBox"); + _topCheckBox.Margin = new Padding(20, 1, 3, 1); + _topCheckBox.Name = "topCheckBox"; // // bottomCheckBox // - resources.ApplyResources(bottomCheckBox, "bottomCheckBox"); - bottomCheckBox.Margin = new Padding(20, 1, 3, 1); - bottomCheckBox.Name = "bottomCheckBox"; + resources.ApplyResources(_bottomCheckBox, "bottomCheckBox"); + _bottomCheckBox.Margin = new Padding(20, 1, 3, 1); + _bottomCheckBox.Name = "bottomCheckBox"; // // rightCheckBox // - resources.ApplyResources(rightCheckBox, "rightCheckBox"); - rightCheckBox.Margin = new Padding(20, 1, 3, 1); - rightCheckBox.Name = "rightCheckBox"; + resources.ApplyResources(_rightCheckBox, "rightCheckBox"); + _rightCheckBox.Margin = new Padding(20, 1, 3, 1); + _rightCheckBox.Name = "rightCheckBox"; // // leftCheckBox // - resources.ApplyResources(leftCheckBox, "leftCheckBox"); - leftCheckBox.Margin = new Padding(20, 1, 3, 1); - leftCheckBox.Name = "leftCheckBox"; + resources.ApplyResources(_leftCheckBox, "leftCheckBox"); + _leftCheckBox.Margin = new Padding(20, 1, 3, 1); + _leftCheckBox.Name = "leftCheckBox"; // // splitterLabel // - resources.ApplyResources(splitterLabel, "splitterLabel"); - splitterLabel.BackColor = SystemColors.ControlDark; - splitterLabel.Name = "splitterLabel"; + resources.ApplyResources(_splitterLabel, "splitterLabel"); + _splitterLabel.BackColor = SystemColors.ControlDark; + _splitterLabel.Name = "splitterLabel"; // // Control // resources.ApplyResources(this, "$this"); - Controls.Add(tableLayoutPanel1); + Controls.Add(_tableLayoutPanel); Padding = new Padding(1, 1, 1, 1); AutoSizeMode = AutoSizeMode.GrowAndShrink; AutoScaleMode = AutoScaleMode.Font; AutoScaleDimensions = new SizeF(6F, 13F); - tableLayoutPanel1.ResumeLayout(false); - tableLayoutPanel1.PerformLayout(); + _tableLayoutPanel.ResumeLayout(false); + _tableLayoutPanel.PerformLayout(); ResumeLayout(false); PerformLayout(); //Events - rightCheckBox.CheckedChanged += rightCheckBox_CheckedChanged; - leftCheckBox.CheckedChanged += leftCheckBox_CheckedChanged; - bottomCheckBox.CheckedChanged += bottomCheckBox_CheckedChanged; - topCheckBox.CheckedChanged += topCheckBox_CheckedChanged; - noneCheckBox.CheckedChanged += noneCheckBox_CheckedChanged; - allCheckBox.CheckedChanged += allCheckBox_CheckedChanged; - - noneCheckBox.Click += noneCheckBoxClicked; - allCheckBox.Click += allCheckBoxClicked; + _rightCheckBox.CheckedChanged += rightCheckBox_CheckedChanged; + _leftCheckBox.CheckedChanged += leftCheckBox_CheckedChanged; + _bottomCheckBox.CheckedChanged += bottomCheckBox_CheckedChanged; + _topCheckBox.CheckedChanged += topCheckBox_CheckedChanged; + _noneCheckBox.CheckedChanged += noneCheckBox_CheckedChanged; + _allCheckBox.CheckedChanged += allCheckBox_CheckedChanged; + + _noneCheckBox.Click += noneCheckBoxClicked; + _allCheckBox.Click += allCheckBoxClicked; } /// /// CheckBox CheckedChanged event.. allows selecting/Deselecting proper values. /// - private void rightCheckBox_CheckedChanged(object sender, EventArgs e) + private void rightCheckBox_CheckedChanged(object? sender, EventArgs e) { - CheckBox senderCheckBox = sender as CheckBox; + CheckBox senderCheckBox = (CheckBox)sender!; if (senderCheckBox.Checked) { - noneCheckBox.Checked = false; + _noneCheckBox.Checked = false; } else // this is turned off.... { - if (allCheckBox.Checked) + if (_allCheckBox.Checked) { - allCheckBox.Checked = false; + _allCheckBox.Checked = false; } } @@ -200,18 +205,18 @@ private void rightCheckBox_CheckedChanged(object sender, EventArgs e) /// /// CheckBox CheckedChanged event.. allows selecting/Deselecting proper values. /// - private void leftCheckBox_CheckedChanged(object sender, EventArgs e) + private void leftCheckBox_CheckedChanged(object? sender, EventArgs e) { - CheckBox senderCheckBox = sender as CheckBox; + CheckBox senderCheckBox = (CheckBox)sender!; if (senderCheckBox.Checked) { - noneCheckBox.Checked = false; + _noneCheckBox.Checked = false; } else // this is turned off.... { - if (allCheckBox.Checked) + if (_allCheckBox.Checked) { - allCheckBox.Checked = false; + _allCheckBox.Checked = false; } } @@ -221,18 +226,18 @@ private void leftCheckBox_CheckedChanged(object sender, EventArgs e) /// /// CheckBox CheckedChanged event.. allows selecting/Deselecting proper values. /// - private void bottomCheckBox_CheckedChanged(object sender, EventArgs e) + private void bottomCheckBox_CheckedChanged(object? sender, EventArgs e) { - CheckBox senderCheckBox = sender as CheckBox; + CheckBox senderCheckBox = (CheckBox)sender!; if (senderCheckBox.Checked) { - noneCheckBox.Checked = false; + _noneCheckBox.Checked = false; } else // this is turned off.... { - if (allCheckBox.Checked) + if (_allCheckBox.Checked) { - allCheckBox.Checked = false; + _allCheckBox.Checked = false; } } @@ -242,18 +247,18 @@ private void bottomCheckBox_CheckedChanged(object sender, EventArgs e) /// /// CheckBox CheckedChanged event.. allows selecting/Deselecting proper values. /// - private void topCheckBox_CheckedChanged(object sender, EventArgs e) + private void topCheckBox_CheckedChanged(object? sender, EventArgs e) { - CheckBox senderCheckBox = sender as CheckBox; + CheckBox senderCheckBox = (CheckBox)sender!; if (senderCheckBox.Checked) { - noneCheckBox.Checked = false; + _noneCheckBox.Checked = false; } else // this is turned off.... { - if (allCheckBox.Checked) + if (_allCheckBox.Checked) { - allCheckBox.Checked = false; + _allCheckBox.Checked = false; } } @@ -263,16 +268,16 @@ private void topCheckBox_CheckedChanged(object sender, EventArgs e) /// /// CheckBox CheckedChanged event.. allows selecting/Deselecting proper values. /// - private void noneCheckBox_CheckedChanged(object sender, EventArgs e) + private void noneCheckBox_CheckedChanged(object? sender, EventArgs e) { - CheckBox senderCheckBox = sender as CheckBox; + CheckBox senderCheckBox = (CheckBox)sender!; if (senderCheckBox.Checked) { - allCheckBox.Checked = false; - topCheckBox.Checked = false; - bottomCheckBox.Checked = false; - leftCheckBox.Checked = false; - rightCheckBox.Checked = false; + _allCheckBox.Checked = false; + _topCheckBox.Checked = false; + _bottomCheckBox.Checked = false; + _leftCheckBox.Checked = false; + _rightCheckBox.Checked = false; } UpdateCurrentValue(); @@ -281,16 +286,16 @@ private void noneCheckBox_CheckedChanged(object sender, EventArgs e) /// /// CheckBox CheckedChanged event.. allows selecting/Deselecting proper values. /// - private void allCheckBox_CheckedChanged(object sender, EventArgs e) + private void allCheckBox_CheckedChanged(object? sender, EventArgs e) { - CheckBox senderCheckBox = sender as CheckBox; + CheckBox senderCheckBox = (CheckBox)sender!; if (senderCheckBox.Checked) { - noneCheckBox.Checked = false; - topCheckBox.Checked = true; - bottomCheckBox.Checked = true; - leftCheckBox.Checked = true; - rightCheckBox.Checked = true; + _noneCheckBox.Checked = false; + _topCheckBox.Checked = true; + _bottomCheckBox.Checked = true; + _leftCheckBox.Checked = true; + _rightCheckBox.Checked = true; } UpdateCurrentValue(); @@ -299,22 +304,22 @@ private void allCheckBox_CheckedChanged(object sender, EventArgs e) /// /// Click event. /// - private void noneCheckBoxClicked(object sender, EventArgs e) + private void noneCheckBoxClicked(object? sender, EventArgs e) { - if (noneChecked) + if (_noneChecked) { - noneCheckBox.Checked = true; + _noneCheckBox.Checked = true; } } /// /// Click event. /// - private void allCheckBoxClicked(object sender, EventArgs e) + private void allCheckBoxClicked(object? sender, EventArgs e) { - if (allChecked) + if (_allChecked) { - allCheckBox.Checked = true; + _allCheckBox.Checked = true; } } @@ -323,12 +328,12 @@ private void allCheckBoxClicked(object sender, EventArgs e) /// private void ResetCheckBoxState() { - allCheckBox.Checked = false; - noneCheckBox.Checked = false; - topCheckBox.Checked = false; - bottomCheckBox.Checked = false; - leftCheckBox.Checked = false; - rightCheckBox.Checked = false; + _allCheckBox.Checked = false; + _noneCheckBox.Checked = false; + _topCheckBox.Checked = false; + _bottomCheckBox.Checked = false; + _leftCheckBox.Checked = false; + _rightCheckBox.Checked = false; } /// @@ -339,24 +344,24 @@ private void SetCheckBoxCheckState(ToolStripStatusLabelBorderSides sides) ResetCheckBoxState(); if ((sides & ToolStripStatusLabelBorderSides.All) == ToolStripStatusLabelBorderSides.All) { - allCheckBox.Checked = true; - topCheckBox.Checked = true; - bottomCheckBox.Checked = true; - leftCheckBox.Checked = true; - rightCheckBox.Checked = true; - allCheckBox.Checked = true; + _allCheckBox.Checked = true; + _topCheckBox.Checked = true; + _bottomCheckBox.Checked = true; + _leftCheckBox.Checked = true; + _rightCheckBox.Checked = true; + _allCheckBox.Checked = true; } else { - noneCheckBox.Checked = (sides & ToolStripStatusLabelBorderSides.None) == + _noneCheckBox.Checked = (sides & ToolStripStatusLabelBorderSides.None) == ToolStripStatusLabelBorderSides.None; - topCheckBox.Checked = (sides & ToolStripStatusLabelBorderSides.Top) == + _topCheckBox.Checked = (sides & ToolStripStatusLabelBorderSides.Top) == ToolStripStatusLabelBorderSides.Top; - bottomCheckBox.Checked = (sides & ToolStripStatusLabelBorderSides.Bottom) == + _bottomCheckBox.Checked = (sides & ToolStripStatusLabelBorderSides.Bottom) == ToolStripStatusLabelBorderSides.Bottom; - leftCheckBox.Checked = (sides & ToolStripStatusLabelBorderSides.Left) == + _leftCheckBox.Checked = (sides & ToolStripStatusLabelBorderSides.Left) == ToolStripStatusLabelBorderSides.Left; - rightCheckBox.Checked = (sides & ToolStripStatusLabelBorderSides.Right) == + _rightCheckBox.Checked = (sides & ToolStripStatusLabelBorderSides.Right) == ToolStripStatusLabelBorderSides.Right; } } @@ -364,12 +369,12 @@ private void SetCheckBoxCheckState(ToolStripStatusLabelBorderSides sides) /// /// Triggered whenever the user drops down the editor. /// - public void Start(IWindowsFormsEditorService edSvc, object value) + public void Start(IWindowsFormsEditorService edSvc, object? value) { Debug.Assert(edSvc is not null); EditorService = edSvc; - originalValue = Value = value; + _originalValue = Value = value; if (value is ToolStripStatusLabelBorderSides currentSides) { @@ -389,53 +394,53 @@ private void UpdateCurrentValue() } ToolStripStatusLabelBorderSides valueSide = ToolStripStatusLabelBorderSides.None; - if (allCheckBox.Checked) + if (_allCheckBox.Checked) { valueSide |= ToolStripStatusLabelBorderSides.All; Value = valueSide; - allChecked = true; - noneChecked = false; + _allChecked = true; + _noneChecked = false; return; } - if (noneCheckBox.Checked) + if (_noneCheckBox.Checked) { valueSide |= ToolStripStatusLabelBorderSides.None; } - if (topCheckBox.Checked) + if (_topCheckBox.Checked) { valueSide |= ToolStripStatusLabelBorderSides.Top; } - if (bottomCheckBox.Checked) + if (_bottomCheckBox.Checked) { valueSide |= ToolStripStatusLabelBorderSides.Bottom; } - if (leftCheckBox.Checked) + if (_leftCheckBox.Checked) { valueSide |= ToolStripStatusLabelBorderSides.Left; } - if (rightCheckBox.Checked) + if (_rightCheckBox.Checked) { valueSide |= ToolStripStatusLabelBorderSides.Right; } if (valueSide == ToolStripStatusLabelBorderSides.None) { - allChecked = false; - noneChecked = true; - noneCheckBox.Checked = true; + _allChecked = false; + _noneChecked = true; + _noneCheckBox.Checked = true; } if (valueSide == (ToolStripStatusLabelBorderSides.Left | ToolStripStatusLabelBorderSides.Right | ToolStripStatusLabelBorderSides.Top | ToolStripStatusLabelBorderSides.Bottom)) { - allChecked = true; - noneChecked = false; - allCheckBox.Checked = true; + _allChecked = true; + _noneChecked = false; + _allCheckBox.Checked = true; } Value = valueSide; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BorderSidesEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BorderSidesEditor.cs index f678c9eca70..2e8d55db702 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BorderSidesEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/BorderSidesEditor.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.Drawing.Design; @@ -15,12 +12,12 @@ namespace System.Windows.Forms.Design; [CLSCompliant(false)] public partial class BorderSidesEditor : UITypeEditor { - private BorderSidesEditorUI _borderSidesEditorUI; + private BorderSidesEditorUI? _borderSidesEditorUI; /// - public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) + public override object? EditValue(ITypeDescriptorContext? context, IServiceProvider provider, object? value) { - if (!provider.TryGetService(out IWindowsFormsEditorService editorService)) + if (!provider.TryGetService(out IWindowsFormsEditorService? editorService)) { return value; } @@ -40,5 +37,5 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide } /// - public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.DropDown; + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext? context) => UITypeEditorEditStyle.DropDown; } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ButtonBaseDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ButtonBaseDesigner.cs index 5fe46826afe..c0bd9057f8d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ButtonBaseDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ButtonBaseDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ChangeToolStripParentVerb.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ChangeToolStripParentVerb.cs index 58e7f5bcd49..0fbc8d94b01 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ChangeToolStripParentVerb.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ChangeToolStripParentVerb.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -17,7 +16,7 @@ internal class ChangeToolStripParentVerb { private readonly ToolStripDesigner _designer; private readonly IDesignerHost _host; - private readonly IComponentChangeService _componentChangeSvc; + private readonly IComponentChangeService _componentChangeService; private readonly IServiceProvider _provider; /// @@ -28,8 +27,8 @@ internal ChangeToolStripParentVerb(string text, ToolStripDesigner designer) Debug.Assert(designer is not null, "Can't have a StandardMenuStripVerb without an associated designer"); _designer = designer; _provider = designer.Component.Site; - _host = (IDesignerHost)_provider.GetService(typeof(IDesignerHost)); - _componentChangeSvc = (IComponentChangeService)_provider.GetService(typeof(IComponentChangeService)); + _host = _provider.GetService(); + _componentChangeService = (IComponentChangeService)_provider.GetService(typeof(IComponentChangeService)); } /// @@ -53,16 +52,16 @@ public void ChangeParent() ToolStrip toolStrip = _designer.Component as ToolStrip; if (toolStrip is not null && _designer is not null && _designer.Component is not null && _provider is not null) { - DesignerActionUIService dapuisvc = _provider.GetService(typeof(DesignerActionUIService)) as DesignerActionUIService; - dapuisvc.HideUI(toolStrip); + DesignerActionUIService designerActionUIService = _provider.GetService(typeof(DesignerActionUIService)) as DesignerActionUIService; + designerActionUIService.HideUI(toolStrip); } // Get OleDragHandler ... - ToolboxItem tbi = new ToolboxItem(typeof(ToolStripContainer)); - OleDragDropHandler ddh = rootDesigner.GetOleDragHandler(); - if (ddh is not null) + ToolboxItem toolboxItem = new ToolboxItem(typeof(ToolStripContainer)); + OleDragDropHandler oleDragDropHandler = rootDesigner.GetOleDragHandler(); + if (oleDragDropHandler is not null) { - IComponent[] newComp = ddh.CreateTool(tbi, root, 0, 0, 0, 0, false, false); + IComponent[] newComp = oleDragDropHandler.CreateTool(toolboxItem, root, 0, 0, 0, 0, false, false); if (newComp[0] is ToolStripContainer tsc) { if (toolStrip is not null) diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CollectionEditVerbManager.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CollectionEditVerbManager.cs index 283d547e461..8b8766f0562 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CollectionEditVerbManager.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CollectionEditVerbManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -17,7 +16,7 @@ namespace System.Windows.Forms.Design; internal class CollectionEditVerbManager : IWindowsFormsEditorService, ITypeDescriptorContext { private readonly ComponentDesigner _designer; - private IComponentChangeService _componentChangeSvc; + private IComponentChangeService _componentChangeService; private readonly PropertyDescriptor _targetProperty; private readonly DesignerVerb _editItemsVerb; @@ -56,9 +55,9 @@ private IComponentChangeService ChangeService { get { - _componentChangeSvc ??= (IComponentChangeService)((IServiceProvider)this).GetService(typeof(IComponentChangeService)); + _componentChangeService ??= this.GetService(); - return _componentChangeSvc; + return _componentChangeService; } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ColumnHeaderCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ColumnHeaderCollectionEditor.cs index 214417b03c8..5df83302284 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ColumnHeaderCollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ColumnHeaderCollectionEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComboBoxDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComboBoxDesigner.cs index 70bb8594da1..b868fb90569 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComboBoxDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComboBoxDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CommandSet.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CommandSet.cs index ac7ce14e607..7b29e7b1aa9 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CommandSet.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CommandSet.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentActionsType.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentActionsType.cs index 52c74a4492f..a80eff78d75 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentActionsType.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentActionsType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentTray.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentTray.cs index d8a617439f4..eb2e2f57e52 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentTray.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentTray.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -26,7 +25,7 @@ namespace System.Windows.Forms.Design; [ProvideProperty("TrayLocation", typeof(IComponent))] public class ComponentTray : ScrollableControl, IExtenderProvider, ISelectionUIHandler, IOleDragClient { - private static readonly Point InvalidPoint = new Point(int.MinValue, int.MinValue); + private static readonly Point InvalidPoint = new(int.MinValue, int.MinValue); private IServiceProvider serviceProvider; // Where services come from. private Point whiteSpace = Point.Empty; // space to leave between components. private Size grabHandle = Size.Empty; // Size of the grab handles. @@ -978,7 +977,7 @@ public Point GetTrayLocation(IComponent receiver) if (c is null) { Debug.Fail("Anything we're extending should have a component view."); - return default(Point); + return default; } Point loc = c.Location; @@ -2527,12 +2526,13 @@ protected override void WndProc(ref Message m) case PInvoke.WM_NCHITTEST: if (_tray.glyphManager is not null) { - // Make sure tha we send our glyphs hit test messages over the TrayControls too + // Make sure that we send our glyphs hit test messages over the TrayControls too. Point pt = PARAM.ToPoint(m.LParamInternal); - var pt1 = default(Point); - pt1 = PointToClient(pt1); + Point pt1 = PointToClient(default); pt.Offset(pt1.X, pt1.Y); - pt.Offset(Location.X, Location.Y); //offset the loc of the traycontrol -so now we're in comptray coords + + // Offset the location of the traycontrol so we're in component tray coordinates. + pt.Offset(Location.X, Location.Y); _tray.glyphManager.GetHitTest(pt); } @@ -2781,7 +2781,7 @@ private class TraySelectionUIHandler : SelectionUIHandler public TraySelectionUIHandler(ComponentTray tray) { _tray = tray; - _snapSize = default(Size); + _snapSize = default; } /// diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CompositionDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CompositionDesigner.cs index 546c2cd0de4..702db474fcb 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CompositionDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CompositionDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventArgs.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventArgs.cs index d7540fb2c17..c698868284d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventArgs.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventArgsType.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventArgsType.cs index 19bbed2c6b4..810350027ee 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventArgsType.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventArgsType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventHandler.cs index 4aa20c4e0ec..53074c212c6 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContainerSelectorActiveEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripActionList.cs index 6a40c9a5903..b6fe3c227db 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripActionList.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripActionList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripGroup.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripGroup.cs index b2e7191c46e..6673f34a8f6 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripGroup.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripGroup.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripGroupCollection.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripGroupCollection.cs index 1e0e877ccc2..f1a44dc01fc 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripGroupCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ContextMenuStripGroupCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlCodeDomSerializer.cs index 477e1435453..25e08a559f6 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlCommandSet.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlCommandSet.cs index 81da104220f..f07f6b812ef 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlCommandSet.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlCommandSet.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.CanResetSizePropertyDescriptor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.CanResetSizePropertyDescriptor.cs index e02a0355167..cc22a807e9d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.CanResetSizePropertyDescriptor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.CanResetSizePropertyDescriptor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ChildSubClass.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ChildSubClass.cs index ec3d842234d..65cf4a746fb 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ChildSubClass.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ChildSubClass.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ChildWindowTarget.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ChildWindowTarget.cs index 03b38b921e9..7a0a1222914 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ChildWindowTarget.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ChildWindowTarget.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ControlDesignerAccessibleObject.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ControlDesignerAccessibleObject.cs index 57984c99fbf..a91698fac6d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ControlDesignerAccessibleObject.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.ControlDesignerAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DesignerControlCollection.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DesignerControlCollection.cs index def8828b67c..83351fc414c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DesignerControlCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DesignerControlCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -34,7 +33,7 @@ internal class DesignerControlCollection : Control.ControlCollection, IList public override void Add(Control c) => _realCollection.Add(c); - public override void AddRange(Control[] controls) => _realCollection.AddRange(controls); + public override void AddRange(params Control[] controls) => _realCollection.AddRange(controls); bool IList.Contains(object control) => ((IList)_realCollection).Contains(control); diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DesignerControlCollectionCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DesignerControlCollectionCodeDomSerializer.cs index d54a1afdfe0..51eba088442 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DesignerControlCollectionCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DesignerControlCollectionCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; using System.Collections; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DesignerWindowTarget.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DesignerWindowTarget.cs index 23dc3d011d0..fb8f1937ea6 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DesignerWindowTarget.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DesignerWindowTarget.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DockingActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DockingActionList.cs index 55c6dc89083..2a4a23fd717 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DockingActionList.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.DockingActionList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.IDesignerTarget.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.IDesignerTarget.cs index b6e08af93a1..90d49e1f9b4 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.IDesignerTarget.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.IDesignerTarget.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.TransparentBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.TransparentBehavior.cs index bec6cc43487..0d6b6abcd5a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.TransparentBehavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.TransparentBehavior.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.cs index a8b78f0bd0c..253eeed9243 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -309,7 +308,7 @@ public virtual SelectionRules SelectionRules internal Point GetOffsetToClientArea() { - var nativeOffset = default(Point); + Point nativeOffset = default; PInvoke.MapWindowPoints(Control, Control.Parent, ref nativeOffset); Point offset = Control.Location; @@ -319,7 +318,7 @@ internal Point GetOffsetToClientArea() offset.Offset(Control.Width, 0); } - return (new Point(Math.Abs(nativeOffset.X - offset.X), nativeOffset.Y - offset.Y)); + return new Point(Math.Abs(nativeOffset.X - offset.X), nativeOffset.Y - offset.Y); } /// @@ -2067,7 +2066,7 @@ protected virtual unsafe void WndProc(ref Message m) // First, save off the update region and call our base class. - RECT clip = default(RECT); + RECT clip = default; using var hrgn = new PInvoke.RegionScope(0, 0, 0, 0); PInvoke.GetUpdateRgn(m.HWND, hrgn, false); PInvoke.GetUpdateRect(m.HWND, &clip, false); diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CustomMenuItemCollection.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CustomMenuItemCollection.cs index 66209746e94..22c3b740720 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CustomMenuItemCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CustomMenuItemCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; @@ -29,7 +28,7 @@ public int Add(ToolStripItem value) /// /// Add range of values to the collection /// - public void AddRange(ToolStripItem[] value) + public void AddRange(params ToolStripItem[] value) { for (int i = 0; (i < value.Length); i++) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewAddColumnDialog.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewAddColumnDialog.cs new file mode 100644 index 00000000000..b76090eb75d --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewAddColumnDialog.cs @@ -0,0 +1,973 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel.Design.Serialization; +using System.ComponentModel.Design; +using System.ComponentModel; +using System.Globalization; +using System.Drawing; + +namespace System.Windows.Forms.Design; + +internal class DataGridViewAddColumnDialog : Form +{ + private RadioButton? _dataBoundColumnRadioButton; + private Label? _columnInDataSourceLabel; + + private ListBox? _dataColumns; + + private RadioButton? _unboundColumnRadioButton; + private TextBox? _nameTextBox; + + private ComboBox? _columnTypesCombo; + + private TextBox? _headerTextBox; + private Label? _nameLabel; + + private Label? _typeLabel; + + private Label? _headerTextLabel; + private CheckBox? _visibleCheckBox; + + private CheckBox? _readOnlyCheckBox; + + private CheckBox? _frozenCheckBox; + private Button? _addButton; + + private Button? _cancelButton; + + private DataGridViewColumnCollection? _dataGridViewColumns; + private DataGridView? _liveDataGridView; + private int _insertAtPosition = -1; + private int _initialDataGridViewColumnsCount = -1; + private bool _persistChangesToDesigner; + + private static Type dataGridViewColumnType = typeof(DataGridViewColumn); + private static Type iDesignerType = typeof(IDesigner); + private static Type iTypeDiscoveryServiceType = typeof(ITypeDiscoveryService); + private static Type iComponentChangeServiceType = typeof(IComponentChangeService); + private static Type iHelpServiceType = typeof(IHelpService); + private static Type iUIServiceType = typeof(IUIService); + private static Type iDesignerHostType = typeof(IDesignerHost); + private static Type iNameCreationServiceType = typeof(INameCreationService); + private static Type dataGridViewColumnDesignTimeVisibleAttributeType = typeof(DataGridViewColumnDesignTimeVisibleAttribute); + private TableLayoutPanel? _okCancelTableLayoutPanel; + private TableLayoutPanel? _checkBoxesTableLayoutPanel; + private TableLayoutPanel? _overarchingTableLayoutPanel; + + public DataGridViewAddColumnDialog(DataGridViewColumnCollection dataGridViewColumns, DataGridView liveDataGridView) + { + _dataGridViewColumns = dataGridViewColumns; + _liveDataGridView = liveDataGridView; + + // PERF: set the Dialog Font before InitializeComponent. + // + Font uiFont = Control.DefaultFont; + IUIService? uiService = _liveDataGridView.Site?.GetService(iUIServiceType) as IUIService; + if (uiService is not null) + { + uiFont = (Font)uiService.Styles["DialogFont"]!; + } + + this.Font = uiFont; + + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // put this code in the constructor because we want to keep the dataBoundColumnRadioButton.Checked state + // when the user closes and reopens the add column dialog + EnableDataBoundSection(); + } + + /// + /// consolidate all the information from the dialog into a data grid view column + /// and insert it in the data grid view column collection + /// + private void AddColumn() + { + ComboBoxItem? comboBoxItem = _columnTypesCombo?.SelectedItem as ComboBoxItem; + Type? columnType = comboBoxItem?.ColumnType; + + DataGridViewColumn? column = Activator.CreateInstance(columnType!) as DataGridViewColumn; + + // if we want to insert a column before a frozen column then make sure that we insert a frozen column + bool forceColumnFrozen = _dataGridViewColumns!.Count > _insertAtPosition && _dataGridViewColumns[_insertAtPosition].Frozen; + + column!.Frozen = forceColumnFrozen; + + // if we don't persist changes to the designer then we want to add the columns before + // setting the Frozen bit + if (!_persistChangesToDesigner) + { + // set the header text because the DataGridViewColumnCollection needs it to compute + // its listbox'x HorizontalOffset + column.HeaderText = _headerTextBox!.Text; + column.Name = _nameTextBox!.Text; + column.DisplayIndex = -1; + _dataGridViewColumns.Insert(_insertAtPosition, column); + _insertAtPosition++; + } + + // if we persist changes directly to the designer then: + // 1. set the column property values + // 2. Add the new column + // 3. site the column + + // 1. set the property values in the column + column.HeaderText = _headerTextBox!.Text; + column.Name = _nameTextBox!.Text; + column.Visible = _visibleCheckBox!.Checked; + column.Frozen = _frozenCheckBox!.Checked || forceColumnFrozen; + column.ReadOnly = _readOnlyCheckBox!.Checked; + + if (_dataBoundColumnRadioButton!.Checked && _dataColumns!.SelectedIndex > -1) + { + column.DataPropertyName = ((ListBoxItem)_dataColumns.SelectedItem!).PropertyName; + } + + if (this._persistChangesToDesigner) + { + try + { + // insert the column before siting the column. + // if DataGridView throws an exception then the designer does not end up w/ a column that is not in any data grid view. + column.DisplayIndex = -1; + _dataGridViewColumns.Insert(_insertAtPosition, column); + _insertAtPosition++; + // site the column + _liveDataGridView?.Site?.Container?.Add(column, column.Name); + } + catch (InvalidOperationException ex) + { + IUIService? uiService = _liveDataGridView?.Site?.GetService(typeof(IUIService)) as IUIService; + DataGridViewDesigner.ShowErrorDialog(uiService, ex, _liveDataGridView); + return; + } + } + + // Set the UserAddedColumn property to true. + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(column); + PropertyDescriptor? pd = props["UserAddedColumn"]; + pd?.SetValue(column, true); + + // pick a new Column name + this._nameTextBox.Text = this._headerTextBox.Text = this.AssignName(); + this._nameTextBox.Focus(); + } + + private string AssignName() + { + int colId = 1; + // string columnName = (SR.DataGridView_ColumnName, colId.ToString()); + string columnName = "Column" + colId.ToString(CultureInfo.InvariantCulture); + + IDesignerHost? host = null; + IContainer? container = null; + + host = _liveDataGridView?.Site?.GetService(iDesignerHostType) as IDesignerHost; + if (host is not null) + { + container = host.Container; + } + + while (!ValidName(columnName, + _dataGridViewColumns!, + container, + null /*nameCreationService*/, + _liveDataGridView!.Columns, + !_persistChangesToDesigner)) + { + colId++; + columnName = $"Column{colId.ToString(CultureInfo.InvariantCulture)}"; + } + + return columnName; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) => base.Dispose(disposing); + + private void EnableDataBoundSection() + { + bool dataGridViewIsDataBound = _dataColumns!.Items.Count > 0; + if (dataGridViewIsDataBound) + { + _dataBoundColumnRadioButton!.Enabled = true; + _dataBoundColumnRadioButton.Checked = true; + _dataBoundColumnRadioButton.Focus(); + _headerTextBox!.Text = _nameTextBox!.Text = AssignName(); + } + else + { + _dataBoundColumnRadioButton!.Enabled = false; + _unboundColumnRadioButton!.Checked = true; + _nameTextBox!.Focus(); + _headerTextBox!.Text = _nameTextBox.Text = AssignName(); + } + } + + /// + /// public because the EditColumns dialog wants to use it as well. + /// + /// + /// + /// + public static ComponentDesigner? GetComponentDesignerForType(ITypeResolutionService? typeResolutionService, Type type) + { + ComponentDesigner? compDesigner = null; + DesignerAttribute? designerAttribute = null; + AttributeCollection? attributes = TypeDescriptor.GetAttributes(type); + for (int i = 0; i < attributes.Count; i++) + { + DesignerAttribute? attribute = attributes[i] as DesignerAttribute; + if (attribute is not null) + { + Type? daType = Type.GetType(attribute.DesignerBaseTypeName); + if (daType is not null && daType == iDesignerType) + { + designerAttribute = attribute; + break; + } + } + } + + if (designerAttribute is not null) + { + Type? designerType = typeResolutionService is not null + ? typeResolutionService.GetType(designerAttribute.DesignerTypeName) + : Type.GetType(designerAttribute.DesignerTypeName); + + if (designerType is not null && typeof(ComponentDesigner).IsAssignableFrom(designerType)) + { + compDesigner = Activator.CreateInstance(designerType) as ComponentDesigner; + } + } + + return compDesigner; + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + ComponentResourceManager resources = new ComponentResourceManager(typeof(DataGridViewAddColumnDialog)); + _dataBoundColumnRadioButton = new RadioButton(); + _overarchingTableLayoutPanel = new TableLayoutPanel(); + _checkBoxesTableLayoutPanel = new TableLayoutPanel(); + _frozenCheckBox = new CheckBox(); + _visibleCheckBox = new CheckBox(); + _readOnlyCheckBox = new CheckBox(); + _okCancelTableLayoutPanel = new TableLayoutPanel(); + _addButton = new Button(); + _cancelButton = new Button(); + _columnInDataSourceLabel = new Label(); + _dataColumns = new ListBox(); + _unboundColumnRadioButton = new RadioButton(); + _nameLabel = new Label(); + _nameTextBox = new TextBox(); + _typeLabel = new Label(); + _columnTypesCombo = new ComboBox(); + _headerTextLabel = new Label(); + _headerTextBox = new TextBox(); + _overarchingTableLayoutPanel.SuspendLayout(); + _checkBoxesTableLayoutPanel.SuspendLayout(); + _okCancelTableLayoutPanel.SuspendLayout(); + SuspendLayout(); + // + // dataBoundColumnRadioButton + // + resources.ApplyResources(_dataBoundColumnRadioButton, "dataBoundColumnRadioButton"); + _dataBoundColumnRadioButton.Checked = true; + _overarchingTableLayoutPanel.SetColumnSpan(_dataBoundColumnRadioButton, 3); + _dataBoundColumnRadioButton.Margin = new Padding(0); + _dataBoundColumnRadioButton.Name = "dataBoundColumnRadioButton"; + _dataBoundColumnRadioButton.CheckedChanged += dataBoundColumnRadioButton_CheckedChanged; + // + // overarchingTableLayoutPanel + // + resources.ApplyResources(this._overarchingTableLayoutPanel, "overarchingTableLayoutPanel"); + _overarchingTableLayoutPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; + _overarchingTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 14F)); + _overarchingTableLayoutPanel.ColumnStyles.Add(new ColumnStyle()); + _overarchingTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 250F)); + _overarchingTableLayoutPanel.Controls.Add(_checkBoxesTableLayoutPanel, 0, 10); + _overarchingTableLayoutPanel.Controls.Add(_okCancelTableLayoutPanel, 2, 11); + _overarchingTableLayoutPanel.Controls.Add(_dataBoundColumnRadioButton, 0, 0); + _overarchingTableLayoutPanel.Controls.Add(_columnInDataSourceLabel, 1, 1); + _overarchingTableLayoutPanel.Controls.Add(_dataColumns, 1, 2); + _overarchingTableLayoutPanel.Controls.Add(_unboundColumnRadioButton, 0, 4); + _overarchingTableLayoutPanel.Controls.Add(_nameLabel, 1, 5); + _overarchingTableLayoutPanel.Controls.Add(_nameTextBox, 2, 5); + _overarchingTableLayoutPanel.Controls.Add(_typeLabel, 1, 7); + _overarchingTableLayoutPanel.Controls.Add(_columnTypesCombo, 2, 7); + _overarchingTableLayoutPanel.Controls.Add(_headerTextLabel, 1, 9); + _overarchingTableLayoutPanel.Controls.Add(_headerTextBox, 2, 9); + _overarchingTableLayoutPanel.Margin = new Padding(12, 12, 12, 13); + _overarchingTableLayoutPanel.Name = "overarchingTableLayoutPanel"; + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 22F)); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 16F)); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 91F)); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 12F)); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 22F)); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle()); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 4F)); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle()); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 4F)); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle()); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 27F)); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle()); + // + // checkBoxesTableLayoutPanel + // + resources.ApplyResources(_checkBoxesTableLayoutPanel, "checkBoxesTableLayoutPanel"); + _checkBoxesTableLayoutPanel.ColumnStyles.Add(new ColumnStyle()); + _checkBoxesTableLayoutPanel.ColumnStyles.Add(new ColumnStyle()); + _checkBoxesTableLayoutPanel.ColumnStyles.Add(new ColumnStyle()); + _checkBoxesTableLayoutPanel.Controls.Add(_frozenCheckBox, 2, 0); + _checkBoxesTableLayoutPanel.Controls.Add(_visibleCheckBox, 0, 0); + _checkBoxesTableLayoutPanel.Controls.Add(_readOnlyCheckBox, 1, 0); + _checkBoxesTableLayoutPanel.Margin = new Padding(0); + _overarchingTableLayoutPanel.SetColumnSpan(_checkBoxesTableLayoutPanel, 3); + _checkBoxesTableLayoutPanel.Name = "checkBoxesTableLayoutPanel"; + _checkBoxesTableLayoutPanel.RowStyles.Add(new RowStyle()); + // + // frozenCheckBox + // + resources.ApplyResources(_frozenCheckBox, "frozenCheckBox"); + _frozenCheckBox.Margin = new Padding(0); + _frozenCheckBox.Name = "frozenCheckBox"; + // + // visibleCheckBox + // + resources.ApplyResources(_visibleCheckBox, "visibleCheckBox"); + _visibleCheckBox.Checked = true; + _visibleCheckBox.CheckState = CheckState.Checked; + _visibleCheckBox.Margin = new Padding(0); + _visibleCheckBox.Name = "visibleCheckBox"; + // + // readOnlyCheckBox + // + resources.ApplyResources(_readOnlyCheckBox, "readOnlyCheckBox"); + _readOnlyCheckBox.Margin = new Padding(0); + _readOnlyCheckBox.Name = "readOnlyCheckBox"; + // + // okCancelTableLayoutPanel + // + resources.ApplyResources(_okCancelTableLayoutPanel, "okCancelTableLayoutPanel"); + _okCancelTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + _okCancelTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + _okCancelTableLayoutPanel.Controls.Add(_addButton, 0, 0); + _okCancelTableLayoutPanel.Controls.Add(_cancelButton, 1, 0); + _okCancelTableLayoutPanel.Margin = new Padding(0, 6, 0, 0); + _okCancelTableLayoutPanel.Name = "okCancelTableLayoutPanel"; + _okCancelTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); + // + // addButton + // + resources.ApplyResources(_addButton, "addButton"); + _addButton.Margin = new Padding(0, 0, 3, 0); + _addButton.Name = "addButton"; + _addButton.Click += addButton_Click; + // + // cancelButton + // + resources.ApplyResources(_cancelButton, "cancelButton"); + _cancelButton.Margin = new Padding(3, 0, 0, 0); + _cancelButton.Name = "cancelButton"; + _cancelButton.Click += cancelButton_Click; + // + // columnInDataSourceLabel + // + resources.ApplyResources(_columnInDataSourceLabel, "columnInDataSourceLabel"); + _overarchingTableLayoutPanel.SetColumnSpan(_columnInDataSourceLabel, 2); + _columnInDataSourceLabel.Margin = new Padding(0); + _columnInDataSourceLabel.Name = "columnInDataSourceLabel"; + // + // dataColumns + // + resources.ApplyResources(_dataColumns, "dataColumns"); + _overarchingTableLayoutPanel.SetColumnSpan(_dataColumns, 2); + _dataColumns.FormattingEnabled = true; + _dataColumns.Margin = new Padding(0); + _dataColumns.Name = "dataColumns"; + + _dataColumns.SelectedIndexChanged += dataColumns_SelectedIndexChanged; + // + // unboundColumnRadioButton + // + resources.ApplyResources(_unboundColumnRadioButton, "unboundColumnRadioButton"); + _overarchingTableLayoutPanel.SetColumnSpan(_unboundColumnRadioButton, 3); + _unboundColumnRadioButton.Margin = new Padding(0); + _unboundColumnRadioButton.Name = "unboundColumnRadioButton"; + _unboundColumnRadioButton.CheckedChanged += unboundColumnRadioButton_CheckedChanged; + // + // nameLabel + // + resources.ApplyResources(_nameLabel, "nameLabel"); + _nameLabel.Margin = new Padding(0); + _nameLabel.Name = "nameLabel"; + // + // nameTextBox + // + resources.ApplyResources(_nameTextBox, "nameTextBox"); + _nameTextBox.Margin = new Padding(0); + _nameTextBox.Name = "nameTextBox"; + _nameTextBox.Validating += nameTextBox_Validating; + // + // typeLabel + // + resources.ApplyResources(_typeLabel, "typeLabel"); + _typeLabel.Margin = new Padding(0); + _typeLabel.Name = "typeLabel"; + // + // columnTypesCombo + // + resources.ApplyResources(_columnTypesCombo, "columnTypesCombo"); + _columnTypesCombo.DropDownStyle = ComboBoxStyle.DropDownList; + _columnTypesCombo.FormattingEnabled = true; + _columnTypesCombo.Margin = new Padding(0); + _columnTypesCombo.Name = "columnTypesCombo"; + _columnTypesCombo.Sorted = true; + // + // headerTextLabel + // + resources.ApplyResources(_headerTextLabel, "headerTextLabel"); + _headerTextLabel.Margin = new Padding(0); + _headerTextLabel.Name = "headerTextLabel"; + // + // headerTextBox + // + resources.ApplyResources(_headerTextBox, "headerTextBox"); + _headerTextBox.Margin = new Padding(0); + _headerTextBox.Name = "headerTextBox"; + // + // DataGridViewAddColumnDialog + // + resources.ApplyResources(this, "$this"); + AutoScaleMode = AutoScaleMode.Font; + CancelButton = _cancelButton; + AutoSizeMode = AutoSizeMode.GrowAndShrink; + Controls.Add(_overarchingTableLayoutPanel); + FormBorderStyle = FormBorderStyle.FixedDialog; + HelpButton = true; + MaximizeBox = false; + MinimizeBox = false; + Name = "DataGridViewAddColumnDialog"; + ShowIcon = false; + ShowInTaskbar = false; + HelpButtonClicked += DataGridViewAddColumnDialog_HelpButtonClicked; + Closed += DataGridViewAddColumnDialog_Closed; + VisibleChanged += DataGridViewAddColumnDialog_VisibleChanged; + Load += DataGridViewAddColumnDialog_Load; + HelpRequested += DataGridViewAddColumnDialog_HelpRequested; + _overarchingTableLayoutPanel.ResumeLayout(false); + _overarchingTableLayoutPanel.PerformLayout(); + _checkBoxesTableLayoutPanel.ResumeLayout(false); + _checkBoxesTableLayoutPanel.PerformLayout(); + _okCancelTableLayoutPanel.ResumeLayout(false); + _okCancelTableLayoutPanel.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + #endregion + + private void dataBoundColumnRadioButton_CheckedChanged(object? sender, EventArgs e) + { + _columnInDataSourceLabel!.Enabled = _dataBoundColumnRadioButton!.Checked; + _dataColumns!.Enabled = _dataBoundColumnRadioButton.Checked; + + // push the property name into the headerTextBox and into the nameTextBox + dataColumns_SelectedIndexChanged(null, EventArgs.Empty); + } + + private void dataColumns_SelectedIndexChanged(object? sender, EventArgs e) + { + if (_dataColumns?.SelectedItem is null) + { + return; + } + + _headerTextBox!.Text = _nameTextBox!.Text = ((ListBoxItem)_dataColumns.SelectedItem).PropertyName; + + // pick a default data grid view column type + // NOTE: this will pick one of our data grid view column types + SetDefaultDataGridViewColumnType(((ListBoxItem)_dataColumns.SelectedItem).PropertyType); + } + + private void unboundColumnRadioButton_CheckedChanged(object? sender, EventArgs e) + { + if (_unboundColumnRadioButton!.Checked) + { + _nameTextBox!.Text = _headerTextBox!.Text = AssignName(); + _nameTextBox.Focus(); + } + } + + private void DataGridViewAddColumnDialog_Closed(object? sender, EventArgs e) + { + if (_persistChangesToDesigner) + { + try + { + Debug.Assert(_initialDataGridViewColumnsCount != -1, "did you forget to set the initialDataGridViewColumnsCount when you started the dialog?"); + IComponentChangeService? changeService = _liveDataGridView!.Site?.GetService(iComponentChangeServiceType) as IComponentChangeService; + if (changeService is null) + { + return; + } + + // to get good Undo/Redo we need to bring the data grid view column collection + // back to its initial state before firing the componentChanging event + DataGridViewColumn[] cols = new DataGridViewColumn[_liveDataGridView.Columns.Count - _initialDataGridViewColumnsCount]; + for (int i = _initialDataGridViewColumnsCount; i < _liveDataGridView.Columns.Count; i++) + { + cols[i - _initialDataGridViewColumnsCount] = _liveDataGridView.Columns[i]; + } + + for (int i = _initialDataGridViewColumnsCount; i < _liveDataGridView.Columns.Count;) + { + _liveDataGridView.Columns.RemoveAt(_initialDataGridViewColumnsCount); + } + + // the data grid view column collection is back to its initial state + // fire the component changing event + PropertyDescriptor? prop = TypeDescriptor.GetProperties(_liveDataGridView)["Columns"]; + changeService.OnComponentChanging(_liveDataGridView, prop); + + // add back the data grid view columns the user added using the Add Columns dialog + // But first wipe out the existing display index. + for (int i = 0; i < cols.Length; i++) + { + cols[i].DisplayIndex = -1; + } + + _liveDataGridView.Columns.AddRange(cols); + + // fire component changed event + changeService.OnComponentChanged(_liveDataGridView, prop, null, null); + } + catch (InvalidOperationException) + { + } + } +#if DEBUG + else + { + Debug.Assert(this._initialDataGridViewColumnsCount == -1, "did you forget to reset the _initialDataGridViewColumnsCount when you started the dialog?"); + } +#endif // DEBUG + + // The DialogResult is OK. + DialogResult = DialogResult.OK; + } + + private void DataGridViewAddColumnDialog_HelpButtonClicked(object? sender, CancelEventArgs e) + { + DataGridViewAddColumnDialog_HelpRequestHandled(); + e.Cancel = true; + } + + private void DataGridViewAddColumnDialog_HelpRequested(object? sender, HelpEventArgs e) + { + DataGridViewAddColumnDialog_HelpRequestHandled(); + e.Handled = true; + } + + private void DataGridViewAddColumnDialog_HelpRequestHandled() + { + IHelpService? helpService = _liveDataGridView?.Site?.GetService(iHelpServiceType) as IHelpService; + helpService?.ShowHelpFromKeyword("vs.DataGridViewAddColumnDialog"); + } + + private void DataGridViewAddColumnDialog_Load(object? sender, EventArgs e) + { + // setup Visible/ReadOnly/Frozen checkboxes + // localization will change the check boxes text length + if (_dataBoundColumnRadioButton!.Checked) + { + _headerTextBox!.Text = _nameTextBox!.Text = AssignName(); + } + else + { + Debug.Assert(_unboundColumnRadioButton!.Checked, "we only have 2 radio buttons"); + string columnName = AssignName(); + _headerTextBox!.Text = _nameTextBox!.Text = columnName; + } + + PopulateColumnTypesCombo(); + + PopulateDataColumns(); + + EnableDataBoundSection(); + + _cancelButton!.Text = SR.DataGridView_Cancel; + } + + private void DataGridViewAddColumnDialog_VisibleChanged(object? sender, EventArgs e) + { + if (Visible && IsHandleCreated) + { + // we loaded the form + if (_dataBoundColumnRadioButton!.Checked) + { + Debug.Assert(_dataColumns!.Enabled, "dataColumns list box and dataBoundColumnRadioButton should be enabled / disabled in sync"); + _dataColumns.Select(); + } + else + { + Debug.Assert(_unboundColumnRadioButton!.Checked, "We only have 2 radio buttons"); + _nameTextBox!.Select(); + } + } + } + + private void nameTextBox_Validating(object? sender, CancelEventArgs e) + { + IDesignerHost? host = null; + INameCreationService? nameCreationService = null; + IContainer? container = null; + + host = _liveDataGridView?.Site?.GetService(iDesignerHostType) as IDesignerHost; + if (host is not null) + { + container = host.Container; + } + + nameCreationService = _liveDataGridView?.Site?.GetService(iNameCreationServiceType) as INameCreationService; + + string errorString = string.Empty; + if (!ValidName(_nameTextBox!.Text, + _dataGridViewColumns!, + container, + nameCreationService, + _liveDataGridView!.Columns, + !_persistChangesToDesigner, + out errorString)) + { + IUIService? uiService = _liveDataGridView?.Site?.GetService(iUIServiceType) as IUIService; + DataGridViewDesigner.ShowErrorDialog(uiService, errorString, _liveDataGridView); + e.Cancel = true; + } + } + + private void PopulateColumnTypesCombo() + { + _columnTypesCombo!.Items.Clear(); + + IDesignerHost? host = _liveDataGridView?.Site?.GetService(iDesignerHostType) as IDesignerHost; + if (host is null) + { + return; + } + + ITypeDiscoveryService? discoveryService = host.GetService(iTypeDiscoveryServiceType) as ITypeDiscoveryService; + + if (discoveryService is null) + { + return; + } + + ICollection columnTypes = (ICollection)DesignerUtils.FilterGenericTypes(discoveryService.GetTypes(dataGridViewColumnType, false /*excludeGlobalTypes*/)); + + foreach (Type type in columnTypes) + { + if (type == dataGridViewColumnType) + { + continue; + } + + if (type.IsAbstract) + { + continue; + } + + if (!type.IsPublic && !type.IsNestedPublic) + { + continue; + } + +#pragma warning disable IL2077 // Target parameter argument does not satisfy 'DynamicallyAccessedMembersAttribute' in call to target method. The source field does not have matching annotations. + DataGridViewColumnDesignTimeVisibleAttribute? attribute = TypeDescriptor.GetAttributes(type)[dataGridViewColumnDesignTimeVisibleAttributeType] as DataGridViewColumnDesignTimeVisibleAttribute; +#pragma warning restore IL2077 // Target parameter argument does not satisfy 'DynamicallyAccessedMembersAttribute' in call to target method. The source field does not have matching annotations. + if (attribute is not null && !attribute.Visible) + { + continue; + } + + _columnTypesCombo.Items.Add(new ComboBoxItem(type)); + } + + // make the textBoxColumn type the selected type + _columnTypesCombo.SelectedIndex = TypeToSelectedIndex(typeof(DataGridViewTextBoxColumn)); + } + + private void PopulateDataColumns() + { + int selectedIndex = _dataColumns!.SelectedIndex; + + _dataColumns.SelectedIndex = -1; + _dataColumns.Items.Clear(); + + if (_liveDataGridView?.DataSource is not null) + { + CurrencyManager? currencyManager = null; + try + { + currencyManager = BindingContext?[_liveDataGridView.DataSource, _liveDataGridView.DataMember] as CurrencyManager; + } + catch (ArgumentException) + { + currencyManager = null; + } + + PropertyDescriptorCollection? propertyDescriptorCollection = currencyManager?.GetItemProperties(); + + if (propertyDescriptorCollection is not null) + { + for (int i = 0; i < propertyDescriptorCollection.Count; i++) + { + if (typeof(IList).IsAssignableFrom(propertyDescriptorCollection[i].PropertyType)) + { + // we have an IList. It could be a byte[] in which case we want to generate an Image column + TypeConverter imageTypeConverter = TypeDescriptor.GetConverter(typeof(Image)); + if (!imageTypeConverter.CanConvertFrom(propertyDescriptorCollection[i].PropertyType)) + { + continue; + } + } + + _dataColumns.Items.Add(new ListBoxItem(propertyDescriptorCollection[i].PropertyType, propertyDescriptorCollection[i].Name)); + } + } + } + + if (selectedIndex != -1 && selectedIndex < _dataColumns.Items.Count) + { + _dataColumns.SelectedIndex = selectedIndex; + } + else + { + _dataColumns.SelectedIndex = _dataColumns.Items.Count > 0 ? 0 : -1; + } + } + + private void addButton_Click(object? sender, EventArgs e) + { + _cancelButton!.Text = (SR.DataGridView_Close); + + // AddColumn takes all the information from this dialog, makes a DataGridViewColumn out of it + // and inserts it at the right index in the data grid view column collection + AddColumn(); + } + + private void cancelButton_Click(object? sender, EventArgs e) + { + Close(); + } + + protected override bool ProcessDialogKey(Keys keyData) + { + if ((keyData & Keys.Modifiers) == 0) + { + switch (keyData & Keys.KeyCode) + { + case Keys.Enter: + // Validate the name before adding the column. + IDesignerHost? host = null; + INameCreationService? nameCreationService = null; + IContainer? container = null; + + host = _liveDataGridView?.Site?.GetService(iDesignerHostType) as IDesignerHost; + if (host is not null) + { + container = host.Container; + } + + nameCreationService = _liveDataGridView?.Site?.GetService(iNameCreationServiceType) as INameCreationService; + + string errorString = string.Empty; + if (ValidName(_nameTextBox!.Text, + _dataGridViewColumns!, + container, + nameCreationService, + _liveDataGridView!.Columns, + !_persistChangesToDesigner, + out errorString)) + { + AddColumn(); + Close(); + } + else + { + IUIService? uiService = _liveDataGridView?.Site?.GetService(iUIServiceType) as IUIService; + DataGridViewDesigner.ShowErrorDialog(uiService, errorString, _liveDataGridView); + } + + return true; + } + } + + return base.ProcessDialogKey(keyData); + } + + internal void Start(int insertAtPosition, bool persistChangesToDesigner) + { + _insertAtPosition = insertAtPosition; + _persistChangesToDesigner = persistChangesToDesigner; + + if (_persistChangesToDesigner) + { + _initialDataGridViewColumnsCount = _liveDataGridView!.Columns.Count; + } + else + { + _initialDataGridViewColumnsCount = -1; + } + } + + private void SetDefaultDataGridViewColumnType(Type type) + { + TypeConverter imageTypeConverter = TypeDescriptor.GetConverter(typeof(Image)); + + if (type == typeof(bool) || type == typeof(CheckState)) + { + // get the data grid view check box column type + _columnTypesCombo!.SelectedIndex = TypeToSelectedIndex(typeof(DataGridViewCheckBoxColumn)); + } + else if (typeof(Image).IsAssignableFrom(type) || imageTypeConverter.CanConvertFrom(type)) + { + // get the data grid view image column type + _columnTypesCombo!.SelectedIndex = TypeToSelectedIndex(typeof(DataGridViewImageColumn)); + } + else + { + // get the data grid view text box column type + _columnTypesCombo!.SelectedIndex = TypeToSelectedIndex(typeof(DataGridViewTextBoxColumn)); + } + } + + private int TypeToSelectedIndex(Type type) + { + for (int i = 0; i < _columnTypesCombo!.Items.Count; i++) + { + if (type == (_columnTypesCombo!.Items![i] as ComboBoxItem)!.ColumnType) + { + return i; + } + } + + Debug.Assert(false, "we should have found a type by now"); + + return -1; + } + + public static bool ValidName(string name, + DataGridViewColumnCollection columns, + IContainer? container, + INameCreationService? nameCreationService, + DataGridViewColumnCollection liveColumns, + bool allowDuplicateNameInLiveColumnCollection) + => ValidName(name, columns, container, nameCreationService, liveColumns, allowDuplicateNameInLiveColumnCollection, out _); + + /// + /// A column name is valid if it does not cause any name conflicts in the DataGridViewColumnCollection + /// and the IContainer::Component collection. + /// + public static bool ValidName(string name, + DataGridViewColumnCollection columns, + IContainer? container, + INameCreationService? nameCreationService, + DataGridViewColumnCollection? liveColumns, + bool allowDuplicateNameInLiveColumnCollection, + out string errorString) + { + if (columns.Contains(name)) + { + errorString = string.Format(SR.DataGridViewDuplicateColumnName, name); + return false; + } + + if (container is not null && container.Components[name] is not null) + { + if (!allowDuplicateNameInLiveColumnCollection || liveColumns is null || !liveColumns.Contains(name)) + { + errorString = string.Format(SR.DesignerHostDuplicateName, name); + return false; + } + } + + if (nameCreationService is not null && !nameCreationService.IsValidName(name)) + { + if (!allowDuplicateNameInLiveColumnCollection || liveColumns is null || !liveColumns.Contains(name)) + { + errorString = string.Format(SR.CodeDomDesignerLoaderInvalidIdentifier, name); + return false; + } + } + + errorString = string.Empty; + return true; + } + + private class ListBoxItem + { + private readonly Type _propertyType; + private readonly string _propertyName; + + public ListBoxItem(Type propertyType, string propertyName) + { + _propertyType = propertyType; + _propertyName = propertyName; + } + + public Type PropertyType + { + get + { + return _propertyType; + } + } + + public string PropertyName + { + get + { + return _propertyName; + } + } + + public override string ToString() + { + return _propertyName; + } + } + + private class ComboBoxItem + { + private Type _columnType; + public ComboBoxItem(Type columnType) + { + this._columnType = columnType; + } + + public override string ToString() + { + return _columnType.Name; + } + + public Type ColumnType + { + get + { + return _columnType; + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewAddColumnDialog.resx b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewAddColumnDialog.resx new file mode 100644 index 00000000000..0b936505194 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewAddColumnDialog.resx @@ -0,0 +1,681 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + True + + + False + + + True + + + 3 + + + Right, Top, Bottom + + + True + + + 3 + + + None + + + True + + + + 132, 5 + + + 58, 17 + + + 2 + + + &Frozen + + + frozenCheckBox + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + checkBoxesTableLayoutPanel + + + 0 + + + None + + + True + + + 0, 5 + + + 56, 17 + + + 0 + + + &Visible + + + visibleCheckBox + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + checkBoxesTableLayoutPanel + + + 1 + + + None + + + True + + + 56, 5 + + + 76, 17 + + + 1 + + + &Read Only + + + readOnlyCheckBox + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + checkBoxesTableLayoutPanel + + + 2 + + + 142, 232 + + + 1 + + + 190, 27 + + + 10 + + + checkBoxesTableLayoutPanel + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 0 + + + Right + + + False + + + True + + + 2 + + + Left, Right + + + True + + + System + + + 0, 0 + + + 0 + + + &Add + + + addButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + okCancelTableLayoutPanel + + + 0 + + + Left, Right + + + False + + + System + + + True + + + 81, 0 + + + 1 + + + Cancel + + + cancelButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + okCancelTableLayoutPanel + + + 1 + + + 176, 265 + + + 1 + + + 156, 23 + + + 11 + + + okCancelTableLayoutPanel + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 1 + + + True + + + 14, 22 + + + 136, 13 + + + 1 + + + &Columns in the DataSource + + + columnInDataSourceLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 3 + + + Top, Left, Right + + + True + + + False + + + 14, 38 + + + 318, 91 + + + 2 + + + dataColumns + + + System.Windows.Forms.ListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 4 + + + True + + + 0, 141 + + + 106, 17 + + + 3 + + + &Unbound column + + + unboundColumnRadioButton + + + System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 5 + + + Left + + + True + + + 14, 166 + + + 38, 13 + + + 4 + + + &Name: + + + MiddleLeft + + + nameLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 6 + + + Left, Right + + + 82, 163 + + + 250, 20 + + + 5 + + + nameTextBox + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 7 + + + Left + + + True + + + 14, 191 + + + 34, 13 + + + 6 + + + &Type: + + + MiddleLeft + + + typeLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 8 + + + Left, Right + + + 82, 187 + + + 250, 21 + + + 7 + + + columnTypesCombo + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 9 + + + Left + + + True + + + 14, 215 + + + 65, 13 + + + 8 + + + &Header text: + + + MiddleLeft + + + headerTextLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 10 + + + Left, Right + + + 82, 212 + + + 250, 20 + + + 9 + + + headerTextBox + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 11 + + + 12, 12 + + + 12 + + + 332, 291 + + + 0 + + + overarchingTableLayoutPanel + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + 0, 0 + + + 115, 17 + + + 0 + + + Data&bound column + + + dataBoundColumnRadioButton + + + System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 2 + + + True + + + 6, 13 + + + True + + + 356, 315 + + + CenterParent + + + Add Column + + + DataGridViewAddColumnDialog + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewCellStyleBuilder.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewCellStyleBuilder.cs index eb0df70455c..8ef118d7330 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewCellStyleBuilder.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewCellStyleBuilder.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; @@ -10,7 +9,7 @@ namespace System.Windows.Forms.Design; internal class DataGridViewCellStyleBuilder : Form { /// - /// Required designer variable. + /// Required designer variable. /// private PropertyGrid _cellStyleProperties; private GroupBox _previewGroupBox; @@ -30,7 +29,7 @@ internal class DataGridViewCellStyleBuilder : Form private DataGridViewCellStyle? _cellStyle; private ITypeDescriptorContext? _context; - public DataGridViewCellStyleBuilder(IServiceProvider serviceProvider, IComponent comp) + public DataGridViewCellStyleBuilder(IServiceProvider serviceProvider, IComponent component) { // Required for Windows Form Designer support InitializeComponent(); @@ -40,7 +39,7 @@ public DataGridViewCellStyleBuilder(IServiceProvider serviceProvider, IComponent _listenerDataGridView = new DataGridView(); - _cellStyleProperties.Site = new DataGridViewComponentPropertyGridSite(serviceProvider, comp); + _cellStyleProperties.Site = new DataGridViewComponentPropertyGridSite(serviceProvider, component); } private void InitializeGrids() @@ -78,7 +77,7 @@ public DataGridViewCellStyle? CellStyle _cellStyleProperties.SelectedObject = _cellStyle; ListenerDataGridViewDefaultCellStyleChanged(null, EventArgs.Empty); _listenerDataGridView.DefaultCellStyle = _cellStyle; - _listenerDataGridView.DefaultCellStyleChanged += new EventHandler(ListenerDataGridViewDefaultCellStyleChanged); + _listenerDataGridView.DefaultCellStyleChanged += ListenerDataGridViewDefaultCellStyleChanged; } } @@ -96,7 +95,7 @@ private void ListenerDataGridViewDefaultCellStyleChanged(object? sender, EventAr #region Windows Form Designer generated code /// - /// Required method for Designer support - do not modify the contents of this method with the code editor. + /// Required method for Designer support - do not modify the contents of this method with the code editor. /// [MemberNotNull(nameof(_cellStyleProperties))] [MemberNotNull(nameof(_sampleViewTableLayoutPanel))] @@ -182,7 +181,7 @@ private void InitializeComponent() _sampleDataGridView.Name = "sampleDataGridView"; _sampleDataGridView.ReadOnly = true; _sampleDataGridView.RowHeadersVisible = false; - _sampleDataGridView.CellStateChanged += new DataGridViewCellStateChangedEventHandler(sampleDataGridView_CellStateChanged); + _sampleDataGridView.CellStateChanged += sampleDataGridView_CellStateChanged; // selectedLabel resources.ApplyResources(_selectedLabel, "selectedLabel"); _selectedLabel.Margin = new Padding(0); @@ -246,9 +245,9 @@ private void InitializeComponent() Name = "DataGridViewCellStyleBuilder"; ShowIcon = false; ShowInTaskbar = false; - HelpButtonClicked += new CancelEventHandler(DataGridViewCellStyleBuilder_HelpButtonClicked); - HelpRequested += new HelpEventHandler(DataGridViewCellStyleBuilder_HelpRequested); - Load += new EventHandler(DataGridViewCellStyleBuilder_Load); + HelpButtonClicked += DataGridViewCellStyleBuilder_HelpButtonClicked; + HelpRequested += DataGridViewCellStyleBuilder_HelpRequested; + Load += DataGridViewCellStyleBuilder_Load; _sampleViewTableLayoutPanel.ResumeLayout(false); _sampleViewTableLayoutPanel.PerformLayout(); _sampleViewGridsTableLayoutPanel.ResumeLayout(false); @@ -311,8 +310,8 @@ private void DataGridViewCellStyleBuilder_Load(object? sender, EventArgs e) _sampleDataGridViewSelected.Columns[0].Width = _sampleDataGridViewSelected.Width; // sync the Layout event for both sample DataGridView's so that when the sample DataGridView's are laid out we know to change the size of their cells - _sampleDataGridView.Layout += new LayoutEventHandler(sampleDataGridView_Layout); - _sampleDataGridViewSelected.Layout += new LayoutEventHandler(sampleDataGridView_Layout); + _sampleDataGridView.Layout += sampleDataGridView_Layout; + _sampleDataGridViewSelected.Layout += sampleDataGridView_Layout; } private void sampleDataGridView_CellStateChanged(object? sender, DataGridViewCellStateChangedEventArgs e) diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewCellStyleEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewCellStyleEditor.cs index 7b4b50cdc05..2d76fde7249 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewCellStyleEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewCellStyleEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewColumnCollectionDialog.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewColumnCollectionDialog.cs new file mode 100644 index 00000000000..9572c374eaa --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewColumnCollectionDialog.cs @@ -0,0 +1,1432 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design; + +internal class DataGridViewColumnCollectionDialog : Form +{ + private Label? _selectedColumnsLabel; + + private ListBox? _selectedColumns; + private Button? _moveUp; + private Button? _moveDown; + private Button? _deleteButton; + private Button? _addButton; + + private Label? _propertyGridLabel; + + private PropertyGrid? _propertyGrid1; + private TableLayoutPanel? _okCancelTableLayoutPanel; + + private Button? _okButton; + + private Button? _cancelButton; + + private DataGridView? _liveDataGridView; + + private IComponentChangeService? _compChangeService; + + private DataGridView _dataGridViewPrivateCopy; + private DataGridViewColumnCollection _columnsPrivateCopy; + private Hashtable? _columnsNames; + private DataGridViewAddColumnDialog? _addColumnDialog; + + private const int _OWNERDRAWHORIZONTALBUFFER = 3; + private const int _OWNERDRAWVERTICALBUFFER = 4; + private const int _OWNERDRAWITEMIMAGEBUFFER = 2; + + // static because we can only have one instance of the DataGridViewColumnCollectionDialog running at a time + private static Bitmap? _selectedColumnsItemBitmap; + private static Type _iTypeResolutionServiceType = typeof(ITypeResolutionService); + private static Type _iComponentChangeServiceType = typeof(IComponentChangeService); + private static Type _iHelpServiceType = typeof(IHelpService); + private static Type _iUIServiceType = typeof(IUIService); + private static Type _toolboxBitmapAttributeType = typeof(ToolboxBitmapAttribute); + + private bool _columnCollectionChanging; + + private bool _formIsDirty; + private TableLayoutPanel? _overarchingTableLayoutPanel; + private TableLayoutPanel? _addRemoveTableLayoutPanel; + private Hashtable? _userAddedColumns; + + private IServiceProvider _serviceProvider; + + internal DataGridViewColumnCollectionDialog(IServiceProvider provider) + { + _serviceProvider = provider; + + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + if (DpiHelper.IsScalingRequired && _moveUp is not null && _moveDown is not null) + { + _moveUp.Image = DpiHelper.ScaleButtonImageLogicalToDevice(_moveUp.Image); + _moveDown.Image = DpiHelper.ScaleButtonImageLogicalToDevice(_moveDown.Image); + } + + _dataGridViewPrivateCopy = new DataGridView(); + _columnsPrivateCopy = _dataGridViewPrivateCopy.Columns; + _columnsPrivateCopy.CollectionChanged += columnsPrivateCopy_CollectionChanged; + } + + private static Bitmap SelectedColumnsItemBitmap + { + get + { + if (_selectedColumnsItemBitmap is null) + { + _selectedColumnsItemBitmap = new Bitmap(BitmapSelector.GetResourceStream(typeof(DataGridViewColumnCollectionDialog), "DataGridViewColumnsDialog.selectedColumns.bmp")); + _selectedColumnsItemBitmap.MakeTransparent(Color.Red); + } + + return _selectedColumnsItemBitmap; + } + } + + private void columnsPrivateCopy_CollectionChanged(object? sender, CollectionChangeEventArgs e) + { + if (_columnCollectionChanging) + { + return; + } + + PopulateSelectedColumns(); + + if (e.Action == CollectionChangeAction.Add && _selectedColumns is not null) + { + _selectedColumns.SelectedIndex = _columnsPrivateCopy.IndexOf(e.Element as DataGridViewColumn); + ListBoxItem? lbi = _selectedColumns.SelectedItem as ListBoxItem; + _userAddedColumns![lbi!.DataGridViewColumn] = true; + _columnsNames![lbi.DataGridViewColumn] = lbi.DataGridViewColumn.Name; + } + + _formIsDirty = true; + } + + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + private void ColumnTypeChanged(ListBoxItem item, Type newType) + { + DataGridViewColumn currentColumn = item.DataGridViewColumn; + Debug.Assert(typeof(DataGridViewColumn).IsAssignableFrom(newType), "we should only have types that can be assigned to a DataGridViewColumn"); + Debug.Assert(_selectedColumns?.SelectedItem == item, "we must have lost track of what item is in the property grid"); + + DataGridViewColumn? newColumn = System.Activator.CreateInstance(newType) as DataGridViewColumn; + + ITypeResolutionService? tr = _liveDataGridView?.Site?.GetService(_iTypeResolutionServiceType) as ITypeResolutionService; + ComponentDesigner newColumnDesigner = DataGridViewAddColumnDialog.GetComponentDesignerForType(tr, newType)!; + + CopyDataGridViewColumnProperties(currentColumn /*srcColumn*/, newColumn! /*destColumn*/); + CopyDataGridViewColumnState(currentColumn /*srcColumn*/, newColumn! /*destColumn*/); + + _columnCollectionChanging = true; + int selectedIndex = _selectedColumns.SelectedIndex; + + // steal the focus away from the PropertyGrid + _selectedColumns.Focus(); + ActiveControl = _selectedColumns; + + try + { + // scrub the TypeDescriptor associations + ListBoxItem listBoxItem = (ListBoxItem)_selectedColumns.SelectedItem; + + bool? userAddedColumn = (bool)_userAddedColumns![listBoxItem.DataGridViewColumn]!; + + string columnSiteName = string.Empty; + if (_columnsNames!.Contains(listBoxItem.DataGridViewColumn)) + { + columnSiteName = (string)_columnsNames[listBoxItem.DataGridViewColumn]!; + _columnsNames.Remove(listBoxItem.DataGridViewColumn); + } + + if (_userAddedColumns.Contains(listBoxItem.DataGridViewColumn)) + { + _userAddedColumns.Remove(listBoxItem.DataGridViewColumn); + } + + if (listBoxItem.DataGridViewColumnDesigner is not null) + { + TypeDescriptor.RemoveAssociation(listBoxItem.DataGridViewColumn, listBoxItem.DataGridViewColumnDesigner); + } + + _selectedColumns.Items.RemoveAt(selectedIndex); + _selectedColumns.Items.Insert(selectedIndex, new ListBoxItem(newColumn!, this, newColumnDesigner)); + + _columnsPrivateCopy.RemoveAt(selectedIndex); + // wipe out the display index + newColumn!.DisplayIndex = -1; + _columnsPrivateCopy.Insert(selectedIndex, newColumn); + + if (!string.IsNullOrEmpty(columnSiteName)) + { + _columnsNames[newColumn] = columnSiteName; + } + + _userAddedColumns[newColumn] = userAddedColumn; + + // properties like DataGridViewColumn::Frozen are dependent on the DisplayIndex + FixColumnCollectionDisplayIndices(); + + _selectedColumns.SelectedIndex = selectedIndex; + _propertyGrid1!.SelectedObject = _selectedColumns.SelectedItem; + } + finally + { + _columnCollectionChanging = false; + } + } + + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + private void CommitChanges() + { + if (!_formIsDirty) + { + return; + } + + try + { + IComponentChangeService? changeService = _liveDataGridView?.Site?.GetService(_iComponentChangeServiceType) as IComponentChangeService; + PropertyDescriptor? prop = TypeDescriptor.GetProperties(_liveDataGridView!)["Columns"]; + IContainer? currentContainer = _liveDataGridView?.Site is not null ? _liveDataGridView.Site.Container : null; + + // Here is the order in which we should do the ComponentChanging/ComponentChanged + // Container.RemoveComponent, Container.AddComponent + // + // 1. OnComponentChanging DataGridView.Columns + // 2. DataGridView.Columns.Clear(); + // 3. OnComponentChanged DataGridView.Columns + // 4. IContainer.Remove(dataGridView.Columns) + // 5. IContainer.Add(new dataGridView.Columns) + // 6. OnComponentChanging DataGridView.Columns + // 7. DataGridView.Columns.Add( new DataGridViewColumns) + // 8. OnComponentChanged DataGridView.Columns + + DataGridViewColumn[] oldColumns = new DataGridViewColumn[_liveDataGridView!.Columns.Count]; + _liveDataGridView.Columns.CopyTo(oldColumns, 0); + + // 1. OnComponentChanging DataGridView.Columns + changeService?.OnComponentChanging(_liveDataGridView, prop); + + // 2. DataGridView.Columns.Clear(); + _liveDataGridView.Columns.Clear(); + + // 3. OnComponentChanged DataGridView.Columns + changeService?.OnComponentChanged(_liveDataGridView, prop, null, null); + + // 4. IContainer.Remove(dataGridView.Columns) + if (currentContainer is not null) + { + for (int i = 0; i < oldColumns.Length; i++) + { + currentContainer.Remove(oldColumns[i]); + } + } + + DataGridViewColumn[] newColumns = new DataGridViewColumn[_columnsPrivateCopy.Count]; + bool[] userAddedColumnsInfo = new bool[_columnsPrivateCopy.Count]; + string[] compNames = new string[_columnsPrivateCopy.Count]; + for (int i = 0; i < _columnsPrivateCopy!.Count; i++) + { + DataGridViewColumn newColumn = (DataGridViewColumn)_columnsPrivateCopy[i].Clone(); + // at design time we need to do a shallow copy for ContextMenuStrip property + newColumn.ContextMenuStrip = _columnsPrivateCopy[i].ContextMenuStrip; + + newColumns[i] = newColumn; + object? boolObject = _userAddedColumns![_columnsPrivateCopy[i]]; + if (boolObject is not null && boolObject is bool boolValue) + { + userAddedColumnsInfo[i] = boolValue; + } + + if (_columnsNames is not null && _columnsPrivateCopy is not null) + { +#pragma warning disable CS8601 // Possible null reference assignment. + compNames[i] = _columnsNames[_columnsPrivateCopy[i]] as string; +#pragma warning restore CS8601 // Possible null reference assignment. + } + } + + // 5. IContainer.Add(new dataGridView.Columns) + if (currentContainer is not null) + { + for (int i = 0; i < newColumns.Length; i++) + { + if (!string.IsNullOrEmpty(compNames[i]) && ValidateName(currentContainer, compNames[i], newColumns[i])) + { + currentContainer.Add(newColumns[i], compNames[i]); + } + else + { + currentContainer.Add(newColumns[i]); + } + } + } + + // 6. OnComponentChanging DataGridView.Columns + changeService?.OnComponentChanging(_liveDataGridView, prop); + + // 7. DataGridView.Columns.Add( new DataGridViewColumns) + for (int i = 0; i < newColumns.Length; i++) + { + // wipe out the DisplayIndex + PropertyDescriptor? propertyDescriptor = TypeDescriptor.GetProperties(newColumns[i])["DisplayIndex"]; + propertyDescriptor?.SetValue(newColumns[i], -1); + + _liveDataGridView.Columns.Add(newColumns[i]); + } + + // 8. OnComponentChanged DataGridView.Columns + changeService?.OnComponentChanged(_liveDataGridView, prop, null, null); + for (int i = 0; i < userAddedColumnsInfo.Length; i++) + { + PropertyDescriptor? pd = TypeDescriptor.GetProperties(newColumns[i])["UserAddedColumn"]; + pd?.SetValue(newColumns[i], userAddedColumnsInfo[i]); + } + } + catch (InvalidOperationException ex) + { + IUIService? uiService = _liveDataGridView?.Site?.GetService(typeof(IUIService)) as IUIService; + DataGridViewDesigner.ShowErrorDialog(uiService, ex, _liveDataGridView); + DialogResult = DialogResult.Cancel; + } + } + + private void componentChanged(object? sender, ComponentChangedEventArgs e) + { + if (e.Component is ListBoxItem && _selectedColumns!.Items.Contains(e.Component)) + { + _formIsDirty = true; + } + } + + private static void CopyDataGridViewColumnProperties(DataGridViewColumn srcColumn, DataGridViewColumn destColumn) + { + destColumn.AutoSizeMode = srcColumn.AutoSizeMode; + destColumn.ContextMenuStrip = srcColumn.ContextMenuStrip; + destColumn.DataPropertyName = srcColumn.DataPropertyName; + if (srcColumn.HasDefaultCellStyle) + { + CopyDefaultCellStyle(srcColumn, destColumn); + } + + destColumn.DividerWidth = srcColumn.DividerWidth; + destColumn.HeaderText = srcColumn.HeaderText; + destColumn.MinimumWidth = srcColumn.MinimumWidth; + destColumn.Name = srcColumn.Name; + destColumn.SortMode = srcColumn.SortMode; + destColumn.Tag = srcColumn.Tag; + destColumn.ToolTipText = srcColumn.ToolTipText; + destColumn.Width = srcColumn.Width; + destColumn.FillWeight = srcColumn.FillWeight; + } + + private static void CopyDataGridViewColumnState(DataGridViewColumn srcColumn, DataGridViewColumn destColumn) + { + destColumn.Frozen = srcColumn.Frozen; + destColumn.Visible = srcColumn.Visible; + destColumn.ReadOnly = srcColumn.ReadOnly; + destColumn.Resizable = srcColumn.Resizable; + } + + // We don't have any control over the srcColumn constructor. + // So we do a catch all. + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] + private static void CopyDefaultCellStyle(DataGridViewColumn srcColumn, DataGridViewColumn destColumn) + { + // Here is what we want to do ( see vsw 352177 for more details ): + // 1. If srcColumn and destColumn have the same type simply copy the default cell style from source to destination + // and be done w/ it. + // 2. Otherwise, determine which properties in the cell style are no longer default and copy those properties. + // To do that we need to: + // 2.a Create a default srcColumn so we get its default cell style. If we get an exception when we are creating the default cell style + // then we copy all the public properties. + // 2.b Go thru the public properties in the DataGridViewCellStyle and copy only the property that are changed from the default values; + // 2.c We need to special case the DataGridViewCellStyle::NullValue property. This property will be copied only if the NullValue + // has the same type in destColumn and in srcColumn. + + Type srcType = srcColumn.GetType(); + Type destType = destColumn.GetType(); + + // 1. If srcColumn and destColumn have the same type simply copy the default cell style from source to destination + // and be done w/ it. + if (srcType.IsAssignableFrom(destType) || destType.IsAssignableFrom(srcType)) + { + destColumn.DefaultCellStyle = srcColumn.DefaultCellStyle; + return; + } + + // 2.a Create a default srcColumn so we get its default cell style. If we get an exception when we are creating the default cell style + // then we copy all the public properties. + DataGridViewColumn? defaultSrcColumn = null; + try + { + defaultSrcColumn = Activator.CreateInstance(srcType) as DataGridViewColumn; + } + catch (Exception e) + { + if (ExceptionExtensions.IsCriticalException(e)) + { + throw; + } + + defaultSrcColumn = null; + } + + // 2.b Go thru the public properties in the DataGridViewCellStyle and copy only the property that are changed from the default values; + if (defaultSrcColumn is null || defaultSrcColumn.DefaultCellStyle.Alignment != srcColumn.DefaultCellStyle.Alignment) + { + destColumn.DefaultCellStyle.Alignment = srcColumn.DefaultCellStyle.Alignment; + } + + if (defaultSrcColumn is null || !defaultSrcColumn.DefaultCellStyle.BackColor.Equals(srcColumn.DefaultCellStyle.BackColor)) + { + destColumn.DefaultCellStyle.BackColor = srcColumn.DefaultCellStyle.BackColor; + } + + if (defaultSrcColumn is not null && srcColumn.DefaultCellStyle.Font is not null && !srcColumn.DefaultCellStyle.Font.Equals(defaultSrcColumn.DefaultCellStyle.Font)) + { + destColumn.DefaultCellStyle.Font = srcColumn.DefaultCellStyle.Font; + } + + if (defaultSrcColumn is null || !defaultSrcColumn.DefaultCellStyle.ForeColor.Equals(srcColumn.DefaultCellStyle.ForeColor)) + { + destColumn.DefaultCellStyle.ForeColor = srcColumn.DefaultCellStyle.ForeColor; + } + + if (defaultSrcColumn is null || !defaultSrcColumn.DefaultCellStyle.Format.Equals(srcColumn.DefaultCellStyle.Format)) + { + destColumn.DefaultCellStyle.Format = srcColumn.DefaultCellStyle.Format; + } + + if (defaultSrcColumn is null || defaultSrcColumn.DefaultCellStyle.Padding != srcColumn.DefaultCellStyle.Padding) + { + destColumn.DefaultCellStyle.Padding = srcColumn.DefaultCellStyle.Padding; + } + + if (defaultSrcColumn is null || !defaultSrcColumn.DefaultCellStyle.SelectionBackColor.Equals(srcColumn.DefaultCellStyle.SelectionBackColor)) + { + destColumn.DefaultCellStyle.SelectionBackColor = srcColumn.DefaultCellStyle.SelectionBackColor; + } + + if (defaultSrcColumn is null || !defaultSrcColumn.DefaultCellStyle.SelectionForeColor.Equals(srcColumn.DefaultCellStyle.SelectionForeColor)) + { + destColumn.DefaultCellStyle.SelectionForeColor = srcColumn.DefaultCellStyle.SelectionForeColor; + } + + if (defaultSrcColumn is null || defaultSrcColumn.DefaultCellStyle.WrapMode != srcColumn.DefaultCellStyle.WrapMode) + { + destColumn.DefaultCellStyle.WrapMode = srcColumn.DefaultCellStyle.WrapMode; + } + + // 2.c We need to special case the DataGridViewCellStyle::NullValue property. This property will be copied only if the NullValue + // has the same type in destColumn and in srcColumn. + if (!srcColumn.DefaultCellStyle.IsNullValueDefault) + { + object srcNullValue = srcColumn.DefaultCellStyle.NullValue; + object destNullValue = destColumn.DefaultCellStyle.NullValue; + + if (srcNullValue is not null && destNullValue is not null && srcNullValue.GetType() == destNullValue.GetType()) + { + destColumn.DefaultCellStyle.NullValue = srcNullValue; + } + } + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + } + + private void FixColumnCollectionDisplayIndices() + { + for (int i = 0; i < _columnsPrivateCopy.Count; i++) + { + _columnsPrivateCopy[i].DisplayIndex = i; + } + } + + private void HookComponentChangedEventHandler(IComponentChangeService componentChangeService) + { + if (componentChangeService is not null) + { + componentChangeService.ComponentChanged += componentChanged; + } + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + ComponentResourceManager resources = new ComponentResourceManager(typeof(DataGridViewColumnCollectionDialog)); + _addButton = new Button(); + _deleteButton = new Button(); + _moveDown = new Button(); + _moveUp = new Button(); + _selectedColumns = new ListBox(); + _overarchingTableLayoutPanel = new TableLayoutPanel(); + _addRemoveTableLayoutPanel = new TableLayoutPanel(); + _selectedColumnsLabel = new Label(); + _propertyGridLabel = new Label(); + _propertyGrid1 = new VsPropertyGrid(_serviceProvider); + _okCancelTableLayoutPanel = new TableLayoutPanel(); + _cancelButton = new Button(); + _okButton = new Button(); + _overarchingTableLayoutPanel.SuspendLayout(); + _addRemoveTableLayoutPanel.SuspendLayout(); + _okCancelTableLayoutPanel.SuspendLayout(); + SuspendLayout(); + // + // addButton + // + resources.ApplyResources(_addButton, "addButton"); + _addButton.Margin = new Padding(0, 0, 3, 0); + _addButton.Name = "addButton"; + _addButton.Padding = new Padding(10, 0, 10, 0); + _addButton.Click += addButton_Click; + // + // deleteButton + // + resources.ApplyResources(_deleteButton, "deleteButton"); + _deleteButton.Margin = new Padding(3, 0, 0, 0); + _deleteButton.Name = "deleteButton"; + _deleteButton.Padding = new Padding(10, 0, 10, 0); + _deleteButton.Click += deleteButton_Click; + // + // moveDown + // + resources.ApplyResources(_moveDown, "moveDown"); + _moveDown.Margin = new Padding(0, 1, 18, 0); + _moveDown.Name = "moveDown"; + _moveDown.Click += moveDown_Click; + // + // moveUp + // + resources.ApplyResources(_moveUp, "moveUp"); + _moveUp.Margin = new Padding(0, 0, 18, 1); + _moveUp.Name = "moveUp"; + _moveUp.Click += moveUp_Click; + // + // selectedColumns + // + resources.ApplyResources(_selectedColumns, "selectedColumns"); + _selectedColumns.DrawMode = DrawMode.OwnerDrawFixed; + _selectedColumns.Margin = new Padding(0, 2, 3, 3); + _selectedColumns.Name = "selectedColumns"; + _overarchingTableLayoutPanel.SetRowSpan(_selectedColumns, 2); + _selectedColumns.SelectedIndexChanged += selectedColumns_SelectedIndexChanged; + _selectedColumns.KeyPress += selectedColumns_KeyPress; + _selectedColumns.DrawItem += selectedColumns_DrawItem; + _selectedColumns.KeyUp += selectedColumns_KeyUp; + // + // overarchingTableLayoutPanel + // + resources.ApplyResources(_overarchingTableLayoutPanel, "overarchingTableLayoutPanel"); + _overarchingTableLayoutPanel.ColumnStyles.Add(new ColumnStyle()); + _overarchingTableLayoutPanel.ColumnStyles.Add(new ColumnStyle()); + _overarchingTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent)); + _overarchingTableLayoutPanel.Controls.Add(_addRemoveTableLayoutPanel, 0, 3); + _overarchingTableLayoutPanel.Controls.Add(_moveUp, 1, 1); + _overarchingTableLayoutPanel.Controls.Add(_selectedColumnsLabel, 0, 0); + _overarchingTableLayoutPanel.Controls.Add(_moveDown, 1, 2); + _overarchingTableLayoutPanel.Controls.Add(_propertyGridLabel, 2, 0); + _overarchingTableLayoutPanel.Controls.Add(_selectedColumns, 0, 1); + _overarchingTableLayoutPanel.Controls.Add(_propertyGrid1, 2, 1); + _overarchingTableLayoutPanel.Controls.Add(_okCancelTableLayoutPanel, 0, 4); + _overarchingTableLayoutPanel.Name = "overarchingTableLayoutPanel"; + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle()); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle()); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle()); + // + // addRemoveTableLayoutPanel + // + resources.ApplyResources(_addRemoveTableLayoutPanel, "addRemoveTableLayoutPanel"); + _addRemoveTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + _addRemoveTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + _addRemoveTableLayoutPanel.Controls.Add(_addButton, 0, 0); + _addRemoveTableLayoutPanel.Controls.Add(_deleteButton, 1, 0); + _addRemoveTableLayoutPanel.Margin = new Padding(0, 3, 3, 3); + _addRemoveTableLayoutPanel.Name = "addRemoveTableLayoutPanel"; + _addRemoveTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); + // + // selectedColumnsLabel + // + resources.ApplyResources(_selectedColumnsLabel, "selectedColumnsLabel"); + _selectedColumnsLabel.Margin = new Padding(0); + _selectedColumnsLabel.Name = "selectedColumnsLabel"; + // + // propertyGridLabel + // + resources.ApplyResources(_propertyGridLabel, "propertyGridLabel"); + _propertyGridLabel.Margin = new Padding(3, 0, 0, 0); + _propertyGridLabel.Name = "propertyGridLabel"; + // + // propertyGrid1 + // + resources.ApplyResources(_propertyGrid1, "propertyGrid1"); + _propertyGrid1.LineColor = SystemColors.ScrollBar; + _propertyGrid1.Margin = new Padding(3, 2, 0, 3); + _propertyGrid1.Name = "propertyGrid1"; + _overarchingTableLayoutPanel.SetRowSpan(_propertyGrid1, 3); + _propertyGrid1.PropertyValueChanged += propertyGrid1_PropertyValueChanged; + // + // okCancelTableLayoutPanel + // + resources.ApplyResources(_okCancelTableLayoutPanel, "okCancelTableLayoutPanel"); + _okCancelTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + _okCancelTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + _okCancelTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 20F)); + _okCancelTableLayoutPanel.Controls.Add(_cancelButton, 1, 0); + _okCancelTableLayoutPanel.Controls.Add(_okButton, 0, 0); + _okCancelTableLayoutPanel.Name = "okCancelTableLayoutPanel"; + _overarchingTableLayoutPanel.SetColumnSpan(_okCancelTableLayoutPanel, 3); + _okCancelTableLayoutPanel.RowStyles.Add(new RowStyle()); + // + // cancelButton + // + resources.ApplyResources(_cancelButton, "cancelButton"); + _cancelButton.DialogResult = DialogResult.Cancel; + _cancelButton.Margin = new Padding(3, 0, 0, 0); + _cancelButton.Name = "cancelButton"; + _cancelButton.Padding = new Padding(10, 0, 10, 0); + // + // okButton + // + resources.ApplyResources(_okButton, "okButton"); + _okButton.DialogResult = DialogResult.OK; + _okButton.Margin = new Padding(0, 0, 3, 0); + _okButton.Name = "okButton"; + _okButton.Padding = new Padding(10, 0, 10, 0); + _okButton.Click += okButton_Click; + // + // DataGridViewColumnCollectionDialog + // + AcceptButton = _okButton; + resources.ApplyResources(this, "$this"); + AutoScaleMode = AutoScaleMode.Font; + CancelButton = _cancelButton; + Controls.Add(_overarchingTableLayoutPanel); + HelpButton = true; + MaximizeBox = false; + MinimizeBox = false; + Name = "DataGridViewColumnCollectionDialog"; + Padding = new Padding(12); + ShowIcon = false; + ShowInTaskbar = false; + HelpButtonClicked += DataGridViewColumnCollectionDialog_HelpButtonClicked; + Closed += DataGridViewColumnCollectionDialog_Closed; + Load += DataGridViewColumnCollectionDialog_Load; + HelpRequested += DataGridViewColumnCollectionDialog_HelpRequested; + _overarchingTableLayoutPanel.ResumeLayout(false); + _overarchingTableLayoutPanel.PerformLayout(); + _addRemoveTableLayoutPanel.ResumeLayout(false); + _addRemoveTableLayoutPanel.PerformLayout(); + _okCancelTableLayoutPanel.ResumeLayout(false); + _okCancelTableLayoutPanel.PerformLayout(); + ResumeLayout(false); + } + #endregion + + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + private static bool IsColumnAddedByUser(DataGridViewColumn col) + { + PropertyDescriptor? propertyDescriptor = TypeDescriptor.GetProperties(col)["UserAddedColumn"]; + object? val = propertyDescriptor?.GetValue(col); + if (propertyDescriptor is not null && val is not null) + { + return (bool)val; + } + else + { + return false; + } + } + + private void okButton_Click(object? sender, EventArgs e) + { + CommitChanges(); + } + + private void moveDown_Click(object? sender, EventArgs e) + { + int selectedIndex = _selectedColumns!.SelectedIndex; + Debug.Assert(selectedIndex > -1 && selectedIndex < _selectedColumns.Items.Count - 1); + + _columnCollectionChanging = true; + try + { + ListBoxItem? item = _selectedColumns.SelectedItem as ListBoxItem; + _selectedColumns.Items.RemoveAt(selectedIndex); + _selectedColumns.Items.Insert(selectedIndex + 1, item!); + + // now do the same thing to the column collection + _columnsPrivateCopy.RemoveAt(selectedIndex); + + // if the column we moved was frozen, make sure the column below is frozen too + if (item!.DataGridViewColumn.Frozen) + { + _columnsPrivateCopy[selectedIndex].Frozen = true; +#if DEBUG + // sanity check + for (int i = 0; i < selectedIndex; i++) + { + Debug.Assert(_columnsPrivateCopy[i].Frozen, "MOVE_DOWN : all the columns up to the one we moved should be frozen"); + } +#endif // DEBUG + } + + // wipe out the DisplayIndex + item.DataGridViewColumn.DisplayIndex = -1; + _columnsPrivateCopy.Insert(selectedIndex + 1, item.DataGridViewColumn); + + // properties like DataGridViewColumn::Frozen are dependent on the DisplayIndex + FixColumnCollectionDisplayIndices(); + } + finally + { + _columnCollectionChanging = false; + } + + _formIsDirty = true; + _selectedColumns.SelectedIndex = selectedIndex + 1; + _moveUp!.Enabled = _selectedColumns.SelectedIndex > 0; + _moveDown!.Enabled = _selectedColumns.SelectedIndex < _selectedColumns.Items.Count - 1; + } + + private void moveUp_Click(object? sender, EventArgs e) + { + int selectedIndex = _selectedColumns!.SelectedIndex; + Debug.Assert(selectedIndex > 0); + + _columnCollectionChanging = true; + try + { + ListBoxItem item = (ListBoxItem)_selectedColumns.Items[selectedIndex - 1]; + _selectedColumns.Items.RemoveAt(selectedIndex - 1); + _selectedColumns.Items.Insert(selectedIndex, item); + + // now do the same thing to the column collection + _columnsPrivateCopy.RemoveAt(selectedIndex - 1); + + // we want to keep the Frozen value of the column we move intact + // if we move up an UnFrozen column and the column above the one we move is Frozen + // then we need to make the column above the one we move UnFrozen, too + // + // columnsPrivateCopy[selectedIndex - 1] points to the column we just moved + // + if (item.DataGridViewColumn.Frozen && !_columnsPrivateCopy[selectedIndex - 1].Frozen) + { + item.DataGridViewColumn.Frozen = false; + } + + // wipe out the display index. + item.DataGridViewColumn.DisplayIndex = -1; + _columnsPrivateCopy.Insert(selectedIndex, item.DataGridViewColumn); + + // properties like DataGridViewColumn::Frozen are dependent on the DisplayIndex + FixColumnCollectionDisplayIndices(); + } + finally + { + _columnCollectionChanging = false; + } + + _formIsDirty = true; + _selectedColumns.SelectedIndex = selectedIndex - 1; + _moveUp!.Enabled = _selectedColumns.SelectedIndex > 0; + _moveDown!.Enabled = _selectedColumns.SelectedIndex < _selectedColumns.Items.Count - 1; + + // vsw 495403: keep the selected item visible. + // For some reason, we only have to do this when we move a column up. + // When we move a column down or when we delete a column, the selected item remains visible. + if (_selectedColumns.SelectedIndex != -1 && _selectedColumns.TopIndex > _selectedColumns.SelectedIndex) + { + _selectedColumns.TopIndex = _selectedColumns.SelectedIndex; + } + } + + private void DataGridViewColumnCollectionDialog_Closed(object? sender, System.EventArgs e) + { + // scrub the TypeDescriptor association between DataGridViewColumns and their designers + for (int i = 0; i < _selectedColumns!.Items.Count; i++) + { + ListBoxItem? lbi = _selectedColumns.Items[i] as ListBoxItem; + if (lbi?.DataGridViewColumnDesigner is not null) + { + TypeDescriptor.RemoveAssociation(lbi.DataGridViewColumn, lbi.DataGridViewColumnDesigner); + } + } + + _columnsNames = null; + _userAddedColumns = null; + } + + private void DataGridViewColumnCollectionDialog_HelpButtonClicked(object? sender, CancelEventArgs e) + { + e.Cancel = true; + DataGridViewColumnCollectionDialog_HelpRequestHandled(); + } + + private void DataGridViewColumnCollectionDialog_HelpRequested(object? sender, HelpEventArgs e) + { + DataGridViewColumnCollectionDialog_HelpRequestHandled(); + e.Handled = true; + } + + private void DataGridViewColumnCollectionDialog_HelpRequestHandled() + { + IHelpService? helpService = _liveDataGridView?.Site?.GetService(_iHelpServiceType) as IHelpService; + helpService?.ShowHelpFromKeyword("vs.DataGridViewColumnCollectionDialog"); + } + + private void DataGridViewColumnCollectionDialog_Load(object? sender, EventArgs e) + { + // get the Dialog Font + // + Font uiFont = Control.DefaultFont; + IUIService? uiService = _liveDataGridView?.Site?.GetService(_iUIServiceType) as IUIService; + object? font = uiService?.Styles["DialogFont"]; + if (uiService is not null && font is Font fontValue) + { + uiFont = fontValue; + } + + Font = uiFont; + + // keep the selected index to 0 or -1 if there are no selected columns + _selectedColumns!.SelectedIndex = Math.Min(0, _selectedColumns.Items.Count - 1); + + _moveUp!.Enabled = _selectedColumns.SelectedIndex > 0; + _moveDown!.Enabled = _selectedColumns.SelectedIndex < _selectedColumns.Items.Count - 1; + _deleteButton!.Enabled = _selectedColumns.Items.Count > 0 && _selectedColumns.SelectedIndex != -1; + _propertyGrid1!.SelectedObject = _selectedColumns.SelectedItem; + + _selectedColumns.ItemHeight = Font.Height + _OWNERDRAWVERTICALBUFFER; + + ActiveControl = _selectedColumns; + + SetSelectedColumnsHorizontalExtent(); + + _selectedColumns.Focus(); + + _formIsDirty = false; + } + + private void deleteButton_Click(object? sender, EventArgs e) + { + Debug.Assert(_selectedColumns!.SelectedIndex != -1); + int selectedIndex = _selectedColumns.SelectedIndex; + + _columnsNames?.Remove(_columnsPrivateCopy[selectedIndex]); + _userAddedColumns?.Remove(_columnsPrivateCopy[selectedIndex]); + + _columnsPrivateCopy.RemoveAt(selectedIndex); + + // try to keep the same selected index + _selectedColumns.SelectedIndex = Math.Min(_selectedColumns.Items.Count - 1, selectedIndex); + + _moveUp!.Enabled = _selectedColumns.SelectedIndex > 0; + _moveDown!.Enabled = _selectedColumns.SelectedIndex < _selectedColumns.Items.Count - 1; + _deleteButton!.Enabled = _selectedColumns.Items.Count > 0 && _selectedColumns.SelectedIndex != -1; + _propertyGrid1!.SelectedObject = _selectedColumns.SelectedItem; + } + + private void addButton_Click(object? sender, EventArgs e) + { + int insertIndex = _selectedColumns!.SelectedIndex == -1 ? _selectedColumns.Items.Count : _selectedColumns.SelectedIndex + 1; + + if (_addColumnDialog is null) + { + // child modal dialog -launching in System Aware mode + _addColumnDialog = DpiHelper.CreateInstanceInSystemAwareContext(() => new DataGridViewAddColumnDialog(_columnsPrivateCopy, _liveDataGridView!)); + _addColumnDialog.StartPosition = FormStartPosition.CenterParent; + } + + _addColumnDialog.Start(insertIndex, false /*persistChangesToDesigner*/); + + _addColumnDialog.ShowDialog(this); + } + + private void PopulateSelectedColumns() + { + int selectedIndex = _selectedColumns!.SelectedIndex; + + // scrub the TypeDescriptor association between DataGridViewColumns and their designers + for (int i = 0; i < _selectedColumns?.Items.Count; i++) + { + ListBoxItem? lbi = _selectedColumns?.Items[i] as ListBoxItem; + if (lbi?.DataGridViewColumnDesigner is not null) + { + TypeDescriptor.RemoveAssociation(lbi.DataGridViewColumn, lbi.DataGridViewColumnDesigner); + } + } + + _selectedColumns?.Items.Clear(); + ITypeResolutionService? tr = _liveDataGridView?.Site?.GetService(_iTypeResolutionServiceType) as ITypeResolutionService; + + for (int i = 0; i < _columnsPrivateCopy.Count; i++) + { + ComponentDesigner columnDesigner = DataGridViewAddColumnDialog.GetComponentDesignerForType(tr, _columnsPrivateCopy[i].GetType())!; + _selectedColumns?.Items.Add(new ListBoxItem(_columnsPrivateCopy[i], this, columnDesigner)); + } + + _selectedColumns!.SelectedIndex = Math.Min(selectedIndex, _selectedColumns.Items.Count - 1); + + SetSelectedColumnsHorizontalExtent(); + + if (_selectedColumns.Items.Count == 0) + { + _propertyGridLabel!.Text = string.Format(SR.DataGridViewProperties); + } + } + + private void propertyGrid1_PropertyValueChanged(object? sender, PropertyValueChangedEventArgs e) + { + if (_columnCollectionChanging) + { + return; + } + + _formIsDirty = true; + // refresh the selected columns when the user changed the HeaderText property + if (e.ChangedItem!.PropertyDescriptor!.Name.Equals("HeaderText")) + { + // invalidate the selected index only + int selectedIndex = _selectedColumns!.SelectedIndex; + Debug.Assert(selectedIndex != -1, "we forgot to take away the selected object from the property grid"); + Rectangle bounds = new Rectangle(0, selectedIndex * _selectedColumns.ItemHeight, _selectedColumns.Width, _selectedColumns.ItemHeight); + _columnCollectionChanging = true; + try + { + // for accessibility reasons, we need to reset the item in the selected columns collection. + _selectedColumns.Items[selectedIndex] = _selectedColumns.Items[selectedIndex]; + } + finally + { + _columnCollectionChanging = false; + } + + _selectedColumns.Invalidate(bounds); + + // if the header text changed make sure that we update the selected columns HorizontalExtent + SetSelectedColumnsHorizontalExtent(); + } + else if (e.ChangedItem.PropertyDescriptor.Name.Equals("DataPropertyName")) + { + ListBoxItem? listBoxItem = _selectedColumns?.SelectedItem as ListBoxItem; + DataGridViewColumn? column = listBoxItem?.DataGridViewColumn; + + if (string.IsNullOrEmpty(column?.DataPropertyName)) + { + _propertyGridLabel!.Text = (SR.DataGridViewUnboundColumnProperties); + } + else + { + _propertyGridLabel!.Text = (SR.DataGridViewBoundColumnProperties); + } + } + else if (e.ChangedItem.PropertyDescriptor.Name.Equals("Name")) + { + ListBoxItem? listBoxItem = _selectedColumns?.SelectedItem as ListBoxItem; + DataGridViewColumn? col = listBoxItem?.DataGridViewColumn; + if (_columnsNames is not null && col is not null) + { + _columnsNames[col] = col.Name; + } + } + } + + private void selectedColumns_DrawItem(object? sender, DrawItemEventArgs e) + { + if (e.Index < 0) + { + return; + } + + ListBoxItem? listBoxItem = _selectedColumns?.Items[e.Index] as ListBoxItem; + +#if DGV_DITHERING + if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) + { + ImageAttributes attributes = new ImageAttributes(); + + colorMap[0].OldColor = Color.White; + colorMap[0].NewColor = e.BackColor; + + // + // TO DO : DITHER + // + attributes.SetRemapTable(colorMap, ColorAdjustType.Bitmap); + + Rectangle imgRectangle = new Rectangle(e.Bounds.X + OWNERDRAWITEMIMAGEBUFFER, e.Bounds.Y + OWNERDRAWITEMIMAGEBUFFER, listBoxItem.ToolboxBitmap.Width, listBoxItem.ToolboxBitmap.Height); + e.Graphics.DrawImage(listBoxItem.ToolboxBitmap, + imgRectangle, + 0, + 0, + imgRectangle.Width, + imgRectangle.Height, + GraphicsUnit.Pixel, + attributes); + attributes.Dispose(); + } + else + { +#endif // DGV_DITHERING + e.Graphics.DrawImage(listBoxItem!.ToolboxBitmap!, + e.Bounds.X + _OWNERDRAWITEMIMAGEBUFFER, + e.Bounds.Y + _OWNERDRAWITEMIMAGEBUFFER, + listBoxItem!.ToolboxBitmap!.Width, + listBoxItem.ToolboxBitmap.Height); + + Rectangle bounds = e.Bounds; + bounds.Width -= listBoxItem.ToolboxBitmap.Width + 2 * _OWNERDRAWITEMIMAGEBUFFER; + bounds.X += listBoxItem.ToolboxBitmap.Width + 2 * _OWNERDRAWITEMIMAGEBUFFER; + bounds.Y += _OWNERDRAWITEMIMAGEBUFFER; + bounds.Height -= 2 * _OWNERDRAWITEMIMAGEBUFFER; + + Brush selectedBrush = new SolidBrush(e.BackColor); + Brush foreBrush = new SolidBrush(e.ForeColor); + Brush backBrush = new SolidBrush(_selectedColumns!.BackColor); + + string columnName = ((ListBoxItem)_selectedColumns.Items[e.Index]).ToString(); + + if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) + { + // first get the text rectangle + int textWidth = Size.Ceiling(e.Graphics.MeasureString(columnName, e.Font!, new SizeF(bounds.Width, bounds.Height))).Width; + // DANIELHE: the spec calls for + 7 but I think that + 3 does the trick better + Rectangle focusRectangle = new Rectangle(bounds.X, e.Bounds.Y + 1, textWidth + _OWNERDRAWHORIZONTALBUFFER, e.Bounds.Height - 2); + + e.Graphics.FillRectangle(selectedBrush, focusRectangle); + focusRectangle.Inflate(-1, -1); + + e.Graphics.DrawString(columnName, e.Font!, foreBrush, focusRectangle); + + focusRectangle.Inflate(1, 1); + + // only paint the focus rectangle when the list box is focused + if (_selectedColumns.Focused) + { + ControlPaint.DrawFocusRectangle(e.Graphics, focusRectangle, e.ForeColor, e.BackColor); + } + + e.Graphics.FillRectangle(backBrush, new Rectangle(focusRectangle.Right + 1, e.Bounds.Y, e.Bounds.Width - focusRectangle.Right - 1, e.Bounds.Height)); + } + else + { + e.Graphics.FillRectangle(backBrush, new Rectangle(bounds.X, e.Bounds.Y, e.Bounds.Width - bounds.X, e.Bounds.Height)); + + e.Graphics.DrawString(columnName, e.Font!, foreBrush, bounds); + } + + selectedBrush.Dispose(); + backBrush.Dispose(); + foreBrush.Dispose(); + } + + private void selectedColumns_KeyUp(object? sender, KeyEventArgs e) + { + if ((e.Modifiers) == 0 && e.KeyCode == Keys.F4) + { + _propertyGrid1?.Focus(); + e.Handled = true; + } + } + + private void selectedColumns_KeyPress(object? sender, KeyPressEventArgs e) + { + Keys modifierKeys = Control.ModifierKeys; + + // vsw 479960. + // Don't let Ctrl-* propagate to the selected columns list box. + if ((modifierKeys & Keys.Control) != 0) + { + e.Handled = true; + } + } + + private void selectedColumns_SelectedIndexChanged(object? sender, EventArgs e) + { + if (_columnCollectionChanging) + { + return; + } + + _propertyGrid1!.SelectedObject = _selectedColumns!.SelectedItem; + + // enable/disable up/down/delete buttons + _moveDown!.Enabled = _selectedColumns.Items.Count > 0 && _selectedColumns.SelectedIndex != _selectedColumns.Items.Count - 1; + _moveUp!.Enabled = _selectedColumns.Items.Count > 0 && _selectedColumns.SelectedIndex > 0; + _deleteButton!.Enabled = _selectedColumns.Items.Count > 0 && _selectedColumns.SelectedIndex != -1; + + if (_selectedColumns.SelectedItem is not null) + { + DataGridViewColumn column = ((ListBoxItem)_selectedColumns.SelectedItem).DataGridViewColumn; + if (string.IsNullOrEmpty(column.DataPropertyName)) + { + _propertyGridLabel!.Text = (SR.DataGridViewUnboundColumnProperties); + } + else + { + _propertyGridLabel!.Text = (SR.DataGridViewBoundColumnProperties); + } + } + else + { + _propertyGridLabel!.Text = (SR.DataGridViewProperties); + } + } + + internal void SetLiveDataGridView(DataGridView dataGridView) + { + IComponentChangeService? newComponentChangeService = null; + if (dataGridView.Site is not null) + { + newComponentChangeService = dataGridView.Site.GetService(_iComponentChangeServiceType) as IComponentChangeService; + } + + if (newComponentChangeService != _compChangeService) + { + UnhookComponentChangedEventHandler(_compChangeService!); + + _compChangeService = newComponentChangeService; + + HookComponentChangedEventHandler(_compChangeService!); + } + + _liveDataGridView = dataGridView; + + _dataGridViewPrivateCopy.Site = dataGridView.Site; + _dataGridViewPrivateCopy.AutoSizeColumnsMode = dataGridView.AutoSizeColumnsMode; + _dataGridViewPrivateCopy.DataSource = dataGridView.DataSource; + _dataGridViewPrivateCopy.DataMember = dataGridView.DataMember; + _columnsNames = new Hashtable(_columnsPrivateCopy.Count); + _columnsPrivateCopy.Clear(); + + _userAddedColumns = new Hashtable(_liveDataGridView.Columns.Count); + + // Set ColumnCollectionChanging to true so: + // 1. the column collection changed event handler does not execute PopulateSelectedColumns over and over again. + // 2. the collection changed event handler does not add each live column to its userAddedColumns hash table. + // + _columnCollectionChanging = true; + try + { + for (int i = 0; i < _liveDataGridView.Columns.Count; i++) + { + DataGridViewColumn liveCol = _liveDataGridView.Columns[i]; + DataGridViewColumn col = (DataGridViewColumn)liveCol.Clone(); + // at design time we need to do a shallow copy for the ContextMenuStrip property + // + col.ContextMenuStrip = _liveDataGridView.Columns[i].ContextMenuStrip; + // wipe out the display index before adding the new column. + col.DisplayIndex = -1; + _columnsPrivateCopy.Add(col); + + if (liveCol.Site is not null) + { + _columnsNames[col] = liveCol.Site.Name; + } + + _userAddedColumns[col] = IsColumnAddedByUser(_liveDataGridView.Columns[i]); + } + } + finally + { + _columnCollectionChanging = false; + } + + PopulateSelectedColumns(); + + _propertyGrid1!.Site = new DataGridViewComponentPropertyGridSite(_liveDataGridView.Site, _liveDataGridView); + + _propertyGrid1.SelectedObject = _selectedColumns!.SelectedItem; + } + + private void SetSelectedColumnsHorizontalExtent() + { + int maxItemWidth = 0; + for (int i = 0; i < _selectedColumns!.Items.Count; i++) + { + int itemWidth = TextRenderer.MeasureText(_selectedColumns.Items[i].ToString(), _selectedColumns.Font).Width; + maxItemWidth = Math.Max(maxItemWidth, itemWidth); + } + + _selectedColumns.HorizontalExtent = SelectedColumnsItemBitmap.Width + 2 * _OWNERDRAWITEMIMAGEBUFFER + maxItemWidth + _OWNERDRAWHORIZONTALBUFFER; + } + + private void UnhookComponentChangedEventHandler(IComponentChangeService componentChangeService) + { + if (componentChangeService is not null) + { + componentChangeService.ComponentChanged -= new ComponentChangedEventHandler(componentChanged); + } + } + + private static bool ValidateName(IContainer container, string siteName, IComponent component) + { + ComponentCollection components = container.Components; + if (components is null) + { + return true; + } + + for (int i = 0; i < components.Count; i++) + { + IComponent? comp = components[i]; + if (comp is null || comp.Site is null) + { + continue; + } + + ISite s = comp.Site; + + if (s is not null && s.Name is not null && string.Equals(s.Name, siteName, StringComparison.OrdinalIgnoreCase) && s.Component != component) + { + return false; + } + } + + return true; + } + + /// + /// internal because the DataGridViewColumnDataPropertyNameEditor needs to get at the ListBoxItem + /// IComponent because some editors for some dataGridViewColumn properties - DataGridViewComboBox::DataSource editor - + /// need the site + /// + internal class ListBoxItem : ICustomTypeDescriptor, IComponent + { + public DataGridViewColumn DataGridViewColumn { get; } + public DataGridViewColumnCollectionDialog Owner { get; } + public ComponentDesigner? DataGridViewColumnDesigner { get; } + public Image? ToolboxBitmap { get; } + + public ListBoxItem(DataGridViewColumn column, DataGridViewColumnCollectionDialog owner, ComponentDesigner compDesigner) + { + DataGridViewColumn = column; + Owner = owner; + DataGridViewColumnDesigner = compDesigner; + + if (DataGridViewColumnDesigner is not null) + { + DataGridViewColumnDesigner.Initialize(column); + TypeDescriptor.CreateAssociation(DataGridViewColumn, DataGridViewColumnDesigner); + } + +#pragma warning disable IL2077 // Target parameter argument does not satisfy 'DynamicallyAccessedMembersAttribute' in call to target method. The source field does not have matching annotations. + ToolboxBitmapAttribute? attr = TypeDescriptor.GetAttributes(column!)[_toolboxBitmapAttributeType!] as ToolboxBitmapAttribute; +#pragma warning restore IL2077 // Target parameter argument does not satisfy 'DynamicallyAccessedMembersAttribute' in call to target method. The source field does not have matching annotations. + if (attr is not null) + { + ToolboxBitmap = attr.GetImage(column, false /*large*/); + } + else + { + ToolboxBitmap = SelectedColumnsItemBitmap; + } + + DataGridViewColumnDesigner? dataGridViewColumnDesigner = compDesigner as DataGridViewColumnDesigner; + if (dataGridViewColumnDesigner is not null && Owner._liveDataGridView is not null) + { + dataGridViewColumnDesigner.LiveDataGridView = Owner._liveDataGridView; + } + } + + public override string ToString() + { + return DataGridViewColumn.HeaderText; + } + + // ICustomTypeDescriptor implementation + AttributeCollection ICustomTypeDescriptor.GetAttributes() => TypeDescriptor.GetAttributes(DataGridViewColumn); + + string? ICustomTypeDescriptor.GetClassName() => TypeDescriptor.GetClassName(DataGridViewColumn); + + string? ICustomTypeDescriptor.GetComponentName() => TypeDescriptor.GetComponentName(DataGridViewColumn); + + TypeConverter ICustomTypeDescriptor.GetConverter() => TypeDescriptor.GetConverter(DataGridViewColumn); + + EventDescriptor? ICustomTypeDescriptor.GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(DataGridViewColumn); + + PropertyDescriptor? ICustomTypeDescriptor.GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(DataGridViewColumn); + + object? ICustomTypeDescriptor.GetEditor(Type type) => TypeDescriptor.GetEditor(DataGridViewColumn, type); + + EventDescriptorCollection ICustomTypeDescriptor.GetEvents() => TypeDescriptor.GetEvents(DataGridViewColumn); + + EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[]? attrs) => TypeDescriptor.GetEvents(DataGridViewColumn, attrs!); + + PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() => ((ICustomTypeDescriptor)this).GetProperties(null); + + PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[]? attrs) + { + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(DataGridViewColumn); + + PropertyDescriptor[]? propArray = null; + if (DataGridViewColumnDesigner is not null) + { + // PropertyDescriptorCollection does not let us change properties. + // So we have to create a hash table that we pass to PreFilterProperties + // and then copy back the result from PreFilterProperties + + // We should look into speeding this up w/ our own DataGridViewColumnTypes... + // + Hashtable hash = new Hashtable(); + for (int i = 0; i < props.Count; i++) + { + hash.Add(props[i].Name, props[i]); + } + + ((IDesignerFilter)DataGridViewColumnDesigner).PreFilterProperties(hash); + + // PreFilterProperties can add / remove properties. + // Use the hashtable's Count, not the old property descriptor collection's count. + propArray = new PropertyDescriptor[hash.Count + 1]; + hash.Values.CopyTo(propArray, 0); + } + else + { + propArray = new PropertyDescriptor[props.Count + 1]; + props.CopyTo(propArray, 0); + } + + propArray[propArray.Length - 1] = new ColumnTypePropertyDescriptor(); + + return new PropertyDescriptorCollection(propArray); + } + + object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor? pd) + { + if (pd is null) + { + return DataGridViewColumn; + } + else if (pd is ColumnTypePropertyDescriptor) + { + return this; + } + else + { + return DataGridViewColumn; + } + } + + ISite? IComponent.Site + { + get => Owner._liveDataGridView?.Site; + + set { } + } + + event EventHandler? IComponent.Disposed + { + add { } + remove { } + } + + [ + SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed") // The ListBoxItem does not own the ToolBoxBitmap + // so it can't dispose it. + ] + void IDisposable.Dispose() + { + } + } + + private class ColumnTypePropertyDescriptor : PropertyDescriptor + { + public ColumnTypePropertyDescriptor() : base("ColumnType", null) + { + } + + public override AttributeCollection Attributes + { + get + { + EditorAttribute editorAttr = new EditorAttribute("Design.DataGridViewColumnTypeEditor, " + AssemblyRef.SystemDesign, typeof(System.Drawing.Design.UITypeEditor)); + DescriptionAttribute descriptionAttr = new DescriptionAttribute(SR.DataGridViewColumnTypePropertyDescription); + CategoryAttribute categoryAttr = CategoryAttribute.Design; + // add the description attribute and the categories attribute + Attribute[] attrs = new Attribute[] { editorAttr, descriptionAttr, categoryAttr }; + return new AttributeCollection(attrs); + } + } + + public override Type ComponentType + { + get + { + return typeof(ListBoxItem); + } + } + + public override bool IsReadOnly + { + get + { + return false; + } + } + + public override Type PropertyType + { + get + { + return typeof(Type); + } + } + + public override bool CanResetValue(object component) + { + Debug.Assert(component is ListBoxItem, "this property descriptor only relates to the data grid view column class"); + return false; + } + + public override object? GetValue(object? component) + { + if (component is null) + { + return null; + } + + ListBoxItem item = (ListBoxItem)component; + return item.DataGridViewColumn.GetType().Name; + } + + public override void ResetValue(object component) + { + } + + public override void SetValue(object? component, object? value) + { + ListBoxItem? item = component as ListBoxItem; + Type? type = value as Type; + if (item?.DataGridViewColumn.GetType() != type) + { + item?.Owner.ColumnTypeChanged(item, type!); + OnValueChanged(component, EventArgs.Empty); + } + } + + public override bool ShouldSerializeValue(object component) + { + return false; + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewColumnCollectionDialog.resx b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewColumnCollectionDialog.resx new file mode 100644 index 00000000000..44eb2cd15b2 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewColumnCollectionDialog.resx @@ -0,0 +1,565 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + Left, Right + + + + True + + + + 3, 3 + + + 72, 23 + + + 0 + + + &Add... + + + addButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + addRemoveTableLayoutPanel + + + 0 + + + Left, Right + + + True + + + 81, 3 + + + 72, 23 + + + 1 + + + &Remove + + + deleteButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + addRemoveTableLayoutPanel + + + 1 + + + Move column down + + + Top + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAElJREFUOE9jYBje + 4MCBA/9hmGSfgjQCNcExlE+8OUPUAHRnI4cB0eFByBCiAhOXIURphsUTxbEAMghmCEk2o6cUijQTn+wo + UAkAY/VsRlvaylwAAAAASUVORK5CYII= + + + + 165, 45 + + + 3, 3, 23, 3 + + + 26, 23 + + + 4 + + + moveDown + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 0 + + + Move column up + + + None + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAEdJREFUOE9jYBj0 + 4MCBA//JdiRU83+yDIFpBtoOcgFphqBrJskQXJqJMoSQZqIMgYU4RWEAMmQYGADzBsgrZCUkspMv3TUC + AGYzbEaI9u+YAAAAAElFTkSuQmCC + + + + 165, 16 + + + 3, 3, 23, 3 + + + 26, 23 + + + 3 + + + moveUp + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 7 + + + Top, Bottom, Left, Right + + + 3 + + + 2 + + + Fill + + + Fill + + + 3, 194 + + + 1 + + + 156, 29 + + + 2 + + + addRemoveTableLayoutPanel + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 1 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="addButton" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="deleteButton" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="Percent,50,Percent,50" /><Rows Styles="Percent,50" /></TableLayoutSettings> + + + Bottom, Right + + + True + + + 2 + + + 0, 0, 0, 0 + + + Left, Right + + + True + + + 84, 3 + + + 75, 23 + + + 1 + + + Cancel + + + cancelButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + okCancelTableLayoutPanel + + + 0 + + + Left, Right + + + True + + + 3, 3 + + + 75, 23 + + + 0 + + + OK + + + okButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + okCancelTableLayoutPanel + + + 1 + + + 314, 229 + + + 1 + + + 162, 29 + + + 5 + + + okCancelTableLayoutPanel + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 2 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="cancelButton" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="okButton" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,50,Percent,50" /><Rows Styles="Percent,50" /></TableLayoutSettings> + + + Left + + + True + + + 3, 0 + + + 95, 13 + + + 0 + + + Selected &Columns: + + + selectedColumnsLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 3 + + + Left + + + True + + + 217, 0 + + + 54, 13 + + + 3 + + + &Properties + + + propertyGridLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 4 + + + Top, Bottom, Left, Right + + + True + + + False + + + 3, 16 + + + 156, 172 + + + 1 + + + selectedColumns + + + System.Windows.Forms.ListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 5 + + + Top, Bottom, Left, Right + + + 217, 16 + + + 241, 207 + + + 4 + + + propertyGrid1 + + + System.Windows.Forms.PropertyGrid, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 6 + + + 12, 12 + + + 5 + + + 479, 261 + + + 0 + + + overarchingTableLayoutPanel + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="moveDown" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="addRemoveTableLayoutPanel" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="okCancelTableLayoutPanel" Row="4" RowSpan="1" Column="0" ColumnSpan="3" /><Control Name="selectedColumnsLabel" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="propertyGridLabel" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="selectedColumns" Row="1" RowSpan="2" Column="0" ColumnSpan="1" /><Control Name="propertyGrid1" Row="1" RowSpan="3" Column="2" ColumnSpan="1" /><Control Name="moveUp" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0,AutoSize,0,Absolute,20" /><Rows Styles="AutoSize,0,AutoSize,0,Percent,100,AutoSize,0,AutoSize,0" /></TableLayoutSettings> + + + True + + + 6, 13 + + + 503, 308 + + + 480, 330 + + + CenterParent + + + Edit Columns + + + DataGridViewColumnCollectionDialog + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewColumnDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewColumnDesigner.cs new file mode 100644 index 00000000000..584ccc20c82 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewColumnDesigner.cs @@ -0,0 +1,357 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections; +using System.ComponentModel.Design.Serialization; +using System.ComponentModel.Design; +using System.ComponentModel; +using System.Windows.Forms.Design.Behavior; + +namespace System.Windows.Forms.Design; +internal class DataGridViewColumnDesigner : ComponentDesigner +{ + private const int DATAGRIDVIEWCOLUMN_defaultWidth = 100; + private bool _userAddedColumn; + private bool _initializing; + private BehaviorService? _behaviorService; + private ISelectionService? _selectionService; + private FilterCutCopyPasteDeleteBehavior? _behavior; + private bool _behaviorPushed; + private DataGridView? _liveDataGridView; + + private string? Name + { + get + { + DataGridViewColumn col = (DataGridViewColumn)Component; + if (col.Site is not null) + { + return col.Site.Name; + } + else + { + return col.Name; + } + } + + set + { + value ??= string.Empty; + + DataGridViewColumn? col = (DataGridViewColumn)Component; + + if (col is null) + { + return; + } + + // Note: case sensitive because lookup inside DataGridViewColumnCollection is case sensitive. + if (string.Compare(value, col.Name, false, Globalization.CultureInfo.InvariantCulture) == 0) + { + return; + } + + DataGridView? dataGridView = col?.DataGridView; + + IDesignerHost? host = null; + IContainer? container = null; + INameCreationService? nameCreationService = null; + + if (dataGridView is not null && dataGridView.Site is not null) + { + host = dataGridView.Site.GetService(typeof(IDesignerHost)) as IDesignerHost; + nameCreationService = dataGridView.Site.GetService(typeof(INameCreationService)) as INameCreationService; + } + + if (host is not null) + { + container = host.Container; + } + + // ValidName() checks any name conflicts on the DGV's column collection as well as any name conflicts + // on the Container::Components collection. + string errorString = string.Empty; + if (dataGridView is not null && + !DataGridViewAddColumnDialog.ValidName(value, + dataGridView.Columns, + container, + nameCreationService, + _liveDataGridView?.Columns, + true, + out errorString)) + { + if (dataGridView is not null && dataGridView.Site is not null) + { + IUIService? uiService = dataGridView.Site.GetService(typeof(IUIService)) as IUIService; + DataGridViewDesigner.ShowErrorDialog(uiService, errorString, _liveDataGridView); + } + + return; + } + + // we are good. + // Set the site name if the column is sited. + // Then set the column name. + if ((host is null || (host is not null && !host.Loading)) && Component.Site is not null) + { + Component.Site.Name = value; + } + + col!.Name = value; + } + } + + public DataGridView LiveDataGridView + { + set + { + _liveDataGridView = value; + } + } + + /// + /// vsw 311922. + /// We want to add a design time only property which tracks if the user added this column or not. + /// Because this is a design time only property, it will be saved to *resx file. + /// Hence, its value will be saved from session to session. + /// + /// The property is set in ONLY one place and is used in ONLY one place. + /// + /// This property is set ONLY the user adds a column via the data grid view add column dialog. + /// If columns are added as a result of binding the data grid view to a data source or as a result + /// of meta data changes then they are not considered to be added by user. + /// + /// This property is used ONLY by the data grid view designer when it has to decide whether or not to remove + /// a data bound property. + /// + private bool UserAddedColumn + { + get + { + return _userAddedColumn; + } + set + { + _userAddedColumn = value; + } + } + + private int Width + { + get + { + DataGridViewColumn col = (DataGridViewColumn)Component; + return col.Width; + } + set + { + DataGridViewColumn col = (DataGridViewColumn)Component; + value = Math.Max(col.MinimumWidth, value); + col.Width = value; + } + } + + public override void Initialize(IComponent component) + { + _initializing = true; + base.Initialize(component); + + if (component.Site is not null) + { + // Acquire a reference to ISelectionService. + _selectionService = + GetService(typeof(ISelectionService)) + as ISelectionService; + Debug.Assert(_selectionService is not null); + + // Acquire a reference to BehaviorService. + _behaviorService = GetService(typeof(BehaviorService)) as BehaviorService; + + if (_behaviorService is not null && _selectionService is not null) + { + _behavior = new FilterCutCopyPasteDeleteBehavior(true, _behaviorService); + + UpdateBehavior(); + _selectionService.SelectionChanged += selectionService_SelectionChanged; + } + } + + _initializing = false; + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + PopBehavior(); + if (_selectionService is not null) + { + _selectionService.SelectionChanged -= selectionService_SelectionChanged; + } + + _selectionService = null; + _behaviorService = null; + } + } + + private void PushBehavior() + { + if (!_behaviorPushed) + { + Debug.Assert(_behavior is not null); + try + { + _behaviorService?.PushBehavior(_behavior); + } + finally + { + _behaviorPushed = true; + } + } + } + + private void PopBehavior() + { + if (_behaviorPushed) + { + Debug.Assert(_behavior is not null); + try + { + _behaviorService?.PopBehavior(_behavior); + } + finally + { + _behaviorPushed = false; + } + } + } + + private void UpdateBehavior() + { + if (_selectionService is not null) + { + if (_selectionService.PrimarySelection is not null + && Component.Equals(_selectionService.PrimarySelection)) + { + PushBehavior(); + } + else + { + //ensure we are popped off + PopBehavior(); + } + } + } + + private void selectionService_SelectionChanged(object? sender, EventArgs e) + { + UpdateBehavior(); + } + + protected override void PreFilterProperties(IDictionary properties) + { + base.PreFilterProperties(properties); + + PropertyDescriptor? prop = properties["Width"] as PropertyDescriptor; + if (prop is not null) + { + properties["Width"] = TypeDescriptor.CreateProperty(typeof(DataGridViewColumnDesigner), prop, Array.Empty()); + } + + prop = properties["Name"] as PropertyDescriptor; + if (prop is not null) + { + if (Component.Site is null) + { + // When the Site is not null the Extender provider will add the (Name) property. + // However, when columns are on the data grid view column collection editor, the site is null. + // In that case we have to make the (Name) property browsable true. + properties["Name"] = TypeDescriptor.CreateProperty(typeof(DataGridViewColumnDesigner), + prop, + BrowsableAttribute.Yes, + CategoryAttribute.Design, + new DescriptionAttribute(SR.DesignerPropName), + new ParenthesizePropertyNameAttribute(true)); + } + else + { + // When the column is sited use DataGridViewColumnDesigner::Name property + // so it can use the Name validation logic specific to DataGridViewColumnCollection. + properties["Name"] = TypeDescriptor.CreateProperty(typeof(DataGridViewColumnDesigner), + prop, + new ParenthesizePropertyNameAttribute(true)); + } + } + + // Add the UserAddedColumn design time only property. + properties["UserAddedColumn"] = TypeDescriptor.CreateProperty(typeof(DataGridViewColumnDesigner), "UserAddedColumn", typeof(bool), + new DefaultValueAttribute(false), + BrowsableAttribute.No, + DesignOnlyAttribute.Yes); + } + + private bool ShouldSerializeWidth() + { + DataGridViewColumn col = (DataGridViewColumn)Component; + return col.InheritedAutoSizeMode != DataGridViewAutoSizeColumnMode.Fill && col.Width != DATAGRIDVIEWCOLUMN_defaultWidth; + } + + private bool ShouldSerializeName() + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host is null) + { + // The column is hosted in the column collection dialog. + // Return false : let the user type whatever he feels like. + return false; + } + + return _initializing ? (Component != host.RootComponent) //for non root components, respect the name that the base Control serialized unless changed + : ShadowProperties.ShouldSerializeValue(nameof(Name), null); + } + + public class FilterCutCopyPasteDeleteBehavior : Behavior.Behavior + { + public FilterCutCopyPasteDeleteBehavior(bool callParentBehavior, BehaviorService behaviorService) : base(callParentBehavior, behaviorService) { } + + public override MenuCommand? FindCommand(CommandID commandId) + { + MenuCommand command; + if ((commandId.ID == StandardCommands.Copy.ID) && (commandId.Guid == StandardCommands.Copy.Guid)) + { + command = new MenuCommand(handler, StandardCommands.Copy); + command.Enabled = false; + + return command; + } + + if ((commandId.ID == StandardCommands.Paste.ID) && (commandId.Guid == StandardCommands.Paste.Guid)) + { + command = new MenuCommand(handler, StandardCommands.Paste); + command.Enabled = false; + + return command; + } + + if ((commandId.ID == StandardCommands.Delete.ID) && (commandId.Guid == StandardCommands.Delete.Guid)) + { + command = new MenuCommand(handler, StandardCommands.Delete); + command.Enabled = false; + + return command; + } + + if ((commandId.ID == StandardCommands.Cut.ID) && (commandId.Guid == StandardCommands.Cut.Guid)) + { + command = new MenuCommand(handler, StandardCommands.Cut); + command.Enabled = false; + + return command; + } + + return base.FindCommand(commandId); + } + + private void handler(object? sender, EventArgs e) { } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewComponentPropertyGridSite.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewComponentPropertyGridSite.cs index 61af9fafe9b..f1985b48170 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewComponentPropertyGridSite.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewComponentPropertyGridSite.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewDesigner.cs new file mode 100644 index 00000000000..85502a49dc4 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewDesigner.cs @@ -0,0 +1,1204 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.Collections; +using System.ComponentModel.Design; +using System.Drawing; +using System.Drawing.Design; + +namespace System.Windows.Forms.Design; + +internal class DataGridViewDesigner : ControlDesigner +{ + protected DesignerVerbCollection? designerVerbs; + + // CHROME stuff + // + // DesignerActionLists + private DesignerActionListCollection? _actionLists; + + // need this to trap meta data changes + private CurrencyManager? _currencyManager; + + // cache this type cause we will use it a lot + private static Type typeofIList = typeof(IList); + private static Type typeofDataGridViewImageColumn = typeof(DataGridViewImageColumn); + private static Type typeofDataGridViewTextBoxColumn = typeof(DataGridViewTextBoxColumn); + private static Type typeofDataGridViewCheckBoxColumn = typeof(DataGridViewCheckBoxColumn); + + public DataGridViewDesigner() + { + AutoResizeHandles = true; + } + + // need AssociatedComponents for Copy / Paste + public override ICollection AssociatedComponents + { + get + { + DataGridView? dataGridView = Component as DataGridView; + if (dataGridView is not null) + { + return dataGridView.Columns; + } + + return base.AssociatedComponents; + } + } + + public DataGridViewAutoSizeColumnsMode AutoSizeColumnsMode + { + get + { + DataGridView? dataGridView = Component as DataGridView; + Debug.Assert(dataGridView is not null, "Unexpected null dataGridView in DataGridViewDesigner:get_AutoSizeColumnsMode"); + return dataGridView.AutoSizeColumnsMode; + } + set + { + // DANIELHE: this is a workaround for a bug in ComponentCache: if a component changed then its list of AssociatedComponents + // is not marked as changed to the serialization engine will not serialize them. + DataGridView? dataGridView = Component as DataGridView; + Debug.Assert(dataGridView is not null, "Unexpected null dataGridView in DataGridViewDesigner:set_AutoSizeColumnsMode"); + IComponentChangeService? componentChangeService = Component.Site?.GetService(typeof(IComponentChangeService)) as IComponentChangeService; + PropertyDescriptor? prop = TypeDescriptor.GetProperties(typeof(DataGridViewColumn))["Width"]; + + for (int i = 0; i < dataGridView.Columns.Count; i++) + { + componentChangeService?.OnComponentChanging(dataGridView.Columns[i], prop); + } + + dataGridView.AutoSizeColumnsMode = value; + + for (int i = 0; i < dataGridView.Columns.Count; i++) + { + componentChangeService?.OnComponentChanged(dataGridView.Columns[i], prop, null, null); + } + } + } + + public object DataSource + { + get + { + return ((DataGridView)Component).DataSource; + } + set + { + DataGridView? dataGridView = Component as DataGridView; + if (dataGridView is not null && dataGridView.AutoGenerateColumns && dataGridView.DataSource is null && value is not null) + { + // RefreshColumnCollection() method does the job of siting/unsiting DataGridViewColumns + // and calls OnComponentChanged/ing at the right times. + // So we need to create / remove columns from the DataGridView DataSource via RefreshColumnCollection() method. + // Set AutoGenerateColumn to false before setting the DataSource, otherwise DataGridViewColumns will be created + // via the runtime method. + // + // We set AutoGenerateColumns to FALSE only if the DataGridView will get a not-null DataSource. + dataGridView.AutoGenerateColumns = false; + } + + ((DataGridView)Component).DataSource = value; + } + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + // we still need the current Component + // so execute this code before base.Dispose(...) + Debug.Assert(Component is not null, "how did this get set to null?"); + DataGridView? dataGridView = Component as DataGridView; + + // unhook our event handlers + if (dataGridView is not null) + { + dataGridView.DataSourceChanged -= dataGridViewChanged; + dataGridView.DataMemberChanged -= dataGridViewChanged; + dataGridView.BindingContextChanged -= dataGridViewChanged; + dataGridView.ColumnRemoved -= dataGridView_ColumnRemoved; + } + + // unhook MetaDataChanged handler from the currency manager + if (_currencyManager is not null) + { + _currencyManager.MetaDataChanged -= dataGridViewMetaDataChanged; + } + + _currencyManager = null; + + // unhook the ComponentRemoved event handler + if (Component.Site is not null) + { + IComponentChangeService? ccs = Component.Site.GetService(typeof(IComponentChangeService)) as IComponentChangeService; + if (ccs is not null) + { + ccs.ComponentRemoving -= DataGridViewDesigner_ComponentRemoving; + } + } + } + + base.Dispose(disposing); + } + + public override void Initialize(IComponent component) + { + base.Initialize(component); + + if (component.Site is not null) + { + IComponentChangeService? componentChangeService = component.Site.GetService(typeof(IComponentChangeService)) as IComponentChangeService; + if (componentChangeService is not null) + { + componentChangeService.ComponentRemoving += DataGridViewDesigner_ComponentRemoving; + } + } + + DataGridView dataGridView = (DataGridView)component; + + // DataGridViewDesigner::Initialize runs after InitializeComponent was deserialized. + // just in case the user tinkered w/ InitializeComponent set AutoGenerateColumns to TRUE if there is no DataSource, otherwise set it to FALSE + dataGridView.AutoGenerateColumns = dataGridView.DataSource is null; + + // hook up the DataSourceChanged event, DataMemberChanged event + dataGridView.DataSourceChanged += dataGridViewChanged; + dataGridView.DataMemberChanged += dataGridViewChanged; + dataGridView.BindingContextChanged += dataGridViewChanged; + + // now add data bound columns + dataGridViewChanged(Component, EventArgs.Empty); + + // Attach to column removed for clean up + dataGridView.ColumnRemoved += dataGridView_ColumnRemoved; + } + + public override void InitializeNewComponent(IDictionary defaultValues) + { + base.InitializeNewComponent(defaultValues); + ((DataGridView)Component).ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + } + + /// + /// + /// Gets the inheritance attribute for the data grid view. + /// + /// + protected override InheritanceAttribute InheritanceAttribute + { + get + { + if ((base.InheritanceAttribute == InheritanceAttribute.Inherited) + || (base.InheritanceAttribute == InheritanceAttribute.InheritedReadOnly)) + { + return InheritanceAttribute.InheritedReadOnly; + } + + return base.InheritanceAttribute; + } + } + + public override DesignerVerbCollection Verbs + { + get + { + if (designerVerbs is null) + { + designerVerbs = new DesignerVerbCollection(); + designerVerbs.Add(new DesignerVerb(SR.DataGridViewEditColumnsVerb, OnEditColumns)); + designerVerbs.Add(new DesignerVerb(SR.DataGridViewAddColumnVerb, OnAddColumn)); + } + + return designerVerbs; + } + } + + public override DesignerActionListCollection ActionLists + { + get + { + if (_actionLists is null) + { + BuildActionLists(); + } + + return _actionLists!; + } + } + + private void BuildActionLists() + { + _actionLists = new DesignerActionListCollection(); + + // ChooseDataSource action list + _actionLists.Add(new DataGridViewChooseDataSourceActionList(this)); + + // column collection editing + _actionLists.Add(new DataGridViewColumnEditingActionList(this)); + + // AllowUserToAddRows / ReadOnly / AllowUserToDeleteRows / AllowUserToOrderColumns + _actionLists.Add(new DataGridViewPropertiesActionList(this)); + + // if one actionList has AutoShow == true then the chrome panel will popup when the user DnD the DataGridView onto the form + // It would make sense to promote AutoShow to DesignerActionListCollection. + // But we don't own the DesignerActionListCollection so we just set AutoShow on the first ActionList + // + _actionLists[0]!.AutoShow = true; + } + + private void dataGridViewChanged(object? sender, EventArgs e) + { + DataGridView dataGridView = (DataGridView)Component; + + CurrencyManager? newCM = null; + if (dataGridView.DataSource is not null && dataGridView.BindingContext is not null) + { + newCM = (CurrencyManager)dataGridView.BindingContext[dataGridView.DataSource, dataGridView.DataMember]; + } + + if (newCM != _currencyManager) + { + // unwire cm + if (_currencyManager is not null) + { + _currencyManager.MetaDataChanged -= dataGridViewMetaDataChanged; + } + + _currencyManager = newCM; + + // wire cm + if (_currencyManager is not null) + { + _currencyManager.MetaDataChanged += dataGridViewMetaDataChanged; + } + } + + if (dataGridView.BindingContext is null) + { + MakeSureColumnsAreSited(dataGridView); + return; + } + + // the user changed the DataSource from null to something else + // Because AutoGenerateColumns is already set to true, all the bound columns are created + // Just set AutoGenerateColumns to false and return + if (dataGridView.AutoGenerateColumns && dataGridView.DataSource is not null) + { + Debug.Assert(string.IsNullOrEmpty(dataGridView.DataMember), "in the designer we can't set DataSource and DataMember at the same time. Did you forget to set AutoGenerateColumns to false at a previous stage?"); + dataGridView.AutoGenerateColumns = false; + MakeSureColumnsAreSited(dataGridView); + return; + } + + if (dataGridView.DataSource is null) + { + if (dataGridView.AutoGenerateColumns) + { + // the BindingContext changed; + // nothing to do + MakeSureColumnsAreSited(dataGridView); + return; + } + else + { + // DataSource changed from something to null + // set AutoGenerateColumns to true and remove the columns marked as DataBound + dataGridView.AutoGenerateColumns = true; + } + } + else + { + // we have a data source. + // set AutoGenerateColumns to false and party on the new DS/DM + dataGridView.AutoGenerateColumns = false; + } + + RefreshColumnCollection(); + } + + private void DataGridViewDesigner_ComponentRemoving(object? sender, ComponentEventArgs e) + { + DataGridView? dataGridView = Component as DataGridView; + + if (e.Component is not null && dataGridView is not null && e.Component == dataGridView.DataSource) + { + // + // The current data source was removed from the designer + // Set DataSource to null. + // This will: + // 1. clear DataGridView::DataSource. + // 2. clear DataGridView::DataMember. + // 3. delete the unbound data grid view columns from the DataGridView column collection. + // 4. set AutoGenerateColumns to TRUE. + // + + IComponentChangeService componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + string previousDataMember = dataGridView.DataMember; + + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(dataGridView); + PropertyDescriptor? propertyDescriptor = props is not null ? props?["DataMember"] : null; + + if (componentChangeService is not null) + { + if (propertyDescriptor is not null) + { + componentChangeService.OnComponentChanging(dataGridView, propertyDescriptor); + } + } + + dataGridView.DataSource = null; + + if (componentChangeService is not null) + { + if (propertyDescriptor is not null) + { + componentChangeService.OnComponentChanged(dataGridView, propertyDescriptor, previousDataMember, ""); + } + } + } + } + + private void dataGridView_ColumnRemoved(object? sender, DataGridViewColumnEventArgs e) + { + // Clear out the DisplayIndex for columns removed at design time. + // If we don't do this, the columns will be reordered after build when there are both databound + // columns and non databound columns. See VSWhidbey 572859. Ideally, we would do this on the Clear + // of the column collection but there is no event there and we are restricted from adding any + // Note: this does not break Undo/Redo because Undo/Redo uses serialization the same way + // the build does and DisplayIndex is not serialized + if (e.Column is not null && e.Column.IsDataBound == false) + e.Column.DisplayIndex = -1; + } + + private static void MakeSureColumnsAreSited(DataGridView dataGridView) + { + // Other designers ( VS Data ) may manipulate the column collection but not add the columns to the + // current container. + // So we have to make sure that the data grid view columns are sited on the current container. + IContainer? currentContainer = dataGridView.Site?.Container; + for (int i = 0; i < dataGridView.Columns.Count; i++) + { + DataGridViewColumn col = dataGridView.Columns[i]; + IContainer? container = col.Site?.Container; + if (currentContainer != container) + { + container?.Remove(col); + + currentContainer?.Add(col); + } + } + } + + protected override void PreFilterProperties(IDictionary properties) + { + base.PreFilterProperties(properties); + + PropertyDescriptor? prop; + + // Handle shadowed properties + // + string[] shadowProps = new string[] + { + "AutoSizeColumnsMode", + "DataSource" + }; + + Attribute[] empty = Array.Empty(); + + for (int i = 0; i < shadowProps.Length; i++) + { + prop = properties[shadowProps[i]] as PropertyDescriptor; + if (prop is not null) + { + properties[shadowProps[i]] = TypeDescriptor.CreateProperty(typeof(DataGridViewDesigner), prop, empty); + } + } + } + + /// + /// If the previous schema and the current schema have common columns then ProcessSimilarSchema does the + /// work of removing columns which are not common and returns TRUE. + /// Otherwise ProcessSimilarSchema returns FALSE. + /// + private bool ProcessSimilarSchema(DataGridView dataGridView) + { + Debug.Assert(dataGridView.DataSource is null || _currencyManager is not null, "if we have a data source we should also have a currency manager by now"); + PropertyDescriptorCollection? backEndProps = null; + + if (_currencyManager is not null) + { + try + { + backEndProps = _currencyManager.GetItemProperties(); + } + catch (ArgumentException ex) + { + throw new InvalidOperationException(SR.DataGridViewDataSourceNoLongerValid, ex); + } + } + + IContainer? currentContainer = dataGridView.Site?.Container; + + bool similarSchema = false; + + for (int i = 0; i < dataGridView.Columns.Count; i++) + { + DataGridViewColumn dataGridViewColumn = dataGridView.Columns[i]; + + if (string.IsNullOrEmpty(dataGridViewColumn.DataPropertyName)) + { + continue; + } + + PropertyDescriptor? pd = TypeDescriptor.GetProperties(dataGridViewColumn)["UserAddedColumn"]; + object? UserAddedColumn = pd?.GetValue(dataGridViewColumn); + if (pd is not null && UserAddedColumn is not null && (bool)UserAddedColumn) + { + continue; + } + + PropertyDescriptor? dataFieldProperty = backEndProps?[dataGridViewColumn.DataPropertyName]; + // remove the column if the DataGridViewColumn::DataPropertyName does not map to any column anymore + // or if the DataGridViewColumn::DataPropertyName maps to a sub list + bool removeColumn = false; + + if (dataFieldProperty is null) + { + // DataPropertyName does not map to a column anymore + removeColumn = true; + } + else if (typeofIList.IsAssignableFrom(dataFieldProperty.PropertyType)) + { + // DataPropertyName may map to an Image column. + // Check for that using the Image TypeConverter + TypeConverter imageTypeConverter = TypeDescriptor.GetConverter(typeof(Image)); + if (!imageTypeConverter.CanConvertFrom(dataFieldProperty.PropertyType)) + { + // DataPropertyName points to a sub list. + removeColumn = true; + } + } + + similarSchema = !removeColumn; + if (similarSchema) + { + break; + } + } + + if (similarSchema) + { + ISite? site = Component?.Site; + IComponentChangeService? changeService = site?.GetService(typeof(IComponentChangeService)) as IComponentChangeService; + PropertyDescriptor? columnsProp = Component is null ? null : TypeDescriptor.GetProperties(Component)["Columns"]; + try + { + changeService?.OnComponentChanging(Component!, columnsProp); + } + catch (InvalidOperationException) + { + return similarSchema; + } + + for (int i = 0; i < dataGridView.Columns.Count;) + { + DataGridViewColumn dataGridViewColumn = dataGridView.Columns[i]; + + if (string.IsNullOrEmpty(dataGridViewColumn.DataPropertyName)) + { + i++; + continue; + } + + PropertyDescriptor? pd = TypeDescriptor.GetProperties(dataGridViewColumn)["UserAddedColumn"]; + object? UserAddedColumn = pd?.GetValue(dataGridViewColumn); + if (pd is not null && UserAddedColumn is not null && (bool)UserAddedColumn) + { + i++; + continue; + } + + PropertyDescriptor? dataFieldProperty = backEndProps?[dataGridViewColumn.DataPropertyName]; + // remove the column if the DataGridViewColumn::DataPropertyName does not map to any column anymore + // or if the DataGridViewColumn::DataPropertyName maps to a sub list + bool removeColumn = false; + + if (dataFieldProperty is null) + { + // DataPropertyName does not map to a column anymore + removeColumn = true; + } + else if (typeofIList.IsAssignableFrom(dataFieldProperty.PropertyType)) + { + // DataPropertyName may map to an Image column. + // Check for that using the Image TypeConverter + TypeConverter imageTypeConverter = TypeDescriptor.GetConverter(typeof(Image)); + if (!imageTypeConverter.CanConvertFrom(dataFieldProperty.PropertyType)) + { + // DataPropertyName points to a sub list. + removeColumn = true; + } + } + + if (removeColumn) + { + dataGridView.Columns.Remove(dataGridViewColumn); + currentContainer?.Remove(dataGridViewColumn); + } + else + { + i++; + } + } + + if (Component is not null) + { + changeService?.OnComponentChanged(Component, columnsProp, null, null); + } + } + + return similarSchema; + } + + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + private void RefreshColumnCollection() + { + DataGridView? dataGridView = (DataGridView)Component; + + ISupportInitializeNotification? dataSource = dataGridView?.DataSource as ISupportInitializeNotification; + if (dataSource is not null && !dataSource.IsInitialized) + { + // The DataSource is not initialized yet. + // When the dataSource gets initialized it will send a MetaDataChanged event and at + // that point we will refresh the column collection. + return; + } + + IComponentChangeService? changeService = null; + PropertyDescriptor? columnsProp = null; + ISite? site = Component.Site; + IDesignerHost? host = site?.GetService(typeof(IDesignerHost)) as IDesignerHost; + + // if after changing the data source / data member the dataGridView has columns which are still databound + // then keep them and don't change the column collection. + // we do this because bound columns represent the dataSource schema + // ALSO, we get Undo/Redo for free w/ this. + // + // For example: our data grid view is bound to a dataManager which in turns is bound to a web service + // which returns different dataSets w/ the same schema. + // If the user wants to see only the first 2 columns and makes some changes to the first two columns ( width, cell style, etc ) + // then we don't want to throw these columns away when the dataManager receives another dataSet from the web service. + // and we don't want to add another columns + + if (dataGridView is not null && ProcessSimilarSchema(dataGridView)) + { + return; + } + + // Here is the sequence of actions to guarantee a good Undo/Redo: + // + // 1. OnComponentChanging DataGridView.Columns + // 2. Remove the columns which should be removed + // 3. OnComponentChanged DataGridView.Columns + // 4. IContainer.Remove(dataGridView.Columns) + // 5. IContainer.Add(new dataGridView.Columns) + // 6. OnComponentChanging DataGridView.Columns + // 7. DataGridView.Columns.Add( new DataGridViewColumns) + // 8. OnComponentChanged DataGridView.Columns + + Debug.Assert(dataGridView?.DataSource is null || _currencyManager is not null, "if we have a data source we should also have a currency manager by now"); + PropertyDescriptorCollection? backEndProps = null; + + if (_currencyManager is not null) + { + try + { + backEndProps = _currencyManager.GetItemProperties(); + } + catch (ArgumentException ex) + { + throw new InvalidOperationException(SR.DataGridViewDataSourceNoLongerValid, ex); + } + } + + IContainer? currentContainer = dataGridView?.Site is not null ? dataGridView.Site.Container : null; + changeService = Component?.Site?.GetService(typeof(IComponentChangeService)) as IComponentChangeService; + columnsProp = TypeDescriptor.GetProperties(Component!)["Columns"]; + + // 1. OnComponentChanging DataGridView.Columns + changeService?.OnComponentChanging(Component!, columnsProp); + + DataGridViewColumn[] removeColumns = new DataGridViewColumn[dataGridView!.Columns.Count]; + int removeColumnsCount = 0; + for (int i = 0; i < dataGridView.Columns.Count; i++) + { + DataGridViewColumn col = dataGridView.Columns[i]; + if (!string.IsNullOrEmpty(col.DataPropertyName)) + { + PropertyDescriptor? propertyDescriptor = TypeDescriptor.GetProperties(col)["UserAddedColumn"]; + object? UserAddedColumn = propertyDescriptor?.GetValue(col); + if (propertyDescriptor is null || UserAddedColumn is null || !(bool)UserAddedColumn) + { + removeColumns[removeColumnsCount] = col; + removeColumnsCount++; + } + } + } + + // 2. Remove the columns which should be removed + for (int i = 0; i < removeColumnsCount; i++) + { + dataGridView.Columns.Remove(removeColumns[i]); + } + + // 3. OnComponentChanged DataGridView.Columns + changeService?.OnComponentChanged(Component!, columnsProp, null, null); + + // 4. IContainer.Remove(dataGridView.Columns) + if (currentContainer is not null) + { + for (int i = 0; i < removeColumnsCount; i++) + { + currentContainer.Remove(removeColumns[i]); + } + } + + DataGridViewColumn[]? columnsToBeAdded = null; + int columnsToBeAddedCount = 0; + if (dataGridView.DataSource is not null) + { + columnsToBeAdded = new DataGridViewColumn[backEndProps!.Count]; + columnsToBeAddedCount = 0; + for (int i = 0; i < backEndProps.Count; i++) + { + DataGridViewColumn? dataGridViewColumn = null; + + TypeConverter imageTypeConverter = TypeDescriptor.GetConverter(typeof(System.Drawing.Image)); + + Type propType = backEndProps[i].PropertyType; + + Type columnType; + + if (typeof(IList).IsAssignableFrom(propType)) + { + if (imageTypeConverter.CanConvertFrom(propType)) + { + columnType = typeofDataGridViewImageColumn; + } + else + { + continue; + } + } + else if (propType == typeof(bool) || propType == typeof(CheckState)) + { + columnType = typeofDataGridViewCheckBoxColumn; + } + else if (typeof(Image).IsAssignableFrom(propType) || imageTypeConverter.CanConvertFrom(propType)) + { + columnType = typeofDataGridViewImageColumn; + } + else + { + columnType = typeofDataGridViewTextBoxColumn; + } + + string nameFromText = ToolStripDesigner.NameFromText(backEndProps[i].Name, columnType, Component!.Site); + + // + // host.CreateComponent adds the column to its list of components + // + // 5. IContainer.Add(newDataGridView.Columns + // +#pragma warning disable IL2077 // Target parameter argument does not satisfy 'DynamicallyAccessedMembersAttribute' in call to target method. The source field does not have matching annotations. + dataGridViewColumn = TypeDescriptor.CreateInstance(host, columnType, null, null) as DataGridViewColumn; +#pragma warning restore IL2077 // Target parameter argument does not satisfy 'DynamicallyAccessedMembersAttribute' in call to target method. The source field does not have matching annotations. + + if (dataGridViewColumn is not null) + { + dataGridViewColumn.DataPropertyName = backEndProps[i].Name; + dataGridViewColumn.HeaderText = !string.IsNullOrEmpty(backEndProps[i].DisplayName) ? backEndProps[i].DisplayName : backEndProps[i].Name; + dataGridViewColumn.Name = backEndProps[i].Name; + dataGridViewColumn.ValueType = backEndProps[i].PropertyType; + dataGridViewColumn.ReadOnly = backEndProps[i].IsReadOnly; + + host?.Container.Add(dataGridViewColumn, nameFromText); + + columnsToBeAdded[columnsToBeAddedCount] = dataGridViewColumn; + columnsToBeAddedCount++; + } + } + } + + // 6. OnComponentChanging DataGridView.Columns + changeService?.OnComponentChanging(Component!, columnsProp); + + // 7. DataGridView.Columns.Add( new DataGridViewColumns) + for (int i = 0; i < columnsToBeAddedCount; i++) + { + // wipe out the display index + columnsToBeAdded![i].DisplayIndex = -1; + dataGridView.Columns.Add(columnsToBeAdded[i]); + } + + // 8. OnComponentChanged DataGridView.Columns + changeService?.OnComponentChanged(Component!, columnsProp, null, null); + } + + private bool ShouldSerializeAutoSizeColumnsMode() + { + DataGridView? dataGridView = Component as DataGridView; + if (dataGridView is not null) + { + return dataGridView.AutoSizeColumnsMode != DataGridViewAutoSizeColumnsMode.None; + } + else + { + return false; + } + } + + private bool ShouldSerializeDataSource() + { + return ((DataGridView)Component).DataSource is not null; + } + + // Ideally there would be a public method like this somewhere. + internal static void ShowErrorDialog(IUIService? uiService, Exception ex, Control? dataGridView) + { + if (uiService is not null) + { + uiService.ShowError(ex); + } + else + { + string message = ex.Message; + if (message is null || message.Length == 0) + { + message = ex.ToString(); + } + + RTLAwareMessageBox.Show(dataGridView, message, null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, + MessageBoxDefaultButton.Button1, 0); + } + } + + internal static void ShowErrorDialog(IUIService? uiService, string errorString, Control? dataGridView) + { + if (uiService is not null) + { + uiService.ShowError(errorString); + } + else + { + RTLAwareMessageBox.Show(dataGridView, errorString, null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, + MessageBoxDefaultButton.Button1, 0); + } + } + + private void dataGridViewMetaDataChanged(object? sender, EventArgs e) + { + RefreshColumnCollection(); + } + + public void OnEditColumns(object? sender, EventArgs e) + { + IDesignerHost? host = Component.Site?.GetService(typeof(IDesignerHost)) as IDesignerHost; + + // child modal dialog -launching in System Aware mode + DataGridViewColumnCollectionDialog dialog = DpiHelper.CreateInstanceInSystemAwareContext(() => new DataGridViewColumnCollectionDialog(((DataGridView)Component!).Site!)); + dialog.SetLiveDataGridView((DataGridView)Component); + DesignerTransaction? transaction = host?.CreateTransaction(SR.DataGridViewEditColumnsTransactionString); + DialogResult result = DialogResult.Cancel; + + try + { + result = ShowDialog(dialog); + } + finally + { + if (result == DialogResult.OK) + { + transaction?.Commit(); + } + else + { + transaction?.Cancel(); + } + } + } + + public void OnAddColumn(object? sender, EventArgs e) + { + IDesignerHost? host = Component.Site?.GetService(typeof(IDesignerHost)) as IDesignerHost; + DesignerTransaction? transaction = host?.CreateTransaction(SR.DataGridViewAddColumnTransactionString); + DialogResult result = DialogResult.Cancel; + + // child modal dialog -launching in System Aware mode + DataGridViewAddColumnDialog dialog = DpiHelper.CreateInstanceInSystemAwareContext(() => new DataGridViewAddColumnDialog(((DataGridView)Component).Columns, (DataGridView)Component)); + dialog.Start(((DataGridView)Component).Columns.Count, true /*persistChangesToDesigner*/); + + try + { + result = ShowDialog(dialog); + } + finally + { + if (result == DialogResult.OK) + { + transaction?.Commit(); + } + else + { + transaction?.Cancel(); + } + } + } + + private DialogResult ShowDialog(Form dialog) + { + IUIService? service = Component.Site?.GetService(typeof(IUIService)) as IUIService; + if (service is not null) + { + return service.ShowDialog(dialog); + } + else + { + return dialog.ShowDialog(Component as IWin32Window); + } + } + + [ComplexBindingProperties("DataSource", "DataMember")] + private class DataGridViewChooseDataSourceActionList : DesignerActionList + { + private DataGridViewDesigner _owner; + + public DataGridViewChooseDataSourceActionList(DataGridViewDesigner owner) : base(owner.Component) + { + _owner = owner; + } + + public override DesignerActionItemCollection GetSortedActionItems() + { + DesignerActionItemCollection items = new DesignerActionItemCollection(); + DesignerActionPropertyItem chooseDataSource = new DesignerActionPropertyItem("DataSource", // property name + SR.DataGridViewChooseDataSource);// displayName + chooseDataSource.RelatedComponent = _owner.Component; + items.Add(chooseDataSource); + return items; + } + + [AttributeProvider(typeof(IListSource))] + [Editor($"System.Windows.Forms.Design.DataSourceListEditor, {AssemblyRef.SystemDesign}", typeof(UITypeEditor))] + public object DataSource + { + [ + SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode") // DAP calls this method thru Reflection. + ] + get + { + // Use the shadow property which is defined on the designer. + return _owner.DataSource; + } + + [ + SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode") // DAP calls this method thru Reflection. + ] + set + { + // left to do: transaction stuff + DataGridView dataGridView = (DataGridView)_owner.Component; + IDesignerHost? host = _owner.Component?.Site?.GetService(typeof(IDesignerHost)) as IDesignerHost; + PropertyDescriptor? dataSourceProp = TypeDescriptor.GetProperties(dataGridView)["DataSource"]; + IComponentChangeService? changeService = _owner.Component?.Site?.GetService(typeof(IComponentChangeService)) as IComponentChangeService; + DesignerTransaction? transaction = host?.CreateTransaction(string.Format(SR.DataGridViewChooseDataSourceTransactionString, dataGridView.Name)); + try + { + changeService?.OnComponentChanging(_owner.Component!, dataSourceProp); + // Use the shadow property which is defined on the designer. + _owner.DataSource = value; + changeService?.OnComponentChanged(_owner.Component!, dataSourceProp, null, null); + transaction?.Commit(); + transaction = null; + } + finally + { + transaction?.Cancel(); + } + } + } + } + + private class DataGridViewColumnEditingActionList : DesignerActionList + { + private DataGridViewDesigner _owner; + public DataGridViewColumnEditingActionList(DataGridViewDesigner owner) : base(owner.Component) + { + _owner = owner; + } + + public override DesignerActionItemCollection GetSortedActionItems() + { + DesignerActionItemCollection items = new DesignerActionItemCollection(); + items.Add(new DesignerActionMethodItem(this, + "EditColumns", // method name + SR.DataGridViewEditColumnsVerb, // display name + true)); // promoteToDesignerVerb + items.Add(new DesignerActionMethodItem(this, + "AddColumn", // method name + SR.DataGridViewAddColumnVerb, // display name + true)); // promoteToDesignerVerb + + return items; + } + + [ + SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode") // DAP calls this method thru Reflection. + ] + public void EditColumns() + { + _owner.OnEditColumns(this, EventArgs.Empty); + } + + [ + SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode") // DAP calls this method thru Reflection. + ] + public void AddColumn() + { + _owner.OnAddColumn(this, EventArgs.Empty); + } + } + + private class DataGridViewPropertiesActionList : DesignerActionList + { + private DataGridViewDesigner _owner; + + public DataGridViewPropertiesActionList(DataGridViewDesigner owner) : base(owner.Component) + { + _owner = owner; + } + + public override DesignerActionItemCollection GetSortedActionItems() + { + DesignerActionItemCollection items = new DesignerActionItemCollection(); + items.Add(new DesignerActionPropertyItem("AllowUserToAddRows", + SR.DataGridViewEnableAdding)); + items.Add(new DesignerActionPropertyItem("ReadOnly", + SR.DataGridViewEnableEditing)); + items.Add(new DesignerActionPropertyItem("AllowUserToDeleteRows", + SR.DataGridViewEnableDeleting)); + items.Add(new DesignerActionPropertyItem("AllowUserToOrderColumns", + SR.DataGridViewEnableColumnReordering)); + return items; + } + + public bool AllowUserToAddRows + { + [ + SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode") // DAP calls this method thru Reflection. + ] + get + { + return ((DataGridView)_owner.Component).AllowUserToAddRows; + } + + [ + SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode") // DAP calls this method thru Reflection. + ] + set + { + if (value == AllowUserToAddRows) + { + return; + } + + IDesignerHost? host = _owner.Component?.Site?.GetService(typeof(IDesignerHost)) as IDesignerHost; + + DesignerTransaction? transaction; + + if (value) + { + transaction = host?.CreateTransaction(SR.DataGridViewEnableAddingTransactionString); + } + else + { + transaction = host?.CreateTransaction(SR.DataGridViewDisableAddingTransactionString); + } + + try + { + IComponentChangeService? changeService = _owner.Component?.Site?.GetService(typeof(IComponentChangeService)) as IComponentChangeService; + PropertyDescriptor? prop = TypeDescriptor.GetProperties(_owner.Component!)["AllowUserToAddRows"]; + changeService?.OnComponentChanging(_owner.Component!, prop); + + ((DataGridView)_owner.Component!).AllowUserToAddRows = value; + + changeService?.OnComponentChanged(_owner.Component, prop, null, null); + transaction?.Commit(); + transaction = null; + } + finally + { + transaction?.Cancel(); + } + } + } + + public bool AllowUserToDeleteRows + { + [ + SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode") // DAP calls this method thru Reflection. + ] + get + { + return ((DataGridView)_owner.Component).AllowUserToDeleteRows; + } + + [ + SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode") // DAP calls this method thru Reflection. + ] + set + { + if (value == AllowUserToDeleteRows) + { + return; + } + + IDesignerHost? host = _owner.Component?.Site?.GetService(typeof(IDesignerHost)) as IDesignerHost; + + DesignerTransaction? transaction; + + if (value) + { + transaction = host?.CreateTransaction(SR.DataGridViewEnableDeletingTransactionString); + } + else + { + transaction = host?.CreateTransaction(SR.DataGridViewDisableDeletingTransactionString); + } + + try + { + IComponentChangeService? changeService = _owner.Component?.Site?.GetService(typeof(IComponentChangeService)) as IComponentChangeService; + PropertyDescriptor? prop = TypeDescriptor.GetProperties(_owner.Component!)["AllowUserToDeleteRows"]; + changeService?.OnComponentChanging(_owner.Component!, prop); + + ((DataGridView)_owner.Component!).AllowUserToDeleteRows = value; + + changeService?.OnComponentChanged(_owner.Component, prop, null, null); + transaction?.Commit(); + transaction = null; + } + finally + { + transaction?.Cancel(); + } + } + } + + public bool AllowUserToOrderColumns + { + [ + SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode") // DAP calls this method thru Reflection. + ] + get + { + return ((DataGridView)_owner.Component).AllowUserToOrderColumns; + } + + [ + SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode") // DAP calls this method thru Reflection. + ] + set + { + if (value == AllowUserToOrderColumns) + { + return; + } + + IDesignerHost? host = _owner.Component?.Site?.GetService(typeof(IDesignerHost)) as IDesignerHost; + + DesignerTransaction? transaction; + + if (value) + { + transaction = host?.CreateTransaction(SR.DataGridViewEnableColumnReorderingTransactionString); + } + else + { + transaction = host?.CreateTransaction(SR.DataGridViewDisableColumnReorderingTransactionString); + } + + try + { + IComponentChangeService? changeService = _owner.Component?.Site?.GetService(typeof(IComponentChangeService)) as IComponentChangeService; + PropertyDescriptor? prop = TypeDescriptor.GetProperties(_owner.Component!)["AllowUserToReorderColumns"]; + changeService?.OnComponentChanging(_owner.Component!, prop); + + ((DataGridView)_owner.Component!).AllowUserToOrderColumns = value; + + changeService?.OnComponentChanged(_owner.Component, prop, null, null); + transaction?.Commit(); + transaction = null; + } + finally + { + transaction?.Cancel(); + } + } + } + + public bool ReadOnly + { + [ + SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode") // DAP calls this method thru Reflection. + ] + get + { + return !((DataGridView)_owner.Component).ReadOnly; + } + + [ + SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode") // DAP calls this method thru Reflection. + ] + set + { + if (value == ReadOnly) + { + return; + } + + IDesignerHost? host = _owner.Component?.Site?.GetService(typeof(IDesignerHost)) as IDesignerHost; + + DesignerTransaction? transaction; + + if (value) + { + transaction = host?.CreateTransaction(SR.DataGridViewEnableEditingTransactionString); + } + else + { + transaction = host?.CreateTransaction(SR.DataGridViewDisableEditingTransactionString); + } + + try + { + IComponentChangeService? changeService = _owner.Component?.Site?.GetService(typeof(IComponentChangeService)) as IComponentChangeService; + PropertyDescriptor? prop = TypeDescriptor.GetProperties(_owner.Component!)["ReadOnly"]; + changeService?.OnComponentChanging(_owner.Component!, prop); + + ((DataGridView)_owner.Component!).ReadOnly = !value; + + changeService?.OnComponentChanged(_owner.Component, prop, null, null); + transaction?.Commit(); + transaction = null; + } + finally + { + transaction?.Cancel(); + } + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewRowCollectionCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewRowCollectionCodeDomSerializer.cs index c809c2d4136..555b5904d8a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewRowCollectionCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataGridViewRowCollectionCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataMemberFieldConverter.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataMemberFieldConverter.cs index 589e8324cf6..77ed3274c1a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataMemberFieldConverter.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataMemberFieldConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceDescriptorCollection.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceDescriptorCollection.cs new file mode 100644 index 00000000000..f1d9200a2cc --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceDescriptorCollection.cs @@ -0,0 +1,56 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections; + +namespace System.Windows.Forms.Design; + +internal class DataSourceDescriptorCollection : CollectionBase +{ + public DataSourceDescriptorCollection() : base() + { + } + + public int Add(DataSourceDescriptor value) + { + return List.Add(value); + } + + public int IndexOf(DataSourceDescriptor value) + { + return List.IndexOf(value); + } + + public void Insert(int index, DataSourceDescriptor value) + { + List.Insert(index, value); + } + + public bool Contains(DataSourceDescriptor value) + { + return List.Contains(value); + } + + public void CopyTo(DataSourceDescriptor[] array, int index) + { + List.CopyTo(array, index); + } + + public void Remove(DataSourceDescriptor value) + { + List.Remove(value); + } + + public DataSourceDescriptor this[int index] + { + get + { + return (DataSourceDescriptor)List[index]!; + } + + set + { + List[index] = value; + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceGroup.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceGroup.cs new file mode 100644 index 00000000000..be810924771 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceGroup.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Drawing; + +namespace System.Windows.Forms.Design; + +internal abstract class DataSourceGroup +{ + public abstract string Name { get; } + + public abstract Bitmap Image { get; } + + public abstract DataSourceDescriptorCollection DataSources { get; } + + public abstract bool IsDefault { get; } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceGroupCollection.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceGroupCollection.cs new file mode 100644 index 00000000000..78f2f6d633b --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceGroupCollection.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections; + +namespace System.Windows.Forms.Design; + +internal class DataSourceGroupCollection : CollectionBase +{ + public DataSourceGroupCollection() : base() + { + } + + public int Add(DataSourceGroup value) + { + return List.Add(value); + } + + public int IndexOf(DataSourceGroup value) + { + return List.IndexOf(value); + } + + public void Insert(int index, DataSourceGroup value) + { + List.Insert(index, value); + } + + public bool Contains(DataSourceGroup value) + { + return List.Contains(value); + } + + public void CopyTo(DataSourceGroup[] array, int index) + { + List.CopyTo(array, index); + } + + public void Remove(DataSourceGroup value) + { + List.Remove(value); + } + + public DataSourceGroup this[int index] + { + get => (DataSourceGroup)List[index]!; + + set => List[index] = value; + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceListEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceListEditor.cs new file mode 100644 index 00000000000..541a755b52e --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceListEditor.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.Drawing.Design; + +namespace System.Windows.Forms.Design; + +internal class DataSourceListEditor : UITypeEditor +{ + private DesignBindingPicker? _designBindingPicker; + + public override bool IsDropDownResizable + { + get + { + return true; + } + } + + public override object? EditValue(ITypeDescriptorContext? context, IServiceProvider provider, object? value) + { + if (provider is not null && context is not null && context.Instance is not null) + { + _designBindingPicker ??= new DesignBindingPicker(); + + DesignBinding oldSelection = new DesignBinding(value, ""); + DesignBinding? newSelection = _designBindingPicker.Pick(context, provider, + true, /* showDataSources */ + false, /* showDataMembers */ + false, /* selectListMembers */ + null, string.Empty, + oldSelection); + if (newSelection is not null) + { + value = newSelection.DataSource; + } + } + + return value; + } + + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext? context) + { + return UITypeEditorEditStyle.DropDown; + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceProviderService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceProviderService.cs new file mode 100644 index 00000000000..59438fa9f5d --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DataSourceProviderService.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design; + +internal abstract class DataSourceProviderService +{ + public abstract bool SupportsAddNewDataSource { get; } + + public abstract bool SupportsConfigureDataSource { get; } + + public abstract DataSourceGroupCollection GetDataSources(); + + public abstract DataSourceGroup InvokeAddNewDataSource(IWin32Window parentWindow, FormStartPosition startPosition); + + public abstract bool InvokeConfigureDataSource(IWin32Window parentWindow, FormStartPosition startPosition, DataSourceDescriptor dataSourceDescriptor); + + public abstract object AddDataSourceInstance(IDesignerHost? host, DataSourceDescriptor dataSourceDescriptor); + + public abstract void NotifyDataSourceComponentAdded(object dsc); +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DateTimePickerDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DateTimePickerDesigner.cs index aa277d1fb2c..1fbaccd03a7 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DateTimePickerDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DateTimePickerDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBinding.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBinding.cs new file mode 100644 index 00000000000..73980932935 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBinding.cs @@ -0,0 +1,68 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Windows.Forms.Design; + +internal class DesignBinding +{ + private object? dataSource; + private string? dataMember; + + public static DesignBinding Null = new(null, null); + + public DesignBinding(object? dataSource, string? dataMember) + { + this.dataSource = dataSource; + this.dataMember = dataMember; + } + + public bool IsNull + { + get + { + return (dataSource is null); + } + } + + public object? DataSource + { + get + { + return dataSource; + } + } + + public string? DataMember + { + get + { + return dataMember; + } + } + + public string DataField + { + get + { + if (string.IsNullOrEmpty(dataMember)) + { + return string.Empty; + } + + int lastDot = dataMember.LastIndexOf("."); + if (lastDot == -1) + { + return dataMember; + } + else + { + return dataMember.Substring(lastDot + 1); + } + } + } + + public bool Equals(object? dataSource, string dataMember) + { + return dataSource == this.dataSource && string.Equals(dataMember, this.dataMember, StringComparison.OrdinalIgnoreCase); + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingPicker.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingPicker.cs new file mode 100644 index 00000000000..c24b4807836 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingPicker.cs @@ -0,0 +1,2644 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Collections; +using System.Drawing; +using System.Drawing.Design; +using System.Data; +using System.Globalization; + +namespace System.Windows.Forms.Design +{ + /// + /// OVERVIEW: + /// + /// Multi-purpose data binding picker control. Used for picking data sources, + /// data members, and data bindings. Invoked using the Pick() method. + /// + /// Data bindable items are displayed in tree form, with the following general + /// structure, consisting of data sources and two kinds of data member... + /// + /// Data source + /// Field member + /// Field member + /// List member + /// Field member + /// Field member + /// List member + /// Field member + /// Field member + /// Data source + /// Field member + /// Field member + /// List member + /// Field member + /// Field member + /// List member + /// Field member + /// Field member + /// + /// ...where data sources are only top-level items, and list members can be + /// nested to any depth. The tree can also be scoped to just show the members + /// of a specific data source. List members and field members can also be + /// filtered out. The user can only select the 'deepest' kind of item being + /// shown (ie. field members, then list members, then data sources). + /// + /// COMMON USES: + /// + /// Example property UITypeEditor Pick(showDS, showDM, selLists, rootDS) + /// ---------------------- --------------------- -------------------------------------- + /// DataGrid.DataSource DataSourceListEditor Pick(1, 0, -, null) + /// TextBox.Text DesignBindingEditor Pick(1, 1, 0, null) + /// ComboBox.DisplayMember DataMemberFieldEditor Pick(0, 1, 0, ComboBox.DataSource) + /// DataGrid.DataMember DataMemberListEditor Pick(0, 1, 1, DataGrid.DataSource) + /// + /// NEW FOR WHIDBEY: + /// + /// When data sources are included, the above tree structure is now organized + /// as shown below. Binding sources appear first, with other form-level data + /// sources relegated to a sub-node. There is also a sub-node that exposes + /// project-level data sources. + /// + /// ["None"] + /// Binding source + /// {{{data members}}} + /// ["Other Data Sources"] + /// ["Project Data Sources"] + /// Project data source group + /// Project data source + /// {{{data members}}} + /// ["Form List Instances"] + /// Data source + /// {{{data members}}} + /// + /// ...data members shown under each BindingSource are fine-tuned to remove + /// the redundancy that confused Everett users; immediate child members + /// are shown, but nothing deeper than that. + /// + /// List members under either BindingSources or project-level data sources + /// count as data sources. When one is picked, a new 'related' BindingSource + /// is created that refers to that list member. + /// OVERVIEW: + /// + [ + ToolboxItem(false), + DesignTimeVisible(false) + ] + internal class DesignBindingPicker : ContainerControl + { + private BindingPickerTree? _treeViewCtrl; // Tree view that shows the available data sources and data members + private BindingPickerLink _addNewCtrl; // Link that invokes the "Add Project Data Source" wizard + private Panel _addNewPanel; // Panel containing the "Add Project Data Source" link + private HelpTextLabel _helpTextCtrl; // Label that displays helpful text as user mouses over tree view nodes + private Panel _helpTextPanel; // Panel containing the help text label + + private IServiceProvider? _serviceProvider; // Current VS service provider + private IWindowsFormsEditorService? _windowsFormsEditorService; // Service used to invoke the picker inside a modal dropdown + private DataSourceProviderService? _dataSourceProviderService; // Service that provides project level data sources and related commands + private ITypeResolutionService? _typeResolutionService; // Service that can return Type info for types in the user's project, at design time + private IDesignerHost? _designerHost; // Service that provides access to current WinForms designer session + + private bool _showDataSources; // True to show all data sources, false to just show contents of root data source + private bool _showDataMembers; // True to show data members of every data source, false to omit data members + private bool _selectListMembers; // True to allow selection of list members, false to allow selection of field members + + private object? _rootDataSource; // Root data source used to build tree (set when picker is invoked) + private string? _rootDataMember; // Root data member used to build tree (set when picker is invoked) + + private DesignBinding? _selectedItem; // Describes the initial selection on open, and the final selection on close + private TreeNode? _selectedNode; // Tree node that matches the initial selected item (selectedItem) + private bool _inSelectNode; // Prevents processing of node expansion events when auot-selecting a tree node + + private NoneNode? _noneNode; // "None" tree node + private OtherNode? _otherNode; // "Other Data Sources" tree node + private ProjectNode? _projectNode; // "Project Data Sources" tree node + private InstancesNode? _instancesNode; // "Form List Instances" tree node + + private const int MinimumDimension = 250; + private static int _minimumHeight = MinimumDimension; + private static int _minimumWidth = MinimumDimension; + private static bool _isScalingInitialized; + private ITypeDescriptorContext? _context; // Context of the current 'pick' operation + + private int _pixel_1 = 1; + private Size _initialSize; + private BindingContext _bindingContext = new(); + + // The type of RuntimeType. + // When binding to a business object, the DesignBindingPicker needs to create an instance of the business object. + // However, Activator.CreateInstance works only with RuntimeType - it does not work w/ Virtual Types. + // We use the runtimeType static to determine if the type of business object is a runtime type or not. + private static Type runtimeType = typeof(object).GetType().GetType(); + + /// + /// Rebuilding binding picker according to new dpi received. + /// + private void BuildBindingPicker(int newDpi, int oldDpi) + { + var factor = ((double)newDpi) / oldDpi; + Label addNewDiv = new Label(); + addNewDiv.Height = DpiHelper.ConvertToGivenDpiPixel(_pixel_1, factor); + addNewDiv.BackColor = SystemColors.ControlDark; + addNewDiv.Dock = DockStyle.Top; + + _addNewCtrl = new BindingPickerLink(); + _addNewCtrl.Text = SR.DesignBindingPickerAddProjDataSourceLabel; + _addNewCtrl.TextAlign = ContentAlignment.MiddleLeft; + _addNewCtrl.BackColor = SystemColors.Window; + _addNewCtrl.ForeColor = SystemColors.WindowText; + _addNewCtrl.LinkBehavior = LinkBehavior.HoverUnderline; + _addNewCtrl.LinkClicked += addNewCtrl_Click; + + // BindingPickerLink always initialize to primary monitor Dpi. Resizing to current Dpi. + _addNewCtrl.Height = DpiHelper.ConvertToGivenDpiPixel(_addNewCtrl.Height, factor); + + Bitmap addNewBitmap = new Bitmap(BitmapSelector.GetResourceStream(typeof(DesignBindingPicker), "AddNewDataSource.bmp")); + addNewBitmap.MakeTransparent(Color.Magenta); + DpiHelper.ScaleBitmapLogicalToDevice(ref addNewBitmap, newDpi); + + PictureBox addNewIcon = new PictureBox(); + addNewIcon.Image = addNewBitmap; + addNewIcon.BackColor = SystemColors.Window; + addNewIcon.ForeColor = SystemColors.WindowText; + addNewIcon.Width = _addNewCtrl.Height; + addNewIcon.Height = _addNewCtrl.Height; + addNewIcon.Dock = DockStyle.Left; + addNewIcon.SizeMode = PictureBoxSizeMode.CenterImage; + addNewIcon.AccessibleRole = AccessibleRole.Graphic; + + Label helpTextDiv = new Label(); + helpTextDiv.Height = DpiHelper.ConvertToGivenDpiPixel(_pixel_1, factor); + helpTextDiv.BackColor = SystemColors.ControlDark; + helpTextDiv.Dock = DockStyle.Top; + + _helpTextCtrl = new HelpTextLabel(); + _helpTextCtrl.TextAlign = ContentAlignment.TopLeft; + _helpTextCtrl.BackColor = SystemColors.Window; + _helpTextCtrl.ForeColor = SystemColors.WindowText; + _helpTextCtrl.Height *= 2; + int helpTextHeight = DpiHelper.ConvertToGivenDpiPixel(_helpTextCtrl.Height, factor); + + _addNewPanel.Height = addNewIcon.Height + _pixel_1; + _addNewPanel.Controls.Add(_addNewCtrl); + _addNewPanel.Controls.Add(addNewIcon); + _addNewPanel.Controls.Add(addNewDiv); + + _helpTextPanel.Controls.Add(_helpTextCtrl); + _helpTextPanel.Controls.Add(helpTextDiv); + _helpTextPanel.Height = helpTextHeight + _pixel_1; + ResetStyles(false); + + Controls.Add(_addNewPanel); + Controls.Add(_helpTextPanel); + } + + private void ResetStyles(bool toNone) + { + if (toNone) + { + _treeViewCtrl!.Dock = DockStyle.None; + _addNewCtrl.Dock = DockStyle.None; + _addNewPanel.Dock = DockStyle.None; + _helpTextCtrl.Dock = DockStyle.None; + _helpTextPanel.Dock = DockStyle.None; + } + else + { + _treeViewCtrl!.Dock = DockStyle.Fill; + _addNewCtrl.Dock = DockStyle.Fill; + _addNewPanel.Dock = DockStyle.Bottom; + _helpTextCtrl.Dock = DockStyle.Fill; + _helpTextPanel.Dock = DockStyle.Bottom; + } + } + + private void InitTreeViewCtl() + { + _treeViewCtrl = new BindingPickerTree(); + _treeViewCtrl.HotTracking = true; + _treeViewCtrl.BackColor = SystemColors.Window; + _treeViewCtrl.ForeColor = SystemColors.WindowText; + _treeViewCtrl.BorderStyle = BorderStyle.None; + _initialSize = _treeViewCtrl.Size; + _treeViewCtrl.Dock = DockStyle.Fill; + _treeViewCtrl.MouseMove += treeViewCtrl_MouseMove; + _treeViewCtrl.MouseLeave += treeViewCtrl_MouseLeave; + _treeViewCtrl.AfterExpand += treeViewCtrl_AfterExpand; + _treeViewCtrl.AccessibleName = (SR.DesignBindingPickerTreeViewAccessibleName); + + // enable explorer tree view style + DesignerUtils.ApplyTreeViewThemeStyles(_treeViewCtrl); + } + + /// + /// Constructor - Initializes child controls and window layout + /// + public DesignBindingPicker() + { + SuspendLayout(); + if (!_isScalingInitialized) + { + if (DpiHelper.IsScalingRequired) + { + _minimumHeight = DpiHelper.LogicalToDeviceUnitsY(MinimumDimension); + _minimumWidth = DpiHelper.LogicalToDeviceUnitsX(MinimumDimension); + } + + _isScalingInitialized = true; + } + + InitTreeViewCtl(); + + Label addNewDiv = new Label(); + addNewDiv.Height = 1; + addNewDiv.BackColor = SystemColors.ControlDark; + addNewDiv.Dock = DockStyle.Top; + + _addNewCtrl = new BindingPickerLink(); + _addNewCtrl.Text = (SR.DesignBindingPickerAddProjDataSourceLabel); + _addNewCtrl.TextAlign = ContentAlignment.MiddleLeft; + _addNewCtrl.BackColor = SystemColors.Window; + _addNewCtrl.ForeColor = SystemColors.WindowText; + _addNewCtrl.LinkBehavior = LinkBehavior.HoverUnderline; + + // use height of text for both dimensions of the Icon + int addNewHeight = _addNewCtrl.Height; + int addNewWidth = _addNewCtrl.Height; + _addNewCtrl.Dock = DockStyle.Fill; + _addNewCtrl.LinkClicked += addNewCtrl_Click; + + Bitmap addNewBitmap = new Bitmap(typeof(DesignBindingPicker), "AddNewDataSource.bmp"); + addNewBitmap.MakeTransparent(Color.Magenta); + if (DpiHelper.IsScalingRequired) + { + DpiHelper.ScaleBitmapLogicalToDevice(ref addNewBitmap); + addNewHeight = DpiHelper.LogicalToDeviceUnitsY(_addNewCtrl.Height); + addNewWidth = DpiHelper.LogicalToDeviceUnitsX(_addNewCtrl.Height); + } + + PictureBox addNewIcon = new PictureBox(); + addNewIcon.Image = addNewBitmap; + addNewIcon.BackColor = SystemColors.Window; + addNewIcon.ForeColor = SystemColors.WindowText; + addNewIcon.Width = addNewWidth; + addNewIcon.Height = addNewHeight; + addNewIcon.Dock = DockStyle.Left; + addNewIcon.SizeMode = PictureBoxSizeMode.CenterImage; + addNewIcon.AccessibleRole = AccessibleRole.Graphic; + + _addNewPanel = new Panel(); + _addNewPanel.Controls.Add(_addNewCtrl); + _addNewPanel.Controls.Add(addNewIcon); + _addNewPanel.Controls.Add(addNewDiv); + _addNewPanel.Height = addNewHeight + 1; + _addNewPanel.Dock = DockStyle.Bottom; + + Label helpTextDiv = new Label(); + helpTextDiv.Height = 1; + helpTextDiv.BackColor = SystemColors.ControlDark; + helpTextDiv.Dock = DockStyle.Top; + + _helpTextCtrl = new HelpTextLabel(); + _helpTextCtrl.TextAlign = ContentAlignment.TopLeft; + _helpTextCtrl.BackColor = SystemColors.Window; + _helpTextCtrl.ForeColor = SystemColors.WindowText; + _helpTextCtrl.Height *= 2; + int helpTextHeight = _helpTextCtrl.Height; + if (DpiHelper.IsScalingRequired) + { + helpTextHeight = DpiHelper.LogicalToDeviceUnitsY(helpTextHeight); + } + + _helpTextCtrl.Dock = DockStyle.Fill; + + _helpTextPanel = new Panel(); + _helpTextPanel.Controls.Add(_helpTextCtrl); + _helpTextPanel.Controls.Add(helpTextDiv); + _helpTextPanel.Height = helpTextHeight + 1; + _helpTextPanel.Dock = DockStyle.Bottom; + + Controls.Add(_treeViewCtrl); + Controls.Add(_addNewPanel); + Controls.Add(_helpTextPanel); + + ResumeLayout(false); + + Size = _initialSize; + BackColor = SystemColors.Control; + ActiveControl = _treeViewCtrl; + AccessibleName = (SR.DesignBindingPickerAccessibleName); + + SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); + } + + /// + /// + /// Invokes picker as a dropdown control, allowing user to pick a data source + /// or data member to apply to some property of some component or control. + /// This is a modal call - it doesn't return until the dropdown closes. + /// + /// Arguments: + /// + /// context - Context of operation (ie. which property of which object is being set) + /// provider - VS service provider (for IWindowsFormsEditorService and DataSourceProviderService) + /// showDataSources - True to show all data sources, false to just show contents of root data source + /// showDataMembers - True to show data members of every data source, false to omit data members + /// selectListMembers - True to allow selection of list members, false to allow selection of field members + /// rootObjectDataSource - Root data source, who's members we want to show (ignored if showDataSources = true) + /// rootObjectDataMember - Optional: For identifying root data source through data member of another data source + /// initialSelectedItem - Optional: Describes which binding to show as the initial selection + /// + /// Return value: + /// + /// Returns a DesignBinding that describes the binding + /// the user picked, or null if no selection was made. + /// + /// + + /// FXCOP suggests we use generics to avoid boxing of value types when referencing + /// values in the uiService.Styles hashtable. However, the values contained within + /// can be of differing types - so we cannot do this. Hence the suppression. + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + public DesignBinding? Pick(ITypeDescriptorContext? context, + IServiceProvider provider, + bool showDataSources, + bool showDataMembers, + bool selectListMembers, + object? rootDataSource, + string rootDataMember, + DesignBinding initialSelectedItem) + { + // Get services + _serviceProvider = provider; + _windowsFormsEditorService = _serviceProvider?.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService; +#pragma warning disable VSSDK006 + _dataSourceProviderService = _serviceProvider?.GetService(typeof(DataSourceProviderService)) as DataSourceProviderService; + _typeResolutionService = _serviceProvider?.GetService(typeof(ITypeResolutionService)) as ITypeResolutionService; + _designerHost = _serviceProvider?.GetService(typeof(IDesignerHost)) as IDesignerHost; +#pragma warning restore VSSDK006 + + if (_windowsFormsEditorService is null) + { + return null; + } + + // Record basic settings + _context = context; + _showDataSources = showDataSources; + _showDataMembers = showDataMembers; + _selectListMembers = showDataMembers ? selectListMembers : true; + _rootDataSource = rootDataSource; + _rootDataMember = rootDataMember; + + //Attempt to adjust the linklabel colors if we can get our ui service + IUIService? uiService = _serviceProvider?.GetService(typeof(IUIService)) as IUIService; + if (uiService is not null) + { + if (uiService.Styles["VsColorPanelHyperLink"] is Color color1) + { + _addNewCtrl.LinkColor = color1; + } + + if (uiService.Styles["VsColorPanelHyperLinkPressed"] is Color color2) + { + _addNewCtrl.ActiveLinkColor = color2; + } + } + + // Fill the tree with lots of juicy stuff + FillTree(initialSelectedItem); + + // Set initial state of the various sub-panels + //addNewPanel.Visible = (showDataSources && dspSvc is not null && dspSvc.SupportsAddNewDataSource); + _helpTextPanel.Visible = (showDataSources); + + // Set initial help text in help pane + UpdateHelpText(null); + + // Invoke the modal dropdown via the editor service (returns once CloseDropDown has been called) + _windowsFormsEditorService.DropDownControl(this); + + // Record any final selection + DesignBinding? finalSelectedItem = _selectedItem; + _selectedItem = null; + + // Clean up tree (remove nodes and clear node references) + EmptyTree(); + + // Clean up references + _serviceProvider = null; + _windowsFormsEditorService = null; + _dataSourceProviderService = null; + _designerHost = null; + context = null; + + // Return final selection to caller + return finalSelectedItem; + } + + protected override void RescaleConstantsForDpi(int deviceDpiOld, int deviceDpiNew) + { + base.RescaleConstantsForDpi(deviceDpiOld, deviceDpiNew); + + var factor = (double)deviceDpiNew / deviceDpiOld; + _minimumWidth = DpiHelper.ConvertToGivenDpiPixel(_minimumWidth, factor); + _minimumHeight = DpiHelper.ConvertToGivenDpiPixel(_minimumHeight, factor); + Size = new Size(DpiHelper.ConvertToGivenDpiPixel(_initialSize.Width, factor), DpiHelper.ConvertToGivenDpiPixel(_initialSize.Height, factor)); + SuspendLayout(); + try + { + ResetStyles(true); + _addNewPanel.Controls.Clear(); + _helpTextPanel.Controls.Clear(); + Controls.Remove(_addNewPanel); + Controls.Remove(_helpTextPanel); + BuildBindingPicker(deviceDpiNew, deviceDpiOld); + } + finally + { + ResumeLayout(false); + } + } + + /// + /// If control is open as a dropdown, and a value has been picked + /// by the user, close the dropdown and end the picking session. + /// + private void CloseDropDown() + { + // VSWhidbey#256272. If the object being edited is a BindingSource, then tell its designer to notify + // the DataSourceProviderService of this change, once the new DataSource/DataMember value has taken + // effect. This allows the service to generate any adapter components or fill statements needed to + // set up whatever data source the BindingSource is now bound to. Scenario: Advanced user manually + // configuring a BindingSource. + // + if (_context?.Instance is BindingSource instance && _designerHost is not null) + { + BindingSourceDesigner? designer = _designerHost.GetDesigner(instance) as BindingSourceDesigner; + if (designer is not null) + { + designer.BindingUpdatedByUser = true; + } + } + + // Tell the editor service to close the dropdown + _windowsFormsEditorService?.CloseDropDown(); + } + + /// + /// Resets tree view to empty state. + /// + private void EmptyTree() + { + _noneNode = null; + _otherNode = null; + _projectNode = null; + _instancesNode = null; + _selectedNode = null; + + _treeViewCtrl?.Nodes.Clear(); + } + + /// + /// Initializes and populates the tree view. + /// + private void FillTree(DesignBinding initialSelectedItem) + { + // Set the initial selected item + _selectedItem = initialSelectedItem; + + // Force tree into empty state + EmptyTree(); + + // Create the 'special' nodes + _noneNode = new NoneNode(); + _otherNode = new OtherNode(); + _projectNode = new ProjectNode(this); + if (_designerHost is not null && _designerHost.RootComponent is not null && _designerHost.RootComponent.Site is not null) + { + _instancesNode = new InstancesNode(_designerHost?.RootComponent.Site.Name); + } + else + { + _instancesNode = new InstancesNode(string.Empty); + } + + // Add the 'None' node at the top + _treeViewCtrl?.Nodes.Add(_noneNode); + + if (_showDataSources) + { + // Add form-level data sources + AddFormDataSources(); + + // Add project-level data sources + AddProjectDataSources(); + + // Add the remaining 'special' nodes, if they are required + if (_projectNode.Nodes.Count > 0) + { + _otherNode.Nodes.Add(_projectNode); + } + + if (_instancesNode.Nodes.Count > 0) + { + _otherNode.Nodes.Add(_instancesNode); + } + + if (_otherNode.Nodes.Count > 0) + { + _treeViewCtrl?.Nodes.Add(_otherNode); + } + } + else + { + // Add contents of one specific data source + AddDataSourceContents(_treeViewCtrl?.Nodes, _rootDataSource, _rootDataMember, null); + } + + // If no node was matched to the selected item, just select the 'None' node + _selectedNode ??= _noneNode; + + // Selected node should be recorded now, so clear the selected item. + _selectedItem = null; + + // Set default width (based on items in tree) + Width = Math.Max(Width, _treeViewCtrl is null ? 0 : _treeViewCtrl.PreferredWidth + (SystemInformation.VerticalScrollBarWidth * 2)); + } + + /// + /// Fills the tree view with top-level data source nodes. + /// + private void AddFormDataSources() + { + // VSWhidbey#455147. If the ITypeDescriptorContext does not have a container, grab the container from the + // IDesignerHost. + IContainer? container = null; + if (_context is not null) + { + container = _context.Container; + } + + if (container is null && _designerHost is not null) + { + container = _designerHost.Container; + } + + // Bail if we have no container to work with + if (container is null) + { + return; + } + + container = DesignerUtils.CheckForNestedContainer(container); // ...necessary to support SplitterPanel components + + ComponentCollection components = container.Components; + + // Enumerate the components of the container (eg. the Form) + foreach (IComponent comp in components) + { + // Don't add component to tree if it is the very object who's property the picker + // is setting (ie. don't let a BindingSource's DataSource property point to itself). + if (comp == _context?.Instance) + { + continue; + } + + // Don't add a DataTable to the tree if its parent DataSet is gonna be in the tree. + // (...new redundancy-reducing measure for Whidbey) + if (comp is DataTable && FindComponent(components, (comp as DataTable)?.DataSet)) + { + continue; + } + + // Add tree node for this data source + if (comp is BindingSource) + { + AddDataSource(_treeViewCtrl?.Nodes, comp, null); + } + else + { + AddDataSource(_instancesNode?.Nodes, comp, null); + } + } + } + + /// + /// Adds a tree node representing a data source. Also adds the data source's immediate + /// child data members, so that the node has the correct +/- state by default. + /// + private void AddDataSource(TreeNodeCollection? nodes, IComponent dataSource, string? dataMember) + { + // Don't add node if not showing data sources + if (!_showDataSources) + { + return; + } + + // Don't add node if this is not a valid bindable data source + if (!IsBindableDataSource(dataSource)) + { + return; + } + + // Get properties of this data source + string? getPropsError = null; + PropertyDescriptorCollection? properties = null; + try + { + properties = GetItemProperties(dataSource, dataMember); + if (properties is null) + { + return; + } + } + catch (ArgumentException e) + { + // Exception can occur trying to get list item properties from a data source that's + // in a badly configured state (eg. its data member refers to a property on its + // parent data source that's invalid because the parent's metadata has changed). + getPropsError = e.Message; + } + + // If data source has no properties, and we are in member-picking mode rather than + // source-picking mode, just omit the data source altogether - its useless. + if (_showDataMembers && properties?.Count == 0) + { + return; + } + + // Create node and add to specified nodes collection + DataSourceNode dataSourceNode = new DataSourceNode(this, dataSource, dataSource.Site?.Name); + nodes?.Add(dataSourceNode); + + // If this node matches the selected item, make it the selected node + if (_selectedItem is not null && _selectedItem.Equals(dataSource, "")) + { + _selectedNode = dataSourceNode; + } + + // Since a data source is added directly to the top level of the tree, rather than + // revealed by user expansion, we need to fill in its children and grand-children, + // and mark it as 'filled'. + if (getPropsError is null) + { + // Properties were good: Add them underneath the data source node now + AddDataSourceContents(dataSourceNode.Nodes, dataSource, dataMember, properties); + dataSourceNode.SubNodesFilled = true; + } + else + { + // Properties were bad: Tag the data source with the error message and show the + // data source as grayed. Error message will appear in help text for that data + // source, and will prevent user from being able to select the data source. + dataSourceNode.Error = getPropsError; + dataSourceNode.ForeColor = SystemColors.GrayText; + } + } + + /// + /// Adds a set of tree nodes representing the immediate child data members of a data source. + /// + private void AddDataSourceContents(TreeNodeCollection? nodes, object? dataSource, string? dataMember, PropertyDescriptorCollection? properties) + { + // Don't add nodes if not showing data members (except for BindingSources, we always want to show list members) + if (!_showDataMembers && !(dataSource is BindingSource)) + { + return; + } + + // Special case: Data source is a list type (or list item type) rather than a list instance. + // Arises when some component's DataSource property is bound to a Type, and the user opens the dropdown for the DataMember property. + // We need to create a temporary instance of the correct list type, and use that as our data source for the purpose of determining + // data members. Since only BindingSource supports type binding, we bind a temporary BindingSource to the specified type - it will + // create an instance of the correct list type for us. Fixes VSWhidbey bugs 302757 and 280708. + if (dataSource is Type) + { + try + { + BindingSource bindingSource = new BindingSource(); + bindingSource.DataSource = dataSource; + dataSource = bindingSource.List; + } + catch (Exception ex) + { + if (ExceptionExtensions.IsCriticalException(ex)) + { + throw; + } + } + } + + // Don't add nodes if this is not a valid bindable data source + if (!IsBindableDataSource(dataSource)) + { + return; + } + + // Get properties of this data source (unless already supplied by caller) + if (properties is null) + { + properties = GetItemProperties(dataSource, dataMember); + if (properties is null) + { + return; + } + } + + // Enumerate the properties of the data source + for (int i = 0; i < properties.Count; ++i) + { + PropertyDescriptor property = properties[i]; + + // Skip properties that do not represent bindable data members + if (!IsBindableDataMember(property)) + { + continue; + } + + // Add a data member node for this property + string dataField = string.IsNullOrEmpty(dataMember) ? property.Name : dataMember + "." + property.Name; + AddDataMember(nodes, dataSource, dataField, property.Name, IsListMember(property)); + } + } + + /// + /// Adds a tree node representing a data member. Also adds the data member's immediate + /// child data members, so that the node has the correct +/- state by default. + /// + private void AddDataMember(TreeNodeCollection? nodes, object? dataSource, string dataMember, string propertyName, bool isList) + { + // Special rules for BindingSources... + // + // - Standard control bindings access data through a BindingContext, which supports 'dot' notation + // in the DataMember property (eg. "Customers.Orders.Quantity") to indicate sub-lists (for complex + // binding) or fields in sub-lists (for simple bindings). + // + // - BindingSources so not go through a BindingContext and so do not support the 'dot' notation. + // Sub-lists are accessed by 'chaining' BindingSources together. + // + // So we must prevent the user from being able to create a binding that would result in the + // DataMember property of a BindingSource containing 'dot' notation. To achieve this, we must + // flatten certain parts of the tree so that nested sub-members cannot be reached. Specifically... + // + // (a) We flatten the tree under every node that represents a BindingSource + // (b) If the edited object is a BindingSource, we flatten the tree under every data source node + // + bool isBindingSourceListMember = isList && dataSource is BindingSource; + bool pickingFieldMembers = _showDataMembers && !_selectListMembers; + bool omitMember = isBindingSourceListMember && pickingFieldMembers; + bool omitMemberContents = (isBindingSourceListMember && !pickingFieldMembers) || _context?.Instance is BindingSource; + + // Just omit this member when necessary + if (omitMember) + { + return; + } + + // Don't add node if its not a list but we only want lists + if (_selectListMembers && !isList) + { + return; + } + + // Create node and add to specified nodes collection + DataMemberNode dataMemberNode = new DataMemberNode(this, dataSource, dataMember, propertyName, isList); + nodes?.Add(dataMemberNode); + + // If this node matches the selected item, make it the selected node + if (_selectedItem is not null && _selectedItem.Equals(dataSource, dataMember) && dataMemberNode is not null) + { + _selectedNode = dataMemberNode; + } + + // Add contents of data member underneath the new node + if (!omitMemberContents && dataMemberNode is not null) + { + AddDataMemberContents(dataMemberNode); + } + } + + /// + /// Adds a set of tree nodes representing the immediate child data members of a data member. + /// + /// Note: If one of the nodes lies in the path to the selected item, we recursively start + /// adding its sub-nodes, and so on, until we reach the node for that item. This is needed + /// to allow that node to be auto-selected and expanded when the dropdown first appears. + /// + private void AddDataMemberContents(TreeNodeCollection nodes, object? dataSource, string dataMember, bool isList) + { + // Sanity check for correct use of the SubNodesFilled mechanism + Debug.Assert(nodes.Count == 0, "We only add data member content sub-nodes once."); + + // Don't add nodes for a data member that isn't a list + if (!isList) + { + return; + } + + // Get properties of this data member + PropertyDescriptorCollection? properties = GetItemProperties(dataSource, dataMember); + if (properties is null) + { + return; + } + + // Enumerate the properties of the data source + for (int i = 0; i < properties.Count; ++i) + { + PropertyDescriptor property = properties[i]; + + // Skip properties that do not represent bindable data members + if (!IsBindableDataMember(property)) + { + continue; + } + + // Don't add sub-node if sub-member is not a list but we only want lists + bool isSubList = IsListMember(property); + if (_selectListMembers && !isSubList) + { + continue; + } + + // Add a data member sub-node for this property + DataMemberNode dataMemberNode = new DataMemberNode(this, dataSource, dataMember + "." + property.Name, property.Name, isSubList); + nodes.Add(dataMemberNode); + + // Auto-select support... + if (_selectedItem is not null && _selectedItem.DataSource == dataMemberNode.DataSource) + { + if (_selectedItem.Equals(dataSource, dataMemberNode.DataMember)) + { + // If this node matches the selected item, make it the selected node + _selectedNode = dataMemberNode; + } + else + { + if (!string.IsNullOrEmpty(_selectedItem.DataMember) && + _selectedItem.DataMember.IndexOf(dataMemberNode.DataMember) == 0) + { + // If this node is an ancestor of the selected item, recursively start + // filling out sub-member tree (so that node for selected item will + // end up being created and selected). + AddDataMemberContents(dataMemberNode); + } + } + } + } + } + + /// + /// AddDataMemberContents overload. This version supplies the information + /// about the data member from an existing data member tree node. + /// + private void AddDataMemberContents(TreeNodeCollection nodes, DataMemberNode dataMemberNode) + { + AddDataMemberContents(nodes, dataMemberNode.DataSource, dataMemberNode.DataMember, dataMemberNode.IsList); + } + + /// + /// AddDataMemberContents overload. This version supplies the information + /// about the data member from an existing data member tree node, and adds + /// the contents to that node. + /// + private void AddDataMemberContents(DataMemberNode dataMemberNode) + { + AddDataMemberContents(dataMemberNode.Nodes, dataMemberNode); + } + + /// + /// Add project level data sources under the special 'Project' tree node + /// + private void AddProjectDataSources() + { + if (_dataSourceProviderService is null) + { + return; + } + + // Get the entire set of project-level data sources + DataSourceGroupCollection groups = _dataSourceProviderService.GetDataSources(); + if (groups is null) + { + return; + } + + // If we're gonna be expanding the Project node tree to select a specific + // project data source or data member, just build the entire tree up front + bool addMembers = (_selectedItem is not null && _selectedItem.DataSource is DataSourceDescriptor); + + // Create nodes for every project-level data source + foreach (DataSourceGroup g in groups) + { + if (g is not null) + { + if (g.IsDefault) + { + // Data sources in project's default namespace go directly under 'Project' node + AddProjectGroupContents(_projectNode?.Nodes, g); + } + else + { + // All other data sources are organized into groups + AddProjectGroup(_projectNode?.Nodes, g, addMembers); + } + } + } + + // If required, force top-level data sources to fill in their data members now + if (addMembers) + { + _projectNode?.FillSubNodes(); + } + } + + /// + /// Add node for a given project level data source 'group'. + /// + private void AddProjectGroup(TreeNodeCollection? nodes, DataSourceGroup group, bool addMembers) + { + // Create the group node, add its data sources, and wire it up + ProjectGroupNode groupNode = new ProjectGroupNode(this, group.Name, group.Image); + AddProjectGroupContents(groupNode.Nodes, group); + nodes?.Add(groupNode); + + // If required, force data sources in this group to fill in their data members now + if (addMembers) + { + groupNode.FillSubNodes(); + } + } + + /// + /// Add nodes for data sources in a given project level data source 'group'. + /// + private void AddProjectGroupContents(TreeNodeCollection? nodes, DataSourceGroup group) + { + DataSourceDescriptorCollection dataSources = group.DataSources; + if (dataSources is null) + { + return; + } + + foreach (DataSourceDescriptor dataSourceDescriptor in dataSources) + { + if (dataSourceDescriptor is not null && nodes is not null) + { + AddProjectDataSource(nodes, dataSourceDescriptor); + } + } + } + + /// + /// Add a node for a single project level data source. + /// + private void AddProjectDataSource(TreeNodeCollection nodes, DataSourceDescriptor descriptor) + { + // Create and add the project data source tree node + // + + // vsw 477085: don't add the project data source if it points to a virtual type. + Type? type = GetType(descriptor.TypeName, true, true); + if (type is not null && type.GetType() != runtimeType) + { + return; + } + + ProjectDataSourceNode projectDataSourceNode = new ProjectDataSourceNode(this, descriptor, descriptor.Name, descriptor.Image); + nodes.Add(projectDataSourceNode); + + // Auto-select this new node if it corresponds to the current selection (ie. current value) + // + if (_selectedItem is not null && string.IsNullOrEmpty(_selectedItem.DataMember)) + { + // If the current selection is a project-level data source, see if this node has the same name. + // - The current selection normally refers to a form-level instance of a data source; the only + // time the current selection will be a project-level data source is when the user has created + // a new one using the 'Add' wizard and we want to show it selected afterwards. + // + if (_selectedItem.DataSource is DataSourceDescriptor && _selectedItem.DataSource is DataSourceDescriptor dataSourceDescriptor && + string.Equals(descriptor.Name, dataSourceDescriptor.Name, StringComparison.OrdinalIgnoreCase)) + { + _selectedNode = projectDataSourceNode; + } + + // If the current selection is a simple type, see if this node refers to the same type. + // - Bindable components can specify an item type as their data source at design time, which + // provides the necessary metadata info for the designer. The assumption is that the 'real' + // data source instance (that actually returns items of that type) gets supplied at run-time + // by customer code. + else if (_selectedItem.DataSource is Type && _selectedItem.DataSource is Type type_ && + string.Equals(descriptor.TypeName, type_.FullName, StringComparison.OrdinalIgnoreCase)) + { + _selectedNode = projectDataSourceNode; + } + } + } + + /// + /// Add the data member nodes for a project level data source. + /// + private void AddProjectDataSourceContents(TreeNodeCollection nodes, DataSourceNode projectDataSourceNode) + { + DataSourceDescriptor? dataSourceDescriptor = projectDataSourceNode.DataSource as DataSourceDescriptor; + if (dataSourceDescriptor is null) + { + return; + } + + // Get data source type + Type? dataSourceType = GetType(dataSourceDescriptor.TypeName, false, false); + if (dataSourceType is null) + { + return; + } + + // If data source type is instancable, create an instance of it, otherwise just use the type itself + object? dataSourceInstance = dataSourceType; + try + { + dataSourceInstance = Activator.CreateInstance(dataSourceType); + } + catch (Exception ex) + { + if (ExceptionExtensions.IsCriticalException(ex)) + { + throw; + } + } + + // Is this data source just a "list of lists"? (eg. DataSet is just a set of DataTables) + bool isListofLists = (dataSourceInstance is IListSource listSource) && listSource.ContainsListCollection; + + // Fix for VSWhidbey#223724: + // When offering choices for the DataSource of a BindingSource, we want to stop the user from being able to pick a table under + // a data set, since this implies a DS/DM combination, requiring us to create a new 'related' BindingSource. We'd rather the + // user just picked the data set as the DS, and then set the DM to the table, and avoid creating a redundant BindingSource. + if (isListofLists && _context?.Instance is BindingSource) + { + return; + } + + // Determine the properties of the data source + PropertyDescriptorCollection properties = ListBindingHelper.GetListItemProperties(dataSourceInstance); + if (properties is null) + { + return; + } + + // Add data members for each property + foreach (PropertyDescriptor pd in properties) + { + // Skip properties that do not represent bindable data members + if (!IsBindableDataMember(pd)) + { + continue; + } + + // Skip properties that are not browsable + if (!pd.IsBrowsable) + { + continue; + } + + // Don't add sub-node if member is not a list but we only want lists + bool isSubList = IsListMember(pd); + if (_selectListMembers && !isSubList) + { + continue; + } + + // If data source is a "list of lists", then include list members + // representing its sub-lists. Otherwise only include field members. + if (!isListofLists && isSubList) + { + continue; + } + + // Add data member and also its contents (ie. sub-members) + AddProjectDataMember(nodes, dataSourceDescriptor, pd, dataSourceInstance, isSubList); + } + } + + /// + /// AddProjectDataSourceContents overload. + /// + private void AddProjectDataSourceContents(DataSourceNode projectDataSourceNode) + { + AddProjectDataSourceContents(projectDataSourceNode.Nodes, projectDataSourceNode); + } + + /// + /// Add a node for a single data member of a project level data source. + /// + private void AddProjectDataMember(TreeNodeCollection nodes, + DataSourceDescriptor dataSourceDescriptor, + PropertyDescriptor propertyDescriptor, + object? dataSourceInstance, + bool isList) + { + // vsw 477085: don't add the project data source if it points to a virtual type. + Type? dsType = GetType(dataSourceDescriptor.TypeName, true, true); + if (dsType is not null && dsType.GetType() != runtimeType) + { + return; + } + + DataMemberNode projectDataMemberNode = new ProjectDataMemberNode(this, dataSourceDescriptor, propertyDescriptor.Name, propertyDescriptor.Name, isList); + nodes.Add(projectDataMemberNode); + AddProjectDataMemberContents(projectDataMemberNode, dataSourceDescriptor, propertyDescriptor, dataSourceInstance); + } + + /// + /// Add nodes for the sub-members of a data member under a project level data source. + /// + private void AddProjectDataMemberContents(TreeNodeCollection nodes, + DataMemberNode projectDataMemberNode, + DataSourceDescriptor dataSourceDescriptor, + PropertyDescriptor propertyDescriptor, + object? dataSourceInstance) + { + // List members under project data sources are only shown to a certain depth, + // and should already have all been created by the time we get here. So if + // we're not adding field members, there's nothing more to do. + if (_selectListMembers) + { + return; + } + + // If its not a list member, it can't have any sub-members + if (!projectDataMemberNode.IsList) + { + return; + } + + // Need data source instance or data source type to determine properties of list member + if (dataSourceInstance is null) + { + return; + } + + // Determine properties of list member + PropertyDescriptorCollection properties = ListBindingHelper.GetListItemProperties(dataSourceInstance, new PropertyDescriptor[] { propertyDescriptor }); + if (properties is null) + { + return; + } + + // Add field member for each property + foreach (PropertyDescriptor descriptor in properties) + { + // Skip properties that do not represent bindable data members + if (!IsBindableDataMember(descriptor)) + { + continue; + } + + // Skip properties that are not browsable + if (!descriptor.IsBrowsable) + { + continue; + } + + // We only add field members (no nesting of list members under project data sources) + bool isSubList = IsListMember(descriptor); + if (isSubList) + { + continue; + } + + // Add the field member (without contents) + AddProjectDataMember(nodes, dataSourceDescriptor, descriptor, dataSourceInstance, isSubList); + } + } + + /// + /// AddProjectDataMemberContents overload. + /// + private void AddProjectDataMemberContents(DataMemberNode projectDataMemberNode, + DataSourceDescriptor dataSourceDescriptor, + PropertyDescriptor propertyDescriptor, + object? dataSourceInstance) + { + AddProjectDataMemberContents(projectDataMemberNode.Nodes, projectDataMemberNode, dataSourceDescriptor, propertyDescriptor, dataSourceInstance); + } + + /// + /// Puts a new BindingSource on the form, with the specified DataSource and DataMember values. + /// + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] + private BindingSource? CreateNewBindingSource(object dataSource, string dataMember) + { + if (_designerHost is null || _dataSourceProviderService is null) + { + return null; + } + + // Create the BindingSource + BindingSource bs = new BindingSource(); + try + { + bs.DataSource = dataSource; + bs.DataMember = dataMember; + } + catch (Exception ex) + { + IUIService? uiService = _serviceProvider?.GetService(typeof(IUIService)) as IUIService; + DataGridViewDesigner.ShowErrorDialog(uiService, ex, this); + return null; + } + + // Give it a name + string bindingSourceName = GetBindingSourceNamePrefix(dataSource, dataMember); + // If we have a service provider then use it to get the camel notation from ToolStripDesigner.NameFromText + if (_serviceProvider is not null) + { + bindingSourceName = ToolStripDesigner.NameFromText(bindingSourceName, bs.GetType(), _serviceProvider); + } + else + { + bindingSourceName += bs.GetType().Name; + } + + // Make sure the name is unique. + string uniqueSiteName = DesignerUtils.GetUniqueSiteName(_designerHost, bindingSourceName); + + DesignerTransaction? trans = _designerHost.CreateTransaction(string.Format(SR.DesignerBatchCreateTool, uniqueSiteName)); + + try + { + // Put it on the form + try + { + _designerHost.Container.Add(bs, uniqueSiteName); + } + + catch (InvalidOperationException ex) + { + trans?.Cancel(); + + IUIService? uiService = _serviceProvider?.GetService(typeof(IUIService)) as IUIService; + DataGridViewDesigner.ShowErrorDialog(uiService, ex, this); + return null; + } + + catch (CheckoutException ex) + { + trans?.Cancel(); + + IUIService? uiService = _serviceProvider?.GetService(typeof(IUIService)) as IUIService; + DataGridViewDesigner.ShowErrorDialog(uiService, ex, this); + return null; + } + + // Notify the provider service that a new form object is referencing this project-level data source + _dataSourceProviderService.NotifyDataSourceComponentAdded(bs); + if (trans is not null) + { + trans.Commit(); + trans = null; + } + } + + finally + { + trans?.Cancel(); + } + + return bs; + } + + /// + /// CreateNewBindingSource overload, for project-level data sources. + /// + private BindingSource? CreateNewBindingSource(DataSourceDescriptor dataSourceDescriptor, string dataMember) + { + if (_designerHost is null || _dataSourceProviderService is null) + { + return null; + } + + // Find or create a form-level instance of this project-level data source + object? dataSource = GetProjectDataSourceInstance(dataSourceDescriptor); + if (dataSource is null) + { + return null; + } + + // Create a BindingSource that points to the form-level instance + return CreateNewBindingSource(dataSource, dataMember); + } + + /// + /// Chooses the best name prefix for a new BindingSource, based on the + /// data source and data member that the binding source is bound to. + /// + private static string GetBindingSourceNamePrefix(object dataSource, string dataMember) + { + // Always use the data member string, if one is available + if (!string.IsNullOrEmpty(dataMember)) + { + return dataMember; + } + + // Data source should never be null + if (dataSource is null) + { + return ""; + } + + // If data source is a type, use the name of the type + Type? type = (dataSource as Type); + if (type is not null) + { + return type.Name; + } + + // If data source is a form component, use its sited name + IComponent? component = (dataSource as IComponent); + if (component is not null) + { + ISite? site = component.Site; + + if (site is not null && !string.IsNullOrEmpty(site.Name)) + { + return site.Name; + } + } + + // Otherwise just use the type name of the data source + return dataSource.GetType().Name; + } + + /// + /// Get the Type with the specified name. If TypeResolutionService is available, + /// use that in preference to using the Type class (since this service can more + /// reliably instantiate project level types). + /// + [SuppressMessage("Trimming", "IL2096:Call to 'Type.GetType' method can perform case insensitive lookup of the type, currently trimming can not guarantee presence of all the matching types.", Justification = "")] + private Type? GetType(string name, bool throwOnError, bool ignoreCase) + { + if (_typeResolutionService is not null) + { + return _typeResolutionService.GetType(name, throwOnError, ignoreCase); + } + else + { + return Type.GetType(name, throwOnError, ignoreCase); + } + } + + /// + /// Finds the form-level instance of a project-level data source. Looks for form components + /// who's type matches that of the project-level data source. If none are found, ask the + /// provider service to add one for us. + /// + /// Note: If the project-level data source is not instance-able, just return its type as + /// the data source to bind to ("simple type binding" case). + /// + private object? GetProjectDataSourceInstance(DataSourceDescriptor dataSourceDescriptor) + { + Type? dsType = GetType(dataSourceDescriptor.TypeName, true, true); + + // Not an instance-able type, so just return the type + if (!dataSourceDescriptor.IsDesignable) + { + return dsType; + } + + // Enumerate the components of the container (eg. the Form) + IContainer? container = _designerHost?.Container; + if (container is not null) + { + foreach (IComponent comp in container.Components) + { + // Return the first matching component we find + if (dsType is not null && dsType.Equals(comp.GetType())) + { + return comp; + } + } + } + + // No existing instances found, so ask provider service to create a new one + try + { + return _dataSourceProviderService?.AddDataSourceInstance(_designerHost, dataSourceDescriptor); + } + catch (InvalidOperationException ex) + { + IUIService? uiService = _serviceProvider?.GetService(typeof(IUIService)) as IUIService; + DataGridViewDesigner.ShowErrorDialog(uiService, ex, this); + return null; + } + catch (CheckoutException ex) + { + IUIService? uiService = _serviceProvider?.GetService(typeof(IUIService)) as IUIService; + DataGridViewDesigner.ShowErrorDialog(uiService, ex, this); + return null; + } + } + + /// + /// See if a component collection contains a given component (simple linear search). + /// + private static bool FindComponent(ComponentCollection components, IComponent? targetComponent) + { + foreach (IComponent component in components) + { + if (component == targetComponent) + { + return true; + } + } + + return false; + } + + /// + /// See if the given object is a valid bindable data source. + /// + private static bool IsBindableDataSource(object? dataSource) + { + // Check for expected interfaces (require at least one) + if (!(dataSource is IListSource || dataSource is IList || dataSource is Array)) + { + return false; + } + + // Check for [ListBindable(false)] attribute + ListBindableAttribute? listBindable = TypeDescriptor.GetAttributes(dataSource)[typeof(ListBindableAttribute)] as ListBindableAttribute; + if (listBindable is not null && !listBindable.ListBindable) + { + return false; + } + + return true; + } + + /// + /// See if the given property represents a bindable data member. + /// + /// [IainHe] Oddly, we always check the [ListBindable] attribute on the property. This makes sense for + /// list members, but seems pretty meaningless for field members. But that's what we've always done, + /// so let's continue to do it. + /// + private static bool IsBindableDataMember(PropertyDescriptor property) + { + // Special case: We want byte arrays to appear as bindable field members. + if (typeof(byte[]).IsAssignableFrom(property.PropertyType)) + { + return true; + } + + // Check for [ListBindable(false)] attribute + ListBindableAttribute? listBindable = property.Attributes[typeof(ListBindableAttribute)] as ListBindableAttribute; + if (listBindable is not null && !listBindable.ListBindable) + { + return false; + } + + return true; + } + + /// + /// See if the given property represents a list member rather than a field member. + /// + private static bool IsListMember(PropertyDescriptor property) + { + // Special case: We want byte arrays to appear as bindable field members + if (typeof(byte[]).IsAssignableFrom(property.PropertyType)) + { + return false; + } + + // If you assign an IList to it, then its a list member + if (typeof(IList).IsAssignableFrom(property.PropertyType)) + { + return true; + } + + return false; + } + + /// + /// For a data source, or a data member that's a list, this method returns a + /// description of the properties possessed by items in the underlying list. + /// + private PropertyDescriptorCollection? GetItemProperties(object? dataSource, string? dataMember) + { + if (dataSource is null) + { + return null; + } + + CurrencyManager? listManager = _bindingContext?[dataSource, dataMember] as CurrencyManager; + return listManager?.GetItemProperties(); + } + + /// + /// Update roll-over help text as user mouses from tree node to tree node. + /// + /// Basic rules... + /// - If the mouse is over a node, the node usually supplies its own help text. + /// - Else if there is an existing selection, report that as the current binding. + /// - Else just display some general picker help text. + /// + /// The goal of the general text is to provide help in 'initial use and set up' scenarios, + /// to guide the user through the set of steps needed to create their first binding. The + /// general text cases below get progressively further "back in time" as you go down. + /// + /// Note: All help text strings are geared specifically towards the context of a picker + /// that is showing data sources. So when the picker is just showing data members (scoped + /// to a specific data source), the help text area will be hidden. + /// + private void UpdateHelpText(BindingPickerNode? mouseNode) + { + if (_instancesNode is null) + { + return; + } + + // See if node under mouse wants to supply its own help text + string? mouseNodeHelpText = mouseNode?.HelpText; + string? mouseNodeErrorText = mouseNode?.Error; + + // Set the colors... + if (mouseNodeHelpText is not null || mouseNodeErrorText is not null) + { + _helpTextCtrl.BackColor = SystemColors.Info; + _helpTextCtrl.ForeColor = SystemColors.InfoText; + } + else + { + _helpTextCtrl.BackColor = SystemColors.Window; + _helpTextCtrl.ForeColor = SystemColors.WindowText; + } + + // Set the text... + if (mouseNodeErrorText is not null) + { + // This node has an ERROR associated with it + _helpTextCtrl.Text = mouseNodeErrorText; + } + else if (mouseNodeHelpText is not null) + { + // Node specific help text + _helpTextCtrl.Text = mouseNodeHelpText; + } + else if (_selectedNode is not null && _selectedNode != _noneNode) + { + // Already bound to something (user has experience) + _helpTextCtrl.Text = string.Format(CultureInfo.CurrentCulture, (SR.DesignBindingPickerHelpGenCurrentBinding), _selectedNode.Text); + } + else if (!_showDataSources) + { + // No data sources, so this is just a simple data member pick list + _helpTextCtrl.Text = (_treeViewCtrl?.Nodes.Count > 1) ? (SR.DesignBindingPickerHelpGenPickMember) : ""; + } + else if (_treeViewCtrl?.Nodes.Count > 1 && _treeViewCtrl.Nodes[1] is DataSourceNode) + { + // BindingSources exist - tell user to pick one + _helpTextCtrl.Text = (SR.DesignBindingPickerHelpGenPickBindSrc); + } + else if (_instancesNode.Nodes.Count > 0 || _projectNode?.Nodes.Count > 0) + { + // Data sources exist - tell user to pick one + _helpTextCtrl.Text = (SR.DesignBindingPickerHelpGenPickDataSrc); + } + else if (_addNewPanel.Visible) + { + // No data sources - tell user how to create one + _helpTextCtrl.Text = (SR.DesignBindingPickerHelpGenAddDataSrc); + } + else + { + // No data sources, and no way to create one! + _helpTextCtrl.Text = ""; + } + } + + /// + /// Always pass focus down to tree control (so that selection is always visible) + /// + protected override void OnGotFocus(EventArgs e) + { + base.OnGotFocus(e); + _treeViewCtrl?.Focus(); + } + + /// + /// Updates the state of the control when shown or hidden. When shown, we make sure + /// the current selection is visible, and start listening to node expand events (so + /// we can fill the tree as the user drills down). + /// + protected override void OnVisibleChanged(EventArgs e) + { + base.OnVisibleChanged(e); + + if (Visible) + { + ShowSelectedNode(); + } + } + + /// + /// Enforces the control's minimum width and height. + /// + protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) + { + if ((specified & BoundsSpecified.Width) == BoundsSpecified.Width) + { + width = Math.Max(width, _minimumWidth); + } + + if ((specified & BoundsSpecified.Height) == BoundsSpecified.Height) + { + height = Math.Max(height, _minimumHeight); + } + + base.SetBoundsCore(x, y, width, height, specified); + } + + /// + /// Handle click on the "Add Project Data Source" link label. + /// + private void addNewCtrl_Click(object? sender, LinkLabelLinkClickedEventArgs e) + { + // No provider service, or provider won't allow creation of new data sources right now + if (_dataSourceProviderService is null || !_dataSourceProviderService.SupportsAddNewDataSource) + { + return; + } + + // Invoke the 'Add' wizard + DataSourceGroup newProjectDataSources = _dataSourceProviderService.InvokeAddNewDataSource(this, FormStartPosition.CenterScreen); + + // Wizard was cancelled or did not create any new data sources + if (newProjectDataSources is null || newProjectDataSources.DataSources.Count == 0) + { + return; + } + + // Rule: If multiple data sources were created, just use the first one. + DataSourceDescriptor newProjectDataSource = newProjectDataSources.DataSources[0]; + + // Update tree to include the new data source (and select it) + FillTree(new DesignBinding(newProjectDataSource, "")); + + // If we weren't able to select the node representing the new data + // source, then something has gone horribly wrong - bail out now! + if (_selectedNode is null) + { + Debug.Fail("Failed to select new project-level data source in DesignBindingPicker tree."); + return; + } + + // Count the number of data members under this data source + int dataMemberCount = _selectedNode.Nodes.Count; + + // + // Decide what to do with the new data source... + // + + if (_context?.Instance is BindingSource) + { + // Bindable object is a BindingSource - no choice, must bind to data source + _treeViewCtrl?.SetSelectedItem(_selectedNode); + } + + if (dataMemberCount == 0 || _context?.Instance is BindingSource) + { + // Zero data members - bind to the data source + _treeViewCtrl?.SetSelectedItem(_selectedNode); + } + else if (dataMemberCount == 1) + { + // One data member - bind to that data member + _treeViewCtrl?.SetSelectedItem(_selectedNode.Nodes[0]); + } + else + { + // Multiple data members - stay open and show them all + ShowSelectedNode(); + _selectedNode.Expand(); + _selectedNode = null; + UpdateHelpText(null); + } + } + + /// + /// Update roll-over help text as user mouses from tree node to tree node. + /// + private void treeViewCtrl_MouseMove(object? sender, MouseEventArgs e) + { + // Get the tree node under the mouse + Point pt = new Point(e.X, e.Y); + TreeNode? node = _treeViewCtrl?.GetNodeAt(pt); + + // Make sure point is over the node label, since GetNodeAt() will return + // a node even when the mouse is way off to the far right of that node. + if (node is not null && !node.Bounds.Contains(pt)) + { + node = null; + } + + // Update the help text + UpdateHelpText(node as BindingPickerNode); + } + + /// + /// Reset roll-over help text if user mouses away from the tree view. + /// + private void treeViewCtrl_MouseLeave(object? sender, EventArgs e) + { + UpdateHelpText(null); + } + + /// + /// When user expands a tree node to reveal its sub-nodes, we fill in the contents + /// of those sub-nodes, so that their +/- states are correct. In other words, we + /// fill the tree "one level ahead" of what the user has revealed. + /// + private void treeViewCtrl_AfterExpand(object? sender, TreeViewEventArgs tvcevent) + { + // Ignore expansion caused by something other than direct user action (eg. auto-selection) + if (_inSelectNode || !Visible) + { + return; + } + + // Let the node do whatever it wants + (tvcevent.Node as BindingPickerNode)?.OnExpand(); + } + + /// + /// Ensure the initial selection is visible (ie. select the corresponding + /// tree node, which also causes auto-expand of all ancestor nodes). + /// + /// Note: Posting has to be used here because the tree view control won't + /// let us select nodes until all the underlying Win32 HTREEITEMs have + /// been created. + /// + private void ShowSelectedNode() + { + PostSelectTreeNode(_selectedNode); + } + + /// + /// Selects a given node in the tree view. Because the tree view will auto-expand any + /// ancestor nodes, in order to make the selected node visible, we have to temporarily + /// turn off a couple of things until selection is finished: (a) painting; (b) processing + /// of 'node expand' events. + /// + private void SelectTreeNode(TreeNode? node) + { + if (_inSelectNode) + { + return; + } + + try + { + _inSelectNode = true; + _treeViewCtrl?.BeginUpdate(); + _treeViewCtrl!.SelectedNode = node; + _treeViewCtrl?.EndUpdate(); + } + finally + { + _inSelectNode = false; + } + } + + /// + /// The following methods exist to support posted (ie. delayed) selection of tree nodes... + /// + private delegate void PostSelectTreeNodeDelegate(TreeNode node); + + private void PostSelectTreeNodeCallback(TreeNode node) + { + SelectTreeNode(null); + SelectTreeNode(node); + } + + private void PostSelectTreeNode(TreeNode? node) + { + if (node is not null && IsHandleCreated) + { + BeginInvoke(PostSelectTreeNodeCallback, new object[] { node }); + } + } + + /// + /// Label control that renders its text with both word wrapping, end ellipsis and partial line clipping. + /// + internal class HelpTextLabel : Label + { + protected override void OnPaint(PaintEventArgs e) + { + TextFormatFlags formatFlags = TextFormatFlags.WordBreak | TextFormatFlags.EndEllipsis | TextFormatFlags.TextBoxControl; + Rectangle rect = new Rectangle(ClientRectangle.Location, ClientRectangle.Size); + rect.Inflate(-2, -2); + TextRenderer.DrawText(e.Graphics, Text, Font, rect, ForeColor, formatFlags); + } + } + + /// + /// Link label used by the DesignBindingPicker to display links. + /// + internal class BindingPickerLink : LinkLabel + { + /// + /// Allow "Return" as an input key (so it allows the link to fire, instead of closing the parent dropdown). + /// + protected override bool IsInputKey(Keys key) + { + return (key == Keys.Return) || base.IsInputKey(key); + } + + private bool _showFocusCues; + + protected override bool ShowFocusCues => _showFocusCues; + + protected override void OnGotFocus(EventArgs e) + { + _showFocusCues = true; + base.OnGotFocus(e); + } + + protected override void OnLostFocus(EventArgs e) + { + _showFocusCues = false; + base.OnLostFocus(e); + } + } + + /// + /// Tree view used by the DesignBindingPicker to display data sources and data members. + /// + internal class BindingPickerTree : TreeView + { + // ImageList containing default tree node images, of default unscaled size. + protected internal static readonly ImageList s_defaultImages = CreateUnscaledDefaultImages(); + + private static ImageList CreateUnscaledDefaultImages() + { + Bitmap images = new(typeof(DesignBindingPicker), "DataPickerImages.bmp"); + images.MakeTransparent(Color.Magenta); + + ImageList defaultImages = new() + { + TransparentColor = Color.Magenta, + ColorDepth = ColorDepth.Depth24Bit + }; + defaultImages.Images.AddStrip(images); + + return defaultImages; + } + + private static ImageList CreateCopy(ImageList imageList) + { + ImageList copy = new() + { + TransparentColor = Color.Magenta, + ColorDepth = ColorDepth.Depth24Bit + }; + + foreach (Image image in imageList.Images) + { + copy.Images.Add(image); + } + + return copy; + } + + private static ImageList CreateScaledCopy(ImageList imageList, int dpi) + { + Size scaledSize = DpiHelper.LogicalToDeviceUnits(imageList.ImageSize, dpi); + + ImageList copy = new() + { + TransparentColor = Color.Magenta, + ColorDepth = ColorDepth.Depth24Bit, + ImageSize = scaledSize + }; + + foreach (Image image in imageList.Images) + { + Bitmap scaledImage = DpiHelper.CreateResizedBitmap((Bitmap)image, scaledSize); + copy.Images.Add(scaledImage); + } + + return copy; + } + + // Cache of ImageList-s for each DPI to which this tree was scaled. + // Cleared every time DesignBindingPicker dropdown is closed. + // Every instance of BindingPickerTree has it's own cache, + // but the basic set of images is shared, see s_defaultImages. + private readonly Dictionary _imageListCacheByDPI = new(); + private int _dpi = (int)DpiHelper.LogicalDpi; + + internal BindingPickerTree() + { + ResetImages(); + } + + internal void ResetImages() + { + // reset current DPI to logical (96) + _dpi = (int)DpiHelper.LogicalDpi; + + // Clear scaled images cache + foreach (var imageList in _imageListCacheByDPI.Values) + { + imageList.Dispose(); + } + + _imageListCacheByDPI.Clear(); + + // Set new ImageList containing only unscaled default images + ImageList?.Dispose(); + ImageList = CreateCopy(s_defaultImages); + + // Cache current ImageList instance as default for scaling + _imageListCacheByDPI.Add((int)DpiHelper.LogicalDpi, ImageList); + } + + internal void RescaleImages(int dpi) + { + if (!IsHandleCreated) + { + return; + } + + if (dpi == _dpi) + { + return; + } + + _dpi = dpi; + + // Get ImageList from cache or create new one from unscaled + if (!_imageListCacheByDPI.TryGetValue(dpi, out ImageList? scaledImageList)) + { + ImageList unscaledImageList = _imageListCacheByDPI[(int)DpiHelper.LogicalDpi]; + scaledImageList = CreateScaledCopy(unscaledImageList, dpi); + _imageListCacheByDPI.Add(dpi, scaledImageList); + } + + ImageList = scaledImageList; + } + + internal int PreferredWidth + => GetMaxItemWidth(Nodes); + + /// + /// Calculate the maximum width of the nodes in the collection recursively. + /// Only walks the existing set of expanded visible nodes. Does NOT expand + /// unexpanded nodes, since tree may contain endless cyclic relationships. + /// + private static int GetMaxItemWidth(TreeNodeCollection nodes) + { + var maxWidth = 0; + + foreach (TreeNode node in nodes) + { + Rectangle bounds = node.Bounds; + var w = bounds.Left + bounds.Width; + maxWidth = Math.Max(w, maxWidth); + + if (node.IsExpanded) + maxWidth = Math.Max(maxWidth, GetMaxItemWidth(node.Nodes)); + } + + return maxWidth; + } + + /// + /// Processes user selection of tree node. If node is selectable, notifies + /// node of selection, retrieves data source and data member info for the + /// caller, and closes the dropdown. + /// + public void SetSelectedItem(TreeNode node) + { + if (!(Parent is DesignBindingPicker picker)) + { + return; + } + + var pickerNode = node as BindingPickerNode; + picker._selectedItem = pickerNode is not null && pickerNode.CanSelect && pickerNode.Error is null ? pickerNode.OnSelect() : null; + + if (picker._selectedItem is not null) + { + picker.CloseDropDown(); + } + } + + /// + /// Process a mouse click on a node. + /// + /// NOTE: Overriding OnAfterSelect() to handle selection changes is not sufficient because of a ComCtl32 quirk: + /// Clicking on the *current* selection does not trigger a selection change notification. And we need to support + /// re-selection of the current selection in certain scenarios. So instead of using OnAfterSelect(), we use + /// OnNodeMouseClick(), and use hit-testing to see whether the node's image or label were clicked. + /// + protected override void OnNodeMouseClick(TreeNodeMouseClickEventArgs e) + { + TreeViewHitTestInfo treeViewHitTestInfo = HitTest(new Point(e.X, e.Y)); + if (treeViewHitTestInfo.Node == e.Node && + (treeViewHitTestInfo.Location == TreeViewHitTestLocations.Image || + treeViewHitTestInfo.Location == TreeViewHitTestLocations.Label)) + { + SetSelectedItem(e.Node); + } + + base.OnNodeMouseClick(e); + } + + /// + /// Treat "Return" as a mouse click select of a node. + /// + protected override void OnKeyUp(KeyEventArgs e) + { + base.OnKeyUp(e); + + if (e.KeyData == Keys.Return && SelectedNode is not null) + { + SetSelectedItem(SelectedNode); + } + } + + /// + /// Allow "Return" as an input key. + /// + protected override bool IsInputKey(Keys key) + { + return key == Keys.Return || base.IsInputKey(key); + } + } + + /// + /// Base class for all nodes in the tree view. + /// + internal class BindingPickerNode : TreeNode + { + private string? _error; + private bool _subNodesFilled; + protected DesignBindingPicker? _picker; + + public BindingPickerNode(DesignBindingPicker picker, string? nodeName) : base(nodeName) + { + _picker = picker; + } + + public BindingPickerNode(DesignBindingPicker? picker, string nodeName, BindingImage index) : base(nodeName) + { + _picker = picker; + BindingImageIndex = (int)index; + } + + /// + /// Given a data source, return the corresponding BindingImageIndex. + /// + public static BindingImage BindingImageIndexForDataSource(object? dataSource) + { + if (dataSource is BindingSource) + { + return BindingImage.BindingSource; + } + + IListSource? ils = dataSource as IListSource; + if (ils is not null) + { + if (ils.ContainsListCollection) + { + return BindingImage.DataSource; + } + else + { + return BindingImage.ListMember; + } + } + else if (dataSource is IList) + { + return BindingImage.ListMember; + } + else + { + return BindingImage.FieldMember; + } + } + + // Called when a node is expanded by the user + public virtual void OnExpand() + { + FillSubNodes(); + } + + // Forces the node's children to populate themeselves, so that their +/- states are correct + // when parent node is first expanded. If children have already been filled, does nothing. + public virtual void FillSubNodes() + { + // Sub-nodes already filled - nothing more to do here + if (SubNodesFilled) + { + return; + } + + // Fill in the contents of each sub-node + foreach (BindingPickerNode node in Nodes) + { + node.Fill(); + } + + // Mark the expanded node as filled + SubNodesFilled = true; + } + + // Fills node with its child nodes (usually called by parent node's OnExpand method) + public virtual void Fill() + { + } + + // Called when node is selected by user. Should only be called if node has + // returned 'true' for CanSelect. Node returns a DesignBinding representing + // the data source + data member that it represents. + public virtual DesignBinding? OnSelect() + { + return null; + } + + // Determines whether selecting this node will close the dropdown + public virtual bool CanSelect + { + get + { + return false; + } + } + + // Error message associated with this node + public virtual string? Error + { + get + { + return _error; + } + set + { + _error = value; + } + } + + // Mouse-over help text for this node + public virtual string? HelpText + { + get + { + return null; + } + } + + // Indexes of images in the tree view's image list + public enum BindingImage + { + None = 0, + Other = 1, + Project = 2, + Instances = 3, + BindingSource = 4, + ListMember = 5, + FieldMember = 6, + DataSource = 7, + } + + // Sets both the selected and unselected images to the same thing + public int BindingImageIndex + { + set + { + ImageIndex = value; + SelectedImageIndex = value; + } + } + + // Let's you assign a custom image to a specific tree node. + // The image is automatically added to the tree view's image list. + public Image CustomBindingImage + { + set + { + try + { + ImageList.ImageCollection? images = _picker?._treeViewCtrl?.ImageList?.Images; + if (images is not null) + { + images.Add(value, Color.Transparent); + BindingImageIndex = images.Count - 1; + } + } + catch (Exception) + { + Debug.Assert(false, "DesignBindingPicker failed to add custom image to image list."); + } + } + } + + // Indicates whether this node's child nodes have had their children + // added (we populate the tree one level deeper than the user can see, + // so that the +/- states are correct. + public bool SubNodesFilled + { + get + { + return _subNodesFilled; + } + set + { + Debug.Assert(!_subNodesFilled && value, "we can only set this bit to true once"); + _subNodesFilled = true; + } + } + } + + /// + /// Node representing a data source. + /// + internal class DataSourceNode : BindingPickerNode + { + private object? _dataSource; + + public DataSourceNode(DesignBindingPicker picker, object? dataSource, string? nodeName) : base(picker, nodeName) + { + _dataSource = dataSource; + BindingImageIndex = (int)BindingImageIndexForDataSource(dataSource); + } + + public object? DataSource + { + get + { + return _dataSource; + } + } + + public override DesignBinding OnSelect() + { + return new DesignBinding(DataSource, ""); + } + + public override bool CanSelect + { + get + { + // If data members are included in tree, only + // they can be selected, not data sources. + return _picker is null ? false : !_picker._showDataMembers; + } + } + + // For any data source or data member derived node, we pick the mouse-over text + // from one of 12 possible string resources, based on the node's particular + // combination of data source type (BindingSource, Project data source, or Form + // list instance), node type (data source, list member or field member) and current + // selectability (true or false). + public override string HelpText + { + get + { + string dsType, nodeType, resName, resValue; + + if (DataSource is DataSourceDescriptor) + dsType = "Project"; + else if (DataSource is BindingSource) + dsType = "BindSrc"; + else + dsType = "FormInst"; + + if (this is not DataMemberNode) + nodeType = "DS"; + else if (this is DataMemberNode dataMemberNode && dataMemberNode.IsList) + nodeType = "LM"; + else + nodeType = "DM"; + + try + { + resName = string.Format(CultureInfo.CurrentCulture, "DesignBindingPickerHelpNode{0}{1}{2}", dsType, nodeType, (CanSelect ? "1" : "0")); + resValue = resName; + } + catch + { + resValue = ""; + } + + return resValue; + } + } + } + + /// + /// Node representing a data member. + /// Note: Inherits from DataSourceNode, so be careful when trying to distinguish between these two types. + /// + + internal class DataMemberNode : DataSourceNode + { + private bool isList; + private string dataMember; + + public DataMemberNode(DesignBindingPicker picker, + object? dataSource, + string dataMember, + string dataField, + bool isList) : base(picker, dataSource, dataField) + { + this.dataMember = dataMember; + this.isList = isList; + BindingImageIndex = (int)(isList ? BindingImage.ListMember : BindingImage.FieldMember); + } + + public string DataMember + { + get + { + return dataMember; + } + } + + // List member or field member? + public bool IsList + { + get + { + return isList; + } + } + + public override void Fill() + { + _picker?.AddDataMemberContents(this); + } + + public override DesignBinding OnSelect() + { + if (_picker is not null && _picker._showDataMembers) + { + // Data member picking mode: Return data member info + return new DesignBinding(DataSource, DataMember); + } + else + { + // Data source picking mode: Return data member wrapped in a BindingSource + BindingSource? newBindingSource = _picker?.CreateNewBindingSource(DataSource!, DataMember); + return (newBindingSource is null) ? DesignBinding.Null : new DesignBinding(newBindingSource, ""); + } + } + + public override bool CanSelect + { + get + { + // Only pick list members in 'list mode', field members in 'field mode' + return (_picker is not null && _picker._selectListMembers == IsList); + } + } + } + + /// + /// Node representing the "None" choice. + /// + internal class NoneNode : BindingPickerNode + { + public NoneNode() : base(null, (SR.DesignBindingPickerNodeNone), BindingImage.None) + { + } + + public override DesignBinding OnSelect() + { + return DesignBinding.Null; + } + + public override bool CanSelect + { + get + { + return true; + } + } + + public override string HelpText + { + get + { + return (SR.DesignBindingPickerHelpNodeNone); + } + } + } + + /// + /// Node representing the "Other Data Sources" branch. + /// + internal class OtherNode : BindingPickerNode + { + public OtherNode() : base(null, (SR.DesignBindingPickerNodeOther), BindingImage.Other) + { + } + + public override string HelpText + { + get + { + return (SR.DesignBindingPickerHelpNodeOther); + } + } + } + + /// + /// Node representing the "Form List Instances" branch. + /// + internal class InstancesNode : BindingPickerNode + { + public InstancesNode(string? rootComponentName) : base(null, string.Format(CultureInfo.CurrentCulture, (SR.DesignBindingPickerNodeInstances), rootComponentName), BindingImage.Instances) + { + } + + public override string HelpText + { + get + { + return (SR.DesignBindingPickerHelpNodeInstances); + } + } + } + + /// + /// Node representing the "Project Data Sources" branch. + /// + internal class ProjectNode : BindingPickerNode + { + public ProjectNode(DesignBindingPicker picker) : base(picker, (SR.DesignBindingPickerNodeProject), BindingImage.Project) + { + } + + public override string HelpText + { + get + { + return (SR.DesignBindingPickerHelpNodeProject); + } + } + } + + /// + /// Node representing a group of data sources under the "Project Data Sources" branch. + /// + internal class ProjectGroupNode : BindingPickerNode + { + public ProjectGroupNode(DesignBindingPicker picker, string nodeName, Image image) : base(picker, nodeName, BindingImage.Project) + { + if (image is not null) + { + CustomBindingImage = image; + } + } + + public override string HelpText + { + get + { + return SR.DesignBindingPickerHelpNodeProjectGroup; + } + } + } + + /// + /// Node representing a project level data source. + /// Note: dataSource is always a DataSourceDescriptor. + /// + internal class ProjectDataSourceNode : DataSourceNode + { + public ProjectDataSourceNode(DesignBindingPicker picker, object dataSource, string nodeName, Image image) : base(picker, dataSource, nodeName) + { + if (image is not null) + { + CustomBindingImage = image; + } + } + + public override void OnExpand() + { + // Do nothing (not even call base class). Project data source + // nodes are full populated when added to the tree. + } + + public override void Fill() + { + _picker?.AddProjectDataSourceContents(this); + } + + public override DesignBinding OnSelect() + { + // When user selects a project-level data source (in data source picking mode), + // we (a) create a form-level instance of the data source, (b) create a new + // BindingSource that points to that instance, and (c) return the new BindingSource + // as the data source to bind to. + // + // EXCEPTION: If we are setting the DataSource property of a BindingSource, then + // there is no need to create an intermediate BindingSource. Just return the + // true data source instance for the BindingSource to bind to. + + DataSourceDescriptor? dataSourceDescriptor = DataSource as DataSourceDescriptor; + ITypeDescriptorContext? context = _picker?._context; + if (context is not null && context.Instance is BindingSource && dataSourceDescriptor is not null) + { + object? newDataSource = _picker?.GetProjectDataSourceInstance(dataSourceDescriptor); + if (newDataSource is not null) + { + return new DesignBinding(newDataSource, ""); + } + else + { + return DesignBinding.Null; + } + } + else + { + if (dataSourceDescriptor is not null) + { + BindingSource? newBindingSource = _picker?.CreateNewBindingSource(dataSourceDescriptor, ""); + return (newBindingSource is null) ? DesignBinding.Null : new DesignBinding(newBindingSource, ""); + } + + return DesignBinding.Null; + } + } + } + + /// + /// Node representing a data member under a project level data source. + /// Note: dataSource is always a DataSourceDescriptor. + /// + internal class ProjectDataMemberNode : DataMemberNode + { + public ProjectDataMemberNode(DesignBindingPicker picker, + object dataSource, + string dataMember, + string dataField, + bool isList) : base(picker, dataSource, dataMember, dataField, isList) + { + } + + public override void OnExpand() + { + // Do nothing (not even call base class). All project data + // members get added when project data source is populated. + } + + public override DesignBinding OnSelect() + { + string bindingSourceMember; + string designBindingMember; + + ProjectDataMemberNode? parentListMember = (Parent as ProjectDataMemberNode); + + if (parentListMember is not null) + { + // Field member under list member: Point the BindingSource at list member, and the binding at the field member + bindingSourceMember = parentListMember.DataMember; + designBindingMember = DataMember; + } + else if (IsList) + { + // List member under data source: Point the BindingSource at list member, and the binding at the list member + bindingSourceMember = DataMember; + designBindingMember = ""; + } + else + { + // Field member under data source: Point the BindingSource at the data source, and the binding at the field member + bindingSourceMember = ""; + designBindingMember = DataMember; + } + + // Instance the project data source on the form, and point a BindingSource + // at the appropriate list member of the form instance + DataSourceDescriptor? dataSourceDescriptor = DataSource as DataSourceDescriptor; + + if (dataSourceDescriptor is null) + { + return DesignBinding.Null; + } + + BindingSource? newBindingSource = _picker?.CreateNewBindingSource(dataSourceDescriptor, bindingSourceMember); + return (newBindingSource is null) ? DesignBinding.Null : new DesignBinding(newBindingSource, designBindingMember); + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingValueUIHandler.LocalUIItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingValueUIHandler.LocalUIItem.cs index 8263b93a3f2..668fc760943 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingValueUIHandler.LocalUIItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingValueUIHandler.LocalUIItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingValueUIHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingValueUIHandler.cs index d8bd4586486..8d4c5f7ea0b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingValueUIHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignBindingValueUIHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerActionVerbItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerActionVerbItem.cs index bb9180e6a0c..95f8b6168cf 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerActionVerbItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerActionVerbItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerActionVerbList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerActionVerbList.cs index b4e6f27a516..c1149bef267 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerActionVerbList.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerActionVerbList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.NameExtenderProvider.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.NameExtenderProvider.cs index 400b3013d41..e39e72c907f 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.NameExtenderProvider.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.NameExtenderProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.NameInheritedExtenderProvider.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.NameInheritedExtenderProvider.cs index 9ab41441d13..f79a738eb6f 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.NameInheritedExtenderProvider.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.NameInheritedExtenderProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.cs index d1016330f96..47c1e879de8 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerExtenders.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerFrame.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerFrame.cs index 08ff20a62ba..da16101c22f 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerFrame.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerFrame.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerOptions.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerOptions.cs index 614e3f159a8..8bb46d0ea7d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerOptions.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerOptions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -14,7 +13,7 @@ public class DesignerOptions { private const int MinGridSize = 2; private const int MaxGridSize = 200; - private Size _gridSize = new Size(8, 8); + private Size _gridSize = new(8, 8); /// /// Public GridSize property. diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerToolStripControlHost.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerToolStripControlHost.cs index e9be9d373c5..8a4018febeb 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerToolStripControlHost.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerToolStripControlHost.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -28,7 +27,7 @@ public DesignerToolStripControlHost(Control c) : base(c) /// protected override Size DefaultSize { - get => new Size(92, 22); + get => new(92, 22); } internal GlyphCollection GetGlyphs(ToolStrip parent, GlyphCollection glyphs, Behavior.Behavior standardBehavior) diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerUtils.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerUtils.cs index 086080de480..d7afbc01210 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerUtils.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerUtils.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerVerbToolStripMenuItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerVerbToolStripMenuItem.cs index 70f0cf9c937..2c4c3d6dddd 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerVerbToolStripMenuItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerVerbToolStripMenuItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DockEditor.DockUI.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DockEditor.DockUI.cs index 75b41cc3725..8d27753baaf 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DockEditor.DockUI.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DockEditor.DockUI.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DockEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DockEditor.cs index 8d11fba6fd5..f92e3d64e0d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DockEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DockEditor.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.Drawing.Design; @@ -16,11 +13,11 @@ namespace System.Windows.Forms.Design; [CLSCompliant(false)] public sealed partial class DockEditor : UITypeEditor { - private DockUI _dockUI; + private DockUI? _dockUI; - public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) + public override object? EditValue(ITypeDescriptorContext? context, IServiceProvider provider, object? value) { - if (!provider.TryGetService(out IWindowsFormsEditorService editorService)) + if (!provider.TryGetService(out IWindowsFormsEditorService? editorService)) { return value; } @@ -36,5 +33,5 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide } /// - public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.DropDown; + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext? context) => UITypeEditorEditStyle.DropDown; } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.AxToolboxItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.AxToolboxItem.cs index 42040a35c98..f3064ef3dbd 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.AxToolboxItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.AxToolboxItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.DocumentInheritanceService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.DocumentInheritanceService.cs index 6105ee649ef..83d47d4cdb0 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.DocumentInheritanceService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.DocumentInheritanceService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.cs index b45fa1005d2..7af09139cc9 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -54,10 +53,10 @@ public partial class DocumentDesigner : ScrollableControlDesigner, IRootDesigner // ActiveX support // - private static readonly Guid htmlDesignTime = new Guid("73CEF3DD-AE85-11CF-A406-00AA00C00940"); + private static readonly Guid htmlDesignTime = new("73CEF3DD-AE85-11CF-A406-00AA00C00940"); private Dictionary axTools; - private static readonly TraceSwitch AxToolSwitch = new TraceSwitch("AxTool", "ActiveX Toolbox Tracing"); + private static readonly TraceSwitch AxToolSwitch = new("AxTool", "ActiveX Toolbox Tracing"); private const string AxClipFormat = "CLSID"; private ToolboxItemCreatorCallback toolboxCreator; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EditorServiceContext.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EditorServiceContext.cs index e20f349f6c3..39acda05ef0 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EditorServiceContext.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EditorServiceContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -17,7 +16,7 @@ namespace System.Windows.Forms.Design; internal class EditorServiceContext : IWindowsFormsEditorService, ITypeDescriptorContext { private readonly ComponentDesigner _designer; - private IComponentChangeService _componentChangeSvc; + private IComponentChangeService _componentChangeService; private readonly PropertyDescriptor _targetProperty; internal EditorServiceContext(ComponentDesigner designer) @@ -81,9 +80,9 @@ private IComponentChangeService ChangeService { get { - _componentChangeSvc ??= (IComponentChangeService)((IServiceProvider)this).GetService(typeof(IComponentChangeService)); + _componentChangeService ??= (IComponentChangeService)((IServiceProvider)this).GetService(typeof(IComponentChangeService)); - return _componentChangeSvc; + return _componentChangeService; } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EventHandlerService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EventHandlerService.cs index f702083ced1..7a94322f142 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EventHandlerService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EventHandlerService.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable namespace System.Windows.Forms.Design; @@ -12,17 +9,17 @@ namespace System.Windows.Forms.Design; public sealed class EventHandlerService : IEventHandlerService { // We cache the last requested handler for speed. - private object _lastHandler; - private Type _lastHandlerType; - private EventHandler _changedEvent; + private object? _lastHandler; + private Type? _lastHandlerType; + private EventHandler? _changedEvent; - private readonly LinkedList _handlers = new LinkedList(); + private readonly LinkedList _handlers = new(); /// /// Initializes a new instance of the EventHandlerService class. /// /// The which is being designed. - public EventHandlerService(Control focusWnd) + public EventHandlerService(Control? focusWnd) { FocusWindow = focusWnd; } @@ -30,18 +27,18 @@ public EventHandlerService(Control focusWnd) /// /// Fires an OnEventHandlerChanged event. /// - public event EventHandler EventHandlerChanged + public event EventHandler? EventHandlerChanged { add => _changedEvent += value; remove => _changedEvent -= value; } - public Control FocusWindow { get; } + public Control? FocusWindow { get; } /// /// Gets the currently active event handler of the specified type. /// - public object GetHandler(Type handlerType) + public object? GetHandler(Type handlerType) { ArgumentNullException.ThrowIfNull(handlerType); @@ -57,7 +54,7 @@ public object GetHandler(Type handlerType) Debug.Assert(_handlers.Count > 0, "Should have handlers to look through."); - object handler = _handlers.FirstOrDefault(handlerType.IsInstanceOfType); + object? handler = _handlers.FirstOrDefault(handlerType.IsInstanceOfType); if (handler is not null) { @@ -75,10 +72,8 @@ public void PopHandler(object handler) { ArgumentNullException.ThrowIfNull(handler); - var node = _handlers.Find(handler); - if (node is not null) + if (_handlers.Remove(handler)) { - _handlers.Remove(node); _lastHandler = null; _lastHandlerType = null; OnEventHandlerChanged(EventArgs.Empty); diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FileNameEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FileNameEditor.cs index e5dacd5a457..f22eaec150c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FileNameEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FileNameEditor.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.Drawing.Design; @@ -15,11 +12,11 @@ namespace System.Windows.Forms.Design; [CLSCompliant(false)] public class FileNameEditor : UITypeEditor { - private OpenFileDialog _openFileDialog; + private OpenFileDialog? _openFileDialog; - public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) + public override object? EditValue(ITypeDescriptorContext? context, IServiceProvider provider, object? value) { - if (!provider.TryGetService(out IWindowsFormsEditorService _)) + if (!provider.TryGetService(out IWindowsFormsEditorService? _)) { return value; } @@ -44,7 +41,7 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide } /// - public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.Modal; + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext? context) => UITypeEditorEditStyle.Modal; /// /// Initializes the open file dialog when it is created. This gives you an opportunity to diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FlowLayoutPanelDesigner .cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FlowLayoutPanelDesigner .cs new file mode 100644 index 00000000000..9baf83532bd --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FlowLayoutPanelDesigner .cs @@ -0,0 +1,882 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#nullable disable warnings + +using System.Collections; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing; +using System.Windows.Forms.Design.Behavior; + +namespace System.Windows.Forms.Design; + +/// +/// This class handles all design time behavior for the +/// control. Basically, this designer carefully watches drag operations. During a drag, we attempt to +/// draw an "I" bar for insertion/feedback purposes. When a control is added to our designer, we check +/// some cached state to see if we believe that it needs to be inserted at a particular index. If +/// so, we re-insert the control appropriately. +/// +internal partial class FlowLayoutPanelDesigner : FlowPanelDesigner +{ + private ChildInfo[] _childInfo; + + /// + /// The controls that are actually being dragged -- used for an internal drag. + /// + private List _dragControls; + + private Control _primaryDragControl; + private Point _lastMouseLocation; + + /// + /// Store the maximum height/width of each row/column. + /// + private readonly List<(int Min, int Max, int Size, int LastIndex)> _commonSizes = new(); + + private const int s_invalidIndex = -1; + + /// + /// The index which we will re-insert a newly added child. + /// + private int _insertionIndex = s_invalidIndex; + + /// + /// Tracks the top or left last rendered I-bar location. + /// + private Point _oldPoint1 = Point.Empty; + + /// + /// Tracks the bottom or right last rendered I-bar location. + /// + private Point _oldPoint2 = Point.Empty; + + /// + /// If space for IBar is less than or equal to minIBar we draw a simple IBar. + /// + private const int MinIBar = 10; + private const int IBarHatHeight = 3; + private const int IBarSpace = 2; + private const int IBarHatWidth = 5; + private const int IBarHalfSize = 2; + + private const int IBarLineOffset = IBarHatHeight + IBarSpace; + + /// + /// Since we don't always know which IBar we are going draw we want to invalidate max area. + /// + private readonly int _maxIBarWidth = Math.Max(IBarHalfSize, (IBarHatWidth - 1) / 2); + + public override void Initialize(IComponent component) + { + base.Initialize(component); + + // If the FLP is InheritedReadOnly, so should be all of the children. + if (IsInheritedReadOnly) + { + foreach (var child in Control.Controls) + { + TypeDescriptor.AddAttributes(child, InheritanceAttribute.InheritedReadOnly); + } + } + } + + private FlowLayoutPanel FlowLayoutPanel => (FlowLayoutPanel)Control; + + protected override void PreFilterProperties(IDictionary properties) + { + base.PreFilterProperties(properties); + + PropertyDescriptor flowDirection = (PropertyDescriptor)properties["FlowDirection"]; + + if (flowDirection is not null) + { + properties["FlowDirection"] = TypeDescriptor.CreateProperty(typeof(FlowLayoutPanelDesigner), flowDirection, Array.Empty()); + } + } + + /// + /// This is called to check whether the z-order of dragged controls should be maintained when dropped on a + /// ParentControlDesigner. By default it will, but e.g. FlowLayoutPanelDesigner wants to do its own z-ordering. + /// + /// If this returns true, then the DropSourceBehavior will attempt to set the index of the controls being + /// dropped to preserve the original order (in the dragSource). If it returns false, the index will not + /// be set. + /// + /// If this is set to false, then the DropSourceBehavior will not treat a drag as a local drag even + /// if the dragSource and the dragTarget are the same. This will allow a ParentControlDesigner to hook + /// OnChildControlAdded to set the right child index, since in this case, the control(s) being dragged + /// will be removed from the dragSource and then added to the dragTarget. + /// + protected internal override bool AllowSetChildIndexOnDrop => false; + + protected override bool AllowGenericDragBox => false; + + /// + /// Returns true if flow direction is right-to-left or left-to-right + /// + private bool HorizontalFlow + { + get + { + var direction = FlowLayoutPanel.FlowDirection; + return direction == FlowDirection.RightToLeft + || direction == FlowDirection.LeftToRight; + } + } + + /// + /// Get and cache the selection service + /// + internal ISelectionService SelectionService => GetService(); + + private FlowDirection RTLTranslateFlowDirection(FlowDirection direction) + { + return !IsRtl + ? direction + : direction switch + { + FlowDirection.LeftToRight => FlowDirection.RightToLeft, + FlowDirection.RightToLeft => FlowDirection.LeftToRight, + FlowDirection.TopDown or FlowDirection.BottomUp => direction, + _ => direction, + }; + } + + private bool IsRtl => Control.RightToLeft == RightToLeft.Yes; + + /// + /// Returns a Rectangle representing the margin bounds of the control. + /// + private Rectangle GetMarginBounds(Control control) + { + // If the FLP is RightToLeft.Yes, then the values of Right and Left margins are swapped, + // account for that here. + var bounds = control.Bounds; + var margin = control.Margin; + + return new Rectangle( + bounds.Left - (IsRtl ? margin.Right : margin.Left), + bounds.Top - margin.Top, + bounds.Width + margin.Horizontal, + bounds.Height + margin.Vertical); + } + + /// + /// Called when we receive a DragEnter notification - here we attempt to cache child position and information + /// intended to be used by drag move and drop messages. Basically we pass through the children twice - first + /// we build up an array of rects representing the children bounds (w/margins) and identify where the row/ + /// column changes are. Secondly, we normalize the child rects so that children in each row/column are the + /// same height/width; + /// + private void CreateMarginBoundsList() + { + _commonSizes.Clear(); + + var children = Control.Controls; + if (children.Count == 0) + { + _childInfo = Array.Empty(); + return; + } + + // This will cache row/column placement and alignment info for the children. + _childInfo = new ChildInfo[children.Count]; + + FlowDirection flowDirection = RTLTranslateFlowDirection(FlowLayoutPanel.FlowDirection); + var horizontalFlow = HorizontalFlow; + + int currentMinTopLeft = int.MaxValue; + int currentMaxBottomRight = -1; + int lastOffset = -1; + + if ((horizontalFlow && flowDirection == FlowDirection.RightToLeft) || + (!horizontalFlow && flowDirection == FlowDirection.BottomUp)) + { + lastOffset = int.MaxValue; + } + + Point offset = Control.PointToScreen(Point.Empty); + int i; + + // Pass 1 - store off the original margin rects & identify row/column sizes + for (i = 0; i < children.Count; i++) + { + var currentControl = children[i]; + var marginBounds = GetMarginBounds(currentControl); + var bounds = currentControl.Bounds; + var margin = currentControl.Margin; + + // Fix up bounds such that the IBar is not drawn right on top of the control. + if (horizontalFlow) + { + // Difference between bounds and rect is that we do not adjust top, bottom, height + // If the FLP is RightToLeft.Yes, then the values of Right and Left margins are swapped, account for that here. + bounds.X -= IsRtl ? margin.Right : margin.Left; + // To draw correctly in dead areas + bounds.Width += margin.Horizontal; + // We want the IBar to stop at the very edge of the control. Offset height + // by 1 pixel to ensure that. This is the classic - how many pixels to draw when you + // draw from Bounds.Top to Bounds.Bottom. + bounds.Height -= 1; + } + else + { + // Difference between bounds and rect is that we do not adjust left, right, width + bounds.Y -= margin.Top; + // To draw correctly in dead areas + bounds.Height += margin.Vertical; + // We want the IBar to stop at the very edge of the control. Offset width + // by 1 pixel to ensure that. This is the classic - how many pixels to draw when you + // draw from Bounds.Left to Bounds.Right. + bounds.Width -= 1; + } + + // Convert to screen coordinates. + marginBounds.Offset(offset.X, offset.Y); + bounds.Offset(offset.X, offset.Y); + + _childInfo[i].MarginBounds = marginBounds; + _childInfo[i].ControlBounds = bounds; + _childInfo[i].InSelectionCollection = _dragControls?.Contains(currentControl) == true; + + if (horizontalFlow) + { + // Identify a new row. + if (flowDirection == FlowDirection.LeftToRight ? marginBounds.X < lastOffset : marginBounds.X > lastOffset) + { + Debug.Assert(currentMinTopLeft > 0 && currentMaxBottomRight > 0, "How can we not have a min/max value?"); + if (currentMinTopLeft > 0 && currentMaxBottomRight > 0) + { + _commonSizes.Add(( + currentMinTopLeft, + currentMaxBottomRight, + currentMaxBottomRight - currentMinTopLeft, + i)); + currentMinTopLeft = int.MaxValue; + currentMaxBottomRight = -1; + } + } + + lastOffset = marginBounds.X; + + // Be sure to track the largest row size. + if (marginBounds.Top < currentMinTopLeft) + { + currentMinTopLeft = marginBounds.Top; + } + + if (marginBounds.Bottom > currentMaxBottomRight) + { + currentMaxBottomRight = marginBounds.Bottom; + } + } + else + { + // Identify a new column. + if (flowDirection == FlowDirection.TopDown ? marginBounds.Y < lastOffset : marginBounds.Y > lastOffset) + { + Debug.Assert(currentMinTopLeft > 0 && currentMaxBottomRight > 0, "How can we not have a min/max value?"); + if (currentMinTopLeft > 0 && currentMaxBottomRight > 0) + { + _commonSizes.Add(( + currentMinTopLeft, + currentMaxBottomRight, + currentMaxBottomRight - currentMinTopLeft, + i)); + currentMinTopLeft = int.MaxValue; + currentMaxBottomRight = -1; + } + } + + lastOffset = marginBounds.Y; + + // Be sure to track the column size. + if (marginBounds.Left < currentMinTopLeft) + { + currentMinTopLeft = marginBounds.Left; + } + + if (marginBounds.Right > currentMaxBottomRight) + { + currentMaxBottomRight = marginBounds.Right; + } + } + } + + // Add the last row/column to our common sizes. + if (currentMinTopLeft > 0 && currentMaxBottomRight > 0) + { + // Store off the max size for this row. + _commonSizes.Add(( + currentMinTopLeft, + currentMaxBottomRight, + currentMaxBottomRight - currentMinTopLeft, + i)); + } + + // Pass2 - adjust all controls to max width/height according to their row/column. + var controlIndex = 0; + foreach (var size in _commonSizes) + { + while (controlIndex < size.LastIndex) + { + if (horizontalFlow) + { + // Min is Top, align all controls horizontally. + _childInfo[controlIndex].MarginBounds.Y = size.Min; + _childInfo[controlIndex].MarginBounds.Height = size.Size; + } + else + { + // Min is Left, align controls vertically. + _childInfo[controlIndex].MarginBounds.X = size.Min; + _childInfo[controlIndex].MarginBounds.Width = size.Size; + } + + controlIndex++; + } + } + } + + private string GetTransactionDescription(bool performCopy) + { + if (_dragControls.Count == 1) + { + var name = TypeDescriptor.GetComponentName(_dragControls[0]); + if (string.IsNullOrEmpty(name)) + { + name = _dragControls[0].GetType().Name; + } + + return string.Format(performCopy ? SR.BehaviorServiceCopyControl : SR.BehaviorServiceMoveControl, name); + } + + return string.Format(performCopy ? SR.BehaviorServiceCopyControls : SR.BehaviorServiceMoveControls, _dragControls.Count); + } + + private void DrawIBarBeforeRectangle(Rectangle bounds) + { + switch (RTLTranslateFlowDirection(FlowLayoutPanel.FlowDirection)) + { + case FlowDirection.LeftToRight: + ReDrawIBar(new Point(bounds.Left, bounds.Top), new Point(bounds.Left, bounds.Bottom)); + break; + case FlowDirection.RightToLeft: + ReDrawIBar(new Point(bounds.Right, bounds.Top), new Point(bounds.Right, bounds.Bottom)); + break; + case FlowDirection.TopDown: + ReDrawIBar(new Point(bounds.Left, bounds.Top), new Point(bounds.Right, bounds.Top)); + break; + case FlowDirection.BottomUp: + ReDrawIBar(new Point(bounds.Left, bounds.Bottom), new Point(bounds.Right, bounds.Bottom)); + break; + } + } + + private void DrawIBarAfterRectangle(Rectangle bounds) + { + switch (RTLTranslateFlowDirection(FlowLayoutPanel.FlowDirection)) + { + case FlowDirection.LeftToRight: + ReDrawIBar(new Point(bounds.Right, bounds.Top), new Point(bounds.Right, bounds.Bottom)); + break; + case FlowDirection.RightToLeft: + ReDrawIBar(new Point(bounds.Left, bounds.Top), new Point(bounds.Left, bounds.Bottom)); + break; + case FlowDirection.TopDown: + ReDrawIBar(new Point(bounds.Left, bounds.Bottom), new Point(bounds.Right, bounds.Bottom)); + break; + case FlowDirection.BottomUp: + ReDrawIBar(new Point(bounds.Left, bounds.Top), new Point(bounds.Right, bounds.Top)); + break; + } + } + + private void EraseIBar() + => ReDrawIBar(Point.Empty, Point.Empty); + + /// + /// Given two points, we'll draw an I-Bar. Note that we only erase at our + /// old points if they are different from the new ones. Also note that if + /// the points are empty - we will simply erase and not draw. + /// + private void ReDrawIBar(Point point1, Point point2) + { + var pen = SystemPens.ControlText; + var backColor = Control.BackColor; + if (backColor != Color.Empty && backColor.GetBrightness() < .5) + { + pen = SystemPens.ControlLight; + } + + // Don't off set if point1 is empty. Empty really just means that we want to erase the IBar. + if (point1 != Point.Empty) + { + Point offset = BehaviorService.AdornerWindowToScreen(); + point1.Offset(-offset.X, -offset.Y); + point2.Offset(-offset.X, -offset.Y); + } + + // Only erase the I-Bar if the points are different from last time. + // Only invalidate if there's something to invalidate. + if (point1 != _oldPoint1 && point2 != _oldPoint2 && _oldPoint1 != Point.Empty) + { + var invalidRect = new Rectangle( + _oldPoint1.X, + _oldPoint1.Y, + _oldPoint2.X - _oldPoint1.X + 1, + _oldPoint2.Y - _oldPoint1.Y + 1); + + // Always invalidate max area. + invalidRect.Inflate(_maxIBarWidth, _maxIBarWidth); + BehaviorService.Invalidate(invalidRect); + } + + // Cache this for next time around -- but do so before changing point1 and point2 below. + _oldPoint1 = point1; + _oldPoint2 = point2; + + // If we have valid new points - redraw our I-Bar. + // We always want to redraw the line. This is because part of it could have been erased when + // the drag image (see DropSourceBehavior) is being moved over the IBar. + if (point1.IsEmpty) + { + return; + } + + using Graphics graphics = BehaviorService.AdornerWindowGraphics; + if (HorizontalFlow) + { + if (Math.Abs(point1.Y - point2.Y) <= MinIBar) + { + // Draw the smaller, simpler IBar + graphics.DrawLine(pen, point1, point2); // vertical line + graphics.DrawLine(pen, point1.X - IBarHalfSize, point1.Y, point1.X + IBarHalfSize, point1.Y); // top hat + graphics.DrawLine(pen, point2.X - IBarHalfSize, point2.Y, point2.X + IBarHalfSize, point2.Y); // bottom hat + } + else + { + // Top and bottom hat. + for (int i = 0; i < IBarHatHeight - 1; i++) + { + // Stop 1 pixel before, since we can't draw a 1 pixel line + // reducing the width of the hat with 2 pixel on each iteration + graphics.DrawLine( + pen, + point1.X - (IBarHatWidth - 1 - i * 2) / 2, + point1.Y + i, + point1.X + (IBarHatWidth - 1 - i * 2) / 2, + point1.Y + i); // top hat + + graphics.DrawLine( + pen, + point2.X - (IBarHatWidth - 1 - i * 2) / 2, + point2.Y - i, + point2.X + (IBarHatWidth - 1 - i * 2) / 2, + point2.Y - i); // bottom hat + } + + // Can't draw a 1 pixel line, so draw a vertical line. + graphics.DrawLine(pen, point1.X, point1.Y, point1.X, point1.Y + IBarHatHeight - 1); // top hat + graphics.DrawLine(pen, point2.X, point2.Y, point2.X, point2.Y - IBarHatHeight + 1); // bottom hat + + // Vertical line + graphics.DrawLine(pen, point1.X, point1.Y + IBarLineOffset, point2.X, point2.Y - IBarLineOffset); + } + } + else + { + if (Math.Abs(point1.X - point2.X) <= MinIBar) + { + // Draw the smaller, simpler IBar. + graphics.DrawLine(pen, point1, point2); // horizontal line + graphics.DrawLine(pen, point1.X, point1.Y - IBarHalfSize, point1.X, point1.Y + IBarHalfSize); // top hat + graphics.DrawLine(pen, point2.X, point2.Y - IBarHalfSize, point2.X, point2.Y + IBarHalfSize); // bottom hat + } + else + { + // Left and right hat. + for (int i = 0; i < IBarHatHeight - 1; i++) + { + // Stop 1 pixel before, since we can't draw a 1 pixel line + // reducing the width of the hat with 2 pixel on each iteration. + graphics.DrawLine( + pen, + point1.X + i, + point1.Y - (IBarHatWidth - 1 - i * 2) / 2, + point1.X + i, + point1.Y + (IBarHatWidth - 1 - i * 2) / 2); // left hat + + graphics.DrawLine( + pen, + point2.X - i, + point2.Y - (IBarHatWidth - 1 - i * 2) / 2, + point2.X - i, + point2.Y + (IBarHatWidth - 1 - i * 2) / 2); // right hat + } + + // Can't draw a 1 pixel line, so draw a horizontal line. + graphics.DrawLine(pen, point1.X, point1.Y, point1.X + IBarHatHeight - 1, point1.Y); // left hat + graphics.DrawLine(pen, point2.X, point2.Y, point2.X - IBarHatHeight + 1, point2.Y); // right hat + + // Horizontal line + graphics.DrawLine(pen, point1.X + IBarLineOffset, point1.Y, point2.X - IBarLineOffset, point2.Y); + } + } + } + + private void ReorderControls(DragEventArgs de) + { + var performCopy = de.Effect == DragDropEffects.Copy; + + // create our transaction + DesignerTransaction designerTransaction = TryGetService(out IDesignerHost host) + ? host.CreateTransaction(GetTransactionDescription(performCopy)) + : null; + + // In order to be able to set the index correctly, we need to create a backwards move. + // We do this by first finding the control foo that corresponds to _insertionIndex. + // We then remove all the drag controls from the FLP. + // Then we get the new childIndex for the control foo. + // Finally we loop: + // add the ith drag control + // set its child index to (index of control foo) - 1 + // On each iteration, the child index of control foo will change. + // + // This ensures that we can move both contiguous and non-contiguous selections. + + // Special case when the element we are inserting before is a part of the dragControls. + while (_insertionIndex < _childInfo.Length - 1 && _childInfo[_insertionIndex].InSelectionCollection) + { + // Find the next control that is not a part of the selection. + ++_insertionIndex; + } + + PropertyDescriptor controlsProperty = TypeDescriptor.GetProperties(Component)["Controls"]; + if (controlsProperty is not null) + { + RaiseComponentChanging(controlsProperty); + } + + Control control = null; + var children = Control.Controls; + if (_insertionIndex != _childInfo.Length) + { + control = children[_insertionIndex]; + } + else + { + // We are inserting past the last control. + _insertionIndex = s_invalidIndex; + } + + // We use this list when doing a Drag-Copy, so that we can correctly restore state when we are done. + //List originalControls = new(); + ArrayList originalControls = new(); + + // Remove the controls in the drag collection - don't need to do this if we are copying. + if (!performCopy) + { + foreach (var dragControl in _dragControls) + { + children.Remove(dragControl); + } + + // Get the new index -- if we are performing a copy, then the index is the same. + if (control is not null) + { + _insertionIndex = children.GetChildIndex(control, throwException: false); + } + } + else + { + // We are doing a copy, so let's copy the controls. + //List tempList = new(); + ArrayList tempList = new ArrayList(); + tempList.AddRange(_dragControls); + + DesignerUtils.CopyDragObjects(tempList, Component.Site); + + if (tempList is null) + { + return; + } + + // And stick the copied controls back into the dragControls array. + for (var j = 0; j < tempList.Count; j++) + { + // Save off the old controls first. + originalControls.Add(_dragControls[j]); + + // Remember to set the new primary control. + if (_primaryDragControl.Equals(_dragControls[j])) + { + _primaryDragControl = tempList[j] as Control; + } + + _dragControls[j] = tempList[j] as Control; + } + } + + if (_insertionIndex == s_invalidIndex) + { + // Either _insertionIndex was _childInfo.Length (inserting past the end) or + // _insertionIndex was _childInfo.Length - 1 and the control at that index was also + // a part of the dragCollection. In either case, the new index is equal to the count + // of existing controls in the ControlCollection. Helps to draw this out. + _insertionIndex = children.Count; + } + + children.Add(_primaryDragControl); + children.SetChildIndex(_primaryDragControl, _insertionIndex); + ++_insertionIndex; + + //Set the Selection .. + SelectionService.SetSelectedComponents(new IComponent[] { _primaryDragControl }, SelectionTypes.Primary | SelectionTypes.Replace); + + // Note _dragControls are in opposite order than what FLP uses, + // so add from the end. + for (var i = _dragControls.Count - 1; i >= 0; i--) + { + if (_primaryDragControl.Equals(_dragControls[i])) + { + continue; + } + + children.Add(_dragControls[i]); + children.SetChildIndex(_dragControls[i], _insertionIndex); + ++_insertionIndex; + + SelectionService.SetSelectedComponents(new IComponent[] { _dragControls[i] }, SelectionTypes.Add); + } + + if (controlsProperty is not null) + { + RaiseComponentChanging(controlsProperty); + } + + // If we did a Copy, then restore the old controls to make sure we set state correctly. + if (originalControls is not null) + { + for (var i = 0; i < originalControls.Count; i++) + { + _dragControls[i] = (Control)originalControls[i]; + } + } + + base.OnDragComplete(de); + + designerTransaction.Commit(); + } + + /// + /// When a child is added -we check to see if we cached an index + /// representing where this control should be inserted. If so, we + /// re-insert the new child. + /// This is only done on an external drag-drop. + /// + private void OnChildControlAdded(object sender, ControlEventArgs e) + { + try + { + if (_insertionIndex == s_invalidIndex) + { + return; + } + + // This will only be true on a drag-drop. + PropertyDescriptor controlsProperty = TypeDescriptor.GetProperties(Component)["Controls"]; + + if (controlsProperty is not null) + { + RaiseComponentChanging(controlsProperty); + + // On an external drag/drop, the control will have been inserted at the end, so we can safely + // set the index and increment it, since we are moving the control backwards. Check out + // SetChildIndex and MoveElement. + Control.Controls.SetChildIndex(e.Control, _insertionIndex); + ++_insertionIndex; + RaiseComponentChanging(controlsProperty); + } + } + finally + { + Control.ControlAdded -= OnChildControlAdded; + _insertionIndex = s_invalidIndex; + } + } + + /// + /// When we receive a drag enter notification - we clear our recommended insertion + /// index and mouse location - then call our method to cache all the bounds of the children. + /// + protected override void OnDragEnter(DragEventArgs de) + { + base.OnDragEnter(de); + + _insertionIndex = s_invalidIndex; + _lastMouseLocation = Point.Empty; + _primaryDragControl = null; + + // Get the sorted drag controls. We use these for an internal drag. + if (de.Data is DropSourceBehavior.BehaviorDataObject data) + { + var primaryIndex = -1; + _dragControls = data.GetSortedDragControls(ref primaryIndex).OfType().ToList(); + _primaryDragControl = _dragControls[primaryIndex]; + } + + // Cache all child bounds and identify rows/columns. + CreateMarginBoundsList(); + } + + protected override void OnDragLeave(EventArgs e) + { + EraseIBar(); + + _insertionIndex = s_invalidIndex; + _primaryDragControl = null; + _dragControls?.Clear(); + + base.OnDragLeave(e); + } + + /// + /// During a drag over, if we have successfully cached margin/row/col information + /// we will attempt to render an "I-bar" for the user based on where we think the + /// user is attempting to insert the control at. Note that we also cache off this + /// guessed-index so that if a control is dropped/added we can re-insert it at this + /// spot. + /// + protected override void OnDragOver(DragEventArgs de) + { + base.OnDragOver(de); + + var mouseLocation = new Point(de.X, de.Y); + + if (mouseLocation.Equals(_lastMouseLocation) + || _childInfo is null + || _childInfo.Length == 0 + || _commonSizes.Count == 0) + { + // No layout data to work with. + return; + } + + _lastMouseLocation = mouseLocation; + + Point controlOffset = Control.PointToScreen(Point.Empty); + if (IsRtl) + { + controlOffset.X += Control.Width; + } + + _insertionIndex = s_invalidIndex; + + // Brute force hit testing to first determine if we're over one + // of our margin bounds. + int i; + Rectangle bounds = Rectangle.Empty; + for (i = 0; i < _childInfo.Length; i++) + { + if (_childInfo[i].MarginBounds.Contains(mouseLocation)) + { + bounds = _childInfo[i].ControlBounds; + break; + } + } + + // If we found the bounds - then we need to draw our "I-Beam" + // If the mouse is over one of the MarginBounds, then the dragged control + // will always be inserted before the control the margin area represents. Thus + // we will always draw the I-Beam to the left or above (FlowDirection.LRT | TB) or + // to the right or below (FlowDirection.RTL | BT). + if (!bounds.IsEmpty) + { + // The insertion index will always be the boxed area(called margin area) we are over. + _insertionIndex = i; + if (_childInfo[i].InSelectionCollection) + { + // If the marginBounds is part of the selection, then don't draw the IBar. But actually + // setting insertIndex, will allows us to correctly drop the control in the right place. + EraseIBar(); + } + else + { + DrawIBarBeforeRectangle(bounds); + } + } + else + { + // Here, we're in a dead area - see what row / column we're in for a + // best-guess at the insertion index. + var offset = HorizontalFlow ? controlOffset.Y : controlOffset.X; + foreach (var size in _commonSizes) + { + bool match; + if (IsRtl) + { + // Size is height/width of row/column. + offset -= size.Size; + match = (HorizontalFlow && mouseLocation.Y <= offset) || (!HorizontalFlow && mouseLocation.X >= offset); + } + else + { + offset += size.Size; + match = (HorizontalFlow ? mouseLocation.Y : mouseLocation.X) <= offset; + } + + if (match) + { + _insertionIndex = size.LastIndex; + bounds = _childInfo[_insertionIndex - 1].ControlBounds; + if (_childInfo[_insertionIndex - 1].InSelectionCollection) + { + EraseIBar(); + } + else + { + DrawIBarAfterRectangle(bounds); + } + + break; + } + } + } + + if (_insertionIndex == s_invalidIndex) + { + // Here, we're at the 'end' of the FlowLayoutPanel - not over + // any controls and not in a row/column. + EraseIBar(); + } + } + + /// + /// On a drop, if we have cached a special index where we think a control + /// should be inserted - we check to see if this was a pure-local drag + /// (i.e. we dragged a child control inside ourselves). If so, we re-insert the + /// child to the appropriate index. Otherwise, we'll do this in the ChildAdded + /// event. + /// + protected override void OnDragDrop(DragEventArgs de) + { + if (_dragControls is not null && + _primaryDragControl is not null && + Control.Controls.Contains(_primaryDragControl)) + { + // Manipulating our controls. We do it ourselves, so that we can set the indices right. + ReorderControls(de); + + _insertionIndex = s_invalidIndex; + } + else + { + // If we are not reordering our controls then just let the base handle it. + Control.ControlAdded += OnChildControlAdded; + base.OnDragDrop(de); + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FlowPanelDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FlowPanelDesigner.cs new file mode 100644 index 00000000000..d7ef7186c75 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FlowPanelDesigner.cs @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#nullable disable + +using System.Collections; +using System.Windows.Forms.Design.Behavior; + +namespace System.Windows.Forms.Design; + +internal class FlowPanelDesigner : PanelDesigner +{ + public override bool ParticipatesWithSnapLines => false; + + public override IList SnapLines + { + get + { + ArrayList snapLines = (ArrayList)base.SnapLines; + + //identify all the paddings to remove + ArrayList paddingsToRemove = new ArrayList(4); + foreach (SnapLine line in snapLines) + { + if (line.Filter is not null && line.Filter.Contains(SnapLine.Padding)) + { + paddingsToRemove.Add(line); + } + } + + //remove all padding + foreach (SnapLine line in paddingsToRemove) + { + snapLines.Remove(line); + } + + return snapLines; + } + } + + // Skip location adjustment because FlowPanel is going to position this control. + // Also, Skip z-order adjustment because SendToFront will put the new control at the + // beginning of the flow instead of the end, plus FlowLayout is already preventing + // overlap. + internal override void AddChildControl(Control newChild) => Control.Controls.Add(newChild); + + protected override void OnDragDrop(DragEventArgs de) + { + base.OnDragDrop(de); + + SelectionManager sm = GetService(typeof(SelectionManager)) as SelectionManager; + sm?.Refresh(); + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderBrowserDialogDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderBrowserDialogDesigner.cs new file mode 100644 index 00000000000..8e59619cba1 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderBrowserDialogDesigner.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design; + +internal class FolderBrowserDialogDesigner : ComponentDesigner +{ + // Overridden to avoid setting the default property ("SelectedPath") + // to the Site.Name (i.e. folderBrowserDialog1). + protected override bool SetTextualDefaultProperty => false; +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.FolderBrowser.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.FolderBrowser.cs index 70193130bba..e071f36962e 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.FolderBrowser.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.FolderBrowser.cs @@ -1,12 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -#nullable disable - -using System.Buffers; using System.ComponentModel; -using Windows.Win32.UI.Shell.Common; namespace System.Windows.Forms.Design; @@ -38,6 +33,7 @@ protected sealed class FolderBrowser : Component /// Gets or sets a description to show above the folders. Here you can provide instructions for /// selecting a folder. /// + [AllowNull] public string Description { get => _descriptionText; @@ -52,60 +48,29 @@ public string Description /// /// Shows the folder browser dialog with the specified owner. /// - public unsafe DialogResult ShowDialog(IWin32Window owner) + public unsafe DialogResult ShowDialog(IWin32Window? owner) { - // Get/find an owner HWND for this dialog. - HWND hWndOwner = owner is not null ? (HWND)owner.Handle : PInvoke.GetActiveWindow(); - - // Get the IDL for the specific start location. - PInvoke.SHGetSpecialFolderLocation((int)StartLocation, out ITEMIDLIST* listHandle); - if (listHandle is null) - { - return DialogResult.Cancel; - } - uint mergedOptions = (uint)Style | PInvoke.BIF_NEWDIALOGSTYLE; if ((mergedOptions & (int)PInvoke.BIF_NEWDIALOGSTYLE) != 0) { Application.OleRequired(); } - char[] displayName = ArrayPool.Shared.Rent(PInvoke.MAX_PATH + 1); - try - { - fixed (char* pDisplayName = displayName) - fixed (char* ptrDescriptionText = _descriptionText) - { - var bi = new BROWSEINFOW - { - pidlRoot = listHandle, - hwndOwner = hWndOwner, - pszDisplayName = pDisplayName, - lpszTitle = ptrDescriptionText, - ulFlags = mergedOptions, - lpfn = null, - lParam = 0, - iImage = 0 - }; - - // Show the dialog. - ITEMIDLIST* browseHandle = PInvoke.SHBrowseForFolder(in bi); - if (browseHandle is null) - { - return DialogResult.Cancel; - } + string? folder = FolderBrowserHelper.BrowseForFolder( + _descriptionText, + (int)StartLocation, + mergedOptions, + owner is not null ? (HWND)owner.Handle : PInvoke.GetActiveWindow(), + callback: null, + lParam: default); - // Retrieve the path from the IDList. - PWSTR selectedPath = default; - PInvoke.SHGetPathFromIDList(browseHandle, selectedPath); - DirectoryPath = new string((char*)selectedPath); - return DialogResult.OK; - } - } - finally + if (folder is not null) { - ArrayPool.Shared.Return(displayName); + DirectoryPath = folder; + return DialogResult.OK; } + + return DialogResult.Cancel; } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.FolderBrowserFolder.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.FolderBrowserFolder.cs index 2c428edd069..5f447229b03 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.FolderBrowserFolder.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.FolderBrowserFolder.cs @@ -1,24 +1,30 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; public partial class FolderNameEditor { + /// + /// + /// is also a list of CSIDL values. Unfortunately CSIDL_CONNECTIONS, + /// CSIDL_NETWORK, and CSIDL_PRINTERS are not currently defined in that enum and can't be passed to + /// . + /// + /// protected enum FolderBrowserFolder { - Desktop = 0x0000, - Favorites = 0x0006, - MyComputer = 0x0011, - MyDocuments = 0x0005, - MyPictures = 0x0027, - NetAndDialUpConnections = 0x0031, - NetworkNeighborhood = 0x0012, - Printers = 0x0004, - Recent = 0x0008, - SendTo = 0x0009, - StartMenu = 0x000b, - Templates = 0x0015 + Desktop = (int)PInvoke.CSIDL_DESKTOP, + Favorites = (int)PInvoke.CSIDL_FAVORITES, + MyComputer = (int)PInvoke.CSIDL_DRIVES, + MyDocuments = (int)PInvoke.CSIDL_PERSONAL, + MyPictures = (int)PInvoke.CSIDL_MYPICTURES, + NetAndDialUpConnections = (int)PInvoke.CSIDL_CONNECTIONS, + NetworkNeighborhood = (int)PInvoke.CSIDL_NETWORK, + Printers = (int)PInvoke.CSIDL_PRINTERS, + Recent = (int)PInvoke.CSIDL_RECENT, + SendTo = (int)PInvoke.CSIDL_SENDTO, + StartMenu = (int)PInvoke.CSIDL_STARTMENU, + Templates = (int)PInvoke.CSIDL_TEMPLATES } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.FolderBrowserStyles.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.FolderBrowserStyles.cs index f601ea6ec5b..dd85db0271e 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.FolderBrowserStyles.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.FolderBrowserStyles.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; @@ -9,12 +8,12 @@ public partial class FolderNameEditor [Flags] protected enum FolderBrowserStyles { - BrowseForComputer = unchecked((int)PInvoke.BIF_BROWSEFORCOMPUTER), - BrowseForEverything = unchecked((int)PInvoke.BIF_BROWSEINCLUDEFILES), - BrowseForPrinter = unchecked((int)PInvoke.BIF_BROWSEFORPRINTER), - RestrictToDomain = unchecked((int)PInvoke.BIF_DONTGOBELOWDOMAIN), - RestrictToFilesystem = unchecked((int)PInvoke.BIF_RETURNONLYFSDIRS), - RestrictToSubfolders = unchecked((int)PInvoke.BIF_RETURNFSANCESTORS), - ShowTextBox = unchecked((int)PInvoke.BIF_EDITBOX) + BrowseForComputer = (int)PInvoke.BIF_BROWSEFORCOMPUTER, + BrowseForEverything = (int)PInvoke.BIF_BROWSEINCLUDEFILES, + BrowseForPrinter = (int)PInvoke.BIF_BROWSEFORPRINTER, + RestrictToDomain = (int)PInvoke.BIF_DONTGOBELOWDOMAIN, + RestrictToFilesystem = (int)PInvoke.BIF_RETURNONLYFSDIRS, + RestrictToSubfolders = (int)PInvoke.BIF_RETURNFSANCESTORS, + ShowTextBox = (int)PInvoke.BIF_EDITBOX } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.cs index b384dc39a41..49c1d937950 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FolderNameEditor.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.Drawing.Design; @@ -15,9 +12,9 @@ namespace System.Windows.Forms.Design; [CLSCompliant(false)] public partial class FolderNameEditor : UITypeEditor { - private FolderBrowser _folderBrowser; + private FolderBrowser? _folderBrowser; - public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) + public override object? EditValue(ITypeDescriptorContext? context, IServiceProvider provider, object? value) { if (_folderBrowser is null) { @@ -34,7 +31,7 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide } /// - public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.Modal; + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext? context) => UITypeEditorEditStyle.Modal; /// /// Initializes the folder browser dialog when it is created. This gives you an opportunity diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormDocumentDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormDocumentDesigner.cs index 5a8cc1769bf..c8a06d6eda8 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormDocumentDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormDocumentDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.CurrencyFormatType.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.CurrencyFormatType.cs index 1d9f4da13c0..1406750a6b4 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.CurrencyFormatType.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.CurrencyFormatType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.CustomFormatType.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.CustomFormatType.cs index 4f759d0c922..9226355114a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.CustomFormatType.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.CustomFormatType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.DateTimeFormatType.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.DateTimeFormatType.cs index 5068a392ce6..8463861efe4 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.DateTimeFormatType.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.DateTimeFormatType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.Designer.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.Designer.cs index 1b7bed20ab0..831741cd6f5 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.Designer.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.Designer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.NoFormattingFormatType.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.NoFormattingFormatType.cs index 43193f6acde..c3a6ddab118 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.NoFormattingFormatType.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.NoFormattingFormatType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.NumericFormatType.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.NumericFormatType.cs index 6cc2a3c60ba..42303f51e1e 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.NumericFormatType.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.NumericFormatType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.ScientificFormatType.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.ScientificFormatType.cs index 688a9ffa900..4c22d875aa9 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.ScientificFormatType.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.ScientificFormatType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.cs index 550fc562ca8..ee397dc60d3 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -17,7 +16,7 @@ internal partial class FormatControl : UserControl private const int ScientificIndex = 4; private const int CustomIndex = 5; - private TextBox customStringTextBox = new TextBox(); + private TextBox customStringTextBox = new(); // static because we want this value to be the same across a // VS session diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatStringDialog.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatStringDialog.cs index 3f41fb8d520..10d43ee0828 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatStringDialog.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatStringDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatStringEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatStringEditor.cs index a5c741096a8..c5fdf0a5ce4 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatStringEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatStringEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/GroupBoxDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/GroupBoxDesigner.cs index c503d8d133d..1c8875d180e 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/GroupBoxDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/GroupBoxDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/GroupedContextMenuStrip.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/GroupedContextMenuStrip.cs index af2bead4869..2721fd79726 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/GroupedContextMenuStrip.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/GroupedContextMenuStrip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/HelpNamespaceEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/HelpNamespaceEditor.cs index d2e4d781455..6279631df12 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/HelpNamespaceEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/HelpNamespaceEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IContainsThemedScrollbarWindows.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IContainsThemedScrollbarWindows.cs index 8cf1167344a..98398a5aa98 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IContainsThemedScrollbarWindows.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IContainsThemedScrollbarWindows.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IEventHandlerService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IEventHandlerService.cs index c3ad383fc1e..e53e9b9a16a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IEventHandlerService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IEventHandlerService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; @@ -28,14 +27,14 @@ internal interface IEventHandlerService /// Gets the control that handles focus changes /// for this event handler service. /// - Control FocusWindow { get; } + Control? FocusWindow { get; } - event EventHandler EventHandlerChanged; + event EventHandler? EventHandlerChanged; /// /// Gets the currently active event handler of the specified type. /// - object GetHandler(Type handlerType); + object? GetHandler(Type handlerType); /// /// Pops diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IMenuStatusHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IMenuStatusHandler.cs index 5f909eaa3d0..99edd1ca2e0 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IMenuStatusHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IMenuStatusHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IMouseHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IMouseHandler.cs index 0c52e5ae463..3a977a77e33 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IMouseHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IMouseHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IOleDragClient.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IOleDragClient.cs index 1dfdd5580a3..f82ea413aa6 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IOleDragClient.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IOleDragClient.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IOverlayService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IOverlayService.cs index 691d20bbc53..c07428ef946 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IOverlayService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/IOverlayService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISelectionUIHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISelectionUIHandler.cs index c9643adbf2b..0cae3b03f4e 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISelectionUIHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISelectionUIHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISelectionUIService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISelectionUIService.cs index 334814f1872..618483acd57 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISelectionUIService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISelectionUIService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISplitWindowService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISplitWindowService.cs index a14473dba9f..09f70aff4f6 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISplitWindowService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISplitWindowService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISupportInSituService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISupportInSituService.cs index f4324be2a16..b1140c6ef13 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISupportInSituService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ISupportInSituService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageCollectionCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageCollectionCodeDomSerializer.cs index c0384289e10..086a1d30b60 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageCollectionCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageCollectionCodeDomSerializer.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.CodeDom; using System.Collections.Specialized; @@ -20,16 +17,14 @@ public class ImageListCodeDomSerializer : CodeDomSerializer /// This method takes a CodeDomObject and deserializes into a real object. /// We don't do anything here. /// - public override object Deserialize(IDesignerSerializationManager manager, object codeObject) + public override object? Deserialize(IDesignerSerializationManager manager, object codeObject) { // REVIEW: Please look at this carefully - This is just copied from ControlCodeDomSerializer ArgumentNullException.ThrowIfNull(manager); ArgumentNullException.ThrowIfNull(codeObject); // Find our base class's serializer. - CodeDomSerializer serializer = (CodeDomSerializer)manager.GetSerializer(typeof(Component), typeof(CodeDomSerializer)); - - if (serializer is null) + if (!manager.TryGetSerializer(typeof(Component), out CodeDomSerializer? serializer)) { Debug.Fail("Unable to find a CodeDom serializer for 'Component'. Has someone tampered with the serialization providers?"); @@ -42,40 +37,36 @@ public override object Deserialize(IDesignerSerializationManager manager, object /// /// Serializes the given object into a CodeDom object. /// - public override object Serialize(IDesignerSerializationManager manager, object value) + public override object? Serialize(IDesignerSerializationManager manager, object value) { - CodeDomSerializer baseSerializer = (CodeDomSerializer)manager.GetSerializer(typeof(ImageList).BaseType, typeof(CodeDomSerializer)); - object codeObject = baseSerializer.Serialize(manager, value); - ImageList imageList = value as ImageList; + CodeDomSerializer baseSerializer = manager.GetSerializer(typeof(ImageList).BaseType)!; + object? codeObject = baseSerializer.Serialize(manager, value); - if (imageList is not null) + if (value is ImageList imageList) { - StringCollection imageKeys = imageList.Images.Keys; - - if (codeObject is CodeStatementCollection) + if (codeObject is CodeStatementCollection codeStatementCollection) { - CodeExpression imageListObject = GetExpression(manager, value); + CodeExpression? imageListObject = GetExpression(manager, value); if (imageListObject is not null) { CodeExpression imageListImagesProperty = new CodePropertyReferenceExpression(imageListObject, "Images"); - if (imageListImagesProperty is not null) + StringCollection imageKeys = imageList.Images.Keys; + + for (int i = 0; i < imageKeys.Count; i++) { - for (int i = 0; i < imageKeys.Count; i++) + if (imageKeys[i] is { Length: not 0 } imageKey) { - if ((imageKeys[i] is not null) || (imageKeys[i].Length != 0)) - { - CodeMethodInvokeExpression setNameMethodCall - = new(imageListImagesProperty, "SetKeyName", - new CodeExpression[] - { - new CodePrimitiveExpression(i), // SetKeyName(int, - new CodePrimitiveExpression(imageKeys[i]) // string); - }); + CodeMethodInvokeExpression setNameMethodCall + = new(imageListImagesProperty, "SetKeyName", + new CodeExpression[] + { + new CodePrimitiveExpression(i), // SetKeyName(int, + new CodePrimitiveExpression(imageKey) // string); + }); - ((CodeStatementCollection)codeObject).Add(setNameMethodCall); - } + codeStatementCollection.Add(setNameMethodCall); } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageCollectionEditor.cs index 138201d9a95..d696e91a320 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageCollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageCollectionEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageIndexEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageIndexEditor.cs index 2c1f1cb73c5..beecf5714dc 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageIndexEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageIndexEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListActionList.cs new file mode 100644 index 00000000000..dca02c35a9b --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListActionList.cs @@ -0,0 +1,56 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing; + +namespace System.Windows.Forms.Design; + +internal class ImageListActionList : DesignerActionList +{ + private readonly ImageListDesigner _designer; + + public ImageListActionList(ImageListDesigner designer) + : base(designer.Component) + { + _designer = designer; + } + + public void ChooseImages() => EditorServiceContext.EditValue(_designer, Component, "Images"); + + public ColorDepth ColorDepth + { + get => (Component as ImageList)!.ColorDepth; + set + { + if (Component is not null) + { + TypeDescriptor.GetProperties(Component)[nameof(ColorDepth)]?.SetValue(Component, value); + } + } + } + + public Size ImageSize + { + get => (Component as ImageList)!.ImageSize; + set + { + if (Component is not null) + { + TypeDescriptor.GetProperties(Component)[nameof(ImageSize)]?.SetValue(Component, value); + } + } + } + + public override DesignerActionItemCollection GetSortedActionItems() + { + DesignerActionItemCollection items = new DesignerActionItemCollection + { + new DesignerActionPropertyItem(nameof(ImageSize), SR.ImageListActionList_ImageSizeDisplayName, SR.PropertiesCategoryName, SR.ImageListActionList_ImageSizeDescription), + new DesignerActionPropertyItem(nameof(ColorDepth), SR.ImageListActionList_ColorDepthDisplayName, SR.PropertiesCategoryName, SR.ImageListActionList_ColorDepthDescription), + new DesignerActionMethodItem(this, nameof(ChooseImages), SR.ImageListActionList_ChooseImagesDisplayName, SR.LinksCategoryName, SR.ImageListActionList_ChooseImagesDescription, true) + }; + return items; + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListDesigner.OriginalImageCollection.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListDesigner.OriginalImageCollection.cs new file mode 100644 index 00000000000..5db14749993 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListDesigner.OriginalImageCollection.cs @@ -0,0 +1,210 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections; +using System.Collections.Specialized; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Design; +using System.Globalization; + +namespace System.Windows.Forms.Design; + +internal partial class ImageListDesigner +{ + // Shadow ImageList.Images to allow arbitrary handle recreation. + [Editor($"System.Windows.Forms.Design.ImageCollectionEditor, {AssemblyRef.SystemDesign}", typeof(UITypeEditor))] + internal class OriginalImageCollection : IList + { + private readonly ImageListDesigner _owner; + private readonly List _items = new(); + + internal OriginalImageCollection(ImageListDesigner owner) + { + _owner = owner; + // just in case it's got images + ReloadFromImageList(); + } + + private void AssertInvariant() + { + Debug.Assert(_owner is not null, "OriginalImageCollection has no owner (ImageListDesigner)"); + Debug.Assert(_items is not null, "OriginalImageCollection has no list (ImageListDesigner)"); + } + + public int Count + { + get + { + AssertInvariant(); + return _items.Count; + } + } + + public bool IsReadOnly => false; + + bool IList.IsFixedSize => false; + + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public ImageListImage this[int index] + { + get + { + return index < 0 || index >= Count + ? throw new ArgumentOutOfRangeException(string.Format(SR.InvalidArgument, + nameof(index), + index.ToString(CultureInfo.CurrentCulture))) + : (ImageListImage)_items[index]; + } + set + { + if (index < 0 || index >= Count) + throw new ArgumentOutOfRangeException(string.Format(SR.InvalidArgument, + nameof(index), + index.ToString(CultureInfo.CurrentCulture))); + + if (value is null) + throw new ArgumentException(string.Format(SR.InvalidArgument, + nameof(value), + "null")); + + AssertInvariant(); + _items[index] = value; + RecreateHandle(); + } + } + + object? IList.this[int index] + { + get => this[index]; + set => this[index] = value is ImageListImage image ? image : throw new ArgumentException(); + } + + public void SetKeyName(int index, string name) + { + this[index].Name = name; + _owner.ImageList.Images.SetKeyName(index, name); + } + + /// + /// Add the given image to the ImageList. + /// + /// + /// + public int Add(ImageListImage value) + { + _items.Add(value); + if (value.Name is not null) + { + _owner.ImageList.Images.Add(value.Name, value.Image); + } + else + { + _owner.ImageList.Images.Add(value.Image); + } + + return _items.IndexOf(value); + } + + public void AddRange(ImageListImage[] values) + { + ArgumentNullException.ThrowIfNull(values); + foreach (ImageListImage value in values) + { + if (value is not null) + { + Add(value); + } + } + } + + int IList.Add(object? value) => value is ImageListImage image ? Add(image) : throw new ArgumentException(); + + // Called when reloading the form. In this case, we have no "originals" list, + // so we make one out of the image list. + internal void ReloadFromImageList() + { + _items.Clear(); + StringCollection imageKeys = _owner.ImageList.Images.Keys; + for (int i = 0; i < _owner.ImageList.Images.Count; i++) + { + _items.Add(new ImageListImage((Bitmap)_owner.ImageList.Images[i], imageKeys[i])); + } + } + + /// + /// Remove all images and masks from the ImageList. + /// + public void Clear() + { + AssertInvariant(); + _items.Clear(); + _owner.ImageList.Images.Clear(); + } + + public bool Contains(ImageListImage value) => _items.Contains(value); + + bool IList.Contains(object? value) => value is ImageListImage image && Contains(image); + + public IEnumerator GetEnumerator() => _items.GetEnumerator(); + + public int IndexOf(Image? value) => value is Image image ? _items.IndexOf(image) : -1; + + int IList.IndexOf(object? value) => value is Image image ? IndexOf(image) : -1; + + void IList.Insert(int index, object? value) => throw new NotSupportedException(); + + internal void PopulateHandle() + { + for (int i = 0; i < _items.Count; i++) + { + ImageListImage imageListImage = (ImageListImage)_items[i]; + _owner.ImageList.Images.Add(imageListImage.Name, imageListImage.Image); + } + } + + private void RecreateHandle() + { + _owner.ImageList.Images.Clear(); + PopulateHandle(); + } + + public void Remove(Image value) + { + AssertInvariant(); + _items.Remove(value); + RecreateHandle(); + } + + void IList.Remove(object? value) + { + if (value is Image image) + { + Remove(image); + } + } + + public void RemoveAt(int index) + { + ArgumentOutOfRangeException.ThrowIfLessThan(index, 0, nameof(index)); + if (index < 0 || index >= Count) + throw new ArgumentOutOfRangeException(string.Format(SR.InvalidArgument, + nameof(index), + index.ToString(CultureInfo.CurrentCulture))); + + AssertInvariant(); + _items.RemoveAt(index); + RecreateHandle(); + } + + int ICollection.Count => Count; + + bool ICollection.IsSynchronized => false; + + object ICollection.SyncRoot => ((ICollection)_items).SyncRoot; + + void ICollection.CopyTo(Array array, int index) => ((ICollection)_items).CopyTo(array, index); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListDesigner.cs new file mode 100644 index 00000000000..322ceb41db3 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListDesigner.cs @@ -0,0 +1,145 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing; + +namespace System.Windows.Forms.Design; + +/// +/// Provides design-time functionality for ImageList. +/// +internal partial class ImageListDesigner : ComponentDesigner +{ + // The designer keeps a backup copy of all the images in the image list. Unlike the image list, + // we don't lose any information about size and color depth. + private OriginalImageCollection? _originalImageCollection; + private DesignerActionListCollection? _actionLists; + + /// + /// Accessor method for the ColorDepth property on ImageList. + /// We shadow this property at design time. + /// + private ColorDepth ColorDepth + { + get => ImageList.ColorDepth; + set + { + ImageList.Images.Clear(); + ImageList.ColorDepth = value; + Images.PopulateHandle(); + } + } + + private bool ShouldSerializeColorDepth() => Images.Count == 0; + + /// + /// Accessor method for the Images property on ImageList. + /// We shadow this property at design time. + /// + private OriginalImageCollection Images + { + get + { + _originalImageCollection ??= new OriginalImageCollection(this); + return _originalImageCollection; + } + } + + internal ImageList ImageList => (ImageList)Component; + + /// + /// Accessor method for the ImageSize property on ImageList. + /// We shadow this property at design time. + /// + private Size ImageSize + { + get => ImageList.ImageSize; + set + { + ImageList.Images.Clear(); + ImageList.ImageSize = value; + Images.PopulateHandle(); + } + } + + private bool ShouldSerializeImageSize() => Images.Count == 0; + + private Color TransparentColor + { + get => ImageList.TransparentColor; + set + { + ImageList.Images.Clear(); + ImageList.TransparentColor = value; + Images.PopulateHandle(); + } + } + + private bool ShouldSerializeTransparentColor() => !TransparentColor.Equals(Color.LightGray); + + /// + /// Accessor method for the ImageStream property on ImageList. + /// We shadow this property at design time. + /// + private ImageListStreamer? ImageStream + { + get => ImageList.ImageStream; + set + { + ImageList.ImageStream = value; + Images.ReloadFromImageList(); + } + } + + /// + /// Provides an opportunity for the designer to filter the properties. + /// + /// + protected override void PreFilterProperties(IDictionary properties) + { + base.PreFilterProperties(properties); + + // Handle shadowed properties + string[] shadowProps = new string[] + { + nameof(ColorDepth), + nameof(ImageSize), + nameof(ImageStream), + nameof(TransparentColor) + }; + + for (int i = 0; i < shadowProps.Length; i++) + { + PropertyDescriptor? prop = (PropertyDescriptor?)properties[shadowProps[i]]; + if (prop is not null) + { + properties[shadowProps[i]] = TypeDescriptor.CreateProperty(typeof(ImageListDesigner), prop, Array.Empty()); + } + } + + // replace this one seperately because it is of a different type (OriginalImageCollection) than + // the original property (ImageCollection) + PropertyDescriptor? imageProp = (PropertyDescriptor?)properties["Images"]; + if (imageProp is not null) + { + Attribute[] attrs = new Attribute[imageProp.Attributes.Count]; + imageProp.Attributes.CopyTo(attrs, 0); + properties["Images"] = TypeDescriptor.CreateProperty(typeof(ImageListDesigner), "Images", typeof(OriginalImageCollection), attrs); + } + } + + public override DesignerActionListCollection ActionLists + { + get + { + _actionLists ??= new DesignerActionListCollection + { + new ImageListActionList(this) + }; + return _actionLists; + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImage.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImage.cs index c692f07380e..cee555146cd 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImage.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImage.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImageEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImageEditor.cs index 40a67a8975d..fc510072339 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImageEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ImageListImageEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/InheritanceUI.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/InheritanceUI.cs index ced8057eba6..97471929479 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/InheritanceUI.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/InheritanceUI.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/InitialDirectoryEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/InitialDirectoryEditor.cs index d451d9a087c..00ab84f5c3c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/InitialDirectoryEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/InitialDirectoryEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ItemTypeToolStripMenuItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ItemTypeToolStripMenuItem.cs index 108c7415b2c..ab80a4445bf 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ItemTypeToolStripMenuItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ItemTypeToolStripMenuItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -15,7 +14,7 @@ namespace System.Windows.Forms.Design; internal class ItemTypeToolStripMenuItem : ToolStripMenuItem { private static readonly string s_systemWindowsFormsNamespace = typeof(ToolStripItem).Namespace; - private static readonly ToolboxItem s_invalidToolboxItem = new ToolboxItem(); + private static readonly ToolboxItem s_invalidToolboxItem = new(); private readonly Type _itemType; private bool _convertTo; private ToolboxItem _tbxItem = s_invalidToolboxItem; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LabelDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LabelDesigner.cs index 0061ccc01bb..274668524c1 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LabelDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LabelDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LinkAreaEditor.LinkAreaUI.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LinkAreaEditor.LinkAreaUI.cs index 34fd2fc2377..0471bbfe00d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LinkAreaEditor.LinkAreaUI.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LinkAreaEditor.LinkAreaUI.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LinkAreaEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LinkAreaEditor.cs index 17148be87d3..cf439207817 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LinkAreaEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/LinkAreaEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListBoxDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListBoxDesigner.cs index 60a78a3ed03..fb7770067df 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListBoxDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListBoxDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListControlStringCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListControlStringCollectionEditor.cs index a0bddbf5fce..30455d3fbff 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListControlStringCollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListControlStringCollectionEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListControlUnboundActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListControlUnboundActionList.cs index 11f3fd40e49..456b188de96 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListControlUnboundActionList.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListControlUnboundActionList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewActionList.cs index 7cedeb30d5e..a2d00ee2598 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewActionList.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewActionList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewDesigner.cs index 69443218538..2ae225f54bd 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewGroupCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewGroupCollectionEditor.cs index bd17fb4a8d6..e01d88fcfe5 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewGroupCollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewGroupCollectionEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewItemCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewItemCollectionEditor.cs index c168632c950..71def63281e 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewItemCollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewItemCollectionEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewSubItemCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewSubItemCollectionEditor.cs index 49021c23a1b..2c9fa3d4443 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewSubItemCollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ListViewSubItemCollectionEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptor.cs index 83e5d415eb7..13af6593918 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptor.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.Globalization; @@ -20,31 +17,28 @@ public abstract class MaskDescriptor /// /// The mask being described. /// - public abstract string Mask { get; } + public abstract string? Mask { get; } /// /// The friendly name of the mask descriptor. /// Used also as the description for the mask. /// - public abstract string Name { get; } + public abstract string? Name { get; } /// /// A sample text following the mask specification. /// - public abstract string Sample { get; } + public abstract string? Sample { get; } /// /// A Type representing the type providing validation for this mask. /// - public abstract Type ValidatingType { get; } + public abstract Type? ValidatingType { get; } /// /// The CultureInfo representing the locale the mask is designed for. /// - public virtual CultureInfo Culture - { - get { return Thread.CurrentThread.CurrentCulture; } - } + public virtual CultureInfo Culture => Thread.CurrentThread.CurrentCulture; /// /// Determines whether the specified mask descriptor is valid and hence can be added to the canned masks list. @@ -56,12 +50,12 @@ public virtual CultureInfo Culture /// 5. The sample is correct based on the mask and all required edit characters have been provided (mask completed - not necessarily full). /// 6. The sample is valid based on the ValidatingType object (if any). /// - public static bool IsValidMaskDescriptor(MaskDescriptor maskDescriptor) + public static bool IsValidMaskDescriptor([NotNullWhen(true)] MaskDescriptor? maskDescriptor) { return IsValidMaskDescriptor(maskDescriptor, out string _); } - public static bool IsValidMaskDescriptor(MaskDescriptor maskDescriptor, out string validationErrorDescription) + public static bool IsValidMaskDescriptor([NotNullWhen(true)] MaskDescriptor? maskDescriptor, out string validationErrorDescription) { validationErrorDescription = string.Empty; @@ -78,14 +72,15 @@ public static bool IsValidMaskDescriptor(MaskDescriptor maskDescriptor, out stri } MaskedTextProvider maskedTextProvider = new MaskedTextProvider(maskDescriptor.Mask, maskDescriptor.Culture); - MaskedTextBox maskedTextBox = new MaskedTextBox(maskedTextProvider); - - maskedTextBox.SkipLiterals = true; - maskedTextBox.ResetOnPrompt = true; - maskedTextBox.ResetOnSpace = true; - maskedTextBox.ValidatingType = maskDescriptor.ValidatingType; - maskedTextBox.FormatProvider = maskDescriptor.Culture; - maskedTextBox.Culture = maskDescriptor.Culture; + MaskedTextBox maskedTextBox = new(maskedTextProvider) + { + SkipLiterals = true, + ResetOnPrompt = true, + ResetOnSpace = true, + ValidatingType = maskDescriptor.ValidatingType, + FormatProvider = maskDescriptor.Culture, + Culture = maskDescriptor.Culture + }; maskedTextBox.TypeValidationCompleted += new TypeValidationEventHandler(maskedTextBox1_TypeValidationCompleted); maskedTextBox.MaskInputRejected += new MaskInputRejectedEventHandler(maskedTextBox1_MaskInputRejected); @@ -102,26 +97,26 @@ public static bool IsValidMaskDescriptor(MaskDescriptor maskDescriptor, out stri if (maskedTextBox.Tag is not null) // Validation failed. { - validationErrorDescription = maskedTextBox.Tag.ToString(); + validationErrorDescription = maskedTextBox.Tag.ToString()!; } return validationErrorDescription.Length == 0; } - private static void maskedTextBox1_MaskInputRejected(object sender, MaskInputRejectedEventArgs e) + private static void maskedTextBox1_MaskInputRejected(object? sender, MaskInputRejectedEventArgs e) { - MaskedTextBox maskedTextBox = sender as MaskedTextBox; + MaskedTextBox maskedTextBox = (MaskedTextBox)sender!; maskedTextBox.Tag = MaskedTextBoxDesigner.GetMaskInputRejectedErrorMessage(e); } - private static void maskedTextBox1_TypeValidationCompleted(object sender, TypeValidationEventArgs e) + private static void maskedTextBox1_TypeValidationCompleted(object? sender, TypeValidationEventArgs e) { if (e.IsValidInput) { return; } - MaskedTextBox maskedTextBox = sender as MaskedTextBox; + MaskedTextBox maskedTextBox = (MaskedTextBox)sender!; maskedTextBox.Tag = e.Message; } @@ -133,9 +128,9 @@ private static void maskedTextBox1_TypeValidationCompleted(object sender, TypeVa /// Observe that the Name property is not considered since MaskedTextProvider/Box are not /// aware of it. /// - public override bool Equals(object maskDescriptor) + public override bool Equals(object? maskDescriptor) { - MaskDescriptor descriptor = maskDescriptor as MaskDescriptor; + MaskDescriptor? descriptor = maskDescriptor as MaskDescriptor; if (!IsValidMaskDescriptor(descriptor) || !IsValidMaskDescriptor(this)) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorComparer.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorComparer.cs index a4712d630f7..f967c0a27b0 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorComparer.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorComparer.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable namespace System.Windows.Forms.Design; @@ -28,7 +25,7 @@ public MaskDescriptorComparer(SortType sortType, SortOrder sortOrder) _sortOrder = sortOrder; } - public int Compare(MaskDescriptor maskDescriptorA, MaskDescriptor maskDescriptorB) + public int Compare(MaskDescriptor? maskDescriptorA, MaskDescriptor? maskDescriptorB) { if (maskDescriptorA is null || maskDescriptorB is null) { @@ -37,7 +34,8 @@ public int Compare(MaskDescriptor maskDescriptorA, MaskDescriptor maskDescriptor return 0; } - string textA, textB; + string? textA; + string? textB; switch (_sortType) { @@ -77,7 +75,7 @@ public static int GetHashCode(MaskDescriptor maskDescriptor) return 0; } - public static bool Equals(MaskDescriptor maskDescriptorA, MaskDescriptor maskDescriptorB) + public static bool Equals(MaskDescriptor? maskDescriptorA, MaskDescriptor? maskDescriptorB) { if (!MaskDescriptor.IsValidMaskDescriptor(maskDescriptorA) || !MaskDescriptor.IsValidMaskDescriptor(maskDescriptorB)) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorTemplate.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorTemplate.cs index 999cf8e6478..b5a2b7dd12e 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorTemplate.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDescriptorTemplate.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Globalization; @@ -13,45 +10,40 @@ namespace System.Windows.Forms.Design; /// internal class MaskDescriptorTemplate : MaskDescriptor { - private readonly string _mask; - private readonly string _name; - private readonly string _sample; - private readonly Type _type; - private readonly CultureInfo _culture; - - public MaskDescriptorTemplate(string mask, string name, string sample, Type validatingType, CultureInfo culture) : this(mask, name, sample, validatingType, culture, false) + public MaskDescriptorTemplate(string? mask, string name, string? sample, Type? validatingType, CultureInfo culture) + : this(mask, name, sample, validatingType, culture, skipValidation: false) { } - public MaskDescriptorTemplate(string mask, string name, string sample, Type validatingType, CultureInfo culture, bool skipValidation) + public MaskDescriptorTemplate(string? mask, string name, string? sample, Type? validatingType, CultureInfo? culture, bool skipValidation) { - _mask = mask; - _name = name; - _sample = sample; - _type = validatingType; - _culture = culture; + Mask = mask; + Name = name; + Sample = sample; + ValidatingType = validatingType; + Culture = culture!; if (skipValidation) { return; } - if (!IsValidMaskDescriptor(this, out _)) + if (!IsValidMaskDescriptor(this)) { // Don't throw here, callers should check the Mask property for validity. See the ValidMaskDescriptorList below. - _mask = null; + Mask = null; } } - public override string Mask => _mask; + public override string? Mask { get; } - public override string Name => _name; + public override string Name { get; } - public override string Sample => _sample; + public override string? Sample { get; } - public override Type ValidatingType => _type; + public override Type? ValidatingType { get; } - public override CultureInfo Culture => _culture; + public override CultureInfo Culture { get; } /// /// Get the canned mask descriptors according to the specified culture. diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDesignerDialog.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDesignerDialog.cs index 1216d69ba87..34343d968cd 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDesignerDialog.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDesignerDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -31,8 +30,8 @@ internal class MaskDesignerDialog : Form private Button _btnCancel; private ErrorProvider _errorProvider; - private readonly List _maskDescriptors = new List(); - private MaskDescriptor _customMaskDescriptor; + private readonly List _maskDescriptors = new(); + private MaskDescriptorTemplate _customMaskDescriptor; private SortOrder _listViewSortOrder = SortOrder.Ascending; private IContainer _components; private readonly IHelpService _helpService; @@ -328,7 +327,7 @@ private void AddDefaultMaskDescriptors(CultureInfo culture) // Need to pass false for validateDescriptor param since the custom mask will fail validation // because the mask is empty. - InsertMaskDescriptor(0, _customMaskDescriptor, /*validate*/ false); + InsertMaskDescriptor(0, _customMaskDescriptor, validateDescriptor: false); foreach (MaskDescriptor maskDescriptor in maskDescriptors) { @@ -342,12 +341,16 @@ private void AddDefaultMaskDescriptors(CultureInfo culture) private bool ContainsMaskDescriptor(MaskDescriptor maskDescriptor) { Debug.Assert(maskDescriptor is not null, "Null mask descriptor."); + Debug.Assert(maskDescriptor.Name is not null, "Mask descriptor should either be valid or equal to _customMaskDescriptor"); + + string maskDescriptorName = maskDescriptor.Name.Trim(); foreach (MaskDescriptor descriptor in _maskDescriptors) { Debug.Assert(descriptor is not null, "Null mask descriptor in the collection."); - if (maskDescriptor.Equals(descriptor) || maskDescriptor.Name.Trim() == descriptor.Name.Trim()) + // descriptor.Name is not null because _maskDescriptors can only contain valid mask descriptors or _customMaskDescriptor + if (maskDescriptor.Equals(descriptor) || maskDescriptorName == descriptor.Name!.Trim()) { return true; } @@ -508,13 +511,13 @@ private void UpdateSortedListView(MaskDescriptorComparer.SortType sortType) string validatingType = maskDescriptor.ValidatingType is not null ? maskDescriptor.ValidatingType.Name : nullEntry; // Make sure the sample displays literals. - MaskedTextProvider mtp = new MaskedTextProvider(maskDescriptor.Mask, maskDescriptor.Culture); - bool success = mtp.Add(maskDescriptor.Sample); + MaskedTextProvider mtp = new(maskDescriptor.Mask!, maskDescriptor.Culture); + bool success = mtp.Add(maskDescriptor.Sample!); Debug.Assert(success, "BadBad: Could not add MaskDescriptor.Sample even it was validated, something is wrong!"); // Don't include prompt. string sample = mtp.ToString(false, true); - _listViewCannedMasks.Items.Add(new ListViewItem(new string[] { maskDescriptor.Name, sample, validatingType })); + _listViewCannedMasks.Items.Add(new ListViewItem(new string[] { maskDescriptor.Name!, sample, validatingType })); } // Add the custom mask descriptor as the last entry. @@ -544,7 +547,7 @@ private void InsertMaskDescriptor(int index, MaskDescriptor maskDescriptor) private void InsertMaskDescriptor(int index, MaskDescriptor maskDescriptor, bool validateDescriptor) { - if (validateDescriptor && !MaskDescriptor.IsValidMaskDescriptor(maskDescriptor, out _)) + if (validateDescriptor && !MaskDescriptor.IsValidMaskDescriptor(maskDescriptor)) { return; } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskPropertyEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskPropertyEditor.cs index fcebd85a7ad..b9ad2ab32bb 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskPropertyEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskPropertyEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxDesigner.cs index fa2eb1472f1..92888deae62 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -19,6 +18,10 @@ internal class MaskedTextBoxDesigner : TextBoxBaseDesigner private DesignerVerbCollection _verbs; private DesignerActionListCollection _actions; + // Overridden to avoid setting the default property ("Mask") + // to the Site.Name (i.e. maskedTextBox1). + protected override bool SetTextualDefaultProperty => false; + /// /// MaskedTextBox designer action list property. Gets the design-time supported actions on the control. /// diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxDesignerActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxDesignerActionList.cs index ce0e802a68b..a3005cbf274 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxDesignerActionList.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxDesignerActionList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxTextEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxTextEditor.cs index 4489e55f03f..781e5a5be2b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxTextEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxTextEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxTextEditorDropDown.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxTextEditorDropDown.cs index 0350b4e2a46..95a77d6e754 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxTextEditorDropDown.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskedTextBoxTextEditorDropDown.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MenuCommands.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MenuCommands.cs index 326d1b59050..b5e43ab379e 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MenuCommands.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MenuCommands.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -64,94 +63,94 @@ public sealed class MenuCommands : StandardCommands /// This new guid is added so that the ToolStripDesigner now respond to the F2 command /// and go into InSitu Edit mode. /// - private static readonly Guid VSStandardCommandSet97 = new Guid("{5efc7975-14bc-11cf-9b2b-00aa00573819}"); + private static readonly Guid VSStandardCommandSet97 = new("{5efc7975-14bc-11cf-9b2b-00aa00573819}"); /// /// This guid corresponds to the menu grouping Windows Forms will use for its menus. This is /// defined in the Windows Forms menu CTC file, but we need it here so we can define what /// context menus to use. /// - private static readonly Guid wfMenuGroup = new Guid("{74D21312-2AEE-11d1-8BFB-00A0C90F26F7}"); + private static readonly Guid wfMenuGroup = new("{74D21312-2AEE-11d1-8BFB-00A0C90F26F7}"); /// /// This guid corresponds to the Windows Forms command set. /// - private static readonly Guid wfCommandSet = new Guid("{74D21313-2AEE-11d1-8BFB-00A0C90F26F7}"); + private static readonly Guid wfCommandSet = new("{74D21313-2AEE-11d1-8BFB-00A0C90F26F7}"); /// /// This guid is the standard vs 2k commands for key bindings /// - private static readonly Guid guidVSStd2K = new Guid("{1496A755-94DE-11D0-8C3F-00C04FC2AAE2}"); + private static readonly Guid guidVSStd2K = new("{1496A755-94DE-11D0-8C3F-00C04FC2AAE2}"); - public static readonly CommandID SelectionMenu = new CommandID(wfMenuGroup, mnuidSelection); + public static readonly CommandID SelectionMenu = new(wfMenuGroup, mnuidSelection); - public static readonly CommandID ContainerMenu = new CommandID(wfMenuGroup, mnuidContainer); + public static readonly CommandID ContainerMenu = new(wfMenuGroup, mnuidContainer); - public static readonly CommandID TraySelectionMenu = new CommandID(wfMenuGroup, mnuidTraySelection); + public static readonly CommandID TraySelectionMenu = new(wfMenuGroup, mnuidTraySelection); - public static readonly CommandID ComponentTrayMenu = new CommandID(wfMenuGroup, mnuidComponentTray); + public static readonly CommandID ComponentTrayMenu = new(wfMenuGroup, mnuidComponentTray); // Windows Forms commands - public static readonly CommandID DesignerProperties = new CommandID(wfCommandSet, cmdidDesignerProperties); + public static readonly CommandID DesignerProperties = new(wfCommandSet, cmdidDesignerProperties); // Windows Forms Key commands - public static readonly CommandID KeyCancel = new CommandID(guidVSStd2K, ECMD_CANCEL); + public static readonly CommandID KeyCancel = new(guidVSStd2K, ECMD_CANCEL); - public static readonly CommandID KeyReverseCancel = new CommandID(wfCommandSet, cmdidReverseCancel); + public static readonly CommandID KeyReverseCancel = new(wfCommandSet, cmdidReverseCancel); - public static readonly CommandID KeyInvokeSmartTag = new CommandID(guidVSStd2K, ECMD_INVOKESMARTTAG); + public static readonly CommandID KeyInvokeSmartTag = new(guidVSStd2K, ECMD_INVOKESMARTTAG); - public static readonly CommandID KeyDefaultAction = new CommandID(guidVSStd2K, ECMD_RETURN); + public static readonly CommandID KeyDefaultAction = new(guidVSStd2K, ECMD_RETURN); - public static readonly CommandID KeyMoveUp = new CommandID(guidVSStd2K, ECMD_UP); + public static readonly CommandID KeyMoveUp = new(guidVSStd2K, ECMD_UP); - public static readonly CommandID KeyMoveDown = new CommandID(guidVSStd2K, ECMD_DOWN); + public static readonly CommandID KeyMoveDown = new(guidVSStd2K, ECMD_DOWN); - public static readonly CommandID KeyMoveLeft = new CommandID(guidVSStd2K, ECMD_LEFT); + public static readonly CommandID KeyMoveLeft = new(guidVSStd2K, ECMD_LEFT); - public static readonly CommandID KeyMoveRight = new CommandID(guidVSStd2K, ECMD_RIGHT); + public static readonly CommandID KeyMoveRight = new(guidVSStd2K, ECMD_RIGHT); - public static readonly CommandID KeyNudgeUp = new CommandID(guidVSStd2K, ECMD_CTLMOVEUP); + public static readonly CommandID KeyNudgeUp = new(guidVSStd2K, ECMD_CTLMOVEUP); - public static readonly CommandID KeyNudgeDown = new CommandID(guidVSStd2K, ECMD_CTLMOVEDOWN); + public static readonly CommandID KeyNudgeDown = new(guidVSStd2K, ECMD_CTLMOVEDOWN); - public static readonly CommandID KeyNudgeLeft = new CommandID(guidVSStd2K, ECMD_CTLMOVELEFT); + public static readonly CommandID KeyNudgeLeft = new(guidVSStd2K, ECMD_CTLMOVELEFT); - public static readonly CommandID KeyNudgeRight = new CommandID(guidVSStd2K, ECMD_CTLMOVERIGHT); + public static readonly CommandID KeyNudgeRight = new(guidVSStd2K, ECMD_CTLMOVERIGHT); - public static readonly CommandID KeySizeWidthIncrease = new CommandID(guidVSStd2K, ECMD_RIGHT_EXT); + public static readonly CommandID KeySizeWidthIncrease = new(guidVSStd2K, ECMD_RIGHT_EXT); - public static readonly CommandID KeySizeHeightIncrease = new CommandID(guidVSStd2K, ECMD_UP_EXT); + public static readonly CommandID KeySizeHeightIncrease = new(guidVSStd2K, ECMD_UP_EXT); - public static readonly CommandID KeySizeWidthDecrease = new CommandID(guidVSStd2K, ECMD_LEFT_EXT); + public static readonly CommandID KeySizeWidthDecrease = new(guidVSStd2K, ECMD_LEFT_EXT); - public static readonly CommandID KeySizeHeightDecrease = new CommandID(guidVSStd2K, ECMD_DOWN_EXT); + public static readonly CommandID KeySizeHeightDecrease = new(guidVSStd2K, ECMD_DOWN_EXT); - public static readonly CommandID KeyNudgeWidthIncrease = new CommandID(guidVSStd2K, ECMD_CTLSIZERIGHT); + public static readonly CommandID KeyNudgeWidthIncrease = new(guidVSStd2K, ECMD_CTLSIZERIGHT); - public static readonly CommandID KeyNudgeHeightIncrease = new CommandID(guidVSStd2K, ECMD_CTLSIZEDOWN); + public static readonly CommandID KeyNudgeHeightIncrease = new(guidVSStd2K, ECMD_CTLSIZEDOWN); - public static readonly CommandID KeyNudgeWidthDecrease = new CommandID(guidVSStd2K, ECMD_CTLSIZELEFT); + public static readonly CommandID KeyNudgeWidthDecrease = new(guidVSStd2K, ECMD_CTLSIZELEFT); - public static readonly CommandID KeyNudgeHeightDecrease = new CommandID(guidVSStd2K, ECMD_CTLSIZEUP); + public static readonly CommandID KeyNudgeHeightDecrease = new(guidVSStd2K, ECMD_CTLSIZEUP); - public static readonly CommandID KeySelectNext = new CommandID(guidVSStd2K, ECMD_TAB); + public static readonly CommandID KeySelectNext = new(guidVSStd2K, ECMD_TAB); - public static readonly CommandID KeySelectPrevious = new CommandID(guidVSStd2K, ECMD_BACKTAB); + public static readonly CommandID KeySelectPrevious = new(guidVSStd2K, ECMD_BACKTAB); - public static readonly CommandID KeyTabOrderSelect = new CommandID(wfCommandSet, cmdidSpace); + public static readonly CommandID KeyTabOrderSelect = new(wfCommandSet, cmdidSpace); - public static readonly CommandID EditLabel = new CommandID(VSStandardCommandSet97, cmdidEditLabel); + public static readonly CommandID EditLabel = new(VSStandardCommandSet97, cmdidEditLabel); - public static readonly CommandID KeyHome = new CommandID(guidVSStd2K, ECMD_HOME); + public static readonly CommandID KeyHome = new(guidVSStd2K, ECMD_HOME); - public static readonly CommandID KeyEnd = new CommandID(guidVSStd2K, ECMD_END); + public static readonly CommandID KeyEnd = new(guidVSStd2K, ECMD_END); - public static readonly CommandID KeyShiftHome = new CommandID(guidVSStd2K, ECMD_HOME_EXT); + public static readonly CommandID KeyShiftHome = new(guidVSStd2K, ECMD_HOME_EXT); - public static readonly CommandID KeyShiftEnd = new CommandID(guidVSStd2K, ECMD_END_EXT); + public static readonly CommandID KeyShiftEnd = new(guidVSStd2K, ECMD_END_EXT); - public static readonly CommandID SetStatusText = new CommandID(wfCommandSet, cmdidSetStatusText); + public static readonly CommandID SetStatusText = new(wfCommandSet, cmdidSetStatusText); - public static readonly CommandID SetStatusRectangle = new CommandID(wfCommandSet, cmdidSetStatusRectangle); + public static readonly CommandID SetStatusRectangle = new(wfCommandSet, cmdidSetStatusRectangle); } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MonthCalendarDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MonthCalendarDesigner.cs new file mode 100644 index 00000000000..49af748e9a2 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MonthCalendarDesigner.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Windows.Forms.Design; + +internal class MonthCalendarDesigner : ControlDesigner +{ + public MonthCalendarDesigner() + { + AutoResizeHandles = true; + } + + /// + /// Retrieves a set of rules concerning the movement capabilities of a component. + /// This should be one or more flags from the SelectionRules class. If no designer + /// provides rules for a component, the component will not get any UI services. + /// + public override SelectionRules SelectionRules + { + get + { + SelectionRules rules = base.SelectionRules; + + if (Control.Parent is null || !Control.Parent.IsMirrored) + { + rules &= ~(SelectionRules.TopSizeable | SelectionRules.LeftSizeable); + } + else + { + rules &= ~(SelectionRules.TopSizeable | SelectionRules.RightSizeable); + } + + return rules; + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NewItemsContextMenuStrip.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NewItemsContextMenuStrip.cs index 95b5c6ad863..ee3e56f23a7 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NewItemsContextMenuStrip.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NewItemsContextMenuStrip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NoBorderRenderer.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NoBorderRenderer.cs index b374dd57083..1b3f38ad046 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NoBorderRenderer.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NoBorderRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NotifyIconDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NotifyIconDesigner.cs new file mode 100644 index 00000000000..de1ae643277 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NotifyIconDesigner.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections; +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design +{ + internal class NotifyIconDesigner : ComponentDesigner + { + private DesignerActionListCollection? _actionLists; + + public override void InitializeNewComponent(IDictionary defaultValues) + { + base.InitializeNewComponent(defaultValues); + NotifyIcon icon = (NotifyIcon)Component; + icon.Visible = true; + } + + public override DesignerActionListCollection ActionLists + { + get + { + _actionLists ??= new DesignerActionListCollection + { + new NotifyIconActionList(this) + }; + + return _actionLists; + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NotifyIconDesignerActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NotifyIconDesignerActionList.cs new file mode 100644 index 00000000000..2d48e3c3c2b --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/NotifyIconDesignerActionList.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design +{ + internal class NotifyIconActionList : DesignerActionList + { + private readonly NotifyIconDesigner _designer; + public NotifyIconActionList(NotifyIconDesigner designer) : base(designer.Component) + { + _designer = designer; + } + + public void ChooseIcon() + { + EditorServiceContext.EditValue(_designer, Component, "Icon"); + } + + public override DesignerActionItemCollection GetSortedActionItems() + { + var items = new DesignerActionItemCollection + { + new DesignerActionMethodItem(this, "ChooseIcon", SR.ChooseIconDisplayName, true) + }; + return items; + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.CfCodeToolboxItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.CfCodeToolboxItem.cs index 55035d0a2f6..1405cc61ee2 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.CfCodeToolboxItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.CfCodeToolboxItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.ComponentDataObject.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.ComponentDataObject.cs index 9845a02ee92..76aed54fca7 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.ComponentDataObject.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.ComponentDataObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.ComponentDataObjectWrapper.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.ComponentDataObjectWrapper.cs index cd6844b09d7..3dab466d126 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.ComponentDataObjectWrapper.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.ComponentDataObjectWrapper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.cs index 1f96433dfdc..3b3a7dca48e 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -871,7 +870,7 @@ public void DoOleDragDrop(DragEventArgs de) if (loc is not null && !loc.IsReadOnly) { - Rectangle bounds = default(Rectangle); + Rectangle bounds = default; Point pt = (Point)loc.GetValue(comp); bounds.X = dropPt.X + pt.X; bounds.Y = dropPt.Y + pt.Y; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PanelDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PanelDesigner.cs index ad1ceb81ab9..73d1e082f8d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PanelDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PanelDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Drawing2D; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.EscapeHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.EscapeHandler.cs index 03593516e2f..e2a0087d2aa 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.EscapeHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.EscapeHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs index 6623765ab72..ea553f18f25 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -36,14 +35,12 @@ public partial class ParentControlDesigner : ControlDesigner, IOleDragClient // Services that we keep around for the duration of a drag. you should always check // to see if you need to get this service. We cache it, but demand create it. - // private IToolboxService _toolboxService; private const int MinGridSize = 2; private const int MaxGridSize = 200; // designer options... - // private Point _adornerWindowToScreenOffset; //quick lookup for offsetting snaplines for new tools private bool _checkSnapLineSetting = true; // Since layout options is global for the duration of the designer, we should only query it once. @@ -70,25 +67,13 @@ public partial class ParentControlDesigner : ControlDesigner, IOleDragClient /// this property returns true, it is indicating that the Controls that were lasso'd on the /// designer's surface will be re-parented to this designer's control. /// - protected virtual bool AllowControlLasso - { - get - { - return true; - } - } + protected virtual bool AllowControlLasso => true; /// /// This is called to check whether a generic dragbox should be drawn when dragging a toolbox item /// over the designer's surface. /// - protected virtual bool AllowGenericDragBox - { - get - { - return true; - } - } + protected virtual bool AllowGenericDragBox => true; /// /// This is called to check whether the z-order of dragged controls should be maintained when dropped on a @@ -101,13 +86,7 @@ protected virtual bool AllowGenericDragBox /// OnChildControlAdded to set the right child index, since in this case, the control(s) being dragged /// will be removed from the dragSource and then added to the dragTarget. /// - protected internal virtual bool AllowSetChildIndexOnDrop - { - get - { - return true; - } - } + protected internal virtual bool AllowSetChildIndexOnDrop => true; /// /// This is called when the component is added to the parent container. @@ -115,10 +94,7 @@ protected internal virtual bool AllowSetChildIndexOnDrop /// unfortunately IsDropOK is not robust enough and does not allow for specific error messages. /// This method is a chance to display the same error as is displayed at runtime. /// - protected internal virtual bool CanAddComponent(IComponent component) - { - return true; - } + protected internal virtual bool CanAddComponent(IComponent component) => true; /// /// This can be called to determine the current grid spacing and mode. @@ -126,25 +102,13 @@ protected internal virtual bool CanAddComponent(IComponent component) /// will either return the current grid snap dimensions, or a 1x1 point /// indicating no snap. /// - private Size CurrentGridSize - { - get - { - return GridSize; - } - } + private Size CurrentGridSize => GridSize; /// /// Determines the default location for a control added to this designer. /// it is usually (0,0), but may be modified if the container has special borders, etc. /// - protected virtual Point DefaultControlLocation - { - get - { - return new Point(0, 0); - } - } + protected virtual Point DefaultControlLocation => new(0, 0); private bool DefaultUseSnapLines { @@ -169,7 +133,6 @@ protected virtual bool DrawGrid get { // If snaplines are on, the we never want to draw the grid - if (DefaultUseSnapLines) { return false; @@ -181,7 +144,6 @@ protected virtual bool DrawGrid //Before we check our options page, we need to see if our parent //is a ParentControlDesigner, is so, then we will want to inherit all //our grid/snap setting from it - instead of our options page - // ParentControlDesigner parent = GetParentControlDesignerOfParent(); if (parent is not null) { @@ -240,21 +202,9 @@ protected virtual bool DrawGrid /// /// Determines whether drag rects can be drawn on this designer. /// - protected override bool EnableDragRect - { - get - { - return true; - } - } + protected override bool EnableDragRect => true; - internal Size ParentGridSize - { - get - { - return GridSize; - } - } + internal Size ParentGridSize => GridSize; /// /// Gets/Sets the GridSize property for a form or user control. @@ -270,7 +220,6 @@ protected Size GridSize //Before we check our options page, we need to see if our parent //is a ParentControlDesigner, is so, then we will want to inherit all //our grid/snap setting from it - instead of our options page - // ParentControlDesigner parent = GetParentControlDesignerOfParent(); if (parent is not null) { @@ -279,9 +228,9 @@ protected Size GridSize else { object value = DesignerUtils.GetOptionValue(ServiceProvider, "GridSize"); - if (value is Size) + if (value is Size size) { - _gridSize = (Size)value; + _gridSize = size; } } } @@ -301,9 +250,8 @@ protected Size GridSize } //do some validation checking here, against min & max GridSize - // if (value.Width < MinGridSize || value.Height < MinGridSize || - value.Width > MaxGridSize || value.Height > MaxGridSize) + value.Width > MaxGridSize || value.Height > MaxGridSize) throw new ArgumentException(string.Format(SR.InvalidArgument, "GridSize", value.ToString())); @@ -333,13 +281,7 @@ protected Size GridSize /// in a state where it has a valid MouseDragTool. /// [CLSCompliant(false)] - protected ToolboxItem MouseDragTool - { - get - { - return _mouseDragTool; - } - } + protected ToolboxItem MouseDragTool => _mouseDragTool; /// /// This property is used by deriving classes to determine if it returns the control being designed or some other @@ -348,10 +290,7 @@ protected ToolboxItem MouseDragTool /// e.g: When SplitContainer is selected and a component is being added ... the SplitContainer designer would return a /// SelectedPanel as the ParentControl for all the items being added rather than itself. /// - protected virtual Control GetParentForComponent(IComponent component) - { - return Control; - } + protected virtual Control GetParentForComponent(IComponent component) => Control; // We need to allocation new ArrayList and pass it to the caller.. // So its ok to Suppress this. @@ -402,18 +341,7 @@ public override IList SnapLines } } - private IServiceProvider ServiceProvider - { - get - { - if (Component is not null) - { - return Component.Site; - } - - return null; - } - } + private IServiceProvider ServiceProvider => Component is not null ? Component.Site : (IServiceProvider)null; /// /// Determines if we should snap to grid or not. @@ -422,7 +350,7 @@ private bool SnapToGrid { get { - // If snaplines are on, the we never want to snap to grid + // If snap lines are on, the we never want to snap to grid if (DefaultUseSnapLines) { return false; @@ -434,7 +362,6 @@ private bool SnapToGrid //Before we check our options page, we need to see if our parent //is a ParentControlDesigner, is so, then we will want to inherit all //our grid/snap setting from it - instead of our options page - // ParentControlDesigner parent = GetParentControlDesignerOfParent(); if (parent is not null) { @@ -443,7 +370,7 @@ private bool SnapToGrid else { object optionValue = DesignerUtils.GetOptionValue(ServiceProvider, "SnapToGrid"); - if (optionValue is not null && optionValue is bool) + if (optionValue is not null and bool) { _gridSnap = (bool)optionValue; } @@ -488,8 +415,7 @@ internal virtual void AddChildControl(Control newChild) { if (newChild.Left == 0 && newChild.Top == 0 && newChild.Width >= Control.Width && newChild.Height >= Control.Height) { - // bump the control down one gridsize just so it's selectable... - // + // bump the control down one grid size just so it's selectable... Point loc = newChild.Location; loc.Offset(GridSize.Width, GridSize.Height); newChild.Location = loc; @@ -521,16 +447,14 @@ internal void AddControl(Control newChild, IDictionary defaultValues) // in the document designer so that we will add those guys to the tray. // Also, if the child-control has already been parented, we assume it's also been located and return immediately. // Otherwise, proceed with the parenting and locating. - // IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); if (host is not null && newChild is not null && !Control.Contains(newChild) && (host.GetDesigner(newChild) as ControlDesigner) is not null && !(newChild is Form && ((Form)newChild).TopLevel)) { - Rectangle bounds = default(Rectangle); + Rectangle bounds = default; // If we were provided with a location, convert it to parent control coordinates. // Otherwise, get the control's size and put the location in the middle of it - // if (hasLocation) { location = Control.PointToClient(location); @@ -540,7 +464,6 @@ internal void AddControl(Control newChild, IDictionary defaultValues) else { // is the currently selected control this container? - // ISelectionService selSvc = (ISelectionService)GetService(typeof(ISelectionService)); object primarySelection = selSvc.PrimarySelection; Control selectedControl = null; @@ -551,7 +474,6 @@ internal void AddControl(Control newChild, IDictionary defaultValues) // If the resulting control that came back isn't sited, it's not part of the // design surface and should not be used as a marker. - // if (selectedControl is not null && selectedControl.Site is null) { selectedControl = null; @@ -559,7 +481,6 @@ internal void AddControl(Control newChild, IDictionary defaultValues) // if the currently selected container is this parent // control, default to 0,0 - // if (primarySelection == Component || selectedControl is null) { bounds.X = DefaultControlLocation.X; @@ -568,7 +489,6 @@ internal void AddControl(Control newChild, IDictionary defaultValues) else { // otherwise offset from selected control. - // bounds.X = selectedControl.Location.X + GridSize.Width; bounds.Y = selectedControl.Location.Y + GridSize.Height; } @@ -577,7 +497,6 @@ internal void AddControl(Control newChild, IDictionary defaultValues) // If we were not given a size, ask the control for its default. We // also update the location here so the control is in the middle of // the user's point, rather than at the edge. - // if (hasSize) { bounds.Width = size.Width; @@ -589,39 +508,32 @@ internal void AddControl(Control newChild, IDictionary defaultValues) } // If we were given neither, center the control - // if (!hasSize && !hasLocation) { // get the adjusted location, then inflate // the rect so we can find a nice spot // for this control to live. - // Rectangle tempBounds = GetAdjustedSnapLocation(Rectangle.Empty, bounds); // compute the stacking location - // tempBounds = GetControlStackLocation(tempBounds); bounds = tempBounds; } else { // Finally, convert the bounds to the appropriate grid snaps - // bounds = GetAdjustedSnapLocation(Rectangle.Empty, bounds); } // Adjust for the offset, if any - // bounds.X += offset.Width; bounds.Y += offset.Height; //check to see if we have additional information for bounds from - //the behaviorservice dragdrop logic + //the behavior service drag drop logic if (defaultValues is not null && defaultValues.Contains("ToolboxSnapDragDropEventArgs")) { ToolboxSnapDragDropEventArgs e = defaultValues["ToolboxSnapDragDropEventArgs"] as ToolboxSnapDragDropEventArgs; - Debug.Assert(e is not null, "Why can't we get a ToolboxSnapDragDropEventArgs object out of our default values?"); - Rectangle snappedBounds = DesignerUtils.GetBoundsFromToolboxSnapDragDropInfo(e, bounds, Control.IsMirrored); //Make sure the snapped bounds intersects with the bounds of the root control before we go @@ -637,16 +549,13 @@ internal void AddControl(Control newChild, IDictionary defaultValues) } // Parent the control to the designer and set it to the front. - // - // PropertyDescriptor controlsProp = TypeDescriptor.GetProperties(Control)["Controls"]; _changeService?.OnComponentChanging(Control, controlsProp); AddChildControl(newChild); - // Now see if the control has size and location properties. Update - // these values if it does. - // + // Now see if the control has size and location properties. + // Update these values if it does. PropertyDescriptorCollection props = TypeDescriptor.GetProperties(newChild); if (props is not null) { @@ -654,8 +563,8 @@ internal void AddControl(Control newChild, IDictionary defaultValues) prop?.SetValue(newChild, new Size(bounds.Width, bounds.Height)); //VSWhidbey# 364133 - ControlDesigner shadows the Location property. If the control is parented - //and the parent is a scrollable control, then it expects the Location to be in displayrectangle coordinates. - //At this point bounds are in clientrectangle coordinates, so we need to check if we need to adjust the coordinates. + //and the parent is a scrollable control, then it expects the Location to be in display rectangle coordinates. + //At this point bounds are in client rectangle coordinates, so we need to check if we need to adjust the coordinates. //The reason this worked in Everett was that the AddChildControl was done AFTER this. The AddChildControl was moved //above a while back. Not sure what will break if AddChildControl is moved down below, so let's just fix up things //here. @@ -685,73 +594,71 @@ internal void AddControl(Control newChild, IDictionary defaultValues) private void AddChildComponents(IComponent component, IContainer container, IDesignerHost host) { Control control = GetControl(component); - - if (control is not null) + if (control is null) { - Control parent = control; + return; + } - Control[] children = new Control[parent.Controls.Count]; - parent.Controls.CopyTo(children, 0); + Control parent = control; - string name; - ISite childSite; + Control[] children = new Control[parent.Controls.Count]; + parent.Controls.CopyTo(children, 0); - for (int i = 0; i < children.Length; i++) - { - childSite = ((IComponent)children[i]).Site; + string name; + ISite childSite; - IContainer childContainer; - if (childSite is not null) - { - name = childSite.Name; - if (container.Components[name] is not null) - { - name = null; - } + for (int i = 0; i < children.Length; i++) + { + childSite = ((IComponent)children[i]).Site; - childContainer = childSite.Container; - } - else + IContainer childContainer; + if (childSite is not null) + { + name = childSite.Name; + if (container.Components[name] is not null) { - //name = null; - // we don't want to add unsited child controls because - // these may be items from a composite control. if they - // are legitimate children, the ComponentModelPersister would have - // sited them already. - // - continue; + name = null; } - childContainer?.Remove(children[i]); - - if (name is not null) - { - container.Add(children[i], name); - } - else - { - container.Add(children[i]); - } + childContainer = childSite.Container; + } + else + { + //name = null; + // we don't want to add unsited child controls because + // these may be items from a composite control. if they + // are legitimate children, the ComponentModelPersister would have + // sited them already. + continue; + } - if (children[i].Parent != parent) - { - parent.Controls.Add(children[i]); - } - else - { - // ugh, last resort - int childIndex = parent.Controls.GetChildIndex(children[i]); - parent.Controls.Remove(children[i]); - parent.Controls.Add(children[i]); - parent.Controls.SetChildIndex(children[i], childIndex); - } + childContainer?.Remove(children[i]); - IComponentInitializer init = host.GetDesigner(component) as IComponentInitializer; - init?.InitializeExistingComponent(null); + if (name is not null) + { + container.Add(children[i], name); + } + else + { + container.Add(children[i]); + } - // recurse; - AddChildComponents(children[i], container, host); + if (children[i].Parent != parent) + { + parent.Controls.Add(children[i]); + } + else + { + int childIndex = parent.Controls.GetChildIndex(children[i]); + parent.Controls.Remove(children[i]); + parent.Controls.Add(children[i]); + parent.Controls.SetChildIndex(children[i], childIndex); } + + IComponentInitializer init = host.GetDesigner(component) as IComponentInitializer; + init?.InitializeExistingComponent(null); + + AddChildComponents(children[i], container, host); } } @@ -762,14 +669,8 @@ protected override void Dispose(bool disposing) { if (disposing) { - // Stop any drag that we are currently processing. - - // HACK HACK HACK - // - // See VSWhidbey #575663. - // - // If we are not in a mousedrag, then pretend we are cancelling. - // This is such that the base will not set the primaryselection to be + // If we are not in a mouse drag, then pretend we are cancelling. + // This is such that the base will not set the primary selection to be // the associated Component. Doing so can cause a crash in hosted designers. // It doesn't make sense to do so anyway, since the designer (and thus // the component) is being disposed. @@ -777,9 +678,9 @@ protected override void Dispose(bool disposing) EnableDragDrop(false); - if (Control is ScrollableControl) + if (Control is ScrollableControl control) { - ((ScrollableControl)Control).Scroll -= new ScrollEventHandler(OnScroll); + control.Scroll -= new ScrollEventHandler(OnScroll); } IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); @@ -802,14 +703,16 @@ protected override void Dispose(bool disposing) /// private void DrawGridOfParentChanged(bool drawGrid) { - if (_parentCanSetDrawGrid) + if (!_parentCanSetDrawGrid) { - // If the parent sets us, then treat this as if no one set us - bool getDefaultDrawGridTemp = _getDefaultDrawGrid; - DrawGrid = drawGrid; - _parentCanSetDrawGrid = true; - _getDefaultDrawGrid = getDefaultDrawGridTemp; + return; } + + // If the parent sets us, then treat this as if no one set us + bool getDefaultDrawGridTemp = _getDefaultDrawGrid; + DrawGrid = drawGrid; + _parentCanSetDrawGrid = true; + _getDefaultDrawGrid = getDefaultDrawGridTemp; } /// @@ -918,7 +821,6 @@ protected virtual IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, in { // We invoke the drag drop handler for this. This implementation is shared between all designers that // create components. - // comp = GetOleDragHandler().CreateTool(tool, Control, x, y, width, height, hasLocation, hasSize, _toolboxSnapDragDropEventArgs); } finally @@ -937,13 +839,13 @@ protected virtual IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, in /// private static SnapLine[] GenerateNewToolSnapLines(Rectangle r) { - return new SnapLine[] - { + return + [ new SnapLine(SnapLineType.Left, r.Right), new SnapLine(SnapLineType.Right, r.Right), new SnapLine(SnapLineType.Bottom, r.Bottom), new SnapLine(SnapLineType.Top, r.Bottom) - }; + ]; } /// @@ -1052,7 +954,6 @@ private static Size GetDefaultSize(IComponent component) } // attempt to get the size property of our component - // prop = TypeDescriptor.GetProperties(component)["Size"]; if (prop is not null) @@ -1076,7 +977,6 @@ private static Size GetDefaultSize(IComponent component) } // Couldn't get the size or a def size attrib, returning 75,23... - // return (new Size(75, 23)); } @@ -1196,7 +1096,6 @@ private Rectangle GetAdjustedSnapLocation(Rectangle originalRect, Rectangle drag //ex: groupbox's display rect.x = 3, but we might snap to 0. //so we need to check with the control's designer to make sure this //doesn't happen - // Point minimumLocation = DefaultControlLocation; if (adjustedRect.X < minimumLocation.X) { @@ -1240,13 +1139,11 @@ protected Rectangle GetUpdatedRect(Rectangle originalRect, Rectangle dragRect, b updatedRect.Y = originalRect.Y; // decide to snap the start location to grid ... - // if (dragRect.X != originalRect.X) { updatedRect.X = (dragRect.X / gridSize.Width) * gridSize.Width; // Snap the location to the grid point closest to the dragRect location - // if (dragRect.X - updatedRect.X > halfGrid.X) { updatedRect.X += gridSize.Width; @@ -1258,7 +1155,6 @@ protected Rectangle GetUpdatedRect(Rectangle originalRect, Rectangle dragRect, b updatedRect.Y = (dragRect.Y / gridSize.Height) * gridSize.Height; // Snap the location to the grid point closest to the dragRect location - // if (dragRect.Y - updatedRect.Y > halfGrid.Y) { updatedRect.Y += gridSize.Height; @@ -1266,17 +1162,14 @@ protected Rectangle GetUpdatedRect(Rectangle originalRect, Rectangle dragRect, b } // here, we need to calculate the new size depending on how we snap to the grid ... - // if (updateSize) { // update the width and the height - // updatedRect.Width = ((dragRect.X + dragRect.Width) / gridSize.Width) * gridSize.Width - updatedRect.X; updatedRect.Height = ((dragRect.Y + dragRect.Height) / gridSize.Height) * gridSize.Height - updatedRect.Y; // ASURT 71552 Added so that if the updated dimension is smaller than grid dimension then snap that dimension to // the grid dimension - // if (updatedRect.Width < gridSize.Width) updatedRect.Width = gridSize.Width; if (updatedRect.Height < gridSize.Height) @@ -1309,7 +1202,6 @@ public override void Initialize(IComponent component) // Hook load events. At the end of load, we need to do a scan through all // of our child controls to see which ones are being inherited. We // connect these up. - // IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); if (host is not null) { @@ -1382,7 +1274,6 @@ public override void InitializeNewComponent(IDictionary defaultValues) //Finally, we have identified that we need to re-parent the lasso'd controls. //We will start a designer transaction, send some changing notifications //and swap parents... - // ReParentControls(Control, selectedControls, string.Format(SR.ParentControlDesignerLassoShortcutRedo, Control.Site.Name), host); } } @@ -1572,7 +1463,6 @@ protected override void OnDragEnter(DragEventArgs de) // If tab order UI is being shown, then don't allow anything to be // dropped here. - // IMenuCommandService ms = (IMenuCommandService)GetService(typeof(IMenuCommandService)); if (ms is not null) { @@ -1585,7 +1475,6 @@ protected override void OnDragEnter(DragEventArgs de) } // Get the objects that are being dragged - // object[] dragComps; if (behDataObject is not null && behDataObject.DragComponents is not null) { @@ -1644,7 +1533,6 @@ protected override void OnDragEnter(DragEventArgs de) } // try go get the control for the thing that's being dragged - // object draggedDesigner = host.GetDesigner(comp); if (draggedDesigner is IOleDragClient) { @@ -1658,7 +1546,6 @@ protected override void OnDragEnter(DragEventArgs de) } // oh well, it's not a control so it doesn't matter - // if (draggedControl is null) { continue; @@ -1667,7 +1554,6 @@ protected override void OnDragEnter(DragEventArgs de) // If we're inheriting from a private container, we can't modify the controls collection. // So drag-drop is only allowed within the container i.e. the dragged controls must already // be parented to this container. - // if (InheritanceAttribute == InheritanceAttribute.InheritedReadOnly && draggedControl.Parent != Control) { de.Effect = DragDropEffects.None; @@ -1694,7 +1580,6 @@ protected override void OnDragEnter(DragEventArgs de) _toolboxService ??= (IToolboxService)GetService(typeof(IToolboxService)); // Only assume the items came from the ToolBox if dragComps == null - // if (_toolboxService is not null && dragComps is null) { _mouseDragTool = _toolboxService.DeserializeToolboxItem(de.Data, host); @@ -1747,7 +1632,6 @@ private void PerformDragEnter(DragEventArgs de, IDesignerHost host) } // Also, select this parent control to indicate it will be the drop target. - // ISelectionService sel = (ISelectionService)GetService(typeof(ISelectionService)); sel?.SetSelectedComponents(new object[] { Component }, SelectionTypes.Replace); } @@ -1782,7 +1666,6 @@ protected override void OnDragOver(DragEventArgs de) // If tab order UI is being shown, then don't allow anything to be // dropped here. - // IMenuCommandService ms = (IMenuCommandService)GetService(typeof(IMenuCommandService)); if (ms is not null) { @@ -1834,7 +1717,6 @@ protected override void OnMouseDragBegin(int x, int y) // a component group, and a thick line for creating a new component. // If we are a privately inherited component, then we always use the // selection frame because we can't add components. - // if (!InheritanceAttribute.Equals(InheritanceAttribute.InheritedReadOnly)) { _toolboxService ??= (IToolboxService)GetService(typeof(IToolboxService)); @@ -1860,7 +1742,6 @@ protected override void OnMouseDragBegin(int x, int y) // Get the event handler service. We push a handler to handle the escape // key. - // IEventHandlerService eventSvc = (IEventHandlerService)GetService(typeof(IEventHandlerService)); //UNDONE: Behavior Work //Debug.Assert(escapeHandler == null, "Why is there already an escape handler?"); @@ -1883,7 +1764,6 @@ protected override void OnMouseDragBegin(int x, int y) protected override void OnMouseDragEnd(bool cancel) { // Do nothing if we're not dragging anything around - // if (_mouseDragBase == InvalidPoint) { Debug.Assert(_graphics is null); @@ -1893,7 +1773,6 @@ protected override void OnMouseDragEnd(bool cancel) } // Important to null these out here, just in case we throw an exception - // Rectangle offset = _mouseDragOffset; ToolboxItem tool = _mouseDragTool; Point baseVar = _mouseDragBase; @@ -1938,7 +1817,6 @@ protected override void OnMouseDragEnd(bool cancel) } // Get the event handler service and pop our handler. - // IEventHandlerService eventSvc = (IEventHandlerService)GetService(typeof(IEventHandlerService)); if (eventSvc is not null && _escapeHandler is not null) { @@ -2038,7 +1916,6 @@ protected override void OnMouseDragMove(int x, int y) // if we're doing an OLE drag, do nothing, or // Do nothing if we haven't initiated a drag - // if (GetOleDragHandler().Dragging || _mouseDragBase == InvalidPoint) { return; @@ -2047,7 +1924,6 @@ protected override void OnMouseDragMove(int x, int y) Rectangle oldFrameRect = _mouseDragOffset; // Calculate the new offset. - // _mouseDragOffset.X = _mouseDragBase.X; _mouseDragOffset.Y = _mouseDragBase.Y; _mouseDragOffset.Width = x - _mouseDragBase.X; @@ -2089,12 +1965,10 @@ protected override void OnMouseDragMove(int x, int y) // If we're dragging out a new component, update the drag rectangle // to use snaps, if they're set. - // if (_mouseDragTool is not null) { // To snap properly, we must snap in client coordinates. So, convert, snap // and re-convert. - // _mouseDragOffset = Control.RectangleToClient(_mouseDragOffset); _mouseDragOffset = GetUpdatedRect(Rectangle.Empty, _mouseDragOffset, true); _mouseDragOffset = Control.RectangleToScreen(_mouseDragOffset); @@ -2281,7 +2155,6 @@ private void ReParentControls(Control newParent, ArrayList controls, string tran changeService?.OnComponentChanging(newParent, controlsProp); //enumerate the lasso'd controls relocate and re-parent... - // foreach (object comp in controls) { Control control = comp as Control; @@ -2355,7 +2228,6 @@ private bool ShouldSerializeDrawGrid() //To determine if we need to persist this value, we first need to check //if we have a parent who is a parentcontroldesigner, then get their //setting... - // ParentControlDesigner parent = GetParentControlDesignerOfParent(); if (parent is not null) { @@ -2363,7 +2235,6 @@ private bool ShouldSerializeDrawGrid() } //Otherwise, we'll compare the value to the options page... - // return !IsOptionDefault("ShowGrid", DrawGrid); } @@ -2375,7 +2246,6 @@ private bool ShouldSerializeSnapToGrid() //To determine if we need to persist this value, we first need to check //if we have a parent who is a parentcontroldesigner, then get their //setting... - // ParentControlDesigner parent = GetParentControlDesignerOfParent(); if (parent is not null) { @@ -2383,7 +2253,6 @@ private bool ShouldSerializeSnapToGrid() } //Otherwise, we'll compare the value to the options page... - // return !IsOptionDefault("SnapToGrid", SnapToGrid); } @@ -2395,7 +2264,6 @@ private bool ShouldSerializeGridSize() //To determine if we need to persist this value, we first need to check //if we have a parent who is a parentcontroldesigner, then get their //setting... - // ParentControlDesigner parent = GetParentControlDesignerOfParent(); if (parent is not null) { @@ -2403,7 +2271,6 @@ private bool ShouldSerializeGridSize() } //Otherwise, we'll compare the value to the options page... - // return !IsOptionDefault("GridSize", GridSize); } @@ -2489,7 +2356,6 @@ bool IOleDragClient.AddComponent(IComponent component, string name, bool firstAd // make sure this designer will accept this component -- we wait until // now to be sure the components designer has been created. - // if (!((IOleDragClient)this).IsDropOk(component)) { try @@ -2531,7 +2397,6 @@ bool IOleDragClient.AddComponent(IComponent component, string name, bool firstAd } // make sure we can handle this thing, otherwise hand it to the base components designer - // Control c = GetControl(component); if (c is not null) @@ -2565,7 +2430,6 @@ bool IOleDragClient.AddComponent(IComponent component, string name, bool firstAd parent.Controls.Add(c); // sburke 78059 -- not sure why we need this call. this should move things to the beginning of the // z-order, but do we need that? - // //parent.Controls.SetChildIndex(c, 0); _changeService?.OnComponentChanged(parent, controlsProp, parent.Controls, parent.Controls); } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PbrsForward.BufferedKey.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PbrsForward.BufferedKey.cs index c245d3716b0..7dc0bf580f1 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PbrsForward.BufferedKey.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PbrsForward.BufferedKey.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PbrsForward.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PbrsForward.cs index 15278a61cc8..6240248e0bb 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PbrsForward.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PbrsForward.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PictureBoxActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PictureBoxActionList.cs index ab7c8fdc658..d01dd195f46 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PictureBoxActionList.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PictureBoxActionList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PictureBoxDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PictureBoxDesigner.cs index 5f9e3757d7d..9a192993c91 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PictureBoxDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PictureBoxDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PrintDialogDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PrintDialogDesigner.cs new file mode 100644 index 00000000000..a6c2c1cdc46 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PrintDialogDesigner.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections; +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design; + +internal class PrintDialogDesigner : ComponentDesigner +{ + /// + /// This method is called when a component is first initialized, typically after being first added + /// to a design surface. The defaultValues property contains a name/value dictionary of default + /// values that should be applied to properties. This dictionary may be null if no default values + /// are specified. You may perform any initialization of this component that you like, and you + /// may even ignore the defaultValues dictionary altogether if you wish. + /// The default implementation of this method does nothing. + /// + public override void InitializeNewComponent(IDictionary defaultValues) + { + if (Component is PrintDialog dialog) + { + dialog.UseEXDialog = true; + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PropertyGridDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PropertyGridDesigner.cs new file mode 100644 index 00000000000..a6851f2b926 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/PropertyGridDesigner.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections; + +namespace System.Windows.Forms.Design; + +internal class PropertyGridDesigner : ControlDesigner +{ + protected override void PreFilterProperties(IDictionary properties) + { + // Remove the ScrollableControl properties... + properties.Remove(nameof(PropertyGrid.AutoScroll)); + properties.Remove(nameof(PropertyGrid.AutoScrollMargin)); + properties.Remove(nameof(PropertyGrid.AutoScrollMinSize)); + properties.Remove(nameof(PropertyGrid.DockPadding)); + + base.PreFilterProperties(properties); + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RadioButtonDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RadioButtonDesigner.cs index 1f98b142f29..e1db2786bf4 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RadioButtonDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RadioButtonDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RichTextBoxActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RichTextBoxActionList.cs index 82f6eb85cfa..10fa8d88b76 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RichTextBoxActionList.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RichTextBoxActionList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RichTextBoxDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RichTextBoxDesigner.cs index a2d45f0403b..cf18ad31a5e 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RichTextBoxDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/RichTextBoxDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SaveFileDialogDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SaveFileDialogDesigner.cs new file mode 100644 index 00000000000..81c5b7b54fa --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SaveFileDialogDesigner.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design; + +internal class SaveFileDialogDesigner : ComponentDesigner +{ + // Overridden to avoid setting the default property ("FileName") + // to the Site.Name (i.e. saveFileDialog1). + protected override bool SetTextualDefaultProperty => false; +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ScrollableControlDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ScrollableControlDesigner.cs index 63626fcd5e9..e612421c9ca 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ScrollableControlDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ScrollableControlDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectedPathEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectedPathEditor.cs index 39e9720b4ca..037d9f44c42 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectedPathEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectedPathEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionRules.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionRules.cs index 7791206ca1f..809f65e5fd7 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionRules.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionRules.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionStyles.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionStyles.cs index 9f18e7f98bd..f22d40d2936 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionStyles.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionStyles.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIHandler.cs index 6d49041494b..518bf303c0b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -39,7 +38,7 @@ internal abstract class SelectionUIHandler /// public virtual bool BeginDrag(object[] components, SelectionRules rules, int initialX, int initialY) { - dragOffset = default(Rectangle); + dragOffset = default; originalCoords = null; this.rules = rules; @@ -93,7 +92,7 @@ private static void CancelControlMove(Control[] controls, BoundsInfo[] bounds) { Debug.Assert(bounds is not null && controls is not null && bounds.Length == controls.Length, "bounds->controls mismatch"); - Rectangle b = default(Rectangle); + Rectangle b = default; // Whip through each of the controls. // @@ -209,7 +208,7 @@ private void MoveControls(object[] components, bool cancel, bool finalMove) Control[] controls = dragControls; Rectangle offset = dragOffset; BoundsInfo[] bounds = originalCoords; - Point adjustedLoc = default(Point); + Point adjustedLoc = default; // Erase the clipping and other state if this is the final move. // diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.ContainerSelectionUIItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.ContainerSelectionUIItem.cs index bc3196180e7..f1094b100d3 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.ContainerSelectionUIItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.ContainerSelectionUIItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.HitTestInfo.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.HitTestInfo.cs index 3679146c78c..783a87f9843 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.HitTestInfo.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.HitTestInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.SelectionUIItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.SelectionUIItem.cs index 42ad4ec2af0..c17f5c2cc31 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.SelectionUIItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.SelectionUIItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.cs index 8986b203675..4fdb4c36266 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -17,7 +16,7 @@ namespace System.Windows.Forms.Design; /// internal sealed partial class SelectionUIService : Control, ISelectionUIService { - private static readonly Point s_invalidPoint = new Point(int.MinValue, int.MinValue); + private static readonly Point s_invalidPoint = new(int.MinValue, int.MinValue); private const int HITTEST_CONTAINER_SELECTOR = 0x0001; private const int HITTEST_NORMAL_SELECTION = 0x0002; private const int HITTEST_DEFAULT = HITTEST_CONTAINER_SELECTOR | HITTEST_NORMAL_SELECTION; @@ -106,7 +105,7 @@ private void BeginMouseDrag(Point anchor, int hitTest) _mouseDragAnchor = anchor; _mouseDragging = true; _mouseDragHitTest = hitTest; - _mouseDragOffset = default(Rectangle); + _mouseDragOffset = default; _savedVisible = Visible; } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ServiceProviderExtensions.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ServiceProviderExtensions.cs index 3780fa80ce8..eaaeee3e23c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ServiceProviderExtensions.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ServiceProviderExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ShortcutKeysEditor.ShortcutKeysUI.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ShortcutKeysEditor.ShortcutKeysUI.cs index c5b4f220bfb..ab7d6bbd4e1 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ShortcutKeysEditor.ShortcutKeysUI.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ShortcutKeysEditor.ShortcutKeysUI.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ShortcutKeysEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ShortcutKeysEditor.cs index efd1de71cf0..1f9f55e4dbd 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ShortcutKeysEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ShortcutKeysEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.OrientationActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.OrientationActionList.cs index 0b1ba275c7b..4cbe0c9ed4d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.OrientationActionList.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.OrientationActionList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; @@ -58,7 +57,7 @@ private void OnOrientationActionClick(object? sender, EventArgs e) actionUIService.Refresh(_ownerComponent); } - public override DesignerActionItemCollection GetSortedActionItems() => new DesignerActionItemCollection + public override DesignerActionItemCollection GetSortedActionItems() => new() { new DesignerActionVerbItem(new DesignerVerb(_actionName!, OnOrientationActionClick)) }; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.cs index d981202bc3b..137637703c4 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -37,7 +36,7 @@ internal partial class SplitContainerDesigner : ParentControlDesigner /// /// Gets the design-time supported actions on the control. /// - public override DesignerActionListCollection ActionLists => new DesignerActionListCollection() + public override DesignerActionListCollection ActionLists => new() { new OrientationActionList(this) }; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitterDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitterDesigner.cs index aa15d285ffb..c00a7515d56 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitterDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitterDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Drawing2D; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitterPanelDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitterPanelDesigner.cs index 7859d5cdb30..83107fe8d19 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitterPanelDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitterPanelDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardCommandToolStripMenuItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardCommandToolStripMenuItem.cs index c575bde85a8..fed0d22929f 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardCommandToolStripMenuItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardCommandToolStripMenuItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardGroups.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardGroups.cs index ceff2f129e1..cd163541668 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardGroups.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardGroups.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardMenuStripVerb.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardMenuStripVerb.cs index 1242bda498c..552acd25a6a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardMenuStripVerb.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StandardMenuStripVerb.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StatusCommandUI.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StatusCommandUI.cs index a460d4c1c51..1b26a021934 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StatusCommandUI.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StatusCommandUI.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringArrayEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringArrayEditor.cs index 54bd4469105..7373b4fe604 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringArrayEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringArrayEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringCollectionEditor.StringCollectionForm.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringCollectionEditor.StringCollectionForm.cs index b50784132bd..eed86781b16 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringCollectionEditor.StringCollectionForm.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringCollectionEditor.StringCollectionForm.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringCollectionEditor.cs index ec0f960fbe9..cf8f26ed7eb 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringCollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/StringCollectionEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabControlDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabControlDesigner.cs new file mode 100644 index 00000000000..de88d666dd7 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabControlDesigner.cs @@ -0,0 +1,662 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#nullable disable + +using System.Collections; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing.Design; +using System.Drawing; +using System.Windows.Forms.Design.Behavior; +using static Interop; + +namespace System.Windows.Forms.Design; + +internal class TabControlDesigner : ParentControlDesigner +{ + private bool tabControlSelected; + private DesignerVerbCollection verbs; + private DesignerVerb removeVerb; + private bool disableDrawGrid; + private int persistedSelectedIndex; + private bool addingOnInitialize; + private bool forwardOnDrag; + + protected override bool AllowControlLasso => false; + + protected override bool DrawGrid + { + get + { + if (disableDrawGrid) + { + return false; + } + + return base.DrawGrid; + } + } + + public override bool ParticipatesWithSnapLines + { + get + { + if (!forwardOnDrag) + { + return false; + } + else + { + TabPageDesigner pageDesigner = GetSelectedTabPageDesigner(); + if (pageDesigner is not null) + { + return pageDesigner.ParticipatesWithSnapLines; + } + + return true; + } + } + } + + private int SelectedIndex + { + get + { + return persistedSelectedIndex; + } + set + { + // TabBase.SelectedIndex has no validation logic, so neither do we + persistedSelectedIndex = value; + } + } + + public override DesignerVerbCollection Verbs + { + get + { + if (verbs is null) + { + removeVerb = new DesignerVerb(SR.TabControlRemove, new EventHandler(OnRemove)); + + verbs = new DesignerVerbCollection(); + verbs.Add(new DesignerVerb(SR.TabControlAdd, new EventHandler(OnAdd))); + verbs.Add(removeVerb); + } + + if (Control is not null) + { + removeVerb.Enabled = Control.Controls.Count > 0; + } + + return verbs; + } + } + + public override void InitializeNewComponent(IDictionary defaultValues) + { + base.InitializeNewComponent(defaultValues); + + // Add 2 tab pages + // member is OK to be null... + try + { + addingOnInitialize = true; + OnAdd(this, EventArgs.Empty); + OnAdd(this, EventArgs.Empty); + } + finally + { + addingOnInitialize = false; + } + + MemberDescriptor member = TypeDescriptor.GetProperties(component: Component)["Controls"]; + RaiseComponentChanging(member); + RaiseComponentChanged(member, null, null); + + TabControl tc = (TabControl)Component; + if (tc is not null) + { //always Select the First Tab on Initialising the component... + tc.SelectedIndex = 0; + } + } + + // If the tabcontrol already contains the control we are dropping then don't allow the drop. + // I.e. we don't want to allow local drag-drop for tabcontrols. + public override bool CanParent(Control control) => (control is TabPage && !Control.Contains(control)); + + private void CheckVerbStatus() + { + if (removeVerb is not null) + { + removeVerb.Enabled = Control.Controls.Count > 0; + } + } + + protected override IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize) + { + TabControl tc = ((TabControl)Control); + //VSWhidbey #409457 + if (tc.SelectedTab is null) + { + throw new ArgumentException(string.Format(SR.TabControlInvalidTabPageType, tool.DisplayName)); + } + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host is not null) + { + TabPageDesigner selectedTabPageDesigner = host.GetDesigner(tc.SelectedTab) as TabPageDesigner; + InvokeCreateTool(selectedTabPageDesigner, tool); + } + + // InvokeCreate Tool will do the necessary hookups. + return null; + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + ISelectionService svc = (ISelectionService)GetService(typeof(ISelectionService)); + if (svc is not null) + { + svc.SelectionChanged -= new EventHandler(OnSelectionChanged); + } + + IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + if (cs is not null) + { + cs.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged); + } + + TabControl tabControl = Control as TabControl; + if (tabControl is not null) + { + tabControl.SelectedIndexChanged -= new EventHandler(OnTabSelectedIndexChanged); + tabControl.GotFocus -= new EventHandler(OnGotFocus); + tabControl.RightToLeftLayoutChanged -= new EventHandler(OnRightToLeftLayoutChanged); + tabControl.ControlAdded -= new ControlEventHandler(OnControlAdded); + } + } + + base.Dispose(disposing); + } + + protected override bool GetHitTest(Point point) + { + TabControl tc = ((TabControl)Control); + + // tabControlSelected tells us if a tab page or the tab control itself is selected. + // If the tab control is selected, then we need to return true from here - so we can switch back and forth + // between tabs. If we're not currently selected, we want to select the tab control + // so return false. + if (tabControlSelected) + { + Point hitTest = Control.PointToClient(point); + return !tc.DisplayRectangle.Contains(hitTest); + } + + return false; + } + + internal static TabPage GetTabPageOfComponent(TabControl parent, object comp) + { + if (!(comp is Control)) + { + return null; + } + + Control c = (Control)comp; + while (c is not null) + { + TabPage page = c as TabPage; + if (page is not null && page.Parent == parent) + { + return page; + } + + c = c.Parent; + } + + return null; + } + + public override void Initialize(IComponent component) + { + base.Initialize(component); + + AutoResizeHandles = true; + TabControl control = component as TabControl; + Debug.Assert(control is not null, "Component must be a tab control, it is a: " + component.GetType().FullName); + + ISelectionService svc = (ISelectionService)GetService(typeof(ISelectionService)); + if (svc is not null) + { + svc.SelectionChanged += new EventHandler(OnSelectionChanged); + } + + IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + if (cs is not null) + { + cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); + } + + if (control is not null) + { + control.SelectedIndexChanged += new EventHandler(OnTabSelectedIndexChanged); + control.GotFocus += new EventHandler(OnGotFocus); + control.RightToLeftLayoutChanged += new EventHandler(OnRightToLeftLayoutChanged); + control.ControlAdded += new ControlEventHandler(OnControlAdded); + } + } + + private void OnAdd(object sender, EventArgs eevent) + { + TabControl tc = (TabControl)Component; + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host is not null) + { + DesignerTransaction t = null; + try + { + try + { + t = host.CreateTransaction(string.Format(SR.TabControlAddTab, Component.Site.Name)); + } + catch (CheckoutException ex) + { + if (ex == CheckoutException.Canceled) + { + return; + } + + throw new CheckoutException("Checkout Error", ex); + } + + MemberDescriptor member = TypeDescriptor.GetProperties(tc)["Controls"]; + TabPage page = (TabPage)host.CreateComponent(typeof(TabPage)); + if (!addingOnInitialize) + { + RaiseComponentChanging(member); + } + + // NOTE: We also modify padding of TabPages added through the TabPageCollectionEditor. + // If you need to change the default Padding, change it there as well. + page.Padding = new Padding(3); + + string pageText = null; + + PropertyDescriptor nameProp = TypeDescriptor.GetProperties(page)["Name"]; + if (nameProp is not null && nameProp.PropertyType == typeof(string)) + { + pageText = nameProp.GetValue(page) as string; + } + + if (pageText is not null) + { + PropertyDescriptor textProperty = TypeDescriptor.GetProperties(page)["Text"]; + Debug.Assert(textProperty is not null, "Could not find 'Text' property in TabPage."); + textProperty?.SetValue(page, pageText); + } + + PropertyDescriptor styleProp = TypeDescriptor.GetProperties(page)["UseVisualStyleBackColor"]; + if (styleProp is not null && styleProp.PropertyType == typeof(bool) && !styleProp.IsReadOnly && styleProp.IsBrowsable) + { + styleProp.SetValue(page, true); + } + + tc.Controls.Add(page); + // Make sure that the last tab is selected. + tc.SelectedIndex = tc.TabCount - 1; + if (!addingOnInitialize) + { + RaiseComponentChanged(member, null, null); + } + } + finally + { + t?.Commit(); + } + } + } + + private void OnComponentChanged(object sender, ComponentChangedEventArgs e) => CheckVerbStatus(); + + private void OnGotFocus(object sender, EventArgs e) + { + IEventHandlerService eventSvc = (IEventHandlerService)GetService(typeof(IEventHandlerService)); + if (eventSvc is not null) + { + Control focusWnd = eventSvc.FocusWindow; + focusWnd?.Focus(); + } + } + + private void OnRemove(object sender, EventArgs eevent) + { + TabControl tc = (TabControl)Component; + + // if the control is null, or there are not tab pages, get out!... + if (tc is null || tc.TabPages.Count == 0) + { + return; + } + + // member is OK to be null... + MemberDescriptor member = TypeDescriptor.GetProperties(Component)["Controls"]; + + TabPage tp = tc.SelectedTab; + + // destroy the page + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host is not null) + { + DesignerTransaction t = null; + try + { + try + { + t = host.CreateTransaction(string.Format(SR.TabControlRemoveTab, ((IComponent)tp).Site.Name, Component.Site.Name)); + RaiseComponentChanging(member); + } + catch (CheckoutException ex) + { + if (ex == CheckoutException.Canceled) + { + return; + } + + throw new CheckoutException("Checkout Error", ex); + } + + if (tp is not null) + { + host.DestroyComponent(tp); + } + + RaiseComponentChanged(member, null, null); + } + finally + { + t?.Commit(); + } + } + } + + protected override void OnPaintAdornments(PaintEventArgs pe) + { + try + { + disableDrawGrid = true; + // we don't want to do this for the tab control designer because you can't drag anything onto it anyway. + // so we will always return false for draw grid. + base.OnPaintAdornments(pe); + } + finally + { + disableDrawGrid = false; + } + } + + private void OnControlAdded(object sender, ControlEventArgs e) + { + if (e.Control is not null && !e.Control.IsHandleCreated) + { + IntPtr hwnd = e.Control.Handle; + } + } + + private void OnRightToLeftLayoutChanged(object sender, EventArgs e) => BehaviorService?.SyncSelection(); + + private void OnSelectionChanged(object sender, EventArgs e) + { + ISelectionService svc = (ISelectionService)GetService(typeof(ISelectionService)); + + tabControlSelected = false;//this is for HitTest purposes + + if (svc is not null) + { + ICollection selComponents = svc.GetSelectedComponents(); + + TabControl tabControl = (TabControl)Component; + + foreach (object comp in selComponents) + { + if (comp == tabControl) + { + tabControlSelected = true;//this is for HitTest purposes + } + + TabPage page = GetTabPageOfComponent(tabControl, comp); + + if (page is not null && page.Parent == tabControl) + { + tabControlSelected = false; //this is for HitTest purposes + tabControl.SelectedTab = page; + SelectionManager selMgr = (SelectionManager)GetService(typeof(SelectionManager)); + selMgr.Refresh(); + break; + } + } + } + } + + private void OnTabSelectedIndexChanged(object sender, EventArgs e) + { + // if this was called as a result of a prop change, don't set the selection to the control (causes flicker) + // Attempt to select the tab control + ISelectionService svc = (ISelectionService)GetService(typeof(ISelectionService)); + if (svc is not null) + { + ICollection selComponents = svc.GetSelectedComponents(); + + TabControl tabControl = (TabControl)Component; + bool selectedComponentOnTab = false; + + foreach (object comp in selComponents) + { + TabPage page = GetTabPageOfComponent(tabControl, comp); + if (page is not null && page.Parent == tabControl && page == tabControl.SelectedTab) + { + selectedComponentOnTab = true; + break; + } + } + + if (!selectedComponentOnTab) + { + svc.SetSelectedComponents(new object[] { Component }); + } + } + } + + protected override void PreFilterProperties(IDictionary properties) + { + base.PreFilterProperties(properties); + + // Handle shadowed properties + string[] shadowProps = new string[] + { + "SelectedIndex", + }; + + Attribute[] empty = Array.Empty(); + + for (int i = 0; i < shadowProps.Length; i++) + { + PropertyDescriptor prop = properties[shadowProps[i]] as PropertyDescriptor; + if (prop is not null) + { + properties[shadowProps[i]] = TypeDescriptor.CreateProperty(typeof(TabControlDesigner), prop, empty); + } + } + } + + private TabPageDesigner GetSelectedTabPageDesigner() + { + TabPageDesigner pageDesigner = null; + TabPage selectedTab = ((TabControl)Component).SelectedTab; + if (selectedTab is not null) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host is not null) + { + pageDesigner = host.GetDesigner(selectedTab) as TabPageDesigner; + } + } + + return pageDesigner; + } + + protected override void OnDragEnter(DragEventArgs de) + { + // Check what we are dragging... If we are just dragging tab pages, then we do not want to forward the OnDragXXX + forwardOnDrag = false; + + DropSourceBehavior.BehaviorDataObject data = de.Data as DropSourceBehavior.BehaviorDataObject; + if (data is not null) + { + ArrayList dragControls; + int primaryIndex = -1; + dragControls = new ArrayList(data.GetSortedDragControls(ref primaryIndex)); + if (dragControls is not null) + { + for (int i = 0; i < dragControls.Count; i++) + { + if (!(dragControls[i] is Control) || (dragControls[i] is Control && !(dragControls[i] is TabPage))) + { + forwardOnDrag = true; + break; + } + } + } + } + else + { + // We must be dragging something off the toolbox, so forward the drag to the right tabpage. + forwardOnDrag = true; + } + + if (forwardOnDrag) + { + TabPageDesigner pageDesigner = GetSelectedTabPageDesigner(); + pageDesigner?.OnDragEnterInternal(de); + } + else + { + base.OnDragEnter(de); + } + } + + protected override void OnDragDrop(DragEventArgs de) + { + if (forwardOnDrag) + { + TabPageDesigner pageDesigner = GetSelectedTabPageDesigner(); + pageDesigner?.OnDragDropInternal(de); + } + else + { + base.OnDragDrop(de); + } + + forwardOnDrag = false; + } + + protected override void OnDragLeave(EventArgs e) + { + if (forwardOnDrag) + { + TabPageDesigner pageDesigner = GetSelectedTabPageDesigner(); + pageDesigner?.OnDragLeaveInternal(e); + } + else + { + base.OnDragLeave(e); + } + + forwardOnDrag = false; + } + + protected override void OnDragOver(DragEventArgs de) + { + if (forwardOnDrag) + { + //Need to make sure that we are over a valid area. VSWhidbey# 354139. Now that all dragging/dropping is done via + //the behavior service and adorner window, we have to do our own validation, and cannot rely on the OS to do it for us. + TabControl tc = ((TabControl)Control); + Point dropPoint = Control.PointToClient(new Point(de.X, de.Y)); + if (!tc.DisplayRectangle.Contains(dropPoint)) + { + de.Effect = DragDropEffects.None; + return; + } + + TabPageDesigner pageDesigner = GetSelectedTabPageDesigner(); + pageDesigner?.OnDragOverInternal(de); + } + else + { + base.OnDragOver(de); + } + } + + protected override void OnGiveFeedback(GiveFeedbackEventArgs e) + { + if (forwardOnDrag) + { + TabPageDesigner pageDesigner = GetSelectedTabPageDesigner(); + pageDesigner?.OnGiveFeedbackInternal(e); + } + else + { + base.OnGiveFeedback(e); + } + } + + protected override void WndProc(ref Message m) + { + switch (m.MsgInternal) + { + case PInvoke.WM_NCHITTEST: + // The tab control always fires HTTRANSPARENT in empty areas, which causes the message to go to our parent. We want + // the tab control's designer to get these messages, however, so change this. + base.WndProc(ref m); + if (m.ResultInternal == PInvoke.HTTRANSPARENT) + { + m.ResultInternal = (LRESULT)(nint)PInvoke.HTCLIENT; + } + + break; + case PInvoke.WM_CONTEXTMENU: +                // We handle this in addition to a right mouse button. +                // Why?  Because we often eat the right mouse button, so +                // it may never generate a WM_CONTEXTMENU.  However, the +                // system may generate one in response to an F-10. +                int x = PARAM.SignedLOWORD(m.LParamInternal); + int y = PARAM.SignedHIWORD(m.LParamInternal); + if (x == -1 && y == -1) + { +                    // for shift-F10 +                    Point p = Cursor.Position; + x = p.X; + y = p.Y; + } + + OnContextMenu(x, y); + break; + case PInvoke.WM_HSCROLL: + case PInvoke.WM_VSCROLL: + //We do this so that we can update the areas covered by glyphs correctly. VSWhidbey# 187405. + //We just invalidate the area corresponding to the ClientRectangle in the adornerwindow. + BehaviorService.Invalidate(BehaviorService.ControlRectInAdornerWindow(Control)); + base.WndProc(ref m); + break; + default: + base.WndProc(ref m); + break; + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabOrder.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabOrder.cs index 9e9ba09b17b..90e72452294 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabOrder.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabOrder.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabPageCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabPageCollectionEditor.cs index b4da0c92b7a..ef336aa518f 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabPageCollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabPageCollectionEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabPageDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabPageDesigner.cs new file mode 100644 index 00000000000..55eddd5f1ca --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabPageDesigner.cs @@ -0,0 +1,53 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel.Design; +using System.Drawing; +using System.Windows.Forms.Design.Behavior; + +namespace System.Windows.Forms.Design; + +internal class TabPageDesigner : PanelDesigner +{ + public override bool CanBeParentedTo(IDesigner parentDesigner) => (parentDesigner is not null && parentDesigner.Component is TabControl); + + public override SelectionRules SelectionRules + { + get + { + SelectionRules rules = base.SelectionRules; + Control ctl = Control; + + if (ctl is not null && ctl.Parent is TabControl) + { + rules &= ~SelectionRules.AllSizeable; + } + + return rules; + } + } + + internal void OnDragDropInternal(DragEventArgs de) => OnDragDrop(de); + + internal void OnDragEnterInternal(DragEventArgs de) => OnDragEnter(de); + + internal void OnDragLeaveInternal(EventArgs e) => OnDragLeave(e); + + internal void OnDragOverInternal(DragEventArgs e) => OnDragOver(e); + + internal void OnGiveFeedbackInternal(GiveFeedbackEventArgs e) => OnGiveFeedback(e); + + protected override ControlBodyGlyph GetControlGlyph(GlyphSelectionType selectionType) + { + // create a new body glyph with empty bounds. This will keep incorrect tab pages from stealing drag/drop messages + // which are now handled by the TabControlDesigner get the right cursor for this component. + OnSetCursor(); + + Rectangle translatedBounds = Rectangle.Empty; + + //create our glyph, and set its cursor appropriately + ControlBodyGlyph g = new ControlBodyGlyph(translatedBounds, Cursor.Current, Control, this); + + return g; + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutControlCollectionCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutControlCollectionCodeDomSerializer.cs index 9f24627e279..a209efe2019 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutControlCollectionCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutControlCollectionCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutPanelCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutPanelCodeDomSerializer.cs index cbf1212a409..cee63445d23 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutPanelCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutPanelCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutPanelDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutPanelDesigner.cs new file mode 100644 index 00000000000..36b05cdfd03 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutPanelDesigner.cs @@ -0,0 +1,2279 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#nullable disable + +using System.Collections; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing.Design; +using System.Drawing; +using System.Windows.Forms.Design.Behavior; +using System.CodeDom; +using System.ComponentModel.Design.Serialization; +using System.Text.RegularExpressions; + +namespace System.Windows.Forms.Design; + +internal class TableLayoutPanelDesigner : FlowPanelDesigner +{ + private TableLayoutPanelBehavior tlpBehavior;//every resize col/row glyph is associated with this instance of behavior + private Point droppedCellPosition = InvalidPoint;//used to insert new children + + // NEVER USE undoing DIRECTLY. ALWAYS USE THE PROPERTY + private bool undoing; + private UndoEngine undoEngine; + + private Control localDragControl;//only valid if we're currently dragging a child control of the table + private ArrayList dragComps; //the components we are dragging + private DesignerVerbCollection verbs;//add col/row and remove col/row tab verbs + private DesignerTableLayoutControlCollection controls; + private DesignerVerb removeRowVerb; + private DesignerVerb removeColVerb; + private DesignerActionListCollection actionLists;//action list for the Smart Tag + + private BaseContextMenuStrip designerContextMenuStrip; + private int curRow = -1; //row cursor was over when context menu was dropped + private int curCol = -1; //col cursor was over when context menu was dropped + + private IComponentChangeService compSvc; + private PropertyDescriptor rowStyleProp; + private PropertyDescriptor colStyleProp; + + // Only used when adding controls via the toolbox + private int rowCountBeforeAdd; // What's the row count before a control is added + private int colCountBeforeAdd; // Ditto for column + + // TLP context menu row/column items. + private ToolStripMenuItem contextMenuRow; + private ToolStripMenuItem contextMenuCol; + + private int ensureSuspendCount; + + private TableLayoutPanelBehavior Behavior + { + get + { + tlpBehavior ??= new TableLayoutPanelBehavior(Table, this, Component.Site); + + return tlpBehavior; + } + } + + private TableLayoutColumnStyleCollection ColumnStyles => Table.ColumnStyles; + + private TableLayoutRowStyleCollection RowStyles => Table.RowStyles; + + public int RowCount + { + get + { + return Table.RowCount; + } + set + { + if (value <= 0 && !Undoing) + { + throw new ArgumentException(string.Format(SR.TableLayoutPanelDesignerInvalidColumnRowCount, "RowCount")); + } + else + { + Table.RowCount = value; + } + } + } + + public int ColumnCount + { + get + { + return Table.ColumnCount; + } + set + { + if (value <= 0 && !Undoing) + { + throw new ArgumentException(string.Format(SR.TableLayoutPanelDesignerInvalidColumnRowCount, "ColumnCount")); + } + else + { + Table.ColumnCount = value; + } + } + } + + private bool IsLocalizable() + { + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null) + { + PropertyDescriptor prop = TypeDescriptor.GetProperties(host.RootComponent)["Localizable"]; + if (prop is not null && prop.PropertyType == typeof(bool)) + { + return (bool)prop.GetValue(host.RootComponent); + } + } + + return false; + } + + private bool ShouldSerializeColumnStyles() + { + return !IsLocalizable(); + } + + private bool ShouldSerializeRowStyles() + { + return !IsLocalizable(); + } + + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + private DesignerTableLayoutControlCollection Controls + { + get + { + controls ??= new DesignerTableLayoutControlCollection((TableLayoutPanel)Control); + return controls; + } + } + + private ContextMenuStrip DesignerContextMenuStrip + { + get + { + if (designerContextMenuStrip is null) + { + designerContextMenuStrip = new BaseContextMenuStrip(Component.Site, Table); + + // Remove all the verbs -- except the Edit Rows and Columns + ContextMenuStripGroup group = designerContextMenuStrip.Groups[StandardGroups.Verbs]; + foreach (DesignerVerb verb in Verbs) + { + if (verb.Text.Equals(string.Format(SR.TableLayoutPanelDesignerEditRowAndCol))) + { + continue; + } + + foreach (ToolStripItem item in group.Items) + { + if (item.Text.Equals(verb.Text)) + { + group.Items.Remove(item); + break; + } + } + } + + // Now build the new menus + ToolStripDropDownMenu rowMenu = BuildMenu(true); + ToolStripDropDownMenu colMenu = BuildMenu(false); + + contextMenuRow = new ToolStripMenuItem(); + contextMenuRow.DropDown = rowMenu; + contextMenuRow.Text = SR.TableLayoutPanelDesignerRowMenu; + + contextMenuCol = new ToolStripMenuItem(); + contextMenuCol.DropDown = colMenu; + contextMenuCol.Text = SR.TableLayoutPanelDesignerColMenu; + + group.Items.Insert(0, contextMenuCol); + group.Items.Insert(0, contextMenuRow); + + group = designerContextMenuStrip.Groups[StandardGroups.Edit]; + foreach (ToolStripItem item in group.Items) + { + if (item.Text.Equals(SR.ContextMenuCut)) + { + item.Text = SR.TableLayoutPanelDesignerContextMenuCut; + } + else if (item.Text.Equals(SR.ContextMenuCopy)) + { + item.Text = SR.TableLayoutPanelDesignerContextMenuCopy; + } + else if (item.Text.Equals(SR.ContextMenuDelete)) + { + item.Text = SR.TableLayoutPanelDesignerContextMenuDelete; + } + } + } + + bool onValidCell = IsOverValidCell(false); + + contextMenuRow.Enabled = onValidCell; + contextMenuCol.Enabled = onValidCell; + + return designerContextMenuStrip; + } + } + + private bool IsLoading + { + get + { + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + + if (host is not null) + { + return host.Loading; + } + + return false; + } + } + + internal TableLayoutPanel Table => Component as TableLayoutPanel; + + private bool Undoing + { + get + { + if (undoEngine is null) + { + undoEngine = GetService(typeof(UndoEngine)) as UndoEngine; + if (undoEngine is not null) + { + undoEngine.Undoing += new EventHandler(OnUndoing); + if (undoEngine.UndoInProgress) + { + undoing = true; + undoEngine.Undone += new EventHandler(OnUndone); + } + } + } + + return undoing; + } + + set + { + undoing = value; + } + } + + public override DesignerVerbCollection Verbs + { + get + { + if (verbs is null) + { + removeColVerb = new DesignerVerb(SR.TableLayoutPanelDesignerRemoveColumn, new EventHandler(OnVerbRemove)); + removeRowVerb = new DesignerVerb(SR.TableLayoutPanelDesignerRemoveRow, new EventHandler(OnVerbRemove)); + + verbs = new DesignerVerbCollection(); + + verbs.Add(new DesignerVerb(SR.TableLayoutPanelDesignerAddColumn, new EventHandler(OnVerbAdd))); + verbs.Add(new DesignerVerb(SR.TableLayoutPanelDesignerAddRow, new EventHandler(OnVerbAdd))); + verbs.Add(removeColVerb); + verbs.Add(removeRowVerb); + verbs.Add(new DesignerVerb(SR.TableLayoutPanelDesignerEditRowAndCol, new EventHandler(OnVerbEdit))); + + CheckVerbStatus(); + } + + return verbs; + } + } + + private void RefreshSmartTag() + { + DesignerActionUIService actionUIService = (DesignerActionUIService)GetService(typeof(DesignerActionUIService)); + actionUIService?.Refresh(Component); + } + + private void CheckVerbStatus() + { + if (Table is not null) + { + if (removeColVerb is not null) + { + bool colState = Table.ColumnCount > 1; + if (removeColVerb.Enabled != colState) + { + removeColVerb.Enabled = colState; + } + } + + if (removeRowVerb is not null) + { + bool rowState = Table.RowCount > 1; + if (removeRowVerb.Enabled != rowState) + { + removeRowVerb.Enabled = rowState; + } + } + + RefreshSmartTag(); + } + } + + public override DesignerActionListCollection ActionLists + { + get + { + if (actionLists is null) + { + BuildActionLists(); + } + + return actionLists; + } + } + + private ToolStripDropDownMenu BuildMenu(bool isRow) + { + ToolStripMenuItem add = new ToolStripMenuItem(); + ToolStripMenuItem insert = new ToolStripMenuItem(); + ToolStripMenuItem delete = new ToolStripMenuItem(); + ToolStripSeparator separator = new ToolStripSeparator(); + ToolStripLabel label = new ToolStripLabel(); + ToolStripMenuItem absolute = new ToolStripMenuItem(); + ToolStripMenuItem percent = new ToolStripMenuItem(); + ToolStripMenuItem autosize = new ToolStripMenuItem(); + + add.Text = SR.TableLayoutPanelDesignerAddMenu; + add.Tag = isRow; + add.Name = "add"; + add.Click += new System.EventHandler(OnAddClick); + + insert.Text = SR.TableLayoutPanelDesignerInsertMenu; + insert.Tag = isRow; + insert.Name = "insert"; + insert.Click += new System.EventHandler(OnInsertClick); + + delete.Text = SR.TableLayoutPanelDesignerDeleteMenu; + delete.Tag = isRow; + delete.Name = "delete"; + delete.Click += new System.EventHandler(OnDeleteClick); + + label.Text = SR.TableLayoutPanelDesignerLabelMenu; + if (SR.TableLayoutPanelDesignerDontBoldLabel == "0") + { + label.Font = new Font(label.Font, FontStyle.Bold); + } + + label.Name = "sizemode"; + + absolute.Text = SR.TableLayoutPanelDesignerAbsoluteMenu; + absolute.Tag = isRow; + absolute.Name = "absolute"; + absolute.Click += new System.EventHandler(OnAbsoluteClick); + + percent.Text = SR.TableLayoutPanelDesignerPercentageMenu; + percent.Tag = isRow; + percent.Name = "percent"; + percent.Click += new System.EventHandler(OnPercentClick); + + autosize.Text = SR.TableLayoutPanelDesignerAutoSizeMenu; + autosize.Tag = isRow; + autosize.Name = "autosize"; + autosize.Click += new System.EventHandler(OnAutoSizeClick); + + ToolStripDropDownMenu menu = new ToolStripDropDownMenu(); + menu.Items.AddRange(new ToolStripItem[] { add, insert, delete, separator, label, absolute, percent, autosize }); + menu.Tag = isRow; + menu.Opening += new System.ComponentModel.CancelEventHandler(OnRowColMenuOpening); + + IUIService uis = GetService(typeof(IUIService)) as IUIService; + if (uis is not null) + { + menu.Renderer = (ToolStripProfessionalRenderer)uis.Styles["VsRenderer"]; + if (uis.Styles["VsColorPanelText"] is Color) + { + menu.ForeColor = (Color)uis.Styles["VsColorPanelText"]; + } + } + + return menu; + } + + private void BuildActionLists() + { + actionLists = new DesignerActionListCollection(); + + // Add Column action list + actionLists.Add(new TableLayouPanelRowColumnActionList(this)); + + // if one actionList has AutoShow == true then the chrome panel will popup when the user DnD the DataGridView onto the form + // It would make sense to promote AutoShow to DesignerActionListCollection. + // But we don't own the DesignerActionListCollection so we just set AutoShow on the first ActionList. + actionLists[0].AutoShow = true; + } + + private class TableLayouPanelRowColumnActionList : DesignerActionList + { + private TableLayoutPanelDesigner owner; + + public TableLayouPanelRowColumnActionList(TableLayoutPanelDesigner owner) : base(owner.Component) + { + this.owner = owner; + } + + public override DesignerActionItemCollection GetSortedActionItems() + { + DesignerActionItemCollection items = new DesignerActionItemCollection(); + + // We don't promote these Items to DesignerVerbs, since we need to be able + // to disable/enable the Remove entries, based on the number of Rows/Cols. + // Unfortunately, you cannot do that via the DesignerAction stuff. + items.Add(new DesignerActionMethodItem(this, + "AddColumn", // method name + SR.TableLayoutPanelDesignerAddColumn, // display name + false)); // promoteToDesignerVerb + items.Add(new DesignerActionMethodItem(this, + "AddRow", // method name + SR.TableLayoutPanelDesignerAddRow, // display name + false)); // promoteToDesignerVerb + + if (owner.Table.ColumnCount > 1) + { + items.Add(new DesignerActionMethodItem(this, + "RemoveColumn", // method name + SR.TableLayoutPanelDesignerRemoveColumn, // display name + false)); // promoteToDesignerVerb + } + + if (owner.Table.RowCount > 1) + { + items.Add(new DesignerActionMethodItem(this, + "RemoveRow", // method name + SR.TableLayoutPanelDesignerRemoveRow, // display name + false)); // promoteToDesignerVerb + } + + items.Add(new DesignerActionMethodItem(this, + "EditRowAndCol", // method name + SR.TableLayoutPanelDesignerEditRowAndCol, // display name + false)); // promoteToDesignerVerb + + return items; + } + + public void AddColumn() => owner.OnAdd(false); + + public void AddRow() => owner.OnAdd(true); + + public void RemoveColumn() => owner.OnRemove(false); + + public void RemoveRow() => owner.OnRemove(true); + + public void EditRowAndCol() => owner.OnEdit(); + } + + private void RemoveControlInternal(Control c) + { + Table.ControlRemoved -= new ControlEventHandler(OnControlRemoved); + Table.Controls.Remove(c); + Table.ControlRemoved += new ControlEventHandler(OnControlRemoved); + } + + private void AddControlInternal(Control c, int col, int row) + { + Table.ControlAdded -= new ControlEventHandler(OnControlAdded); + Table.Controls.Add(c, col, row); + Table.ControlAdded += new ControlEventHandler(OnControlAdded); + } + + private void ControlAddedInternal(Control control, Point newControlPosition, bool localReposition, bool fullTable, DragEventArgs de) + { + //If the table is full - we'll want to 'autogrow' either the row or column based on the grow style property + //before we actually add the control. + if (fullTable) + { + if (Table.GrowStyle == TableLayoutPanelGrowStyle.AddRows) + { + PropertyDescriptor rowProp = TypeDescriptor.GetProperties(Table)["RowCount"]; + rowProp?.SetValue(Table, Table.GetRowHeights().Length); + + newControlPosition.X = 0; + newControlPosition.Y = Table.RowCount - 1; + } + else if (Table.GrowStyle == TableLayoutPanelGrowStyle.AddColumns) + { + PropertyDescriptor colProp = TypeDescriptor.GetProperties(Table)["ColumnCount"]; + colProp?.SetValue(Table, Table.GetColumnWidths().Length); + + newControlPosition.X = Table.ColumnCount - 1; + newControlPosition.Y = 0; + } + else + { + //fixed growstyle - what do we do here? + } + } + + DesignerTransaction trans = null; + PropertyDescriptor controlsProp = TypeDescriptor.GetProperties(Table)["Controls"]; + //find the control that currently resides at our newControlPosition - we'll want to either + //remove it or swap it. + try + { + // Are we doing a local copy + bool localCopy = ((de is not null) && (de.Effect == DragDropEffects.Copy) && localReposition); + + Control existingControl = ((TableLayoutPanel)Control).GetControlFromPosition(newControlPosition.X, newControlPosition.Y); + + if (localCopy) + { + Debug.Assert(existingControl is null, "We shouldn't be able to do a local copy of a cell with an existing control"); + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null) + { + trans = host.CreateTransaction(string.Format(SR.BehaviorServiceCopyControl, control.Site.Name)); + } + + // Need to do this after the transaction is created + PropChanging(controlsProp); + } + + //does the newControlPosition contain a valid control + //if so - we need to perform a 'swap' function if this is local - or default + //to controls.add if this is from an external source + else if (existingControl is not null && !existingControl.Equals(control)) + { + if (localReposition) + { + // If we're swapping controls, create a DesignerTransaction + // so this can be undoable. + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null) + { + trans = host.CreateTransaction(string.Format(SR.TableLayoutPanelDesignerControlsSwapped, control.Site.Name, existingControl.Site.Name)); + } + + // Need to do this after the transaction is created + PropChanging(controlsProp); + RemoveControlInternal(existingControl);//we found our control to swap + } + else + { + //here we externally dragged a control onto a valid control in our table + //we'll try to find a place to put it (since we shouldn't be here if our table + //was full + + // MartinTh -- we shouldn't ever get here... + PropChanging(controlsProp); + existingControl = null;//null this out since we're not swapping + } + } + else + { + //here we have a truly empty cell + + // If we are not doing a local move, then the DropSourceBehavior created the transaction for us + if (localReposition) + { + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null) + { + trans = host.CreateTransaction(string.Format(SR.BehaviorServiceMoveControl, control.Site.Name)); + } + } + + existingControl = null; + PropChanging(controlsProp); + } + + //Need to do this after the transaction has been created + if (localCopy) + { + ArrayList temp = new ArrayList(); + temp.Add(control); + temp = DesignerUtils.CopyDragObjects(temp, Component.Site) as ArrayList; + control = temp[0] as Control; + } + + //if we are locally repositioning this control - remove it (internally) + //from the table's child collection and add something in its place. This + //will be a control to swap it with + if (localReposition) + { + Point oldPosition = GetControlPosition(control); + if (oldPosition != InvalidPoint) + { + RemoveControlInternal(control); + + if (oldPosition != newControlPosition) + {//guard against dropping it back on itself + if (existingControl is not null) + { + //we have something to swap... + AddControlInternal(existingControl, oldPosition.X, oldPosition.Y); + } + } + } + } + + //Finally - set our new control to the new position + if (localReposition) + { + //If we are doing a local drag, then the control previously got removed + AddControlInternal(control, newControlPosition.X, newControlPosition.Y); + } + else + { + //If not, then the control has already been added, and all we need to do is set the position + Table.SetCellPosition(control, new TableLayoutPanelCellPosition(newControlPosition.X, newControlPosition.Y)); + } + + PropChanged(controlsProp); + + if (de is not null) + { + base.OnDragComplete(de); + } + + if (trans is not null) + { + trans.Commit(); + trans = null; + } + + // Set the selection to be the newly added control - but only if we are doing a local copy + if (localCopy) + { + ISelectionService selSvc = GetService(typeof(ISelectionService)) as ISelectionService; + selSvc?.SetSelectedComponents(new object[] { control }, SelectionTypes.Primary | SelectionTypes.Replace); + } + } + + // VSWhidbey #390285 + catch (ArgumentException argumentEx) + { + IUIService uiService = GetService(typeof(IUIService)) as IUIService; + uiService?.ShowError(argumentEx); + } + + catch (Exception ex) when (!ex.IsCriticalException()) + { + } + + finally + { + trans?.Cancel(); + } + } + + private void CreateEmptyTable() + { + //set the table's default rows and columns + PropertyDescriptor colProp = TypeDescriptor.GetProperties(Table)["ColumnCount"]; + colProp?.SetValue(Table, DesignerUtils.DEFAULTCOLUMNCOUNT); + + PropertyDescriptor rowProp = TypeDescriptor.GetProperties(Table)["RowCount"]; + rowProp?.SetValue(Table, DesignerUtils.DEFAULTROWCOUNT); + + //this will make sure we have styles created for every row & column + EnsureAvailableStyles(); + + InitializeNewStyles(); + } + + private void InitializeNewStyles() + { + //adjust the two absolutely positioned columns + Table.ColumnStyles[0].SizeType = SizeType.Percent; + Table.ColumnStyles[0].Width = DesignerUtils.MINIMUMSTYLEPERCENT; + Table.ColumnStyles[1].SizeType = SizeType.Percent; + Table.ColumnStyles[1].Width = DesignerUtils.MINIMUMSTYLEPERCENT; + + //adjust two absolutely positioned rows + Table.RowStyles[0].SizeType = SizeType.Percent; + Table.RowStyles[0].Height = DesignerUtils.MINIMUMSTYLEPERCENT; + Table.RowStyles[1].SizeType = SizeType.Percent; + Table.RowStyles[1].Height = DesignerUtils.MINIMUMSTYLEPERCENT; + } + + /// + /// Returns true if an empty subset of size subsetColumns x subsetRows exists in the cells + /// array. cells[c,r] == true if the corresponding cell contains a control + /// + /// + /// + /// + /// + /// + /// + private static bool SubsetExists(bool[,] cells, int columns, int rows, int subsetColumns, int subsetRows) + { + bool exists = false; + int column = 0; + int row; + + for (row = 0; row < rows - subsetRows + 1; row++) + { + for (column = 0; column < columns - subsetColumns + 1; column++) + { + if (!cells[column, row]) + { + exists = true; + for (int m = row; (m < row + subsetRows) && exists; m++) + { + for (int n = column; n < column + subsetColumns; n++) + { + if (cells[n, m]) + { + exists = false; + break; + } + } + } + + if (exists) + { + break; + } + } + } + + if (exists) + { + break; + } + } + + return exists; + } + + protected internal override bool CanAddComponent(IComponent component) + { + if (Table.GrowStyle != TableLayoutPanelGrowStyle.FixedSize) + { + return true; + } + + Control newControl = GetControl(component); + if (newControl is null) + { + // this case should have been filtered out by CanParent + return false; + } + + int rowSpan = Table.GetRowSpan(newControl); + int columnSpan = Table.GetColumnSpan(newControl); + + // under certain conditions RowCount and ColumnCount are not accurate + int numRows = Table.GetRowHeights().Length; + int numColumns = Table.GetColumnWidths().Length; + int numOccupiedCells = 0; // total occupied cells in the TableLayoutPanel + + int totalCells = numRows * numColumns; + int cellsNeeded = rowSpan * columnSpan; + + // cache which cells have controls in them + bool[,] occupiedCells = null; + if (cellsNeeded > 1) + { + occupiedCells = new bool[numColumns, numRows]; + } + + if (cellsNeeded <= totalCells) + { + for (int row = 0; row < numRows; row++) + { + for (int column = 0; column < numColumns; column++) + { + if (Table.GetControlFromPosition(column, row) is not null) + { + numOccupiedCells++; + if (cellsNeeded > 1) + { + occupiedCells[column, row] = true; + } + } + } + } + } + + // Check if the table has enough empty cells to accomodate the new component + if (numOccupiedCells + cellsNeeded > totalCells) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + uiService.ShowError(SR.TableLayoutPanelFullDesc); + + return false; + } + + // if the new control spans several rows or columns, check if the + // table has a contiguous free area to accomodate the control + if (cellsNeeded > 1) + { + if (!SubsetExists(occupiedCells, numColumns, numRows, columnSpan, rowSpan)) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + uiService.ShowError(SR.TableLayoutPanelSpanDesc); + + return false; + } + } + + return true; + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host is not null) + { + host.TransactionClosing -= new DesignerTransactionCloseEventHandler(OnTransactionClosing); + } + + if (undoEngine is not null) + { + if (Undoing) + { + undoEngine.Undone -= new EventHandler(OnUndone); + } + + undoEngine.Undoing -= new EventHandler(OnUndoing); + } + + if (compSvc is not null) + { + compSvc.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged); + compSvc.ComponentChanging -= new ComponentChangingEventHandler(OnComponentChanging); + } + + if (Table is not null) + { + Table.ControlAdded -= new ControlEventHandler(OnControlAdded); + Table.ControlRemoved -= new ControlEventHandler(OnControlRemoved); + } + + contextMenuRow?.Dispose(); + + contextMenuCol?.Dispose(); + + rowStyleProp = null; + colStyleProp = null; + } + + base.Dispose(disposing); + } + + protected override void DrawBorder(Graphics graphics) + { + if (Table.CellBorderStyle != TableLayoutPanelCellBorderStyle.None) + { + //only draw a fake border if there is no borderstyle. + return; + } + + base.DrawBorder(graphics); + + Rectangle rc = Control.DisplayRectangle; + rc.Width--; + rc.Height--; + + int[] cw = Table.GetColumnWidths(); + int[] rh = Table.GetRowHeights(); + + using (Pen pen = BorderPen) + { + if (cw.Length > 1) + { + bool isRTL = (Table.RightToLeft == RightToLeft.Yes); + // offset by padding + int startX = isRTL ? rc.Right : rc.Left; + for (int i = 0; i < cw.Length - 1; i++) + { + if (isRTL) + { + startX -= cw[i]; + } + else + { + startX += cw[i]; + } + + graphics.DrawLine(pen, startX, rc.Top, startX, rc.Bottom); + } + } + + if (rh.Length > 1) + { + int startY = rc.Top; + for (int i = 0; i < rh.Length - 1; i++) + { + startY += rh[i]; + graphics.DrawLine(pen, rc.Left, startY, rc.Right, startY); + } + } + } + } + + internal void SuspendEnsureAvailableStyles() => ensureSuspendCount++; + + internal void ResumeEnsureAvailableStyles(bool performEnsure) + { + if (ensureSuspendCount > 0) + { + ensureSuspendCount--; + + if (ensureSuspendCount == 0 && performEnsure) + { + EnsureAvailableStyles(); + } + } + } + + private bool EnsureAvailableStyles() + { + if (IsLoading || Undoing || ensureSuspendCount > 0) + { + return false; + } + + int[] cw = Table.GetColumnWidths(); + int[] rh = Table.GetRowHeights(); + + Table.SuspendLayout(); + try + { + //if we have more columns then column styles add some... + if (cw.Length > Table.ColumnStyles.Count) + { + int colDifference = cw.Length - Table.ColumnStyles.Count; + PropChanging(rowStyleProp); + for (int i = 0; i < colDifference; i++) + { + Table.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, DesignerUtils.MINIMUMSTYLESIZE)); + } + + PropChanged(rowStyleProp); + } + + //if we have more rows then row styles add some... + if (rh.Length > Table.RowStyles.Count) + { + int rowDifference = rh.Length - Table.RowStyles.Count; + PropChanging(colStyleProp); + for (int i = 0; i < rowDifference; i++) + { + Table.RowStyles.Add(new RowStyle(SizeType.Absolute, DesignerUtils.MINIMUMSTYLESIZE)); + } + + PropChanged(colStyleProp); + } + } + finally + { + Table.ResumeLayout(); + } + + return true; + } + + private Control ExtractControlFromDragEvent(DragEventArgs de) + { + DropSourceBehavior.BehaviorDataObject data = de.Data as DropSourceBehavior.BehaviorDataObject; + if (data is not null) + { + dragComps = new ArrayList(data.DragComponents); + return dragComps[0] as Control; + } + + return null; + } + + private Point GetCellPosition(Point pos) + { + //get some runtime table info + int[] rows = Table.GetRowHeights(); + int[] columns = Table.GetColumnWidths(); + + //By using DisplayRectangle here we handle the case where we are scrolled. VSWhidbey #399557 + Point startingPoint = Table.PointToScreen(Table.DisplayRectangle.Location); + Rectangle bounds = new Rectangle(startingPoint, Table.DisplayRectangle.Size); + + Point position = new Point(-1, -1); + + bool isRTL = Table.RightToLeft == RightToLeft.Yes; + int offset = bounds.X; + + // find column ... + if (isRTL) + { + if (pos.X <= bounds.X) + { // if pos.X >= bounds.Right, position.X = -1 + position.X = columns.Length; + } + else if (pos.X < bounds.Right) + { // it must be within the bounds + offset = bounds.Right; + + //loop through the columns and identify where the mouse is + for (int i = 0; i < columns.Length; i++) + { + position.X = i; + if (pos.X >= offset - columns[i]) + { + break; + } + + offset -= columns[i]; + } + } + } + else + { + if (pos.X >= bounds.Right) + { + position.X = columns.Length; + } + else if (pos.X > bounds.X) + { // if pos.X <= bounds.X, position.X = -1. + //loop through the columns and identify where the mouse is + for (int i = 0; i < columns.Length; i++) + { // it must be within the bounds + position.X = i; + if (pos.X <= offset + columns[i]) + { + break; + } + + offset += columns[i]; + } + } + } + + // find row ... + offset = bounds.Y; + + if (pos.Y >= bounds.Bottom) + { + position.Y = rows.Length; + } + else if (pos.Y > bounds.Y) + { // if pos.Y <= bounds.Y, position.Y = -1 + //loop through the rows and identify where the mouse is + for (int i = 0; i < rows.Length; i++) + { + if (pos.Y <= offset + rows[i]) + { + position.Y = i; + break; + } + + offset += rows[i]; + } + } + + return position; + } + + private Point GetControlPosition(Control control) + { + TableLayoutPanelCellPosition pos = Table.GetPositionFromControl(control); + if ((pos.Row == -1) && (pos.Column == -1)) + { + return InvalidPoint; + } + + return new Point(pos.Column, pos.Row); + } + + public override GlyphCollection GetGlyphs(GlyphSelectionType selectionType) + { + GlyphCollection glyphs = base.GetGlyphs(selectionType); + + PropertyDescriptor prop = TypeDescriptor.GetProperties(Component)["Locked"]; + bool locked = (prop is not null) ? ((bool)prop.GetValue(Component)) : false; + + //Before adding glyphs for every row/column, make sure we have a column/rowstyle for every column/row + bool safeToRefresh = EnsureAvailableStyles(); + + //if we're somehow selected, not locked, and not inherited -then offer up glyphs for every + //column/row line + if (selectionType != GlyphSelectionType.NotSelected && !locked && InheritanceAttribute != InheritanceAttribute.InheritedReadOnly) + { + //get the correctly translated bounds + //By using DisplayRectangle here we handle the case where we are scrolled. VSWhidbey #399689 + Point loc = BehaviorService.MapAdornerWindowPoint(Table.Handle, Table.DisplayRectangle.Location); + Rectangle bounds = new Rectangle(loc, Table.DisplayRectangle.Size); + + Point controlLoc = BehaviorService.ControlToAdornerWindow(Control); + Rectangle checkBounds = new Rectangle(controlLoc, Control.ClientSize); // Can't use Control.Size since that will include any scrollbar + + int[] cw = Table.GetColumnWidths(); + int[] rh = Table.GetRowHeights(); + int halfSize = DesignerUtils.RESIZEGLYPHSIZE / 2; + + bool isRTL = (Table.RightToLeft == RightToLeft.Yes); + int startLoc = isRTL ? bounds.Right : bounds.X; + + if (safeToRefresh) + { + //add resize glyphs for each column and row + for (int i = 0; i < cw.Length - 1; i++) + { + //Do not add a glyph for columns of 0 width. This can happen for percentage columns, where the table is not + //big enough for there to be any space for percentage columns + if (cw[i] == 0) + { + continue; + } + + if (isRTL) + { + startLoc -= cw[i]; + } + else + { + startLoc += cw[i];//x offset of column line + } + + Rectangle gBounds = new Rectangle(startLoc - halfSize, checkBounds.Top, DesignerUtils.RESIZEGLYPHSIZE, checkBounds.Height); + //Don't add glyphs for columns that are not within the clientrectangle. + if (!checkBounds.Contains(gBounds)) + { + continue; + } + + Debug.Assert(Table.ColumnStyles[i] is not null, "Table's ColumnStyle[" + i + "] is null!"); + if (Table.ColumnStyles[i] is not null) + { + TableLayoutPanelResizeGlyph g = new TableLayoutPanelResizeGlyph(gBounds, Table.ColumnStyles[i], Cursors.VSplit, Behavior); + glyphs.Add(g); + } + } + + startLoc = bounds.Y;//reset for the rows... + + for (int i = 0; i < rh.Length - 1; i++) + { + //Do not add a glyph for rows of 0 height. This can happen for percentage columns, where the table is not + //big enough for there to be any space for percentage columns + if (rh[i] == 0) + { + continue; + } + + startLoc += rh[i];//y offset of row line + Rectangle gBounds = new Rectangle(checkBounds.Left, startLoc - halfSize, checkBounds.Width, DesignerUtils.RESIZEGLYPHSIZE); + if (!checkBounds.Contains(gBounds)) + { + continue; + } + + Debug.Assert(Table.RowStyles[i] is not null, "Table's RowStyle[" + i + "] is null!"); + if (Table.RowStyles[i] is not null) + { + TableLayoutPanelResizeGlyph g = new TableLayoutPanelResizeGlyph(gBounds, Table.RowStyles[i], Cursors.HSplit, Behavior); + glyphs.Add(g); + } + } + } + } + + return glyphs; + } + + public override void Initialize(IComponent component) + { + base.Initialize(component); + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host is not null) + { + host.TransactionClosing += new DesignerTransactionCloseEventHandler(OnTransactionClosing); +#pragma warning disable VSSDK006 + compSvc = host.GetService(typeof(IComponentChangeService)) as IComponentChangeService; +#pragma warning restore VSSDK006 + } + + if (compSvc is not null) + { + compSvc.ComponentChanging += new ComponentChangingEventHandler(OnComponentChanging); + compSvc.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); + } + + Control.ControlAdded += new ControlEventHandler(OnControlAdded); + Control.ControlRemoved += new ControlEventHandler(OnControlRemoved); + + rowStyleProp = TypeDescriptor.GetProperties(Table)["RowStyles"]; + colStyleProp = TypeDescriptor.GetProperties(Table)["ColumnStyles"]; + + // VSWhidbey #424845. If the TLP is inheritedreadonly, so should all of the children + if (InheritanceAttribute == InheritanceAttribute.InheritedReadOnly) + { + for (int i = 0; i < Control.Controls.Count; i++) + { + TypeDescriptor.AddAttributes(Control.Controls[i], InheritanceAttribute.InheritedReadOnly); + } + } + } + + protected override InheritanceAttribute InheritanceAttribute + { + get + { + if ((base.InheritanceAttribute == InheritanceAttribute.Inherited) + || (base.InheritanceAttribute == InheritanceAttribute.InheritedReadOnly)) + { + return InheritanceAttribute.InheritedReadOnly; + } + + return base.InheritanceAttribute; + } + } + + public override void InitializeNewComponent(IDictionary defaultValues) + { + base.InitializeNewComponent(defaultValues); + CreateEmptyTable(); + } + + protected override IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize) + { + rowCountBeforeAdd = Math.Max(0, Table.GetRowHeights().Length); // don't want negative + colCountBeforeAdd = Math.Max(0, Table.GetColumnWidths().Length); + + return base.CreateToolCore(tool, x, y, width, height, hasLocation, hasSize); + } + + private void OnControlAdded(object sender, ControlEventArgs e) + { + if (IsLoading || Undoing) + { + return; + } + + // Calculate the number cells spanned by controls in the Table + // This can be slow, but it is the only way to really calculate the number of cells spanned. + // We cannot rely on checking the control's span since the TLP's growstyle might affect it. + // E.g. RowCount = ColumnCount = 2, GrowStyle = AddRows, button in cell(0,0), button.ColumnSpan = 6 + int totalArea = 0; + int[] rows = Table.GetRowHeights(); + int[] columns = Table.GetColumnWidths(); + + for (int row = 0; row < rows.Length; row++) + { + for (int column = 0; column < columns.Length; column++) + { + if (Table.GetControlFromPosition(column, row) is not null) + { + ++totalArea; + } + } + } + + //The control we are about to place, have already been added to the TLP's control collection, so -1 here. + //This is because we want to know if the table was full BEFORE the control was added. + + bool fullTable = (totalArea - 1) >= (Math.Max(1, colCountBeforeAdd) * Math.Max(1, rowCountBeforeAdd)); + + if (droppedCellPosition == InvalidPoint) + { + droppedCellPosition = GetControlPosition(e.Control); + } + + Debug.Assert(fullTable || (droppedCellPosition != InvalidPoint), "Why is neither fullTable or droppedCellPosition set?"); + + ControlAddedInternal(e.Control, droppedCellPosition, false, fullTable, null); + + droppedCellPosition = InvalidPoint; + } + + private void OnControlRemoved(object sender, ControlEventArgs e) + { + // Need to do this to make sure undo/redo works + // Since the Row/Col extended property is DesignerSerializationVisibility.Hidden, the undo engine + // will not serialize the value out, so we need to reset it here. VSWhidbey #392705. + if (e is not null && e.Control is not null) + { + Table.SetCellPosition(e.Control, new TableLayoutPanelCellPosition(-1, -1)); + } + } + + private bool IsOverValidCell(bool dragOp) + { + Point dropPoint = GetCellPosition(Control.MousePosition); + + // check if cell position is valid. + int[] rows = Table.GetRowHeights(); + int[] columns = Table.GetColumnWidths(); + + if (dropPoint.Y < 0 || dropPoint.Y >= rows.Length || dropPoint.X < 0 || dropPoint.X >= columns.Length) + { + return false; + } + + if (dragOp) + { + Control existingControl = (Control)((TableLayoutPanel)Control).GetControlFromPosition(dropPoint.X, dropPoint.Y); + + //If the cell is not empty, and we are not doing a local drag, then show the no-smoking cursor + //or if we are doing a multi-select local drag, then show the no-smoking cursor. + //or if we are doig a local drag, and the cell is not empty, and we are doing a copy + if ((existingControl is not null && localDragControl is null) || + (localDragControl is not null && dragComps.Count > 1) || + (localDragControl is not null && existingControl is not null && Control.ModifierKeys == Keys.Control)) + { + return false; + } + } + + return true; + } + + protected override void OnContextMenu(int x, int y) + { + Point cell = GetCellPosition(new Point(x, y)); + + curRow = cell.Y; + curCol = cell.X; + + //Set the SizeMode correctly + EnsureAvailableStyles(); + + DesignerContextMenuStrip.Show(x, y); + } + + protected override void OnDragEnter(DragEventArgs de) + { + base.OnDragEnter(de); + + //peak at what just entered her e- it it's a local control + //we'll cache it off + if (localDragControl is null) + { + Control dragControl = ExtractControlFromDragEvent(de); + if (dragControl is not null && Table.Controls.Contains(dragControl)) + { + localDragControl = dragControl; + } + } + } + + protected override void OnDragLeave(EventArgs e) + { + localDragControl = null; //VSWhidbey #275678 + dragComps = null; + base.OnDragLeave(e); + } + + protected override void OnDragDrop(DragEventArgs de) + { + droppedCellPosition = GetCellPosition(Control.MousePosition); + + //the scenario where we just dropped our own child control + if (localDragControl is not null) + { + //local drag to our TLP - we need to re-insert or swap it... + ControlAddedInternal(localDragControl, droppedCellPosition, true, false, de); + localDragControl = null; + } + else + { + rowCountBeforeAdd = Math.Max(0, Table.GetRowHeights().Length); // don't want negative + colCountBeforeAdd = Math.Max(0, Table.GetColumnWidths().Length); + + //If from the outside, just let the base class handle it + base.OnDragDrop(de); + + // VSWhidbey #390230 + // Devdiv Bugs 40804 + // This will not fix VSWhidbey #390230 in the copy/paste scenario but it will for the + // main drag/drop scneario. + // We need to do this after the controls are added (after base.OnDragDrop above) + // because Span is an "attached" property which is not available unless the control is parented to + // a table. However in the case when the table is full and can't grow, setting control's + // span after the Add is too late, because the runtime had already thrown an exception. + // Unfortunally cancelling the transaction throws as well, so we need a way to undo the Add + // or access internal properties of the control. + // dragComps is null when dragging off the toolbox + if (dragComps is not null) + { + foreach (Control dragControl in dragComps) + { + if (dragControl is not null) + { + PropertyDescriptor columnSpan = TypeDescriptor.GetProperties(dragControl)["ColumnSpan"]; + PropertyDescriptor rowSpan = TypeDescriptor.GetProperties(dragControl)["RowSpan"]; + columnSpan?.SetValue(dragControl, 1); + + rowSpan?.SetValue(dragControl, 1); + } + } + } + } + + droppedCellPosition = InvalidPoint; + dragComps = null; + } + + protected override void OnDragOver(DragEventArgs de) + { + // If we are not over a valid cell, then do not allow the drop + if (!IsOverValidCell(true)) + { + de.Effect = DragDropEffects.None; + return; + } + + base.OnDragOver(de); + } + + private Dictionary extenderProperties; + + private Dictionary ExtenderProperties + { + get + { + if (extenderProperties is null && Component is not null) + { + extenderProperties = new Dictionary(); + + AttributeCollection attribs = TypeDescriptor.GetAttributes(Component.GetType()); + + foreach (Attribute a in attribs) + { + ProvidePropertyAttribute extender = a as ProvidePropertyAttribute; + if (extender is not null) + { + extenderProperties[extender.PropertyName] = true; + } + } + } + + return extenderProperties; + } + } + + private bool DoesPropertyAffectPosition(MemberDescriptor member) + { + bool affectsPosition = false; + DesignerSerializationVisibilityAttribute dsv = member.Attributes[typeof(DesignerSerializationVisibilityAttribute)] as DesignerSerializationVisibilityAttribute; + if (dsv is not null) + { + affectsPosition = dsv.Visibility == DesignerSerializationVisibility.Hidden && ExtenderProperties.ContainsKey(member.Name); + } + + return affectsPosition; + } + + private void OnComponentChanging(object sender, ComponentChangingEventArgs e) + { + Control changingControl = e.Component as Control; + + if (changingControl is not null && changingControl.Parent == Component && + e.Member is not null && DoesPropertyAffectPosition(e.Member)) + { + PropertyDescriptor controlsProp = TypeDescriptor.GetProperties(Component)["Controls"]; + compSvc.OnComponentChanging(Component, controlsProp); + } + } + + private void OnComponentChanged(object sender, ComponentChangedEventArgs e) + { + //VSWhidbey 233871 + //When the Row or Column property is being set on a control in the TLP, a Row/Col Style is not being added. + //After the property is being set, the SelectionManager::OnSelectionChanged gets called. It in turn calls + //GetGlyphs, and the TLP designer's GetGlyphs calls EnsureAvaiableStyles. Since no style was added, we will add + //a default one of type Absolute, Height/Width 20. But but but... If the control has added its glyph before we + //add the style, the glyphs wil be misaligned, since EnsureAvailableStyles also causes the TLP to do a layout. This + //layout will actually size the control to a smaller size. So let's trap the Row/Col property changing, call + //EnsureAvailableStyles, which will force the layout BEFORE the SelectionManager is called. + if (e.Component is not null) + { + Control c = e.Component as Control; + if (c is not null && c.Parent is not null && c.Parent.Equals(Control) && e.Member is not null && (e.Member.Name == "Row" || e.Member.Name == "Column")) + { + EnsureAvailableStyles(); + } + + if (c is not null && c.Parent == Component && + e.Member is not null && DoesPropertyAffectPosition(e.Member)) + { + PropertyDescriptor controlsProp = TypeDescriptor.GetProperties(Component)["Controls"]; + compSvc.OnComponentChanged(Component, controlsProp, null, null); + } + } + + CheckVerbStatus(); + } + + private void OnTransactionClosing(object sender, DesignerTransactionCloseEventArgs e) + { + ISelectionService selSvc = GetService(typeof(ISelectionService)) as ISelectionService; + if (selSvc is not null && Table is not null) + { + ICollection selectedComps = selSvc.GetSelectedComponents(); + bool selectedComponentHasTableParent = false; + foreach (object comp in selectedComps) + { + Control c = comp as Control; + if (c is not null && c.Parent == Table) + { + selectedComponentHasTableParent = true; + break; + } + } + + if (selSvc.GetComponentSelected(Table) || selectedComponentHasTableParent) + { + //force an internal 'onlayout' event to refresh our control + Table.SuspendLayout(); + EnsureAvailableStyles(); + Table.ResumeLayout(false); + Table.PerformLayout(); + } + } + } + + private void OnUndoing(object sender, EventArgs e) + { + if (!Undoing) + { + if (undoEngine is not null) + { + undoEngine.Undone += new EventHandler(OnUndone); + } + + Undoing = true; + } + } + + private void OnUndone(object sender, EventArgs e) + { + if (Undoing) + { + if (undoEngine is not null) + { + undoEngine.Undone -= new EventHandler(OnUndone); + } + + Undoing = false; + + bool isSafeToRefresh = EnsureAvailableStyles(); + + if (isSafeToRefresh) + { + Refresh(); + } + } + } + + protected override void OnMouseDragBegin(int x, int y) + { + if (IsOverValidCell(true)) + { + //make sure we have a valid toolbox item and we're not just drawing a rect + IToolboxService tbx = (IToolboxService)GetService(typeof(IToolboxService)); + if (tbx is not null && tbx.GetSelectedToolboxItem((IDesignerHost)GetService(typeof(IDesignerHost))) is not null) + { + droppedCellPosition = GetCellPosition(Control.MousePosition); + } + } + else + { + droppedCellPosition = InvalidPoint; + Cursor.Current = Cursors.No; + } + + base.OnMouseDragBegin(x, y); + } + + protected override void OnMouseDragMove(int x, int y) + { + //If they are trying to draw in a cell that already has a control, then we + //do not want to draw an outline + if (droppedCellPosition == InvalidPoint) + { + Cursor.Current = Cursors.No; + return; + } + + base.OnMouseDragMove(x, y); + } + + protected override void OnMouseDragEnd(bool cancel) + { + if (droppedCellPosition == InvalidPoint) + { + // If they are trying to draw in a cell that already has a control, then just act like a cancel + cancel = true; + } + + base.OnMouseDragEnd(cancel); + } + + private void OnRowColMenuOpening(object sender, CancelEventArgs e) + { + e.Cancel = false; + //Set the size mode correctly + ToolStripDropDownMenu menu = sender as ToolStripDropDownMenu; + if (menu is not null) + { + int selCount = 0; + ISelectionService selSvc = GetService(typeof(ISelectionService)) as ISelectionService; + if (selSvc is not null) + { + selCount = selSvc.SelectionCount; + } + + // Always make sure and set the Enabled state in case the user + // has changed the selection since the last time the menu was shown. + bool enabled = (selCount == 1) && (InheritanceAttribute != InheritanceAttribute.InheritedReadOnly); + + menu.Items["add"].Enabled = enabled; + menu.Items["insert"].Enabled = enabled; + menu.Items["delete"].Enabled = enabled; + menu.Items["sizemode"].Enabled = enabled; + menu.Items["absolute"].Enabled = enabled; + menu.Items["percent"].Enabled = enabled; + menu.Items["autosize"].Enabled = enabled; + + if (selCount == 1) + { + ((ToolStripMenuItem)menu.Items["absolute"]).Checked = false; + ((ToolStripMenuItem)menu.Items["percent"]).Checked = false; + ((ToolStripMenuItem)menu.Items["autosize"]).Checked = false; + + bool isRow = (bool)menu.Tag; + switch (isRow ? Table.RowStyles[curRow].SizeType : Table.ColumnStyles[curCol].SizeType) + { + case SizeType.Absolute: + ((ToolStripMenuItem)menu.Items["absolute"]).Checked = true; + break; + case SizeType.Percent: + ((ToolStripMenuItem)menu.Items["percent"]).Checked = true; + break; + case SizeType.AutoSize: + ((ToolStripMenuItem)menu.Items["autosize"]).Checked = true; + break; + default: + Debug.Fail("Unknown SizeType!"); + break; + } + + if ((isRow ? Table.RowCount : Table.ColumnCount) < 2) + { + //can't remove a row/column if we only have + menu.Items["delete"].Enabled = false; + } + } + } + } + + private void OnAdd(bool isRow) + { + // get the property and add to it... + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null && Table.Site is not null) + { + using (DesignerTransaction t = host.CreateTransaction(string.Format(isRow ? SR.TableLayoutPanelDesignerAddRowUndoUnit : + SR.TableLayoutPanelDesignerAddColumnUndoUnit, Table.Site.Name))) + { + try + { + Table.SuspendLayout(); // To avoid flickering + // This ensures that the Row/Col Style gets set BEFORE the row is added. This in turn + // ensures that the row/col shows up. Since we turn off tablelayout, a style won't have been added + // when EnsureVisibleStyles is called from the shadowed property. + InsertRowCol(isRow, isRow ? Table.RowCount : Table.ColumnCount); + Table.ResumeLayout(); + t.Commit(); + } + catch (CheckoutException checkoutException) + { + if (CheckoutException.Canceled.Equals(checkoutException)) + { + t?.Cancel(); + } + else + { + throw; + } + } + } + } + } + + private void OnAddClick(object sender, EventArgs e) => OnAdd((bool)((ToolStripMenuItem)sender).Tag); //Tag = isRow + + internal void InsertRowCol(bool isRow, int index) + { + // We shadow the ColumnCount/RowCount property, so let's add the style first + // to make sure that the right style is added at the right location. + try + { + if (isRow) + { + PropertyDescriptor rowProp = TypeDescriptor.GetProperties(Table)["RowCount"]; + if (rowProp is not null) + { + PropChanging(rowStyleProp); + Table.RowStyles.Insert(index, new RowStyle(SizeType.Absolute, DesignerUtils.MINIMUMSTYLESIZE)); + PropChanged(rowStyleProp); + + rowProp.SetValue(Table, Table.RowCount + 1); + } + } + else + { + PropertyDescriptor colProp = TypeDescriptor.GetProperties(Table)["ColumnCount"]; + if (colProp is not null) + { + PropChanging(colStyleProp); + Table.ColumnStyles.Insert(index, new ColumnStyle(SizeType.Absolute, DesignerUtils.MINIMUMSTYLESIZE)); + PropChanged(colStyleProp); + + colProp.SetValue(Table, Table.ColumnCount + 1); + } + } + } + catch (InvalidOperationException ex) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + uiService.ShowError(ex.Message); + } + + // VSWhidbey # 490635 + BehaviorService.Invalidate(BehaviorService.ControlRectInAdornerWindow(Control)); + } + + internal void FixUpControlsOnInsert(bool isRow, int index) + { + PropertyDescriptor childProp = TypeDescriptor.GetProperties(Table)["Controls"]; + PropChanging(childProp); + + foreach (Control child in Table.Controls) + { + int currentIndex = isRow ? Table.GetRow(child) : Table.GetColumn(child); + PropertyDescriptor prop = TypeDescriptor.GetProperties(child)[isRow ? "Row" : "Column"]; + PropertyDescriptor spanProp = TypeDescriptor.GetProperties(child)[isRow ? "RowSpan" : "ColumnSpan"]; + + if (currentIndex == -1) + { + //this is a flow element. We don't really know where + //this is going to go, so we cannot fix up anything. + continue; + } + + //push all controls >= the original row/col into the new row/col + if (currentIndex >= index) + { + prop?.SetValue(child, currentIndex + 1); + } + else + { + //If the control is before the row/col we are inserting and the control has a span that includes the inserted row/col + //the increase the span to include the insert row/col + int span = isRow ? Table.GetRowSpan(child) : Table.GetColumnSpan(child); //span is always at least 1 + if (currentIndex + span > index) + { + spanProp?.SetValue(child, span + 1); + } + } + } + + PropChanged(childProp); + } + + private void OnInsertClick(object sender, EventArgs e) + { + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null && Table.Site is not null) + { + bool isRow = (bool)((ToolStripMenuItem)sender).Tag; + using (DesignerTransaction t = host.CreateTransaction(string.Format(isRow ? SR.TableLayoutPanelDesignerAddRowUndoUnit : + SR.TableLayoutPanelDesignerAddColumnUndoUnit, Table.Site.Name))) + { + try + { + Table.SuspendLayout(); + InsertRowCol(isRow, isRow ? curRow : curCol); + FixUpControlsOnInsert(isRow, isRow ? curRow : curCol); + Table.ResumeLayout(); + t.Commit(); + } + catch (CheckoutException checkoutException) + { + if (CheckoutException.Canceled.Equals(checkoutException)) + { + t?.Cancel(); + } + else + { + throw; + } + } + catch (System.InvalidOperationException ex) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + uiService.ShowError(ex.Message); + } + } + } + } + + internal void FixUpControlsOnDelete(bool isRow, int index, ArrayList deleteList) + { + PropertyDescriptor childProp = TypeDescriptor.GetProperties(Table)["Controls"]; + PropChanging(childProp); + + foreach (Control child in Table.Controls) + { + int currentIndex = isRow ? Table.GetRow(child) : Table.GetColumn(child); + PropertyDescriptor prop = TypeDescriptor.GetProperties(child)[isRow ? "Row" : "Column"]; + PropertyDescriptor spanProp = TypeDescriptor.GetProperties(child)[isRow ? "RowSpan" : "ColumnSpan"]; + + if (currentIndex == index) + { + //We add the deleteList.Contains check just to make extra sure. Could be + //that the deleteList for some reason already contained the child. + if (!deleteList.Contains(child)) + { + deleteList.Add(child); + } + + continue; + } + + if (currentIndex == -1 || deleteList.Contains(child)) + { + //If this is a flow element. We don't really know where this is going to go, so we cannot fix up anything. + //If the child has already been marked for deletion, we can keep going + continue; + } + + Debug.Assert(currentIndex != index); + + //push all controls >= the original row/col into the new row/col, but only + if (currentIndex > index) + { + prop?.SetValue(child, currentIndex - 1); + } + else + { + //If the control is before the row/col we are removing and the control has a span that includes the row/col + //we are deleting, then decrease the span. + int span = isRow ? Table.GetRowSpan(child) : Table.GetColumnSpan(child); //span is always at least 1 + if (currentIndex + span > index) + { + //We've bled into the row/col, shrink up as expected + spanProp?.SetValue(child, span - 1); + } + } + } + + PropChanged(childProp); + } + + internal void DeleteRowCol(bool isRow, int index) + { + if (isRow) + { + PropertyDescriptor rowProp = TypeDescriptor.GetProperties(Table)["RowCount"]; + if (rowProp is not null) + { + rowProp.SetValue(Table, Table.RowCount - 1); + + PropChanging(rowStyleProp); + Table.RowStyles.RemoveAt(index); + PropChanged(rowStyleProp); + } + } + else + { + PropertyDescriptor colProp = TypeDescriptor.GetProperties(Table)["ColumnCount"]; + if (colProp is not null) + { + colProp.SetValue(Table, Table.ColumnCount - 1); + + PropChanging(colStyleProp); + Table.ColumnStyles.RemoveAt(index); + PropChanged(colStyleProp); + } + } + } + + private void OnRemoveInternal(bool isRow, int index) + { + if ((isRow ? Table.RowCount : Table.ColumnCount) < 2) + { + //can't remove a row/column if we only have 1 + return; + } + + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null && Table.Site is not null) + { + using (DesignerTransaction t = host.CreateTransaction(string.Format(isRow ? SR.TableLayoutPanelDesignerRemoveRowUndoUnit : + SR.TableLayoutPanelDesignerRemoveColumnUndoUnit, Table.Site.Name))) + { + try + { + Table.SuspendLayout(); + ArrayList deleteList = new ArrayList(); + + //First fix up any controls in the row/col we are deleting + FixUpControlsOnDelete(isRow, index, deleteList); + //Then delete the row col + DeleteRowCol(isRow, index); + + //Now delete any child control + + // IF YOU CHANGE THIS, YOU SHOULD ALSO CHANGE THE CODE IN StyleCollectionEditor.OnOkButtonClick + if (deleteList.Count > 0) + { + PropertyDescriptor childProp = TypeDescriptor.GetProperties(Table)["Controls"]; + PropChanging(childProp); + foreach (object o in deleteList) + { + ArrayList al = new ArrayList(); + DesignerUtils.GetAssociatedComponents((IComponent)o, host, al); + foreach (IComponent comp in al) + { + compSvc.OnComponentChanging(comp, null); + } + + host.DestroyComponent(o as Component); + } + + PropChanged(childProp); + } + + Table.ResumeLayout(); + t.Commit(); + } + catch (CheckoutException checkoutException) + { + if (CheckoutException.Canceled.Equals(checkoutException)) + { + t?.Cancel(); + } + else + { + throw; + } + } + } + } + } + + private void OnRemove(bool isRow) => OnRemoveInternal(isRow, isRow ? Table.RowCount - 1 : Table.ColumnCount - 1); + + private void OnDeleteClick(object sender, EventArgs e) + { + try + { + bool isRow = (bool)((ToolStripMenuItem)sender).Tag; + OnRemoveInternal(isRow, isRow ? curRow : curCol); + } + catch (System.InvalidOperationException ex) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + uiService.ShowError(ex.Message); + } + } + + private void ChangeSizeType(bool isRow, SizeType newType) + { + TableLayoutStyleCollection styles = null; + try + { + if (isRow) + { + styles = Table.RowStyles; + } + else + { + styles = Table.ColumnStyles; + } + + int index = isRow ? curRow : curCol; + + if (styles[index].SizeType == newType) + { + // nuthin' to do + return; + } + + int[] rh = Table.GetRowHeights(); + int[] ch = Table.GetColumnWidths(); + + if ((isRow && rh.Length < index - 1) || (!isRow && ch.Length < index - 1)) + { + //something got messed up + Debug.Fail("Our indices are outta whack, how did that happen?"); + return; + } + + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null && Table.Site is not null) + { + using (DesignerTransaction t = host.CreateTransaction(string.Format(SR.TableLayoutPanelDesignerChangeSizeTypeUndoUnit, Table.Site.Name))) + { + try + { + Table.SuspendLayout(); + + PropChanging(isRow ? rowStyleProp : colStyleProp); + + switch (newType) + { + case SizeType.Absolute: + styles[index].SizeType = SizeType.Absolute; + if (isRow) + { + Table.RowStyles[index].Height = rh[index]; + } + else + { + Table.ColumnStyles[index].Width = ch[index]; + } + + break; + case SizeType.Percent: + styles[index].SizeType = SizeType.Percent; + if (isRow) + { + Table.RowStyles[index].Height = DesignerUtils.MINIMUMSTYLEPERCENT; + } + else + { + Table.ColumnStyles[index].Width = DesignerUtils.MINIMUMSTYLEPERCENT; + } + + break; + case SizeType.AutoSize: + styles[index].SizeType = SizeType.AutoSize; + break; + default: + Debug.Fail("Unknown SizeType!"); + break; + } + + PropChanged(isRow ? rowStyleProp : colStyleProp); + + Table.ResumeLayout(); + t.Commit(); + } + catch (CheckoutException checkoutException) + { + if (CheckoutException.Canceled.Equals(checkoutException)) + { + t?.Cancel(); + } + else + { + throw; + } + } + } + } + } + catch (System.InvalidOperationException ex) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + uiService.ShowError(ex.Message); + } + } + + private void OnAbsoluteClick(object sender, EventArgs e) => ChangeSizeType((bool)((ToolStripMenuItem)sender).Tag, SizeType.Absolute); + + private void OnPercentClick(object sender, EventArgs e) => ChangeSizeType((bool)((ToolStripMenuItem)sender).Tag, SizeType.Percent); + + private void OnAutoSizeClick(object sender, EventArgs e) => ChangeSizeType((bool)((ToolStripMenuItem)sender).Tag, SizeType.AutoSize); + + private void OnEdit() + { + try + { + EditorServiceContext.EditValue(this, Table, "ColumnStyles"); + } + catch (System.InvalidOperationException ex) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + uiService.ShowError(ex.Message); + } + } + + private static string ReplaceText(string text) => text is null ? null : Regex.Replace(text, @"\(\&.\)", ""); + + private void OnVerbRemove(object sender, EventArgs e) + { + //sniff the text of the verb to see if we're adding columns or rows + bool isRow = ((DesignerVerb)sender).Text.Equals(ReplaceText(SR.TableLayoutPanelDesignerRemoveRow)); + OnRemove(isRow); + } + + private void OnVerbAdd(object sender, EventArgs e) + { + //sniff the text of the verb to see if we're adding columns or rows + bool isRow = ((DesignerVerb)sender).Text.Equals(ReplaceText(SR.TableLayoutPanelDesignerAddRow)); + OnAdd(isRow); + } + + private void OnVerbEdit(object sender, EventArgs e) => OnEdit(); + + protected override void PreFilterProperties(IDictionary properties) + { + base.PreFilterProperties(properties); + + // Handle shadowed properties + string[] shadowProps = new string[] + { + "ColumnStyles", + "RowStyles", + "ColumnCount", + "RowCount" + }; + + // VSWhidbey 491088 + // To enable the PropertyGrid to work with the TableLayoutPanel at runtime (when no designer is available), + // the above properties are marked browsable(false) and re-enabled when a designer is present. + // Since so much of the logic for keeping the TLP in a valid Row/Column state is designer dependent, + // these properties are not accessible by the PropertyGrid without a designer. + Attribute[] attribs = new Attribute[] { new BrowsableAttribute(true) }; + + for (int i = 0; i < shadowProps.Length; i++) + { + PropertyDescriptor prop = (PropertyDescriptor)properties[shadowProps[i]]; + if (prop is not null) + { + properties[shadowProps[i]] = TypeDescriptor.CreateProperty(typeof(TableLayoutPanelDesigner), prop, attribs); + } + } + + // replace this one seperately because it is of a different type (DesignerTableLayoutControlCollection) than + // the original property (TableLayoutControlCollection) + // + PropertyDescriptor controlsProp = (PropertyDescriptor)properties["Controls"]; + + if (controlsProp is not null) + { + Attribute[] attrs = new Attribute[controlsProp.Attributes.Count]; + controlsProp.Attributes.CopyTo(attrs, 0); + properties["Controls"] = TypeDescriptor.CreateProperty(typeof(TableLayoutPanelDesigner), "Controls", typeof(DesignerTableLayoutControlCollection), attrs); + } + } + + private void Refresh() + { + //refresh selection, glyphs, and adorners + BehaviorService.SyncSelection(); + + Table?.Invalidate(true); + } + + private void PropChanging(PropertyDescriptor prop) + { + if (compSvc is not null && prop is not null) + { + compSvc.OnComponentChanging(Table, prop); + } + } + + private void PropChanged(PropertyDescriptor prop) + { + if (compSvc is not null && prop is not null) + { + compSvc.OnComponentChanged(Table, prop, null, null); + } + } + + [ListBindable(false)] + [DesignerSerializer(typeof(DesignerTableLayoutControlCollectionCodeDomSerializer), typeof(CodeDomSerializer))] + internal class DesignerTableLayoutControlCollection : TableLayoutControlCollection, IList + { + private TableLayoutControlCollection realCollection; + + public DesignerTableLayoutControlCollection(TableLayoutPanel owner) : base(owner) => realCollection = owner.Controls; + + public override int Count => realCollection.Count; + + object ICollection.SyncRoot => this; + + bool ICollection.IsSynchronized => false; + + bool IList.IsFixedSize => false; + + public new bool IsReadOnly => realCollection.IsReadOnly; + + int IList.Add(object control) => ((IList)realCollection).Add(control); + + public override void Add(Control c) => realCollection.Add(c); + + public override void AddRange(Control[] controls) => realCollection.AddRange(controls); + + bool IList.Contains(object control) => ((IList)realCollection).Contains(control); + + public new void CopyTo(Array dest, int index) => realCollection.CopyTo(dest, index); + + public override bool Equals(object other) => realCollection.Equals(other); + + public new IEnumerator GetEnumerator() => realCollection.GetEnumerator(); + + public override int GetHashCode() => realCollection.GetHashCode(); + + int IList.IndexOf(object control) => ((IList)realCollection).IndexOf(control); + + void IList.Insert(int index, object value) => ((IList)realCollection).Insert(index, value); + + void IList.Remove(object control) => ((IList)realCollection).Remove(control); + + void IList.RemoveAt(int index) => ((IList)realCollection).RemoveAt(index); + + object IList.this[int index] + { + get + { + return ((IList)realCollection)[index]; + } + set + { + throw new NotSupportedException(); + } + } + + public override void Add(Control control, int column, int row) => realCollection.Add(control, column, row); + + public override int GetChildIndex(Control child, bool throwException) => realCollection.GetChildIndex(child, throwException); + + public override void SetChildIndex(Control child, int newIndex) => realCollection.SetChildIndex(child, newIndex); + + public override void Clear() + { + // only remove the sited non-inherited components + for (int i = realCollection.Count - 1; i >= 0; i--) + { + if (realCollection[i] is not null && + realCollection[i].Site is not null && + TypeDescriptor.GetAttributes(realCollection[i]).Contains(InheritanceAttribute.NotInherited)) + { + realCollection.RemoveAt(i); + } + } + } + } + + // Custom code dom serializer for the DesignerControlCollection. We need this so we can filter out controls + // that aren't sited in the host's container. + internal class DesignerTableLayoutControlCollectionCodeDomSerializer : TableLayoutControlCollectionCodeDomSerializer + { + protected override object SerializeCollection(IDesignerSerializationManager manager, CodeExpression targetExpression, Type targetType, ICollection originalCollection, ICollection valuesToSerialize) + { + ArrayList subset = new ArrayList(); + + if (valuesToSerialize is not null && valuesToSerialize.Count > 0) + { + foreach (object val in valuesToSerialize) + { + IComponent comp = val as IComponent; + + if (comp is not null && comp.Site is not null && !(comp.Site is INestedSite)) + { + subset.Add(comp); + } + } + } + + return base.SerializeCollection(manager, targetExpression, targetType, originalCollection, subset); + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TemplateNodeCustomMenuItemCollection.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TemplateNodeCustomMenuItemCollection.cs index ccdc33c2c6f..81f746ee31b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TemplateNodeCustomMenuItemCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TemplateNodeCustomMenuItemCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TemplateNodeSelectionState.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TemplateNodeSelectionState.cs index c81d4819a79..b3ecd9bae6c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TemplateNodeSelectionState.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TemplateNodeSelectionState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxActionList.cs index 15c05418ca5..a9c956b6c65 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxActionList.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxActionList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxBaseDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxBaseDesigner.cs index 22eb03769b9..26efc159cee 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxBaseDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxBaseDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxDesigner.cs index 7657a77df50..fbfb49049fb 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TextBoxDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ThemedScrollbarMode.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ThemedScrollbarMode.cs index d5b33b19c2b..dcaa44970e0 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ThemedScrollbarMode.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ThemedScrollbarMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ThemedScrollbarWindow.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ThemedScrollbarWindow.cs index 09030343964..135b13397e4 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ThemedScrollbarWindow.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ThemedScrollbarWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripActionList.cs index 5c1f40f514d..0f2806d3f96 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripActionList.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripActionList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripAdornerWindowService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripAdornerWindowService.cs index 725b520a59a..7991bb44c7c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripAdornerWindowService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripAdornerWindowService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripCodeDomSerializer.cs index f090befe1f1..301d1ac610c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripContainerDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripContainerDesigner.cs new file mode 100644 index 00000000000..b592e17cecc --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripContainerDesigner.cs @@ -0,0 +1,490 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.Collections; +using System.ComponentModel.Design; +using System.Drawing; +using System.Drawing.Design; +using System.Windows.Forms.Design.Behavior; + +namespace System.Windows.Forms.Design; + +internal class ToolStripContainerDesigner : ParentControlDesigner +{ + private ToolStripPanel? _topToolStripPanel; + private ToolStripPanel? _bottomToolStripPanel; + private ToolStripPanel? _leftToolStripPanel; + private ToolStripPanel? _rightToolStripPanel; + private ToolStripContentPanel? _contentToolStripPanel; + + private const string TopToolStripPanelName = "TopToolStripPanel"; + private const string BottomToolStripPanelName = "BottomToolStripPanel"; + private const string LeftToolStripPanelName = "LeftToolStripPanel"; + private const string RightToolStripPanelName = "RightToolStripPanel"; + private const string ContentToolStripPanelName = "ContentPanel"; + + private Control[]? _panels; + private bool _disableDrawGrid; + private ISelectionService? _selectionService; + private ToolStripContainer? _toolStripContainer; + + /// + /// The that owns this designer. + /// + private IDesignerHost _designerHost => (IDesignerHost)GetService(typeof(IDesignerHost)); + + /// + /// Shadow the property at design-time + /// so that we only set the visibility at design time if the user sets it directly. + /// + private bool TopToolStripPanelVisible + { + get => (bool)ShadowProperties[nameof(TopToolStripPanelVisible)]; + set + { + ShadowProperties[nameof(TopToolStripPanelVisible)] = value; + ((ToolStripContainer)Component).TopToolStripPanelVisible = value; + } + } + + /// + /// Shadow the property at design-time + /// so that we only set the visibility at design time if the user sets it directly. + /// + private bool LeftToolStripPanelVisible + { + get => (bool)ShadowProperties[nameof(LeftToolStripPanelVisible)]; + set + { + ShadowProperties[nameof(LeftToolStripPanelVisible)] = value; + ((ToolStripContainer)Component).LeftToolStripPanelVisible = value; + } + } + + /// + /// Shadow the property at design-time + /// so that we only set the visibility at design time if the user sets it directly. + /// + private bool RightToolStripPanelVisible + { + get => (bool)ShadowProperties[nameof(RightToolStripPanelVisible)]; + set + { + ShadowProperties[nameof(RightToolStripPanelVisible)] = value; + ((ToolStripContainer)Component).RightToolStripPanelVisible = value; + } + } + + /// + /// Shadow the property at design-time + /// so that we only set the visibility at design time if the user sets it directly. + /// + private bool BottomToolStripPanelVisible + { + get => (bool)ShadowProperties[nameof(BottomToolStripPanelVisible)]; + set + { + ShadowProperties[nameof(BottomToolStripPanelVisible)] = value; + ((ToolStripContainer)Component).BottomToolStripPanelVisible = value; + } + } + + public override DesignerActionListCollection ActionLists + { + get + { + DesignerActionListCollection actions = new DesignerActionListCollection(); + + // Here is our action list we'll use + ToolStripContainerActionList actionList = new ToolStripContainerActionList(_toolStripContainer!) + { + AutoShow = true + }; + + actions.Add(actionList); + return actions; + } + } + + /// + /// The ToolStripContainerDesigner will re-parent any controls that are within it's lasso at + /// creation time. + /// + protected override bool AllowControlLasso => false; + + protected override bool DrawGrid => !_disableDrawGrid && base.DrawGrid; + + public override IList SnapLines + // We don't want padding SnapLines, so call directly to the internal method. + => SnapLinesInternal(); + + /// + /// Returns the internal control designer with the specified index in the ControlDesigner. + /// internalControlIndex is zero-based. + /// + public override ControlDesigner? InternalControlDesigner(int internalControlIndex) + { + if (_panels is null) + { + return null; + } + + if (internalControlIndex >= _panels.Length || internalControlIndex < 0) + { + return null; + } + + Control panel = _panels[internalControlIndex]; + + return _designerHost.GetDesigner(panel) as ControlDesigner; + } + + /// + /// We want those to come with in any cut, copy operations. + /// + public override ICollection AssociatedComponents + { + get + { + ArrayList components = new ArrayList(); + foreach (Control parent in _toolStripContainer!.Controls) + { + foreach (Control control in parent.Controls) + { + components.Add(control); + } + } + + return components; + } + } + + protected override IComponent[]? CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize) + { + if (tool is null) + { + return null; + } + + Type toolType = tool.GetType(_designerHost); + + if (typeof(StatusStrip).IsAssignableFrom(toolType)) + { + InvokeCreateTool(GetDesigner(_bottomToolStripPanel!), tool); + } + else if (typeof(ToolStrip).IsAssignableFrom(toolType)) + { + InvokeCreateTool(GetDesigner(_topToolStripPanel!), tool); + } + else + { + InvokeCreateTool(GetDesigner(_contentToolStripPanel!), tool); + } + + return null; + } + + public override bool CanParent(Control control) => false; + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (_selectionService is not null) + { + _selectionService = null; + } + } + + private ToolStripPanelDesigner? GetDesigner(ToolStripPanel panel) + => _designerHost.GetDesigner(panel) is ToolStripPanelDesigner toolStripPanelDesigner + ? toolStripPanelDesigner + : null; + + private PanelDesigner? GetDesigner(ToolStripContentPanel panel) + => _designerHost.GetDesigner(panel) is PanelDesigner panelDesigner + ? panelDesigner + : null; + + private static ToolStripContainer? ContainerParent(Control control) + { + if (control is null or ToolStripContainer) + { + return null; + } + + ToolStripContainer? parent = null; + while (control.Parent is not null) + { + if (control.Parent is ToolStripContainer) + { + parent = control.Parent as ToolStripContainer; + break; + } + + control = control.Parent; + } + + return parent; + } + + protected override ControlBodyGlyph GetControlGlyph(GlyphSelectionType selectionType) + { + SelectionManager selectionManager = GetService(); + + if (selectionManager is null) + { + return base.GetControlGlyph(selectionType); + } + + //Create BodyGlyphs for all _panels + for (int i = 0; i <= 4; i++) + { + Control currentPanel = _panels![i]; + Rectangle translatedBounds = BehaviorService.ControlRectInAdornerWindow(currentPanel); + ControlDesigner? panelDesigner = InternalControlDesigner(i); + OnSetCursor(); + + if (panelDesigner is not null) + { + //create our glyph, and set its cursor appropriately + ControlBodyGlyph bodyGlyph = new ControlBodyGlyph(translatedBounds, Cursor.Current, currentPanel, panelDesigner); + selectionManager.BodyGlyphAdorner.Glyphs.Add(bodyGlyph); + + bool addGlyphs = true; + ICollection selComponents = _selectionService!.GetSelectedComponents(); + if (!_selectionService.GetComponentSelected(_toolStripContainer!)) + { + foreach (object comp in selComponents) + { + ToolStripContainer container = ContainerParent((Control)comp)!; + addGlyphs = container == _toolStripContainer; + } + } + + if (addGlyphs) + { + ToolStripPanelDesigner? designer = panelDesigner as ToolStripPanelDesigner; + if (designer is not null) + { + AddPanelSelectionGlyph(designer, selectionManager); + } + } + } + } + + return base.GetControlGlyph(selectionType); + } + + private static Control? GetAssociatedControl(Component component) + { + Control? associatedControl = null; + if (component is Control control) + { + return control; + } + + if (component is ToolStripItem item) + { + Control parent = item.GetCurrentParent()!; + parent ??= item.Owner!; + + return parent; + } + + return associatedControl; + } + + private bool CheckDropDownBounds(ToolStripDropDownItem dropDownItem, Glyph childGlyph, GlyphCollection glyphs) + { + if (dropDownItem is null) + { + return false; + } + + Rectangle glyphBounds = childGlyph.Bounds; + Rectangle controlBounds = BehaviorService.ControlRectInAdornerWindow(dropDownItem.DropDown); + if (!glyphBounds.IntersectsWith(controlBounds)) + { + glyphs.Insert(0, childGlyph); + } + + return true; + } + + /// + /// Checks if the associated control bounds overlap the PanelSelectionGlyph bounds. + /// + private bool CheckAssociatedControl(Component component, Glyph childGlyph, GlyphCollection glyphs) + { + bool result = false; + + ToolStripDropDownItem? item = component as ToolStripDropDownItem; + if (item is not null) + { + result = CheckDropDownBounds(item, childGlyph, glyphs); + } + + if (!result) + { + Control? associatedControl = GetAssociatedControl(component); + if (associatedControl is not null + && _toolStripContainer is not null + && associatedControl != _toolStripContainer + && !PInvoke.IsChild(_toolStripContainer, associatedControl)) + { + Rectangle glyphBounds = childGlyph.Bounds; + Rectangle controlBounds = BehaviorService.ControlRectInAdornerWindow(associatedControl); + if ((component == _designerHost.RootComponent) || !glyphBounds.IntersectsWith(controlBounds)) + { + glyphs.Insert(0, childGlyph); + } + + result = true; + } + } + + return result; + } + + protected override Control? GetParentForComponent(IComponent component) + { + Type toolType = component.GetType(); + + if (typeof(StatusStrip).IsAssignableFrom(toolType)) + { + return _bottomToolStripPanel; + } + else if (typeof(ToolStrip).IsAssignableFrom(toolType)) + { + return _topToolStripPanel; + } + else + { + return _contentToolStripPanel; + } + } + + public override void Initialize(IComponent component) + { + _toolStripContainer = (ToolStripContainer)component; + base.Initialize(component); + AutoResizeHandles = true; + + _topToolStripPanel = _toolStripContainer.TopToolStripPanel; + _bottomToolStripPanel = _toolStripContainer.BottomToolStripPanel; + _leftToolStripPanel = _toolStripContainer.LeftToolStripPanel; + _rightToolStripPanel = _toolStripContainer.RightToolStripPanel; + _contentToolStripPanel = _toolStripContainer.ContentPanel; + + _panels = [_contentToolStripPanel, _leftToolStripPanel, _rightToolStripPanel, _topToolStripPanel, _bottomToolStripPanel]; + + // Add custom bitmaps for the child toolStripPanels. + ToolboxBitmapAttribute bottomToolboxBitmapAttribute = new ToolboxBitmapAttribute(typeof(ToolStripPanel), "ToolStripContainer_BottomToolStripPanel"); + ToolboxBitmapAttribute rightToolboxBitmapAttribute = new ToolboxBitmapAttribute(typeof(ToolStripPanel), "ToolStripContainer_RightToolStripPanel"); + ToolboxBitmapAttribute topToolboxBitmapAttribute = new ToolboxBitmapAttribute(typeof(ToolStripPanel), "ToolStripContainer_TopToolStripPanel"); + ToolboxBitmapAttribute leftToolboxBitmapAttribute = new ToolboxBitmapAttribute(typeof(ToolStripPanel), "ToolStripContainer_LeftToolStripPanel"); + + TypeDescriptor.AddAttributes(_bottomToolStripPanel, bottomToolboxBitmapAttribute, new DescriptionAttribute("bottom")); + TypeDescriptor.AddAttributes(_rightToolStripPanel, rightToolboxBitmapAttribute, new DescriptionAttribute("right")); + TypeDescriptor.AddAttributes(_leftToolStripPanel, leftToolboxBitmapAttribute, new DescriptionAttribute("left")); + TypeDescriptor.AddAttributes(_topToolStripPanel, topToolboxBitmapAttribute, new DescriptionAttribute("top")); + + EnableDesignMode(_topToolStripPanel, TopToolStripPanelName); + EnableDesignMode(_bottomToolStripPanel, BottomToolStripPanelName); + EnableDesignMode(_leftToolStripPanel, LeftToolStripPanelName); + EnableDesignMode(_rightToolStripPanel, RightToolStripPanelName); + EnableDesignMode(_contentToolStripPanel, ContentToolStripPanelName); + + _selectionService ??= (ISelectionService)GetService(typeof(ISelectionService)); + + if (_topToolStripPanel is not null) + { + ToolStripPanelDesigner? panelDesigner = _designerHost?.GetDesigner(_topToolStripPanel) as ToolStripPanelDesigner; + panelDesigner?.ExpandTopPanel(); + } + + // Set ShadowProperties + TopToolStripPanelVisible = _toolStripContainer.TopToolStripPanelVisible; + LeftToolStripPanelVisible = _toolStripContainer.LeftToolStripPanelVisible; + RightToolStripPanelVisible = _toolStripContainer.RightToolStripPanelVisible; + BottomToolStripPanelVisible = _toolStripContainer.BottomToolStripPanelVisible; + } + + public override void InitializeNewComponent(IDictionary defaultValues) => base.InitializeNewComponent(defaultValues); + + protected override void OnPaintAdornments(PaintEventArgs pe) + { + try + { + _disableDrawGrid = true; + + // we don't want to do this for the tab control designer + // because you can't drag anything onto it anyway. + // so we will always return false for draw grid. + base.OnPaintAdornments(pe); + } + finally + { + _disableDrawGrid = false; + } + } + + /// + /// Allows a designer to filter the set of properties + /// the component it is designing will expose through the + /// TypeDescriptor object. This method is called + /// immediately before its corresponding "Post" method. + /// If you are overriding this method you should call + /// the base implementation before you perform your own + /// filtering. + /// + protected override void PreFilterProperties(IDictionary properties) + { + PropertyDescriptor? propertyDescriptor; + + base.PreFilterProperties(properties); + + // Handle shadowed properties + string[] shadowProps = + [ + "TopToolStripPanelVisible", + "LeftToolStripPanelVisible", + "RightToolStripPanelVisible", + "BottomToolStripPanelVisible" + ]; + + Attribute[] empty = []; + + for (int i = 0; i < shadowProps.Length; i++) + { + propertyDescriptor = (PropertyDescriptor?)properties[shadowProps[i]]; + if (propertyDescriptor is not null) + { + properties[shadowProps[i]] = TypeDescriptor.CreateProperty(typeof(ToolStripContainerDesigner), propertyDescriptor, empty); + } + } + } + + private void AddPanelSelectionGlyph(ToolStripPanelDesigner designer, SelectionManager selectionManager) + { + if (designer is null || designer.GetGlyph() is not { } childGlyph || _selectionService is null) + { + return; + } + + // Now create SelectionGlyph for the panel and add it + ICollection selectedComponents = _selectionService.GetSelectedComponents(); + foreach (object selectedComponent in selectedComponents) + { + Component component = (Component)selectedComponent; + if (component is not null) + { + if (!CheckAssociatedControl(component, childGlyph, selectionManager.BodyGlyphAdorner.Glyphs)) + { + selectionManager.BodyGlyphAdorner.Glyphs.Insert(0, childGlyph); + } + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripContentPanelDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripContentPanelDesigner.cs new file mode 100644 index 00000000000..542c17bb059 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripContentPanelDesigner.cs @@ -0,0 +1,99 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.Collections; +using System.ComponentModel.Design; + +namespace System.Windows.Forms.Design; + +internal class ToolStripContentPanelDesigner : PanelDesigner +{ + private BaseContextMenuStrip? _contextMenu; + + private ContextMenuStrip DesignerContextMenu + { + get + { + if (_contextMenu is null) + { + _contextMenu = new BaseContextMenuStrip(Component.Site, Component as Component); + + // If multiple Items Selected don't show the custom properties... + _contextMenu.GroupOrdering.Clear(); + _contextMenu.GroupOrdering.AddRange( + [ + StandardGroups.Code, + StandardGroups.Verbs, + StandardGroups.Custom, + StandardGroups.Selection, + StandardGroups.Edit, + StandardGroups.Properties + ]); + _contextMenu.Text = "CustomContextMenu"; + } + + return _contextMenu; + } + } + + public override IList SnapLines + { + get + { + // We don't want margin snap lines, so call directly to the internal method. + ArrayList? snapLines = null; + AddPaddingSnapLines(ref snapLines); + return snapLines; + } + } + + public override bool CanBeParentedTo(IDesigner parentDesigner) + { + return false; + } + + protected override void OnContextMenu(int x, int y) + { + ToolStripContentPanel? panel = Component as ToolStripContentPanel; + if (panel is not null && panel.Parent is ToolStripContainer) + { + DesignerContextMenu.Show(x, y); + } + else + { + base.OnContextMenu(x, y); + } + } + + protected override void PreFilterEvents(IDictionary events) + { + base.PreFilterEvents(events); + EventDescriptor? eventDescriptor; + string[] noBrowseEvents = + [ + "BindingContextChanged", + "ChangeUICues", + "ClientSizeChanged", + "EnabledChanged", + "FontChanged", + "ForeColorChanged", + "GiveFeedback", + "ImeModeChanged", + "Move", + "QueryAccessibilityHelp", + "Validated", + "Validating", + "VisibleChanged", + ]; + + for (int i = 0; i < noBrowseEvents.Length; i++) + { + eventDescriptor = (EventDescriptor?)events[noBrowseEvents[i]]; + if (eventDescriptor is not null) + { + events[noBrowseEvents[i]] = TypeDescriptor.CreateEvent(eventDescriptor.ComponentType, eventDescriptor, BrowsableAttribute.No); + } + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesigner.cs index f209d7fb5b2..ec1ded182f9 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -45,7 +44,7 @@ internal class ToolStripDesigner : ControlDesigner private ToolStripActionList _actionLists; // Action List on Chrome... private ToolStripAdornerWindowService _toolStripAdornerWindowService; // Add the Adorner Service for OverFlow DropDown... private IDesignerHost _host; //get private copy of the DesignerHost - private IComponentChangeService _componentChangeSvc; + private IComponentChangeService _componentChangeService; private bool _undoingCalled; private IToolboxService _toolboxService; private ContextMenuStrip _toolStripContextMenu; @@ -93,7 +92,7 @@ private Rectangle AddItemRect { get { - Rectangle rect = default(Rectangle); + Rectangle rect = default; if (_miniToolStrip is null) { return rect; @@ -372,7 +371,7 @@ private Rectangle OverFlowButtonRect { get { - Rectangle rect = default(Rectangle); + Rectangle rect = default; if (ToolStrip.OverflowButton.Visible) { return ToolStrip.OverflowButton.Bounds; @@ -1392,7 +1391,7 @@ public override void Initialize(IComponent component) AutoResizeHandles = true; if (TryGetService(out _host)) { - _componentChangeSvc = (IComponentChangeService)_host.GetService(typeof(IComponentChangeService)); + _componentChangeService = (IComponentChangeService)_host.GetService(typeof(IComponentChangeService)); } // initialize new Manager For Editing ToolStrips @@ -1442,7 +1441,7 @@ public override void Initialize(IComponent component) /// public override void InitializeNewComponent(IDictionary defaultValues) { - Control parent = defaultValues["Parent"] as Control; + Control parent = defaultValues is not null ? defaultValues["Parent"] as Control : null; Form parentForm = _host.RootComponent as Form; FormDocumentDesigner parentFormDesigner = null; if (parentForm is not null) @@ -1484,18 +1483,18 @@ public override void InitializeNewComponent(IDictionary defaultValues) { PropertyDescriptor controlsProp = TypeDescriptor.GetProperties(parentPanel)["Controls"]; - _componentChangeSvc?.OnComponentChanging(parentPanel, controlsProp); + _componentChangeService?.OnComponentChanging(parentPanel, controlsProp); parentPanel.Join(ToolStrip, parentPanel.Rows.Length); - _componentChangeSvc?.OnComponentChanged(parentPanel, controlsProp, parentPanel.Controls, parentPanel.Controls); + _componentChangeService?.OnComponentChanged(parentPanel, controlsProp, parentPanel.Controls, parentPanel.Controls); //Try to fire ComponentChange on the Location Property for ToolStrip. PropertyDescriptor locationProp = TypeDescriptor.GetProperties(ToolStrip)["Location"]; - if (_componentChangeSvc is not null) + if (_componentChangeService is not null) { - _componentChangeSvc.OnComponentChanging(ToolStrip, locationProp); - _componentChangeSvc.OnComponentChanged(ToolStrip, locationProp); + _componentChangeService.OnComponentChanging(ToolStrip, locationProp); + _componentChangeService.OnComponentChanged(ToolStrip, locationProp); } } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesignerUtils.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesignerUtils.cs index 81fdfe6ac82..20b7c76e548 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesignerUtils.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesignerUtils.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownDesigner.cs index 9bd47b06a1b..569966db7ad 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownItemDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownItemDesigner.cs index 1a2d74b1daa..71548dfac69 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownItemDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDropDownItemDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripEditorManager.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripEditorManager.cs index 022f713bfb0..c3f4fe98097 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripEditorManager.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripEditorManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripInSituService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripInSituService.cs index 6f176184d90..1223d90f5d6 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripInSituService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripInSituService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -16,7 +15,7 @@ internal class ToolStripInSituService : ISupportInSituService, IDisposable { private readonly IServiceProvider _sp; private readonly IDesignerHost _designerHost; - private IComponentChangeService _componentChangeSvc; + private IComponentChangeService _componentChangeService; private ToolStripDesigner _toolDesigner; private ToolStripItemDesigner _toolItemDesigner; private ToolStripKeyboardHandlingService _toolStripKeyBoardService; @@ -31,11 +30,11 @@ public ToolStripInSituService(IServiceProvider provider) Debug.Assert(_designerHost is not null, "ToolStripKeyboardHandlingService relies on the selection service, which is unavailable."); _designerHost?.AddService(typeof(ISupportInSituService), this); - _componentChangeSvc = (IComponentChangeService)_designerHost.GetService(typeof(IComponentChangeService)); - Debug.Assert(_componentChangeSvc is not null, "ToolStripKeyboardHandlingService relies on the componentChange service, which is unavailable."); - if (_componentChangeSvc is not null) + _componentChangeService = (IComponentChangeService)_designerHost.GetService(typeof(IComponentChangeService)); + Debug.Assert(_componentChangeService is not null, "ToolStripKeyboardHandlingService relies on the componentChange service, which is unavailable."); + if (_componentChangeService is not null) { - _componentChangeSvc.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); + _componentChangeService.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); } } @@ -56,10 +55,10 @@ public void Dispose() _toolItemDesigner = null; } - if (_componentChangeSvc is not null) + if (_componentChangeService is not null) { - _componentChangeSvc.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); - _componentChangeSvc = null; + _componentChangeService.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); + _componentChangeService = null; } } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemBehavior.cs index aea0a762f36..b995fad2278 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemBehavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemBehavior.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemCustomMenuItemCollection.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemCustomMenuItemCollection.cs index 0634afa17f2..6c502eb6efd 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemCustomMenuItemCollection.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemCustomMenuItemCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemDataObject.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemDataObject.cs index d332a070050..0534eef00fb 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemDataObject.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemDataObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemDesigner.cs index e1345cb384f..7fe7a76713d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemGlyph.cs index f08d396395e..ed107058244 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemGlyph.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripItemGlyph.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Design.Behavior; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripKeyboardHandlingService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripKeyboardHandlingService.cs index b362fdce10e..28590e13260 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripKeyboardHandlingService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripKeyboardHandlingService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -15,7 +14,7 @@ namespace System.Windows.Forms.Design; internal class ToolStripKeyboardHandlingService { private ISelectionService _selectionService; - private IComponentChangeService _componentChangeSvc; + private IComponentChangeService _componentChangeService; private IServiceProvider _provider; private IMenuCommandService _menuCommandService; private readonly IDesignerHost _designerHost; @@ -60,11 +59,11 @@ public ToolStripKeyboardHandlingService(IServiceProvider serviceProvider) Debug.Assert(_designerHost is not null, "ToolStripKeyboardHandlingService relies on the selection service, which is unavailable."); _designerHost?.AddService(typeof(ToolStripKeyboardHandlingService), this); - _componentChangeSvc = (IComponentChangeService)_designerHost.GetService(typeof(IComponentChangeService)); - Debug.Assert(_componentChangeSvc is not null, "ToolStripKeyboardHandlingService relies on the componentChange service, which is unavailable."); - if (_componentChangeSvc is not null) + _componentChangeService = (IComponentChangeService)_designerHost.GetService(typeof(IComponentChangeService)); + Debug.Assert(_componentChangeService is not null, "ToolStripKeyboardHandlingService relies on the componentChange service, which is unavailable."); + if (_componentChangeService is not null) { - _componentChangeSvc.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); + _componentChangeService.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); } } @@ -1635,10 +1634,10 @@ public void RemoveCommands() _selectionService = null; } - if (_componentChangeSvc is not null) + if (_componentChangeService is not null) { - _componentChangeSvc.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); - _componentChangeSvc = null; + _componentChangeService.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); + _componentChangeService = null; } _currentSelection = null; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemCodeDomSerializer.cs index 2b31db82672..998da92ee76 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemCodeDomSerializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemDesigner.cs index c64a5e531a7..665d0ef3b36 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripMenuItemDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripPanelDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripPanelDesigner.cs new file mode 100644 index 00000000000..601d73b0506 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripPanelDesigner.cs @@ -0,0 +1,607 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.Collections; +using System.ComponentModel.Design; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Design; +using System.Windows.Forms.Design.Behavior; +using System.Runtime.Versioning; + +namespace System.Windows.Forms.Design; + +/// +/// Designer for the ToolStripPanel. +/// +internal class ToolStripPanelDesigner : ScrollableControlDesigner +{ + private static Padding s_defaultPadding = new(0); + private ToolStripPanel? _panel; + private IComponentChangeService? _componentChangeService; + private IDesignerHost? _designerHost; + + // The container selector glyph which is associated with this designer. + private ToolStripPanelSelectionGlyph? _containerSelectorGlyph; + private ToolStripPanelSelectionBehavior? _behavior; + + //Designer context Menu for this designer + private BaseContextMenuStrip? _contextMenu; + + // The SelectionService.. + private ISelectionService? _selectionService; + + private MenuCommand? _designerShortCutCommand; + private MenuCommand? _oldShortCutCommand; + + /// + /// Creates a Dashed-Pen of appropriate color. + /// + private Pen BorderPen + { + [ResourceExposure(ResourceScope.Process)] + [ResourceConsumption(ResourceScope.Process)] + get + { + Color penColor = Control.BackColor.GetBrightness() < .5 ? + ControlPaint.Light(Control.BackColor) : + ControlPaint.Dark(Control.BackColor); + + Pen pen = new Pen(penColor) + { + DashStyle = DashStyle.Dash + }; + + return pen; + } + } + + // Custom ContextMenu. + private ContextMenuStrip DesignerContextMenu + { + get + { + if (_contextMenu is null) + { + _contextMenu = new BaseContextMenuStrip(Component.Site, Component as Component); + // If multiple Items Selected don't show the custom properties... + _contextMenu.GroupOrdering.Clear(); + _contextMenu.GroupOrdering.AddRange([StandardGroups.Code, + StandardGroups.Verbs, + StandardGroups.Custom, + StandardGroups.Selection, + StandardGroups.Edit, + StandardGroups.Properties + ]); + _contextMenu.Text = "CustomContextMenu"; + } + + return _contextMenu; + } + } + + // ToolStripPanels if Inherited ACT as Readonly. + protected override InheritanceAttribute InheritanceAttribute + { + get => _panel is not null && _panel.Parent is ToolStripContainer && (base.InheritanceAttribute == InheritanceAttribute.Inherited) + ? InheritanceAttribute.InheritedReadOnly + : base.InheritanceAttribute; + } + + private Padding Padding + { + get => (Padding)ShadowProperties[nameof(Padding)]; + set + { + ShadowProperties[nameof(Padding)] = value; + } + } + + /// + /// This designer doesn't participate in SnapLines for the controls contained.. + /// + public override bool ParticipatesWithSnapLines => false; + + /// + /// Retrieves a set of rules concerning the movement capabilities of a component. + /// This should be one or more flags from the SelectionRules class. If no designer + /// provides rules for a component, the component will not get any UI services. + /// + public override SelectionRules SelectionRules + => _panel?.Parent is ToolStripContainer + ? SelectionRules.Locked + : base.SelectionRules; + + /// + /// Called from to set the Expanded + /// state to false when the panel's visibility is changed. + /// + public ToolStripPanelSelectionGlyph? ToolStripPanelSelectorGlyph { get; private set; } + + /// + /// ShadowProperty. + /// + private bool Visible + { + get => (bool)ShadowProperties[nameof(Visible)]; + set + { + ShadowProperties[nameof(Visible)] = value; + _panel!.Visible = value; + } + } + + /// + /// Determines if the this designer can parent to the specified designers + /// generally this means if the control for this designer can parent the + /// given ControlDesigner's designer. + /// + public override bool CanParent(Control control) + => control is ToolStrip; + + /// + /// This designer can be parented to only ToolStripContainer. + /// + public override bool CanBeParentedTo(IDesigner parentDesigner) + => _panel is not null && _panel.Parent is not ToolStripContainer; + + /// + /// Update the glyph whenever component is changed. + /// + private void OnComponentChanged(object? sender, ComponentChangedEventArgs e) + => _containerSelectorGlyph?.UpdateGlyph(); + + /// + /// This is the worker method of all CreateTool methods. It is the only one + /// that can be overridden. + /// + protected override IComponent[]? CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize) + { + if (tool is null) + { + return null; + } + + Type toolType = tool.GetType(_designerHost); + + if (!typeof(ToolStrip).IsAssignableFrom(toolType)) + { + //ToolStripContainer? parent = _panel?.Parent as ToolStripContainer; + if (_panel?.Parent is ToolStripContainer parent + && parent.ContentPanel is { } contentPanel + && _designerHost?.GetDesigner(contentPanel) is PanelDesigner designer) + { + InvokeCreateTool(designer, tool); + } + } + else + { + base.CreateToolCore(tool, x, y, width, height, hasLocation, hasSize); + } + + return null; + } + + /// + /// Disposes of this designer. + /// + protected override void Dispose(bool disposing) + { + try + { + // Bug 904525: Need to recover the old menu item when deleting the component. + if (_selectionService is not null && _selectionService.PrimarySelection is null) + { + OnSelectionChanging(_selectionService, EventArgs.Empty); + } + + base.Dispose(disposing); + } + finally + { + if (disposing) + { + _contextMenu?.Dispose(); + } + + if (_selectionService is not null) + { + _selectionService.SelectionChanging -= OnSelectionChanging; + _selectionService.SelectionChanged -= OnSelectionChanged; + _selectionService = null; + } + + if (_componentChangeService is not null) + { + _componentChangeService.ComponentChanged -= OnComponentChanged; + } + + _panel!.ControlAdded -= OnControlAdded; + _panel.ControlRemoved -= OnControlRemoved; + } + } + + /// + /// This draws a nice border around our RaftingContainer. We need + /// this because the _panel can have no border and you can't + /// tell where it is. + /// + private void DrawBorder(Graphics graphics) + { + Pen pen = BorderPen; + Rectangle rc = Control.ClientRectangle; + + rc.Width--; + rc.Height--; + + graphics.DrawRectangle(pen, rc); + + pen.Dispose(); + } + + /// + /// We need to expand the TopToolStripPanel only when the control is Dropped onto the form .. for the first time. + /// + internal void ExpandTopPanel() + { + if (_containerSelectorGlyph is null && Component.Site is not null) + { + //get the adorner window-relative coordinates for the container control + _behavior = new ToolStripPanelSelectionBehavior(_panel!, Component.Site); + _containerSelectorGlyph = new ToolStripPanelSelectionGlyph(Rectangle.Empty, Cursors.Default, _panel!, Component.Site, _behavior); + } + + if (_containerSelectorGlyph is not null && _panel?.Dock == DockStyle.Top) + { + _panel.Padding = new Padding(0, 0, 25, 25); + _containerSelectorGlyph.IsExpanded = true; + } + } + + private void OnKeyShowDesignerActions(object? sender, EventArgs e) + { + if (_containerSelectorGlyph is null) + { + return; + } + + _behavior?.OnMouseDown(_containerSelectorGlyph, MouseButtons.Left, Point.Empty); + } + + /// + /// Since we have to initialize glyphs for SplitterPanel (which is not a part of Components.) we override the + /// GetGlyphs for the parent. + /// + internal Glyph? GetGlyph() + { + if (_panel is null) + { + return null; + } + + // Add own Glyphs. + if (_containerSelectorGlyph is null && Component.Site is not null) + { + //get the adorner window-relative coordinates for the container control + _behavior = new ToolStripPanelSelectionBehavior(_panel, Component.Site); + _containerSelectorGlyph = new ToolStripPanelSelectionGlyph(Rectangle.Empty, Cursors.Default, _panel, Component.Site, _behavior); + } + + // Show the Glyph only if Panel is Visible. + return _panel.Visible ? _containerSelectorGlyph : null; + } + + /// + /// This property is used by deriving classes to determine if it returns the control being designed or some other Container + /// while adding a component to it. + /// e.g: When SplitContainer is selected and a component is being added ... the SplitContainer designer would return a + /// SelectedPanel as the ParentControl for all the items being added rather than itself. + /// + protected override Control? GetParentForComponent(IComponent component) + { + Type toolType = component.GetType(); + + if (typeof(ToolStrip).IsAssignableFrom(toolType)) + { + return _panel; + } + + ToolStripContainer? parent = _panel?.Parent as ToolStripContainer; + return parent is not null ? parent.ContentPanel : (Control?)null; + } + + /// + /// Get the designer set up to run. + /// + public override void Initialize(IComponent component) + { + if (component is null) + { + return; + } + + _panel = component as ToolStripPanel; + + base.Initialize(component); + + Padding = _panel!.Padding; + _designerHost = component?.Site?.GetService(); + + if (_selectionService is null) + { + _selectionService = GetService(); + _selectionService.SelectionChanging += OnSelectionChanging; + _selectionService.SelectionChanged += OnSelectionChanged; + } + + if (_designerHost is not null) + { + _componentChangeService = _designerHost.GetService(); + } + + if (_componentChangeService is not null) + { + _componentChangeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); + } + + // Hook up the ControlAdded Event + _panel.ControlAdded += new ControlEventHandler(OnControlAdded); + _panel.ControlRemoved += new ControlEventHandler(OnControlRemoved); + } + + /// + /// We need to invalidate the glyphBounds when the glyphs are turned off. + /// + internal void InvalidateGlyph() + { + if (_containerSelectorGlyph is null) + { + return; + } + + BehaviorService.Invalidate(_containerSelectorGlyph.Bounds); + } + + /// + /// Required to CodeGen the Controls collection. + /// + private void OnControlAdded(object? sender, ControlEventArgs e) + { + if (e.Control is not ToolStrip || _panel is null) + { + return; + } + + // Change the padding which might have been set by the Behavior if the _panel is Expanded. + _panel.Padding = new Padding(0); + + if (_containerSelectorGlyph is not null) + { + _containerSelectorGlyph.IsExpanded = false; + } + + // Smoke the dock property whenever we add a toolstrip to a toolstrip _panel. + PropertyDescriptor? dockProp = TypeDescriptor.GetProperties(e.Control)["Dock"]; + dockProp?.SetValue(e.Control, DockStyle.None); + + RefreshSelection(); + } + + /// + /// Required to CodeGen the Controls collection. + /// + private void OnControlRemoved(object? sender, ControlEventArgs e) + { + if (_panel is not null && _panel.Controls.Count == 0) + { + if (_containerSelectorGlyph is not null) + { + _containerSelectorGlyph.IsExpanded = false; + } + + RefreshSelection(); + } + } + + private void RefreshSelection() + { + if (_designerHost is not null && !_designerHost.Loading) + { + SelectionManager selectionManager = GetService(); + selectionManager?.Refresh(); + } + } + + /// + /// Called when ContextMenu is invoked. + /// + protected override void OnContextMenu(int x, int y) + { + if (_panel is not null && _panel.Parent is ToolStripContainer) + { + DesignerContextMenu.Show(x, y); + } + else + { + base.OnContextMenu(x, y); + } + } + + private void OnSelectionChanging(object? sender, EventArgs e) + { + if (_designerShortCutCommand is null) + { + return; + } + + // Remove our DesignerShortCutHandler + IMenuCommandService menuCommandService = (IMenuCommandService)GetService(typeof(IMenuCommandService)); + if (menuCommandService is not null) + { + menuCommandService.RemoveCommand(_designerShortCutCommand); + if (_oldShortCutCommand is not null) + { + menuCommandService.AddCommand(_oldShortCutCommand); + } + } + + _designerShortCutCommand = null; + } + + private void OnSelectionChanged(object? sender, EventArgs e) + { + if (_selectionService?.PrimarySelection == _panel) + { + _designerShortCutCommand = new MenuCommand(OnKeyShowDesignerActions, MenuCommands.KeyInvokeSmartTag); + IMenuCommandService menuCommandService = (IMenuCommandService)GetService(typeof(IMenuCommandService)); + if (menuCommandService is not null) + { + _oldShortCutCommand = menuCommandService.FindCommand(MenuCommands.KeyInvokeSmartTag); + if (_oldShortCutCommand is not null) + { + menuCommandService.RemoveCommand(_oldShortCutCommand); + } + + menuCommandService.AddCommand(_designerShortCutCommand); + } + } + } + + /// + /// Paint the borders for the panels. + /// + protected override void OnPaintAdornments(PaintEventArgs paintEvent) + { + if (!ToolStripDesignerUtils.DisplayInformation.TerminalServer + && !ToolStripDesignerUtils.DisplayInformation.HighContrast + && !ToolStripDesignerUtils.DisplayInformation.LowResolution) + { + using (Brush brush = new SolidBrush(Color.FromArgb(50, Color.White))) + { + paintEvent.Graphics.FillRectangle(brush, _panel!.ClientRectangle); + } + } + + DrawBorder(paintEvent.Graphics); + } + + protected override void PreFilterEvents(IDictionary events) + { + base.PreFilterEvents(events); + EventDescriptor? eventDescriptor; + + if (_panel?.Parent is ToolStripContainer) + { + string[] noBrowseEvents = + [ + nameof(ToolStripPanel.AutoSizeChanged), + nameof(ToolStripPanel.BindingContextChanged), + nameof(ToolStripPanel.CausesValidationChanged), + nameof(ToolStripPanel.ChangeUICues), + nameof(ToolStripPanel.DockChanged), + nameof(ToolStripPanel.DragDrop), + nameof(ToolStripPanel.DragEnter), + nameof(ToolStripPanel.DragLeave), + nameof(ToolStripPanel.DragOver), + nameof(ToolStripPanel.EnabledChanged), + nameof(ToolStripPanel.FontChanged), + nameof(ToolStripPanel.ForeColorChanged), + nameof(ToolStripPanel.GiveFeedback), + nameof(ToolStripPanel.ImeModeChanged), + nameof(ToolStripPanel.KeyDown), + nameof(ToolStripPanel.KeyPress), + nameof(ToolStripPanel.KeyUp), + nameof(ToolStripPanel.LocationChanged), + nameof(ToolStripPanel.MarginChanged), + nameof(ToolStripPanel.MouseCaptureChanged), + nameof(ToolStripPanel.Move), + nameof(ToolStripPanel.QueryAccessibilityHelp), + nameof(ToolStripPanel.QueryContinueDrag), + nameof(ToolStripPanel.RegionChanged), + nameof(ToolStripPanel.Scroll), + nameof(ToolStripPanel.Validated), + nameof(ToolStripPanel.Validating) + ]; + + for (int i = 0; i < noBrowseEvents.Length; i++) + { + eventDescriptor = (EventDescriptor?)events[noBrowseEvents[i]]; + if (eventDescriptor is not null) + { + events[noBrowseEvents[i]] = TypeDescriptor.CreateEvent(eventDescriptor.ComponentType, eventDescriptor, BrowsableAttribute.No); + } + } + } + } + + /// + /// Set some properties to non-browsable depending on the Parent. (StandAlone ToolStripPanel should support properties that are usually hidden when its a part of ToolStripContainer) + /// + protected override void PreFilterProperties(IDictionary properties) + { + base.PreFilterProperties(properties); + PropertyDescriptor? propertyDescriptor; + + if (_panel?.Parent is ToolStripContainer) + { + properties.Remove("Modifiers"); + properties.Remove("Locked"); + properties.Remove("GenerateMember"); + + string[] noBrowseProps = + [ + nameof(ToolStripPanel.Anchor), + nameof(ToolStripPanel.AutoSize), + nameof(ToolStripPanel.Dock), + nameof(ToolStripPanel.DockPadding), + nameof(ToolStripPanel.Height), + nameof(ToolStripPanel.Location), + nameof(ToolStripPanel.Name), + nameof(ToolStripPanel.Orientation), + nameof(ToolStripPanel.Renderer), + nameof(ToolStripPanel.RowMargin), + nameof(ToolStripPanel.Size), + nameof(ToolStripPanel.Visible), + nameof(ToolStripPanel.Width), + ]; + + for (int i = 0; i < noBrowseProps.Length; i++) + { + propertyDescriptor = (PropertyDescriptor?)properties[noBrowseProps[i]]; + if (propertyDescriptor is not null) + { + properties[noBrowseProps[i]] = TypeDescriptor.CreateProperty(propertyDescriptor.ComponentType, propertyDescriptor, BrowsableAttribute.No, DesignerSerializationVisibilityAttribute.Hidden); + } + } + } + + string[] shadowProps = ["Padding", "Visible"]; + Attribute[] empty = []; + for (int i = 0; i < shadowProps.Length; i++) + { + propertyDescriptor = (PropertyDescriptor?)properties[shadowProps[i]]; + if (propertyDescriptor is not null) + { + properties[shadowProps[i]] = TypeDescriptor.CreateProperty(typeof(ToolStripPanelDesigner), propertyDescriptor, empty); + } + } + } + + /// + /// Should Serialize Padding + /// + private bool ShouldSerializePadding() + { + Padding padding = (Padding)ShadowProperties[nameof(Padding)]; + return !padding.Equals(s_defaultPadding); + } + + /// + /// Should serialize for visible property + /// + private bool ShouldSerializeVisible() + { + return !Visible; + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripTemplateNode.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripTemplateNode.cs index 9e7e3d6507f..b1fe0eb81cb 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripTemplateNode.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripTemplateNode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TrackBarDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TrackBarDesigner.cs new file mode 100644 index 00000000000..bdd00c8bb5e --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TrackBarDesigner.cs @@ -0,0 +1,46 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; + +namespace System.Windows.Forms.Design; + +internal class TrackBarDesigner : ControlDesigner +{ + public TrackBarDesigner() + { + AutoResizeHandles = true; + } + + public override SelectionRules SelectionRules + { + get + { + SelectionRules rules = base.SelectionRules; + rules |= SelectionRules.AllSizeable; + + if (GetPropertyValue(Component, nameof(TrackBar.AutoSize))) + { + var orientation = GetPropertyValue(Component, nameof(TrackBar.Orientation)) ?? Orientation.Horizontal; + + switch (orientation) + { + case Orientation.Horizontal: + rules &= ~(SelectionRules.TopSizeable | SelectionRules.BottomSizeable); + break; + case Orientation.Vertical: + rules &= ~(SelectionRules.LeftSizeable | SelectionRules.RightSizeable); + break; + } + } + + return rules; + } + } + + private static T? GetPropertyValue(object component, string propertyName) + { + PropertyDescriptor? prop = TypeDescriptor.GetProperties(component)[propertyName]; + return prop is null ? default : (T?)prop.GetValue(component); + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeViewActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeViewActionList.cs index a7d9a7f7d85..e5376c22868 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeViewActionList.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeViewActionList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; @@ -24,7 +23,7 @@ public void InvokeNodesDialog() EditorServiceContext.EditValue(_designer, Component, "Nodes"); } - public ImageList ImageList + public ImageList? ImageList { get { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeViewDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeViewDesigner.cs index 6352a6c85f4..e910a002640 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeViewDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeViewDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/UpDownBaseDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/UpDownBaseDesigner.cs index 483f46c7695..b5a4ea24101 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/UpDownBaseDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/UpDownBaseDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/UserControlDocumentDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/UserControlDocumentDesigner.cs index 5a38178c207..2dbdc0693c5 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/UserControlDocumentDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/UserControlDocumentDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/VsPropertyGrid.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/VsPropertyGrid.cs new file mode 100644 index 00000000000..4329fe77eb7 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/VsPropertyGrid.cs @@ -0,0 +1,77 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Drawing; + +namespace System.Windows.Forms.Design; + +internal class VsPropertyGrid : PropertyGrid +{ + private static readonly Size _ICON_SIZE = new(16, 16); + private static Size _iconSize = _ICON_SIZE; + private static bool _isScalingInitialized; + + public VsPropertyGrid(IServiceProvider serviceProvider) : base() + { + } + + protected override Bitmap SortByPropertyImage + { + get + { + return GetBitmap("PBAlpha"); + } + } + + protected override Bitmap SortByCategoryImage + { + get + { + return GetBitmap("PBCategory", true); + } + } + + protected override Bitmap ShowPropertyPageImage + { + get + { + return GetBitmap("PBPPage"); + } + } + + // try to find the best possible image + private static Bitmap GetBitmap(string resourceName, bool setMagentaTransparent = false) + { + Bitmap? bitmap = null; + // this resource might be present in System.Windows.Forms.VisualStudio.11.0.dll if this code is running on dev14 or newer + Stream stream = BitmapSelector.GetResourceStream(typeof(PropertyGrid), resourceName); + if (stream is not null) + { + if (!_isScalingInitialized) + { + if (DpiHelper.IsScalingRequired) + { + _iconSize = DpiHelper.LogicalToDeviceUnits(_ICON_SIZE); + } + + _isScalingInitialized = true; + } + + // retrieve icon closest to the desired size + Icon icon = new Icon(stream, _iconSize); + bitmap = icon.ToBitmap(); + icon.Dispose(); + } + else + { + // this resource must be present in System.Windows.Forms.dll if it is not available in System.Windows.Forms.VisualStudio.11.0.dll + bitmap = new Bitmap(BitmapSelector.GetResourceStream(typeof(PropertyGrid), resourceName + ".bmp")); + if (setMagentaTransparent) + { + bitmap.MakeTransparent(Color.Magenta); + } + } + + return bitmap; + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/WindowsFormsDesignerOptionService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/WindowsFormsDesignerOptionService.cs index e6f17628cdf..e1235a03126 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/WindowsFormsDesignerOptionService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/WindowsFormsDesignerOptionService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.cs.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.cs.xlf new file mode 100644 index 00000000000..faf0012c8e6 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.cs.xlf @@ -0,0 +1,67 @@ + + + + + + Add Column + Přidat sloupec + + + + &Add + &Přidat + + + + Cancel + Zrušit + + + + &Columns in the DataSource + &Sloupce v objektu DataSource + + + + Data&bound column + Sloupec &vázaný na data + + + + &Frozen + &Ukotvený + + + + &Header text: + Text &záhlaví: + + + + &Name: + &Název: + + + + &Read Only + &Jen pro čtení + + + + &Type: + &Typ: + + + + &Unbound column + &Nevázaný sloupec + + + + &Visible + &Viditelné + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.de.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.de.xlf new file mode 100644 index 00000000000..af8d0995852 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.de.xlf @@ -0,0 +1,67 @@ + + + + + + Add Column + Spalte hinzufügen + + + + &Add + &Hinzufügen + + + + Cancel + Abbrechen + + + + &Columns in the DataSource + &Spalten in der DataSource + + + + Data&bound column + Datengeb&undene Spalte + + + + &Frozen + &Fixiert + + + + &Header text: + &Headertext: + + + + &Name: + N&ame: + + + + &Read Only + S&chreibgeschützt + + + + &Type: + &Typ: + + + + &Unbound column + U&ngebundene Spalte + + + + &Visible + &Sichtbar + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.es.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.es.xlf new file mode 100644 index 00000000000..cf13604740c --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.es.xlf @@ -0,0 +1,67 @@ + + + + + + Add Column + Agregar columna + + + + &Add + &Agregar + + + + Cancel + Cancelar + + + + &Columns in the DataSource + &Columnas en DataSource + + + + Data&bound column + Columna de enlace de &datos + + + + &Frozen + &Inmovilizar + + + + &Header text: + Texto del &encabezado: + + + + &Name: + &Nombre: + + + + &Read Only + So&lo lectura + + + + &Type: + &Tipo: + + + + &Unbound column + &Columna sin enlazar + + + + &Visible + &Visible + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.fr.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.fr.xlf new file mode 100644 index 00000000000..4ef5bfe438c --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.fr.xlf @@ -0,0 +1,67 @@ + + + + + + Add Column + Ajouter une colonne + + + + &Add + &Ajouter + + + + Cancel + Annuler + + + + &Columns in the DataSource + &Colonnes du DataSource + + + + Data&bound column + Colonne &liée aux données + + + + &Frozen + &Figé + + + + &Header text: + Texte &de l'en-tête : + + + + &Name: + &Nom : + + + + &Read Only + &Lecture seule + + + + &Type: + T&ype : + + + + &Unbound column + Colonne &indépendante + + + + &Visible + &Visible + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.it.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.it.xlf new file mode 100644 index 00000000000..c00a7c669c0 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.it.xlf @@ -0,0 +1,67 @@ + + + + + + Add Column + Aggiungi colonna + + + + &Add + &Aggiungi + + + + Cancel + Annulla + + + + &Columns in the DataSource + &Colonne nel DataSource + + + + Data&bound column + Colonna a&ssociata ai dati + + + + &Frozen + &Bloccato + + + + &Header text: + Testo intesta&zione: + + + + &Name: + &Nome: + + + + &Read Only + &Sola lettura + + + + &Type: + &Tipo: + + + + &Unbound column + &Colonna non associata + + + + &Visible + &Visibile + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.ja.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.ja.xlf new file mode 100644 index 00000000000..60adc6e6b48 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.ja.xlf @@ -0,0 +1,67 @@ + + + + + + Add Column + 列を追加 + + + + &Add + 追加(&A) + + + + Cancel + キャンセル + + + + &Columns in the DataSource + DataSource の列(&C) + + + + Data&bound column + データバインド列(&B) + + + + &Frozen + 固定(&F) + + + + &Header text: + ヘッダー テキスト(&H): + + + + &Name: + 名前(&N): + + + + &Read Only + 読み取り専用(&R) + + + + &Type: + 型(&T): + + + + &Unbound column + 非バインド列(&U) + + + + &Visible + 表示(&V) + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.ko.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.ko.xlf new file mode 100644 index 00000000000..72a80ff09c6 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.ko.xlf @@ -0,0 +1,67 @@ + + + + + + Add Column + 열 추가 + + + + &Add + 추가(&A) + + + + Cancel + 취소 + + + + &Columns in the DataSource + DataSource의 열(&C) + + + + Data&bound column + 데이터 바인딩된 열(&B) + + + + &Frozen + 고정(&F) + + + + &Header text: + 머리글 텍스트(&H): + + + + &Name: + 이름(&N): + + + + &Read Only + 읽기 전용(&R) + + + + &Type: + 유형(&T): + + + + &Unbound column + 바인딩되지 않은 열(&U) + + + + &Visible + 표시(&V) + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.pl.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.pl.xlf new file mode 100644 index 00000000000..5ac5cf4985b --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.pl.xlf @@ -0,0 +1,67 @@ + + + + + + Add Column + Dodaj kolumnę + + + + &Add + &Dodaj + + + + Cancel + Anuluj + + + + &Columns in the DataSource + &Kolumny w elemencie DataSource + + + + Data&bound column + Ko&lumna związana z danymi + + + + &Frozen + &Zamrożony + + + + &Header text: + Tekst na&główka: + + + + &Name: + &Nazwa: + + + + &Read Only + Tylk&o do odczytu + + + + &Type: + &Typ: + + + + &Unbound column + Kol&umna niepowiązana + + + + &Visible + &Widoczny + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.pt-BR.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.pt-BR.xlf new file mode 100644 index 00000000000..9f5bbb9b57e --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.pt-BR.xlf @@ -0,0 +1,67 @@ + + + + + + Add Column + Adicionar Coluna + + + + &Add + &Adicionar + + + + Cancel + Cancelar + + + + &Columns in the DataSource + &Colunas em DataSource + + + + Data&bound column + Coluna de associação de &dados + + + + &Frozen + &Congelado + + + + &Header text: + &Texto do cabeçalho: + + + + &Name: + &Nome: + + + + &Read Only + &Somente Leitura + + + + &Type: + &Tipo: + + + + &Unbound column + &Coluna não associada + + + + &Visible + &Visível + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.ru.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.ru.xlf new file mode 100644 index 00000000000..347d04744ad --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.ru.xlf @@ -0,0 +1,67 @@ + + + + + + Add Column + Добавить столбец + + + + &Add + &Добавить + + + + Cancel + Отмена + + + + &Columns in the DataSource + &Столбцы в DataSource + + + + Data&bound column + &Столбец со связанными &данными + + + + &Frozen + &Заблокирован + + + + &Header text: + Текст &заголовка: + + + + &Name: + &Имя: + + + + &Read Only + &Только для чтения + + + + &Type: + &Тип: + + + + &Unbound column + &Непривязанный столбец + + + + &Visible + &Видимый + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.tr.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.tr.xlf new file mode 100644 index 00000000000..b0d381678ed --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.tr.xlf @@ -0,0 +1,67 @@ + + + + + + Add Column + Sütun Ekle + + + + &Add + &Ekle + + + + Cancel + İptal + + + + &Columns in the DataSource + &DataSource içindeki sütunlar + + + + Data&bound column + &Veri bağlama sütunu + + + + &Frozen + &Donduruldu + + + + &Header text: + Üst &bilgi metni: + + + + &Name: + &Ad: + + + + &Read Only + &Salt Okunur + + + + &Type: + &Tür: + + + + &Unbound column + İlişkisi&z sütun + + + + &Visible + Gö&rünür + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.zh-Hans.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.zh-Hans.xlf new file mode 100644 index 00000000000..08356e1228a --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.zh-Hans.xlf @@ -0,0 +1,67 @@ + + + + + + Add Column + 添加列 + + + + &Add + 添加(&A) + + + + Cancel + 取消 + + + + &Columns in the DataSource + DataSource 中的列(&C) + + + + Data&bound column + 数据绑定列(&B) + + + + &Frozen + 冻结(&F) + + + + &Header text: + 页眉文本(&H): + + + + &Name: + 名称(&N): + + + + &Read Only + 只读(&R) + + + + &Type: + 类型(&T): + + + + &Unbound column + 未绑定列(&U) + + + + &Visible + 可见(&V) + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.zh-Hant.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.zh-Hant.xlf new file mode 100644 index 00000000000..9cd1710c4cb --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewAddColumnDialog.zh-Hant.xlf @@ -0,0 +1,67 @@ + + + + + + Add Column + 新增資料行 + + + + &Add + 新增(&A) + + + + Cancel + 取消 + + + + &Columns in the DataSource + DataSource 中的資料行(&C) + + + + Data&bound column + 已繫結資料的資料行(&B) + + + + &Frozen + 凍結(&F) + + + + &Header text: + 標題文字(&H): + + + + &Name: + 名稱(&N): + + + + &Read Only + 唯讀(&R) + + + + &Type: + 類型(&T): + + + + &Unbound column + 未繫結的資料行(&U) + + + + &Visible + 可見(&V) + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.cs.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.cs.xlf new file mode 100644 index 00000000000..0da89d13c0d --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.cs.xlf @@ -0,0 +1,52 @@ + + + + + + Edit Columns + Upravit sloupce + + + + &Add... + &Přidat... + + + + Cancel + Zrušit + + + + &Remove + &Remove + + + + Move column down + Posunout sloupec dolů + + + + Move column up + Posunout sloupec nahoru + + + + OK + OK + + + + &Properties + &Properties + + + + Selected &Columns: + Vybrané &sloupce: + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.de.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.de.xlf new file mode 100644 index 00000000000..d4879ff57dc --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.de.xlf @@ -0,0 +1,52 @@ + + + + + + Edit Columns + Spalten bearbeiten + + + + &Add... + Hin&zufügen... + + + + Cancel + Abbrechen + + + + &Remove + &Remove + + + + Move column down + Spalte nach unten verschieben + + + + Move column up + Spalte nach oben verschieben + + + + OK + OK + + + + &Properties + &Properties + + + + Selected &Columns: + &Ausgewählte Spalten: + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.es.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.es.xlf new file mode 100644 index 00000000000..048ce467759 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.es.xlf @@ -0,0 +1,52 @@ + + + + + + Edit Columns + Editar columnas + + + + &Add... + &Agregar... + + + + Cancel + Cancelar + + + + &Remove + &Remove + + + + Move column down + Bajar columna + + + + Move column up + Subir columna + + + + OK + Aceptar + + + + &Properties + &Properties + + + + Selected &Columns: + Columnas &seleccionadas: + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.fr.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.fr.xlf new file mode 100644 index 00000000000..55f15e01aa5 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.fr.xlf @@ -0,0 +1,52 @@ + + + + + + Edit Columns + Modifier les colonnes + + + + &Add... + &Ajouter... + + + + Cancel + Annuler + + + + &Remove + &Remove + + + + Move column down + Déplacer la colonne vers le bas + + + + Move column up + Déplacer la colonne vers le haut + + + + OK + OK + + + + &Properties + &Properties + + + + Selected &Columns: + C&olonnes sélectionnées : + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.it.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.it.xlf new file mode 100644 index 00000000000..1510c910e24 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.it.xlf @@ -0,0 +1,52 @@ + + + + + + Edit Columns + Modifica le colonne + + + + &Add... + &Aggiungi... + + + + Cancel + Annulla + + + + &Remove + &Remove + + + + Move column down + Sposta colonna verso il basso + + + + Move column up + Sposta colonna verso l'alto + + + + OK + OK + + + + &Properties + &Properties + + + + Selected &Columns: + &Colonne selezionate: + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.ja.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.ja.xlf new file mode 100644 index 00000000000..c89e33ea9d9 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.ja.xlf @@ -0,0 +1,52 @@ + + + + + + Edit Columns + 列の編集 + + + + &Add... + 追加(&A)... + + + + Cancel + キャンセル + + + + &Remove + &Remove + + + + Move column down + 列を下に移動 + + + + Move column up + 列を上に移動 + + + + OK + OK + + + + &Properties + &Properties + + + + Selected &Columns: + 選択された列(&C): + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.ko.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.ko.xlf new file mode 100644 index 00000000000..70d80eeb5c7 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.ko.xlf @@ -0,0 +1,52 @@ + + + + + + Edit Columns + 열 편집 + + + + &Add... + 추가(&A)... + + + + Cancel + 취소 + + + + &Remove + &Remove + + + + Move column down + 아래로 열 이동 + + + + Move column up + 위로 열 이동 + + + + OK + 확인 + + + + &Properties + &Properties + + + + Selected &Columns: + 선택한 열(&C): + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.pl.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.pl.xlf new file mode 100644 index 00000000000..2d85ee7c264 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.pl.xlf @@ -0,0 +1,52 @@ + + + + + + Edit Columns + Edytuj kolumny + + + + &Add... + &Dodaj... + + + + Cancel + Anuluj + + + + &Remove + &Remove + + + + Move column down + Przenieś kolumnę w dół + + + + Move column up + Przenieś kolumnę w górę + + + + OK + OK + + + + &Properties + &Properties + + + + Selected &Columns: + Wybrane &Kolumny: + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.pt-BR.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.pt-BR.xlf new file mode 100644 index 00000000000..a898c80d2b5 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.pt-BR.xlf @@ -0,0 +1,52 @@ + + + + + + Edit Columns + Editar as Colunas + + + + &Add... + &Adicionar... + + + + Cancel + Cancel + + + + &Remove + &Remove + + + + Move column down + Mover coluna para baixo + + + + Move column up + Mover coluna para cima + + + + OK + OK + + + + &Properties + &Properties + + + + Selected &Columns: + &Colunas Selecionadas: + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.ru.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.ru.xlf new file mode 100644 index 00000000000..e3a1913c3bd --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.ru.xlf @@ -0,0 +1,52 @@ + + + + + + Edit Columns + Изменить столбцы + + + + &Add... + &Добавить… + + + + Cancel + Отмена + + + + &Remove + &Remove + + + + Move column down + Переместить столбец вниз + + + + Move column up + Переместить столбец вверх + + + + OK + ОК + + + + &Properties + &Properties + + + + Selected &Columns: + Выбранные &столбцы: + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.tr.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.tr.xlf new file mode 100644 index 00000000000..f23ff461d4f --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.tr.xlf @@ -0,0 +1,52 @@ + + + + + + Edit Columns + Sütunları Düzenle + + + + &Add... + &Ekle... + + + + Cancel + İptal + + + + &Remove + &Remove + + + + Move column down + Sütunu aşağı taşı + + + + Move column up + Sütunu yukarı taşı + + + + OK + Tamam + + + + &Properties + &Properties + + + + Selected &Columns: + &Seçili Sütunlar: + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.zh-Hans.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.zh-Hans.xlf new file mode 100644 index 00000000000..5675caec7ac --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.zh-Hans.xlf @@ -0,0 +1,52 @@ + + + + + + Edit Columns + 编辑列 + + + + &Add... + 添加(&A)... + + + + Cancel + 取消 + + + + &Remove + &Remove + + + + Move column down + 下移列 + + + + Move column up + 上移列 + + + + OK + 确定 + + + + &Properties + &Properties + + + + Selected &Columns: + 选择的列(&C): + + + + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.zh-Hant.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.zh-Hant.xlf new file mode 100644 index 00000000000..9bb2c4d620d --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/DataGridViewColumnCollectionDialog.zh-Hant.xlf @@ -0,0 +1,52 @@ + + + + + + Edit Columns + 編輯資料行 + + + + &Add... + 新增(&A)... + + + + Cancel + 取消 + + + + &Remove + &Remove + + + + Move column down + 將資料行下移 + + + + Move column up + 將資料行上移 + + + + OK + 確定 + + + + &Properties + &Properties + + + + Selected &Columns: + 選取的資料行(&C): + + + + + diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/BinaryEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/BinaryEditorTests.cs new file mode 100644 index 00000000000..f34461c5a53 --- /dev/null +++ b/src/System.Windows.Forms.Design/tests/UnitTests/BinaryEditorTests.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel.Design; +using Moq; + +namespace System.Windows.Forms.Design.Editors.Tests; + +public class BinaryEditorTests +{ + [WinFormsFact] + public void BinaryEditor_EditValue() + { + // Ensure that we can instantiate the modal editor. + + BinaryEditor editor = new(); + var editorService = new Mock(); + editorService.Setup(e => e.ShowDialog(It.IsAny
())) + .Callback(f => { f.Show(); f.Close(); }) + .Returns(DialogResult.OK); + var serviceProvider = new Mock(); + serviceProvider.Setup(s => s.GetService(typeof(IWindowsFormsEditorService))).Returns(editorService.Object); + + var result = editor.EditValue(serviceProvider.Object, new byte[10]); + } +} diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/CodeDomHelpers.cs b/src/System.Windows.Forms.Design/tests/UnitTests/CodeDomHelpers.cs index 2305b04c86b..93ed7c7938f 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/CodeDomHelpers.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/CodeDomHelpers.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/ControlDesignerTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/ControlDesignerTests.cs index c39ba845223..4b591e25770 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/ControlDesignerTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/ControlDesignerTests.cs @@ -1,7 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. +using System.ComponentModel.Design; +using System.Windows.Forms.Design.Tests.Mocks; +using Moq; using Windows.Win32; namespace System.Windows.Forms.Design.Tests; @@ -195,4 +197,47 @@ public void ControlDesigner_WndProc_InvokePaint_Success() }; designer.TestAccessor().Dynamic.WndProc(ref m); } + + [Fact] + public void ControlDesigner_AssociatedComponents_NullSite_Test() + { + using ControlDesigner controlDesigner = new(); + using Control control = new(); + + using Control childControl = new(); + controlDesigner.Initialize(control); + + Assert.Empty(controlDesigner.AssociatedComponents); + + control.Controls.Add(childControl); + + Assert.Empty(controlDesigner.AssociatedComponents); + } + + [WinFormsFact] + public void ControlDesigner_AssociatedComponentsTest() + { + using Control control = new(); + using ControlDesigner controlDesigner = new(); + + Mock mockDesignerHost = new(MockBehavior.Strict); + mockDesignerHost + .Setup(h => h.RootComponent) + .Returns(control); + mockDesignerHost + .Setup(s => s.GetDesigner(It.IsAny())) + .Returns(() => null); + var mockSite = MockSite.CreateMockSiteWithDesignerHost(mockDesignerHost.Object); + control.Site = mockSite.Object; + + controlDesigner.Initialize(control); + + Assert.Empty(controlDesigner.AssociatedComponents); + + using Control childControl = new(); + childControl.Site = mockSite.Object; + control.Controls.Add(childControl); + + Assert.Equal(1, controlDesigner.AssociatedComponents.Count); + } } diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/EnsureDesignerTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/EnsureDesignerTests.cs index 3e21386cf42..2ee6b726208 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/EnsureDesignerTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/EnsureDesignerTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/EnsureEditorsTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/EnsureEditorsTests.cs index 9f83337cbd1..4b8b4f50823 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/EnsureEditorsTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/EnsureEditorsTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/GlobalUsings.cs b/src/System.Windows.Forms.Design/tests/UnitTests/GlobalUsings.cs index 6561f274c5f..12febf7aa93 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/GlobalUsings.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/GlobalUsings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. global using System.Windows.Forms; global using Xunit; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/ListViewDesignerTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/ListViewDesignerTests.cs new file mode 100644 index 00000000000..5a3aa0deef3 --- /dev/null +++ b/src/System.Windows.Forms.Design/tests/UnitTests/ListViewDesignerTests.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Windows.Forms.Design.Tests; + +public class ListViewDesignerTests +{ + [WinFormsFact] + public void ListViewDesigner_AssociatedComponentsTest() + { + using ListViewDesigner listViewDesigner = new(); + using ListView listView = new(); + listViewDesigner.Initialize(listView); + + Assert.Empty(listViewDesigner.AssociatedComponents); + + listView.Columns.Add("123"); + listView.Columns.Add("abc"); + + Assert.Equal(2, listViewDesigner.AssociatedComponents.Count); + } +} diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/Mocks/MockSite.cs b/src/System.Windows.Forms.Design/tests/UnitTests/Mocks/MockSite.cs new file mode 100644 index 00000000000..c995c284322 --- /dev/null +++ b/src/System.Windows.Forms.Design/tests/UnitTests/Mocks/MockSite.cs @@ -0,0 +1,67 @@ +using System.ComponentModel.Design; +using System.ComponentModel; +using Moq; + +namespace System.Windows.Forms.Design.Tests.Mocks +{ + public class MockSite + { + public static Mock CreateMockSiteWithDesignerHost(object designerHost) + { + Mock mockSite = new(MockBehavior.Strict); + mockSite + .Setup(s => s.GetService(typeof(IDesignerHost))) + .Returns(designerHost); + mockSite + .Setup(s => s.GetService(typeof(IInheritanceService))) + .Returns(null); + mockSite + .Setup(s => s.GetService(typeof(IDictionaryService))) + .Returns(null); + mockSite + .Setup(s => s.GetService(typeof(IExtenderListService))) + .Returns(null); + mockSite + .Setup(s => s.GetService(typeof(ITypeDescriptorFilterService))) + .Returns(null); + mockSite + .Setup(s => s.GetService(typeof(AmbientProperties))) + .Returns(null); + mockSite + .Setup(s => s.GetService(typeof(DesignerActionService))) + .Returns(null); + mockSite + .Setup(s => s.GetService(typeof(IComponentChangeService))) + .Returns(null); + mockSite + .Setup(s => s.GetService(typeof(ToolStripKeyboardHandlingService))) + .Returns(null); + mockSite + .Setup(s => s.GetService(typeof(ISupportInSituService))) + .Returns(null); + mockSite + .Setup(s => s.GetService(typeof(INestedContainer))) + .Returns(null); + + Mock mockSelectionService = new(MockBehavior.Strict); + + mockSite + .Setup(s => s.GetService(typeof(ISelectionService))) + .Returns(mockSelectionService.Object); + mockSite + .Setup(s => s.Container) + .Returns((IContainer)null); + mockSite + .Setup(s => s.Name) + .Returns("Site"); + mockSite + .Setup(s => s.DesignMode) + .Returns(true); + mockSite + .Setup(s => s.GetService(typeof(UndoEngine))) + .Returns(null); + + return mockSite; + } + } +} diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/SerializableAttributeTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/SerializableAttributeTests.cs index 3c9242d97b9..c9bef24c0c8 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/SerializableAttributeTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/SerializableAttributeTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design.Tests.Serialization; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/CodeDomSerializerTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/CodeDomSerializerTests.cs index b60d4355e9f..bc74b9c8b43 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/CodeDomSerializerTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/CodeDomSerializerTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/CollectionCodeDomSerializerTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/CollectionCodeDomSerializerTests.cs index 8fea1c0c772..462e562f7b6 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/CollectionCodeDomSerializerTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/CollectionCodeDomSerializerTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/PrimitiveCodeDomSerializerTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/PrimitiveCodeDomSerializerTests.cs index 94d46ff3ddb..7638edaf1ed 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/PrimitiveCodeDomSerializerTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/PrimitiveCodeDomSerializerTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/TypeCodeDomSerializerTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/TypeCodeDomSerializerTests.cs index e78d707cdd5..6cd6b565d6d 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/TypeCodeDomSerializerTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/Serialization/TypeCodeDomSerializerTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Moq; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/SplitContainerDesignerTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/SplitContainerDesignerTests.cs new file mode 100644 index 00000000000..c14736ffddd --- /dev/null +++ b/src/System.Windows.Forms.Design/tests/UnitTests/SplitContainerDesignerTests.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel.Design; +using Moq; +using System.Windows.Forms.Design.Tests.Mocks; + +namespace System.Windows.Forms.Design.Tests; + +public class SplitContainerDesignerTests +{ + [WinFormsFact] + public void SplitContainerDesigner_AssociatedComponentsTest() + { + using SplitContainer splitContainer = new(); + using SplitContainerDesigner splitContainerDesigner = new(); + + Mock mockDesignerHost = new(MockBehavior.Strict); + mockDesignerHost + .Setup(h => h.RootComponent) + .Returns(splitContainer); + mockDesignerHost + .Setup(s => s.GetDesigner(It.IsAny())) + .Returns(splitContainerDesigner); + Mock mockComponentChangeService = new(MockBehavior.Strict); + mockDesignerHost + .Setup(s => s.GetService(typeof(IComponentChangeService))) + .Returns(mockComponentChangeService.Object); + + var mockSite = MockSite.CreateMockSiteWithDesignerHost(mockDesignerHost.Object); + splitContainer.Site = mockSite.Object; + + splitContainerDesigner.Initialize(splitContainer); + + Assert.Empty(splitContainerDesigner.AssociatedComponents); + + using Control control = new(); + control.Parent = splitContainer.Panel1; + + Assert.Equal(1, splitContainerDesigner.AssociatedComponents.Count); + } +} diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ArrayEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ArrayEditorTests.cs index b96469556a6..a7028015085 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ArrayEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ArrayEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Drawing.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ByteViewerTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ByteViewerTests.cs index cead8ce6adb..34499ca652e 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ByteViewerTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ByteViewerTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.TestUtilities; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionEditorTests.cs index b6fdc925d59..6cadb7e8fd8 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Drawing.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionFormTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionFormTests.cs index 7a7daab4ffb..bc8b6ca320a 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionFormTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionFormTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.Design; using Moq; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ComponentDesignerTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ComponentDesignerTests.cs index e6a99817dfb..dbf1d4bafdc 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ComponentDesignerTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ComponentDesignerTests.cs @@ -1,12 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Configuration; using Moq; using Moq.Protected; using System.Windows.Forms.TestUtilities; +using System.Windows.Forms.Design.Tests.Mocks; namespace System.ComponentModel.Design.Tests; @@ -56,7 +56,7 @@ public void ComponentDesigner_GetService_ReturnsExpected() mockDesignerHost .Setup(h => h.RootComponent) .Returns(component); - var mockSite = CreateMockSiteWithDesignerHost(mockDesignerHost.Object); + var mockSite = MockSite.CreateMockSiteWithDesignerHost(mockDesignerHost.Object); component.Site = mockSite.Object; designer.Initialize(component); @@ -83,7 +83,7 @@ public void ComponentDesigner_PostFilterProperties_Success() mockDesignerHost .Setup(h => h.RootComponent) .Returns(component); - var mockSite = CreateMockSiteWithDesignerHost(mockDesignerHost.Object); + var mockSite = MockSite.CreateMockSiteWithDesignerHost(mockDesignerHost.Object); component.Site = mockSite.Object; designer.Initialize(component); @@ -92,34 +92,6 @@ public void ComponentDesigner_PostFilterProperties_Success() Assert.NotSame(descriptor, result); } - private static Mock CreateMockSiteWithDesignerHost(object designerHost) - { - Mock mockSite = new(MockBehavior.Strict); - mockSite - .Setup(s => s.GetService(typeof(IDesignerHost))) - .Returns(designerHost); - mockSite - .Setup(s => s.GetService(typeof(IComponentChangeService))) - .Returns(null); - mockSite - .Setup(s => s.GetService(typeof(IInheritanceService))) - .Returns(null); - mockSite - .Setup(s => s.GetService(typeof(IDictionaryService))) - .Returns(null); - mockSite - .Setup(s => s.GetService(typeof(IExtenderListService))) - .Returns(null); - mockSite - .Setup(s => s.GetService(typeof(ITypeDescriptorFilterService))) - .Returns(null); - mockSite - .SetupGet(s => s.Container) - .Returns((IContainer)null); - - return mockSite; - } - [Fact] public void ComponentDesigner_Children_GetWithValidHostValidResult_ReturnsExpected() { @@ -145,7 +117,7 @@ public void ComponentDesigner_Children_GetWithValidHostValidResult_ReturnsExpect using Component component = new() { - Site = CreateMockSiteWithDesignerHost(mockDesignerHost.Object).Object + Site = MockSite.CreateMockSiteWithDesignerHost(mockDesignerHost.Object).Object }; designer.Initialize(component); @@ -183,7 +155,7 @@ public void ComponentDesigner_Children_GetWithValidHostInvalidResult_ReturnsExpe using Component component = new() { - Site = CreateMockSiteWithDesignerHost(mockDesignerHost.Object).Object + Site = MockSite.CreateMockSiteWithDesignerHost(mockDesignerHost.Object).Object }; designer.Initialize(component); @@ -215,7 +187,7 @@ public void ComponentDesigner_Children_GetWithInvalidDesignerHost_ReturnsEmpty(I using Component component = new() { - Site = CreateMockSiteWithDesignerHost(host).Object + Site = MockSite.CreateMockSiteWithDesignerHost(host).Object }; designer.Initialize(component); @@ -337,7 +309,7 @@ public void ComponentDesigner_ParentComponent_GetWithValidService_ReturnsExpecte mockDesignerHost .Setup(h => h.RootComponent) .Returns(rootComponent); - var mockSite = CreateMockSiteWithDesignerHost(mockDesignerHost.Object); + var mockSite = MockSite.CreateMockSiteWithDesignerHost(mockDesignerHost.Object); using Component component = new() { @@ -367,7 +339,7 @@ public void ComponentDesigner_ParentComponent_GetWithValidServiceRootComponentEq mockDesignerHost .Setup(h => h.RootComponent) .Returns(component); - var mockSite = CreateMockSiteWithDesignerHost(mockDesignerHost.Object); + var mockSite = MockSite.CreateMockSiteWithDesignerHost(mockDesignerHost.Object); component.Site = mockSite.Object; designer.Initialize(component); mockSite.Verify(s => s.GetService(typeof(IDesignerHost)), Times.Once()); @@ -394,7 +366,7 @@ public static IEnumerable ParentComponent_InvalidService_TestData() public void ComponentDesigner_ParentComponent_GetWithInvalidService_ReturnsNull(object host) { using SubComponentDesigner designer = new(); - var mockSite = CreateMockSiteWithDesignerHost(host); + var mockSite = MockSite.CreateMockSiteWithDesignerHost(host); using Component component = new() { @@ -426,7 +398,7 @@ public void ComponentDesigner_ITreeDesignerParent_GetWithValidService_ReturnsExp .Setup(h => h.GetDesigner(rootComponent)) .Returns(designer) .Verifiable(); - var mockSite = CreateMockSiteWithDesignerHost(mockDesignerHost.Object); + var mockSite = MockSite.CreateMockSiteWithDesignerHost(mockDesignerHost.Object); using Component component = new() { @@ -460,7 +432,7 @@ public void ComponentDesigner_ITreeDesignerParent_GetWithValidServiceRootCompone mockDesignerHost .Setup(h => h.RootComponent) .Returns(component); - var mockSite = CreateMockSiteWithDesignerHost(mockDesignerHost.Object); + var mockSite = MockSite.CreateMockSiteWithDesignerHost(mockDesignerHost.Object); component.Site = mockSite.Object; designer.Initialize(component); mockSite.Verify(s => s.GetService(typeof(IDesignerHost)), Times.Once()); @@ -482,7 +454,7 @@ public void ComponentDesigner_ITreeDesignerParent_GetWithInvalidServiceFirstCall { using SubComponentDesigner designer = new(); ITreeDesigner treeDesigner = designer; - var mockSite = CreateMockSiteWithDesignerHost(host); + var mockSite = MockSite.CreateMockSiteWithDesignerHost(host); using Component component = new() { diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignSurfaceTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignSurfaceTests.cs index f0ba4cc1ecd..5109bcfb2a9 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignSurfaceTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignSurfaceTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design.Serialization; using System.Reflection; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionHeaderItemTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionHeaderItemTests.cs index 8dfc24937f0..235ab214a8b 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionHeaderItemTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionHeaderItemTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionItemCollectionTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionItemCollectionTests.cs index 100e4f64347..d7b0207cabb 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionItemCollectionTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionItemCollectionTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design.Tests; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionItemTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionItemTests.cs index d6379cb022d..59ddc25aa8d 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionItemTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionItemTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionListCollectionTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionListCollectionTests.cs index 703365f1895..86051c4b169 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionListCollectionTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionListCollectionTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design.Tests; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionListTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionListTests.cs index edda8101f9b..3bc45ebbb20 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionListTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionListTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using Moq; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionListsChangedEventArgsTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionListsChangedEventArgsTests.cs index cdd793e4432..8552fd326e4 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionListsChangedEventArgsTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionListsChangedEventArgsTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design.Tests; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionMethodItemTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionMethodItemTests.cs index 543bdc75be6..c8f934527bf 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionMethodItemTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionMethodItemTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.Reflection; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionPropertyItemTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionPropertyItemTests.cs index 15058844077..e2ae8200248 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionPropertyItemTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionPropertyItemTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionServiceTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionServiceTests.cs index 532016297fe..b925d15d202 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionServiceTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionServiceTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Collections.Specialized; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionTextItemTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionTextItemTests.cs index 4af2afe306e..3067851f318 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionTextItemTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionTextItemTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionUIStateChangeEventArgsTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionUIStateChangeEventArgsTests.cs index 0babfab13e1..b86c5e824c1 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionUIStateChangeEventArgsTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerActionUIStateChangeEventArgsTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design.Tests; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerCommandSetTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerCommandSetTests.cs index d83d49fd8cb..e5c158c268b 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerCommandSetTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerCommandSetTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Moq; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerHostTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerHostTests.cs index eb5bf62537f..3f3796e49ee 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerHostTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerHostTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel.Design.Serialization; @@ -1727,7 +1726,7 @@ public void DesignerHost_AddService_InvokeObject_GetServiceReturnsExpected() SubDesignSurface surface = new(); IDesignerLoaderHost2 host = surface.Host; - object service = new object(); + object service = new(); host.AddService(typeof(object), service); Assert.Same(service, surface.ServiceContainer.GetService(typeof(object))); Assert.Same(service, surface.GetService(typeof(object))); @@ -1741,7 +1740,7 @@ public void DesignerHost_AddService_InvokeObjectBool_GetServiceReturnsExpected(b SubDesignSurface surface = new(); IDesignerLoaderHost2 host = surface.Host; - object service = new object(); + object service = new(); host.AddService(typeof(object), service, promote); Assert.Same(service, surface.ServiceContainer.GetService(typeof(object))); Assert.Same(service, surface.GetService(typeof(object))); @@ -1754,7 +1753,7 @@ public void DesignerHost_AddService_InvokeCallback_GetServiceReturnsExpected() SubDesignSurface surface = new(); IDesignerLoaderHost2 host = surface.Host; - object service = new object(); + object service = new(); ServiceCreatorCallback callback = (container, serviceType) => service; host.AddService(typeof(object), callback); Assert.Same(service, surface.ServiceContainer.GetService(typeof(object))); @@ -1769,7 +1768,7 @@ public void DesignerHost_AddService_InvokeObjectCallback_GetServiceReturnsExpect SubDesignSurface surface = new(); IDesignerLoaderHost2 host = surface.Host; - object service = new object(); + object service = new(); ServiceCreatorCallback callback = (container, serviceType) => service; host.AddService(typeof(object), callback, promote); Assert.Same(service, surface.ServiceContainer.GetService(typeof(object))); diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerVerbCollectionTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerVerbCollectionTests.cs index a60b79f0385..763fee93188 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerVerbCollectionTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerVerbCollectionTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design.Tests; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ExceptionCollectionTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ExceptionCollectionTests.cs index dcbaba5a4c0..8087bf4a2c0 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ExceptionCollectionTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ExceptionCollectionTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Runtime.Serialization; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ExtenderProviderServiceTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ExtenderProviderServiceTests.cs index aec185a24cc..70a84a3e53c 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ExtenderProviderServiceTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ExtenderProviderServiceTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Moq; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/InheritanceServiceTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/InheritanceServiceTests.cs index afafb2334c6..eb424834bb4 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/InheritanceServiceTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/InheritanceServiceTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design.Tests; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/LoadedEventArgsTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/LoadedEventArgsTests.cs index bb9f046253e..d3799e4a0f2 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/LoadedEventArgsTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/LoadedEventArgsTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/MultilineStringEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/MultilineStringEditorTests.cs index cfc952595ca..debdb00f925 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/MultilineStringEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/MultilineStringEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing.Design; using System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ObjectSelectorEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ObjectSelectorEditorTests.cs index c4a21b2622f..bd26eb592bf 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ObjectSelectorEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ObjectSelectorEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing.Design; using System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ProjectTargetFrameworkAttributeTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ProjectTargetFrameworkAttributeTests.cs index f203263da4f..1a46eefee9c 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ProjectTargetFrameworkAttributeTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ProjectTargetFrameworkAttributeTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design.Tests; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationServiceTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationServiceTests.cs index edd89d4f44b..da0bcaac799 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationServiceTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationServiceTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; using System.Collections; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/CodeDomSerializerExceptionTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/CodeDomSerializerExceptionTests.cs index 0a081ff45cb..e4e6626aee5 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/CodeDomSerializerExceptionTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/CodeDomSerializerExceptionTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/DesignerSerializationManagerTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/DesignerSerializationManagerTests.cs index 7d2b1ec0e62..c09b7daa39b 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/DesignerSerializationManagerTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/DesignerSerializationManagerTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using Moq; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/ExpressionContextTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/ExpressionContextTests.cs index edb1a993651..483b73a0fd1 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/ExpressionContextTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/ExpressionContextTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/RootContextTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/RootContextTests.cs index 068deab2c9b..d5f8c6d6ba0 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/RootContextTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/RootContextTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/SerializeAbsoluteContextTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/SerializeAbsoluteContextTests.cs index a38813d1c90..ac3906a8810 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/SerializeAbsoluteContextTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/SerializeAbsoluteContextTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design.Serialization.Tests; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/StatementContextTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/StatementContextTests.cs index 914558e4b6c..1532efa41bd 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/StatementContextTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/Serialization/StatementContextTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design.Serialization.Tests; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/SiteNestedContainerTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/SiteNestedContainerTests.cs index a355ead0d21..2933ad5579f 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/SiteNestedContainerTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/SiteNestedContainerTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design.Serialization; using Moq; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/UndoUnitTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/UndoUnitTests.cs index 27b177f8ca1..265167f5e66 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/UndoUnitTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/UndoUnitTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design.Serialization; using Moq; @@ -26,7 +25,7 @@ private static IServiceProvider GetServiceProvider() .Returns(mockComponentChangeService.Object); mockServiceProvider .Setup(p => p.GetService(typeof(ComponentSerializationService))) - .Returns(new object()); + .Returns(new CodeDomComponentSerializationService()); return mockServiceProvider.Object; } diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/BitmapEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/BitmapEditorTests.cs index 6b0b17f7822..dd819a953fe 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/BitmapEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/BitmapEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Imaging; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ColorEditorTests.CustomColorDialogTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ColorEditorTests.CustomColorDialogTests.cs index 0d0c2b16691..e69749a9026 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ColorEditorTests.CustomColorDialogTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ColorEditorTests.CustomColorDialogTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ColorEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ColorEditorTests.cs index e8b1381f076..71463510fb4 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ColorEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ColorEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/CursorEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/CursorEditorTests.cs index a66f7b07844..58a0dc5889e 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/CursorEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/CursorEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/FontEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/FontEditorTests.cs index 0826ed5dbd6..91ff0614af6 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/FontEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/FontEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Windows.Forms.TestUtilities; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/FontNameEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/FontNameEditorTests.cs index 28c9397db17..e1b0c39bc89 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/FontNameEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/FontNameEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ImageEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ImageEditorTests.cs index 9cbb496d685..8e751661d38 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ImageEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ImageEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Imaging; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/MetafileEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/MetafileEditorTests.cs index b791a70423d..3b27a0d62f2 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/MetafileEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/MetafileEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Imaging; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxComponentsCreatedEventArgsTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxComponentsCreatedEventArgsTests.cs index 3cdf3da8c79..4d88a90973a 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxComponentsCreatedEventArgsTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxComponentsCreatedEventArgsTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxComponentsCreatingEventArgsTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxComponentsCreatingEventArgsTests.cs index 6d37eafae2f..c58789f3fb6 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxComponentsCreatingEventArgsTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxComponentsCreatingEventArgsTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; using Moq; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxItemCollectionTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxItemCollectionTests.cs index fbf9089a687..c55d2da638d 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxItemCollectionTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxItemCollectionTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Drawing.Design.Tests; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxItemTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxItemTests.cs index bb29076faf1..6a1464424c9 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxItemTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/ToolboxItemTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Resources/Tools/CodeDomCompileHelper.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Resources/Tools/CodeDomCompileHelper.cs index 53df1d8d31f..9e2cbc50096 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Resources/Tools/CodeDomCompileHelper.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Resources/Tools/CodeDomCompileHelper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom.Compiler; using Microsoft.CodeAnalysis; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Resources/Tools/StronglyTypedResourceBuilderTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Resources/Tools/StronglyTypedResourceBuilderTests.cs index 9e3c7343da4..431e4f4a964 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Resources/Tools/StronglyTypedResourceBuilderTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Resources/Tools/StronglyTypedResourceBuilderTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.CodeDom; using System.CodeDom.Compiler; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/AnchorEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/AnchorEditorTests.cs index 49b77bde2e5..01182921e0e 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/AnchorEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/AnchorEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; @@ -76,16 +75,15 @@ public void AnchorEditor_GetPaintValueSupported_Invoke_ReturnsFalse(ITypeDescrip } [Theory] - [InlineData("left")] - [InlineData("right")] - [InlineData("top")] - [InlineData("bottom")] + [InlineData("_left")] + [InlineData("_right")] + [InlineData("_top")] + [InlineData("_bottom")] public void AnchorEditor_AnchorUI_ControlType_IsCheckButton(string fieldName) { - AnchorEditor editor = new(); - Type type = editor.GetType() + Type type = typeof(AnchorEditor) .GetNestedType("AnchorUI", BindingFlags.NonPublic | BindingFlags.Instance); - var anchorUI = (Control)Activator.CreateInstance(type, new object[] { editor }); + var anchorUI = (Control)Activator.CreateInstance(type); var item = (Control)anchorUI.GetType() .GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance).GetValue(anchorUI); diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventArgsTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventArgsTests.cs index c1d7f7a316b..7f0732ab4ac 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventArgsTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/Behavior/BehaviorDragDropEventArgsTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/Behavior/SnapLineTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/Behavior/SnapLineTests.cs index f8080de1c98..ba8e02577fa 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/Behavior/SnapLineTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/Behavior/SnapLineTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design.Behavior.Tests; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/BorderSidesEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/BorderSidesEditorTests.cs index a17a2dae1df..42579768c40 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/BorderSidesEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/BorderSidesEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ColumnHeaderCollectionEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ColumnHeaderCollectionEditorTests.cs index 8c7578d1387..a84da13d0ab 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ColumnHeaderCollectionEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ColumnHeaderCollectionEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design.Tests; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ContentAlignmentEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ContentAlignmentEditorTests.cs index cdc7235b118..0010ebdc11f 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ContentAlignmentEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ContentAlignmentEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing.Design; using System.Reflection; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DataGridViewCellStyleEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DataGridViewCellStyleEditorTests.cs index ff08385e944..bab5774d6ad 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DataGridViewCellStyleEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DataGridViewCellStyleEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DataMemberFieldConverterTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DataMemberFieldConverterTests.cs index 6df25f049d4..67797a29721 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DataMemberFieldConverterTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DataMemberFieldConverterTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; @@ -10,7 +9,7 @@ namespace System.Windows.Forms.Design.Tests; public class DataMemberFieldConverterTests { - private static DataMemberFieldConverter s_converter = new DataMemberFieldConverter(); + private static DataMemberFieldConverter s_converter = new(); private static ITypeDescriptorContext s_context = new MyTypeDescriptorContext(); [Fact] diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerOptionsTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerOptionsTests.cs index edf069f6241..78abd8cce0f 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerOptionsTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DesignerOptionsTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DockEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DockEditorTests.cs index 644cb4b87a4..36a2c08d584 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DockEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DockEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EmbeddedResourceTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EmbeddedResourceTests.cs index b550788e09b..e158a6564de 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EmbeddedResourceTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EmbeddedResourceTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Reflection; @@ -25,6 +24,7 @@ public class EmbeddedResourceTests System.Windows.Forms.Design.256_1 System.Windows.Forms.Design.256_2 System.Windows.Forms.Design.AddNewDataSource + System.Windows.Forms.Design.AddNewDataSource.bmp System.Windows.Forms.Design.Behavior.bottomclose System.Windows.Forms.Design.Behavior.bottomopen System.Windows.Forms.Design.Behavior.Close_left @@ -48,7 +48,9 @@ public class EmbeddedResourceTests System.Windows.Forms.Design.DataGridViewColumnsDialog.moveDown System.Windows.Forms.Design.DataGridViewColumnsDialog.moveUp System.Windows.Forms.Design.DataGridViewColumnsDialog.selectedColumns + System.Windows.Forms.Design.DataGridViewColumnsDialog.selectedColumns.bmp System.Windows.Forms.Design.DataPickerImages + System.Windows.Forms.Design.DataPickerImages.bmp System.Windows.Forms.Design.default System.Windows.Forms.Design.Delete System.Windows.Forms.Design.DummyNodeImage @@ -62,8 +64,26 @@ public class EmbeddedResourceTests System.Windows.Forms.Design.UserControlToolboxItem """; + private static string s_expectedBitmapNames = """ + System.Windows.Forms.Design.Behavior.BottomClose + System.Windows.Forms.Design.Behavior.BottomOpen + System.Windows.Forms.Design.Behavior.LeftClose + System.Windows.Forms.Design.Behavior.LeftOpen + System.Windows.Forms.Design.Behavior.RightClose + System.Windows.Forms.Design.Behavior.RightOpen + System.Windows.Forms.Design.Behavior.ToolStripContainer_BottomToolStripPanel + System.Windows.Forms.Design.Behavior.ToolStripContainer_LeftToolStripPanel + System.Windows.Forms.Design.Behavior.ToolStripContainer_RightToolStripPanel + System.Windows.Forms.Design.Behavior.ToolStripContainer_TopToolStripPanel + System.Windows.Forms.Design.Behavior.TopClose + System.Windows.Forms.Design.Behavior.TopOpen + """; + public static TheoryData ExpectedIconNames() - => s_expectedIconNames.Split(Environment.NewLine).ToTheoryData(); + => s_expectedIconNames.Split(Environment.NewLine).Where(item => !item.EndsWith(".bmp")).ToTheoryData(); + + public static TheoryData ExpectedBitmapNames() + => s_expectedBitmapNames.Split(Environment.NewLine).ToTheoryData(); [Theory] [MemberData(nameof(ExpectedIconNames))] @@ -76,15 +96,28 @@ public void EmbeddedResource_ResourcesExist_Icon(string resourceName) Assert.NotNull(icon); } + [Theory] + [MemberData(nameof(ExpectedBitmapNames))] + public void EmbeddedResource_ResourcesExist_Bitmap(string resourceName) + { + using Stream stream = assembly.GetManifestResourceStream(resourceName); + Assert.NotNull(stream); + + using Bitmap bitmap = new(stream); + Assert.NotNull(bitmap); + } + private const string expectedResourceNames = """ + System.ComponentModel.Design.BinaryEditor.resources System.ComponentModel.Design.CollectionEditor.resources System.SR.resources System.Windows.Forms.Design.BorderSidesEditor.resources System.Windows.Forms.Design.colordlg.data + System.Windows.Forms.Design.DataGridViewAddColumnDialog.resources + System.Windows.Forms.Design.DataGridViewColumnCollectionDialog.resources System.Windows.Forms.Design.FormatControl.resources System.Windows.Forms.Design.LinkAreaEditor.resources System.Windows.Forms.Design.MaskDesignerDialog.resources - System.Windows.Forms.Design.Resources.System.ComponentModel.Design.BinaryEditor.resources System.Windows.Forms.Design.ShortcutKeysEditor.resources System.Windows.Forms.Design.StringCollectionEditor.resources """; @@ -95,7 +128,8 @@ public void EmbeddedResource_VerifyList() string[] actual = assembly.GetManifestResourceNames(); Array.Sort(actual, StringComparer.Ordinal); - string[] expected = $"{s_expectedIconNames}{Environment.NewLine}{expectedResourceNames}".Split(Environment.NewLine); + string resourceNames = s_expectedIconNames + "\r\n" + s_expectedBitmapNames; + string[] expected = $"{resourceNames}{Environment.NewLine}{expectedResourceNames}".Split(Environment.NewLine); Array.Sort(expected, StringComparer.Ordinal); AssertExtensions.Equal(expected, actual); diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EventHandlerServiceTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EventHandlerServiceTests.cs index fd1a0987271..6531eb20d8b 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EventHandlerServiceTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EventHandlerServiceTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design.Tests; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/FileNameEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/FileNameEditorTests.cs index effec64b184..d57065cc32e 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/FileNameEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/FileNameEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/FolderNameEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/FolderNameEditorTests.cs index 95de8508838..d53cef3a678 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/FolderNameEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/FolderNameEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ImageListImageEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ImageListImageEditorTests.cs index 9066ce2ba7c..991eb3c6a6d 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ImageListImageEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ImageListImageEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Imaging; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/MenuCommandsTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/MenuCommandsTests.cs index 366192cc249..2866b979514 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/MenuCommandsTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/MenuCommandsTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ShortcutKeysEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ShortcutKeysEditorTests.cs index f00fd1e8c6a..c88e7c454e2 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ShortcutKeysEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ShortcutKeysEditorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/WindowsFormsDesignerOptionServiceTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/WindowsFormsDesignerOptionServiceTests.cs index da2e8ff2684..036585aa9cf 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/WindowsFormsDesignerOptionServiceTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/WindowsFormsDesignerOptionServiceTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/SystemDesignMetadataReader.cs b/src/System.Windows.Forms.Design/tests/UnitTests/SystemDesignMetadataReader.cs index 99ac912469a..3af622fcc0e 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/SystemDesignMetadataReader.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/SystemDesignMetadataReader.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; using System.Reflection; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/TestControlDesigner.cs b/src/System.Windows.Forms.Design/tests/UnitTests/TestControlDesigner.cs index 915f4bee5c0..1f8e465d66d 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/TestControlDesigner.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/TestControlDesigner.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/ToolStripDesignerTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/ToolStripDesignerTests.cs new file mode 100644 index 00000000000..fcd98f0bd20 --- /dev/null +++ b/src/System.Windows.Forms.Design/tests/UnitTests/ToolStripDesignerTests.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel.Design; +using System.Windows.Forms.Design.Behavior; +using System.Windows.Forms.Design.Tests.Mocks; +using Moq; + +namespace System.Windows.Forms.Design.Tests; + +public class ToolStripDesignerTests +{ + [WinFormsFact] + public void ToolStripDesigner_AssociatedComponentsTest() + { + using ToolStripDesigner toolStripDesigner = new(); + using ToolStrip toolStrip = new(); + + Mock mockIComponentChangeService = new(MockBehavior.Strict); + Mock mockDesignerHost = new(MockBehavior.Strict); + mockDesignerHost + .Setup(h => h.RootComponent) + .Returns(toolStrip); + mockDesignerHost + .Setup(s => s.GetService(typeof(IComponentChangeService))) + .Returns(mockIComponentChangeService.Object); + mockDesignerHost.Setup(s => s.AddService(typeof(ToolStripKeyboardHandlingService), It.IsAny())); + mockDesignerHost.Setup(s => s.AddService(typeof(ISupportInSituService), It.IsAny())); + + var mockSite = MockSite.CreateMockSiteWithDesignerHost(mockDesignerHost.Object); + mockSite.Setup(s => s.GetService(typeof(BehaviorService))).Returns(null); + mockSite.Setup(s => s.GetService(typeof(ToolStripAdornerWindowService))).Returns(null); + toolStrip.Site = mockSite.Object; + + toolStripDesigner.Initialize(toolStrip); + + Assert.Empty(toolStripDesigner.AssociatedComponents); + + toolStrip.Items.Add("123"); + toolStrip.Items.Add("abc"); + + Assert.Equal(2, toolStripDesigner.AssociatedComponents.Count); + } +} diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/ToolStripDropDownDesignerTest.cs b/src/System.Windows.Forms.Design/tests/UnitTests/ToolStripDropDownDesignerTest.cs new file mode 100644 index 00000000000..3c838cde0f1 --- /dev/null +++ b/src/System.Windows.Forms.Design/tests/UnitTests/ToolStripDropDownDesignerTest.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel.Design; +using System.ComponentModel; +using Moq; +using System.Windows.Forms.Design.Tests.Mocks; + +namespace System.Windows.Forms.Design.Tests; + +public class ToolStripDropDownDesignerTest +{ + [WinFormsFact] + public void ToolStripDropDownDesignerTest_AssociatedComponentsTest() + { + ToolStripDropDownDesigner toolStripDropDownDesigner = new(); + ToolStripDropDown toolStripDropDown = new(); + + Mock mockDesignerHost = new(MockBehavior.Strict); + mockDesignerHost + .Setup(h => h.RootComponent) + .Returns(toolStripDropDown); + mockDesignerHost + .Setup(h => h.Loading) + .Returns(true); + Mock mockComponentChangeService = new(MockBehavior.Strict); + mockDesignerHost + .Setup(s => s.GetService(typeof(IComponentChangeService))) + .Returns(mockComponentChangeService.Object); + mockDesignerHost.Setup(s => s.AddService(It.IsAny(), It.IsAny())); + + Mock mockSite = MockSite.CreateMockSiteWithDesignerHost(mockDesignerHost.Object); + toolStripDropDown.Site = mockSite.Object; + + toolStripDropDownDesigner.Initialize(toolStripDropDown); + + Assert.Empty(toolStripDropDownDesigner.AssociatedComponents); + + toolStripDropDown.Items.Add("123"); + toolStripDropDown.Items.Add("456"); + + Assert.Equal(2, toolStripDropDownDesigner.AssociatedComponents.Count); + } +} diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/ToolStripDropDownItemDesignerTest.cs b/src/System.Windows.Forms.Design/tests/UnitTests/ToolStripDropDownItemDesignerTest.cs new file mode 100644 index 00000000000..be8816ac49a --- /dev/null +++ b/src/System.Windows.Forms.Design/tests/UnitTests/ToolStripDropDownItemDesignerTest.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Windows.Forms.Design.Tests; + +public class ToolStripDropDownItemDesignerTest +{ + [WinFormsFact] + public void ToolStripDropDownItemDesignerTest_AssociatedComponentsTest() + { + ToolStripDropDownItemDesigner toolStripDropDownItemDesigner = new(); + ToolStripMenuItem toolStripDropDown = new(); + + toolStripDropDownItemDesigner.Initialize(toolStripDropDown); + + Assert.Empty(toolStripDropDownItemDesigner.AssociatedComponents); + + toolStripDropDown.DropDownItems.Add("123"); + + Assert.Equal(1, toolStripDropDownItemDesigner.AssociatedComponents.Count); + } +} diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/ToolStripMenuItemDesignerTest.cs b/src/System.Windows.Forms.Design/tests/UnitTests/ToolStripMenuItemDesignerTest.cs new file mode 100644 index 00000000000..f561584c81c --- /dev/null +++ b/src/System.Windows.Forms.Design/tests/UnitTests/ToolStripMenuItemDesignerTest.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Windows.Forms.Design.Tests; + +public class ToolStripMenuItemDesignerTest +{ + [WinFormsFact] + public void ToolStripMenuItemDesignerTest_AssociatedComponentsTest() + { + ToolStripMenuItemDesigner toolStripMenuItemDesigner = new(); + ToolStripMenuItem toolStripDropDown = new(); + toolStripMenuItemDesigner.Initialize(toolStripDropDown); + + Assert.Empty(toolStripMenuItemDesigner.AssociatedComponents); + + toolStripDropDown.DropDownItems.Add("123"); + + Assert.Equal(1, toolStripMenuItemDesigner.AssociatedComponents.Count); + } +} diff --git a/src/System.Windows.Forms.Primitives/src/GlobalUsings.cs b/src/System.Windows.Forms.Primitives/src/GlobalUsings.cs index 5a1040e76de..d2a82a61249 100644 --- a/src/System.Windows.Forms.Primitives/src/GlobalUsings.cs +++ b/src/System.Windows.Forms.Primitives/src/GlobalUsings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. global using System.Diagnostics; global using System.Diagnostics.CodeAnalysis; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.DTN.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.DTN.cs index 2c61c88f3cf..42302cdd238 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.DTN.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.DTN.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HDHITTESTINFO.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HDHITTESTINFO.cs index 85669011210..fdb6a10efc7 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HDHITTESTINFO.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HDHITTESTINFO.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HDITEMW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HDITEMW.cs index a7701ac8c83..68209f5788a 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HDITEMW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HDITEMW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HDN.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HDN.cs index faeab457b23..cd6360bca7c 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HDN.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.HDN.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.ILD.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.ILD.cs index e01e842b19a..c64de64691a 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.ILD.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.ILD.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.InitCommonControls.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.InitCommonControls.cs index d4f63232a2f..f47251eb3ef 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.InitCommonControls.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.InitCommonControls.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LITEM.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LITEM.cs index bffdade0cbb..6ea9ffb3708 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LITEM.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LITEM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVBKIMAGEW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVBKIMAGEW.cs index 6a0463338a5..6baa05b5a96 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVBKIMAGEW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVBKIMAGEW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVCOLUMNW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVCOLUMNW.cs index 13a4e57f3e9..2f4351cb456 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVCOLUMNW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVCOLUMNW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVFINDINFOW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVFINDINFOW.cs index e176dd6f6ca..fe596e900f4 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVFINDINFOW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVFINDINFOW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVGF.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVGF.cs index d45577d64e0..fdd42b3ad4f 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVGF.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVGF.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVGROUPW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVGROUPW.cs index 41e45cdede4..9666ccaf3b5 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVGROUPW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVGROUPW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVHITTESTINFO.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVHITTESTINFO.cs index c70ece808ba..12a7479f7b6 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVHITTESTINFO.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVHITTESTINFO.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVIM.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVIM.cs index 712b34cfea1..89d4327979a 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVIM.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVIM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVINSERTMARK.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVINSERTMARK.cs index c830cf003e9..9c6a868143a 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVINSERTMARK.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVINSERTMARK.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVITEMW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVITEMW.cs index 790d571884a..a5979e5c57f 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVITEMW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVITEMW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVN.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVN.cs index 3221f78a29d..adfc42b3947 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVN.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVN.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVTILEVIEWINFO.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVTILEVIEWINFO.cs index d6ecbd3a26d..84397fb9081 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVTILEVIEWINFO.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.LVTILEVIEWINFO.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.MCGRIDINFO.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.MCGRIDINFO.cs index 2563f05e40d..b6239c4f4ed 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.MCGRIDINFO.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.MCGRIDINFO.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.MCHITTESTINFO.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.MCHITTESTINFO.cs index 2776ff876c6..d5b1bf51f7f 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.MCHITTESTINFO.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.MCHITTESTINFO.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.MCN.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.MCN.cs index 9294f57616a..d55a34ed7b7 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.MCN.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.MCN.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NM.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NM.cs index 42af88c56f2..368b57a39f2 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NM.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMDATETIMECHANGE.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMDATETIMECHANGE.cs index 3d97b5da28c..20649462cc0 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMDATETIMECHANGE.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMDATETIMECHANGE.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMDAYSTATE.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMDAYSTATE.cs index 6239acf5b90..e183dcff99e 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMDAYSTATE.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMDAYSTATE.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMHEADERW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMHEADERW.cs index 293155232dd..9e38ccb549d 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMHEADERW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMHEADERW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLISTVIEW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLISTVIEW.cs index ba5346cedf1..28df4922182 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLISTVIEW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLISTVIEW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVCACHEHINT.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVCACHEHINT.cs index 584a7281e1c..4c2c827f0e8 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVCACHEHINT.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVCACHEHINT.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVCUSTOMDRAW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVCUSTOMDRAW.cs index 2a3c35ec833..8d11d975ec0 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVCUSTOMDRAW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVCUSTOMDRAW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVDISPINFO.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVDISPINFO.cs index 03d1bdd284e..9dda8d2a4f2 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVDISPINFO.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVDISPINFO.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVFINDITEMW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVFINDITEMW.cs index 913cd5ecdca..3a53f7eef6c 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVFINDITEMW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVFINDITEMW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVGETINFOTIPW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVGETINFOTIPW.cs index 4bd8093c30f..dae9584b7eb 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVGETINFOTIPW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVGETINFOTIPW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVKEYDOWN.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVKEYDOWN.cs index e9f9818c313..b7f8cbbe4f7 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVKEYDOWN.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVKEYDOWN.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVLINK.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVLINK.cs index e2a8e0e274a..faa17181829 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVLINK.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVLINK.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVODSTATECHANGE.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVODSTATECHANGE.cs index 8d73972e8bc..2b94ed309ef 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVODSTATECHANGE.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMLVODSTATECHANGE.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMSELCHANGE.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMSELCHANGE.cs index 32f925d71df..9fdd8a691d5 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMSELCHANGE.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMSELCHANGE.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMTREEVIEW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMTREEVIEW.cs index a57a4c6457e..d9e2305dcc6 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMTREEVIEW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMTREEVIEW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMTTDISPINFOW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMTTDISPINFOW.cs index 7ee68a10404..0160a35a1a8 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMTTDISPINFOW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMTTDISPINFOW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMTVDISPINFOW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMTVDISPINFOW.cs index 470aa653ab8..259121ddfb3 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMTVDISPINFOW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMTVDISPINFOW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMVIEWCHANGE.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMVIEWCHANGE.cs index 3e2341fe548..7d143fab33c 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMVIEWCHANGE.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.NMVIEWCHANGE.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TASKDIALOGCONFIG.IconUnion.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TASKDIALOGCONFIG.IconUnion.cs index d88f0180c3a..4f263800b92 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TASKDIALOGCONFIG.IconUnion.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TASKDIALOGCONFIG.IconUnion.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TASKDIALOGCONFIG.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TASKDIALOGCONFIG.cs index bd5d21abae9..c1a6c3b96e9 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TASKDIALOGCONFIG.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TASKDIALOGCONFIG.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TASKDIALOG_BUTTON.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TASKDIALOG_BUTTON.cs index ea037f65e47..c3db3281124 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TASKDIALOG_BUTTON.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TASKDIALOG_BUTTON.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TCITEMW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TCITEMW.cs index beeac83df17..69aa26f99e7 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TCITEMW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TCITEMW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TCN.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TCN.cs index ce0ed989a14..f00d5b107e0 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TCN.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TCN.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TDCBF.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TDCBF.cs index c237bbd05d4..3de817e06d0 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TDCBF.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TDCBF.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TTN.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TTN.cs index 359554e25dd..a39fa084794 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TTN.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TTN.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TTOOLINFOW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TTOOLINFOW.cs index 4d27593f042..2cf48800eb8 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TTOOLINFOW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TTOOLINFOW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVHITTESTINFO.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVHITTESTINFO.cs index 5233d0263ad..4d85ec3557c 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVHITTESTINFO.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVHITTESTINFO.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVHT.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVHT.cs index b07d7d513b2..636159174de 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVHT.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVHT.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVI.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVI.cs index a15168ddebc..275c12001b2 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVI.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVI.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVINSERTSTRUCTW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVINSERTSTRUCTW.cs index 14a34497787..4c8e9a94973 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVINSERTSTRUCTW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVINSERTSTRUCTW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVIS.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVIS.cs index f2f940cd161..205b4064637 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVIS.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVIS.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVITEMW.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVITEMW.cs index 2829d72aac5..43de3666554 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVITEMW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVITEMW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVN.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVN.cs index 2d6a9a3d6ac..7fa00923548 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVN.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TVN.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TaskDialogIndirect.cs b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TaskDialogIndirect.cs index e889ff19d1d..ae5fdb87601 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TaskDialogIndirect.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.TaskDialogIndirect.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.CC.cs b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.CC.cs index d02c42830ef..9a51abc1390 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.CC.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.CC.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.CF.cs b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.CF.cs index 710abc26259..d024b67bc65 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.CF.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.CF.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.COLOR.cs b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.COLOR.cs index 536192689e3..9bfada9fdca 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.COLOR.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.COLOR.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.ChooseColorW.cs b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.ChooseColorW.cs index 2bb2084b285..e21e6944b06 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.ChooseColorW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.ChooseColorW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.ChooseFontW.cs b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.ChooseFontW.cs index e374d5b5647..861f5c00f62 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.ChooseFontW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.ChooseFontW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.FR.cs b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.FR.cs index 31bce14dfd5..53963c8163a 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.FR.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.FR.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PD.cs b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PD.cs index 5510a466d3c..2b2702bbee1 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PD.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PD.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PD_RESULT.cs b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PD_RESULT.cs index 5516ae36f05..23dc9ead66f 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PD_RESULT.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PD_RESULT.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PRINTPAGERANGE.cs b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PRINTPAGERANGE.cs index 561cc20a186..1395c086483 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PRINTPAGERANGE.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PRINTPAGERANGE.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PSD.cs b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PSD.cs index 06963d7cc97..d07d2f7fc66 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PSD.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PSD.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PageSetupDlgW.cs b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PageSetupDlgW.cs index 6ca0c6207a2..071c702e5b2 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PageSetupDlgW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PageSetupDlgW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PrintDlg.cs b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PrintDlg.cs index 6918af0e770..f280078aa1e 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PrintDlg.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PrintDlg.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PrintDlgW.cs b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PrintDlgW.cs index c5dee48edc7..37345899d4c 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PrintDlgW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PrintDlgW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/GdiPlus/Interop.GdipCloneBrush.cs b/src/System.Windows.Forms.Primitives/src/Interop/GdiPlus/Interop.GdipCloneBrush.cs index 98ec1bd88c2..04615e22bfa 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/GdiPlus/Interop.GdipCloneBrush.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/GdiPlus/Interop.GdipCloneBrush.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/GdiPlus/Interop.GdipCreateSolidFill.cs b/src/System.Windows.Forms.Primitives/src/Interop/GdiPlus/Interop.GdipCreateSolidFill.cs index 0202702c38c..1e329a8cdd0 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/GdiPlus/Interop.GdipCreateSolidFill.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/GdiPlus/Interop.GdipCreateSolidFill.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/GdiPlus/Interop.GpStatus.cs b/src/System.Windows.Forms.Primitives/src/Interop/GdiPlus/Interop.GpStatus.cs index c81deaca244..bccc798e947 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/GdiPlus/Interop.GpStatus.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/GdiPlus/Interop.GpStatus.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/HandleRef.cs b/src/System.Windows.Forms.Primitives/src/Interop/HandleRef.cs index 607bd1e577d..ede7576fc5c 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/HandleRef.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/HandleRef.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. /// /// Adapter to use when owning classes cannot directly implement . diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH.cs b/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH.cs index b879fea833d..d4cf871dcaf 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH_ALINKW.cs b/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH_ALINKW.cs index e657cdff4cc..5f025ad4ff8 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH_ALINKW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH_ALINKW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH_FTS_QUERYW.cs b/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH_FTS_QUERYW.cs index 376b7565689..47d7a332b1f 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH_FTS_QUERYW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH_FTS_QUERYW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH_POPUPW.cs b/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH_POPUPW.cs index 5ddf09feb7f..193af309ff6 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH_POPUPW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HH_POPUPW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HtmlHelpW.cs b/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HtmlHelpW.cs index edd4f367395..8ef7e2fcf37 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HtmlHelpW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Hhctrl/Interop.HtmlHelpW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/IHandle.cs b/src/System.Windows.Forms.Primitives/src/Interop/IHandle.cs index 847433d1623..aea69585820 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/IHandle.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/IHandle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Interop.ARGB.cs b/src/System.Windows.Forms.Primitives/src/Interop/Interop.ARGB.cs index 89402070e82..642b11444be 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Interop.ARGB.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Interop.ARGB.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.CompilerServices; @@ -40,6 +39,6 @@ public unsafe ARGB(int value) Value = value; } - public static implicit operator ARGB(Color color) => new ARGB(color.ToArgb()); + public static implicit operator ARGB(Color color) => new(color.ToArgb()); public static implicit operator Color(ARGB argb) => Color.FromArgb(argb.Value); } diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Interop.ERROR.cs b/src/System.Windows.Forms.Primitives/src/Interop/Interop.ERROR.cs index eb05133541a..0e59d518dde 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Interop.ERROR.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Interop.ERROR.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Interop.Libraries.cs b/src/System.Windows.Forms.Primitives/src/Interop/Interop.Libraries.cs index aed75c6b8e8..4e4b63764ed 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Interop.Libraries.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Interop.Libraries.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Interop.PARAM.cs b/src/System.Windows.Forms.Primitives/src/Interop/Interop.PARAM.cs index 8bab982efa6..05ec01450f6 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Interop.PARAM.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Interop.PARAM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Interop.POINTS.cs b/src/System.Windows.Forms.Primitives/src/Interop/Interop.POINTS.cs index ce7eef15f4e..e513ae338b0 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Interop.POINTS.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Interop.POINTS.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; @@ -13,6 +12,6 @@ public struct POINTS public override string ToString() => $"{{X={x} Y={y}}}"; - public static implicit operator Point(POINTS point) => new Point(point.x, point.y); + public static implicit operator Point(POINTS point) => new(point.x, point.y); } } diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Interop.RegionType.cs b/src/System.Windows.Forms.Primitives/src/Interop/Interop.RegionType.cs index ca66d9cf64d..b1480143925 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Interop.RegionType.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Interop.RegionType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLAnchorEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLAnchorEvents2.cs index f19151deb9d..98372dce76e 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLAnchorEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLAnchorEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLAreaEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLAreaEvents2.cs index 04091a0dc5a..b51d720333d 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLAreaEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLAreaEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLButtonElementEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLButtonElementEvents2.cs index c533ad1e0a1..80d1f2b9554 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLButtonElementEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLButtonElementEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLControlElementEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLControlElementEvents2.cs index 077cfadee9c..ea1fe663704 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLControlElementEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLControlElementEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLDocumentEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLDocumentEvents2.cs index 1392d35570b..e934b16603a 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLDocumentEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLDocumentEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLElementEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLElementEvents2.cs index 8bb92e07bdb..58215728018 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLElementEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLElementEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLFormElementEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLFormElementEvents2.cs index 79974ffd0a1..72e502363f2 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLFormElementEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLFormElementEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLFrameSiteEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLFrameSiteEvents2.cs index 216d3284c8b..fe6644eb143 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLFrameSiteEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLFrameSiteEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLImgEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLImgEvents2.cs index 79c90e55587..06c3f4aea51 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLImgEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLImgEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLInputFileElementEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLInputFileElementEvents2.cs index 8e3df14aa96..5ecb8c3cf7d 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLInputFileElementEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLInputFileElementEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLInputImageEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLInputImageEvents2.cs index dc81677bedf..c7e41ec142c 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLInputImageEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLInputImageEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLInputTextElementEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLInputTextElementEvents2.cs index d924cfe6c6f..3b720a86172 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLInputTextElementEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLInputTextElementEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLLabelEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLLabelEvents2.cs index e049db2538c..5d138ce1d0f 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLLabelEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLLabelEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLLinkElementEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLLinkElementEvents2.cs index 2ad52e771d4..25b93eb8e70 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLLinkElementEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLLinkElementEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLMapEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLMapEvents2.cs index e4bf13fc639..bfe68963bd5 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLMapEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLMapEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLMarqueeElementEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLMarqueeElementEvents2.cs index 6da2b77f89e..60742947170 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLMarqueeElementEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLMarqueeElementEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLOptionButtonElementEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLOptionButtonElementEvents2.cs index be21aedf0aa..ad0dd3b2538 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLOptionButtonElementEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLOptionButtonElementEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLScriptEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLScriptEvents2.cs index 6ba3918953e..e45af7a05f2 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLScriptEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLScriptEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLSelectElementEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLSelectElementEvents2.cs index 1aed8a621d3..d1e57fe68dc 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLSelectElementEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLSelectElementEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLStyleElementEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLStyleElementEvents2.cs index 631bec1f707..86870d0f663 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLStyleElementEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLStyleElementEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLTableEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLTableEvents2.cs index f45578c9d09..16d8932838c 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLTableEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLTableEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLTextContainerEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLTextContainerEvents2.cs index 14a0b2be5c4..c6b4126300f 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLTextContainerEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLTextContainerEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLWindowEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLWindowEvents2.cs index 86beac26122..3c3182118cb 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLWindowEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DHTMLWindowEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DOCHOSTUIDBLCLK.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DOCHOSTUIDBLCLK.cs index d9f860c5d57..6bdb7bf2ab2 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DOCHOSTUIDBLCLK.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DOCHOSTUIDBLCLK.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DOCHOSTUIFLAG.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DOCHOSTUIFLAG.cs index cb41f25cccc..c77de0d4ad0 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DOCHOSTUIFLAG.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DOCHOSTUIFLAG.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DOCHOSTUIINFO.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DOCHOSTUIINFO.cs index 1a5117ebd7d..40c63da5d3d 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DOCHOSTUIINFO.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.DOCHOSTUIINFO.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IDocHostUIHandler.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IDocHostUIHandler.cs index e013635fc02..30fff546859 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IDocHostUIHandler.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IDocHostUIHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDOMNode.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDOMNode.cs index 0ed6d21e9bd..2dd557d6879 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDOMNode.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDOMNode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument.cs index 58a86a14caa..676b248ab8d 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument2.cs index 9b7e31751ec..f8758346588 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument3.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument3.cs index 36faf3b9e30..5d0d332e6ac 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument3.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument3.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument4.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument4.cs index 7842a67cd37..5f7c8f1f186 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument4.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLDocument4.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElement.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElement.cs index 3da416034d1..7ba01914f65 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElement.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElement.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElement2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElement2.cs index 709f7c77bfe..cb0461953f8 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElement2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElement2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElement3.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElement3.cs index 66fac51b8ab..133af6e2edb 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElement3.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElement3.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElementCollection.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElementCollection.cs index d0506207501..6c49dbeee34 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElementCollection.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLElementCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLEventObj.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLEventObj.cs index 30b24b130b5..bd668418de6 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLEventObj.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLEventObj.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLFramesCollection2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLFramesCollection2.cs index b52786987c6..2c9452f81f2 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLFramesCollection2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLFramesCollection2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLLocation.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLLocation.cs index ba1cd39efaa..b7cb481e158 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLLocation.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLLocation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLStyle.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLStyle.cs index d89026f024b..ca4a4699910 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLStyle.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLWindow2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLWindow2.cs index dead53233ae..6530c6d1b9d 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLWindow2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLWindow2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLWindow3.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLWindow3.cs index 6c0ad2d9904..dfbab1711e1 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLWindow3.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLWindow3.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLWindow4.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLWindow4.cs index b46087ffe1a..2d607550cfb 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLWindow4.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IHTMLWindow4.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IOmHistory.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IOmHistory.cs index a07ad6aa982..14b18d922e7 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IOmHistory.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IOmHistory.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IWebBrowser2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IWebBrowser2.cs index edf9ac5de9c..4f8683b5e6b 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IWebBrowser2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Mshtml/Interop.IWebBrowser2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.System.Ole; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/NullHandle.cs b/src/System.Windows.Forms.Primitives/src/Interop/NullHandle.cs index 413ea8472ce..e50d7931eb4 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/NullHandle.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/NullHandle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal class NullHandle : IHandle where T : unmanaged { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.CoCreateInstance.cs b/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.CoCreateInstance.cs index de46d262897..79a395c8205 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.CoCreateInstance.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.CoCreateInstance.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.DoDragDrop.cs b/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.DoDragDrop.cs index 3c60db802e2..a030b2c34ee 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.DoDragDrop.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.DoDragDrop.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.GPStream.cs b/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.GPStream.cs index 905955b378b..073389e9adb 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.GPStream.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.GPStream.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.OleGetClipboard.cs b/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.OleGetClipboard.cs index 766afc16ff8..cc5fea431c3 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.OleGetClipboard.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.OleGetClipboard.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.OleSetClipboard.cs b/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.OleSetClipboard.cs index 8b3447e0724..91f598dec99 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.OleSetClipboard.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.OleSetClipboard.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.ReleaseStgMedium.cs b/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.ReleaseStgMedium.cs index 78e84ad88ef..ec2db601431 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.ReleaseStgMedium.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Ole32/Interop.ReleaseStgMedium.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.GetErrorInfo.cs b/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.GetErrorInfo.cs deleted file mode 100644 index ad8693a3859..00000000000 --- a/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.GetErrorInfo.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; - -internal partial class Interop -{ - internal static partial class Oleaut32 - { - [DllImport(Libraries.Oleaut32)] - private static extern HRESULT GetErrorInfo(uint dwReserved, out IntPtr pperrinfo); - - public static void GetErrorInfo(out WinFormsComWrappers.ErrorInfoWrapper? errinfo) - { - HRESULT result = GetErrorInfo(0, out IntPtr pperrinfo); - errinfo = null; - if (result.Succeeded && pperrinfo != IntPtr.Zero) - { - errinfo = (WinFormsComWrappers.ErrorInfoWrapper)WinFormsComWrappers.Instance.GetOrCreateObjectForComInstance(pperrinfo, CreateObjectFlags.Unwrap); - } - } - } -} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.VARIANT.cs b/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.VARIANT.cs index 62a59e433e7..4d54a807c8c 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.VARIANT.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.VARIANT.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -152,13 +151,13 @@ public void Clear() return Marshal.PtrToStringAnsi(*(IntPtr*)data); case VT_DISPATCH: case VT_UNKNOWN: - IntPtr pInterface = *(IntPtr*)data; - if (pInterface == IntPtr.Zero) + IUnknown* pInterface = *(IUnknown**)data; + if (pInterface is null) { return null; } - return Marshal.GetObjectForIUnknown(pInterface); + return ComHelpers.GetObjectForIUnknown(pInterface); case VT_DECIMAL: return ((DECIMAL*)data)->ToDecimal(); case VT_BOOL: @@ -381,7 +380,7 @@ private static Type GetRecordElementType(IRecordInfo* record) var result = GetSpan(array); for (int i = 0; i < data.Length; i++) { - result[i] = data[i] == IntPtr.Zero ? null : Marshal.GetObjectForIUnknown(data[i]); + result[i] = data[i] == IntPtr.Zero ? null : ComHelpers.GetObjectForIUnknown((IUnknown*)data[i]); } break; @@ -591,7 +590,7 @@ static void SetValue(Array array, T value, Span indices, Span lower } else { - SetValue(array, Marshal.GetObjectForIUnknown(data), indices, lowerBounds); + SetValue(array, ComHelpers.GetObjectForIUnknown((IUnknown*)data), indices, lowerBounds); } break; @@ -890,6 +889,7 @@ public static explicit operator int(VARIANT value) public static explicit operator VARIANT(int value) => new() { + // Legacy marshalling uses VT_I4, not VT_INT vt = VT_I4, data = new() { intVal = value } }; @@ -902,6 +902,7 @@ public static explicit operator uint(VARIANT value) public static explicit operator VARIANT(uint value) => new() { + // Legacy marshalling uses VT_UI4, not VT_UINT vt = VT_UI4, data = new() { uintVal = value } }; @@ -940,7 +941,7 @@ public static explicit operator CY(VARIANT value) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static explicit operator VARIANT(IUnknown* value) - => new VARIANT() + => new() { vt = VT_UNKNOWN, data = new() { punkVal = value } diff --git a/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.VARIANTVector.cs b/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.VARIANTVector.cs index e9bb1a33dde..3a4ecc8aa2b 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.VARIANTVector.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.VARIANTVector.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.CFE.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.CFE.cs index ee5f90a4c1f..a049d499fda 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.CFE.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.CFE.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.CFM.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.CFM.cs index 82978cec0ab..cdac9a79a01 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.CFM.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.CFM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.CHARFORMAT2W.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.CHARFORMAT2W.cs index dec0f8061a1..77068a6703d 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.CHARFORMAT2W.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.CHARFORMAT2W.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ECO.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ECO.cs index 38a09471e4c..69e9640376b 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ECO.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ECO.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ECOOP.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ECOOP.cs index 2b5569f334d..1c788184b1b 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ECOOP.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ECOOP.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.EDITSTREAM.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.EDITSTREAM.cs index 7a892dd0e99..441b7c0ffe0 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.EDITSTREAM.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.EDITSTREAM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.EDITSTREAMCALLBACK.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.EDITSTREAMCALLBACK.cs index fbdb99ed891..1d02c0bd440 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.EDITSTREAMCALLBACK.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.EDITSTREAMCALLBACK.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.EN.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.EN.cs index 3e20fad68f2..fc60ebc70d3 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.EN.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.EN.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENDROPFILES.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENDROPFILES.cs index ddd4018b9b0..207a85969d6 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENDROPFILES.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENDROPFILES.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENLINK.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENLINK.cs index 724d2b4e578..bdb458989c7 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENLINK.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENLINK.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.UI.Controls.RichEdit; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENM.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENM.cs index c509b25f7fb..3bd5a231329 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENM.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENPROTECTED.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENPROTECTED.cs index 6e6e8fac48c..8068915a9a8 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENPROTECTED.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ENPROTECTED.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.UI.Controls.RichEdit; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ES.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ES.cs index 89cf1dcd2a6..b41870f18e1 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ES.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ES.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.FINDTEXTW.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.FINDTEXTW.cs index 375ec8cdd32..8c4e359278b 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.FINDTEXTW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.FINDTEXTW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.UI.Controls.RichEdit; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GETTEXTEX.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GETTEXTEX.cs index 7ad4fde15bd..0439ca01334 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GETTEXTEX.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GETTEXTEX.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GETTEXTLENGTHEX.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GETTEXTLENGTHEX.cs index 02b5088fe6f..5e86ca4de5b 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GETTEXTLENGTHEX.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GETTEXTLENGTHEX.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GT.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GT.cs index d3a78e2ac00..dbeec4afc63 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GT.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GT.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GTL.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GTL.cs index 80ce9142353..d1219e70f04 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GTL.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.GTL.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ICM.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ICM.cs index 43f99383967..148cd80208f 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ICM.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ICM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ITextDocument.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ITextDocument.cs index 13a438a3338..4ebb32e5a2f 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ITextDocument.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ITextDocument.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ITextRange.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ITextRange.cs index fc75cb29e11..44bbdac3041 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ITextRange.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.ITextRange.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.MAX_TAB_STOPS.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.MAX_TAB_STOPS.cs index 4ff9f217407..78dec3e8167 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.MAX_TAB_STOPS.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.MAX_TAB_STOPS.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PARAFORMAT.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PARAFORMAT.cs index c2964afc9ed..b484c1200c1 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PARAFORMAT.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PARAFORMAT.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PFA.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PFA.cs index 845266bb644..93eac2e9529 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PFA.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PFA.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PFM.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PFM.cs index 59f1b8e4d44..95c3256abba 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PFM.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PFM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PFN.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PFN.cs index a09060c3a28..0726aee4433 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PFN.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.PFN.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.RECO.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.RECO.cs index 0b74a79656d..d2aba2d83a5 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.RECO.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.RECO.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.REQRESIZE.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.REQRESIZE.cs index e4eaed106f1..9149e484acb 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.REQRESIZE.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.REQRESIZE.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.RichEditPack.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.RichEditPack.cs index 5e1d3771009..3211dd7b2af 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.RichEditPack.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.RichEditPack.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SCF.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SCF.cs index df2022858f8..6fad1b1b4c4 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SCF.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SCF.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SEL.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SEL.cs index 9527453da54..d2f30f355a0 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SEL.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SEL.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SELCHANGE.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SELCHANGE.cs index e54b51a70e6..c36ae8a2361 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SELCHANGE.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SELCHANGE.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.UI.Controls.RichEdit; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SF.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SF.cs index 257f2074acf..1a71256b34f 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SF.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SF.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.TEXTRANGE.cs b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.TEXTRANGE.cs index c83f1e6d94c..d6c6a62f724 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.TEXTRANGE.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.TEXTRANGE.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.UI.Controls.RichEdit; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/SHDocVw/Interop.CSC.cs b/src/System.Windows.Forms.Primitives/src/Interop/SHDocVw/Interop.CSC.cs index 2f050963c38..99a2c0cf5e8 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/SHDocVw/Interop.CSC.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/SHDocVw/Interop.CSC.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/SHDocVw/Interop.DWebBrowserEvents2.cs b/src/System.Windows.Forms.Primitives/src/Interop/SHDocVw/Interop.DWebBrowserEvents2.cs index febf0b24927..e82c32cedd6 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/SHDocVw/Interop.DWebBrowserEvents2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/SHDocVw/Interop.DWebBrowserEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.IDragSourceHelper2.cs b/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.IDragSourceHelper2.cs index d4e1c4240c4..b872340144c 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.IDragSourceHelper2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.IDragSourceHelper2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.IDropTargetHelper.cs b/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.IDropTargetHelper.cs index ae63e025454..fa81ae0ceca 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.IDropTargetHelper.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.IDropTargetHelper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NIF.cs b/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NIF.cs index cb6679da267..5dcadc8303b 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NIF.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NIF.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NIIF.cs b/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NIIF.cs index bd55c5255bd..33e9eadefbb 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NIIF.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NIIF.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NIM.cs b/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NIM.cs index cf4220d5284..a6906f5a6d1 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NIM.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NIM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NOTIFYICONDATAW.cs b/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NOTIFYICONDATAW.cs index 313e9d1f4d1..3667b775c09 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NOTIFYICONDATAW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.NOTIFYICONDATAW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.Shell_NotifyIconW.cs b/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.Shell_NotifyIconW.cs index f5cba3d07ae..2496fa7e7c7 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.Shell_NotifyIconW.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Shell32/Interop.Shell_NotifyIconW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ExpandCollapseState.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ExpandCollapseState.cs index 37a354ee672..0fbdfa0f97f 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ExpandCollapseState.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ExpandCollapseState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IAccessibleEx.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IAccessibleEx.cs index a37449f6a76..c47129bf0a7 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IAccessibleEx.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IAccessibleEx.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IAccessibleInternal.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IAccessibleInternal.cs index 192feef23be..6b41485d107 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IAccessibleInternal.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IAccessibleInternal.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IExpandCollapseProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IExpandCollapseProvider.cs index 7c06dc35e1c..fd4f04de7af 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IExpandCollapseProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IExpandCollapseProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IGridItemProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IGridItemProvider.cs index 225767afb91..7b606e5cb38 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IGridItemProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IGridItemProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IGridProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IGridProvider.cs index a2f29e3a7e9..e08db3e30be 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IGridProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IGridProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IInvokeProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IInvokeProvider.cs index 466e4430d70..3d2a559efd9 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IInvokeProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IInvokeProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ILegacyIAccessibleProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ILegacyIAccessibleProvider.cs index bfeb6ebf135..2cc2fb37f4a 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ILegacyIAccessibleProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ILegacyIAccessibleProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IMultipleViewProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IMultipleViewProvider.cs index 205b65c9d24..75e95f7d64d 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IMultipleViewProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IMultipleViewProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRangeValueProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRangeValueProvider.cs index 0eb08d8c634..290af1b4338 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRangeValueProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRangeValueProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderFragment.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderFragment.cs index 6f6477cc7cc..50fc53fc447 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderFragment.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderFragment.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderFragmentRoot.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderFragmentRoot.cs index b97940629ed..3fe8008778d 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderFragmentRoot.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderFragmentRoot.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderHwndOverride.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderHwndOverride.cs index dae80d8df6f..b57ecd55b90 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderHwndOverride.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderHwndOverride.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderSimple.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderSimple.cs index 3f826d687ee..7a3f8db8335 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderSimple.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IRawElementProviderSimple.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IScrollItemProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IScrollItemProvider.cs index d961e1dbaa2..3f9710720b1 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IScrollItemProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IScrollItemProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ISelectionItemProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ISelectionItemProvider.cs index 4eb29591ca4..e32ae61ef73 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ISelectionItemProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ISelectionItemProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ISelectionProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ISelectionProvider.cs index 93b1e4212ba..b514e0e5307 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ISelectionProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ISelectionProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITableItemProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITableItemProvider.cs index 5f226646c55..ac562e11395 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITableItemProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITableItemProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITableProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITableProvider.cs index da820794c4c..3ca452f09ae 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITableProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITableProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITextProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITextProvider.cs index b7a5b98f7f8..871f9f72783 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITextProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITextProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITextProvider2.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITextProvider2.cs index d73dbdde0b4..1f69d38b4aa 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITextProvider2.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITextProvider2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITextRangeProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITextRangeProvider.cs index 216c3519e72..c9395621fdd 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITextRangeProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITextRangeProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IToggleProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IToggleProvider.cs index 981b56a80f0..2c8d6755659 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IToggleProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IToggleProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IValueProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IValueProvider.cs index f266a72098f..e16f705dacc 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IValueProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.IValueProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.NavigateDirection.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.NavigateDirection.cs index 6ebf0f99117..2a8dd722a1f 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.NavigateDirection.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.NavigateDirection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ProviderOptions.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ProviderOptions.cs index d53b8db2fbf..64b6bf2608e 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ProviderOptions.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ProviderOptions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.RowOrColumnMajor.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.RowOrColumnMajor.cs index 9c36875df60..e368aa664c4 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.RowOrColumnMajor.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.RowOrColumnMajor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.StructureChangeType.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.StructureChangeType.cs index c4aa91c196c..10aab277e26 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.StructureChangeType.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.StructureChangeType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.StubFragmentRoot.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.StubFragmentRoot.cs index da5d9acf4b3..5b7e8ac55cf 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.StubFragmentRoot.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.StubFragmentRoot.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.SupportedTextSelection.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.SupportedTextSelection.cs index 0eec713cd7d..29da76e56a0 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.SupportedTextSelection.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.SupportedTextSelection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.TextAttributeIdentifier.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.TextAttributeIdentifier.cs index 96bb2d93fa6..9b6b70d8c36 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.TextAttributeIdentifier.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.TextAttributeIdentifier.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.TextPatternRangeEndpoint.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.TextPatternRangeEndpoint.cs index 179391e6c06..52c03f4d3ce 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.TextPatternRangeEndpoint.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.TextPatternRangeEndpoint.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.TextUnit.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.TextUnit.cs index 527c2ba159e..67237850eaf 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.TextUnit.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.TextUnit.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ToggleState.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ToggleState.cs index 7dcfa4a5695..1e51d95ffe8 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ToggleState.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ToggleState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UIA.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UIA.cs index 87afbe48bdc..89320c1799d 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UIA.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UIA.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static partial class Interop { diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaClientsAreListening.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaClientsAreListening.cs index d4d25bf90cf..ce322bcc29c 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaClientsAreListening.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaClientsAreListening.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaCoreTypes.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaCoreTypes.cs index d71a594eeb0..8072c2f4d60 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaCoreTypes.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaCoreTypes.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaDisconnectProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaDisconnectProvider.cs index 24ab2e3d473..b0be2ae262d 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaDisconnectProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaDisconnectProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaHostProviderFromHwnd.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaHostProviderFromHwnd.cs index 80922b0bf64..57b7210d1b1 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaHostProviderFromHwnd.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaHostProviderFromHwnd.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseAutomationEvent.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseAutomationEvent.cs index fb73c837186..8f7b90cfccb 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseAutomationEvent.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseAutomationEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseAutomationPropertyChangedEvent.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseAutomationPropertyChangedEvent.cs index 0e6f9b6daae..10d4f1112c3 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseAutomationPropertyChangedEvent.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseAutomationPropertyChangedEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseNotificationEvent.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseNotificationEvent.cs index 80df78f6bfc..9b80c9b17ca 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseNotificationEvent.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseNotificationEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using System.Windows.Forms.Automation; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseStructureChangedEvent.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseStructureChangedEvent.cs index f3806cf51ba..5d5ab123fd1 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseStructureChangedEvent.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRaiseStructureChangedEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRect.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRect.cs index 293b5c2e98a..c3808ac551d 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRect.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaRect.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaReturnRawElementProvider.cs b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaReturnRawElementProvider.cs index 7ec2b63df80..c4baa22d580 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaReturnRawElementProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaReturnRawElementProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/User32/WMExtensions.cs b/src/System.Windows.Forms.Primitives/src/Interop/User32/WMExtensions.cs index e442e8c5b75..ed66dfff8c4 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/User32/WMExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/User32/WMExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/Interop/WinFormsComStrategy.cs b/src/System.Windows.Forms.Primitives/src/Interop/WinFormsComStrategy.cs new file mode 100644 index 00000000000..d8a284305c6 --- /dev/null +++ b/src/System.Windows.Forms.Primitives/src/Interop/WinFormsComStrategy.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using Windows.Win32.System.Com; + +internal partial class Interop +{ + /// + /// Windows Forms implementation. + /// + /// + /// + /// Deriving from allows us to leverage the functionality the runtime + /// has implemented for source generated "RCW"s, including support for adaption + /// when built-in COM support is availalbe (EnableGeneratedComInterfaceComImportInterop). + /// + /// + /// It isn't immediately clear how we could merge with this as there is no + /// strategy for . We rely + /// on to apply the needed vtable functionality and it doesn't appear that we + /// can apply without manually implementing (or source generating) + /// on our exposed classes. + /// + /// + internal unsafe class WinFormsComStrategy : StrategyBasedComWrappers + { + internal static WinFormsComStrategy Instance { get; } = new(); + + protected override IIUnknownStrategy GetOrCreateIUnknownStrategy() => GlobalInterfaceTable.CreateUnknownStrategy(); + } +} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/WinFormsComWrappers.ErrorInfoWrapper.cs b/src/System.Windows.Forms.Primitives/src/Interop/WinFormsComWrappers.ErrorInfoWrapper.cs deleted file mode 100644 index e342b0206d9..00000000000 --- a/src/System.Windows.Forms.Primitives/src/Interop/WinFormsComWrappers.ErrorInfoWrapper.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; -using System.Windows.Forms; - -internal partial class Interop -{ - internal unsafe partial class WinFormsComWrappers - { - internal class ErrorInfoWrapper - { - private IntPtr _wrappedInstance; - - public ErrorInfoWrapper(IntPtr wrappedInstance) - { - _wrappedInstance = wrappedInstance.OrThrowIfZero(); - } - - internal IntPtr Instance => _wrappedInstance; - - public void Dispose() - { - Marshal.Release(_wrappedInstance); - _wrappedInstance = IntPtr.Zero; - } - - public bool GetDescription([NotNullWhen(true)] out string? pBstrDescription) - { - IntPtr descriptionPtr; - var result = ((delegate* unmanaged)(*(*(void***)_wrappedInstance + 5 /* IErrorInfo.GetDescription */))) - (_wrappedInstance, &descriptionPtr); - if (result.Succeeded) - { - pBstrDescription = Marshal.PtrToStringUni(descriptionPtr); - Marshal.FreeBSTR(descriptionPtr); - } - else - { - pBstrDescription = null; - } - - return result.Succeeded; - } - } - } -} diff --git a/src/System.Windows.Forms.Primitives/src/Interop/WinFormsComWrappers.cs b/src/System.Windows.Forms.Primitives/src/Interop/WinFormsComWrappers.cs index da3597115a0..045e3c53dfe 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/WinFormsComWrappers.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/WinFormsComWrappers.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Runtime.InteropServices; @@ -13,8 +12,6 @@ internal partial class Interop /// internal unsafe partial class WinFormsComWrappers : ComWrappers { - private const int S_OK = 0; - internal static WinFormsComWrappers Instance { get; } = new WinFormsComWrappers(); private WinFormsComWrappers() { } @@ -44,17 +41,6 @@ internal static void PopulateIUnknownVTable(IUnknown.Vtbl* unknown) protected override object CreateObject(IntPtr externalComObject, CreateObjectFlags flags) { - Debug.Assert(flags == CreateObjectFlags.UniqueInstance - || flags == CreateObjectFlags.None - || flags == CreateObjectFlags.Unwrap); - - int hr = Marshal.QueryInterface(externalComObject, ref IID.GetRef(), out IntPtr errorInfoComObject); - if (hr == S_OK) - { - Marshal.Release(externalComObject); - return new ErrorInfoWrapper(errorInfoComObject); - } - throw new NotImplementedException(); } diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/IMsoComponent.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/IMsoComponent.cs index 929badf0df0..d01d655ae77 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/IMsoComponent.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/IMsoComponent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/IMsoComponentManager.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/IMsoComponentManager.cs index 15051036e58..46ec6ea3800 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/IMsoComponentManager.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/IMsoComponentManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.System.Ole; diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/MSOCRINFO.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/MSOCRINFO.cs index d39c808fe00..a7e3f139ce5 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/MSOCRINFO.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/MSOCRINFO.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/MsoComponentIds.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/MsoComponentIds.cs index 240b57d5d75..89329b2c1da 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/MsoComponentIds.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/MsoComponentIds.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.Office; diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocWindow.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocWindow.cs index 29ff51fd422..db36aeceec8 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocWindow.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.Office; diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocadvf.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocadvf.cs index 5b2a2c2b81f..d137ed908a8 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocadvf.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocadvf.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.Office; diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msoccontext.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msoccontext.cs index 7dfbde19013..eaac826b48d 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msoccontext.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msoccontext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.Office; diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocrf.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocrf.cs index 069c4659813..0a5a5f5303e 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocrf.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocrf.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.Office; diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocstate.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocstate.cs index 98128c9c1eb..70b8ef489c9 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocstate.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msocstate.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.Office; diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msogac.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msogac.cs index 4a49bcc4f43..f1b495e4b62 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msogac.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msogac.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.Office; diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msoidlef.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msoidlef.cs index 3f79467ccc8..9a5bf7f2105 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msoidlef.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msoidlef.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.Office; diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msoloop.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msoloop.cs index 63294402927..5e2f2b4c08c 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msoloop.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/Office/msoloop.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.Office; diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/CTLBLDTYPE.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/CTLBLDTYPE.cs index 73774a3532e..eb2d5785ee7 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/CTLBLDTYPE.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/CTLBLDTYPE.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualStudio.Shell; diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/ICategorizeProperties.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/ICategorizeProperties.cs index 290d870a875..1347f29f38a 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/ICategorizeProperties.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/ICategorizeProperties.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -11,7 +10,7 @@ namespace Microsoft.VisualStudio.Shell; /// internal unsafe struct ICategorizeProperties : IComIID { - internal static readonly Guid Guid = new Guid(0x4D07FC10, 0xF931, 0x11CE, 0xB0, 0x01, 0x00, 0xAA, 0x00, 0x68, 0x84, 0xE5); + internal static readonly Guid Guid = new(0x4D07FC10, 0xF931, 0x11CE, 0xB0, 0x01, 0x00, 0xAA, 0x00, 0x68, 0x84, 0xE5); static ref readonly Guid IComIID.Guid { diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IProvidePropertyBuilder.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IProvidePropertyBuilder.cs index bef88a767c3..eb51241a8e4 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IProvidePropertyBuilder.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IProvidePropertyBuilder.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -11,7 +10,7 @@ namespace Microsoft.VisualStudio.Shell; internal unsafe struct IProvidePropertyBuilder : IComIID { - internal static readonly Guid Guid = new Guid(0x33C0C1D8, 0x33CF, 0x11d3, 0xBF, 0xF2, 0x00, 0xC0, 0x4F, 0x99, 0x02, 0x35); + internal static readonly Guid Guid = new(0x33C0C1D8, 0x33CF, 0x11d3, 0xBF, 0xF2, 0x00, 0xC0, 0x4F, 0x99, 0x02, 0x35); static ref readonly Guid IComIID.Guid { diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVSMDPerPropertyBrowsing.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVSMDPerPropertyBrowsing.cs index 378655f9b26..dba26669ceb 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVSMDPerPropertyBrowsing.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVSMDPerPropertyBrowsing.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -12,7 +11,7 @@ namespace Microsoft.VisualStudio.Shell; /// internal unsafe struct IVSMDPerPropertyBrowsing : IComIID { - internal static readonly Guid Guid = new Guid(0x7494683C, 0x37A0, 0x11D2, 0xA2, 0x73, 0x00, 0xC0, 0x4F, 0x8E, 0xF4, 0xFF); + internal static readonly Guid Guid = new(0x7494683C, 0x37A0, 0x11D2, 0xA2, 0x73, 0x00, 0xC0, 0x4F, 0x8E, 0xF4, 0xFF); static ref readonly Guid IComIID.Guid { diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVsPerPropertyBrowsing.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVsPerPropertyBrowsing.cs index b581f860213..68e09aaa804 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVsPerPropertyBrowsing.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVsPerPropertyBrowsing.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -11,7 +10,7 @@ namespace Microsoft.VisualStudio.Shell; /// internal unsafe struct IVsPerPropertyBrowsing : IComIID { - public static readonly Guid Guid = new Guid(0x0FF510A3, 0x5FA5, 0x49F1, 0x8C, 0xCC, 0x19, 0x0D, 0x71, 0x08, 0x3F, 0x3E); + public static readonly Guid Guid = new(0x0FF510A3, 0x5FA5, 0x49F1, 0x8C, 0xCC, 0x19, 0x0D, 0x71, 0x08, 0x3F, 0x3E); static ref readonly Guid IComIID.Guid { diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/PROPCAT.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/PROPCAT.cs index 865782086f8..b05e85ebcfc 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/PROPCAT.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/PROPCAT.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Microsoft.VisualStudio.Shell; diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/Win32/SafeHandles/CoTaskMemSafeHandle.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/Win32/SafeHandles/CoTaskMemSafeHandle.cs index 048377699f7..405a7c065f9 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/Win32/SafeHandles/CoTaskMemSafeHandle.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/Win32/SafeHandles/CoTaskMemSafeHandle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/NativeMethods.json b/src/System.Windows.Forms.Primitives/src/NativeMethods.json index 7c17238a0cc..39363bc7f1e 100644 --- a/src/System.Windows.Forms.Primitives/src/NativeMethods.json +++ b/src/System.Windows.Forms.Primitives/src/NativeMethods.json @@ -61,6 +61,7 @@ "IEnumVARIANT.Skip", "IEnumVARIANT.Reset", "IEnumVARIANT.Clone", + "IErrorInfo.GetDescription", "IFileDialog.Show", "IFileDialog.GetResult", "IFileOpenDialog.GetResults", @@ -70,6 +71,11 @@ "IGlobalInterfaceTable.GetInterfaceFromGlobal", "IGlobalInterfaceTable.RegisterInterfaceInGlobal", "IGlobalInterfaceTable.RevokeInterfaceFromGlobal", + "IOleAdviseHolder.Advise", + "IOleAdviseHolder.SendOnClose", + "IOleAdviseHolser.SendOnRename", + "IOleAdviseHolder.SendOnSave", + "IOleAdviseHolder.Unadvise", "IOleCommandTarget.Exec", "IOleCommandTarget.QueryStatus", "IOleControl.GetControlInfo", @@ -130,6 +136,19 @@ "IPerPropertyBrowsing.GetPredefinedStrings", "IPerPropertyBrowsing.GetPredefinedValue", "IPerPropertyBrowsing.MapPropertyToPage", + "IPersistPropertyBag.Load", + "IPersistPropertyBag.Save", + "IPersistStorage.HandsOffStorage", + "IPersistStorage.InitNew", + "IPersistStorage.Load", + "IPersistStorage.Save", + "IPersistStorage.SaveCompleted", + "IPersistStream.Load", + "IPersistStream.Save", + "IPersistStreamInit.InitNew", + "IPersistStreamInit.Load", + "IPersistStreamInit.Save", + "IPersistPropertyBag.InitNew", "IPropertyBag.Read", "IPropertyNotifySink.OnChanged", "IPropertyNotifySink.OnRequestEdit", @@ -164,6 +183,7 @@ "ITypeInfo.ReleaseFuncDesc", "ITypeInfo.ReleaseTypeAttr", "ITypeLib.GetLibAttr", + "ITypeLib.GetTypeInfoOfGuid", "IUnknown.QueryInterface" ] } diff --git a/src/System.Windows.Forms.Primitives/src/NativeMethods.txt b/src/System.Windows.Forms.Primitives/src/NativeMethods.txt index bc67f369b8d..a3c36f64c83 100644 --- a/src/System.Windows.Forms.Primitives/src/NativeMethods.txt +++ b/src/System.Windows.Forms.Primitives/src/NativeMethods.txt @@ -28,6 +28,7 @@ CDM_GETSPEC CDRF_* CHILDID_SELF ChildWindowFromPointEx +CSIDL_* CLIENTCREATESTRUCT ClientToScreen ClipCursor @@ -63,6 +64,7 @@ CreateHalftonePalette CreateICW CreateILockBytesOnHGlobal CreateMenu +CreateOleAdviseHolder CreatePatternBrush CreatePen CreateRectRgn @@ -171,6 +173,7 @@ FDAP fdex* FILETIME FillRect +FindExecutable FindWindow FONTDESC FormatMessage @@ -218,6 +221,7 @@ GetDlgItemInt GetDoubleClickTime GetDpiForSystem GetDpiForWindow +GetErrorInfo GetExitCodeThread GetFocus GetForegroundWindow @@ -414,6 +418,7 @@ IsAccelerator IsAppThemed IsChild IsDialogMessage +IScrollProvider IServiceProvider IShellItem ISimpleFrameSite @@ -640,7 +645,7 @@ SHCreateShellItem SHDRAGIMAGE ShellExecute SHGetKnownFolderPath -SHGetPathFromIDList +SHGetPathFromIDListEx SHGetSpecialFolderLocation ShowCaret ShowCursor diff --git a/src/System.Windows.Forms.Primitives/src/Properties/AssemblyInfo.cs b/src/System.Windows.Forms.Primitives/src/Properties/AssemblyInfo.cs index d59b1128c21..0fb4756e6ac 100644 --- a/src/System.Windows.Forms.Primitives/src/Properties/AssemblyInfo.cs +++ b/src/System.Windows.Forms.Primitives/src/Properties/AssemblyInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/System.Windows.Forms.Primitives/src/Resources/SR.resx b/src/System.Windows.Forms.Primitives/src/Resources/SR.resx index 7d3730d7383..0a6720aa668 100644 --- a/src/System.Windows.Forms.Primitives/src/Resources/SR.resx +++ b/src/System.Windows.Forms.Primitives/src/Resources/SR.resx @@ -138,4 +138,7 @@ Failed to set thread's DPI hosting behavior {0}. - \ No newline at end of file + + Unable to retrieve the root folder. + + diff --git a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.cs.xlf index 20b18fcedf4..93b87455cfb 100644 --- a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.cs.xlf @@ -7,6 +7,11 @@ Nezpracovaná hodnota VT: {0}. + + Unable to retrieve the root folder. + Unable to retrieve the root folder. + + The service '{0}' must be installed for this feature to work. Ensure that this service is available. Pro využití této funkce musí být nainstalovaná služba {0}. Zkontrolujte, jestli je tato služba dostupná. diff --git a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.de.xlf index 22268e8bbaa..74a862e4442 100644 --- a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.de.xlf @@ -7,6 +7,11 @@ Unbehandelter VT: {0}. + + Unable to retrieve the root folder. + Unable to retrieve the root folder. + + The service '{0}' must be installed for this feature to work. Ensure that this service is available. Der Dienst "{0}" muss installiert sein, damit diese Funktion funktioniert. Stellen Sie sicher, dass der Dienst verfügbar ist. diff --git a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.es.xlf index e5d4ec1401f..edac584badc 100644 --- a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.es.xlf @@ -7,6 +7,11 @@ VT no controlado: {0}. + + Unable to retrieve the root folder. + Unable to retrieve the root folder. + + The service '{0}' must be installed for this feature to work. Ensure that this service is available. Debe instalar el servicio "{0}" para que esta funcionalidad funcione. Asegúrese de que este servicio está disponible. diff --git a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.fr.xlf index 7395ade7a7f..94223cf5369 100644 --- a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.fr.xlf @@ -7,6 +7,11 @@ VT non géré : {0}. + + Unable to retrieve the root folder. + Unable to retrieve the root folder. + + The service '{0}' must be installed for this feature to work. Ensure that this service is available. Le service '{0}' doit être installé afin que cette fonctionnalité soit activée. Assurez-vous que ce service est disponible. diff --git a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.it.xlf index 787109d0f62..13194ab781f 100644 --- a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.it.xlf @@ -7,6 +7,11 @@ VT non gestito: {0}. + + Unable to retrieve the root folder. + Unable to retrieve the root folder. + + The service '{0}' must be installed for this feature to work. Ensure that this service is available. Per poter usare questa funzionalità, è necessario aver installato il servizio '{0}'. Verificare che il servizio sia disponibile. diff --git a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.ja.xlf index 63866c47613..46275aba3d3 100644 --- a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.ja.xlf @@ -7,6 +7,11 @@ ハンドルされていない VT: {0} + + Unable to retrieve the root folder. + Unable to retrieve the root folder. + + The service '{0}' must be installed for this feature to work. Ensure that this service is available. この機能が動作するためにはサービス '{0}' をインストールする必要があります。サービスが利用可能であることを確認してください。 diff --git a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.ko.xlf index 904c031e3aa..415e99e6dce 100644 --- a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.ko.xlf @@ -7,6 +7,11 @@ 처리되지 않은 VT입니다. {0} + + Unable to retrieve the root folder. + Unable to retrieve the root folder. + + The service '{0}' must be installed for this feature to work. Ensure that this service is available. 이 기능을 제대로 사용하려면 '{0}' 서비스가 설치되어 있어야 합니다. 이 서비스를 사용할 수 있는지 확인하세요. diff --git a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.pl.xlf index a7035ccd1b7..099efe60030 100644 --- a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.pl.xlf @@ -7,6 +7,11 @@ Nieobsługiwany VT: {0}. + + Unable to retrieve the root folder. + Unable to retrieve the root folder. + + The service '{0}' must be installed for this feature to work. Ensure that this service is available. Usługa „{0}” musi być zainstalowana, aby ta funkcja działała. Sprawdź dostępność usługi. diff --git a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.pt-BR.xlf index c9e16a6a3e0..c41e6bc2dd7 100644 --- a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.pt-BR.xlf @@ -7,6 +7,11 @@ VT não tratado: {0}. + + Unable to retrieve the root folder. + Unable to retrieve the root folder. + + The service '{0}' must be installed for this feature to work. Ensure that this service is available. O serviço '{0}' deve estar instalado para que este recurso funcione. Verifique se esse serviço está disponível. diff --git a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.ru.xlf index 419926dd4b2..fcb5150c317 100644 --- a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.ru.xlf @@ -7,6 +7,11 @@ Необработанный VT: {0}. + + Unable to retrieve the root folder. + Unable to retrieve the root folder. + + The service '{0}' must be installed for this feature to work. Ensure that this service is available. Для работы этой возможности должна быть установлена служба "{0}". Убедитесь, что эта служба доступна. diff --git a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.tr.xlf index 60daa14cac1..6585c202c0a 100644 --- a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.tr.xlf @@ -7,6 +7,11 @@ İşlenmemiş VT: {0}. + + Unable to retrieve the root folder. + Unable to retrieve the root folder. + + The service '{0}' must be installed for this feature to work. Ensure that this service is available. Bu özelliğin çalışması için '{0}' hizmetinin yüklenmesi gerekiyor. Bu hizmetin kullanılabildiğinden emin olun. diff --git a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.zh-Hans.xlf index acb8292d5c7..ef2d24743c7 100644 --- a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.zh-Hans.xlf @@ -7,6 +7,11 @@ 未处理的 VT: {0}。 + + Unable to retrieve the root folder. + Unable to retrieve the root folder. + + The service '{0}' must be installed for this feature to work. Ensure that this service is available. 要使此功能工作,必须安装服务“{0}”。 请确保此服务可用。 diff --git a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.zh-Hant.xlf index ac1f19f427b..9c42c35b341 100644 --- a/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Primitives/src/Resources/xlf/SR.zh-Hant.xlf @@ -7,6 +7,11 @@ 未處理的 VT: {0}。 + + Unable to retrieve the root folder. + Unable to retrieve the root folder. + + The service '{0}' must be installed for this feature to work. Ensure that this service is available. 必須安裝服務 '{0}',才能讓這項功能運作。請確定這項服務可供使用。 diff --git a/src/System.Windows.Forms.Primitives/src/System.Windows.Forms.Primitives.csproj b/src/System.Windows.Forms.Primitives/src/System.Windows.Forms.Primitives.csproj index a9395d91100..502f1174f7d 100644 --- a/src/System.Windows.Forms.Primitives/src/System.Windows.Forms.Primitives.csproj +++ b/src/System.Windows.Forms.Primitives/src/System.Windows.Forms.Primitives.csproj @@ -21,6 +21,11 @@ See https://github.com/dotnet/winforms/issues/4649 --> $(NoWarn);IL2026;IL2050 + + $(NoWarn);CS9195 true true true diff --git a/src/System.Windows.Forms.Primitives/src/System/BufferScope.cs b/src/System.Windows.Forms.Primitives/src/System/BufferScope.cs index 4b7fe98c3d3..e7f14e806ff 100644 --- a/src/System.Windows.Forms.Primitives/src/System/BufferScope.cs +++ b/src/System.Windows.Forms.Primitives/src/System/BufferScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Buffers; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/System/CharacterConstants.cs b/src/System.Windows.Forms.Primitives/src/System/CharacterConstants.cs index 6feddc1d233..6be0d4dc364 100644 --- a/src/System.Windows.Forms.Primitives/src/System/CharacterConstants.cs +++ b/src/System.Windows.Forms.Primitives/src/System/CharacterConstants.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System; diff --git a/src/System.Windows.Forms.Primitives/src/System/Collections/Generic/ListConverter.cs b/src/System.Windows.Forms.Primitives/src/System/Collections/Generic/ListConverter.cs index f9177755d15..bee976be4ad 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Collections/Generic/ListConverter.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Collections/Generic/ListConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Collections.Generic; diff --git a/src/System.Windows.Forms.Primitives/src/System/ComponentModel/CompModSwitches.cs b/src/System.Windows.Forms.Primitives/src/System/ComponentModel/CompModSwitches.cs index ba157c278cd..05a1a1dcf1d 100644 --- a/src/System.Windows.Forms.Primitives/src/System/ComponentModel/CompModSwitches.cs +++ b/src/System.Windows.Forms.Primitives/src/System/ComponentModel/CompModSwitches.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel; diff --git a/src/System.Windows.Forms.Primitives/src/System/ComponentModel/Design/ComponentChangeServiceExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/ComponentModel/Design/ComponentChangeServiceExtensions.cs index 4f28c0197a4..aff812b99b4 100644 --- a/src/System.Windows.Forms.Primitives/src/System/ComponentModel/Design/ComponentChangeServiceExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/ComponentModel/Design/ComponentChangeServiceExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Primitives/src/System/ComponentModel/Design/Serialization/DesignerSerializationManagerHelper.cs b/src/System.Windows.Forms.Primitives/src/System/ComponentModel/Design/Serialization/DesignerSerializationManagerHelper.cs index 2c73f3f337f..d63c8b9909b 100644 --- a/src/System.Windows.Forms.Primitives/src/System/ComponentModel/Design/Serialization/DesignerSerializationManagerHelper.cs +++ b/src/System.Windows.Forms.Primitives/src/System/ComponentModel/Design/Serialization/DesignerSerializationManagerHelper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel.Design.Serialization { diff --git a/src/System.Windows.Forms.Primitives/src/System/ComponentModel/MemberDescriptorExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/ComponentModel/MemberDescriptorExtensions.cs index df9c76e052d..8ab3936c11b 100644 --- a/src/System.Windows.Forms.Primitives/src/System/ComponentModel/MemberDescriptorExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/ComponentModel/MemberDescriptorExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel; @@ -19,4 +18,34 @@ public static T? GetAttribute <[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.PublicFields)] T>( this MemberDescriptor descriptor) where T : Attribute => descriptor?.Attributes[typeof(T)] as T; + + public static bool TryGetValue(this PropertyDescriptor descriptor, object? component, out T? value) + { + if (descriptor.PropertyType == typeof(T)) + { + value = (T?)descriptor.GetValue(component); + return true; + } + + value = default; + return false; + } + + public static T? GetValue(this PropertyDescriptor descriptor, object? component) where T : class + { + if (descriptor.PropertyType == typeof(T)) + { + return (T?)descriptor.GetValue(component); + } + + return null; + } + + public static T? GetEditor(this PropertyDescriptor descriptor) => (T?)descriptor.GetEditor(typeof(T)); + + public static bool TryGetEditor(this PropertyDescriptor descriptor, [NotNullWhen(true)] out T? value) + { + value = (T?)descriptor.GetEditor(typeof(T)); + return value is not null; + } } diff --git a/src/System.Windows.Forms.Primitives/src/System/ComponentModel/TypeDescriptorHelper.cs b/src/System.Windows.Forms.Primitives/src/System/ComponentModel/TypeDescriptorHelper.cs index b73177010b3..5f62f2ed09d 100644 --- a/src/System.Windows.Forms.Primitives/src/System/ComponentModel/TypeDescriptorHelper.cs +++ b/src/System.Windows.Forms.Primitives/src/System/ComponentModel/TypeDescriptorHelper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel; @@ -14,4 +13,19 @@ public static bool TryGetAttribute attribute = TypeDescriptor.GetAttributes(component)[typeof(T)] as T; return attribute is not null; } + + public static bool TryGetPropertyValue( + object component, + string name, + out T? value) + { + PropertyDescriptor? property = TypeDescriptor.GetProperties(component)[name]; + if (property is not null && property.TryGetValue(component, out value)) + { + return true; + } + + value = default; + return false; + } } diff --git a/src/Common/src/TraceSwitchExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/Diagnostics/TraceSwitchExtensions.cs similarity index 98% rename from src/Common/src/TraceSwitchExtensions.cs rename to src/System.Windows.Forms.Primitives/src/System/Diagnostics/TraceSwitchExtensions.cs index befccd727b0..90df444fa47 100644 --- a/src/Common/src/TraceSwitchExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Diagnostics/TraceSwitchExtensions.cs @@ -1,12 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.CompilerServices; using System.Text; -namespace System.Windows.Forms; +namespace System.Diagnostics; internal static class TraceSwitchExtensions { diff --git a/src/System.Windows.Forms.Primitives/src/System/DisposeHelper.cs b/src/System.Windows.Forms.Primitives/src/System/DisposeHelper.cs new file mode 100644 index 00000000000..e9d22a9f06b --- /dev/null +++ b/src/System.Windows.Forms.Primitives/src/System/DisposeHelper.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.CompilerServices; +using Windows.Win32.System.Com; + +namespace System; + +internal static class DisposeHelper +{ + /// + /// Sets to null before disposing it. Useful for guarding against field + /// access when disposing the field. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static void NullAndDispose(ref T? disposable) where T : class, IDisposable + { + IDisposable? localDisposable = disposable; + disposable = null; + localDisposable?.Dispose(); + } + + /// + /// Sets to null before releasing it. Useful for guarding against field + /// access when releasing the field. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static unsafe void NullAndRelease(ref T* comPointer) where T : unmanaged, IComIID + { + IUnknown* localComPointer = (IUnknown*)comPointer; + comPointer = null; + if (localComPointer is not null) + { + localComPointer->Release(); + } + } +} diff --git a/src/System.Windows.Forms.Primitives/src/System/Drawing/ColorExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/Drawing/ColorExtensions.cs index ec0a26a542f..ff4be4f0383 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Drawing/ColorExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Drawing/ColorExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/System/EasyPoint.cs b/src/System.Windows.Forms.Primitives/src/System/EasyPoint.cs index 836d22351c9..72c6d645bff 100644 --- a/src/System.Windows.Forms.Primitives/src/System/EasyPoint.cs +++ b/src/System.Windows.Forms.Primitives/src/System/EasyPoint.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; @@ -16,7 +15,7 @@ internal readonly struct EasyPoint public EasyPoint(int x, int y) => (X, Y) = (x, y); public EasyPoint((int X, int Y) point) => (X, Y) = point; public void Deconstruct(out int x, out int y) => (x, y) = (X, Y); - public static implicit operator Point(in EasyPoint point) => new Point(point.X, point.Y); - public static implicit operator EasyPoint(Point point) => new EasyPoint(point.X, point.Y); - public static implicit operator EasyPoint(in (int X, int Y) point) => new EasyPoint(point); + public static implicit operator Point(in EasyPoint point) => new(point.X, point.Y); + public static implicit operator EasyPoint(Point point) => new(point.X, point.Y); + public static implicit operator EasyPoint(in (int X, int Y) point) => new(point); } diff --git a/src/System.Windows.Forms.Primitives/src/System/EnumExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/EnumExtensions.cs index 4602f277829..990d3fdb163 100644 --- a/src/System.Windows.Forms.Primitives/src/System/EnumExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/EnumExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/System.Windows.Forms.Primitives/src/System/ExceptionExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/ExceptionExtensions.cs index e6414e40136..3c94f041371 100644 --- a/src/System.Windows.Forms.Primitives/src/System/ExceptionExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/ExceptionExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System; diff --git a/src/System.Windows.Forms.Primitives/src/System/IO/BinaryReaderExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/IO/BinaryReaderExtensions.cs index 60d985c11cb..88e71ef4c27 100644 --- a/src/System.Windows.Forms.Primitives/src/System/IO/BinaryReaderExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/IO/BinaryReaderExtensions.cs @@ -1,10 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. +using System.Runtime.CompilerServices; using System.Runtime.Serialization; -using System.Windows.Forms.BinaryFormat; - namespace System.IO; internal static class BinaryReaderExtensions @@ -14,7 +12,34 @@ internal static class BinaryReaderExtensions /// /// The data was invalid. public static unsafe DateTime ReadDateTime(this BinaryReader reader) - => BinaryFormatReader.CreateDateTimeFromData(reader.ReadInt64()); + => CreateDateTimeFromData(reader.ReadInt64()); + + /// + /// Creates a object from raw data with validation. + /// + /// was invalid. + private static DateTime CreateDateTimeFromData(long data) + { + // Copied from System.Runtime.Serialization.Formatters.Binary.BinaryParser + + // Use DateTime's public constructor to validate the input, but we + // can't return that result as it strips off the kind. To address + // that, store the value directly into a DateTime via an unsafe cast. + // See BinaryFormatterWriter.WriteDateTime for details. + + try + { + const long TicksMask = 0x3FFFFFFFFFFFFFFF; + _ = new DateTime(data & TicksMask); + } + catch (ArgumentException ex) + { + // Bad data + throw new SerializationException(ex.Message, ex); + } + + return Unsafe.As(ref data); + } /// /// Returns the remaining amount of bytes in the given . diff --git a/src/System.Windows.Forms.Primitives/src/System/IO/BinaryWriterExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/IO/BinaryWriterExtensions.cs index e6132f18f14..2de0a30d1c8 100644 --- a/src/System.Windows.Forms.Primitives/src/System/IO/BinaryWriterExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/IO/BinaryWriterExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/System.Windows.Forms.Primitives/src/System/IntrinsicExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/IntrinsicExtensions.cs index 4760737c46d..9df2276a874 100644 --- a/src/System.Windows.Forms.Primitives/src/System/IntrinsicExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/IntrinsicExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Numerics; diff --git a/src/System.Windows.Forms.Primitives/src/System/LocalAppContextSwitches/LocalAppContextSwitches.cs b/src/System.Windows.Forms.Primitives/src/System/LocalAppContextSwitches/LocalAppContextSwitches.cs index 0e138037222..7c4e24a2780 100644 --- a/src/System.Windows.Forms.Primitives/src/System/LocalAppContextSwitches/LocalAppContextSwitches.cs +++ b/src/System.Windows.Forms.Primitives/src/System/LocalAppContextSwitches/LocalAppContextSwitches.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.Versioning; diff --git a/src/System.Windows.Forms.Primitives/src/System/ServiceExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/ServiceExtensions.cs index 6a4b711daf6..a7893b86336 100644 --- a/src/System.Windows.Forms.Primitives/src/System/ServiceExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/ServiceExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms.Primitives/src/System/TrimmingConstants.cs b/src/System.Windows.Forms.Primitives/src/System/TrimmingConstants.cs index dec5a8a9ee1..8c106b7ed3a 100644 --- a/src/System.Windows.Forms.Primitives/src/System/TrimmingConstants.cs +++ b/src/System.Windows.Forms.Primitives/src/System/TrimmingConstants.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System; diff --git a/src/System.Windows.Forms.Primitives/src/System/VirtualKeyUtilities.cs b/src/System.Windows.Forms.Primitives/src/System/VirtualKeyUtilities.cs index 5ad917bf9f0..b07f3d55e22 100644 --- a/src/System.Windows.Forms.Primitives/src/System/VirtualKeyUtilities.cs +++ b/src/System.Windows.Forms.Primitives/src/System/VirtualKeyUtilities.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.UI.Input.KeyboardAndMouse; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/AccessibiltyExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/AccessibiltyExtensions.cs index cf4fed7e680..855b26fbd20 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/AccessibiltyExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/AccessibiltyExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Com; using Accessibility; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/ApplyGraphicsProperties.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/ApplyGraphicsProperties.cs index b96c1fd5932..f980a01f352 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/ApplyGraphicsProperties.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/ApplyGraphicsProperties.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/AutomationLiveSetting.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/AutomationLiveSetting.cs index 5d7963e7a87..cfd6d9623fe 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/AutomationLiveSetting.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/AutomationLiveSetting.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Automation; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/AutomationNotificationKind.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/AutomationNotificationKind.cs index 39013c1276b..67e88d86737 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/AutomationNotificationKind.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/AutomationNotificationKind.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Automation; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/AutomationNotificationProcessing.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/AutomationNotificationProcessing.cs index a2ba1a67c72..a4fea0341e0 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/AutomationNotificationProcessing.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/AutomationNotificationProcessing.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Automation; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/CapStyle.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/CapStyle.cs index 9fd9c3de62b..4f85ea644ef 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/CapStyle.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/CapStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Automation; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/HorizontalTextAlignment.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/HorizontalTextAlignment.cs index 0d1d4db453d..f41e3f6d4c4 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/HorizontalTextAlignment.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/HorizontalTextAlignment.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Automation; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/IAutomationLiveRegion.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/IAutomationLiveRegion.cs index 117d5340d5f..5a9f0a828d0 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/IAutomationLiveRegion.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/IAutomationLiveRegion.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Automation; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/TextDecorationLineStyle.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/TextDecorationLineStyle.cs index 5ce892fbf35..46a6544c3fd 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/TextDecorationLineStyle.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/TextDecorationLineStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Automation; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextProvider.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextProvider.cs index 786d39dcf70..4cf77006476 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using Windows.Win32.UI.Input.KeyboardAndMouse; @@ -106,7 +105,7 @@ public int SendInput(int inputs, ref INPUT input, int size) public unsafe int SendKeyboardInputVK(VIRTUAL_KEY vk, bool press) { - INPUT keyboardInput = default(INPUT); + INPUT keyboardInput = default; keyboardInput.type = INPUT_TYPE.INPUT_KEYBOARD; keyboardInput.Anonymous.ki.wVk = vk; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextProvider2.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextProvider2.cs index 19f2fefcfb2..fa90c4a18ee 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextProvider2.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextProvider2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextRange.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextRange.cs index 8572265ba4b..4477c78d9cd 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextRange.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextRange.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -1045,8 +1044,11 @@ private int MoveEndpointBackward(int index, TextUnit unit, int count, out int mo /// private void MoveTo(int start, int end) { - _start = start >= 0 ? start : throw new ArgumentOutOfRangeException(nameof(start)); - _end = end >= start ? end : throw new ArgumentOutOfRangeException(nameof(end)); + ArgumentOutOfRangeException.ThrowIfNegative(start); + ArgumentOutOfRangeException.ThrowIfLessThan(end, start); + + _start = start; + _end = end; } private void ValidateEndpoints() diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArrayInfo.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArrayInfo.cs index 15fbc058dee..d67e97558f6 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArrayInfo.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArrayInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArrayRecord.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArrayRecord.cs index bd5e21a371b..940235aa104 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArrayRecord.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArrayRecord.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArraySingleObject.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArraySingleObject.cs index aa6af7b191f..d70b779bf0f 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArraySingleObject.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArraySingleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArraySinglePrimitive.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArraySinglePrimitive.cs index 61572856414..60ad6d74e96 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArraySinglePrimitive.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArraySinglePrimitive.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArraySingleString.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArraySingleString.cs index af0b679dde8..b5cb769a638 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArraySingleString.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ArraySingleString.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryArray.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryArray.cs index 675009212fe..a5d16f319f3 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryArray.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryArray.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryArrayType.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryArrayType.cs index adf0b7c3ee1..7d001640204 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryArrayType.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryArrayType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryFormatReader.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryFormatReader.cs deleted file mode 100644 index 6f539e7b3bf..00000000000 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryFormatReader.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.CompilerServices; -using System.Runtime.Serialization; - -namespace System.Windows.Forms.BinaryFormat; - -/// -/// Reader that reads specific types in binary format without using the BinaryFormatter. -/// -internal static class BinaryFormatReader -{ - /// - /// Creates a object from raw data with validation. - /// - /// was invalid. - internal static DateTime CreateDateTimeFromData(long data) - { - // Copied from System.Runtime.Serialization.Formatters.Binary.BinaryParser - - // Use DateTime's public constructor to validate the input, but we - // can't return that result as it strips off the kind. To address - // that, store the value directly into a DateTime via an unsafe cast. - // See BinaryFormatterWriter.WriteDateTime for details. - - try - { - const long TicksMask = 0x3FFFFFFFFFFFFFFF; - _ = new DateTime(data & TicksMask); - } - catch (ArgumentException ex) - { - // Bad data - throw new SerializationException(ex.Message, ex); - } - - return Unsafe.As(ref data); - } -} diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryFormatWriter.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryFormatWriter.cs index d341c81a4e5..9d16410c2c3 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryFormatWriter.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryFormatWriter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Drawing; @@ -433,7 +432,9 @@ public static bool TryWriteHashtable(Stream stream, Hashtable hashtable) /// Primitive types are anything in the enum. /// /// - /// contained non-primitive values. + /// + /// contained non-primitive values or a custom comparer or hash code provider. + /// public static void WritePrimitiveHashtable(Stream stream, Hashtable hashtable) { // Get the ISerializable data from the hashtable. This way we don't have to worry about @@ -445,6 +446,12 @@ public static void WritePrimitiveHashtable(Stream stream, Hashtable hashtable) hashtable.GetObjectData(info, default); #pragma warning restore SYSLIB0051 + if (info.GetValue("Comparer") is not null + || info.GetValue("HashCodeProvider") is not null) + { + throw new ArgumentException("Hashtable has custom Comparer or HashCodeProvider.", nameof(hashtable)); + } + // Build up the key and value data object[] keys = info.GetValue("Keys")!; object?[] values = info.GetValue("Values")!; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryFormattedObject.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryFormattedObject.cs index 5d7bd41c193..4943aaaafc8 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryFormattedObject.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryFormattedObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.Serialization; using System.Text; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryFormattedObjectExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryFormattedObjectExtensions.cs index 408bc5cee4e..5385fa9d5f2 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryFormattedObjectExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryFormattedObjectExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Drawing; @@ -393,7 +392,9 @@ static bool Get(BinaryFormattedObject format, [NotNullWhen(true)] out object? ha { hashtable = null; - if (format.RecordCount < 5 + // Note that hashtables with custom comparers and/or hash code providers will have that information before + // the value pair arrays. + if (format.RecordCount != 5 || format[1] is not SystemClassWithMembersAndTypes classInfo || classInfo.Name != TypeInfo.HashtableType || format[2] is not ArraySingleObject keys diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryLibrary.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryLibrary.cs index 73910f82543..53a2890832e 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryLibrary.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryLibrary.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryObjectString.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryObjectString.cs index 441ca27561e..01114c7de2c 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryObjectString.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryObjectString.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryType.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryType.cs index 415c6206369..f5725edb980 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryType.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/BinaryType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassInfo.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassInfo.cs index a9093bd63a7..a2f5d8f6d09 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassInfo.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassRecord.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassRecord.cs index 82a853e32cf..f2497f4356f 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassRecord.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassRecord.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassTypeInfo.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassTypeInfo.cs index b7cacf61aae..b2edcb0f7b7 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassTypeInfo.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassTypeInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassWithId.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassWithId.cs index e779a18cbfe..e02a4d30d00 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassWithId.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassWithId.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.Serialization; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassWithMembers.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassWithMembers.cs index 6c844543244..7613e2db5f7 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassWithMembers.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassWithMembers.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassWithMembersAndTypes.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassWithMembersAndTypes.cs index 31f721f7d37..d0e1ff287df 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassWithMembersAndTypes.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ClassWithMembersAndTypes.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/IBinaryFormatParseable.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/IBinaryFormatParseable.cs index 3cc3e15b62b..7347211a0ba 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/IBinaryFormatParseable.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/IBinaryFormatParseable.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/IBinaryWriteable.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/IBinaryWriteable.cs index 814dc600668..4129b2395e5 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/IBinaryWriteable.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/IBinaryWriteable.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/IRecord.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/IRecord.cs index afc7974a67f..7dba711576c 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/IRecord.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/IRecord.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MemberPrimitiveTyped.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MemberPrimitiveTyped.cs index e3dcd88dcac..13f62235da1 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MemberPrimitiveTyped.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MemberPrimitiveTyped.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MemberReference.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MemberReference.cs index 4295a367c50..d2c7a44ff0a 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MemberReference.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MemberReference.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MemberTypeInfo.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MemberTypeInfo.cs index 81369a7d1ec..dad6be7d973 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MemberTypeInfo.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MemberTypeInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Runtime.Serialization; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MessageEnd.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MessageEnd.cs index e1c8e8764ec..c19eabf3e3a 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MessageEnd.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/MessageEnd.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/NullRecord.ObjectNullMultiple.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/NullRecord.ObjectNullMultiple.cs index 2f4d1025fac..e4581efa1c6 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/NullRecord.ObjectNullMultiple.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/NullRecord.ObjectNullMultiple.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/NullRecord.ObjectNullMultiple256.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/NullRecord.ObjectNullMultiple256.cs index 834f8f42bd2..2de823c56b6 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/NullRecord.ObjectNullMultiple256.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/NullRecord.ObjectNullMultiple256.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/NullRecord.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/NullRecord.cs index 4bffaaa0e44..3944e4cddc1 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/NullRecord.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/NullRecord.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ObjectNull.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ObjectNull.cs index cb296c0a6c1..07bef61ba09 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ObjectNull.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/ObjectNull.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/PrimitiveType.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/PrimitiveType.cs index e633bcf702d..4d29298111d 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/PrimitiveType.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/PrimitiveType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Record.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Record.cs index a856c79967a..ec35530e4ec 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Record.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Record.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; using System.Runtime.Serialization; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/RecordMap.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/RecordMap.cs index b4e9880c164..47b5436bccb 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/RecordMap.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/RecordMap.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/RecordType.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/RecordType.cs index f2c4a6ab744..9fadc584f68 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/RecordType.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/RecordType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/SerializationHeader.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/SerializationHeader.cs index b16237ebf19..acf108477c0 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/SerializationHeader.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/SerializationHeader.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/BinaryFormatWriterScope.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/BinaryFormatWriterScope.cs index 7474c73470b..1c6361be045 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/BinaryFormatWriterScope.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/BinaryFormatWriterScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Text; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/FormatterConverterStub.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/FormatterConverterStub.cs index 8a397a8664f..1462524e78e 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/FormatterConverterStub.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/FormatterConverterStub.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.Serialization; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/ListConverter.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/ListConverter.cs index eed46959526..d7335c51917 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/ListConverter.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/ListConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/SerializationExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/SerializationExtensions.cs index c3997455918..89132feb8ff 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/SerializationExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/SerializationExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.ExceptionServices; using System.Runtime.Serialization; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/StringRecordsCollection.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/StringRecordsCollection.cs index 050363098a2..1126e67afbc 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/StringRecordsCollection.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/StringRecordsCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/TypeInfo.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/TypeInfo.cs index 65830cb636f..c6de1c6f181 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/TypeInfo.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/Support/TypeInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/SystemClassWithMembers.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/SystemClassWithMembers.cs index cc27250c12b..8c29a202b19 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/SystemClassWithMembers.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/SystemClassWithMembers.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/SystemClassWithMembersAndTypes.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/SystemClassWithMembersAndTypes.cs index 74e5ac6a545..eac360f9d47 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/SystemClassWithMembersAndTypes.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/BinaryFormat/SystemClassWithMembersAndTypes.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Count.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Count.cs index 5b323969a84..e82fa7f72f3 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Count.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Count.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextExtensions.cs index 0bd25003652..76d8ecbd3f2 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; @@ -89,7 +88,7 @@ internal static unsafe void DrawLines(this HDC hdc, HPEN hpen, ReadOnlySpan using PInvoke.SetBkModeScope bkScope = new(hdc, BACKGROUND_MODE.TRANSPARENT); using PInvoke.SelectObjectScope selection = new(hdc, (HGDIOBJ)hpen.Value); - Point oldPoint = default(Point); + Point oldPoint = default; for (int i = 0; i < lines.Length; i += 4) { diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextHdcScope.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextHdcScope.cs index 077eeae68e9..c2857f30906 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextHdcScope.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextHdcScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DisposalTracking.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DisposalTracking.cs index 80159a08955..423befbf833 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DisposalTracking.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DisposalTracking.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/FileDialogCustomPlace.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/FileDialogCustomPlace.cs index 19fac5832cb..c063e8eb746 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/FileDialogCustomPlace.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/FileDialogCustomPlace.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/FileDialogCustomPlacesCollection.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/FileDialogCustomPlacesCollection.cs index 611c4075873..13d1ab6f4c7 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/FileDialogCustomPlacesCollection.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/FileDialogCustomPlacesCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.ObjectModel; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/FontExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/FontExtensions.cs index d1f36937745..2a653eaa903 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/FontExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/FontExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GdiPlus/GdiPlusCache.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GdiPlus/GdiPlusCache.cs index f9b3763c751..a0928e6a199 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GdiPlus/GdiPlusCache.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GdiPlus/GdiPlusCache.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GdiPlus/PenCache.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GdiPlus/PenCache.cs index 2e82febd38f..9c8e073f51e 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GdiPlus/PenCache.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GdiPlus/PenCache.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GdiPlus/SolidBrushCache.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GdiPlus/SolidBrushCache.cs index 593b6ed3bdc..e93762ff8eb 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GdiPlus/SolidBrushCache.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GdiPlus/SolidBrushCache.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GraphicsClipScope.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GraphicsClipScope.cs index 88022ff635a..aa7dc7a9d8a 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GraphicsClipScope.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GraphicsClipScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GraphicsStateScope.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GraphicsStateScope.cs index cba87174472..ff84a7929d3 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GraphicsStateScope.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/GraphicsStateScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Drawing2D; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/HighDpiMode.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/HighDpiMode.cs index 6fece1a75d1..7b10accefef 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/HighDpiMode.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/HighDpiMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #if WINFORMS_ANALYZERS namespace System.Windows.Forms.Analyzers; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/IExtender.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/IExtender.cs index 3db534a6d93..877baf75d15 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/IExtender.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/IExtender.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/IGraphicsHdcProvider.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/IGraphicsHdcProvider.cs index 13fb7b3f756..e7a8c4cecec 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/IGraphicsHdcProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/IGraphicsHdcProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Drawing2D; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Id.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Id.cs index 5572cbccf62..ce6c7c52e90 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Id.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Id.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ArgumentValidation.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ArgumentValidation.cs index 6deead8a4f6..13253db3fd6 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ArgumentValidation.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ArgumentValidation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ClientUtils.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ClientUtils.cs index 65233e14ad1..2a342b6d8e6 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ClientUtils.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ClientUtils.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.DpiAwarenessContext.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.DpiAwarenessContext.cs index c8fda886d3f..00c6fd25173 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.DpiAwarenessContext.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.DpiAwarenessContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.DpiAwarenessScope.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.DpiAwarenessScope.cs index b77830238d9..5ef9f28d995 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.DpiAwarenessScope.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.DpiAwarenessScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.cs index 5ec505664de..ad21a963c3d 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Drawing2D; @@ -488,4 +487,26 @@ internal static bool SetWinformsApplicationDpiAwareness(HighDpiMode highDpiMode) return success; } + + /// + /// Create a new button bitmap scaled for the device units. + /// Note: original image might be disposed. + /// + public static Image? ScaleButtonImageLogicalToDevice(Image? buttonImage) + { + if (buttonImage is null) + { + return null; + } + + Bitmap? buttonBitmap = buttonImage as Bitmap; + if (buttonBitmap is null) + { + return null; + } + + Bitmap deviceBitmap = CreateScaledBitmap(buttonBitmap); + buttonImage.Dispose(); + return deviceBitmap; + } } diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/MessageDecoder.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/MessageDecoder.cs index 341497559da..088fb238494 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/MessageDecoder.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/MessageDecoder.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/NativeMethods.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/NativeMethods.cs index 00b212ba84b..22f134cb63e 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/NativeMethods.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/NativeMethods.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/OsVersion.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/OsVersion.cs index 62184c92b61..de3a565646e 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/OsVersion.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/OsVersion.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.Versioning; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/SpanHelpers.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/SpanHelpers.cs index a8671e62dcb..393f0c85bc2 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/SpanHelpers.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/SpanHelpers.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ThemingScope.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ThemingScope.cs index 1347f46509f..97f49340895 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ThemingScope.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ThemingScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.ApplicationInstallationAndServicing; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/UnicodeCharBuffer.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/UnicodeCharBuffer.cs index 91fd53dbc17..e9950908990 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/UnicodeCharBuffer.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/UnicodeCharBuffer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; @@ -31,7 +30,7 @@ public string GetString() i++; } - string result = new string(_buffer, _offset, i - _offset); + string result = new(_buffer, _offset, i - _offset); if (i < _buffer.Length) { i++; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/UnsafeNativeMethods.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/UnsafeNativeMethods.cs index d112d3f0e80..817d87aa966 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/UnsafeNativeMethods.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/UnsafeNativeMethods.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/WeakRefCollection.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/WeakRefCollection.cs index 9f2d360742e..567f90db366 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/WeakRefCollection.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/WeakRefCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; @@ -106,7 +105,7 @@ public override bool Equals(object? obj) public override int GetHashCode() { - var hash = default(HashCode); + HashCode hash = default; foreach (WeakRefObject? o in InnerList) { hash.Add(o); diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Message.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Message.cs index 12026a1ceb8..f0ded75b306 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Message.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Message.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; @@ -32,7 +31,7 @@ public struct Message : IEquatable, IHandle public int Msg { - get => (int)MsgInternal; + readonly get => (int)MsgInternal; set => MsgInternal = (MessageId)value; } @@ -58,7 +57,7 @@ public int Msg #endif public IntPtr WParam { - get => (nint)(nuint)WParamInternal; + readonly get => (nint)(nuint)WParamInternal; set => WParamInternal = (nuint)value; } @@ -69,7 +68,7 @@ public IntPtr WParam #endif public IntPtr LParam { - get => LParamInternal; + readonly get => LParamInternal; set => LParamInternal = value; } @@ -80,7 +79,7 @@ public IntPtr LParam #endif public IntPtr Result { - get => ResultInternal; + readonly get => ResultInternal; set => ResultInternal = (LRESULT)value; } @@ -89,7 +88,7 @@ public IntPtr Result /// /// Gets the value, and converts the value to an object. /// - public object? GetLParam( + public readonly object? GetLParam( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type cls) => Marshal.PtrToStructure(LParamInternal, cls); @@ -122,7 +121,7 @@ public static Message Create(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam) return m; } - public override bool Equals(object? o) + public override readonly bool Equals(object? o) { if (o is not Message m) { @@ -132,7 +131,7 @@ public override bool Equals(object? o) return Equals(m); } - public bool Equals(Message other) + public readonly bool Equals(Message other) => HWnd == other.HWnd && MsgInternal == other.MsgInternal && WParamInternal == other.WParamInternal @@ -143,9 +142,9 @@ public bool Equals(Message other) public static bool operator !=(Message a, Message b) => !a.Equals(b); - public override int GetHashCode() => HashCode.Combine(HWnd, Msg); + public override readonly int GetHashCode() => HashCode.Combine(HWnd, Msg); - public override string ToString() => MessageDecoder.ToString(this); + public override readonly string ToString() => MessageDecoder.ToString(this); internal MSG ToMSG() => new() { diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/NonNullCollection.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/NonNullCollection.cs index 5e565c822cf..30c70cc2839 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/NonNullCollection.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/NonNullCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/ObjectCache.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/ObjectCache.cs index cfcd5cc2622..5d2980f33fd 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/ObjectCache.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/ObjectCache.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Padding.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Padding.cs index 8fd92856e1f..be7b7e3dc9f 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Padding.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Padding.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -18,7 +17,7 @@ public struct Padding : IEquatable private int _right; // Do NOT rename (binary serialization). private int _bottom; // Do NOT rename (binary serialization). - public static readonly Padding Empty = new Padding(0); + public static readonly Padding Empty = new(0); public Padding(int all) { @@ -40,7 +39,7 @@ public Padding(int left, int top, int right, int bottom) [RefreshProperties(RefreshProperties.All)] public int All { - get => _all ? _top : -1; + readonly get => _all ? _top : -1; set { if (_all != true || _top != value) @@ -56,7 +55,7 @@ public int All [RefreshProperties(RefreshProperties.All)] public int Bottom { - get => _all ? _top : _bottom; + readonly get => _all ? _top : _bottom; set { if (_all || _bottom != value) @@ -72,7 +71,7 @@ public int Bottom [RefreshProperties(RefreshProperties.All)] public int Left { - get => _all ? _top : _left; + readonly get => _all ? _top : _left; set { if (_all || _left != value) @@ -88,7 +87,7 @@ public int Left [RefreshProperties(RefreshProperties.All)] public int Right { - get => _all ? _top : _right; + readonly get => _all ? _top : _right; set { if (_all || _right != value) @@ -104,7 +103,7 @@ public int Right [RefreshProperties(RefreshProperties.All)] public int Top { - get => _top; + readonly get => _top; set { if (_all || _top != value) @@ -118,19 +117,19 @@ public int Top } [Browsable(false)] - public int Horizontal => Left + Right; + public readonly int Horizontal => Left + Right; [Browsable(false)] - public int Vertical => Top + Bottom; + public readonly int Vertical => Top + Bottom; [Browsable(false)] - public Size Size => new Size(Horizontal, Vertical); + public readonly Size Size => new(Horizontal, Vertical); public static Padding Add(Padding p1, Padding p2) => p1 + p2; public static Padding Subtract(Padding p1, Padding p2) => p1 - p2; - public override bool Equals(object? other) + public override readonly bool Equals(object? other) { if (other is not Padding otherPadding) { @@ -140,7 +139,7 @@ public override bool Equals(object? other) return Equals(otherPadding); } - public bool Equals(Padding other) + public readonly bool Equals(Padding other) => Left == other.Left && Top == other.Top && Right == other.Right @@ -175,9 +174,9 @@ public bool Equals(Padding other) /// public static bool operator !=(Padding p1, Padding p2) => !(p1 == p2); - public override int GetHashCode() => HashCode.Combine(Left, Top, Right, Bottom); + public override readonly int GetHashCode() => HashCode.Combine(Left, Top, Right, Bottom); - public override string ToString() => $"{{Left={Left},Top={Top},Right={Right},Bottom={Bottom}}}"; + public override readonly string ToString() => $"{{Left={Left},Top={Top},Right={Right},Bottom={Bottom}}}"; private void ResetAll() => All = 0; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/PaddingConverter.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/PaddingConverter.cs index 09f07f83276..33e2187db6c 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/PaddingConverter.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/PaddingConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.CacheEntry.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.CacheEntry.cs index 0cf0e355839..41e1546920a 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.CacheEntry.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.CacheEntry.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.Scope.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.Scope.cs index f7576639aa6..860244e6cfe 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.Scope.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.Scope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.cs index fdcbece8fa0..90b07fcbea1 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; @@ -22,7 +21,7 @@ namespace System.Windows.Forms; /// internal abstract partial class RefCountedCache : IDisposable { - private readonly SinglyLinkedList _list = new SinglyLinkedList(); + private readonly SinglyLinkedList _list = new(); private readonly int _softLimit; private readonly int _hardLimit; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/ScreenOrientation.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/ScreenOrientation.cs index 0ca7ae3ca2a..ebda87083a9 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/ScreenOrientation.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/ScreenOrientation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SinglyLinkedList.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SinglyLinkedList.cs index 8f7e9cfc7a6..2b89fe5f947 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SinglyLinkedList.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SinglyLinkedList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; @@ -55,7 +54,7 @@ public Node AddLast(T value) return node; } - public Enumerator GetEnumerator() => new Enumerator(this); + public Enumerator GetEnumerator() => new(this); public class Node { diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SystemDrawingExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SystemDrawingExtensions.cs index a5cd5270d9e..b4ddbbbcf70 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SystemDrawingExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SystemDrawingExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Drawing2D; @@ -117,7 +116,7 @@ internal static Pen CreateStaticPen(this Color color, DashStyle dashStyle, float /// Not strictly needed (yet), but allows using the same pattern for all pens. /// internal static Pen CreateStaticPen(this Brush brush, float width = 1.0f) - => new Pen(brush, width); + => new(brush, width); /// /// Creates a . If is a system color, makes a static copy of diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/TextMetrics.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/TextMetrics.cs index a34527bd4fb..9e815f88805 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/TextMetrics.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/TextMetrics.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/TextMetricsCharacterSet.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/TextMetricsCharacterSet.cs index f70704b0a0d..b9c872226b3 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/TextMetricsCharacterSet.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/TextMetricsCharacterSet.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/TextMetricsPitchAndFamilyValues.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/TextMetricsPitchAndFamilyValues.cs index 9c2bd0c5534..7d6cf886bd1 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/TextMetricsPitchAndFamilyValues.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/TextMetricsPitchAndFamilyValues.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/ThemeSizeType.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/ThemeSizeType.cs index 177d4bca2dc..9a98f21da8e 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/ThemeSizeType.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/VisualStyles/ThemeSizeType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/ComHelpers.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/ComHelpers.cs index 0cc0607ea02..bf52a5cca69 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/ComHelpers.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/ComHelpers.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.System.Com; @@ -13,6 +12,15 @@ internal static unsafe partial class ComHelpers // // using var stream = GetComScope(obj, out bool success); + /// + /// Returns if built-in COM interop is supported. When using AOT or trimming this will + /// return . + /// + internal static bool BuiltInComSupported { get; } + = AppContext.TryGetSwitch("System.Runtime.InteropServices.BuiltInComInterop.IsSupported", out bool supported) + ? supported + : true; + /// /// Gets a pointer for the specified for the given . Throws if /// the desired pointer can not be obtained. @@ -52,6 +60,8 @@ internal static ComScope TryGetComScope(object? @object, out HRESULT hr) w /// /// Queries for the given interface and releases it. + /// Note that this method should only be used for the purposes of checking if the object supports a given interface. + /// If that interface is needed, it is best try to get the ComScope directly to avoid querying twice. /// internal static bool SupportsInterface(object? @object) where T : unmanaged, IComIID { @@ -181,8 +191,7 @@ internal static bool TryGetManagedInterface( return true; } - // Fall back to Marshal. - @interface = (TWrapper)Marshal.GetObjectForIUnknown((nint)unknown); + @interface = (TWrapper)GetObjectForIUnknown(unknown); return true; } catch (Exception ex) @@ -214,6 +223,31 @@ internal static bool WrapsManagedObject(object @object, IUnknown* unknown) return ccw.Value == unknown; } + /// + /// capable wrapper for . + /// + /// is . + internal static object GetObjectForIUnknown(IUnknown* unknown) + { + if (unknown is null) + { + throw new ArgumentNullException(nameof(unknown)); + } + + if (BuiltInComSupported) + { + return Marshal.GetObjectForIUnknown((nint)unknown); + } + else + { + // Analagous to ComInterfaceMarshaller.ConvertToManaged(unknown), but we need our own strategy. + return Interop.WinFormsComStrategy.Instance.GetOrCreateObjectForComInstance((nint)unknown, CreateObjectFlags.Unwrap); + } + } + + /// + /// vtable population hook for CsWin32's generated implementation. + /// static partial void PopulateIUnknownImpl(IUnknown.Vtbl* vtable) where TComInterface : unmanaged { diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ATOM.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ATOM.cs index f7ad868550d..0dec72048e7 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ATOM.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ATOM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.Foundation; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/AgileComPointer.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/AgileComPointer.cs index 59450ef23d5..4c7cd0688b6 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/AgileComPointer.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/AgileComPointer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Com; @@ -15,6 +14,11 @@ namespace Windows.Win32.Foundation; /// safely finalized when needed. Finalization should be avoided whenever possible for performance and timely /// resource release (that is, this class should be disposed). /// +/// +/// Fields should be nulled out before calling . Releasing the COM pointer during disposal +/// can result in callbacks to containing classes. Rather than evaluate the risk of this for every class, always +/// follow this pattern. facilitates doing this safely. +/// /// internal unsafe class AgileComPointer : #if DEBUG @@ -24,8 +28,20 @@ internal unsafe class AgileComPointer : where TInterface : unmanaged, IComIID { private uint _cookie; + private readonly TInterface* _originalPointer; - public TInterface* OriginalHandle { get; } + /// + /// Returns if the given is the same pointer this + /// was created from. + /// + /// + /// + /// This is useful in avoiding recreating a new for the same + /// object. + /// + /// + public bool MatchesOriginalPointer(TInterface* @interface) + => _cookie != 0 && @interface == _originalPointer; #if DEBUG public AgileComPointer(TInterface* @interface, bool takeOwnership, bool trackDisposal = true) @@ -35,7 +51,7 @@ public AgileComPointer(TInterface* @interface, bool takeOwnership) #endif { _cookie = GlobalInterfaceTable.RegisterInterface(@interface); - OriginalHandle = @interface; + _originalPointer = @interface; if (takeOwnership) { @@ -95,13 +111,15 @@ public void Dispose() protected virtual void Dispose(bool disposing) { - if (_cookie == 0) + // Clear the cookie before revoking the interface to guard against re-entry. + + uint cookie = Interlocked.Exchange(ref _cookie, 0); + if (cookie == 0) { return; } - HRESULT hr = GlobalInterfaceTable.RevokeInterface(_cookie); - _cookie = 0; + HRESULT hr = GlobalInterfaceTable.RevokeInterface(cookie); if (disposing) { diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/BOOL.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/BOOL.cs index f19e77c1905..356001936e8 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/BOOL.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/BOOL.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.Foundation; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/BSTR.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/BSTR.cs index d327d689c19..cc570599efa 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/BSTR.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/BSTR.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -20,7 +19,7 @@ public void Dispose() if (Value is not null) { Marshal.FreeBSTR((nint)Value); - Unsafe.AsRef(this) = default; + Unsafe.AsRef(in this) = default; } } diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/COLORREF.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/COLORREF.cs index 61004939cb3..9561bc518af 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/COLORREF.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/COLORREF.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ComInterfaceTable.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ComInterfaceTable.cs index 66437fd4b9f..950187ae950 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ComInterfaceTable.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ComInterfaceTable.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ComPointerList.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ComPointerList.cs index a3a1a52a505..378df6ddad6 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ComPointerList.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ComPointerList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.Foundation; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ComScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ComScope.cs index acdef9d10b2..845206b9ae7 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ComScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/ComScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using Windows.Win32.System.Com; @@ -47,10 +46,10 @@ namespace Windows.Win32.Foundation; public static implicit operator nint(in ComScope scope) => scope._value; [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator T**(in ComScope scope) => (T**)Unsafe.AsPointer(ref Unsafe.AsRef(scope._value)); + public static implicit operator T**(in ComScope scope) => (T**)Unsafe.AsPointer(ref Unsafe.AsRef(in scope._value)); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator void**(in ComScope scope) => (void**)Unsafe.AsPointer(ref Unsafe.AsRef(scope._value)); + public static implicit operator void**(in ComScope scope) => (void**)Unsafe.AsPointer(ref Unsafe.AsRef(in scope._value)); public bool IsNull => _value == 0; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/DECIMAL.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/DECIMAL.cs index 705a0fe636b..ec0b961134a 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/DECIMAL.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/DECIMAL.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.Foundation; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/GlobalInterfaceTable.UnknownStrategy.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/GlobalInterfaceTable.UnknownStrategy.cs new file mode 100644 index 00000000000..f3911ba7e26 --- /dev/null +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/GlobalInterfaceTable.UnknownStrategy.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices.Marshalling; +using Windows.Win32.System.Com; + +namespace Windows.Win32.Foundation; + +internal static unsafe partial class GlobalInterfaceTable +{ + /// + /// Strategy for that uses the . + /// + private unsafe class UnknownStrategy : IIUnknownStrategy + { + private uint _cookie; + + void* IIUnknownStrategy.CreateInstancePointer(void* unknown) + { + Debug.Assert(_cookie == 0, "A cookie has already been generated for this instance."); + _cookie = RegisterInterface((IUnknown*)unknown); + return unknown; + } + + int IIUnknownStrategy.QueryInterface(void* instancePtr, in Guid iid, out void* ppObj) + => s_globalInterfaceTable->GetInterfaceFromGlobal(_cookie, iid, out ppObj); + + int IIUnknownStrategy.Release(void* instancePtr) + { + uint cookie = Interlocked.Exchange(ref _cookie, 0); + return cookie != 0 ? (int)HRESULT.S_OK : (int)RevokeInterface(_cookie); + } + } +} diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/GlobalInterfaceTable.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/GlobalInterfaceTable.cs index f5186734c03..e0522ffd10b 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/GlobalInterfaceTable.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/GlobalInterfaceTable.cs @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. +using System.Runtime.InteropServices.Marshalling; using Windows.Win32.System.Com; namespace Windows.Win32.Foundation; @@ -9,7 +9,7 @@ namespace Windows.Win32.Foundation; /// /// Wrapper for the COM global interface table. /// -internal static unsafe class GlobalInterfaceTable +internal static unsafe partial class GlobalInterfaceTable { private static readonly IGlobalInterfaceTable* s_globalInterfaceTable; @@ -66,4 +66,15 @@ public static HRESULT RevokeInterface(uint cookie) Debug.WriteLineIf(hr.Failed, $"{nameof(GlobalInterfaceTable)}: Failed to revoke interface."); return hr; } + + /// + /// Creates a new instance of an for + /// that uses the Global Interface Table. + /// + /// + /// + /// The returned instance should not be cached. + /// + /// + public static IIUnknownStrategy CreateUnknownStrategy() => new UnknownStrategy(); } diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/HRESULT.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/HRESULT.cs index 1615976ceea..1bb353bf1d3 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/HRESULT.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/HRESULT.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.Foundation; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/HWND.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/HWND.cs index cf0a280e8c8..e5581ef70ce 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/HWND.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/HWND.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.Foundation; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/IID.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/IID.cs index 6fd8937542f..e759e07970b 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/IID.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/IID.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/LPARAM.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/LPARAM.cs index 05113c8cf47..8420e003db3 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/LPARAM.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/LPARAM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/LRESULT.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/LRESULT.cs index ece7daa15d3..1330c483ffd 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/LRESULT.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/LRESULT.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.Foundation; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/PWSTR.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/PWSTR.cs index f0ec054cd70..c503658774b 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/PWSTR.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/PWSTR.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/RECT.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/RECT.cs index 88543e57144..924a7f1281a 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/RECT.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/RECT.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/WPARAM.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/WPARAM.cs index 3d551249555..745401e643f 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/WPARAM.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Foundation/WPARAM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/GetDcScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/GetDcScope.cs index 6853efac549..f8f6b94d2d4 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/GetDcScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/GetDcScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; @@ -53,7 +52,7 @@ public GetDcScope(HWND hwnd, HRGN hrgnClip, GET_DCX_FLAGS flags) /// API to get the DC for the entire desktop. /// /// - public static GetDcScope ScreenDC => new GetDcScope(HWND.Null); + public static GetDcScope ScreenDC => new(HWND.Null); public bool IsNull => HDC.IsNull; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/FW.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/FW.cs index 1f3688ed760..5c82a43f43a 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/FW.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/FW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.Graphics.Gdi; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HBITMAP.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HBITMAP.cs index 726e32a34b1..598f34799ee 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HBITMAP.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HBITMAP.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.Graphics.Gdi; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HDC.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HDC.cs index 7783543e47a..10d83fc23c3 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HDC.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HDC.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.Graphics.Gdi; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HGDIOBJ.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HGDIOBJ.cs index e370747e29c..fee7f9359f0 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HGDIOBJ.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HGDIOBJ.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.Graphics.Gdi; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HRGN.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HRGN.cs index 4b6242e9161..bf30024b4e0 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HRGN.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/HRGN.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.Graphics.Gdi; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/LOGFONTW.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/LOGFONTW.cs index a6b2090291b..a603ebd8224 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/LOGFONTW.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/LOGFONTW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Interop; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/RGNDATAHEADER.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/RGNDATAHEADER.cs index de58e16eee2..05e828f563a 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/RGNDATAHEADER.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Graphics/Gdi/RGNDATAHEADER.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.Graphics.Gdi; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/HOOKPROC.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/HOOKPROC.cs index 5638cfd0e91..1875e855561 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/HOOKPROC.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/HOOKPROC.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Interop.RegisteredMessage.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Interop.RegisteredMessage.cs index 0f639277543..bbad953a006 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Interop.RegisteredMessage.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Interop.RegisteredMessage.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/MessageId.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/MessageId.cs index a5284f723b9..630ef4dd687 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/MessageId.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/MessageId.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.AreDpiAwarenessContextsEqual.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.AreDpiAwarenessContextsEqual.cs index 53896310a5d..399b6ff0e25 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.AreDpiAwarenessContextsEqual.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.AreDpiAwarenessContextsEqual.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.BeginPaintScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.BeginPaintScope.cs index 3b7633e0893..7e3401917e4 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.BeginPaintScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.BeginPaintScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.BitBlt.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.BitBlt.cs index 1dd44151605..1353b5bd899 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.BitBlt.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.BitBlt.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CDN_.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CDN_.cs index a167a118434..0e8e95f354b 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CDN_.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CDN_.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CallWindowProc.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CallWindowProc.cs index 7422a1d22f9..225c69f52a8 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CallWindowProc.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CallWindowProc.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ChildWindowFromPointEx.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ChildWindowFromPointEx.cs index f18ca87e0c4..21b383159c5 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ChildWindowFromPointEx.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ChildWindowFromPointEx.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ClientToScreen.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ClientToScreen.cs index 4666aeb9c12..063a1e2f63a 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ClientToScreen.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ClientToScreen.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CloseHandle.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CloseHandle.cs index 9e1c2301b32..cd7d086b398 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CloseHandle.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CloseHandle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CopyImage.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CopyImage.cs index 2987f91f0b9..197a8f71d07 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CopyImage.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CopyImage.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateBitmapScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateBitmapScope.cs index b5f01d1b619..dd1caef658f 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateBitmapScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateBitmapScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateBrushScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateBrushScope.cs index ee9e724b9cf..30e9a889b04 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateBrushScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateBrushScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateDcScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateDcScope.cs index bc8d980b81a..836e59db1f0 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateDcScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateDcScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreatePenScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreatePenScope.cs index 408493ab1ab..9f7546a7d92 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreatePenScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreatePenScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateWindowEx.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateWindowEx.cs index 646b3903c76..bb307e58407 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateWindowEx.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.CreateWindowEx.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using System.Text; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DestroyAcceleratorTable.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DestroyAcceleratorTable.cs index 02950768bf6..8001eb27775 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DestroyAcceleratorTable.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DestroyAcceleratorTable.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DispatchMessageA.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DispatchMessageA.cs index 0beed41ac36..e6188234678 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DispatchMessageA.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DispatchMessageA.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DragAcceptFiles.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DragAcceptFiles.cs index 9560b60589f..daecd113728 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DragAcceptFiles.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DragAcceptFiles.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawIcon.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawIcon.cs index 6040ead9ce6..5cce2f7b599 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawIcon.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawIcon.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawIconEx.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawIconEx.cs index b990df28f5c..3fda5695d40 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawIconEx.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawIconEx.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawMenuBar.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawMenuBar.cs index 2ae938c3051..626c5053a25 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawMenuBar.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawMenuBar.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawTextEx.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawTextEx.cs index 617421d5251..2e90ee6fdff 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawTextEx.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.DrawTextEx.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnableMenuItem.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnableMenuItem.cs index e6bdef16f1b..5a430176e47 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnableMenuItem.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnableMenuItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnableScrollBar.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnableScrollBar.cs index 12fdf330861..84c9f2a56b0 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnableScrollBar.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnableScrollBar.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnableWindow.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnableWindow.cs index 97d85ebe236..87c09a7074c 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnableWindow.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnableWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EndDialog.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EndDialog.cs index d12c9cc16ef..69398acbff4 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EndDialog.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EndDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumChildWindows.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumChildWindows.cs index 17d210c26cd..6e2caca57ae 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumChildWindows.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumChildWindows.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumDisplayMonitors.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumDisplayMonitors.cs index 475aba368fa..a899c1961f7 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumDisplayMonitors.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumDisplayMonitors.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumThreadWindows.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumThreadWindows.cs index 849a12bfe6d..1518887fd0f 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumThreadWindows.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumThreadWindows.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumWindows.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumWindows.cs index 4b5562d5823..7d1117daed7 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumWindows.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.EnumWindows.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.FILETIME.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.FILETIME.cs index 6a23021c767..83e72e3421e 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.FILETIME.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.FILETIME.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.FillRect.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.FillRect.cs index ab0eecbc0a6..389ff66b181 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.FillRect.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.FillRect.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; @@ -9,7 +8,7 @@ internal static partial class PInvoke public static int FillRect(T hDC, ref RECT lprc, HBRUSH hbr) where T : IHandle { - int result = FillRect(hDC.Handle, ref lprc, hbr); + int result = FillRect(hDC.Handle, in lprc, hbr); GC.KeepAlive(hDC.Wrapper); return result; } diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GMEM.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GMEM.cs index 9cb1d5415d8..65776e0339e 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GMEM.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GMEM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetAncestor.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetAncestor.cs index 6f291a7b29f..dd4550e4207 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetAncestor.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetAncestor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetClassLong.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetClassLong.cs index 8e76aff0158..bf34d2c54c1 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetClassLong.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetClassLong.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetClientRect.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetClientRect.cs index e7fee7a894e..1399c71009d 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetClientRect.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetClientRect.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetDlgItem.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetDlgItem.cs index 62f00bdc0ca..032425637d0 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetDlgItem.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetDlgItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetDpiForWindow.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetDpiForWindow.cs index 450b6d568de..02e62222375 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetDpiForWindow.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetDpiForWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetIconInfo.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetIconInfo.cs index 281dc135a31..b7af97cf269 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetIconInfo.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetIconInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetMenu.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetMenu.cs index e481882dae8..f6f5e8819bd 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetMenu.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetMenu.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetMenuItemCount.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetMenuItemCount.cs index a9446e49ada..2c145b2c665 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetMenuItemCount.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetMenuItemCount.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetModuleFileNameLongPath.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetModuleFileNameLongPath.cs index 12b4951f7a0..83ce43788e7 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetModuleFileNameLongPath.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetModuleFileNameLongPath.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetObject.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetObject.cs index e9e8321c38d..81d98aa8346 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetObject.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetOpenFileName.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetOpenFileName.cs index cf3e9121153..7ae07f4f16b 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetOpenFileName.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetOpenFileName.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.UI.Controls.Dialogs; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetPaletteEntries.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetPaletteEntries.cs index f08f716e531..68a05518136 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetPaletteEntries.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetPaletteEntries.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetParent.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetParent.cs index 5146cd8761d..612321b2527 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetParent.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetParent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetScrollInfo.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetScrollInfo.cs index c075e1307f6..a0b277e6b1d 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetScrollInfo.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetScrollInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetSysColorBrush.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetSysColorBrush.cs index c64d75dc30e..a78ee055d93 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetSysColorBrush.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetSysColorBrush.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetSystemMenu.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetSystemMenu.cs index 6bd63203db1..3d389c9d350 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetSystemMenu.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetSystemMenu.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetSystemMetrics.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetSystemMetrics.cs index 0c6d7b5289c..282f64f8470 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetSystemMetrics.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetSystemMetrics.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetTextExtentPoint32.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetTextExtentPoint32.cs index 40e0724f8c9..813cb46295b 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetTextExtentPoint32.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetTextExtentPoint32.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetThemeDocumentationProperty.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetThemeDocumentationProperty.cs index 4caec359687..a5402c364f6 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetThemeDocumentationProperty.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetThemeDocumentationProperty.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetThemeFont.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetThemeFont.cs index 373e07dbf4e..7994fc6d573 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetThemeFont.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetThemeFont.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing.Interop; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetThreadDpiAwarenessContext.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetThreadDpiAwarenessContext.cs index ca5d0ba37f2..4383a196933 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetThreadDpiAwarenessContext.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetThreadDpiAwarenessContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindow.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindow.cs index 9f014aa21e2..c991f4c5633 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindow.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowLong.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowLong.cs index 0599f736949..0d7b6f34845 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowLong.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowLong.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowRect.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowRect.cs index 0081d284a7a..ca988454787 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowRect.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowRect.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowText.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowText.cs index 2df6c6930df..1858bb1debf 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowText.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowText.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowTextLength.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowTextLength.cs index 1730570a066..705a498618b 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowTextLength.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowTextLength.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowThreadProcessId.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowThreadProcessId.cs index 77fbf38adfd..a171b22c010 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowThreadProcessId.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.GetWindowThreadProcessId.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ImageList.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ImageList.cs index 5e7c00c9bb0..f467e869399 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ImageList.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ImageList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ImmGetContext.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ImmGetContext.cs index d8fea1cca90..47583ee794d 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ImmGetContext.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ImmGetContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.Globalization; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ImmReleaseContext.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ImmReleaseContext.cs index 25cb504b6ce..52619d95b06 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ImmReleaseContext.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ImmReleaseContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.Globalization; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IntersectClipRect.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IntersectClipRect.cs index 86f7a6644f0..2743630e3cf 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IntersectClipRect.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IntersectClipRect.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.InvalidateRect.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.InvalidateRect.cs index 7ec78f02e88..efa0d601765 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.InvalidateRect.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.InvalidateRect.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.InvalidateRgn.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.InvalidateRgn.cs index 6827fb561c3..6802b13a9ea 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.InvalidateRgn.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.InvalidateRgn.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsAccelerator.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsAccelerator.cs index 379fe668ead..eef5abb20d8 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsAccelerator.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsAccelerator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsChild.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsChild.cs index 4dfa27185b8..ce4c57c6f6f 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsChild.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsChild.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsWindow.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsWindow.cs index cfa44a6e77a..213fae66e03 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsWindow.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsWindowEnabled.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsWindowEnabled.cs index 9decb8df801..a55cf234377 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsWindowEnabled.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsWindowEnabled.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsWindowVisible.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsWindowVisible.cs index 91f71f066af..d0ef1871f8e 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsWindowVisible.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.IsWindowVisible.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.KillTimer.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.KillTimer.cs index 3131da2701f..ab39855b32c 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.KillTimer.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.KillTimer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LCID.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LCID.cs index 1b982e0f826..4907a40e79e 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LCID.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LCID.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; @@ -30,8 +29,8 @@ public override bool Equals(object? obj) public static bool operator !=(LCID a, LCID b) => a.RawValue != b.RawValue; - public static implicit operator LCID(uint value) => new LCID(value); + public static implicit operator LCID(uint value) => new(value); - public static readonly LCID USER_DEFAULT = new LCID(0x0400); + public static readonly LCID USER_DEFAULT = new(0x0400); } } diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LCTYPE.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LCTYPE.cs index a4cffd14dcd..ce1246a6c70 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LCTYPE.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LCTYPE.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LoadLibrary.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LoadLibrary.cs index 1e3da281f90..688117f4eac 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LoadLibrary.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LoadLibrary.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.System.LibraryLoader; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MAX_PATH.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MAX_PATH.cs index f18c50d4658..6b7c0583ef8 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MAX_PATH.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MAX_PATH.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MAX_UNICODESTRING_LEN.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MAX_UNICODESTRING_LEN.cs index e2d62d49372..a6bb4868985 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MAX_UNICODESTRING_LEN.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MAX_UNICODESTRING_LEN.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MapWindowPoints.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MapWindowPoints.cs index 3dd24d203ed..0ae33b8e352 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MapWindowPoints.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MapWindowPoints.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MaxClassName.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MaxClassName.cs index b2e195183f3..6ea5f729e30 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MaxClassName.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.MaxClassName.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.NotifyWinEvent.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.NotifyWinEvent.cs index 8d0b1b7b384..e68d740cc5b 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.NotifyWinEvent.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.NotifyWinEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ObjectScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ObjectScope.cs index 8ea39f20ab9..5592050831c 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ObjectScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ObjectScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.OpenThemeDataScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.OpenThemeDataScope.cs index 1c243ba9826..ccfbdc86cc6 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.OpenThemeDataScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.OpenThemeDataScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.PeekMessage.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.PeekMessage.cs index 781ebdfd923..510faf9cac1 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.PeekMessage.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.PeekMessage.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.PostMessage.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.PostMessage.cs index 1e32fd6be85..f4d001cad71 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.PostMessage.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.PostMessage.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RedrawWindow.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RedrawWindow.cs index 0647303b688..8fff0aea963 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RedrawWindow.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RedrawWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RegionScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RegionScope.cs index 7098b2f1067..6f7a0326a36 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RegionScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RegionScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Drawing = System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RegisterDragDrop.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RegisterDragDrop.cs index 3212094343d..f769dc7b0e4 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RegisterDragDrop.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RegisterDragDrop.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Ole; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RevokeDragDrop.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RevokeDragDrop.cs index 95d357ce479..93311f8a5ed 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RevokeDragDrop.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.RevokeDragDrop.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SHAutoComplete.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SHAutoComplete.cs index 27f104356f1..f6292145661 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SHAutoComplete.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SHAutoComplete.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SHCreateItemFromParsingName.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SHCreateItemFromParsingName.cs index ab0929ba920..9fb42d61e35 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SHCreateItemFromParsingName.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SHCreateItemFromParsingName.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SHCreateShellItem.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SHCreateShellItem.cs index 95869616416..ccc0f9ce039 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SHCreateShellItem.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SHCreateShellItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SaveDcScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SaveDcScope.cs index 41089b8fc07..6217128f9a9 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SaveDcScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SaveDcScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ScreenToClient.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ScreenToClient.cs index a66dc84f269..9bbd06efd8a 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ScreenToClient.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ScreenToClient.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ScrollWindow.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ScrollWindow.cs index 15d4410343f..053e2657d61 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ScrollWindow.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ScrollWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ScrollWindowEx.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ScrollWindowEx.cs index f9cc3042d70..1bd77dca93d 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ScrollWindowEx.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ScrollWindowEx.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SelectPaletteScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SelectPaletteScope.cs index f23d7cb40ae..344deb710a2 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SelectPaletteScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SelectPaletteScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; @@ -48,7 +47,7 @@ public static SelectPaletteScope HalftonePalette(HDC hdc, bool forceBackground, #if DEBUG return new SelectPaletteScope(); #else - return default(SelectPaletteScope); + return default; #endif } diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SelectionScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SelectionScope.cs index 49281124522..3521a20d549 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SelectionScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SelectionScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SendMessage.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SendMessage.cs index 4d4ebc4ccb8..e5602f4f4a2 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SendMessage.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SendMessage.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetActiveWindow.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetActiveWindow.cs index 63191e78b3c..f74a12ab685 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetActiveWindow.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetActiveWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetBackgroundColorScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetBackgroundColorScope.cs index ac5a7178e76..12011d60301 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetBackgroundColorScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetBackgroundColorScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetBkModeScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetBkModeScope.cs index 02db6bd0255..2abf59979da 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetBkModeScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetBkModeScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetCapture.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetCapture.cs index eee9f896e21..8adcb29f882 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetCapture.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetCapture.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetClassLong.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetClassLong.cs index fbb1f16b684..6e1538da726 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetClassLong.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetClassLong.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetFocus.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetFocus.cs index 0bf49334a80..40c8301f6d3 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetFocus.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetFocus.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetForegroundWindow.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetForegroundWindow.cs index 90187287b49..d9e661a22f8 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetForegroundWindow.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetForegroundWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetLayeredWindowAttributes.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetLayeredWindowAttributes.cs index 9678c169c8d..633a40f3c2c 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetLayeredWindowAttributes.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetLayeredWindowAttributes.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetMapModeScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetMapModeScope.cs index 83c9816e630..c103d248bda 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetMapModeScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetMapModeScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetMenu.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetMenu.cs index 1cc73000e06..f56b6a8b2b0 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetMenu.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetMenu.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetParent.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetParent.cs index f4838869103..2aee9ae2e12 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetParent.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetParent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetRop2Scope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetRop2Scope.cs index 8f52a1c255b..5476e07ace3 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetRop2Scope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetRop2Scope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetScrollInfo.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetScrollInfo.cs index 980dd9f83af..304af4e43c2 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetScrollInfo.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetScrollInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetScrollPos.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetScrollPos.cs index 6c9fabc3dc2..22dcd6db597 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetScrollPos.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetScrollPos.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetTextAlignmentScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetTextAlignmentScope.cs index 37930aa6036..b34bdb50ca6 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetTextAlignmentScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetTextAlignmentScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetTextColorScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetTextColorScope.cs index b1d5eba52a7..8dec3b1c0cd 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetTextColorScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetTextColorScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetThreadDpiAwarenessContext.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetThreadDpiAwarenessContext.cs index 89bc6e67807..f331f9ae523 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetThreadDpiAwarenessContext.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetThreadDpiAwarenessContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetTimer.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetTimer.cs index 7bba2e2dd08..44bdc6499ef 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetTimer.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetTimer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowLong.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowLong.cs index 438b053297f..a037624647b 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowLong.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowLong.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowPos.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowPos.cs index cae64f81f5f..2f181ef87e6 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowPos.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowPos.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowRgn.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowRgn.cs index 4a983103b48..535db5ecae3 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowRgn.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowRgn.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowText.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowText.cs index 3dc3442a201..74482ebef61 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowText.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SetWindowText.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ShowWindow.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ShowWindow.cs index b6b764d3add..dff3acdd61d 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ShowWindow.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ShowWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SystemParametersInfo.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SystemParametersInfo.cs index 4649da028ba..bbbd02652ba 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SystemParametersInfo.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SystemParametersInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; using Windows.Win32.UI.Accessibility; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.TBM_GETPOS.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.TBM_GETPOS.cs index 716d66a86ab..41de88e64b2 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.TBM_GETPOS.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.TBM_GETPOS.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.UpdateWindow.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.UpdateWindow.cs index 8d79524b41f..4485fa5e842 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.UpdateWindow.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.UpdateWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ValidateRect.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ValidateRect.cs index 3ce28c21b95..715cb14ddeb 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ValidateRect.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.ValidateRect.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Pinvoke.RegLoadMUIString.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Pinvoke.RegLoadMUIString.cs index b81376af428..96ab275ebf8 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/Pinvoke.RegLoadMUIString.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/Pinvoke.RegLoadMUIString.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using Microsoft.Win32; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/CLSID.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/CLSID.cs index ed8109dc16a..38bcb807ef2 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/CLSID.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/CLSID.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/CY.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/CY.cs index b3200cf1084..1fb005a21b5 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/CY.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/CY.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/FORMATETC.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/FORMATETC.cs index 2fd3283e6bf..798a979f0a7 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/FORMATETC.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/FORMATETC.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using ComType = System.Runtime.InteropServices.ComTypes; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IComCallableWrapper.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IComCallableWrapper.cs index af0d3b62fcd..da870ee6842 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IComCallableWrapper.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IComCallableWrapper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IDispatch.Interface.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IDispatch.Interface.cs index af6ebeec32c..1e9f1c7cdc4 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IDispatch.Interface.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IDispatch.Interface.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IDispatch.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IDispatch.cs index d89a202fd12..130eb0fdd41 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IDispatch.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IDispatch.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Variant; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IManagedWrapper.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IManagedWrapper.cs index 2ec6b516395..b9a816d8757 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IManagedWrapper.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IManagedWrapper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IUnknown.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IUnknown.cs index 9939b322d9e..5e8330fcc2e 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IUnknown.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IUnknown.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IWrapperInitialize.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IWrapperInitialize.cs index 742e08cc55e..f2f961bf668 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IWrapperInitialize.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/IWrapperInitialize.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/SAFEARRAY.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/SAFEARRAY.cs index 27df00519b6..3894997ba66 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/SAFEARRAY.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/SAFEARRAY.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using Windows.Win32.System.Variant; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/STGMEDIUM.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/STGMEDIUM.cs index 28a999e00a7..1706cf78b29 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/STGMEDIUM.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/STGMEDIUM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using ComType = System.Runtime.InteropServices.ComTypes; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/StandardDispatch.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/StandardDispatch.cs index 0a5a7e82300..ed1eb863f10 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/StandardDispatch.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/StandardDispatch.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; using Windows.Win32.System.Ole; @@ -60,11 +59,10 @@ void IWrapperInitialize.OnInitialized(IUnknown* unknown) // Load the registered type library and get the relevant ITypeInfo for the specified interface. using ComScope typelib = new(null); - HRESULT hr = PInvoke.LoadRegTypeLib(_typeLibrary, _majorVersion, _minorVersion, 0, typelib); - hr.ThrowOnFailure(); + PInvoke.LoadRegTypeLib(_typeLibrary, _majorVersion, _minorVersion, 0, typelib).ThrowOnFailure(); using ComScope typeinfo = new(null); - typelib.Value->GetTypeInfoOfGuid(_interfaceId, typeinfo); + typelib.Value->GetTypeInfoOfGuid(_interfaceId, typeinfo).ThrowOnFailure(); // The unknown we get is a wrapper unknown. unknown->QueryInterface(_interfaceId, out void* instance).ThrowOnFailure(); @@ -114,6 +112,11 @@ HRESULT IDispatch.Interface.Invoke( EXCEPINFO* pExcepInfo, uint* pArgErr) { + if (pDispParams is null) + { + return HRESULT.E_INVALIDARG; + } + HRESULT hr = MapDotNetHRESULTs(Invoke( dispIdMember, lcid, @@ -167,6 +170,11 @@ HRESULT IDispatchEx.Interface.InvokeEx( EXCEPINFO* pei, IServiceProvider* pspCaller) { + if (pdp is null) + { + return HRESULT.E_INVALIDARG; + } + HRESULT hr = MapDotNetHRESULTs(Invoke( id, lcid, @@ -247,43 +255,18 @@ HRESULT IDispatchEx.Interface.GetNameSpaceParent(IUnknown** ppunk) return HRESULT.E_NOTIMPL; } - private static FDEX_PROP_FLAGS GetFuncDescProperties(FUNCDESC* funcdesc) - { - FDEX_PROP_FLAGS flags = default; - - INVOKEKIND invokekind = funcdesc->invkind; - flags |= invokekind.HasFlag(INVOKEKIND.INVOKE_PROPERTYPUT) - ? FDEX_PROP_FLAGS.fdexPropCanPut - : FDEX_PROP_FLAGS.fdexPropCannotPut; - - flags |= invokekind.HasFlag(INVOKEKIND.INVOKE_PROPERTYPUTREF) - ? FDEX_PROP_FLAGS.fdexPropCanPutRef - : FDEX_PROP_FLAGS.fdexPropCannotPutRef; - - flags |= invokekind.HasFlag(INVOKEKIND.INVOKE_PROPERTYGET) - ? FDEX_PROP_FLAGS.fdexPropCanGet - : FDEX_PROP_FLAGS.fdexPropCannotGet; - - flags |= invokekind.HasFlag(INVOKEKIND.INVOKE_FUNC) - ? FDEX_PROP_FLAGS.fdexPropCanCall - : FDEX_PROP_FLAGS.fdexPropCannotCall; - - flags |= FDEX_PROP_FLAGS.fdexPropCannotConstruct | FDEX_PROP_FLAGS.fdexPropCannotSourceEvents; - - return flags; - } - protected virtual void Dispose(bool disposing) { if (disposing) { - _standardDispatch?.Dispose(); - _standardDispatch = null; + DisposeHelper.NullAndDispose(ref _standardDispatch); } } private static HRESULT MapDotNetHRESULTs(HRESULT hr) { + // Following along with .NET COM interop + if (hr == HRESULT.COR_E_OVERFLOW) { return HRESULT.DISP_E_OVERFLOW; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/StructuredStorage/CA.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/StructuredStorage/CA.cs index e85eb90381e..39efc421f51 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/StructuredStorage/CA.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/StructuredStorage/CA.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.System.Com.StructuredStorage; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/StructuredStorage/PropertyBagExtensions.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/StructuredStorage/PropertyBagExtensions.cs index ec1d6c65748..4c7b49aecc4 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/StructuredStorage/PropertyBagExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Com/StructuredStorage/PropertyBagExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Variant; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/CADWORD.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/CADWORD.cs index 803f24f3dbd..b571bc1530b 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/CADWORD.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/CADWORD.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/CALPOLESTR.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/CALPOLESTR.cs index 26758897ad1..b392aacfcd9 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/CALPOLESTR.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/CALPOLESTR.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.System.Ole; internal partial struct CALPOLESTR diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/ClassPropertyDispatchAdapter.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/ClassPropertyDispatchAdapter.cs index cc5d3d4b6c8..d321da3cc49 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/ClassPropertyDispatchAdapter.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/ClassPropertyDispatchAdapter.cs @@ -1,12 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; using System.Runtime.InteropServices; using Windows.Win32.System.Com; using Windows.Win32.System.Variant; -using InteropMarshal = System.Runtime.InteropServices.Marshal; namespace Windows.Win32.System.Ole; @@ -71,7 +69,7 @@ private bool IdInUse(int id) private int GetUnusedDispId(int desiredId) { - if (desiredId != PInvoke.DISPID_UNKNOWN && !_members.ContainsKey(desiredId)) + if (desiredId != PInvoke.DISPID_UNKNOWN && !IdInUse(desiredId)) { return desiredId; } @@ -155,6 +153,16 @@ public HRESULT Invoke( } } + if (!_members.TryGetValue(dispId, out var entry)) + { + return HRESULT.DISP_E_MEMBERNOTFOUND; + } + + if (!_instance.TryGetTarget(out object? target)) + { + return HRESULT.COR_E_OBJECTDISPOSED; + } + BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static; if (flags.HasFlag(DISPATCH_FLAGS.DISPATCH_PROPERTYPUT | DISPATCH_FLAGS.DISPATCH_PROPERTYPUTREF)) @@ -176,20 +184,12 @@ public HRESULT Invoke( Debug.Assert(!bindingFlags.HasFlag(BindingFlags.NonPublic)); - if (!_members.TryGetValue(dispId, out var entry)) - { - return HRESULT.DISP_E_MEMBERNOTFOUND; - } - - if (!_instance.TryGetTarget(out object? target)) - { - return HRESULT.COR_E_OBJECTDISPOSED; - } - object? resultObject = null; if (bindingFlags.HasFlag(BindingFlags.PutDispProperty)) { + // Setter + if (parameters->cArgs != 1) { return HRESULT.DISP_E_BADPARAMCOUNT; @@ -197,7 +197,8 @@ public HRESULT Invoke( try { - object? value = InteropMarshal.GetObjectForNativeVariant((nint)parameters->rgvarg); + VARIANT* variantValue = parameters->rgvarg; + object? value = variantValue is null ? null : variantValue->ToObject(); resultObject = _type.InvokeMember( entry.Name, bindingFlags, @@ -212,10 +213,7 @@ public HRESULT Invoke( } else { - if (result is null) - { - return HRESULT.E_POINTER; - } + // Getter try { @@ -226,7 +224,11 @@ public HRESULT Invoke( target, args: null); - InteropMarshal.GetNativeVariantForObject(resultObject, (nint)result); + // It is technically ok to not get the result. + if (result is not null) + { + *result = VARIANT.FromObject(resultObject); + } } catch (Exception ex) { diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/IPicture.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/IPicture.cs index d128aef9341..cdbfe370088 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/IPicture.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/IPicture.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/IPictureDisp.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/IPictureDisp.cs index 655b383d849..a6b07c02a8d 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/IPictureDisp.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/IPictureDisp.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/OLE_HANDLE.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/OLE_HANDLE.cs index 9f4515c8ae0..ce12c1d3039 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/OLE_HANDLE.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/OLE_HANDLE.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Imaging; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/PICTDESC.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/PICTDESC.cs index 26ab0e5563c..05eaf619112 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/PICTDESC.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/System/Ole/PICTDESC.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Imaging; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/Controls/Dialogs/OFNOTIFY.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/Controls/Dialogs/OFNOTIFY.cs index 011cfe3a1c1..02d9ef58254 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/Controls/Dialogs/OFNOTIFY.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/Controls/Dialogs/OFNOTIFY.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.UI.Controls.Dialogs; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/Controls/Dialogs/OPENFILENAME.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/Controls/Dialogs/OPENFILENAME.cs index 7625f2abe63..b697ecb3a8d 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/Controls/Dialogs/OPENFILENAME.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/Controls/Dialogs/OPENFILENAME.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.UI.Controls.Dialogs; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/HiDpi/DPI_AWARENESS_CONTEXT.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/HiDpi/DPI_AWARENESS_CONTEXT.cs index d62549ac2ae..182b3dc52bb 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/HiDpi/DPI_AWARENESS_CONTEXT.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/HiDpi/DPI_AWARENESS_CONTEXT.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.UI.HiDpi; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/Shell/FolderBrowserHelper.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/Shell/FolderBrowserHelper.cs new file mode 100644 index 00000000000..efac32c764a --- /dev/null +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/Shell/FolderBrowserHelper.cs @@ -0,0 +1,70 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; +using System.Windows.Forms.Primitives.Resources; + +namespace Windows.Win32.UI.Shell; + +internal static class FolderBrowserHelper +{ + /// + /// Helper for the legacy API. + /// + /// The selected path if successful, if failed. + /// Could not get the root folder. + internal static unsafe string? BrowseForFolder( + string title, + int rootFolderCsidl, + uint flags, + HWND owner, + delegate* unmanaged[Stdcall] callback, + LPARAM lParam) + { + PInvoke.SHGetSpecialFolderLocation(rootFolderCsidl, out ITEMIDLIST* rootFolderId); + if (rootFolderId is null) + { + PInvoke.SHGetSpecialFolderLocation((int)Environment.SpecialFolder.Desktop, out rootFolderId); + if (rootFolderId is null) + { + throw new InvalidOperationException(SR.FolderBrowserDialogNoRootFolder); + } + } + + using BufferScope buffer = new(PInvoke.MAX_PATH + 1); + + fixed (char* b = buffer) + fixed (char* t = title) + { + BROWSEINFOW bi = new() + { + pidlRoot = rootFolderId, + hwndOwner = owner, + // This is assumed to be MAX_PATH. We don't use it, but we need to have the buffer available. + pszDisplayName = b, + lpszTitle = t, + ulFlags = flags, + lpfn = callback, + lParam = lParam, + iImage = 0 + }; + + // Show the dialog + ITEMIDLIST* resultId = PInvoke.SHBrowseForFolder(&bi); + Marshal.FreeCoTaskMem((nint)rootFolderId); + + if (resultId is null) + { + return null; + } + + // Retrieve the path from the IDList (GPFIDL_UNCPRINTER is what gets passed by SHGETPathFromWidList). + // In theory this will handle long paths, but the underlying HRESULT is lost and there is no other + // immediately apparent way to get the result. Could potentially retry a few times to catch the most common cases. + bool success = PInvoke.SHGetPathFromIDListEx(resultId, b, (uint)buffer.Length, GPFIDL_FLAGS.GPFIDL_UNCPRINTER); + Marshal.FreeCoTaskMem((nint)resultId); + + return success ? new(b) : null; + } + } +} diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/HICON.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/HICON.cs index 54ad67ff392..76e4d21bec2 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/HICON.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/HICON.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.UI.WindowsAndMessaging; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/ICONINFO.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/ICONINFO.cs index bd286cbf55c..9e965e1c9d2 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/ICONINFO.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/ICONINFO.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.UI.WindowsAndMessaging; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/MSG.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/MSG.cs index e06dac6caab..aaebb8cd313 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/MSG.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/MSG.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/WNDPROC.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/WNDPROC.cs index 70ba80766a3..41162905360 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/WNDPROC.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/UI/WindowsAndMessaging/WNDPROC.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Windows.Win32.UI.WindowsAndMessaging; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/ComparisonHelpersTests.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/ComparisonHelpersTests.cs index 316d3159390..1e57bf6f9c1 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/ComparisonHelpersTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/ComparisonHelpersTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Tests; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/GlobalUsings.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/GlobalUsings.cs index 04aa3c6cb9c..4fb1a00800f 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/GlobalUsings.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/GlobalUsings.cs @@ -1,5 +1,4 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. global using Xunit; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/Metafiles/Validators/RepeatValidatorTests.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/Metafiles/Validators/RepeatValidatorTests.cs index 4cfd72a4784..a673d16c54d 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/Metafiles/Validators/RepeatValidatorTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/Metafiles/Validators/RepeatValidatorTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Moq; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/ArchitectureDetection.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/ArchitectureDetection.cs index 23672786605..1f4610884bf 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/ArchitectureDetection.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/ArchitectureDetection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/DeviceContextState.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/DeviceContextState.cs index 4a16a6fa5b4..dbc98ac401b 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/DeviceContextState.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/DeviceContextState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable @@ -18,7 +17,7 @@ internal unsafe class DeviceContextState // Not all state is handled yet. Backfilling in as we write specific tests. Of special note is that we don't // have tracking for Save/RestoreDC yet. - private readonly List _savedStates = new List(); + private readonly List _savedStates = new(); private State _currentState; /// diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Extensions/GdiExtensions.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Extensions/GdiExtensions.cs index 1edff6627d3..790585670e0 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Extensions/GdiExtensions.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Extensions/GdiExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Numerics; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Extensions/SpanExtensions.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Extensions/SpanExtensions.cs index 107ad3abdc4..a43299aa580 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Extensions/SpanExtensions.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Extensions/SpanExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Extensions/TheoryExtensions.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Extensions/TheoryExtensions.cs index 2865408947b..aac1b9bfedd 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Extensions/TheoryExtensions.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Extensions/TheoryExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/GdiHelper.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/GdiHelper.cs index eee8752b8ba..6d99d4c510d 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/GdiHelper.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/GdiHelper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/GlobalUsings.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/GlobalUsings.cs index bab7a4e45f3..f5e1f631fa7 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/GlobalUsings.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/GlobalUsings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. global using System.Diagnostics; global using System.Diagnostics.CodeAnalysis; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/HdcDeviceContextAdapter.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/HdcDeviceContextAdapter.cs index 2fa8f840eab..c63a5379759 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/HdcDeviceContextAdapter.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/HdcDeviceContextAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/DataHelpers.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/DataHelpers.cs index 50b12a07646..a7ce7ef14b2 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/DataHelpers.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/DataHelpers.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Numerics; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfRecord.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfRecord.cs index cb3bc52ab18..ffd635f77fe 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfRecord.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfRecord.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable using Windows.Win32.UI.ColorSystem; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfScope.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfScope.cs index f330d8d293f..c4434fd1555 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfScope.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable @@ -55,7 +54,7 @@ private static unsafe HDC CreateEnhMetaFile( } } - public static unsafe EmfScope Create() => new EmfScope(); + public static unsafe EmfScope Create() => new(); public HENHMETAFILE HENHMETAFILE { diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/ProcessRecordDelegate.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/ProcessRecordDelegate.cs index dad7d9cc471..e741bfa43ea 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/ProcessRecordDelegate.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/ProcessRecordDelegate.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/ProcessRecordWithStateDelegate.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/ProcessRecordWithStateDelegate.cs index 24f3d022bca..d9146533152 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/ProcessRecordWithStateDelegate.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/ProcessRecordWithStateDelegate.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMR.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMR.cs index 25ea69321c8..4651cc01f0e 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMR.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMR.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRBITBLT.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRBITBLT.cs index 02daf3b6e91..018e457dbab 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRBITBLT.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRBITBLT.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRCREATEBRUSHINDIRECT.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRCREATEBRUSHINDIRECT.cs index 0411af8095a..3fc6eab6b8d 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRCREATEBRUSHINDIRECT.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRCREATEBRUSHINDIRECT.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRCREATEDIBPATTERNBRUSHPT.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRCREATEDIBPATTERNBRUSHPT.cs index 6802acdbdc1..0e6fa3b06de 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRCREATEDIBPATTERNBRUSHPT.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRCREATEDIBPATTERNBRUSHPT.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRCREATEPEN.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRCREATEPEN.cs index 2d036cb3049..4251c9dd463 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRCREATEPEN.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRCREATEPEN.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRENUMRECORD.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRENUMRECORD.cs index 4a5a2231398..0da5b8ac4de 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRENUMRECORD.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRENUMRECORD.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTCREATEFONTINDIRECTW.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTCREATEFONTINDIRECTW.cs index b97f4458aaf..14306f07a8a 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTCREATEFONTINDIRECTW.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTCREATEFONTINDIRECTW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTCREATEPEN.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTCREATEPEN.cs index 5b708f3bff9..1b1042c59f7 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTCREATEPEN.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTCREATEPEN.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTSELECTCLIPRGN.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTSELECTCLIPRGN.cs index 9c93dd60e03..343ca889894 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTSELECTCLIPRGN.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTSELECTCLIPRGN.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTTEXTOUTW.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTTEXTOUTW.cs index 4d0a91651e1..1fdea4428a7 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTTEXTOUTW.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMREXTTEXTOUTW.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRINDEXRECORD.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRINDEXRECORD.cs index eec50803f47..26cb44240b8 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRINDEXRECORD.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRINDEXRECORD.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRMODIFYWORLDTRANSFORM.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRMODIFYWORLDTRANSFORM.cs index 2a1860f728d..3433ffc8d4d 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRMODIFYWORLDTRANSFORM.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRMODIFYWORLDTRANSFORM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRPOINTRECORD.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRPOINTRECORD.cs index e7e1f08ec2a..bd8531c593e 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRPOINTRECORD.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRPOINTRECORD.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRPOLY16.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRPOLY16.cs index 65a82e15a61..8682738c802 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRPOLY16.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRPOLY16.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRPOLYPOLY16.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRPOLYPOLY16.cs index 74136cc1479..cd7d742ac0f 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRPOLYPOLY16.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRPOLYPOLY16.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRRECTRECORD.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRRECTRECORD.cs index ce653f09166..cf55246e669 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRRECTRECORD.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRRECTRECORD.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRRESTOREDC.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRRESTOREDC.cs index cbff121497f..393bcd6b9d0 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRRESTOREDC.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRRESTOREDC.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRSETCOLOR.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRSETCOLOR.cs index b073bacda5b..b959003ea2b 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRSETCOLOR.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRSETCOLOR.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRSETWORLDTRANSFORM.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRSETWORLDTRANSFORM.cs index c5d54f634b7..365b4cf58e6 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRSETWORLDTRANSFORM.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRSETWORLDTRANSFORM.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRTEXT.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRTEXT.cs index 312409f138f..bb15e729835 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRTEXT.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/EMRTEXT.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/ENHMETAHEADER.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/ENHMETAHEADER.cs index 0d6b75c046e..4c7f53cdc59 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/ENHMETAHEADER.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/RecordTypes/ENHMETAHEADER.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/ActionValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/ActionValidator.cs index 36cf79f14d1..a592f55003e 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/ActionValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/ActionValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BackgroundModeValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BackgroundModeValidator.cs index b538d388157..b896f612c05 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BackgroundModeValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BackgroundModeValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BitBltValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BitBltValidator.cs index 1225cd68ece..2641c52067f 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BitBltValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BitBltValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BrushColorValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BrushColorValidator.cs index 7fe60288ea6..e5ae6688ef9 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BrushColorValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BrushColorValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BrushStyleValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BrushStyleValidator.cs index 881ef3f5d76..26b508bc795 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BrushStyleValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BrushStyleValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BrushValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BrushValidator.cs index cccb49471d1..96551a6c523 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BrushValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/BrushValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/ClippingValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/ClippingValidator.cs index 1509af2aa32..41671f8f322 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/ClippingValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/ClippingValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/EmfValidator.WrappedXunitException.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/EmfValidator.WrappedXunitException.cs index 73db37fcdb3..979af99637f 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/EmfValidator.WrappedXunitException.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/EmfValidator.WrappedXunitException.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/EmfValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/EmfValidator.cs index 2a382db5e8c..070c1fb84a5 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/EmfValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/EmfValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/FontFaceNameValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/FontFaceNameValidator.cs index fa6fa82417b..d15759c815e 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/FontFaceNameValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/FontFaceNameValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/IEmfValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/IEmfValidator.cs index e972407f4c2..62f1b0f4acc 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/IEmfValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/IEmfValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/IStateValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/IStateValidator.cs index 00f91f4697e..0aac2e00646 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/IStateValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/IStateValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/LineToValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/LineToValidator.cs index edef8ad6089..802955ab8be 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/LineToValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/LineToValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenColorValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenColorValidator.cs index 50b80208e7b..74063ecf60d 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenColorValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenColorValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenStyleValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenStyleValidator.cs index 226e0e4b821..ba8a2f8823c 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenStyleValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenStyleValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenValidator.cs index 92ef6ad4e08..b9447e88bd5 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenWidthValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenWidthValidator.cs index 308cc835fd3..c0961e80f7a 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenWidthValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PenWidthValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Poly16Validator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Poly16Validator.cs index 2f5f896bcd4..8fb3ab299c4 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Poly16Validator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Poly16Validator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PolyPoly16Validator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PolyPoly16Validator.cs index ec74e90aea5..c0a56225b6b 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PolyPoly16Validator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PolyPoly16Validator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PolyPolygon16Validator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PolyPolygon16Validator.cs index fb10fa5f68c..95419758cc4 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PolyPolygon16Validator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PolyPolygon16Validator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PolyPolyline16Validator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PolyPolyline16Validator.cs index 4aa6c8d4f72..a736e36d9dd 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PolyPolyline16Validator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/PolyPolyline16Validator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Polygon16Validator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Polygon16Validator.cs index b3b7c9b8ece..df4065932a3 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Polygon16Validator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Polygon16Validator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Polyline16Validator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Polyline16Validator.cs index be02fbf07b5..827988790a7 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Polyline16Validator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Polyline16Validator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/RectangleValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/RectangleValidator.cs index 9aa31be6586..77fe47552e3 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/RectangleValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/RectangleValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/RepeatValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/RepeatValidator.cs index 9bf2b22ed2d..091bb77385d 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/RepeatValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/RepeatValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Rop2Validator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Rop2Validator.cs index 8606d66bd8e..282243ad255 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Rop2Validator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Rop2Validator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/SkipAllValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/SkipAllValidator.cs index 2240fe9bd79..12611e4d689 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/SkipAllValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/SkipAllValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/SkipToValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/SkipToValidator.cs index d17029dc123..1ee65af2273 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/SkipToValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/SkipToValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/SkipTypesValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/SkipTypesValidator.cs index 7a29fcc4725..b0bde5bc89d 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/SkipTypesValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/SkipTypesValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/State.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/State.cs index c8f0d5d179c..c8ccf694ad3 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/State.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/State.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/StateValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/StateValidator.cs index e7f4568073f..9ce077cda80 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/StateValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/StateValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/TextColorValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/TextColorValidator.cs index 810f27f9913..1102fdc5282 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/TextColorValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/TextColorValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/TextOutValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/TextOutValidator.cs index 41294a9495e..7ca90c29360 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/TextOutValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/TextOutValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/TransformValidator.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/TransformValidator.cs index 4eb5bef72dc..d154d74385f 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/TransformValidator.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/TransformValidator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Validate.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Validate.cs index 6bf6160aee8..b655e81d323 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Validate.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/Validate.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/ModuleInitializer.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/ModuleInitializer.cs index b75ae91495a..bd13bfb703c 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/ModuleInitializer.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/ModuleInitializer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/NoAssertContext.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/NoAssertContext.cs index 8d131fa342f..a479116fbfd 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/NoAssertContext.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/NoAssertContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable enable @@ -21,16 +20,16 @@ public sealed class NoAssertContext : IDisposable // We do, however need to lock around hooking/unhooking our custom listener to make sure that we // are rerouting correctly if multiple threads are creating/disposing this class concurrently. - private static readonly object s_lock = new object(); + private static readonly object s_lock = new(); private static bool s_hooked; private static bool s_hasDefaultListener; private static bool s_hasThrowingListener; - private static readonly ConcurrentDictionary s_suppressedThreads = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary s_suppressedThreads = new(); // "Default" is the listener that terminates the process when debug assertions fail. private static readonly TraceListener? s_defaultListener = Trace.Listeners["Default"]; - private static readonly NoAssertListener s_noAssertListener = new NoAssertListener(); + private static readonly NoAssertListener s_noAssertListener = new(); public NoAssertContext() { diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.Windows.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.Windows.cs index 0477298a06c..4ee3ef4b15b 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.Windows.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.Windows.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using System.Security; @@ -33,7 +32,7 @@ public static partial class PlatformDetection public static bool IsWindowsServerCore => GetInstallationType().Equals("Server Core", StringComparison.OrdinalIgnoreCase); public static int WindowsVersion => GetWindowsVersion(); public static bool IsMacOsHighSierraOrHigher { get; } - public static Version ICUVersion => new Version(0, 0, 0, 0); + public static Version ICUVersion => new(0, 0, 0, 0); public static bool IsRedHatFamily => false; public static bool IsNotRedHatFamily => true; public static bool IsRedHatFamily6 => false; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.cs index 30d0adf6283..25fc44a1cf8 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -65,7 +64,7 @@ public static partial class PlatformDetection // running in AppContainer when running on .NetNative. public static bool IsNotNetNativeRunningAsConsoleApp => !(IsNetNative && !IsInAppContainer); - private static readonly Lazy m_isWindowsSubsystemForLinux = new Lazy(GetIsWindowsSubsystemForLinux); + private static readonly Lazy m_isWindowsSubsystemForLinux = new(GetIsWindowsSubsystemForLinux); public static bool IsWindowsSubsystemForLinux => m_isWindowsSubsystemForLinux.Value; public static bool IsNotWindowsSubsystemForLinux => !IsWindowsSubsystemForLinux; @@ -91,7 +90,7 @@ private static bool GetIsWindowsSubsystemForLinux() return false; } - private static readonly Lazy s_largeArrayIsNotSupported = new Lazy(IsLargeArrayNotSupported); + private static readonly Lazy s_largeArrayIsNotSupported = new(IsLargeArrayNotSupported); [MethodImpl(MethodImplOptions.NoOptimization)] private static bool IsLargeArrayNotSupported() diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Properties/InternalsVisibleTo.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Properties/InternalsVisibleTo.cs index 856216fbd25..b8a60fe3ae0 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Properties/InternalsVisibleTo.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Properties/InternalsVisibleTo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/System/Windows/Forms/BinaryFormat/BinaryFormatTestExtensions.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/System/Windows/Forms/BinaryFormat/BinaryFormatTestExtensions.cs index 628feac5b9f..b5e8a2cdbb2 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/System/Windows/Forms/BinaryFormat/BinaryFormatTestExtensions.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/System/Windows/Forms/BinaryFormat/BinaryFormatTestExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.Serialization; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/SystemCOLORs.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/SystemCOLORs.cs index 6e354330bab..8f00854e431 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/SystemCOLORs.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/SystemCOLORs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/EditClass.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/EditClass.cs index 258aa2f93d9..2e53e1f9225 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/EditClass.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/EditClass.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/EditControl.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/EditControl.cs index c194bed6ed3..0ea04ead502 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/EditControl.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/EditControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/Window.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/Window.cs index a25a0096bb5..9bf9c7c8349 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/Window.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/Window.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/WindowClass.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/WindowClass.cs index f48eaa52329..36885ee3215 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/WindowClass.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Win32/WindowClass.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Reflection; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Windows/Win32/System/Com/ComClassFactory.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Windows/Win32/System/Com/ComClassFactory.cs index e4e899851be..b25bc1ce816 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Windows/Win32/System/Com/ComClassFactory.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Windows/Win32/System/Com/ComClassFactory.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Windows/Win32/System/Ole/DropTargetMock.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Windows/Win32/System/Ole/DropTargetMock.cs index 777d8d78e6b..acf7a3d531c 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Windows/Win32/System/Ole/DropTargetMock.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Windows/Win32/System/Ole/DropTargetMock.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Com; using Windows.Win32.System.SystemServices; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/GlobalUsings.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/GlobalUsings.cs index 5aa8144cf45..46aa0cc2626 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/GlobalUsings.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/GlobalUsings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. global using Windows.Win32; global using Windows.Win32.Foundation; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/LVITEMWTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/LVITEMWTests.cs index 9dc1404f725..ae6d6810398 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/LVITEMWTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/LVITEMWTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.ComCtl32; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/MCGRIDINFOTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/MCGRIDINFOTests.cs index fdb26132cac..130451f2f8c 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/MCGRIDINFOTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/MCGRIDINFOTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop.ComCtl32; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/TASKDIALOGCONFIGIconUnionTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/TASKDIALOGCONFIGIconUnionTests.cs index fc8878e05da..cfa44e0b62d 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/TASKDIALOGCONFIGIconUnionTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/TASKDIALOGCONFIGIconUnionTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.ComCtl32; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/TASKDIALOGCONFIGTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/TASKDIALOGCONFIGTests.cs index 2ee41067531..788e97eba9a 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/TASKDIALOGCONFIGTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/TASKDIALOGCONFIGTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.ComCtl32; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/TASKDIALOG_BUTTONTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/TASKDIALOG_BUTTONTests.cs index d78ad96ae48..92178253ef6 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/TASKDIALOG_BUTTONTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/ComCtl32/TASKDIALOG_BUTTONTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.ComCtl32; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Comdlg32/PRINTDLGWTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Comdlg32/PRINTDLGWTests.cs index bf65e966a25..3f18186e61a 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Comdlg32/PRINTDLGWTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Comdlg32/PRINTDLGWTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.Comdlg32; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Gdi32/GetStockObjectTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Gdi32/GetStockObjectTests.cs index 3f9f0843f1e..700ddea1b86 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Gdi32/GetStockObjectTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Gdi32/GetStockObjectTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Gdi32Tests; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/GdiPlus/ARGBTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/GdiPlus/ARGBTests.cs index cd43fb6224e..c998e1caed7 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/GdiPlus/ARGBTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/GdiPlus/ARGBTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; @@ -37,7 +36,7 @@ public void ToFromColor(Color color) } public static TheoryData Colors => - new TheoryData + new() { Color.CornflowerBlue, Color.Transparent, diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Kernel32/FILETIMETests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Kernel32/FILETIMETests.cs index afbf6133da3..daba6eeae7a 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Kernel32/FILETIMETests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Kernel32/FILETIMETests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Kernel32/SYSTEMTIMETests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Kernel32/SYSTEMTIMETests.cs index aae6876a9b3..94f3377005d 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Kernel32/SYSTEMTIMETests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Kernel32/SYSTEMTIMETests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Mocks/MockCursor.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Mocks/MockCursor.cs index dc4c75ab4f8..dfb4a71d68e 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Mocks/MockCursor.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Mocks/MockCursor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Ole32/CADWORDTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Ole32/CADWORDTests.cs index a764557d052..6aa04748197 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Ole32/CADWORDTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Ole32/CADWORDTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.System.Ole; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Ole32/CALPOLESTRTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Ole32/CALPOLESTRTests.cs index 97f24b0667a..5d5abf2a5ec 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Ole32/CALPOLESTRTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Ole32/CALPOLESTRTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.System.Ole; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Ole32/IPictureTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Ole32/IPictureTests.cs index 817554ef300..92ee2e4ce05 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Ole32/IPictureTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Ole32/IPictureTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Primitives.Tests.Interop.Mocks; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/DECIMALTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/DECIMALTests.cs index ed96701152e..0262a1f73e4 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/DECIMALTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/DECIMALTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/ITypeInfoTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/ITypeInfoTests.cs index fa5ca8fa1a7..28caada8a3f 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/ITypeInfoTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/ITypeInfoTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/SAFEARRAYTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/SAFEARRAYTests.cs index ececfee56f7..0c5d15d9f80 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/SAFEARRAYTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/SAFEARRAYTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/VARIANTTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/VARIANTTests.cs index ac44c726d6b..bd19d46ec3d 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/VARIANTTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Oleaut32/VARIANTTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -5786,6 +5785,19 @@ public void MarshallingFromExchangeTypes() } } + [Fact] + public void MarshallingFromIntAndUint() + { + // Interop marshals as VT_I4/VT_UI4 and not VT_INT/VT_UINT + VARIANT variant = new(); + int intValue = 42; + Marshal.GetNativeVariantForObject(intValue, (nint)(void*)&variant); + variant.vt.Should().Be(VT_I4); + uint uintValue = 42; + Marshal.GetNativeVariantForObject(uintValue, (nint)(void*)&variant); + variant.vt.Should().Be(VT_UI4); + } + [DllImport(Libraries.Propsys, ExactSpelling = true)] private static extern unsafe HRESULT InitPropVariantFromCLSID(Guid* clsid, VARIANT* ppropvar); diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/PARAMTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/PARAMTests.cs index fff128882cb..a9a2924539c 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/PARAMTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/PARAMTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Richedit/CHARFORMAT2WTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Richedit/CHARFORMAT2WTests.cs index 83584d673ad..96b70a5fb31 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Richedit/CHARFORMAT2WTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Richedit/CHARFORMAT2WTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.Richedit; @@ -28,7 +27,7 @@ public unsafe void CharFormat_FaceName() // CHARFORMAT has space for 32 characters, we want to see it gets // cut to 31 to make room for the null. - string bigString = new string('*', 32); + string bigString = new('*', 32); charFormat.FaceName = bigString; Assert.True(charFormat.FaceName.SequenceEqual(bigString.AsSpan().Slice(1))); diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Richedit/EDITSTREAMTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Richedit/EDITSTREAMTests.cs index 69c4d1dd52c..cbf0783375e 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Richedit/EDITSTREAMTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Richedit/EDITSTREAMTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.Richedit; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Shell32/ShellItemTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Shell32/ShellItemTests.cs index 8c6c8e68023..b928c0d1c86 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Shell32/ShellItemTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Shell32/ShellItemTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.UI.Shell.Common; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/GetWindowTextTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/GetWindowTextTests.cs index 42b641cf96c..52452706fef 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/GetWindowTextTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/GetWindowTextTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Primitives.Tests.Interop.User32; @@ -23,7 +22,7 @@ private void CallGetWindowText(bool useBeforeGetTextLengthCallback) const string shortText = "A"; // Use a long string that exceeds the initial buffer size (16). - string longText = new string('X', 50); + string longText = new('X', 50); var windowClass = new ChangeWindowTextClass(); windowClass.Register(); diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/LOGFONTWTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/LOGFONTWTests.cs index f0dbcb52a7e..cb3dc932d32 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/LOGFONTWTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/LOGFONTWTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Primitives.Tests.Interop.User32; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/SystemParametersInfoWTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/SystemParametersInfoWTests.cs index 1cc394698fe..2e06516a80c 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/SystemParametersInfoWTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/SystemParametersInfoWTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/BufferScopeTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/BufferScopeTests.cs index 4f24a747a6c..8b7311c019a 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/BufferScopeTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/BufferScopeTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Tests; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/TestAccessors.UiaTextRangeTestAccessor.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/TestAccessors.UiaTextRangeTestAccessor.cs index 604f3031e2d..770a1742f73 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/TestAccessors.UiaTextRangeTestAccessor.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/TestAccessors.UiaTextRangeTestAccessor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.Automation; @@ -65,5 +64,5 @@ public HorizontalTextAlignment GetHorizontalTextAlignment(WINDOW_STYLE windowSty } internal static UiaTextRangeTestAccessor TestAccessor(this UiaTextRange textRange) - => new UiaTextRangeTestAccessor(textRange); + => new(textRange); } diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/UiaTextProviderTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/UiaTextProviderTests.cs index a5bb6b7b80c..b0a9e7296a1 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/UiaTextProviderTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/UiaTextProviderTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Automation; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/UiaTextRangeTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/UiaTextRangeTests.cs index f060adea517..8258448d2ac 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/UiaTextRangeTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/UiaTextRangeTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ArrayTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ArrayTests.cs index 86fe6bc6c08..3fc0bd560e2 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ArrayTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ArrayTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/BinaryFormatWriterTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/BinaryFormatWriterTests.cs index 83d9d91eb0a..86207ab7391 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/BinaryFormatWriterTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/BinaryFormatWriterTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Runtime.Serialization.Formatters.Binary; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/BinaryFormattedObjectTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/BinaryFormattedObjectTests.cs index cebc4006cd3..00d8b8655ad 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/BinaryFormattedObjectTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/BinaryFormattedObjectTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; @@ -178,7 +177,7 @@ public void ReadHashTableWithNullValues() value.ObjectId.Should().Be(4); value.Value.Should().BeOneOf("Yowza", "Youza", "Meeza"); - array = (ArrayRecord)format[(MemberReference)systemClass["Values"]]; ; + array = (ArrayRecord)format[(MemberReference)systemClass["Values"]]; array.ArrayInfo.ObjectId.Should().Be(3); array.ArrayInfo.Length.Should().Be(3); array.ArrayObjects[0].Should().BeOfType(); diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/BinaryFormattedTypes.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/BinaryFormattedTypes.cs index bf00fea76ba..746d6ce5f89 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/BinaryFormattedTypes.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/BinaryFormattedTypes.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ClassInfoTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ClassInfoTests.cs index 5389b0a08cb..5f5250fdb8f 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ClassInfoTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ClassInfoTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat.Tests; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/CountTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/CountTests.cs index f59ac90e695..80bbd0c4eb0 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/CountTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/CountTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat.Tests; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ExceptionTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ExceptionTests.cs index cb542fce7a3..6c88318a557 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ExceptionTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ExceptionTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/HashTableTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/HashTableTests.cs index 9a00a733c13..c00265f58d5 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/HashTableTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/HashTableTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Drawing; @@ -59,6 +58,55 @@ public void HashTable_GetObjectData() enumerator.Current.Value.Should().BeEquivalentTo(new object[] { "That" }); } + [Fact] + public void HashTable_CustomComparer() + { + Hashtable hashtable = new(new CustomHashCodeProvider(), StringComparer.OrdinalIgnoreCase) + { + { "This", "That" } + }; + + BinaryFormattedObject format = hashtable.SerializeAndParse(); + format[1].Should().BeOfType(); + format[2].Should().BeOfType().Which.Name.Should().Be("System.Collections.Hashtable"); + format[3].Should().BeOfType().Which.Name.Should().Be("System.OrdinalComparer"); + format[4].Should().BeOfType().Which.Name.Should().Be("System.Windows.Forms.BinaryFormat.Tests.HashtableTests+CustomHashCodeProvider"); + format[5].Should().BeOfType(); + format[6].Should().BeOfType(); + } + + [Fact] + public void HashTable_CustomComparer_DoesNotRead() + { + Hashtable hashtable = new(new CustomHashCodeProvider(), StringComparer.OrdinalIgnoreCase) + { + { "This", "That" } + }; + + BinaryFormattedObject format = hashtable.SerializeAndParse(); + format.TryGetPrimitiveHashtable(out Hashtable? deserialized).Should().BeFalse(); + deserialized.Should().BeNull(); + } + + [Serializable] + public class CustomHashCodeProvider : IHashCodeProvider + { + public int GetHashCode(object obj) => HashCode.Combine(obj); + } + + [Fact] + public void BinaryFormatWriter_WriteCustomComparerfails() + { + Hashtable hashtable = new(new CustomHashCodeProvider(), StringComparer.OrdinalIgnoreCase) + { + { "This", "That" } + }; + + using MemoryStream stream = new(); + BinaryFormatWriter.TryWriteHashtable(stream, hashtable).Should().BeFalse(); + stream.Position.Should().Be(0); + } + [Theory] [MemberData(nameof(Hashtables_TestData))] public void BinaryFormatWriter_WriteHashtables(Hashtable hashtable) diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ListTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ListTests.cs index 33338063806..230064ba22a 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ListTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/ListTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/MemberTypeInfoTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/MemberTypeInfoTests.cs index 71e38948e69..fe4099e4745 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/MemberTypeInfoTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/MemberTypeInfoTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat.Tests; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/NullTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/NullTests.cs index c4b84b971de..b57769c0bb1 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/NullTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/NullTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat.Tests; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/PointFTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/PointFTests.cs index 92cbd41b432..ad1a7a42f7e 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/PointFTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/PointFTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/PrimitiveTypeTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/PrimitiveTypeTests.cs index d77ce6aae31..2548a9c368f 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/PrimitiveTypeTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/PrimitiveTypeTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.Serialization.Formatters.Binary; using System.Text; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/RecordMapTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/RecordMapTests.cs index 0cb04f74d10..5a7e529b149 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/RecordMapTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/RecordMapTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat.Tests; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/StringRecordsCollectionTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/StringRecordsCollectionTests.cs index 2d7d5717aaa..36c83e59f39 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/StringRecordsCollectionTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/StringRecordsCollectionTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.BinaryFormat.Tests; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/SystemDrawingTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/SystemDrawingTests.cs index dcd7a60a021..3798293bfa0 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/SystemDrawingTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/BinaryFormat/SystemDrawingTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/DeviceContextHdcScopeTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/DeviceContextHdcScopeTests.cs index ce1c48656df..9783097eec3 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/DeviceContextHdcScopeTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/DeviceContextHdcScopeTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Drawing2D; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/DeviceContextScopeTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/DeviceContextScopeTests.cs index b79fa263246..2db959c4ef3 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/DeviceContextScopeTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/DeviceContextScopeTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Drawing2D; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/FileDialogCustomPlaceTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/FileDialogCustomPlaceTests.cs index e488ea9112e..515dab0b718 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/FileDialogCustomPlaceTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/FileDialogCustomPlaceTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Tests; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/FileDialogCustomPlacesCollectionTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/FileDialogCustomPlacesCollectionTests.cs index 0e17333db2f..a02c26c501b 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/FileDialogCustomPlacesCollectionTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/FileDialogCustomPlacesCollectionTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Tests; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/IdTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/IdTests.cs index 6d2523187ee..3dac040b44f 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/IdTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/IdTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Tests; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Internals/ArgumentValidationTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Internals/ArgumentValidationTests.cs index f74c35d7bf3..3550d3611e9 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Internals/ArgumentValidationTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Internals/ArgumentValidationTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Tests; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/LocalAppContextSwitchesTest.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/LocalAppContextSwitchesTest.cs index afabddf3d1a..77d8cdb76fe 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/LocalAppContextSwitchesTest.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/LocalAppContextSwitchesTest.cs @@ -1,6 +1,5 @@ // Licensed to the.NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.Versioning; using System.Windows.Forms.Primitives; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/NonNullCollectionTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/NonNullCollectionTests.cs index 588cada3c9f..3bb39bb3586 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/NonNullCollectionTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/NonNullCollectionTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/RefCacheTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/RefCacheTests.cs index 13f40c22368..23be0e958c4 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/RefCacheTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/RefCacheTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/SinglyLinkedListTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/SinglyLinkedListTests.cs index 88969f6af44..8ea9d4d7185 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/SinglyLinkedListTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/SinglyLinkedListTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Tests; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/AgileComPointerTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/AgileComPointerTests.cs index 18b1c830ebf..a2d8604c64c 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/AgileComPointerTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/AgileComPointerTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/GlobalInterfaceTableTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/GlobalInterfaceTableTests.cs index 8f60e355ef7..ff3fd1b83aa 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/GlobalInterfaceTableTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/GlobalInterfaceTableTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/RegionTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/RegionTests.cs index 4c90d02f7a8..c3f3763e10a 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/RegionTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/RegionTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/System/Com/IDispatchTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/System/Com/IDispatchTests.cs index 9d71846212a..101f6ea00c1 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/System/Com/IDispatchTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/System/Com/IDispatchTests.cs @@ -1,13 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; -using Windows.Win32.System.Com; using Windows.Win32.System.Ole; using Windows.Win32.System.Variant; -namespace System.Windows.Forms.Primitives.Tests.Windows.Win32.System.Com; +namespace Windows.Win32.System.Com.Tests; [Collection("Sequential")] public partial class IDispatchTests diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/System/Ole/ClassPropertyDispatchAdapterTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/System/Ole/ClassPropertyDispatchAdapterTests.cs new file mode 100644 index 00000000000..c1a4a3494cc --- /dev/null +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Windows/Win32/System/Ole/ClassPropertyDispatchAdapterTests.cs @@ -0,0 +1,89 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; +using Windows.Win32.System.Variant; +using static Windows.Win32.System.Ole.FDEX_PROP_FLAGS; + +namespace Windows.Win32.System.Ole.Tests; + +public unsafe class ClassPropertyDispatchAdapterTests +{ + [Fact] + public void ClassPropertyDispatchAdapter_SingleClass() + { + TestClass testClass = new(); + ClassPropertyDispatchAdapter adapter = new(testClass); + + adapter.TryGetNextDispId(PInvoke.DISPID_STARTENUM, out int result).Should().BeTrue(); + result.Should().Be(0x10000); + adapter.TryGetMemberName(result, out string? name).Should().BeTrue(); + name.Should().Be("Value"); + adapter.TryGetMemberProperties(result, out var flags).Should().BeTrue(); + flags.Should().Be(fdexPropCanGet | fdexPropCanPut | fdexPropCannotPutRef | fdexPropCannotCall | fdexPropCannotConstruct | fdexPropCannotSourceEvents); + + VARIANT parameter = (VARIANT)42; + Com.DISPPARAMS dispParams = new() + { + cArgs = 1, + rgvarg = ¶meter + }; + + HRESULT hr = adapter.Invoke(result, 0, Com.DISPATCH_FLAGS.DISPATCH_PROPERTYPUT, &dispParams, null); + hr.Succeeded.Should().BeTrue(); + testClass.Value.Should().Be(42); + VARIANT returnValue = default; + hr = adapter.Invoke(result, 0, Com.DISPATCH_FLAGS.DISPATCH_PROPERTYGET, &dispParams, &returnValue); + hr.Succeeded.Should().BeTrue(); + ((int)returnValue).Should().Be(42); + + adapter.TryGetNextDispId(result, out result).Should().BeTrue(); + result.Should().Be(0x10001); + adapter.TryGetMemberName(result, out name).Should().BeTrue(); + name.Should().Be("Name"); + adapter.TryGetMemberProperties(result, out flags).Should().BeTrue(); + flags.Should().Be(fdexPropCanGet | fdexPropCannotPut | fdexPropCannotPutRef | fdexPropCannotCall | fdexPropCannotConstruct | fdexPropCannotSourceEvents); + hr = adapter.Invoke(result, 0, Com.DISPATCH_FLAGS.DISPATCH_PROPERTYGET, &dispParams, &returnValue); + hr.Succeeded.Should().BeTrue(); + ((BSTR)returnValue).ToStringAndFree().Should().Be("Q"); + + adapter.TryGetNextDispId(result, out result).Should().BeTrue(); + result.Should().Be(0x1); + adapter.TryGetMemberName(result, out name).Should().BeTrue(); + name.Should().Be("Percent"); + } + + [Fact] + public void ClassPropertyDispatchAdapter_ConflictingDispID() + { + TestClass testClass = new(); + TestClass2 testClass2 = new(); + + ClassPropertyDispatchAdapter adapter = new(testClass, new(testClass2)); + adapter.TryGetDispID("Percent", out int dispId).Should().BeTrue(); + dispId.Should().Be(0x10002); + adapter.TryGetDispID("CollidingDispId", out dispId).Should().BeTrue(); + dispId.Should().Be(0x1); + + adapter = new(testClass2, new(testClass)); + adapter.TryGetDispID("Percent", out dispId).Should().BeTrue(); + dispId.Should().Be(0x1); + adapter.TryGetDispID("CollidingDispId", out dispId).Should().BeTrue(); + dispId.Should().Be(0x10002); + } + + public class TestClass + { + public int Value { get; set; } + public string Name { get; } = "Q"; + + [DispId(1)] + public float Percent { get; set; } + } + + public class TestClass2 + { + [DispId(1)] + public int CollidingDispId { get; set; } + } +} diff --git a/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Runtime/CompilerServices/IsExternalInit.cs b/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Runtime/CompilerServices/IsExternalInit.cs index ea3907a883e..9d08ade203c 100644 --- a/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Runtime/CompilerServices/IsExternalInit.cs +++ b/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Runtime/CompilerServices/IsExternalInit.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. // Copied from: // https://github.com/dotnet/runtime/blob/218ef0f7776c2c20f6c594e3475b80f1fe2d7d08/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IsExternalInit.cs diff --git a/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Windows/Forms/SourceGenerators/EnumValidationGenerator.cs b/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Windows/Forms/SourceGenerators/EnumValidationGenerator.cs index e34dd2330e8..71a07f64c8f 100644 --- a/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Windows/Forms/SourceGenerators/EnumValidationGenerator.cs +++ b/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Windows/Forms/SourceGenerators/EnumValidationGenerator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Immutable; using System.Text; diff --git a/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Windows/Forms/SourceGenerators/EnumValidationInfo.cs b/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Windows/Forms/SourceGenerators/EnumValidationInfo.cs index c80fcdf1aff..1ce5e51face 100644 --- a/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Windows/Forms/SourceGenerators/EnumValidationInfo.cs +++ b/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Windows/Forms/SourceGenerators/EnumValidationInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Immutable; diff --git a/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Windows/Forms/SourceGenerators/EquatableArray`1.cs b/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Windows/Forms/SourceGenerators/EquatableArray`1.cs index 8bb17e6e16a..2a3fa9cf0ea 100644 --- a/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Windows/Forms/SourceGenerators/EquatableArray`1.cs +++ b/src/System.Windows.Forms.PrivateSourceGenerators/src/System/Windows/Forms/SourceGenerators/EquatableArray`1.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Immutable; diff --git a/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/EnumValidationTests.cs b/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/EnumValidationTests.cs index 5ef10b23b59..d164c03e558 100644 --- a/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/EnumValidationTests.cs +++ b/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/EnumValidationTests.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Immutable; using System.Reflection; diff --git a/src/System.Windows.Forms/src/AssemblyRef.cs b/src/System.Windows.Forms/src/AssemblyRef.cs index 12cff395b2a..ab3e532e150 100644 --- a/src/System.Windows.Forms/src/AssemblyRef.cs +++ b/src/System.Windows.Forms/src/AssemblyRef.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. internal static class FXAssembly { diff --git a/src/System.Windows.Forms/src/GlobalUsings.cs b/src/System.Windows.Forms/src/GlobalUsings.cs index d48813d93bf..31fb337a417 100644 --- a/src/System.Windows.Forms/src/GlobalUsings.cs +++ b/src/System.Windows.Forms/src/GlobalUsings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. global using System.Diagnostics; global using System.Diagnostics.CodeAnalysis; diff --git a/src/System.Windows.Forms/src/Properties/AssemblyInfo.cs b/src/System.Windows.Forms/src/Properties/AssemblyInfo.cs index bde86a6b6f2..45c3e6510a3 100644 --- a/src/System.Windows.Forms/src/Properties/AssemblyInfo.cs +++ b/src/System.Windows.Forms/src/Properties/AssemblyInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/System.Windows.Forms/src/Properties/TypeForwards.cs b/src/System.Windows.Forms/src/Properties/TypeForwards.cs index 43a72c032f6..9abff666cd2 100644 --- a/src/System.Windows.Forms/src/Properties/TypeForwards.cs +++ b/src/System.Windows.Forms/src/Properties/TypeForwards.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/System.Windows.Forms/src/PublicAPI.Shipped.txt b/src/System.Windows.Forms/src/PublicAPI.Shipped.txt index 3cfbd49a94f..5afe50dfe5d 100644 --- a/src/System.Windows.Forms/src/PublicAPI.Shipped.txt +++ b/src/System.Windows.Forms/src/PublicAPI.Shipped.txt @@ -4,8 +4,8 @@ ~override System.Windows.Forms.ControlBindingsCollection.RemoveCore(System.Windows.Forms.Binding dataBinding) -> void ~override System.Windows.Forms.CurrencyManager.Current.get -> object ~override System.Windows.Forms.CurrencyManager.GetItemProperties() -> System.ComponentModel.PropertyDescriptorCollection -~override System.Windows.Forms.DataGridView.BackgroundImage.get -> System.Drawing.Image -~override System.Windows.Forms.DataGridView.BackgroundImage.set -> void +override System.Windows.Forms.DataGridView.BackgroundImage.get -> System.Drawing.Image? +override System.Windows.Forms.DataGridView.BackgroundImage.set -> void ~override System.Windows.Forms.DataGridView.CreateAccessibilityInstance() -> System.Windows.Forms.AccessibleObject ~override System.Windows.Forms.DataGridView.CreateControlsInstance() -> System.Windows.Forms.Control.ControlCollection ~override System.Windows.Forms.DataGridView.Font.get -> System.Drawing.Font @@ -42,26 +42,6 @@ ~override System.Windows.Forms.DataGridView.OnVisibleChanged(System.EventArgs e) -> void ~override System.Windows.Forms.DataGridView.Text.get -> string ~override System.Windows.Forms.DataGridView.Text.set -> void -~override System.Windows.Forms.DataGridViewButtonCell.Clone() -> object -~override System.Windows.Forms.DataGridViewButtonCell.CreateAccessibilityInstance() -> System.Windows.Forms.AccessibleObject -~override System.Windows.Forms.DataGridViewButtonCell.EditType.get -> System.Type -~override System.Windows.Forms.DataGridViewButtonCell.FormattedValueType.get -> System.Type -~override System.Windows.Forms.DataGridViewButtonCell.GetContentBounds(System.Drawing.Graphics graphics, System.Windows.Forms.DataGridViewCellStyle cellStyle, int rowIndex) -> System.Drawing.Rectangle -~override System.Windows.Forms.DataGridViewButtonCell.GetErrorIconBounds(System.Drawing.Graphics graphics, System.Windows.Forms.DataGridViewCellStyle cellStyle, int rowIndex) -> System.Drawing.Rectangle -~override System.Windows.Forms.DataGridViewButtonCell.GetPreferredSize(System.Drawing.Graphics graphics, System.Windows.Forms.DataGridViewCellStyle cellStyle, int rowIndex, System.Drawing.Size constraintSize) -> System.Drawing.Size -~override System.Windows.Forms.DataGridViewButtonCell.GetValue(int rowIndex) -> object -~override System.Windows.Forms.DataGridViewButtonCell.KeyDownUnsharesRow(System.Windows.Forms.KeyEventArgs e, int rowIndex) -> bool -~override System.Windows.Forms.DataGridViewButtonCell.KeyUpUnsharesRow(System.Windows.Forms.KeyEventArgs e, int rowIndex) -> bool -~override System.Windows.Forms.DataGridViewButtonCell.MouseDownUnsharesRow(System.Windows.Forms.DataGridViewCellMouseEventArgs e) -> bool -~override System.Windows.Forms.DataGridViewButtonCell.MouseUpUnsharesRow(System.Windows.Forms.DataGridViewCellMouseEventArgs e) -> bool -~override System.Windows.Forms.DataGridViewButtonCell.OnKeyDown(System.Windows.Forms.KeyEventArgs e, int rowIndex) -> void -~override System.Windows.Forms.DataGridViewButtonCell.OnKeyUp(System.Windows.Forms.KeyEventArgs e, int rowIndex) -> void -~override System.Windows.Forms.DataGridViewButtonCell.OnMouseDown(System.Windows.Forms.DataGridViewCellMouseEventArgs e) -> void -~override System.Windows.Forms.DataGridViewButtonCell.OnMouseMove(System.Windows.Forms.DataGridViewCellMouseEventArgs e) -> void -~override System.Windows.Forms.DataGridViewButtonCell.OnMouseUp(System.Windows.Forms.DataGridViewCellMouseEventArgs e) -> void -~override System.Windows.Forms.DataGridViewButtonCell.Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates elementState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle, System.Windows.Forms.DataGridViewPaintParts paintParts) -> void -~override System.Windows.Forms.DataGridViewButtonCell.ToString() -> string -~override System.Windows.Forms.DataGridViewButtonCell.ValueType.get -> System.Type ~override System.Windows.Forms.DataGridViewButtonColumn.CellTemplate.get -> System.Windows.Forms.DataGridViewCell ~override System.Windows.Forms.DataGridViewButtonColumn.CellTemplate.set -> void ~override System.Windows.Forms.DataGridViewButtonColumn.Clone() -> object @@ -142,9 +122,6 @@ ~override System.Windows.Forms.DataGridViewComboBoxColumn.CellTemplate.set -> void ~override System.Windows.Forms.DataGridViewComboBoxColumn.Clone() -> object ~override System.Windows.Forms.DataGridViewComboBoxColumn.ToString() -> string -~override System.Windows.Forms.DataGridViewComboBoxEditingControl.CreateAccessibilityInstance() -> System.Windows.Forms.AccessibleObject -~override System.Windows.Forms.DataGridViewComboBoxEditingControl.OnHandleCreated(System.EventArgs e) -> void -~override System.Windows.Forms.DataGridViewComboBoxEditingControl.OnSelectedIndexChanged(System.EventArgs e) -> void ~override System.Windows.Forms.DataGridViewHeaderCell.Clone() -> object ~override System.Windows.Forms.DataGridViewHeaderCell.FormattedValueType.get -> System.Type ~override System.Windows.Forms.DataGridViewHeaderCell.GetInheritedContextMenuStrip(int rowIndex) -> System.Windows.Forms.ContextMenuStrip @@ -269,22 +246,22 @@ ~override System.Windows.Forms.PropertyGrid.Text.get -> string ~override System.Windows.Forms.PropertyGrid.Text.set -> void ~override System.Windows.Forms.TreeNode.ToString() -> string -~override System.Windows.Forms.TreeView.BackgroundImage.get -> System.Drawing.Image -~override System.Windows.Forms.TreeView.BackgroundImage.set -> void -~override System.Windows.Forms.TreeView.CreateAccessibilityInstance() -> System.Windows.Forms.AccessibleObject -~override System.Windows.Forms.TreeView.CreateParams.get -> System.Windows.Forms.CreateParams +override System.Windows.Forms.TreeView.BackgroundImage.get -> System.Drawing.Image? +override System.Windows.Forms.TreeView.BackgroundImage.set -> void +override System.Windows.Forms.TreeView.CreateAccessibilityInstance() -> System.Windows.Forms.AccessibleObject! +override System.Windows.Forms.TreeView.CreateParams.get -> System.Windows.Forms.CreateParams! ~override System.Windows.Forms.TreeView.OnGotFocus(System.EventArgs e) -> void -~override System.Windows.Forms.TreeView.OnHandleCreated(System.EventArgs e) -> void -~override System.Windows.Forms.TreeView.OnHandleDestroyed(System.EventArgs e) -> void -~override System.Windows.Forms.TreeView.OnKeyDown(System.Windows.Forms.KeyEventArgs e) -> void -~override System.Windows.Forms.TreeView.OnKeyPress(System.Windows.Forms.KeyPressEventArgs e) -> void -~override System.Windows.Forms.TreeView.OnKeyUp(System.Windows.Forms.KeyEventArgs e) -> void +override System.Windows.Forms.TreeView.OnHandleCreated(System.EventArgs! e) -> void +override System.Windows.Forms.TreeView.OnHandleDestroyed(System.EventArgs! e) -> void +override System.Windows.Forms.TreeView.OnKeyDown(System.Windows.Forms.KeyEventArgs! e) -> void +override System.Windows.Forms.TreeView.OnKeyPress(System.Windows.Forms.KeyPressEventArgs! e) -> void +override System.Windows.Forms.TreeView.OnKeyUp(System.Windows.Forms.KeyEventArgs! e) -> void ~override System.Windows.Forms.TreeView.OnLostFocus(System.EventArgs e) -> void -~override System.Windows.Forms.TreeView.OnMouseHover(System.EventArgs e) -> void -~override System.Windows.Forms.TreeView.OnMouseLeave(System.EventArgs e) -> void -~override System.Windows.Forms.TreeView.Text.get -> string -~override System.Windows.Forms.TreeView.Text.set -> void -~override System.Windows.Forms.TreeView.ToString() -> string +override System.Windows.Forms.TreeView.OnMouseHover(System.EventArgs! e) -> void +override System.Windows.Forms.TreeView.OnMouseLeave(System.EventArgs! e) -> void +override System.Windows.Forms.TreeView.Text.get -> string! +override System.Windows.Forms.TreeView.Text.set -> void +override System.Windows.Forms.TreeView.ToString() -> string! ~static System.Windows.Forms.AxHost.GetFontFromIFont(object font) -> System.Drawing.Font ~static System.Windows.Forms.AxHost.GetFontFromIFontDisp(object font) -> System.Drawing.Font ~static System.Windows.Forms.AxHost.GetIFontDispFromFont(System.Drawing.Font font) -> object @@ -305,28 +282,11 @@ ~static System.Windows.Forms.HtmlElement.operator ==(System.Windows.Forms.HtmlElement left, System.Windows.Forms.HtmlElement right) -> bool ~static System.Windows.Forms.HtmlWindow.operator !=(System.Windows.Forms.HtmlWindow left, System.Windows.Forms.HtmlWindow right) -> bool ~static System.Windows.Forms.HtmlWindow.operator ==(System.Windows.Forms.HtmlWindow left, System.Windows.Forms.HtmlWindow right) -> bool -~static System.Windows.Forms.ToolStripManager.FindToolStrip(string toolStripName) -> System.Windows.Forms.ToolStrip -~static System.Windows.Forms.ToolStripManager.LoadSettings(System.Windows.Forms.Form targetForm) -> void -~static System.Windows.Forms.ToolStripManager.LoadSettings(System.Windows.Forms.Form targetForm, string key) -> void -~static System.Windows.Forms.ToolStripManager.Merge(System.Windows.Forms.ToolStrip sourceToolStrip, string targetName) -> bool -~static System.Windows.Forms.ToolStripManager.Merge(System.Windows.Forms.ToolStrip sourceToolStrip, System.Windows.Forms.ToolStrip targetToolStrip) -> bool -~static System.Windows.Forms.ToolStripManager.Renderer.get -> System.Windows.Forms.ToolStripRenderer -~static System.Windows.Forms.ToolStripManager.Renderer.set -> void -~static System.Windows.Forms.ToolStripManager.RevertMerge(string targetName) -> bool -~static System.Windows.Forms.ToolStripManager.RevertMerge(System.Windows.Forms.ToolStrip targetToolStrip) -> bool -~static System.Windows.Forms.ToolStripManager.RevertMerge(System.Windows.Forms.ToolStrip targetToolStrip, System.Windows.Forms.ToolStrip sourceToolStrip) -> bool -~static System.Windows.Forms.ToolStripManager.SaveSettings(System.Windows.Forms.Form sourceForm) -> void -~static System.Windows.Forms.ToolStripManager.SaveSettings(System.Windows.Forms.Form sourceForm, string key) -> void ~static System.Windows.Forms.TreeNode.FromHandle(System.Windows.Forms.TreeView tree, nint handle) -> System.Windows.Forms.TreeNode -~System.Windows.Forms.AxHost.ContainingControl.get -> System.Windows.Forms.ContainerControl -~System.Windows.Forms.AxHost.ContainingControl.set -> void ~System.Windows.Forms.AxHost.GetOcx() -> object -~System.Windows.Forms.AxHost.OcxState.get -> System.Windows.Forms.AxHost.State -~System.Windows.Forms.AxHost.OcxState.set -> void ~System.Windows.Forms.AxHost.RaiseOnMouseDown(object o1, object o2, object o3, object o4) -> void ~System.Windows.Forms.AxHost.RaiseOnMouseMove(object o1, object o2, object o3, object o4) -> void ~System.Windows.Forms.AxHost.RaiseOnMouseUp(object o1, object o2, object o3, object o4) -> void -~System.Windows.Forms.AxHost.SetAboutBoxDelegate(System.Windows.Forms.AxHost.AboutBoxDelegate d) -> void ~System.Windows.Forms.AxHost.ShowPropertyPages(System.Windows.Forms.Control control) -> void ~System.Windows.Forms.Binding.BindableComponent.get -> System.Windows.Forms.IBindableComponent ~System.Windows.Forms.Binding.Binding(string propertyName, object dataSource, string dataMember) -> void @@ -371,11 +331,11 @@ ~System.Windows.Forms.ControlBindingsCollection.Remove(System.Windows.Forms.Binding binding) -> void ~System.Windows.Forms.ControlBindingsCollection.this[string propertyName].get -> System.Windows.Forms.Binding ~System.Windows.Forms.CurrencyManager.List.get -> System.Collections.IList -~System.Windows.Forms.DataGridView.AdvancedCellBorderStyle.get -> System.Windows.Forms.DataGridViewAdvancedBorderStyle -~System.Windows.Forms.DataGridView.AdvancedColumnHeadersBorderStyle.get -> System.Windows.Forms.DataGridViewAdvancedBorderStyle -~System.Windows.Forms.DataGridView.AdvancedRowHeadersBorderStyle.get -> System.Windows.Forms.DataGridViewAdvancedBorderStyle -~System.Windows.Forms.DataGridView.AlternatingRowsDefaultCellStyle.get -> System.Windows.Forms.DataGridViewCellStyle -~System.Windows.Forms.DataGridView.AlternatingRowsDefaultCellStyle.set -> void +System.Windows.Forms.DataGridView.AdvancedCellBorderStyle.get -> System.Windows.Forms.DataGridViewAdvancedBorderStyle! +System.Windows.Forms.DataGridView.AdvancedColumnHeadersBorderStyle.get -> System.Windows.Forms.DataGridViewAdvancedBorderStyle! +System.Windows.Forms.DataGridView.AdvancedRowHeadersBorderStyle.get -> System.Windows.Forms.DataGridViewAdvancedBorderStyle! +System.Windows.Forms.DataGridView.AlternatingRowsDefaultCellStyle.get -> System.Windows.Forms.DataGridViewCellStyle! +System.Windows.Forms.DataGridView.AlternatingRowsDefaultCellStyle.set -> void ~System.Windows.Forms.DataGridView.ColumnHeadersDefaultCellStyle.get -> System.Windows.Forms.DataGridViewCellStyle ~System.Windows.Forms.DataGridView.ColumnHeadersDefaultCellStyle.set -> void ~System.Windows.Forms.DataGridView.Columns.get -> System.Windows.Forms.DataGridViewColumnCollection @@ -441,13 +401,6 @@ ~System.Windows.Forms.DataGridViewCellCollection.this[int index].set -> void ~System.Windows.Forms.DataGridViewCellCollection.this[string columnName].get -> System.Windows.Forms.DataGridViewCell ~System.Windows.Forms.DataGridViewCellCollection.this[string columnName].set -> void -~System.Windows.Forms.DataGridViewCellPaintingEventArgs.AdvancedBorderStyle.get -> System.Windows.Forms.DataGridViewAdvancedBorderStyle -~System.Windows.Forms.DataGridViewCellPaintingEventArgs.CellStyle.get -> System.Windows.Forms.DataGridViewCellStyle -~System.Windows.Forms.DataGridViewCellPaintingEventArgs.DataGridViewCellPaintingEventArgs(System.Windows.Forms.DataGridView dataGridView, System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, int columnIndex, System.Windows.Forms.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle, System.Windows.Forms.DataGridViewPaintParts paintParts) -> void -~System.Windows.Forms.DataGridViewCellPaintingEventArgs.ErrorText.get -> string -~System.Windows.Forms.DataGridViewCellPaintingEventArgs.FormattedValue.get -> object -~System.Windows.Forms.DataGridViewCellPaintingEventArgs.Graphics.get -> System.Drawing.Graphics -~System.Windows.Forms.DataGridViewCellPaintingEventArgs.Value.get -> object ~System.Windows.Forms.DataGridViewCellStyle.DataGridViewCellStyle(System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle) -> void ~System.Windows.Forms.DataGridViewCellStyle.DataSourceNullValue.get -> object ~System.Windows.Forms.DataGridViewCellStyle.DataSourceNullValue.set -> void @@ -546,10 +499,6 @@ ~System.Windows.Forms.DataGridViewRowCollection.List.get -> System.Collections.ArrayList ~System.Windows.Forms.DataGridViewRowCollection.SharedRow(int rowIndex) -> System.Windows.Forms.DataGridViewRow ~System.Windows.Forms.DataGridViewRowCollection.this[int index].get -> System.Windows.Forms.DataGridViewRow -~System.Windows.Forms.DataGridViewSelectedCellCollection.Contains(System.Windows.Forms.DataGridViewCell dataGridViewCell) -> bool -~System.Windows.Forms.DataGridViewSelectedCellCollection.CopyTo(System.Windows.Forms.DataGridViewCell[] array, int index) -> void -~System.Windows.Forms.DataGridViewSelectedCellCollection.Insert(int index, System.Windows.Forms.DataGridViewCell dataGridViewCell) -> void -~System.Windows.Forms.DataGridViewSelectedCellCollection.this[int index].get -> System.Windows.Forms.DataGridViewCell ~System.Windows.Forms.HtmlElement.All.get -> System.Windows.Forms.HtmlElementCollection ~System.Windows.Forms.HtmlElement.AppendChild(System.Windows.Forms.HtmlElement newElement) -> System.Windows.Forms.HtmlElement ~System.Windows.Forms.HtmlElement.AttachEventHandler(string eventName, System.EventHandler eventHandler) -> void @@ -662,35 +611,28 @@ ~System.Windows.Forms.TreeNode.TreeNode(string text, System.Windows.Forms.TreeNode[] children) -> void ~System.Windows.Forms.TreeNode.TreeNode(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext context) -> void ~System.Windows.Forms.TreeNode.TreeView.get -> System.Windows.Forms.TreeView -~System.Windows.Forms.TreeNodeCollection.Contains(System.Windows.Forms.TreeNode node) -> bool -~System.Windows.Forms.TreeNodeCollection.CopyTo(System.Array dest, int index) -> void -~System.Windows.Forms.TreeNodeCollection.Find(string key, bool searchAllChildren) -> System.Windows.Forms.TreeNode[] -~System.Windows.Forms.TreeNodeCollection.GetEnumerator() -> System.Collections.IEnumerator -~System.Windows.Forms.TreeNodeCollection.IndexOf(System.Windows.Forms.TreeNode node) -> int -~System.Windows.Forms.TreeNodeCollection.Remove(System.Windows.Forms.TreeNode node) -> void ~System.Windows.Forms.TreeView.GetItemRenderStyles(System.Windows.Forms.TreeNode node, int state) -> System.Windows.Forms.OwnerDrawPropertyBag -~System.Windows.Forms.TreeView.GetNodeAt(int x, int y) -> System.Windows.Forms.TreeNode -~System.Windows.Forms.TreeView.GetNodeAt(System.Drawing.Point pt) -> System.Windows.Forms.TreeNode -~System.Windows.Forms.TreeView.HitTest(int x, int y) -> System.Windows.Forms.TreeViewHitTestInfo -~System.Windows.Forms.TreeView.HitTest(System.Drawing.Point pt) -> System.Windows.Forms.TreeViewHitTestInfo -~System.Windows.Forms.TreeView.ImageKey.get -> string -~System.Windows.Forms.TreeView.ImageKey.set -> void -~System.Windows.Forms.TreeView.ImageList.get -> System.Windows.Forms.ImageList -~System.Windows.Forms.TreeView.ImageList.set -> void -~System.Windows.Forms.TreeView.Nodes.get -> System.Windows.Forms.TreeNodeCollection -~System.Windows.Forms.TreeView.PathSeparator.get -> string -~System.Windows.Forms.TreeView.PathSeparator.set -> void -~System.Windows.Forms.TreeView.SelectedImageKey.get -> string -~System.Windows.Forms.TreeView.SelectedImageKey.set -> void -~System.Windows.Forms.TreeView.SelectedNode.get -> System.Windows.Forms.TreeNode -~System.Windows.Forms.TreeView.SelectedNode.set -> void -~System.Windows.Forms.TreeView.StateImageList.get -> System.Windows.Forms.ImageList -~System.Windows.Forms.TreeView.StateImageList.set -> void -~System.Windows.Forms.TreeView.TopNode.get -> System.Windows.Forms.TreeNode -~System.Windows.Forms.TreeView.TopNode.set -> void -~System.Windows.Forms.TreeView.TreeViewNodeSorter.get -> System.Collections.IComparer -~System.Windows.Forms.TreeView.TreeViewNodeSorter.set -> void -~virtual System.Windows.Forms.AxHost.CreateInstanceCore(System.Guid clsid) -> object +System.Windows.Forms.TreeView.GetNodeAt(int x, int y) -> System.Windows.Forms.TreeNode? +System.Windows.Forms.TreeView.GetNodeAt(System.Drawing.Point pt) -> System.Windows.Forms.TreeNode? +System.Windows.Forms.TreeView.HitTest(int x, int y) -> System.Windows.Forms.TreeViewHitTestInfo! +System.Windows.Forms.TreeView.HitTest(System.Drawing.Point pt) -> System.Windows.Forms.TreeViewHitTestInfo! +System.Windows.Forms.TreeView.ImageKey.get -> string! +System.Windows.Forms.TreeView.ImageKey.set -> void +System.Windows.Forms.TreeView.ImageList.get -> System.Windows.Forms.ImageList? +System.Windows.Forms.TreeView.ImageList.set -> void +System.Windows.Forms.TreeView.Nodes.get -> System.Windows.Forms.TreeNodeCollection! +System.Windows.Forms.TreeView.PathSeparator.get -> string! +System.Windows.Forms.TreeView.PathSeparator.set -> void +System.Windows.Forms.TreeView.SelectedImageKey.get -> string! +System.Windows.Forms.TreeView.SelectedImageKey.set -> void +System.Windows.Forms.TreeView.SelectedNode.get -> System.Windows.Forms.TreeNode? +System.Windows.Forms.TreeView.SelectedNode.set -> void +System.Windows.Forms.TreeView.StateImageList.get -> System.Windows.Forms.ImageList? +System.Windows.Forms.TreeView.StateImageList.set -> void +System.Windows.Forms.TreeView.TopNode.get -> System.Windows.Forms.TreeNode? +System.Windows.Forms.TreeView.TopNode.set -> void +System.Windows.Forms.TreeView.TreeViewNodeSorter.get -> System.Collections.IComparer? +System.Windows.Forms.TreeView.TreeViewNodeSorter.set -> void ~virtual System.Windows.Forms.Binding.OnBindingComplete(System.Windows.Forms.BindingCompleteEventArgs e) -> void ~virtual System.Windows.Forms.Binding.OnFormat(System.Windows.Forms.ConvertEventArgs cevent) -> void ~virtual System.Windows.Forms.Binding.OnParse(System.Windows.Forms.ConvertEventArgs cevent) -> void @@ -726,7 +668,7 @@ ~virtual System.Windows.Forms.BindingSource.this[int index].get -> object ~virtual System.Windows.Forms.BindingSource.this[int index].set -> void ~virtual System.Windows.Forms.DataGridView.AdjustColumnHeaderBorderStyle(System.Windows.Forms.DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput, System.Windows.Forms.DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder, bool isFirstDisplayedColumn, bool isLastVisibleColumn) -> System.Windows.Forms.DataGridViewAdvancedBorderStyle -~virtual System.Windows.Forms.DataGridView.AdjustedTopLeftHeaderBorderStyle.get -> System.Windows.Forms.DataGridViewAdvancedBorderStyle +virtual System.Windows.Forms.DataGridView.AdjustedTopLeftHeaderBorderStyle.get -> System.Windows.Forms.DataGridViewAdvancedBorderStyle! ~virtual System.Windows.Forms.DataGridView.CreateColumnsInstance() -> System.Windows.Forms.DataGridViewColumnCollection ~virtual System.Windows.Forms.DataGridView.CreateRowsInstance() -> System.Windows.Forms.DataGridViewRowCollection ~virtual System.Windows.Forms.DataGridView.GetClipboardContent() -> System.Windows.Forms.DataObject @@ -935,13 +877,6 @@ ~virtual System.Windows.Forms.DataGridViewComboBoxCell.ObjectCollection.this[int index].set -> void ~virtual System.Windows.Forms.DataGridViewComboBoxCell.ValueMember.get -> string ~virtual System.Windows.Forms.DataGridViewComboBoxCell.ValueMember.set -> void -~virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.ApplyCellStyleToEditingControl(System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle) -> void -~virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlDataGridView.get -> System.Windows.Forms.DataGridView -~virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlDataGridView.set -> void -~virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlFormattedValue.get -> object -~virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlFormattedValue.set -> void -~virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingPanelCursor.get -> System.Windows.Forms.Cursor -~virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.GetEditingControlFormattedValue(System.Windows.Forms.DataGridViewDataErrorContexts context) -> object ~virtual System.Windows.Forms.DataGridViewRow.AdjustRowHeaderBorderStyle(System.Windows.Forms.DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput, System.Windows.Forms.DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded, bool isFirstDisplayedRow, bool isLastVisibleRow) -> System.Windows.Forms.DataGridViewAdvancedBorderStyle ~virtual System.Windows.Forms.DataGridViewRow.CreateAccessibilityInstance() -> System.Windows.Forms.AccessibleObject ~virtual System.Windows.Forms.DataGridViewRow.CreateCellsInstance() -> System.Windows.Forms.DataGridViewCellCollection @@ -976,43 +911,22 @@ ~virtual System.Windows.Forms.TreeNode.ContextMenuStrip.set -> void ~virtual System.Windows.Forms.TreeNode.Deserialize(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext context) -> void ~virtual System.Windows.Forms.TreeNode.Serialize(System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext context) -> void -~virtual System.Windows.Forms.TreeNodeCollection.Add(string key, string text) -> System.Windows.Forms.TreeNode -~virtual System.Windows.Forms.TreeNodeCollection.Add(string key, string text, int imageIndex) -> System.Windows.Forms.TreeNode -~virtual System.Windows.Forms.TreeNodeCollection.Add(string key, string text, int imageIndex, int selectedImageIndex) -> System.Windows.Forms.TreeNode -~virtual System.Windows.Forms.TreeNodeCollection.Add(string key, string text, string imageKey) -> System.Windows.Forms.TreeNode -~virtual System.Windows.Forms.TreeNodeCollection.Add(string key, string text, string imageKey, string selectedImageKey) -> System.Windows.Forms.TreeNode -~virtual System.Windows.Forms.TreeNodeCollection.Add(string text) -> System.Windows.Forms.TreeNode -~virtual System.Windows.Forms.TreeNodeCollection.Add(System.Windows.Forms.TreeNode node) -> int -~virtual System.Windows.Forms.TreeNodeCollection.AddRange(System.Windows.Forms.TreeNode[] nodes) -> void -~virtual System.Windows.Forms.TreeNodeCollection.ContainsKey(string key) -> bool -~virtual System.Windows.Forms.TreeNodeCollection.IndexOfKey(string key) -> int -~virtual System.Windows.Forms.TreeNodeCollection.Insert(int index, string key, string text) -> System.Windows.Forms.TreeNode -~virtual System.Windows.Forms.TreeNodeCollection.Insert(int index, string key, string text, int imageIndex) -> System.Windows.Forms.TreeNode -~virtual System.Windows.Forms.TreeNodeCollection.Insert(int index, string key, string text, int imageIndex, int selectedImageIndex) -> System.Windows.Forms.TreeNode -~virtual System.Windows.Forms.TreeNodeCollection.Insert(int index, string key, string text, string imageKey) -> System.Windows.Forms.TreeNode -~virtual System.Windows.Forms.TreeNodeCollection.Insert(int index, string key, string text, string imageKey, string selectedImageKey) -> System.Windows.Forms.TreeNode -~virtual System.Windows.Forms.TreeNodeCollection.Insert(int index, string text) -> System.Windows.Forms.TreeNode -~virtual System.Windows.Forms.TreeNodeCollection.Insert(int index, System.Windows.Forms.TreeNode node) -> void -~virtual System.Windows.Forms.TreeNodeCollection.RemoveByKey(string key) -> void -~virtual System.Windows.Forms.TreeNodeCollection.this[int index].get -> System.Windows.Forms.TreeNode -~virtual System.Windows.Forms.TreeNodeCollection.this[int index].set -> void -~virtual System.Windows.Forms.TreeNodeCollection.this[string key].get -> System.Windows.Forms.TreeNode -~virtual System.Windows.Forms.TreeView.OnAfterCheck(System.Windows.Forms.TreeViewEventArgs e) -> void -~virtual System.Windows.Forms.TreeView.OnAfterCollapse(System.Windows.Forms.TreeViewEventArgs e) -> void -~virtual System.Windows.Forms.TreeView.OnAfterExpand(System.Windows.Forms.TreeViewEventArgs e) -> void -~virtual System.Windows.Forms.TreeView.OnAfterLabelEdit(System.Windows.Forms.NodeLabelEditEventArgs e) -> void -~virtual System.Windows.Forms.TreeView.OnAfterSelect(System.Windows.Forms.TreeViewEventArgs e) -> void -~virtual System.Windows.Forms.TreeView.OnBeforeCheck(System.Windows.Forms.TreeViewCancelEventArgs e) -> void -~virtual System.Windows.Forms.TreeView.OnBeforeCollapse(System.Windows.Forms.TreeViewCancelEventArgs e) -> void -~virtual System.Windows.Forms.TreeView.OnBeforeExpand(System.Windows.Forms.TreeViewCancelEventArgs e) -> void -~virtual System.Windows.Forms.TreeView.OnBeforeLabelEdit(System.Windows.Forms.NodeLabelEditEventArgs e) -> void -~virtual System.Windows.Forms.TreeView.OnBeforeSelect(System.Windows.Forms.TreeViewCancelEventArgs e) -> void -~virtual System.Windows.Forms.TreeView.OnDrawNode(System.Windows.Forms.DrawTreeNodeEventArgs e) -> void -~virtual System.Windows.Forms.TreeView.OnItemDrag(System.Windows.Forms.ItemDragEventArgs e) -> void -~virtual System.Windows.Forms.TreeView.OnNodeMouseClick(System.Windows.Forms.TreeNodeMouseClickEventArgs e) -> void -~virtual System.Windows.Forms.TreeView.OnNodeMouseDoubleClick(System.Windows.Forms.TreeNodeMouseClickEventArgs e) -> void -~virtual System.Windows.Forms.TreeView.OnNodeMouseHover(System.Windows.Forms.TreeNodeMouseHoverEventArgs e) -> void -~virtual System.Windows.Forms.TreeView.OnRightToLeftLayoutChanged(System.EventArgs e) -> void +virtual System.Windows.Forms.TreeView.OnAfterCheck(System.Windows.Forms.TreeViewEventArgs! e) -> void +virtual System.Windows.Forms.TreeView.OnAfterCollapse(System.Windows.Forms.TreeViewEventArgs! e) -> void +virtual System.Windows.Forms.TreeView.OnAfterExpand(System.Windows.Forms.TreeViewEventArgs! e) -> void +virtual System.Windows.Forms.TreeView.OnAfterLabelEdit(System.Windows.Forms.NodeLabelEditEventArgs! e) -> void +virtual System.Windows.Forms.TreeView.OnAfterSelect(System.Windows.Forms.TreeViewEventArgs! e) -> void +virtual System.Windows.Forms.TreeView.OnBeforeCheck(System.Windows.Forms.TreeViewCancelEventArgs! e) -> void +virtual System.Windows.Forms.TreeView.OnBeforeCollapse(System.Windows.Forms.TreeViewCancelEventArgs! e) -> void +virtual System.Windows.Forms.TreeView.OnBeforeExpand(System.Windows.Forms.TreeViewCancelEventArgs! e) -> void +virtual System.Windows.Forms.TreeView.OnBeforeLabelEdit(System.Windows.Forms.NodeLabelEditEventArgs! e) -> void +virtual System.Windows.Forms.TreeView.OnBeforeSelect(System.Windows.Forms.TreeViewCancelEventArgs! e) -> void +virtual System.Windows.Forms.TreeView.OnDrawNode(System.Windows.Forms.DrawTreeNodeEventArgs! e) -> void +virtual System.Windows.Forms.TreeView.OnItemDrag(System.Windows.Forms.ItemDragEventArgs! e) -> void +virtual System.Windows.Forms.TreeView.OnNodeMouseClick(System.Windows.Forms.TreeNodeMouseClickEventArgs! e) -> void +virtual System.Windows.Forms.TreeView.OnNodeMouseDoubleClick(System.Windows.Forms.TreeNodeMouseClickEventArgs! e) -> void +virtual System.Windows.Forms.TreeView.OnNodeMouseHover(System.Windows.Forms.TreeNodeMouseHoverEventArgs! e) -> void +virtual System.Windows.Forms.TreeView.OnRightToLeftLayoutChanged(System.EventArgs! e) -> void abstract System.Windows.Forms.BindingManagerBase.AddNew() -> void abstract System.Windows.Forms.BindingManagerBase.CancelCurrentEdit() -> void abstract System.Windows.Forms.BindingManagerBase.Count.get -> int @@ -1350,13 +1264,33 @@ override System.Windows.Forms.DataGridViewAdvancedBorderStyle.Equals(object? oth override System.Windows.Forms.DataGridViewAdvancedBorderStyle.GetHashCode() -> int override System.Windows.Forms.DataGridViewAdvancedBorderStyle.ToString() -> string! override System.Windows.Forms.DataGridViewBand.ToString() -> string! +override System.Windows.Forms.DataGridViewButtonCell.Clone() -> object! +override System.Windows.Forms.DataGridViewButtonCell.CreateAccessibilityInstance() -> System.Windows.Forms.AccessibleObject! override System.Windows.Forms.DataGridViewButtonCell.DataGridViewButtonCellAccessibleObject.DefaultAction.get -> string! override System.Windows.Forms.DataGridViewButtonCell.DataGridViewButtonCellAccessibleObject.DoDefaultAction() -> void override System.Windows.Forms.DataGridViewButtonCell.DataGridViewButtonCellAccessibleObject.GetChildCount() -> int +override System.Windows.Forms.DataGridViewButtonCell.EditType.get -> System.Type? +override System.Windows.Forms.DataGridViewButtonCell.FormattedValueType.get -> System.Type! +override System.Windows.Forms.DataGridViewButtonCell.GetContentBounds(System.Drawing.Graphics! graphics, System.Windows.Forms.DataGridViewCellStyle! cellStyle, int rowIndex) -> System.Drawing.Rectangle +override System.Windows.Forms.DataGridViewButtonCell.GetErrorIconBounds(System.Drawing.Graphics! graphics, System.Windows.Forms.DataGridViewCellStyle! cellStyle, int rowIndex) -> System.Drawing.Rectangle +override System.Windows.Forms.DataGridViewButtonCell.GetPreferredSize(System.Drawing.Graphics! graphics, System.Windows.Forms.DataGridViewCellStyle! cellStyle, int rowIndex, System.Drawing.Size constraintSize) -> System.Drawing.Size +override System.Windows.Forms.DataGridViewButtonCell.GetValue(int rowIndex) -> object? +override System.Windows.Forms.DataGridViewButtonCell.KeyDownUnsharesRow(System.Windows.Forms.KeyEventArgs! e, int rowIndex) -> bool +override System.Windows.Forms.DataGridViewButtonCell.KeyUpUnsharesRow(System.Windows.Forms.KeyEventArgs! e, int rowIndex) -> bool +override System.Windows.Forms.DataGridViewButtonCell.MouseDownUnsharesRow(System.Windows.Forms.DataGridViewCellMouseEventArgs! e) -> bool override System.Windows.Forms.DataGridViewButtonCell.MouseEnterUnsharesRow(int rowIndex) -> bool override System.Windows.Forms.DataGridViewButtonCell.MouseLeaveUnsharesRow(int rowIndex) -> bool +override System.Windows.Forms.DataGridViewButtonCell.MouseUpUnsharesRow(System.Windows.Forms.DataGridViewCellMouseEventArgs! e) -> bool +override System.Windows.Forms.DataGridViewButtonCell.OnKeyDown(System.Windows.Forms.KeyEventArgs! e, int rowIndex) -> void +override System.Windows.Forms.DataGridViewButtonCell.OnKeyUp(System.Windows.Forms.KeyEventArgs! e, int rowIndex) -> void override System.Windows.Forms.DataGridViewButtonCell.OnLeave(int rowIndex, bool throughMouseClick) -> void +override System.Windows.Forms.DataGridViewButtonCell.OnMouseDown(System.Windows.Forms.DataGridViewCellMouseEventArgs! e) -> void override System.Windows.Forms.DataGridViewButtonCell.OnMouseLeave(int rowIndex) -> void +override System.Windows.Forms.DataGridViewButtonCell.OnMouseMove(System.Windows.Forms.DataGridViewCellMouseEventArgs! e) -> void +override System.Windows.Forms.DataGridViewButtonCell.OnMouseUp(System.Windows.Forms.DataGridViewCellMouseEventArgs! e) -> void +override System.Windows.Forms.DataGridViewButtonCell.Paint(System.Drawing.Graphics! graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates elementState, object? value, object? formattedValue, string? errorText, System.Windows.Forms.DataGridViewCellStyle! cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle! advancedBorderStyle, System.Windows.Forms.DataGridViewPaintParts paintParts) -> void +override System.Windows.Forms.DataGridViewButtonCell.ToString() -> string! +override System.Windows.Forms.DataGridViewButtonCell.ValueType.get -> System.Type! override System.Windows.Forms.DataGridViewCell.DataGridViewCellAccessibleObject.Bounds.get -> System.Drawing.Rectangle override System.Windows.Forms.DataGridViewCell.DataGridViewCellAccessibleObject.DefaultAction.get -> string! override System.Windows.Forms.DataGridViewCell.DataGridViewCellAccessibleObject.DoDefaultAction() -> void @@ -1412,6 +1346,9 @@ override System.Windows.Forms.DataGridViewComboBoxCell.OnEnter(int rowIndex, boo override System.Windows.Forms.DataGridViewComboBoxCell.OnLeave(int rowIndex, bool throughMouseClick) -> void override System.Windows.Forms.DataGridViewComboBoxCell.OnMouseEnter(int rowIndex) -> void override System.Windows.Forms.DataGridViewComboBoxCell.OnMouseLeave(int rowIndex) -> void +override System.Windows.Forms.DataGridViewComboBoxEditingControl.CreateAccessibilityInstance() -> System.Windows.Forms.AccessibleObject! +override System.Windows.Forms.DataGridViewComboBoxEditingControl.OnHandleCreated(System.EventArgs! e) -> void +override System.Windows.Forms.DataGridViewComboBoxEditingControl.OnSelectedIndexChanged(System.EventArgs! e) -> void override System.Windows.Forms.DataGridViewHeaderCell.Displayed.get -> bool override System.Windows.Forms.DataGridViewHeaderCell.Dispose(bool disposing) -> void override System.Windows.Forms.DataGridViewHeaderCell.Frozen.get -> bool @@ -1966,8 +1903,11 @@ override System.Windows.Forms.PrintControllerWithStatusDialog.OnStartPage(System override System.Windows.Forms.PrintControllerWithStatusDialog.OnStartPrint(System.Drawing.Printing.PrintDocument! document, System.Drawing.Printing.PrintEventArgs! e) -> void override System.Windows.Forms.PrintDialog.Reset() -> void override System.Windows.Forms.PrintPreviewControl.CreateAccessibilityInstance() -> System.Windows.Forms.AccessibleObject! -override System.Windows.Forms.PrintPreviewControl.CreateParams.get -> System.Windows.Forms.CreateParams! +override System.Windows.Forms.PrintPreviewControl.OnGotFocus(System.EventArgs! e) -> void +override System.Windows.Forms.PrintPreviewControl.OnLostFocus(System.EventArgs! e) -> void +override System.Windows.Forms.PrintPreviewControl.OnMouseDown(System.Windows.Forms.MouseEventArgs! e) -> void override System.Windows.Forms.PrintPreviewControl.OnPaint(System.Windows.Forms.PaintEventArgs! pevent) -> void +override System.Windows.Forms.PrintPreviewControl.OnPaintBackground(System.Windows.Forms.PaintEventArgs! e) -> void override System.Windows.Forms.PrintPreviewControl.OnResize(System.EventArgs! eventargs) -> void override System.Windows.Forms.PrintPreviewControl.ResetBackColor() -> void override System.Windows.Forms.PrintPreviewControl.ResetForeColor() -> void @@ -3526,11 +3466,23 @@ static System.Windows.Forms.TextRenderer.MeasureText(System.ReadOnlySpan t static System.Windows.Forms.TextRenderer.MeasureText(System.ReadOnlySpan text, System.Drawing.Font? font, System.Drawing.Size proposedSize) -> System.Drawing.Size static System.Windows.Forms.TextRenderer.MeasureText(System.ReadOnlySpan text, System.Drawing.Font? font, System.Drawing.Size proposedSize, System.Windows.Forms.TextFormatFlags flags) -> System.Drawing.Size static System.Windows.Forms.ToolStrip.SetItemParent(System.Windows.Forms.ToolStripItem! item, System.Windows.Forms.ToolStrip! parent) -> void +static System.Windows.Forms.ToolStripManager.FindToolStrip(string! toolStripName) -> System.Windows.Forms.ToolStrip? static System.Windows.Forms.ToolStripManager.IsShortcutDefined(System.Windows.Forms.Keys shortcut) -> bool static System.Windows.Forms.ToolStripManager.IsValidShortcut(System.Windows.Forms.Keys shortcut) -> bool -static System.Windows.Forms.ToolStripManager.RendererChanged -> System.EventHandler +static System.Windows.Forms.ToolStripManager.LoadSettings(System.Windows.Forms.Form! targetForm) -> void +static System.Windows.Forms.ToolStripManager.LoadSettings(System.Windows.Forms.Form! targetForm, string! key) -> void +static System.Windows.Forms.ToolStripManager.Merge(System.Windows.Forms.ToolStrip! sourceToolStrip, string! targetName) -> bool +static System.Windows.Forms.ToolStripManager.Merge(System.Windows.Forms.ToolStrip! sourceToolStrip, System.Windows.Forms.ToolStrip! targetToolStrip) -> bool +static System.Windows.Forms.ToolStripManager.Renderer.get -> System.Windows.Forms.ToolStripRenderer! +static System.Windows.Forms.ToolStripManager.Renderer.set -> void +static System.Windows.Forms.ToolStripManager.RendererChanged -> System.EventHandler? static System.Windows.Forms.ToolStripManager.RenderMode.get -> System.Windows.Forms.ToolStripManagerRenderMode static System.Windows.Forms.ToolStripManager.RenderMode.set -> void +static System.Windows.Forms.ToolStripManager.RevertMerge(string! targetName) -> bool +static System.Windows.Forms.ToolStripManager.RevertMerge(System.Windows.Forms.ToolStrip! targetToolStrip) -> bool +static System.Windows.Forms.ToolStripManager.RevertMerge(System.Windows.Forms.ToolStrip! targetToolStrip, System.Windows.Forms.ToolStrip! sourceToolStrip) -> bool +static System.Windows.Forms.ToolStripManager.SaveSettings(System.Windows.Forms.Form! sourceForm) -> void +static System.Windows.Forms.ToolStripManager.SaveSettings(System.Windows.Forms.Form! sourceForm, string! key) -> void static System.Windows.Forms.ToolStripManager.VisualStylesEnabled.get -> bool static System.Windows.Forms.ToolStripManager.VisualStylesEnabled.set -> void static System.Windows.Forms.ToolStripRenderer.CreateDisabledImage(System.Drawing.Image! normalImage) -> System.Drawing.Image! @@ -4040,9 +3992,9 @@ System.Resources.ResXDataNode.Comment.set -> void System.Resources.ResXDataNode.FileRef.get -> System.Resources.ResXFileRef? System.Resources.ResXDataNode.GetNodePosition() -> System.Drawing.Point System.Resources.ResXDataNode.GetValue(System.ComponentModel.Design.ITypeResolutionService? typeResolver) -> object? -System.Resources.ResXDataNode.GetValue(System.Reflection.AssemblyName![]! names) -> object? +System.Resources.ResXDataNode.GetValue(System.Reflection.AssemblyName![]? names) -> object? System.Resources.ResXDataNode.GetValueTypeName(System.ComponentModel.Design.ITypeResolutionService? typeResolver) -> string? -System.Resources.ResXDataNode.GetValueTypeName(System.Reflection.AssemblyName![]! names) -> string? +System.Resources.ResXDataNode.GetValueTypeName(System.Reflection.AssemblyName![]? names) -> string? System.Resources.ResXDataNode.Name.get -> string! System.Resources.ResXDataNode.Name.set -> void System.Resources.ResXDataNode.ResXDataNode(string! name, object? value) -> void @@ -4383,6 +4335,8 @@ System.Windows.Forms.AxHost.ConnectionPointCookie System.Windows.Forms.AxHost.ConnectionPointCookie.~ConnectionPointCookie() -> void System.Windows.Forms.AxHost.ConnectionPointCookie.ConnectionPointCookie(object! source, object! sink, System.Type! eventInterface) -> void System.Windows.Forms.AxHost.ConnectionPointCookie.Disconnect() -> void +System.Windows.Forms.AxHost.ContainingControl.get -> System.Windows.Forms.ContainerControl? +System.Windows.Forms.AxHost.ContainingControl.set -> void System.Windows.Forms.AxHost.CursorChanged -> System.EventHandler? System.Windows.Forms.AxHost.DoubleClick -> System.EventHandler? System.Windows.Forms.AxHost.DoVerb(int verb) -> void @@ -4421,6 +4375,8 @@ System.Windows.Forms.AxHost.MouseLeave -> System.EventHandler? System.Windows.Forms.AxHost.MouseMove -> System.Windows.Forms.MouseEventHandler? System.Windows.Forms.AxHost.MouseUp -> System.Windows.Forms.MouseEventHandler? System.Windows.Forms.AxHost.MouseWheel -> System.Windows.Forms.MouseEventHandler? +System.Windows.Forms.AxHost.OcxState.get -> System.Windows.Forms.AxHost.State? +System.Windows.Forms.AxHost.OcxState.set -> void System.Windows.Forms.AxHost.Paint -> System.Windows.Forms.PaintEventHandler? System.Windows.Forms.AxHost.PropsValid() -> bool System.Windows.Forms.AxHost.QueryAccessibilityHelp -> System.Windows.Forms.QueryAccessibilityHelpEventHandler? @@ -4432,6 +4388,7 @@ System.Windows.Forms.AxHost.RaiseOnMouseMove(short button, short shift, int x, i System.Windows.Forms.AxHost.RaiseOnMouseUp(short button, short shift, float x, float y) -> void System.Windows.Forms.AxHost.RaiseOnMouseUp(short button, short shift, int x, int y) -> void System.Windows.Forms.AxHost.RightToLeftChanged -> System.EventHandler? +System.Windows.Forms.AxHost.SetAboutBoxDelegate(System.Windows.Forms.AxHost.AboutBoxDelegate! d) -> void System.Windows.Forms.AxHost.ShowAboutBox() -> void System.Windows.Forms.AxHost.ShowPropertyPages() -> void System.Windows.Forms.AxHost.State @@ -5350,24 +5307,24 @@ System.Windows.Forms.DataFormats.Format.Name.get -> string! System.Windows.Forms.DataGridView System.Windows.Forms.DataGridView.AllowUserToAddRows.get -> bool System.Windows.Forms.DataGridView.AllowUserToAddRows.set -> void -System.Windows.Forms.DataGridView.AllowUserToAddRowsChanged -> System.EventHandler +System.Windows.Forms.DataGridView.AllowUserToAddRowsChanged -> System.EventHandler? System.Windows.Forms.DataGridView.AllowUserToDeleteRows.get -> bool System.Windows.Forms.DataGridView.AllowUserToDeleteRows.set -> void -System.Windows.Forms.DataGridView.AllowUserToDeleteRowsChanged -> System.EventHandler +System.Windows.Forms.DataGridView.AllowUserToDeleteRowsChanged -> System.EventHandler? System.Windows.Forms.DataGridView.AllowUserToOrderColumns.get -> bool System.Windows.Forms.DataGridView.AllowUserToOrderColumns.set -> void -System.Windows.Forms.DataGridView.AllowUserToOrderColumnsChanged -> System.EventHandler +System.Windows.Forms.DataGridView.AllowUserToOrderColumnsChanged -> System.EventHandler? System.Windows.Forms.DataGridView.AllowUserToResizeColumns.get -> bool System.Windows.Forms.DataGridView.AllowUserToResizeColumns.set -> void -System.Windows.Forms.DataGridView.AllowUserToResizeColumnsChanged -> System.EventHandler +System.Windows.Forms.DataGridView.AllowUserToResizeColumnsChanged -> System.EventHandler? System.Windows.Forms.DataGridView.AllowUserToResizeRows.get -> bool System.Windows.Forms.DataGridView.AllowUserToResizeRows.set -> void -System.Windows.Forms.DataGridView.AllowUserToResizeRowsChanged -> System.EventHandler -System.Windows.Forms.DataGridView.AlternatingRowsDefaultCellStyleChanged -> System.EventHandler +System.Windows.Forms.DataGridView.AllowUserToResizeRowsChanged -> System.EventHandler? +System.Windows.Forms.DataGridView.AlternatingRowsDefaultCellStyleChanged -> System.EventHandler? System.Windows.Forms.DataGridView.AreAllCellsSelected(bool includeInvisibleCells) -> bool System.Windows.Forms.DataGridView.AutoGenerateColumns.get -> bool System.Windows.Forms.DataGridView.AutoGenerateColumns.set -> void -System.Windows.Forms.DataGridView.AutoGenerateColumnsChanged -> System.EventHandler +System.Windows.Forms.DataGridView.AutoGenerateColumnsChanged -> System.EventHandler? System.Windows.Forms.DataGridView.AutoResizeColumn(int columnIndex) -> void System.Windows.Forms.DataGridView.AutoResizeColumn(int columnIndex, System.Windows.Forms.DataGridViewAutoSizeColumnMode autoSizeColumnMode) -> void System.Windows.Forms.DataGridView.AutoResizeColumn(int columnIndex, System.Windows.Forms.DataGridViewAutoSizeColumnMode autoSizeColumnMode, bool fixedHeight) -> void @@ -5392,16 +5349,16 @@ System.Windows.Forms.DataGridView.AutoResizeRows(System.Windows.Forms.DataGridVi System.Windows.Forms.DataGridView.AutoSizeColumnModeChanged -> System.Windows.Forms.DataGridViewAutoSizeColumnModeEventHandler System.Windows.Forms.DataGridView.AutoSizeColumnsMode.get -> System.Windows.Forms.DataGridViewAutoSizeColumnsMode System.Windows.Forms.DataGridView.AutoSizeColumnsMode.set -> void -System.Windows.Forms.DataGridView.AutoSizeColumnsModeChanged -> System.Windows.Forms.DataGridViewAutoSizeColumnsModeEventHandler +System.Windows.Forms.DataGridView.AutoSizeColumnsModeChanged -> System.Windows.Forms.DataGridViewAutoSizeColumnsModeEventHandler? System.Windows.Forms.DataGridView.AutoSizeRowsMode.get -> System.Windows.Forms.DataGridViewAutoSizeRowsMode System.Windows.Forms.DataGridView.AutoSizeRowsMode.set -> void -System.Windows.Forms.DataGridView.AutoSizeRowsModeChanged -> System.Windows.Forms.DataGridViewAutoSizeModeEventHandler -System.Windows.Forms.DataGridView.BackColorChanged -> System.EventHandler +System.Windows.Forms.DataGridView.AutoSizeRowsModeChanged -> System.Windows.Forms.DataGridViewAutoSizeModeEventHandler? +System.Windows.Forms.DataGridView.BackColorChanged -> System.EventHandler? System.Windows.Forms.DataGridView.BackgroundColor.get -> System.Drawing.Color System.Windows.Forms.DataGridView.BackgroundColor.set -> void -System.Windows.Forms.DataGridView.BackgroundColorChanged -> System.EventHandler -System.Windows.Forms.DataGridView.BackgroundImageChanged -> System.EventHandler -System.Windows.Forms.DataGridView.BackgroundImageLayoutChanged -> System.EventHandler +System.Windows.Forms.DataGridView.BackgroundColorChanged -> System.EventHandler? +System.Windows.Forms.DataGridView.BackgroundImageChanged -> System.EventHandler? +System.Windows.Forms.DataGridView.BackgroundImageLayoutChanged -> System.EventHandler? System.Windows.Forms.DataGridView.BorderStyle.get -> System.Windows.Forms.BorderStyle System.Windows.Forms.DataGridView.BorderStyle.set -> void System.Windows.Forms.DataGridView.BorderStyleChanged -> System.EventHandler @@ -5797,15 +5754,22 @@ System.Windows.Forms.DataGridViewCellMouseEventArgs.DataGridViewCellMouseEventAr System.Windows.Forms.DataGridViewCellMouseEventArgs.RowIndex.get -> int System.Windows.Forms.DataGridViewCellMouseEventHandler System.Windows.Forms.DataGridViewCellPaintingEventArgs +System.Windows.Forms.DataGridViewCellPaintingEventArgs.AdvancedBorderStyle.get -> System.Windows.Forms.DataGridViewAdvancedBorderStyle? System.Windows.Forms.DataGridViewCellPaintingEventArgs.CellBounds.get -> System.Drawing.Rectangle +System.Windows.Forms.DataGridViewCellPaintingEventArgs.CellStyle.get -> System.Windows.Forms.DataGridViewCellStyle? System.Windows.Forms.DataGridViewCellPaintingEventArgs.ClipBounds.get -> System.Drawing.Rectangle System.Windows.Forms.DataGridViewCellPaintingEventArgs.ColumnIndex.get -> int +System.Windows.Forms.DataGridViewCellPaintingEventArgs.DataGridViewCellPaintingEventArgs(System.Windows.Forms.DataGridView! dataGridView, System.Drawing.Graphics! graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, int columnIndex, System.Windows.Forms.DataGridViewElementStates cellState, object? value, object? formattedValue, string? errorText, System.Windows.Forms.DataGridViewCellStyle! cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle? advancedBorderStyle, System.Windows.Forms.DataGridViewPaintParts paintParts) -> void +System.Windows.Forms.DataGridViewCellPaintingEventArgs.ErrorText.get -> string? +System.Windows.Forms.DataGridViewCellPaintingEventArgs.FormattedValue.get -> object? +System.Windows.Forms.DataGridViewCellPaintingEventArgs.Graphics.get -> System.Drawing.Graphics? System.Windows.Forms.DataGridViewCellPaintingEventArgs.Paint(System.Drawing.Rectangle clipBounds, System.Windows.Forms.DataGridViewPaintParts paintParts) -> void System.Windows.Forms.DataGridViewCellPaintingEventArgs.PaintBackground(System.Drawing.Rectangle clipBounds, bool cellsPaintSelectionBackground) -> void System.Windows.Forms.DataGridViewCellPaintingEventArgs.PaintContent(System.Drawing.Rectangle clipBounds) -> void System.Windows.Forms.DataGridViewCellPaintingEventArgs.PaintParts.get -> System.Windows.Forms.DataGridViewPaintParts System.Windows.Forms.DataGridViewCellPaintingEventArgs.RowIndex.get -> int System.Windows.Forms.DataGridViewCellPaintingEventArgs.State.get -> System.Windows.Forms.DataGridViewElementStates +System.Windows.Forms.DataGridViewCellPaintingEventArgs.Value.get -> object? System.Windows.Forms.DataGridViewCellPaintingEventHandler System.Windows.Forms.DataGridViewCellParsingEventArgs System.Windows.Forms.DataGridViewCellParsingEventArgs.ColumnIndex.get -> int @@ -6253,6 +6217,10 @@ System.Windows.Forms.DataGridViewRowStateChangedEventArgs.StateChanged.get -> Sy System.Windows.Forms.DataGridViewRowStateChangedEventHandler System.Windows.Forms.DataGridViewSelectedCellCollection System.Windows.Forms.DataGridViewSelectedCellCollection.Clear() -> void +System.Windows.Forms.DataGridViewSelectedCellCollection.Contains(System.Windows.Forms.DataGridViewCell! dataGridViewCell) -> bool +System.Windows.Forms.DataGridViewSelectedCellCollection.CopyTo(System.Windows.Forms.DataGridViewCell![]! array, int index) -> void +System.Windows.Forms.DataGridViewSelectedCellCollection.Insert(int index, System.Windows.Forms.DataGridViewCell! dataGridViewCell) -> void +System.Windows.Forms.DataGridViewSelectedCellCollection.this[int index].get -> System.Windows.Forms.DataGridViewCell! System.Windows.Forms.DataGridViewSelectedColumnCollection System.Windows.Forms.DataGridViewSelectedColumnCollection.Clear() -> void System.Windows.Forms.DataGridViewSelectedColumnCollection.Contains(System.Windows.Forms.DataGridViewColumn! dataGridViewColumn) -> bool @@ -6430,7 +6398,7 @@ System.Windows.Forms.Design.IUIService.ShowToolWindow(System.Guid toolWindow) -> System.Windows.Forms.Design.IUIService.Styles.get -> System.Collections.IDictionary! System.Windows.Forms.Design.IWindowsFormsEditorService System.Windows.Forms.Design.IWindowsFormsEditorService.CloseDropDown() -> void -System.Windows.Forms.Design.IWindowsFormsEditorService.DropDownControl(System.Windows.Forms.Control? control) -> void +System.Windows.Forms.Design.IWindowsFormsEditorService.DropDownControl(System.Windows.Forms.Control! control) -> void System.Windows.Forms.Design.IWindowsFormsEditorService.ShowDialog(System.Windows.Forms.Form! dialog) -> System.Windows.Forms.DialogResult System.Windows.Forms.Design.PropertyTab System.Windows.Forms.Design.PropertyTab.~PropertyTab() -> void @@ -8921,7 +8889,6 @@ System.Windows.Forms.PrintPreviewControl.StartPage.set -> void System.Windows.Forms.PrintPreviewControl.StartPageChanged -> System.EventHandler? System.Windows.Forms.PrintPreviewControl.TabStop.get -> bool System.Windows.Forms.PrintPreviewControl.TabStop.set -> void -System.Windows.Forms.PrintPreviewControl.TabStopChanged -> System.EventHandler? System.Windows.Forms.PrintPreviewControl.TextChanged -> System.EventHandler? System.Windows.Forms.PrintPreviewControl.UseAntiAlias.get -> bool System.Windows.Forms.PrintPreviewControl.UseAntiAlias.set -> void @@ -11550,8 +11517,14 @@ System.Windows.Forms.TreeNode.StateImageIndex.set -> void System.Windows.Forms.TreeNode.Toggle() -> void System.Windows.Forms.TreeNode.TreeNode() -> void System.Windows.Forms.TreeNodeCollection +System.Windows.Forms.TreeNodeCollection.Contains(System.Windows.Forms.TreeNode! node) -> bool +System.Windows.Forms.TreeNodeCollection.CopyTo(System.Array! dest, int index) -> void System.Windows.Forms.TreeNodeCollection.Count.get -> int +System.Windows.Forms.TreeNodeCollection.Find(string! key, bool searchAllChildren) -> System.Windows.Forms.TreeNode![]! +System.Windows.Forms.TreeNodeCollection.GetEnumerator() -> System.Collections.IEnumerator! +System.Windows.Forms.TreeNodeCollection.IndexOf(System.Windows.Forms.TreeNode! node) -> int System.Windows.Forms.TreeNodeCollection.IsReadOnly.get -> bool +System.Windows.Forms.TreeNodeCollection.Remove(System.Windows.Forms.TreeNode! node) -> void System.Windows.Forms.TreeNodeConverter System.Windows.Forms.TreeNodeConverter.TreeNodeConverter() -> void System.Windows.Forms.TreeNodeMouseClickEventArgs @@ -11573,18 +11546,18 @@ System.Windows.Forms.TreeNodeStates.Marked = 128 -> System.Windows.Forms.TreeNod System.Windows.Forms.TreeNodeStates.Selected = 1 -> System.Windows.Forms.TreeNodeStates System.Windows.Forms.TreeNodeStates.ShowKeyboardCues = 512 -> System.Windows.Forms.TreeNodeStates System.Windows.Forms.TreeView -System.Windows.Forms.TreeView.AfterCheck -> System.Windows.Forms.TreeViewEventHandler -System.Windows.Forms.TreeView.AfterCollapse -> System.Windows.Forms.TreeViewEventHandler -System.Windows.Forms.TreeView.AfterExpand -> System.Windows.Forms.TreeViewEventHandler -System.Windows.Forms.TreeView.AfterLabelEdit -> System.Windows.Forms.NodeLabelEditEventHandler -System.Windows.Forms.TreeView.AfterSelect -> System.Windows.Forms.TreeViewEventHandler -System.Windows.Forms.TreeView.BackgroundImageChanged -> System.EventHandler -System.Windows.Forms.TreeView.BackgroundImageLayoutChanged -> System.EventHandler -System.Windows.Forms.TreeView.BeforeCheck -> System.Windows.Forms.TreeViewCancelEventHandler -System.Windows.Forms.TreeView.BeforeCollapse -> System.Windows.Forms.TreeViewCancelEventHandler -System.Windows.Forms.TreeView.BeforeExpand -> System.Windows.Forms.TreeViewCancelEventHandler -System.Windows.Forms.TreeView.BeforeLabelEdit -> System.Windows.Forms.NodeLabelEditEventHandler -System.Windows.Forms.TreeView.BeforeSelect -> System.Windows.Forms.TreeViewCancelEventHandler +System.Windows.Forms.TreeView.AfterCheck -> System.Windows.Forms.TreeViewEventHandler? +System.Windows.Forms.TreeView.AfterCollapse -> System.Windows.Forms.TreeViewEventHandler? +System.Windows.Forms.TreeView.AfterExpand -> System.Windows.Forms.TreeViewEventHandler? +System.Windows.Forms.TreeView.AfterLabelEdit -> System.Windows.Forms.NodeLabelEditEventHandler? +System.Windows.Forms.TreeView.AfterSelect -> System.Windows.Forms.TreeViewEventHandler? +System.Windows.Forms.TreeView.BackgroundImageChanged -> System.EventHandler? +System.Windows.Forms.TreeView.BackgroundImageLayoutChanged -> System.EventHandler? +System.Windows.Forms.TreeView.BeforeCheck -> System.Windows.Forms.TreeViewCancelEventHandler? +System.Windows.Forms.TreeView.BeforeCollapse -> System.Windows.Forms.TreeViewCancelEventHandler? +System.Windows.Forms.TreeView.BeforeExpand -> System.Windows.Forms.TreeViewCancelEventHandler? +System.Windows.Forms.TreeView.BeforeLabelEdit -> System.Windows.Forms.NodeLabelEditEventHandler? +System.Windows.Forms.TreeView.BeforeSelect -> System.Windows.Forms.TreeViewCancelEventHandler? System.Windows.Forms.TreeView.BeginUpdate() -> void System.Windows.Forms.TreeView.BorderStyle.get -> System.Windows.Forms.BorderStyle System.Windows.Forms.TreeView.BorderStyle.set -> void @@ -11593,7 +11566,7 @@ System.Windows.Forms.TreeView.CheckBoxes.set -> void System.Windows.Forms.TreeView.CollapseAll() -> void System.Windows.Forms.TreeView.DrawMode.get -> System.Windows.Forms.TreeViewDrawMode System.Windows.Forms.TreeView.DrawMode.set -> void -System.Windows.Forms.TreeView.DrawNode -> System.Windows.Forms.DrawTreeNodeEventHandler +System.Windows.Forms.TreeView.DrawNode -> System.Windows.Forms.DrawTreeNodeEventHandler? System.Windows.Forms.TreeView.EndUpdate() -> void System.Windows.Forms.TreeView.ExpandAll() -> void System.Windows.Forms.TreeView.FullRowSelect.get -> bool @@ -11607,21 +11580,21 @@ System.Windows.Forms.TreeView.ImageIndex.get -> int System.Windows.Forms.TreeView.ImageIndex.set -> void System.Windows.Forms.TreeView.Indent.get -> int System.Windows.Forms.TreeView.Indent.set -> void -System.Windows.Forms.TreeView.ItemDrag -> System.Windows.Forms.ItemDragEventHandler +System.Windows.Forms.TreeView.ItemDrag -> System.Windows.Forms.ItemDragEventHandler? System.Windows.Forms.TreeView.ItemHeight.get -> int System.Windows.Forms.TreeView.ItemHeight.set -> void System.Windows.Forms.TreeView.LabelEdit.get -> bool System.Windows.Forms.TreeView.LabelEdit.set -> void System.Windows.Forms.TreeView.LineColor.get -> System.Drawing.Color System.Windows.Forms.TreeView.LineColor.set -> void -System.Windows.Forms.TreeView.NodeMouseClick -> System.Windows.Forms.TreeNodeMouseClickEventHandler -System.Windows.Forms.TreeView.NodeMouseDoubleClick -> System.Windows.Forms.TreeNodeMouseClickEventHandler -System.Windows.Forms.TreeView.NodeMouseHover -> System.Windows.Forms.TreeNodeMouseHoverEventHandler +System.Windows.Forms.TreeView.NodeMouseClick -> System.Windows.Forms.TreeNodeMouseClickEventHandler? +System.Windows.Forms.TreeView.NodeMouseDoubleClick -> System.Windows.Forms.TreeNodeMouseClickEventHandler? +System.Windows.Forms.TreeView.NodeMouseHover -> System.Windows.Forms.TreeNodeMouseHoverEventHandler? System.Windows.Forms.TreeView.Padding.get -> System.Windows.Forms.Padding System.Windows.Forms.TreeView.Padding.set -> void -System.Windows.Forms.TreeView.PaddingChanged -> System.EventHandler -System.Windows.Forms.TreeView.Paint -> System.Windows.Forms.PaintEventHandler -System.Windows.Forms.TreeView.RightToLeftLayoutChanged -> System.EventHandler +System.Windows.Forms.TreeView.PaddingChanged -> System.EventHandler? +System.Windows.Forms.TreeView.Paint -> System.Windows.Forms.PaintEventHandler? +System.Windows.Forms.TreeView.RightToLeftLayoutChanged -> System.EventHandler? System.Windows.Forms.TreeView.Scrollable.get -> bool System.Windows.Forms.TreeView.Scrollable.set -> void System.Windows.Forms.TreeView.SelectedImageIndex.get -> int @@ -11637,7 +11610,7 @@ System.Windows.Forms.TreeView.ShowRootLines.set -> void System.Windows.Forms.TreeView.Sort() -> void System.Windows.Forms.TreeView.Sorted.get -> bool System.Windows.Forms.TreeView.Sorted.set -> void -System.Windows.Forms.TreeView.TextChanged -> System.EventHandler +System.Windows.Forms.TreeView.TextChanged -> System.EventHandler? System.Windows.Forms.TreeView.TreeView() -> void System.Windows.Forms.TreeView.VisibleCount.get -> int System.Windows.Forms.TreeViewAction @@ -12517,6 +12490,7 @@ virtual System.Windows.Forms.ApplicationContext.Dispose(bool disposing) -> void virtual System.Windows.Forms.ApplicationContext.ExitThreadCore() -> void virtual System.Windows.Forms.ApplicationContext.OnMainFormClosed(object? sender, System.EventArgs! e) -> void virtual System.Windows.Forms.AxHost.AttachInterfaces() -> void +virtual System.Windows.Forms.AxHost.CreateInstanceCore(System.Guid clsid) -> object? virtual System.Windows.Forms.AxHost.CreateSink() -> void virtual System.Windows.Forms.AxHost.DetachSink() -> void virtual System.Windows.Forms.AxHost.Enabled.get -> bool @@ -12850,11 +12824,18 @@ virtual System.Windows.Forms.DataGridViewComboBoxCell.MaxDropDownItems.get -> in virtual System.Windows.Forms.DataGridViewComboBoxCell.MaxDropDownItems.set -> void virtual System.Windows.Forms.DataGridViewComboBoxCell.Sorted.get -> bool virtual System.Windows.Forms.DataGridViewComboBoxCell.Sorted.set -> void +virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.ApplyCellStyleToEditingControl(System.Windows.Forms.DataGridViewCellStyle! dataGridViewCellStyle) -> void +virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlDataGridView.get -> System.Windows.Forms.DataGridView? +virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlDataGridView.set -> void +virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlFormattedValue.get -> object! +virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlFormattedValue.set -> void virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlRowIndex.get -> int virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlRowIndex.set -> void virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlValueChanged.get -> bool virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlValueChanged.set -> void virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlWantsInputKey(System.Windows.Forms.Keys keyData, bool dataGridViewWantsInputKey) -> bool +virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingPanelCursor.get -> System.Windows.Forms.Cursor! +virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.GetEditingControlFormattedValue(System.Windows.Forms.DataGridViewDataErrorContexts context) -> object! virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.PrepareEditingControlForEdit(bool selectAll) -> void virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.RepositionEditingControlOnValueChange.get -> bool virtual System.Windows.Forms.DataGridViewElement.OnDataGridViewChanged() -> void @@ -13505,8 +13486,29 @@ virtual System.Windows.Forms.TrackBar.OnScroll(System.EventArgs! e) -> void virtual System.Windows.Forms.TrackBar.OnValueChanged(System.EventArgs! e) -> void virtual System.Windows.Forms.TrackBar.RightToLeftLayout.get -> bool virtual System.Windows.Forms.TrackBar.RightToLeftLayout.set -> void +virtual System.Windows.Forms.TreeNodeCollection.Add(string? key, string? text) -> System.Windows.Forms.TreeNode! +virtual System.Windows.Forms.TreeNodeCollection.Add(string? key, string? text, int imageIndex) -> System.Windows.Forms.TreeNode! +virtual System.Windows.Forms.TreeNodeCollection.Add(string? key, string? text, int imageIndex, int selectedImageIndex) -> System.Windows.Forms.TreeNode! +virtual System.Windows.Forms.TreeNodeCollection.Add(string? key, string? text, string? imageKey) -> System.Windows.Forms.TreeNode! +virtual System.Windows.Forms.TreeNodeCollection.Add(string? key, string? text, string? imageKey, string? selectedImageKey) -> System.Windows.Forms.TreeNode! +virtual System.Windows.Forms.TreeNodeCollection.Add(string? text) -> System.Windows.Forms.TreeNode! +virtual System.Windows.Forms.TreeNodeCollection.Add(System.Windows.Forms.TreeNode! node) -> int +virtual System.Windows.Forms.TreeNodeCollection.AddRange(System.Windows.Forms.TreeNode![]! nodes) -> void virtual System.Windows.Forms.TreeNodeCollection.Clear() -> void +virtual System.Windows.Forms.TreeNodeCollection.ContainsKey(string? key) -> bool +virtual System.Windows.Forms.TreeNodeCollection.IndexOfKey(string? key) -> int +virtual System.Windows.Forms.TreeNodeCollection.Insert(int index, string? key, string? text) -> System.Windows.Forms.TreeNode! +virtual System.Windows.Forms.TreeNodeCollection.Insert(int index, string? key, string? text, int imageIndex) -> System.Windows.Forms.TreeNode! +virtual System.Windows.Forms.TreeNodeCollection.Insert(int index, string? key, string? text, int imageIndex, int selectedImageIndex) -> System.Windows.Forms.TreeNode! +virtual System.Windows.Forms.TreeNodeCollection.Insert(int index, string? key, string? text, string? imageKey) -> System.Windows.Forms.TreeNode! +virtual System.Windows.Forms.TreeNodeCollection.Insert(int index, string? key, string? text, string? imageKey, string? selectedImageKey) -> System.Windows.Forms.TreeNode! +virtual System.Windows.Forms.TreeNodeCollection.Insert(int index, string? text) -> System.Windows.Forms.TreeNode! +virtual System.Windows.Forms.TreeNodeCollection.Insert(int index, System.Windows.Forms.TreeNode! node) -> void virtual System.Windows.Forms.TreeNodeCollection.RemoveAt(int index) -> void +virtual System.Windows.Forms.TreeNodeCollection.RemoveByKey(string? key) -> void +virtual System.Windows.Forms.TreeNodeCollection.this[int index].get -> System.Windows.Forms.TreeNode! +virtual System.Windows.Forms.TreeNodeCollection.this[int index].set -> void +virtual System.Windows.Forms.TreeNodeCollection.this[string? key].get -> System.Windows.Forms.TreeNode? virtual System.Windows.Forms.TreeView.RightToLeftLayout.get -> bool virtual System.Windows.Forms.TreeView.RightToLeftLayout.set -> void virtual System.Windows.Forms.UpDownBase.OnChanged(object? source, System.EventArgs! e) -> void diff --git a/src/System.Windows.Forms/src/PublicAPI.Unshipped.txt b/src/System.Windows.Forms/src/PublicAPI.Unshipped.txt index e69de29bb2d..102d835a48a 100644 --- a/src/System.Windows.Forms/src/PublicAPI.Unshipped.txt +++ b/src/System.Windows.Forms/src/PublicAPI.Unshipped.txt @@ -0,0 +1,30 @@ +*REMOVED*System.Windows.Forms.AutoCompleteStringCollection.AddRange(string![]! value) -> void +*REMOVED*System.Windows.Forms.ComboBox.ObjectCollection.AddRange(object![]! items) -> void +*REMOVED*System.Windows.Forms.ImageList.ImageCollection.AddRange(System.Drawing.Image![]! images) -> void +*REMOVED*System.Windows.Forms.ListBox.IntegerCollection.AddRange(int[]! items) -> void +*REMOVED*System.Windows.Forms.ListBox.ObjectCollection.AddRange(object![]! items) -> void +*REMOVED*System.Windows.Forms.ListView.ListViewItemCollection.AddRange(System.Windows.Forms.ListViewItem![]! items) -> void +*REMOVED*System.Windows.Forms.ListViewGroupCollection.AddRange(System.Windows.Forms.ListViewGroup![]! groups) -> void +*REMOVED*System.Windows.Forms.ListViewItem.ListViewSubItemCollection.AddRange(string![]! items) -> void +*REMOVED*System.Windows.Forms.ListViewItem.ListViewSubItemCollection.AddRange(System.Windows.Forms.ListViewItem.ListViewSubItem![]! items) -> void +*REMOVED*System.Windows.Forms.TabControl.TabPageCollection.AddRange(System.Windows.Forms.TabPage![]! pages) -> void +*REMOVED*System.Windows.Forms.ToolStripItemCollection.AddRange(System.Windows.Forms.ToolStripItem![]! toolStripItems) -> void +*REMOVED*System.Windows.Forms.ToolStripPanel.ToolStripPanelRowCollection.AddRange(System.Windows.Forms.ToolStripPanelRow![]! value) -> void +*REMOVED*virtual System.Windows.Forms.Control.ControlCollection.AddRange(System.Windows.Forms.Control![]! controls) -> void +*REMOVED*virtual System.Windows.Forms.ListView.ColumnHeaderCollection.AddRange(System.Windows.Forms.ColumnHeader![]! values) -> void +*REMOVED*virtual System.Windows.Forms.TreeNodeCollection.AddRange(System.Windows.Forms.TreeNode![]! nodes) -> void +System.Windows.Forms.AutoCompleteStringCollection.AddRange(params string![]! value) -> void +System.Windows.Forms.ComboBox.ObjectCollection.AddRange(params object![]! items) -> void +System.Windows.Forms.ImageList.ImageCollection.AddRange(params System.Drawing.Image![]! images) -> void +System.Windows.Forms.ListBox.IntegerCollection.AddRange(params int[]! items) -> void +System.Windows.Forms.ListBox.ObjectCollection.AddRange(params object![]! items) -> void +System.Windows.Forms.ListView.ListViewItemCollection.AddRange(params System.Windows.Forms.ListViewItem![]! items) -> void +System.Windows.Forms.ListViewGroupCollection.AddRange(params System.Windows.Forms.ListViewGroup![]! groups) -> void +System.Windows.Forms.ListViewItem.ListViewSubItemCollection.AddRange(params string![]! items) -> void +System.Windows.Forms.ListViewItem.ListViewSubItemCollection.AddRange(params System.Windows.Forms.ListViewItem.ListViewSubItem![]! items) -> void +System.Windows.Forms.TabControl.TabPageCollection.AddRange(params System.Windows.Forms.TabPage![]! pages) -> void +System.Windows.Forms.ToolStripItemCollection.AddRange(params System.Windows.Forms.ToolStripItem![]! toolStripItems) -> void +System.Windows.Forms.ToolStripPanel.ToolStripPanelRowCollection.AddRange(params System.Windows.Forms.ToolStripPanelRow![]! value) -> void +virtual System.Windows.Forms.Control.ControlCollection.AddRange(params System.Windows.Forms.Control![]! controls) -> void +virtual System.Windows.Forms.ListView.ColumnHeaderCollection.AddRange(params System.Windows.Forms.ColumnHeader![]! values) -> void +virtual System.Windows.Forms.TreeNodeCollection.AddRange(params System.Windows.Forms.TreeNode![]! nodes) -> void diff --git a/src/System.Windows.Forms/src/Resources/SR.resx b/src/System.Windows.Forms/src/Resources/SR.resx index 6bff516ddb1..87500f3321f 100644 --- a/src/System.Windows.Forms/src/Resources/SR.resx +++ b/src/System.Windows.Forms/src/Resources/SR.resx @@ -3100,9 +3100,6 @@ Do you want to replace it? The string that is displayed above the tree view control in the dialog box. This string can be used to specify instructions to the user. - - Unable to retrieve the root folder. - The location of the root folder from which to start browsing. Only the specified folder and any subfolders that are beneath it will appear in the dialog box. @@ -6131,42 +6128,52 @@ Stack trace where the illegal operation occurred was: Alt + {Locked="Alt"} Back Ctrl + {Locked=!de; "Ctrl"} (default) Del + {Locked=!fr,de,it,es; "Del"} End + {Locked=!fr,de,it,es; "End"} Enter + {Locked=!fr,de,it,es; "Enter"} Home + {Locked=!fr,de,es; "Home"} - Ins + Insert + {Locked=!fr,de,it,es,zh-Hant; "Insert"} (none) PgDn + {Locked=!fr,de,it,es; "PgDn"} PgUp + {Locked=!fr,de,it,es; "PgUp"} Shift + {Locked=!fr,de,it,es; "Shift"} Indicates whether the control will resize itself automatically based on a computation of the default scroll bar dimensions. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf index 0cf816e6d54..213a79130f2 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf @@ -5210,11 +5210,6 @@ Chcete jej nahradit? Řetězec zobrazený v dialogovém okně nad ovládacím prvkem zobrazení stromu. V řetězci můžete uvést pokyny pro uživatele. - - Unable to retrieve the root folder. - Kořenovou složku nelze načíst. - - Controls whether the OK button of the dialog box is disabled until the user navigates the view or edits the filename (if applicable). Note: Disabling of the OK button does not prevent the dialog from being submitted by the Enter key. Určuje, jestli je tlačítko OK v dialogovém okně zakázané, dokud uživatel neprojde zobrazením nebo neupraví název souboru (pokud je to možné). Poznámka: Zakázání tlačítka OK nezabrání odeslání dialogového okna klávesou Enter. @@ -11367,7 +11362,7 @@ Trasování zásobníku, kde došlo k neplatné operaci: Alt Alt - + {Locked="Alt"} Back @@ -11377,7 +11372,7 @@ Trasování zásobníku, kde došlo k neplatné operaci: Ctrl Ctrl - + {Locked=!de; "Ctrl"} (default) @@ -11386,28 +11381,28 @@ Trasování zásobníku, kde došlo k neplatné operaci: Del - Odstranit - + Del + {Locked=!fr,de,it,es; "Del"} End End - + {Locked=!fr,de,it,es; "End"} Enter Enter - + {Locked=!fr,de,it,es; "Enter"} Home - Domů - + Home + {Locked=!fr,de,es; "Home"} - Ins - Vložit - + Insert + Insert + {Locked=!fr,de,it,es,zh-Hant; "Insert"} (none) @@ -11416,18 +11411,18 @@ Trasování zásobníku, kde došlo k neplatné operaci: PgDn - Page Down - + PgDn + {Locked=!fr,de,it,es; "PgDn"} PgUp - Page Up - + PgUp + {Locked=!fr,de,it,es; "PgUp"} Shift Shift - + {Locked=!fr,de,it,es; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf index 647b9f39570..34359e0070b 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf @@ -5210,11 +5210,6 @@ Möchten Sie sie ersetzen? Die Zeichenfolge, die im Dialogfeld über dem Strukturansicht-Steuerelement angezeigt wird. Sie kann zum Angeben von Benutzeranweisungen verwendet werden. - - Unable to retrieve the root folder. - Der Stammordner kann nicht abgerufen werden. - - Controls whether the OK button of the dialog box is disabled until the user navigates the view or edits the filename (if applicable). Note: Disabling of the OK button does not prevent the dialog from being submitted by the Enter key. Steuert, ob die Schaltfläche „OK“ des Dialogfelds deaktiviert ist, bis der Benutzer in der Ansicht navigiert oder den Dateinamen bearbeitet (falls zutreffend). Hinweis: Das Deaktivieren der Schaltfläche „OK“ verhindert nicht, dass das Dialogfeld mit der EINGABETASTE übermittelt wird. @@ -11367,7 +11362,7 @@ Stapelüberwachung, in der der unzulässige Vorgang auftrat: Alt Alt - + {Locked="Alt"} Back @@ -11377,7 +11372,7 @@ Stapelüberwachung, in der der unzulässige Vorgang auftrat: Ctrl Strg - + {Locked=!de; "Ctrl"} (default) @@ -11387,27 +11382,27 @@ Stapelüberwachung, in der der unzulässige Vorgang auftrat: Del Entf - + {Locked=!fr,de,it,es; "Del"} End - Beenden - + Ende + {Locked=!fr,de,it,es; "End"} Enter EINGABE - + {Locked=!fr,de,it,es; "Enter"} Home Startseite - + {Locked=!fr,de,es; "Home"} - Ins + Insert Einfg - + {Locked=!fr,de,it,es,zh-Hant; "Insert"} (none) @@ -11417,17 +11412,17 @@ Stapelüberwachung, in der der unzulässige Vorgang auftrat: PgDn Bild ab - + {Locked=!fr,de,it,es; "PgDn"} PgUp Bild auf - + {Locked=!fr,de,it,es; "PgUp"} Shift Umschalttaste - + {Locked=!fr,de,it,es; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf index a92e21332e7..9a903f8da2e 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf @@ -5210,11 +5210,6 @@ Do you want to replace it? Cadena que aparece encima del control de vista de árbol en el cuadro de diálogo. Esta cadena se utiliza para especificar instrucciones al usuario. - - Unable to retrieve the root folder. - No se puede recuperar la carpeta raíz. - - Controls whether the OK button of the dialog box is disabled until the user navigates the view or edits the filename (if applicable). Note: Disabling of the OK button does not prevent the dialog from being submitted by the Enter key. Controla si el botón Aceptar del cuadro de diálogo está deshabilitado hasta que el usuario navega por la vista o edita el nombre de archivo (si corresponde). Nota: Deshabilitar el botón Aceptar no impide que la tecla Entrar envíe el cuadro de diálogo. @@ -11367,7 +11362,7 @@ El seguimiento de la pila donde tuvo lugar la operación no válida fue: Alt Alt - + {Locked="Alt"} Back @@ -11377,7 +11372,7 @@ El seguimiento de la pila donde tuvo lugar la operación no válida fue: Ctrl Ctrl - + {Locked=!de; "Ctrl"} (default) @@ -11387,27 +11382,27 @@ El seguimiento de la pila donde tuvo lugar la operación no válida fue: Del Suprimir - + {Locked=!fr,de,it,es; "Del"} End Fin - + {Locked=!fr,de,it,es; "End"} Enter Entrar - + {Locked=!fr,de,it,es; "Enter"} Home Inicio - + {Locked=!fr,de,es; "Home"} - Ins + Insert Insertar - + {Locked=!fr,de,it,es,zh-Hant; "Insert"} (none) @@ -11417,17 +11412,17 @@ El seguimiento de la pila donde tuvo lugar la operación no válida fue: PgDn Avanzar página - + {Locked=!fr,de,it,es; "PgDn"} PgUp Retroceder página - + {Locked=!fr,de,it,es; "PgUp"} Shift Mayúsculas - + {Locked=!fr,de,it,es; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf index c71f56c17e9..c32040002c0 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf @@ -5210,11 +5210,6 @@ Voulez-vous le remplacer ? Chaîne affichée au-dessus du contrôle TreeView dans la boîte de dialogue. Cette chaîne peut être utilisée pour spécifier des instructions à l'utilisateur. - - Unable to retrieve the root folder. - Impossible de récupérer le dossier racine. - - Controls whether the OK button of the dialog box is disabled until the user navigates the view or edits the filename (if applicable). Note: Disabling of the OK button does not prevent the dialog from being submitted by the Enter key. Contrôle si le bouton OK de la boîte de dialogue est désactivé jusqu'à ce que l'utilisateur navigue dans la vue ou modifie le nom de fichier (le cas échéant). Remarque : La désactivation du bouton OK n'empêche pas la soumission de la boîte de dialogue par la touche Entrée. @@ -11367,7 +11362,7 @@ Cette opération non conforme s'est produite sur la trace de la pile : Alt Alt - + {Locked="Alt"} Back @@ -11377,7 +11372,7 @@ Cette opération non conforme s'est produite sur la trace de la pile : Ctrl Ctrl - + {Locked=!de; "Ctrl"} (default) @@ -11387,27 +11382,27 @@ Cette opération non conforme s'est produite sur la trace de la pile : Del Supprimer - + {Locked=!fr,de,it,es; "Del"} End Fin - + {Locked=!fr,de,it,es; "End"} Enter Entrée - + {Locked=!fr,de,it,es; "Enter"} Home Début - + {Locked=!fr,de,es; "Home"} - Ins - Insertion - + Insert + Insérer + {Locked=!fr,de,it,es,zh-Hant; "Insert"} (none) @@ -11417,17 +11412,17 @@ Cette opération non conforme s'est produite sur la trace de la pile : PgDn Page suivante - + {Locked=!fr,de,it,es; "PgDn"} PgUp Page précédente - + {Locked=!fr,de,it,es; "PgUp"} Shift Majuscule - + {Locked=!fr,de,it,es; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf index 1f41ec9f703..2252ee790ef 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf @@ -5210,11 +5210,6 @@ Sostituirlo? Stringa visualizzata sopra il controllo TreeView nella finestra di dialogo. Può essere utilizzata per specificare istruzioni all'utente. - - Unable to retrieve the root folder. - Impossibile recuperare la cartella radice. - - Controls whether the OK button of the dialog box is disabled until the user navigates the view or edits the filename (if applicable). Note: Disabling of the OK button does not prevent the dialog from being submitted by the Enter key. Controlla se il pulsante OK della finestra di dialogo è disabilitato finché l'utente non passa alla visualizzazione o modifica il nome file (se applicabile). La disabilitazione del pulsante OK non impedisce l'invio della finestra di dialogo tramite il tasto INVIO. @@ -11366,8 +11361,8 @@ Traccia dello stack da cui si è verificata l'operazione non valida: Alt - ALT - + Alt + {Locked="Alt"} Back @@ -11376,8 +11371,8 @@ Traccia dello stack da cui si è verificata l'operazione non valida: Ctrl - CTRL - + Ctrl + {Locked=!de; "Ctrl"} (default) @@ -11387,27 +11382,27 @@ Traccia dello stack da cui si è verificata l'operazione non valida: Del CANC - + {Locked=!fr,de,it,es; "Del"} End FINE - + {Locked=!fr,de,it,es; "End"} Enter INVIO - + {Locked=!fr,de,it,es; "Enter"} Home Home - + {Locked=!fr,de,es; "Home"} - Ins - INS - + Insert + Insert + {Locked=!fr,de,it,es,zh-Hant; "Insert"} (none) @@ -11417,17 +11412,17 @@ Traccia dello stack da cui si è verificata l'operazione non valida: PgDn PGGIÙ - + {Locked=!fr,de,it,es; "PgDn"} PgUp PGSU - + {Locked=!fr,de,it,es; "PgUp"} Shift MAIUSC - + {Locked=!fr,de,it,es; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf index 34eda13e3b7..525f32e234d 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf @@ -5210,11 +5210,6 @@ Do you want to replace it? ダイアログ ボックスのツリー ビュー コントロールの上に表示される文字列です。この文字列は、ユーザーに手順を指定するのに使用されます。 - - Unable to retrieve the root folder. - ルート フォルダーを取得できません。 - - Controls whether the OK button of the dialog box is disabled until the user navigates the view or edits the filename (if applicable). Note: Disabling of the OK button does not prevent the dialog from being submitted by the Enter key. ユーザーがビュー内を移動するか、ファイル名を編集するまで (該当する場合)、ダイアログ ボックスの [OK] ボタンを無効にするかどうかを制御します。注: [OK] ボタンを無効にしても、Enter キーによってダイアログが送信されるのを防ぐことはできません。 @@ -11367,7 +11362,7 @@ Stack trace where the illegal operation occurred was: Alt Alt - + {Locked="Alt"} Back @@ -11377,7 +11372,7 @@ Stack trace where the illegal operation occurred was: Ctrl Ctrl - + {Locked=!de; "Ctrl"} (default) @@ -11387,27 +11382,27 @@ Stack trace where the illegal operation occurred was: Del Delete - + {Locked=!fr,de,it,es; "Del"} End - 終了 - + End + {Locked=!fr,de,it,es; "End"} Enter - 入力 - + Enter + {Locked=!fr,de,it,es; "Enter"} Home - ホーム - + Home + {Locked=!fr,de,es; "Home"} - Ins + Insert Insert - + {Locked=!fr,de,it,es,zh-Hant; "Insert"} (none) @@ -11416,18 +11411,18 @@ Stack trace where the illegal operation occurred was: PgDn - PageDown - + PgDn + {Locked=!fr,de,it,es; "PgDn"} PgUp - PageUp - + PgUp + {Locked=!fr,de,it,es; "PgUp"} Shift Shift - + {Locked=!fr,de,it,es; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf index bca63f5563b..d712fad67d0 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf @@ -5210,11 +5210,6 @@ Do you want to replace it? 대화 상자의 tree view 컨트롤 위에 표시되는 문자열입니다. 이 문자열을 사용하여 사용자에게 표시될 지시 사항을 지정할 수 있습니다. - - Unable to retrieve the root folder. - 루트 폴더를 검색할 수 없습니다. - - Controls whether the OK button of the dialog box is disabled until the user navigates the view or edits the filename (if applicable). Note: Disabling of the OK button does not prevent the dialog from being submitted by the Enter key. 사용자가 파일 이름 보기 또는 편집으로 이동할 때까지 대화 상자의 확인 버튼을 사용하지 않을지를 제어합니다(해당하는 경우). 참고: 확인 버튼을 사용하지 않아도 Enter 키로 대화 상자를 제출할 수 있습니다. @@ -11367,7 +11362,7 @@ Stack trace where the illegal operation occurred was: Alt Alt - + {Locked="Alt"} Back @@ -11377,7 +11372,7 @@ Stack trace where the illegal operation occurred was: Ctrl Ctrl - + {Locked=!de; "Ctrl"} (default) @@ -11387,27 +11382,27 @@ Stack trace where the illegal operation occurred was: Del Delete - + {Locked=!fr,de,it,es; "Del"} End End - + {Locked=!fr,de,it,es; "End"} Enter Enter - + {Locked=!fr,de,it,es; "Enter"} Home - - + Home + {Locked=!fr,de,es; "Home"} - Ins + Insert Insert - + {Locked=!fr,de,it,es,zh-Hant; "Insert"} (none) @@ -11416,18 +11411,18 @@ Stack trace where the illegal operation occurred was: PgDn - Page Down - + PgDn + {Locked=!fr,de,it,es; "PgDn"} PgUp - Page Up - + PgUp + {Locked=!fr,de,it,es; "PgUp"} Shift Shift - + {Locked=!fr,de,it,es; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf index e9127615869..2bc82e65006 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf @@ -5210,11 +5210,6 @@ Czy chcesz go zamienić? Ciąg wyświetlony w oknie dialogowym nad formantem widoku drzewa. Ten ciąg może posłużyć do określenia instrukcji dla użytkownika. - - Unable to retrieve the root folder. - Nie można pobrać folderu głównego. - - Controls whether the OK button of the dialog box is disabled until the user navigates the view or edits the filename (if applicable). Note: Disabling of the OK button does not prevent the dialog from being submitted by the Enter key. Określa, czy przycisk OK okna dialogowego jest wyłączony, dopóki użytkownik nie nawiguje po widoku lub nie edytuje nazwy pliku (jeśli ma zastosowanie). Uwaga: wyłączenie przycisku OK nie zapobiega przesyłaniu okna dialogowego przez klawisz Enter. @@ -11367,7 +11362,7 @@ Stos śledzenia, w którym wystąpiła zabroniona operacja: Alt Alt - + {Locked="Alt"} Back @@ -11377,7 +11372,7 @@ Stos śledzenia, w którym wystąpiła zabroniona operacja: Ctrl Ctrl - + {Locked=!de; "Ctrl"} (default) @@ -11387,27 +11382,27 @@ Stos śledzenia, w którym wystąpiła zabroniona operacja: Del Delete - + {Locked=!fr,de,it,es; "Del"} End End - + {Locked=!fr,de,it,es; "End"} Enter Enter - + {Locked=!fr,de,it,es; "Enter"} Home - Strona główna - + Home + {Locked=!fr,de,es; "Home"} - Ins + Insert Insert - + {Locked=!fr,de,it,es,zh-Hant; "Insert"} (none) @@ -11416,18 +11411,18 @@ Stos śledzenia, w którym wystąpiła zabroniona operacja: PgDn - Page Down - + PgDn + {Locked=!fr,de,it,es; "PgDn"} PgUp - Page Up - + PgUp + {Locked=!fr,de,it,es; "PgUp"} Shift Shift - + {Locked=!fr,de,it,es; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf index 335b575e02a..eb4505e49be 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf @@ -5210,11 +5210,6 @@ Deseja substituí-lo? A cadeia de caracteres exibida acima do controle do modo de exibição de árvore na caixa de diálogo. Esta cadeia de caracteres pode ser utilizada para especificar instruções para o usuário. - - Unable to retrieve the root folder. - Não é possível recuperar a pasta raiz. - - Controls whether the OK button of the dialog box is disabled until the user navigates the view or edits the filename (if applicable). Note: Disabling of the OK button does not prevent the dialog from being submitted by the Enter key. Controla se o botão OK da caixa de diálogo está desabilitado até que o usuário navegue pela exibição ou edite o nome do arquivo (se aplicável). Observação: A desativação do botão OK não impede que a caixa de diálogo seja enviada pela tecla Enter. @@ -11367,7 +11362,7 @@ Rastreamento de pilha em que a operação ilegal ocorreu: Alt Alt - + {Locked="Alt"} Back @@ -11377,7 +11372,7 @@ Rastreamento de pilha em que a operação ilegal ocorreu: Ctrl Ctrl - + {Locked=!de; "Ctrl"} (default) @@ -11387,27 +11382,27 @@ Rastreamento de pilha em que a operação ilegal ocorreu: Del Delete - + {Locked=!fr,de,it,es; "Del"} End End - + {Locked=!fr,de,it,es; "End"} Enter Enter - + {Locked=!fr,de,it,es; "Enter"} Home - Início - + Home + {Locked=!fr,de,es; "Home"} - Ins + Insert Insert - + {Locked=!fr,de,it,es,zh-Hant; "Insert"} (none) @@ -11416,18 +11411,18 @@ Rastreamento de pilha em que a operação ilegal ocorreu: PgDn - Page Down - + PgDn + {Locked=!fr,de,it,es; "PgDn"} PgUp - Page Up - + PgUp + {Locked=!fr,de,it,es; "PgUp"} Shift Shift - + {Locked=!fr,de,it,es; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf index 4193cf33330..bcfb7b33f8e 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf @@ -5211,11 +5211,6 @@ Do you want to replace it? Строка, отображаемая над иерархическим представлением структуры дерева в данном диалоговом окне. Эта строка служит для задания инструкций для пользователя. - - Unable to retrieve the root folder. - Не удалось извлечь корневую папку. - - Controls whether the OK button of the dialog box is disabled until the user navigates the view or edits the filename (if applicable). Note: Disabling of the OK button does not prevent the dialog from being submitted by the Enter key. Определяет, отключена ли кнопка "ОК" в диалоговом окне, пока пользователь не перейдет в представление или не изменит имя файла (если применимо). Примечание. Отключение кнопки "ОК" не блокирует отправку сообщения из диалогового окна при нажатии клавиши ВВОД. @@ -11368,7 +11363,7 @@ Stack trace where the illegal operation occurred was: Alt Alt - + {Locked="Alt"} Back @@ -11378,7 +11373,7 @@ Stack trace where the illegal operation occurred was: Ctrl Ctrl - + {Locked=!de; "Ctrl"} (default) @@ -11387,28 +11382,28 @@ Stack trace where the illegal operation occurred was: Del - DELETE - + Del + {Locked=!fr,de,it,es; "Del"} End - Конец - + End + {Locked=!fr,de,it,es; "End"} Enter - ВВОД - + Enter + {Locked=!fr,de,it,es; "Enter"} Home - Главная - + Home + {Locked=!fr,de,es; "Home"} - Ins - INSERT - + Insert + Insert + {Locked=!fr,de,it,es,zh-Hant; "Insert"} (none) @@ -11417,18 +11412,18 @@ Stack trace where the illegal operation occurred was: PgDn - PAGE DOWN - + PgDn + {Locked=!fr,de,it,es; "PgDn"} PgUp - PAGE UP - + PgUp + {Locked=!fr,de,it,es; "PgUp"} Shift - SHIFT - + Shift + {Locked=!fr,de,it,es; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf index f8e9882ccab..e41d54bf92f 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf @@ -5210,11 +5210,6 @@ Bunu değiştirmek istiyor musunuz? İletişim kutusundaki ağaç görünümü denetiminin üstünde görüntülenen dize. Bu dize kullanıcıya yönergeleri bildirmek için kullanılabilir. - - Unable to retrieve the root folder. - Kök klasör alınamıyor. - - Controls whether the OK button of the dialog box is disabled until the user navigates the view or edits the filename (if applicable). Note: Disabling of the OK button does not prevent the dialog from being submitted by the Enter key. Kullanıcı görünümde gezinene veya dosya adını düzenleyene (yapabiliyorsa) kadar iletişim kutusunun Tamam düğmesinin devre dışı bırakılıp bırakılmadığını kontrol eder. Not: Tamam düğmesinin devre dışı bırakılması, iletişim kutusunun Enter tuşuyla gönderilmesini engellemez. @@ -11367,7 +11362,7 @@ Geçersiz işlemin gerçekleştiği yığın izi: Alt Alt - + {Locked="Alt"} Back @@ -11377,7 +11372,7 @@ Geçersiz işlemin gerçekleştiği yığın izi: Ctrl Ctrl - + {Locked=!de; "Ctrl"} (default) @@ -11387,27 +11382,27 @@ Geçersiz işlemin gerçekleştiği yığın izi: Del Delete - + {Locked=!fr,de,it,es; "Del"} End End - + {Locked=!fr,de,it,es; "End"} Enter Enter - + {Locked=!fr,de,it,es; "Enter"} Home - Giriş - + Home + {Locked=!fr,de,es; "Home"} - Ins + Insert Insert - + {Locked=!fr,de,it,es,zh-Hant; "Insert"} (none) @@ -11416,18 +11411,18 @@ Geçersiz işlemin gerçekleştiği yığın izi: PgDn - Page Down - + PgDn + {Locked=!fr,de,it,es; "PgDn"} PgUp - Page Up - + PgUp + {Locked=!fr,de,it,es; "PgUp"} Shift Shift - + {Locked=!fr,de,it,es; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf index 52f283f1339..4956e80123c 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf @@ -5210,11 +5210,6 @@ Do you want to replace it? 显示在对话框的树视图控件上方的字符串。该字符串可用来指定显示给用户的指导信息。 - - Unable to retrieve the root folder. - 无法检索根文件夹。 - - Controls whether the OK button of the dialog box is disabled until the user navigates the view or edits the filename (if applicable). Note: Disabling of the OK button does not prevent the dialog from being submitted by the Enter key. 控制在用户导航视图或编辑文件名(如果适用)之前是否禁用对话框的“确定”按钮。注意: 禁用“确定”按钮不会阻止 Enter 键提交对话框。 @@ -11367,7 +11362,7 @@ Stack trace where the illegal operation occurred was: Alt Alt - + {Locked="Alt"} Back @@ -11377,7 +11372,7 @@ Stack trace where the illegal operation occurred was: Ctrl Ctrl - + {Locked=!de; "Ctrl"} (default) @@ -11387,27 +11382,27 @@ Stack trace where the illegal operation occurred was: Del Delete - + {Locked=!fr,de,it,es; "Del"} End End - + {Locked=!fr,de,it,es; "End"} Enter Enter - + {Locked=!fr,de,it,es; "Enter"} Home - 主页 - + Home + {Locked=!fr,de,es; "Home"} - Ins + Insert Insert - + {Locked=!fr,de,it,es,zh-Hant; "Insert"} (none) @@ -11416,18 +11411,18 @@ Stack trace where the illegal operation occurred was: PgDn - Page Down - + PgDn + {Locked=!fr,de,it,es; "PgDn"} PgUp - Page Up - + PgUp + {Locked=!fr,de,it,es; "PgUp"} Shift Shift - + {Locked=!fr,de,it,es; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf index 06c10daeb3b..c2d9b1065e9 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf @@ -5210,11 +5210,6 @@ Do you want to replace it? 顯示在對話方塊中樹狀檢視控制項上方的字串。這個字串可以用來指定對使用者的指示。 - - Unable to retrieve the root folder. - 無法擷取根資料夾。 - - Controls whether the OK button of the dialog box is disabled until the user navigates the view or edits the filename (if applicable). Note: Disabling of the OK button does not prevent the dialog from being submitted by the Enter key. 控制是否在使用者巡覽檢視或編輯檔案名稱 (如適用) 之前,停用對話方塊的 [確定] 按鈕。請注意: 停用 [確定] 按鈕無法防止透過 Enter 鍵送出對話方塊。 @@ -11367,7 +11362,7 @@ Stack trace where the illegal operation occurred was: Alt Alt - + {Locked="Alt"} Back @@ -11377,7 +11372,7 @@ Stack trace where the illegal operation occurred was: Ctrl Ctrl - + {Locked=!de; "Ctrl"} (default) @@ -11387,27 +11382,27 @@ Stack trace where the illegal operation occurred was: Del Del - + {Locked=!fr,de,it,es; "Del"} End End - + {Locked=!fr,de,it,es; "End"} Enter Enter - + {Locked=!fr,de,it,es; "Enter"} Home - 首頁 - + Home + {Locked=!fr,de,es; "Home"} - Ins - Ins - + Insert + 插入 + {Locked=!fr,de,it,es,zh-Hant; "Insert"} (none) @@ -11417,17 +11412,17 @@ Stack trace where the illegal operation occurred was: PgDn PgDn - + {Locked=!fr,de,it,es; "PgDn"} PgUp PgUp - + {Locked=!fr,de,it,es; "PgUp"} Shift Shift - + {Locked=!fr,de,it,es; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/SRCategoryAttribute.cs b/src/System.Windows.Forms/src/SRCategoryAttribute.cs index c800d26a9c7..82abe171f94 100644 --- a/src/System.Windows.Forms/src/SRCategoryAttribute.cs +++ b/src/System.Windows.Forms/src/SRCategoryAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/SRDescriptionAttribute.cs b/src/System.Windows.Forms/src/SRDescriptionAttribute.cs index 47561c51601..bd86838d05e 100644 --- a/src/System.Windows.Forms/src/SRDescriptionAttribute.cs +++ b/src/System.Windows.Forms/src/SRDescriptionAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System.Windows.Forms.csproj b/src/System.Windows.Forms/src/System.Windows.Forms.csproj index 6ad4d72f90c..97f297112a4 100644 --- a/src/System.Windows.Forms/src/System.Windows.Forms.csproj +++ b/src/System.Windows.Forms/src/System.Windows.Forms.csproj @@ -4,8 +4,6 @@ System.Windows.Forms true true - True - False enable $(NoWarn);618 @@ -45,7 +43,6 @@ - diff --git a/src/System.Windows.Forms/src/System/Drawing/Design/IPropertyValueUIService.cs b/src/System.Windows.Forms/src/System/Drawing/Design/IPropertyValueUIService.cs index c002feee337..c64198d2a43 100644 --- a/src/System.Windows.Forms/src/System/Drawing/Design/IPropertyValueUIService.cs +++ b/src/System.Windows.Forms/src/System/Drawing/Design/IPropertyValueUIService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Drawing/Design/PaintValueEventArgs.cs b/src/System.Windows.Forms/src/System/Drawing/Design/PaintValueEventArgs.cs index d1c4fcbb649..a17b3024acc 100644 --- a/src/System.Windows.Forms/src/System/Drawing/Design/PaintValueEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Drawing/Design/PaintValueEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Drawing/Design/PropertyValueUIHandler.cs b/src/System.Windows.Forms/src/System/Drawing/Design/PropertyValueUIHandler.cs index da3b5ff6b0c..6474ae7bccb 100644 --- a/src/System.Windows.Forms/src/System/Drawing/Design/PropertyValueUIHandler.cs +++ b/src/System.Windows.Forms/src/System/Drawing/Design/PropertyValueUIHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Drawing/Design/PropertyValueUIItem.cs b/src/System.Windows.Forms/src/System/Drawing/Design/PropertyValueUIItem.cs index 913252ce9ab..6ae16f0edf4 100644 --- a/src/System.Windows.Forms/src/System/Drawing/Design/PropertyValueUIItem.cs +++ b/src/System.Windows.Forms/src/System/Drawing/Design/PropertyValueUIItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Drawing/Design/PropertyValueUIItemInvokeHandler.cs b/src/System.Windows.Forms/src/System/Drawing/Design/PropertyValueUIItemInvokeHandler.cs index 6d609c4838b..87cee76f561 100644 --- a/src/System.Windows.Forms/src/System/Drawing/Design/PropertyValueUIItemInvokeHandler.cs +++ b/src/System.Windows.Forms/src/System/Drawing/Design/PropertyValueUIItemInvokeHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Drawing/Design/UITypeEditor.cs b/src/System.Windows.Forms/src/System/Drawing/Design/UITypeEditor.cs index 41da0303653..09594546630 100644 --- a/src/System.Windows.Forms/src/System/Drawing/Design/UITypeEditor.cs +++ b/src/System.Windows.Forms/src/System/Drawing/Design/UITypeEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Collections.ObjectModel; diff --git a/src/System.Windows.Forms/src/System/Drawing/Design/UITypeEditorEditStyle.cs b/src/System.Windows.Forms/src/System/Drawing/Design/UITypeEditorEditStyle.cs index 932416943b5..73b700d6235 100644 --- a/src/System.Windows.Forms/src/System/Drawing/Design/UITypeEditorEditStyle.cs +++ b/src/System.Windows.Forms/src/System/Drawing/Design/UITypeEditorEditStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Drawing.Design; diff --git a/src/System.Windows.Forms/src/System/Resources/AssemblyNamesTypeResolutionService.cs b/src/System.Windows.Forms/src/System/Resources/AssemblyNamesTypeResolutionService.cs index 82ff28d3d30..c4e0df1ca9d 100644 --- a/src/System.Windows.Forms/src/System/Resources/AssemblyNamesTypeResolutionService.cs +++ b/src/System.Windows.Forms/src/System/Resources/AssemblyNamesTypeResolutionService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Concurrent; using System.ComponentModel.Design; @@ -10,14 +9,14 @@ namespace System.Resources; internal class AssemblyNamesTypeResolutionService : ITypeResolutionService { - private AssemblyName[] _names; + private AssemblyName[]? _names; private ConcurrentDictionary? _cachedAssemblies; private ConcurrentDictionary? _cachedTypes; private static readonly string s_dotNetPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles") ?? string.Empty, "dotnet\\shared"); private static readonly string s_dotNetPathX86 = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles(x86)") ?? string.Empty, "dotnet\\shared"); - internal AssemblyNamesTypeResolutionService(AssemblyName[] names) => _names = names; + internal AssemblyNamesTypeResolutionService(AssemblyName[]? names) => _names = names; public Assembly? GetAssembly(AssemblyName name) => GetAssembly(name, true); diff --git a/src/System.Windows.Forms/src/System/Resources/DataNodeInfo.cs b/src/System.Windows.Forms/src/System/Resources/DataNodeInfo.cs index 128e0b1b7d0..cb4c5c5c695 100644 --- a/src/System.Windows.Forms/src/System/Resources/DataNodeInfo.cs +++ b/src/System.Windows.Forms/src/System/Resources/DataNodeInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Resources/IAliasResolver.cs b/src/System.Windows.Forms/src/System/Resources/IAliasResolver.cs index 398d841c4fb..d294d0bd433 100644 --- a/src/System.Windows.Forms/src/System/Resources/IAliasResolver.cs +++ b/src/System.Windows.Forms/src/System/Resources/IAliasResolver.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; diff --git a/src/System.Windows.Forms/src/System/Resources/ResXDataNode.cs b/src/System.Windows.Forms/src/System/Resources/ResXDataNode.cs index 5b014ff1f26..23846496189 100644 --- a/src/System.Windows.Forms/src/System/Resources/ResXDataNode.cs +++ b/src/System.Windows.Forms/src/System/Resources/ResXDataNode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; @@ -590,7 +589,7 @@ internal DataNodeInfo GetDataNodeInfo() /// /// Retrieves the type name for the value by examining the specified assemblies. /// - public string? GetValueTypeName(AssemblyName[] names) + public string? GetValueTypeName(AssemblyName[]? names) => GetValueTypeName(new AssemblyNamesTypeResolutionService(names)); /// @@ -633,7 +632,7 @@ internal DataNodeInfo GetDataNodeInfo() /// /// Retrieves the object that is stored by this node by searching the specified assemblies. /// - public object? GetValue(AssemblyName[] names) => GetValue(new AssemblyNamesTypeResolutionService(names)); + public object? GetValue(AssemblyName[]? names) => GetValue(new AssemblyNamesTypeResolutionService(names)); private static byte[] FromBase64WrappedString(string text) { diff --git a/src/System.Windows.Forms/src/System/Resources/ResXFileRef.cs b/src/System.Windows.Forms/src/System/Resources/ResXFileRef.cs index 4dc3f3e1675..92f1be5e6d4 100644 --- a/src/System.Windows.Forms/src/System/Resources/ResXFileRef.cs +++ b/src/System.Windows.Forms/src/System/Resources/ResXFileRef.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Resources/ResXNullRef.cs b/src/System.Windows.Forms/src/System/Resources/ResXNullRef.cs index a303c01609c..b741d6b2389 100644 --- a/src/System.Windows.Forms/src/System/Resources/ResXNullRef.cs +++ b/src/System.Windows.Forms/src/System/Resources/ResXNullRef.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Resources; diff --git a/src/System.Windows.Forms/src/System/Resources/ResXResourceReader.ReaderAliasResolver.cs b/src/System.Windows.Forms/src/System/Resources/ResXResourceReader.ReaderAliasResolver.cs index f423cdae07e..bc7c327f5de 100644 --- a/src/System.Windows.Forms/src/System/Resources/ResXResourceReader.ReaderAliasResolver.cs +++ b/src/System.Windows.Forms/src/System/Resources/ResXResourceReader.ReaderAliasResolver.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; diff --git a/src/System.Windows.Forms/src/System/Resources/ResXResourceReader.cs b/src/System.Windows.Forms/src/System/Resources/ResXResourceReader.cs index 97df975da13..9bb52eb17ec 100644 --- a/src/System.Windows.Forms/src/System/Resources/ResXResourceReader.cs +++ b/src/System.Windows.Forms/src/System/Resources/ResXResourceReader.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel.Design; @@ -290,7 +289,7 @@ public static ResXResourceReader FromFileContents(string fileContents) /// Creates a reader with the specified file contents. /// public static ResXResourceReader FromFileContents(string fileContents, ITypeResolutionService? typeResolver) - => new ResXResourceReader(typeResolver) + => new(typeResolver) { _fileContents = fileContents }; @@ -299,7 +298,7 @@ public static ResXResourceReader FromFileContents(string fileContents, ITypeReso /// Creates a reader with the specified file contents. /// public static ResXResourceReader FromFileContents(string fileContents, AssemblyName[] assemblyNames) - => new ResXResourceReader(assemblyNames) + => new(assemblyNames) { _fileContents = fileContents }; diff --git a/src/System.Windows.Forms/src/System/Resources/ResXResourceSet.cs b/src/System.Windows.Forms/src/System/Resources/ResXResourceSet.cs index 6ee1e30c3b0..7bc7a717633 100644 --- a/src/System.Windows.Forms/src/System/Resources/ResXResourceSet.cs +++ b/src/System.Windows.Forms/src/System/Resources/ResXResourceSet.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Resources; diff --git a/src/System.Windows.Forms/src/System/Resources/ResXResourceWriter.cs b/src/System.Windows.Forms/src/System/Resources/ResXResourceWriter.cs index 5d83b43397a..6955de71848 100644 --- a/src/System.Windows.Forms/src/System/Resources/ResXResourceWriter.cs +++ b/src/System.Windows.Forms/src/System/Resources/ResXResourceWriter.cs @@ -1,10 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; using System.Text; -using System.Windows.Forms; using System.Xml; namespace System.Resources; @@ -31,7 +29,7 @@ public class ResXResourceWriter : IResourceWriter private Dictionary? _cachedAliases; - private static readonly TraceSwitch s_resValueProviderSwitch = new TraceSwitch("ResX", "Debug the resource value provider"); + private static readonly TraceSwitch s_resValueProviderSwitch = new("ResX", "Debug the resource value provider"); #pragma warning disable IDE1006 // Naming Styles (Shipped public API) public static readonly string BinSerializedObjectMimeType = "application/x-microsoft.net.object.binary.base64"; diff --git a/src/System.Windows.Forms/src/System/Resources/ResXSerializationBinder.cs b/src/System.Windows.Forms/src/System/Resources/ResXSerializationBinder.cs index d750456d6b4..ca86d50ba53 100644 --- a/src/System.Windows.Forms/src/System/Resources/ResXSerializationBinder.cs +++ b/src/System.Windows.Forms/src/System/Resources/ResXSerializationBinder.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; using System.Runtime.Serialization; diff --git a/src/System.Windows.Forms/src/System/Resources/ResxFileRef.Converter.cs b/src/System.Windows.Forms/src/System/Resources/ResxFileRef.Converter.cs index 6e55c92736c..e648b27be21 100644 --- a/src/System.Windows.Forms/src/System/Resources/ResxFileRef.Converter.cs +++ b/src/System.Windows.Forms/src/System/Resources/ResxFileRef.Converter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleEvents.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleEvents.cs index a9078917d37..ae35ae2d9a3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleEvents.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleEvents.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleNavigation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleNavigation.cs index f80dd8670f6..f51cdd0d33b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleNavigation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleNavigation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObject.EnumVariantObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObject.EnumVariantObject.cs index c96b85c9d71..3b3eaf34d71 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObject.EnumVariantObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObject.EnumVariantObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObject.cs index 198f70299b7..87b9d74169a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -237,16 +236,19 @@ public virtual string? Value internal virtual int[]? GetSysChildOrder() => null; /// - /// Mechanism for overriding default IAccessible.accNavigate behavior of - /// the 'inner' system accessible object (accNavigate is how you move - /// between parent, child and sibling accessible objects). - /// - /// USAGE: 'navdir' indicates navigation operation to perform, relative to - /// this accessible object. - /// If operation is unsupported, return false to allow fall-back to default - /// system behavior. Otherwise return destination object in the out - /// parameter, or null to indicate 'off end of list'. + /// Mechanism for overriding default + /// behavior of the 'inner' system accessible object (accNavigate is how you move between parent, child and + /// sibling accessible objects). /// + /// + /// Navigation operation to perform, relative to this accessible object. + /// + /// + /// The destination object or to indicate 'off end of list'. + /// + /// + /// to allow fall-back to default system behavior. + /// internal virtual bool GetSysChild(AccessibleNavigation navdir, out AccessibleObject? accessibleObject) { accessibleObject = null; @@ -791,7 +793,26 @@ unsafe HRESULT UiaCore.IAccessibleEx.ConvertReturnedElement(UiaCore.IRawElementP return null; } - object? UiaCore.IRawElementProviderSimple.GetPropertyValue(UiaCore.UIA propertyID) => GetPropertyValue(propertyID); + object? UiaCore.IRawElementProviderSimple.GetPropertyValue(UiaCore.UIA propertyID) + { + object? value = GetPropertyValue(propertyID); + +#if DEBUG + if (value?.GetType() is { } type && type.IsValueType && !type.IsPrimitive && !type.IsEnum) + { + // Check to make sure we can actually convert this to a VARIANT. + // + // Our interop handle structs (such as HWND) cannot be marshalled directly and will fail "silently" on + // callbacks (they will throw but the marshaller will convert that to an HRESULT that we won't see unless + // first-chance exceptions are on when we're debugging). + + using VARIANT variant = default; + Marshal.GetNativeVariantForObject(value, (nint)(void*)&variant); + } +#endif + + return value; + } object? UiaCore.IRawElementProviderFragment.Navigate(UiaCore.NavigateDirection direction) => FragmentNavigate(direction); @@ -1145,19 +1166,19 @@ void IAccessible.accLocation( } } - if (!SysNavigate(navDir, childID, out object? retObject)) + if (SysNavigate((AccessibleNavigation)navDir, childID, out AccessibleObject? accessibleObject)) { - using var accessible = SystemIAccessible.TryGetIAccessible(out HRESULT result); - if (result.Failed) - { - return null; - } + return AsChildId(accessibleObject); + } - result = accessible.Value->accNavigate(navDir, ChildIdToVARIANT(childID), out VARIANT endUpAt); - return endUpAt.ToObject(); + using var accessible = SystemIAccessible.TryGetIAccessible(out HRESULT result); + if (result.Failed) + { + return null; } - return retObject; + result = accessible.Value->accNavigate(navDir, ChildIdToVARIANT(childID), out VARIANT endUpAt); + return endUpAt.ToObject(); } /// @@ -1838,13 +1859,20 @@ HRESULT IEnumVARIANT.Interface.Next(uint celt, VARIANT* rgVar, uint* pCeltFetche } using var accessible = SystemIAccessible.TryGetIAccessible(out HRESULT result); - if (result.Succeeded && !SysNavigate((int)navdir, (int)PInvoke.CHILDID_SELF, out object? retObject)) + if (result.Failed) + { + return null; + } + + if (SysNavigate(navdir, (int)PInvoke.CHILDID_SELF, out AccessibleObject? accessibleObject)) + { + return accessibleObject; + } + else { result = accessible.Value->accNavigate((int)navdir, CHILDID_SELF, out VARIANT endUpAt); return TryGetAccessibleObject(endUpAt); } - - return null; } /// @@ -1855,7 +1883,7 @@ public virtual void Select(AccessibleSelection flags) using var accessible = SystemIAccessible.TryGetIAccessible(out HRESULT result); if (result.Succeeded) { - accessible.Value->accSelect((int)flags, CHILDID_SELF); + result = accessible.Value->accSelect((int)flags, CHILDID_SELF); } } @@ -1874,6 +1902,7 @@ public virtual void Select(AccessibleSelection flags) { if (obj is not null && obj._isSystemWrapper && obj.SystemIAccessible is { } accessible) { + // We're just a simple system wrapper, return the pointer. return new VARIANT() { vt = VARENUM.VT_DISPATCH, @@ -1968,16 +1997,19 @@ protected unsafe void UseStdAccessibleObjects(IntPtr handle, int objid) } /// - /// Performs custom navigation between parent/child/sibling accessible - /// objects. This is basically just a wrapper for GetSysChild(), that - /// does some of the dirty work, such as wrapping the returned object - /// in a VARIANT. Usage is similar to GetSysChild(). Called prior to - /// calling IAccessible.accNavigate on the 'inner' system accessible - /// object. + /// Performs custom navigation between parent, child, and sibling accessible objects. /// - private bool SysNavigate(int navDir, object childID, out object? retObject) + /// + /// + /// This is basically just a wrapper for + /// that does some of the dirty work. Usage is similar to . + /// Called prior to calling on the 'inner' system + /// accessible object. + /// + /// + private bool SysNavigate(AccessibleNavigation direction, object childID, out AccessibleObject? accessibleObject) { - retObject = null; + accessibleObject = null; // Only override system navigation relative to ourselves (since we can't interpret OLEACC child ids) if (!childID.Equals((int)PInvoke.CHILDID_SELF)) @@ -1986,16 +2018,7 @@ private bool SysNavigate(int navDir, object childID, out object? retObject) } // Perform any supported navigation operation (fall back on system for unsupported navigation ops) - if (!GetSysChild((AccessibleNavigation)navDir, out AccessibleObject? newObject)) - { - return false; - } - - // If object found, wrap in a VARIANT. Otherwise return null for 'end of list' (OLEACC expects this) - retObject = (newObject is null) ? null : AsChildId(newObject); - - // Tell caller not to fall back on system behavior now - return true; + return GetSysChild(direction, out accessibleObject); } /// @@ -2061,9 +2084,10 @@ internal static void ValidateChildID(ref object childID) } UIA.IAccessible* accessible; - if (dispatch->QueryInterface(IID.Get(), (void**)&accessible).Failed) + if (dispatch->QueryInterface(IID.Get(), (void**)&accessible).Failed) { Debug.Fail("This should never happen"); + dispatch->Release(); return null; } @@ -2080,7 +2104,7 @@ internal static void ValidateChildID(ref object childID) // Check to see if this object already wraps the given pointer. if (SystemIAccessible is { } systemAccessible - && systemAccessible.OriginalHandle == accessible) + && systemAccessible.MatchesOriginalPointer(accessible)) { accessible->Release(); return this; @@ -2088,6 +2112,7 @@ internal static void ValidateChildID(ref object childID) return new AccessibleObject( #if DEBUG + // AccessibleObject is not disposable so we shouldn't be tracking it. new AgileComPointer(accessible, takeOwnership: true, trackDisposal: false) #else new AgileComPointer(accessible, takeOwnership: true) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObjectExtensions.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObjectExtensions.cs index 5daaf544bfe..f4a4d01f43b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObjectExtensions.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObjectExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using Windows.Win32.System.Variant; @@ -195,7 +194,7 @@ public static AccessibleRole TryGetRole(this AgileComPointer? agile Debug.Assert(result.Succeeded, $"{nameof(TryGetRole)}: get_accRole call failed with {result}"); - return role.vt != VARENUM.VT_I4 ? AccessibleRole.None : (AccessibleRole)(int)role; + return role.vt is VARENUM.VT_I4 or VARENUM.VT_INT ? (AccessibleRole)(int)role : AccessibleRole.None; } public static AccessibleStates TryGetState(this AgileComPointer? agile, int child) @@ -216,7 +215,7 @@ public static AccessibleStates TryGetState(this AgileComPointer? ag result.Succeeded, $"{nameof(TryGetState)}: get_accState call for id {(int)child} failed with {result}"); - return state.vt != VARENUM.VT_I4 ? AccessibleStates.None : (AccessibleStates)(int)state; + return state.vt is VARENUM.VT_I4 or VARENUM.VT_INT ? (AccessibleStates)(int)state : AccessibleStates.None; } public static string? TryGetValue(this AgileComPointer? agile, VARIANT child) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleRoleControlTypeMap.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleRoleControlTypeMap.cs index 604ec8e45a3..ebc7bbdf13e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleRoleControlTypeMap.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleRoleControlTypeMap.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.UiaCore; @@ -11,7 +10,7 @@ namespace System.Windows.Forms; /// internal static class AccessibleRoleControlTypeMap { - private static readonly Dictionary s_map = new Dictionary + private static readonly Dictionary s_map = new() { { AccessibleRole.Alert, UIA.PaneControlTypeId }, { AccessibleRole.Animation, UIA.PaneControlTypeId }, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleRoles.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleRoles.cs index e0e8ce6ab35..b7253b35911 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleRoles.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleRoles.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleSelection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleSelection.cs index 06966ce933b..b40b5a6027f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleSelection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleSelection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleStates.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleStates.cs index eca6c737ee0..34cf2d1b520 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleStates.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleStates.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AmbientProperties.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AmbientProperties.cs index a482280443f..bffea0354ba 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AmbientProperties.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AmbientProperties.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AnchorStyles.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AnchorStyles.cs index 27634b2b701..a5dd530b6fc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AnchorStyles.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AnchorStyles.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Appearance.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Appearance.cs index a9b7a9d5b20..fb144cac774 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Appearance.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Appearance.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ApplicableToButtonAttribute.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ApplicableToButtonAttribute.cs index 667c49121eb..7ceb6eb45e1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ApplicableToButtonAttribute.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ApplicableToButtonAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Application.ComponentManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Application.ComponentManager.cs index f06dbcb8ad0..a1da6f21061 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Application.ComponentManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Application.ComponentManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Application.MarshallingControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Application.MarshallingControl.cs index b631225428c..091c7fe37b4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Application.MarshallingControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Application.MarshallingControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Application.ModalApplicationContext.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Application.ModalApplicationContext.cs index 187e3c5fe04..451490dd4c2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Application.ModalApplicationContext.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Application.ModalApplicationContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Application.ParkingWindow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Application.ParkingWindow.cs index 22da4961c5d..256cd9f05e6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Application.ParkingWindow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Application.ParkingWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Application.ThreadContext.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Application.ThreadContext.cs index b0479d14c19..5d39ddeee45 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Application.ThreadContext.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Application.ThreadContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.CompilerServices; @@ -796,23 +795,18 @@ internal unsafe bool GetMessageLoop(bool mustBeActive) /// internal bool IsValidComponentId() => _componentID != s_invalidId; - internal ApartmentState OleRequired() + internal unsafe ApartmentState OleRequired() { - _ = Thread.CurrentThread; if (!GetState(STATE_OLEINITIALIZED)) { - HRESULT ret; - unsafe - { - ret = PInvoke.OleInitialize(pvReserved: (void*)null); - } + HRESULT hr = PInvoke.OleInitialize(pvReserved: (void*)null); SetState(STATE_OLEINITIALIZED, true); - if (ret == HRESULT.RPC_E_CHANGED_MODE) + if (hr == HRESULT.RPC_E_CHANGED_MODE) { // This could happen if the thread was already initialized for MTA - // and then we call OleInitialize which tries to initialized it for STA - // This currently happens while profiling... + // and then we call OleInitialize which tries to initialize it for STA + // This currently happens while profiling. SetState(STATE_EXTERNALOLEINIT, true); } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Application.ThreadWindows.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Application.ThreadWindows.cs index 850847cca79..e66037c4ac8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Application.ThreadWindows.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Application.ThreadWindows.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Application.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Application.cs index 0241b10db53..210d0cdb427 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Application.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Application.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -42,10 +41,6 @@ public sealed partial class Application private static readonly object s_internalSyncObject = new(); private static bool s_useWaitCursor; - private static bool s_useEverettThreadAffinity; - private static bool s_checkedThreadAffinity; - private const string EverettThreadAffinityValue = "EnableSystemEventsThreadAffinityCompatibility"; - /// /// Events the user can hook into /// @@ -144,43 +139,6 @@ public static RegistryKey CommonAppDataRegistry internal static string CommonAppDataRegistryKeyName => $"Software\\{CompanyName}\\{ProductName}\\{ProductVersion}"; - internal static bool UseEverettThreadAffinity - { - get - { - if (!s_checkedThreadAffinity) - { - s_checkedThreadAffinity = true; - try - { - // We need access to be able to read from the registry here. We're not creating a - // registry key, nor are we returning information from the registry to the user. - RegistryKey? key = Registry.LocalMachine.OpenSubKey(CommonAppDataRegistryKeyName); - if (key is not null) - { - object? value = key.GetValue(EverettThreadAffinityValue); - key.Close(); - - if (value is not null && (int)value != 0) - { - s_useEverettThreadAffinity = true; - } - } - } - catch (Security.SecurityException) - { - // Can't read the key: use default value (false) - } - catch (InvalidCastException) - { - // Key is of wrong type: use default value (false) - } - } - - return s_useEverettThreadAffinity; - } - } - /// /// Gets the path for the application data that is shared among all users. /// diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ApplicationContext.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ApplicationContext.cs index ba95bb3119c..686bded7018 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ApplicationContext.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ApplicationContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ArrangeDirection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ArrangeDirection.cs index 72db34ace1d..e4b97d98e79 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ArrangeDirection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ArrangeDirection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ArrangeStartingPosition.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ArrangeStartingPosition.cs index cf853694672..80420bbf804 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ArrangeStartingPosition.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ArrangeStartingPosition.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ArrangedElement.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ArrangedElement.cs index a57c69234ca..5a818dc2394 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ArrangedElement.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ArrangedElement.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -14,7 +13,7 @@ internal abstract class ArrangedElement : Component, IArrangedElement private Rectangle _bounds = Rectangle.Empty; private IArrangedElement? _parent; private BitVector32 _state; - private readonly PropertyStore _propertyStore = new PropertyStore(); // Contains all properties that are not always set. + private readonly PropertyStore _propertyStore = new(); // Contains all properties that are not always set. private static readonly int s_stateVisible = BitVector32.CreateMask(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ArrowDirection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ArrowDirection.cs index d405153fb7b..ef6b3855d87 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ArrowDirection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ArrowDirection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AssemblyAttributes.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AssemblyAttributes.cs index e301cf469fc..5dd6106ce0e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AssemblyAttributes.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AssemblyAttributes.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. // Always hard bind to System.dll and System.Drawing.dll diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AutoCompleteMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AutoCompleteMode.cs index eebcf59e1d4..feca11ae2a4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AutoCompleteMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AutoCompleteMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AutoCompleteSource.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AutoCompleteSource.cs index d18867a5b12..5ea086b5172 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AutoCompleteSource.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AutoCompleteSource.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AutoCompleteStringCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AutoCompleteStringCollection.cs index 575594ce92f..3c8fea30ddd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AutoCompleteStringCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AutoCompleteStringCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -68,7 +67,7 @@ public int Add(string value) /// /// Copies the elements of a string array to the end of the . /// - public void AddRange(string[] value) + public void AddRange(params string[] value) { ArgumentNullException.ThrowIfNull(value); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AutoScaleMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AutoScaleMode.cs index cccd56ac9bd..e4e7394afdd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AutoScaleMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AutoScaleMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AutoSizeMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AutoSizeMode.cs index b034363f37a..2128627ecf0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AutoSizeMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AutoSizeMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AutoValidate.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AutoValidate.cs index c66e5809c5e..de8d92d07d4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AutoValidate.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AutoValidate.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AutomationMessages.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AutomationMessages.cs index cba1781a4c4..af261bf1e1f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AutomationMessages.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AutomationMessages.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.ActiveXInvokeKind.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.ActiveXInvokeKind.cs index 47001517e3f..a4b9b411985 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.ActiveXInvokeKind.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.ActiveXInvokeKind.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxComponentEditor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxComponentEditor.cs index 51521f7639a..0d8f7b72988 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxComponentEditor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxComponentEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Windows.Forms.Design; @@ -18,17 +17,8 @@ public override bool EditComponent(ITypeDescriptorContext? context, object obj, { if (obj is AxHost host) { - try - { - s_axHTraceSwitch.TraceVerbose("in AxComponentEditor.EditComponent"); - ((IOleControlSite.Interface)host._oleSite).ShowPropertyFrame(); - return true; - } - catch (Exception ex) - { - Debug.Fail(ex.ToString()); - throw; - } + ((IOleControlSite.Interface)host._oleSite).ShowPropertyFrame().ThrowOnFailure(); + return true; } return false; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxContainer.ExtenderProxy.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxContainer.ExtenderProxy.cs index 6ab8b91d29b..9cf6e91fd8c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxContainer.ExtenderProxy.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxContainer.ExtenderProxy.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Com; using Windows.Win32.System.Ole; @@ -54,7 +53,6 @@ HRESULT IVBGetControl.Interface.EnumControls( ENUM_CONTROLS_WHICH_FLAGS dwWhich, IEnumUnknown** ppenum) { - s_axHTraceSwitch.TraceVerbose("in EnumControls for proxy"); if (ppenum is null) { return HRESULT.E_POINTER; @@ -69,7 +67,6 @@ HRESULT IVBGetControl.Interface.EnumControls( HRESULT IGetOleObject.Interface.GetOleObject(Guid* riid, void** ppvObj) { - s_axHTraceSwitch.TraceVerbose("in GetOleObject for proxy"); if (ppvObj is null) { return HRESULT.E_POINTER; @@ -83,7 +80,8 @@ HRESULT IGetOleObject.Interface.GetOleObject(Guid* riid, void** ppvObj) if (GetControl() is AxHost hostControl) { - *ppvObj = ComHelpers.GetComPointer(hostControl.GetOcx()); + // VB6 passes this back as the IOleObject interface. + *ppvObj = ComHelpers.GetComPointer(hostControl.GetOcx()); return HRESULT.S_OK; } @@ -92,7 +90,6 @@ HRESULT IGetOleObject.Interface.GetOleObject(Guid* riid, void** ppvObj) HRESULT IGetVBAObject.Interface.GetObject(Guid* riid, void** ppvObj, uint dwReserved) { - s_axHTraceSwitch.TraceVerbose("in GetObject for proxy"); if (ppvObj is null || riid is null) { return HRESULT.E_INVALIDARG; @@ -112,7 +109,6 @@ public int Align { get { - s_axHTraceSwitch.TraceVerbose($"in getAlign for proxy for {GetControl()}"); int result = (int)(GetControl()?.Dock ?? NativeMethods.ActiveX.ALIGN_NO_CHANGE); if (result is < NativeMethods.ActiveX.ALIGN_MIN or > NativeMethods.ActiveX.ALIGN_MAX) { @@ -123,7 +119,6 @@ public int Align } set { - s_axHTraceSwitch.TraceVerbose($"in setAlign for proxy for {GetControl()} {value}"); if (GetControl() is { } control) { control.Dock = (DockStyle)value; @@ -133,14 +128,9 @@ public int Align public uint BackColor { - get - { - s_axHTraceSwitch.TraceVerbose($"in getBackColor for proxy for {GetControl()}"); - return GetOleColorFromColor(GetControl()?.BackColor ?? default); - } + get => GetOleColorFromColor(GetControl()?.BackColor ?? default); set { - s_axHTraceSwitch.TraceVerbose($"in setBackColor for proxy for {GetControl()} {value}"); if (GetControl() is { } control) { control.BackColor = GetColorFromOleColor(value); @@ -150,14 +140,9 @@ public uint BackColor public BOOL Enabled { - get - { - s_axHTraceSwitch.TraceVerbose($"in getEnabled for proxy for {GetControl()}"); - return GetControl()?.Enabled ?? BOOL.FALSE; - } + get => GetControl()?.Enabled ?? BOOL.FALSE; set { - s_axHTraceSwitch.TraceVerbose($"in setEnabled for proxy for {GetControl()} {value}"); if (GetControl() is { } control) { control.Enabled = value; @@ -167,14 +152,9 @@ public BOOL Enabled public uint ForeColor { - get - { - s_axHTraceSwitch.TraceVerbose($"in getForeColor for proxy for {GetControl()}"); - return GetOleColorFromColor(GetControl()?.ForeColor ?? default); - } + get => GetOleColorFromColor(GetControl()?.ForeColor ?? default); set { - s_axHTraceSwitch.TraceVerbose($"in setForeColor for proxy for {GetControl()} {value}"); if (GetControl() is { } control) { control.ForeColor = GetColorFromOleColor(value); @@ -184,14 +164,9 @@ public uint ForeColor public int Height { - get - { - s_axHTraceSwitch.TraceVerbose($"in getHeight for proxy for {GetControl()}"); - return Pixel2Twip(GetControl()?.Height ?? 0, xDirection: false); - } + get => Pixel2Twip(GetControl()?.Height ?? 0, xDirection: false); set { - s_axHTraceSwitch.TraceVerbose($"in setHeight for proxy for {GetControl()} {Twip2Pixel(value, false)}"); if (GetControl() is { } control) { control.Height = Twip2Pixel(value, xDirection: false); @@ -201,14 +176,9 @@ public int Height public int Left { - get - { - s_axHTraceSwitch.TraceVerbose($"in getLeft for proxy for {GetControl()}"); - return Pixel2Twip(GetControl()?.Left ?? 0, xDirection: true); - } + get => Pixel2Twip(GetControl()?.Left ?? 0, xDirection: true); set { - s_axHTraceSwitch.TraceVerbose($"in setLeft for proxy for {GetControl()} {Twip2Pixel(value, true)}"); if (GetControl() is { } control) { control.Left = Twip2Pixel(value, xDirection: true); @@ -220,7 +190,6 @@ public IUnknown* Parent { get { - s_axHTraceSwitch.TraceVerbose($"in getParent for proxy for {GetControl()}"); IExtender.Interface? extender = GetContainer() is { } container ? container.GetExtenderProxyForControl(container._parent) : null; @@ -231,14 +200,9 @@ public IUnknown* Parent public short TabIndex { - get - { - s_axHTraceSwitch.TraceVerbose($"in getTabIndex for proxy for {GetControl()}"); - return (short)(GetControl()?.TabIndex ?? 0); - } + get => (short)(GetControl()?.TabIndex ?? 0); set { - s_axHTraceSwitch.TraceVerbose($"in setTabIndex for proxy for {GetControl()} {value}"); if (GetControl() is { } control) { control.TabIndex = value; @@ -248,14 +212,9 @@ public short TabIndex public BOOL TabStop { - get - { - s_axHTraceSwitch.TraceVerbose($"in getTabStop for proxy for {GetControl()}"); - return GetControl()?.TabStop ?? BOOL.FALSE; - } + get => GetControl()?.TabStop ?? BOOL.FALSE; set { - s_axHTraceSwitch.TraceVerbose($"in setTabStop for proxy for {GetControl()} {value}"); if (GetControl() is { } control) { control.TabStop = value; @@ -265,14 +224,9 @@ public BOOL TabStop public int Top { - get - { - s_axHTraceSwitch.TraceVerbose($"in getTop for proxy for {GetControl()}"); - return Pixel2Twip(GetControl()?.Top ?? 0, xDirection: false); - } + get => Pixel2Twip(GetControl()?.Top ?? 0, xDirection: false); set { - s_axHTraceSwitch.TraceVerbose($"in setTop for proxy for {GetControl()} {Twip2Pixel(value, false)}"); if (GetControl() is { } control) { control.Top = Twip2Pixel(value, xDirection: false); @@ -282,14 +236,9 @@ public int Top public BOOL Visible { - get - { - s_axHTraceSwitch.TraceVerbose($"in getVisible for proxy for {GetControl()}"); - return GetControl()?.Visible ?? false; - } + get => GetControl()?.Visible ?? false; set { - s_axHTraceSwitch.TraceVerbose($"in setVisible for proxy for {GetControl()} {value}"); if (GetControl() is { } control) { control.Visible = value; @@ -299,14 +248,9 @@ public BOOL Visible public int Width { - get - { - s_axHTraceSwitch.TraceVerbose($"in getWidth for proxy for {GetControl()}"); - return Pixel2Twip(GetControl()?.Width ?? 0, xDirection: true); - } + get => Pixel2Twip(GetControl()?.Width ?? 0, xDirection: true); set { - s_axHTraceSwitch.TraceVerbose($"in setWidth for proxy for {GetControl()} {Twip2Pixel(value, true)}"); if (GetControl() is { } control) { control.Width = Twip2Pixel(value, xDirection: true); @@ -314,23 +258,9 @@ public int Width } } - public BSTR Name - { - get - { - s_axHTraceSwitch.TraceVerbose($"in getName for proxy for {GetControl()}"); - return new(GetControl() is { } control ? GetNameForControl(control) : string.Empty); - } - } + public BSTR Name => new(GetControl() is { } control ? GetNameForControl(control) : string.Empty); - public HWND Hwnd - { - get - { - s_axHTraceSwitch.TraceVerbose($"in getHwnd for proxy for {GetControl()}"); - return GetControl()?.HWND ?? HWND.Null; - } - } + public HWND Hwnd => GetControl()?.HWND ?? HWND.Null; public IUnknown* Container { @@ -343,14 +273,9 @@ public IUnknown* Container public string Text { - get - { - s_axHTraceSwitch.TraceVerbose($"in getText for proxy for {GetControl()}"); - return GetControl()?.Text ?? string.Empty; - } + get => GetControl()?.Text ?? string.Empty; set { - s_axHTraceSwitch.TraceVerbose($"in setText for proxy for {GetControl()}"); if (GetControl() is { } control) { control.Text = value; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxContainer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxContainer.cs index 169218ecd4f..7f833359bd6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxContainer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxContainer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; @@ -37,7 +36,6 @@ internal unsafe partial class AxContainer : internal AxContainer(ContainerControl parent) { - s_axHTraceSwitch.TraceVerbose($"in constructor. Parent created : {parent.Created}"); _parent = parent; if (parent.Created) { @@ -96,7 +94,6 @@ protected override unsafe HRESULT Invoke( { if (control != _parent && !GetComponents().Contains(control)) { - s_axHTraceSwitch.TraceVerbose("!parent || !belongs NYI"); AxContainer? container = FindContainerForControl(control); if (container is not null) { @@ -104,7 +101,6 @@ protected override unsafe HRESULT Invoke( } else { - s_axHTraceSwitch.TraceVerbose("unable to find proxy, returning null"); return null; } } @@ -116,7 +112,6 @@ protected override unsafe HRESULT Invoke( _extenderCache.Add(control, extender); } - s_axHTraceSwitch.TraceVerbose($"found proxy {extender}"); return extender; } @@ -148,15 +143,6 @@ internal void AddControl(AxHost control) } } } - else - { -#if DEBUG - if (control.Site is { } site && _associatedContainer != site.Container) - { - s_axHTraceSwitch.TraceVerbose("mismatch between assoc container & added control"); - } -#endif - } } } @@ -344,7 +330,6 @@ private void FillComponentsTable(IContainer? container) } Debug.Assert(_parent.Site is null, "Parent is sited but we could not find IContainer"); - s_axHTraceSwitch.TraceVerbose("Did not find a container in FillComponentsTable"); if (_containerCache.Count > 0) { @@ -513,7 +498,6 @@ internal void OnUIActivate(AxHost site) // The ShDocVw control repeatedly calls OnUIActivate() with the same site. // This causes the assert below to fire. Debug.Assert(_siteUIActive is null, "Object did not call OnUIDeactivate"); - s_axHTraceSwitch.TraceVerbose($"active Object is now {site}"); _siteUIActive = site; if (site.ContainingControl is { } container) { @@ -523,7 +507,6 @@ internal void OnUIActivate(AxHost site) internal void ControlCreated(AxHost invoker) { - s_axHTraceSwitch.TraceVerbose($"in controlCreated for {invoker} fAC: {_formAlreadyCreated}"); if (_formAlreadyCreated) { if (invoker.IsUserMode() && invoker.AwaitingDefreezing()) @@ -579,7 +562,6 @@ HRESULT IOleContainer.Interface.ParseDisplayName( uint* pchEaten, IMoniker** ppmkOut) { - s_axHTraceSwitch.TraceVerbose("in ParseDisplayName"); if (ppmkOut is not null) { *ppmkOut = null; @@ -595,8 +577,6 @@ HRESULT IOleContainer.Interface.EnumObjects(uint grfFlags, IEnumUnknown** ppenum return HRESULT.E_POINTER; } - s_axHTraceSwitch.TraceVerbose("in EnumObjects"); - if (((OLECONTF)grfFlags).HasFlag(OLECONTF.OLECONTF_EMBEDDINGS)) { Debug.Assert(_parent is not null); @@ -621,11 +601,7 @@ HRESULT IOleContainer.Interface.EnumObjects(uint grfFlags, IEnumUnknown** ppenum return HRESULT.S_OK; } - HRESULT IOleContainer.Interface.LockContainer(BOOL fLock) - { - s_axHTraceSwitch.TraceVerbose("in LockContainer"); - return HRESULT.E_NOTIMPL; - } + HRESULT IOleContainer.Interface.LockContainer(BOOL fLock) => HRESULT.E_NOTIMPL; // IOleInPlaceFrame methods: HRESULT IOleInPlaceFrame.Interface.GetWindow(HWND* phwnd) @@ -635,34 +611,17 @@ HRESULT IOleInPlaceFrame.Interface.GetWindow(HWND* phwnd) return HRESULT.E_POINTER; } - s_axHTraceSwitch.TraceVerbose("in GetWindow"); *phwnd = _parent.HWND; return HRESULT.S_OK; } - HRESULT IOleInPlaceFrame.Interface.ContextSensitiveHelp(BOOL fEnterMode) - { - s_axHTraceSwitch.TraceVerbose("in ContextSensitiveHelp"); - return HRESULT.S_OK; - } + HRESULT IOleInPlaceFrame.Interface.ContextSensitiveHelp(BOOL fEnterMode) => HRESULT.S_OK; - HRESULT IOleInPlaceFrame.Interface.GetBorder(RECT* lprectBorder) - { - s_axHTraceSwitch.TraceVerbose("in GetBorder"); - return HRESULT.E_NOTIMPL; - } + HRESULT IOleInPlaceFrame.Interface.GetBorder(RECT* lprectBorder) => HRESULT.E_NOTIMPL; - HRESULT IOleInPlaceFrame.Interface.RequestBorderSpace(RECT* pborderwidths) - { - s_axHTraceSwitch.TraceVerbose("in RequestBorderSpace"); - return HRESULT.E_NOTIMPL; - } + HRESULT IOleInPlaceFrame.Interface.RequestBorderSpace(RECT* pborderwidths) => HRESULT.E_NOTIMPL; - HRESULT IOleInPlaceFrame.Interface.SetBorderSpace(RECT* pborderwidths) - { - s_axHTraceSwitch.TraceVerbose("in SetBorderSpace"); - return HRESULT.E_NOTIMPL; - } + HRESULT IOleInPlaceFrame.Interface.SetBorderSpace(RECT* pborderwidths) => HRESULT.E_NOTIMPL; internal void OnExitEditMode(AxHost ctl) { @@ -677,13 +636,19 @@ internal void OnExitEditMode(AxHost ctl) HRESULT IOleInPlaceFrame.Interface.SetActiveObject(IOleInPlaceActiveObject* pActiveObject, PCWSTR pszObjName) { - s_axHTraceSwitch.TraceVerbose($"in SetActiveObject {pszObjName.ToString() ?? ""}"); if (_siteUIActive is { } activeHost && activeHost._iOleInPlaceActiveObjectExternal is { } existing - && existing.OriginalHandle != pActiveObject) + && !existing.MatchesOriginalPointer(pActiveObject)) { + // Release the field before disposing to avoid accessing it during disposal on callbacks. + activeHost._iOleInPlaceActiveObjectExternal = null; existing.Dispose(); - activeHost._iOleInPlaceActiveObjectExternal = new(pActiveObject, takeOwnership: true); + + if (pActiveObject is not null) + { + pActiveObject->AddRef(); + activeHost._iOleInPlaceActiveObjectExternal = new(pActiveObject, takeOwnership: true); + } } if (pActiveObject is null) @@ -722,12 +687,10 @@ HRESULT IOleInPlaceFrame.Interface.SetActiveObject(IOleInPlaceActiveObject* pAct if (host is null) { - s_axHTraceSwitch.TraceVerbose("control w/o a valid site called setactiveobject"); _controlInEditMode = null; } else { - s_axHTraceSwitch.TraceVerbose($"resolved to {host}"); if (!host.IsUserMode()) { _controlInEditMode = host; @@ -740,41 +703,17 @@ HRESULT IOleInPlaceFrame.Interface.SetActiveObject(IOleInPlaceActiveObject* pAct return HRESULT.S_OK; } - unsafe HRESULT IOleInPlaceFrame.Interface.InsertMenus(HMENU hmenuShared, OLEMENUGROUPWIDTHS* lpMenuWidths) - { - s_axHTraceSwitch.TraceVerbose("in InsertMenus"); - return HRESULT.S_OK; - } + HRESULT IOleInPlaceFrame.Interface.InsertMenus(HMENU hmenuShared, OLEMENUGROUPWIDTHS* lpMenuWidths) => HRESULT.S_OK; - HRESULT IOleInPlaceFrame.Interface.SetMenu(HMENU hmenuShared, nint holemenu, HWND hwndActiveObject) - { - s_axHTraceSwitch.TraceVerbose("in SetMenu"); - return HRESULT.E_NOTIMPL; - } + HRESULT IOleInPlaceFrame.Interface.SetMenu(HMENU hmenuShared, nint holemenu, HWND hwndActiveObject) => HRESULT.E_NOTIMPL; - HRESULT IOleInPlaceFrame.Interface.RemoveMenus(HMENU hmenuShared) - { - s_axHTraceSwitch.TraceVerbose("in RemoveMenus"); - return HRESULT.E_NOTIMPL; - } + HRESULT IOleInPlaceFrame.Interface.RemoveMenus(HMENU hmenuShared) => HRESULT.E_NOTIMPL; - HRESULT IOleInPlaceFrame.Interface.SetStatusText(PCWSTR pszStatusText) - { - s_axHTraceSwitch.TraceVerbose("in SetStatusText"); - return HRESULT.E_NOTIMPL; - } + HRESULT IOleInPlaceFrame.Interface.SetStatusText(PCWSTR pszStatusText) => HRESULT.E_NOTIMPL; - HRESULT IOleInPlaceFrame.Interface.EnableModeless(BOOL fEnable) - { - s_axHTraceSwitch.TraceVerbose("in EnableModeless"); - return HRESULT.E_NOTIMPL; - } + HRESULT IOleInPlaceFrame.Interface.EnableModeless(BOOL fEnable) => HRESULT.E_NOTIMPL; - HRESULT IOleInPlaceFrame.Interface.TranslateAccelerator(MSG* lpmsg, ushort wID) - { - s_axHTraceSwitch.TraceVerbose("in IOleInPlaceFrame.TranslateAccelerator"); - return HRESULT.S_FALSE; - } + HRESULT IOleInPlaceFrame.Interface.TranslateAccelerator(MSG* lpmsg, ushort wID) => HRESULT.S_FALSE; HRESULT IOleInPlaceUIWindow.Interface.GetWindow(HWND* phwnd) => ((IOleInPlaceFrame.Interface)this).GetWindow(phwnd); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxEnumConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxEnumConverter.cs index 8cb4d84ca62..5545fa92371 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxEnumConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxEnumConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Windows.Forms.ComponentModel.Com2Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxFlags.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxFlags.cs index 6483effd278..46f2b3c9f07 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxFlags.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxFlags.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPerPropertyBrowsingEnum.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPerPropertyBrowsingEnum.cs index 63ef287fbe0..8bdfb7e50f2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPerPropertyBrowsingEnum.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPerPropertyBrowsingEnum.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.ComponentModel.Com2Interop; using Windows.Win32.System.Ole; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPropertyDescriptor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPropertyDescriptor.cs index cb41a6f998b..83b45a9356b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPropertyDescriptor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPropertyDescriptor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; @@ -45,13 +44,12 @@ internal AxPropertyDescriptor(PropertyDescriptor baseDescriptor, AxHost owner) : Guid g = GetPropertyPage(_dispid.Value); if (!Guid.Empty.Equals(g)) { - s_axPropTraceSwitch.TraceVerbose($"Making property: {Name} browsable because we found an property page."); AddAttribute(new BrowsableAttribute(true)); } } // Use the CategoryAttribute provided by the OCX. - CategoryAttribute cat = owner.GetCategoryForDispid(_dispid.Value); + CategoryAttribute? cat = owner.GetCategoryForDispid(_dispid.Value); if (cat is not null) { AddAttribute(cat); @@ -171,12 +169,10 @@ private unsafe Guid GetPropertyPage(int dispid) _owner.NoComponentChangeEvents++; return _baseDescriptor.GetValue(component); } - catch (Exception e) + catch (Exception) { if (!GetFlag(FlagCheckGetter)) { - s_axPropTraceSwitch.TraceVerbose( - $"Get failed for : {Name} with exception: {e.Message}. Making property non-browsable."); SetFlag(FlagCheckGetter, true); AddAttribute(new BrowsableAttribute(false)); _owner.RefreshAllProperties = true; @@ -362,14 +358,12 @@ internal unsafe void UpdateTypeConverterAndTypeEditorInternal(bool force, int di // Show any non-browsable property that has an editor through a property page. if (!IsBrowsable) { - s_axPropTraceSwitch.TraceVerbose($"Making property: {Name} browsable because we found an editor."); AddAttribute(new BrowsableAttribute(true)); } } } - catch (Exception ex) + catch (Exception) { - s_axPropTraceSwitch.TraceVerbose($"Could not get the type editor for property: {Name} Exception: {ex}"); } finally { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPropertyTypeEditor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPropertyTypeEditor.cs index 8782615aa26..6f5998b35a6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPropertyTypeEditor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPropertyTypeEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.ClsidAttribute.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.ClsidAttribute.cs index afdafc6fd8a..2d4b856fe35 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.ClsidAttribute.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.ClsidAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.ConnectionPointCookie.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.ConnectionPointCookie.cs index 2d7dd32a7e8..760ea9db68b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.ConnectionPointCookie.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.ConnectionPointCookie.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.EnumUnknown.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.EnumUnknown.cs index d4bbd06582d..a7c2c12d169 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.EnumUnknown.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.EnumUnknown.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.InvalidActiveXStateException.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.InvalidActiveXStateException.cs index 52ec40049d3..dd0cb8b42a3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.InvalidActiveXStateException.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.InvalidActiveXStateException.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.OleInterfaces.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.OleInterfaces.cs index 84860c4d84a..165cff86f3d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.OleInterfaces.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.OleInterfaces.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; @@ -69,8 +68,6 @@ internal void StopEvents() // IGetVBAObject methods: HRESULT IGetVBAObject.Interface.GetObject(Guid* riid, void** ppvObj, uint dwReserved) { - s_axHTraceSwitch.TraceVerbose("in GetObject"); - if (ppvObj is null || riid is null) { return HRESULT.E_INVALIDARG; @@ -93,7 +90,6 @@ HRESULT IVBGetControl.Interface.EnumControls( ENUM_CONTROLS_WHICH_FLAGS dwWhich, IEnumUnknown** ppenum) { - s_axHTraceSwitch.TraceVerbose("in EnumControls"); *ppenum = ComHelpers.GetComPointer( _host.GetParentContainer().EnumControls(_host, dwOleContF, dwWhich)); return HRESULT.S_OK; @@ -130,7 +126,7 @@ protected override unsafe HRESULT Invoke( return HRESULT.E_POINTER; } - object ambient = _host.GetAmbientProperty(dispId); + object? ambient = _host.GetAmbientProperty(dispId); if (ambient is not null) { Marshal.GetNativeVariantForObject(ambient, (nint)result); @@ -141,33 +137,24 @@ protected override unsafe HRESULT Invoke( } // IOleControlSite methods: - HRESULT IOleControlSite.Interface.OnControlInfoChanged() - { - s_axHTraceSwitch.TraceVerbose("in OnControlInfoChanged"); - return HRESULT.S_OK; - } + HRESULT IOleControlSite.Interface.OnControlInfoChanged() => HRESULT.S_OK; - HRESULT IOleControlSite.Interface.LockInPlaceActive(BOOL fLock) - { - s_axHTraceSwitch.TraceVerbose("in LockInPlaceActive"); - return HRESULT.E_NOTIMPL; - } + HRESULT IOleControlSite.Interface.LockInPlaceActive(BOOL fLock) => HRESULT.E_NOTIMPL; HRESULT IOleControlSite.Interface.GetExtendedControl(IDispatch** ppDisp) { - s_axHTraceSwitch.TraceVerbose($"in GetExtendedControl {_host}"); if (ppDisp is null) { return HRESULT.E_POINTER; } - object? proxy = _host.GetParentContainer().GetExtenderProxyForControl(_host); + AxContainer.ExtenderProxy? proxy = _host.GetParentContainer().GetExtenderProxyForControl(_host); if (proxy is null) { return HRESULT.E_NOTIMPL; } - *ppDisp = (IDispatch*)Marshal.GetIDispatchForObject(proxy); + *ppDisp = ComHelpers.GetComPointer(proxy); return HRESULT.S_OK; } @@ -179,7 +166,7 @@ HRESULT IOleControlSite.Interface.TransformCoords(POINTL* pPtlHimetric, PointF* } HRESULT hr = SetupLogPixels(force: false); - if (hr < 0) + if (hr.Failed) { return hr; } @@ -199,7 +186,6 @@ HRESULT IOleControlSite.Interface.TransformCoords(POINTL* pPtlHimetric, PointF* } else { - s_axHTraceSwitch.TraceVerbose($"\t dwFlags not supported: {dwFlags}"); return HRESULT.E_INVALIDARG; } } @@ -217,13 +203,11 @@ HRESULT IOleControlSite.Interface.TransformCoords(POINTL* pPtlHimetric, PointF* } else { - s_axHTraceSwitch.TraceVerbose($"\t dwFlags not supported: {dwFlags}"); return HRESULT.E_INVALIDARG; } } else { - s_axHTraceSwitch.TraceVerbose($"\t dwFlags not supported: {dwFlags}"); return HRESULT.E_INVALIDARG; } @@ -266,11 +250,7 @@ HRESULT IOleControlSite.Interface.ShowPropertyFrame() } // IOleClientSite methods: - HRESULT IOleClientSite.Interface.SaveObject() - { - s_axHTraceSwitch.TraceVerbose("in SaveObject"); - return HRESULT.E_NOTIMPL; - } + HRESULT IOleClientSite.Interface.SaveObject() => HRESULT.E_NOTIMPL; unsafe HRESULT IOleClientSite.Interface.GetMoniker(uint dwAssign, uint dwWhichMoniker, IMoniker** ppmk) { @@ -279,7 +259,6 @@ unsafe HRESULT IOleClientSite.Interface.GetMoniker(uint dwAssign, uint dwWhichMo return HRESULT.E_POINTER; } - Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:GetMoniker"); *ppmk = null; return HRESULT.E_NOTIMPL; } @@ -291,14 +270,12 @@ unsafe HRESULT IOleClientSite.Interface.GetContainer(IOleContainer** ppContainer return HRESULT.E_POINTER; } - s_axHTraceSwitch.TraceVerbose("in getContainer"); *ppContainer = ComHelpers.GetComPointer(_host.GetParentContainer()); return HRESULT.S_OK; } unsafe HRESULT IOleClientSite.Interface.ShowObject() { - s_axHTraceSwitch.TraceVerbose("in ShowObject"); if (_host.GetAxState(s_fOwnWindow)) { Debug.Fail("we can't be in showobject if we own our window..."); @@ -338,24 +315,15 @@ unsafe HRESULT IOleClientSite.Interface.ShowObject() } else if (inPlaceObject.SupportsInterface()) { - s_axHTraceSwitch.TraceVerbose("Windowless control."); throw new InvalidOperationException(SR.AXWindowlessControl); } return HRESULT.S_OK; } - HRESULT IOleClientSite.Interface.OnShowWindow(BOOL fShow) - { - s_axHTraceSwitch.TraceVerbose("in OnShowWindow"); - return HRESULT.S_OK; - } + HRESULT IOleClientSite.Interface.OnShowWindow(BOOL fShow) => HRESULT.S_OK; - HRESULT IOleClientSite.Interface.RequestNewObjectLayout() - { - s_axHTraceSwitch.TraceVerbose("in RequestNewObjectLayout"); - return HRESULT.E_NOTIMPL; - } + HRESULT IOleClientSite.Interface.RequestNewObjectLayout() => HRESULT.E_NOTIMPL; // IOleInPlaceSite methods: @@ -372,26 +340,16 @@ HRESULT IOleInPlaceSite.Interface.GetWindow(HWND* phwnd) return HRESULT.E_POINTER; } - s_axHTraceSwitch.TraceVerbose("in GetWindow"); *phwnd = _host.ParentInternal?.HWND ?? HWND.Null; return HRESULT.S_OK; } - HRESULT IOleInPlaceSite.Interface.ContextSensitiveHelp(BOOL fEnterMode) - { - s_axHTraceSwitch.TraceVerbose("in ContextSensitiveHelp"); - return HRESULT.E_NOTIMPL; - } + HRESULT IOleInPlaceSite.Interface.ContextSensitiveHelp(BOOL fEnterMode) => HRESULT.E_NOTIMPL; - HRESULT IOleInPlaceSite.Interface.CanInPlaceActivate() - { - s_axHTraceSwitch.TraceVerbose("in CanInPlaceActivate"); - return HRESULT.S_OK; - } + HRESULT IOleInPlaceSite.Interface.CanInPlaceActivate() => HRESULT.S_OK; HRESULT IOleInPlaceSite.Interface.OnInPlaceActivate() { - s_axHTraceSwitch.TraceVerbose("in OnInPlaceActivate"); _host.SetAxState(s_ownDisposing, false); _host.SetAxState(s_rejectSelection, false); _host.SetOcState(OC_INPLACE); @@ -400,7 +358,6 @@ HRESULT IOleInPlaceSite.Interface.OnInPlaceActivate() HRESULT IOleInPlaceSite.Interface.OnUIActivate() { - s_axHTraceSwitch.TraceVerbose($"in OnUIActivate for {_host}"); _host.SetOcState(OC_UIACTIVE); _host.GetParentContainer().OnUIActivate(_host); return HRESULT.S_OK; @@ -413,9 +370,19 @@ HRESULT IOleInPlaceSite.Interface.GetWindowContext( RECT* lprcClipRect, OLEINPLACEFRAMEINFO* lpFrameInfo) { - ppDoc = null; + // Following MFC CAxHostWindow::GetWindowContext handling + + if (ppFrame is not null) + { + *ppFrame = null; + } - if (ppFrame is null || lprcPosRect is null || lprcClipRect is null) + if (ppDoc is not null) + { + *ppDoc = null; + } + + if (ppDoc is null || ppFrame is null || lprcPosRect is null || lprcClipRect is null) { return HRESULT.E_POINTER; } @@ -423,6 +390,7 @@ HRESULT IOleInPlaceSite.Interface.GetWindowContext( *ppFrame = ComHelpers.GetComPointer(_host.GetParentContainer()); *lprcPosRect = _host.Bounds; *lprcClipRect = WebBrowserHelper.GetClipRect(); + if (lpFrameInfo is not null) { lpFrameInfo->cb = (uint)sizeof(OLEINPLACEFRAMEINFO); @@ -439,7 +407,6 @@ HRESULT IOleInPlaceSite.Interface.GetWindowContext( HRESULT IOleInPlaceSite.Interface.OnUIDeactivate(BOOL fUndoable) { - s_axHTraceSwitch.TraceVerbose($"in OnUIDeactivate for {_host}"); _host.GetParentContainer().OnUIDeactivate(_host); if (_host.GetOcState() > OC_INPLACE) { @@ -451,10 +418,9 @@ HRESULT IOleInPlaceSite.Interface.OnUIDeactivate(BOOL fUndoable) HRESULT IOleInPlaceSite.Interface.OnInPlaceDeactivate() { - s_axHTraceSwitch.TraceVerbose("in OnInPlaceDeactivate"); if (_host.GetOcState() == OC_UIACTIVE) { - ((IOleInPlaceSite.Interface)this).OnUIDeactivate(false); + ((IOleInPlaceSite.Interface)this).OnUIDeactivate(fUndoable: false).AssertSuccess(); } _host.GetParentContainer().OnInPlaceDeactivate(_host); @@ -463,15 +429,10 @@ HRESULT IOleInPlaceSite.Interface.OnInPlaceDeactivate() return HRESULT.S_OK; } - HRESULT IOleInPlaceSite.Interface.DiscardUndoState() - { - s_axHTraceSwitch.TraceVerbose("in DiscardUndoState"); - return HRESULT.S_OK; - } + HRESULT IOleInPlaceSite.Interface.DiscardUndoState() => HRESULT.S_OK; HRESULT IOleInPlaceSite.Interface.DeactivateAndUndo() { - s_axHTraceSwitch.TraceVerbose($"in DeactivateAndUndo for {_host}"); using var inPlaceObject = _host.GetComScope(); return inPlaceObject.Value->UIDeactivate(); } @@ -494,16 +455,11 @@ HRESULT IOleInPlaceSite.Interface.OnPosRectChange(RECT* lprcPosRect) if (useRect) { - s_axHTraceSwitch.TraceVerbose($"in OnPosRectChange{lprcPosRect->ToString()}"); RECT clipRect = WebBrowserHelper.GetClipRect(); using var inPlaceObject = _host.GetComScope(); inPlaceObject.Value->SetObjectRects(lprcPosRect, &clipRect).ThrowOnFailure(); _host.MakeDirty(); } - else - { - s_axHTraceSwitch.TraceVerbose("Control directly called OnPosRectChange... ignoring the new size"); - } return HRESULT.S_OK; } @@ -524,8 +480,6 @@ HRESULT IPropertyNotifySink.Interface.OnChanged(int dispid) { AxPropertyDescriptor? prop = null; - s_axHTraceSwitch.TraceVerbose("in OnChanged"); - if (dispid != PInvoke.DISPID_UNKNOWN) { prop = _host.GetPropertyDescriptorFromDispid(dispid); @@ -580,10 +534,6 @@ HRESULT IPropertyNotifySink.Interface.OnChanged(int dispid) return HRESULT.S_OK; } - HRESULT IPropertyNotifySink.Interface.OnRequestEdit(int dispid) - { - s_axHTraceSwitch.TraceVerbose($"in OnRequestEdit for {_host}"); - return HRESULT.S_OK; - } + HRESULT IPropertyNotifySink.Interface.OnRequestEdit(int dispid) => HRESULT.S_OK; } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.PropertyBagStream.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.PropertyBagStream.cs index 20ab1c526dd..4d5d1ed0b8a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.PropertyBagStream.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.PropertyBagStream.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Runtime.Serialization.Formatters.Binary; @@ -63,8 +62,6 @@ HRESULT IPropertyBag.Interface.Read(PCWSTR pszPropName, VARIANT* pVar, IErrorLog string name = pszPropName.ToString(); - s_axHTraceSwitch.TraceVerbose($"Reading property {name} from OCXState propertybag."); - if (!_bag.Contains(name)) { *pVar = default; @@ -73,7 +70,6 @@ HRESULT IPropertyBag.Interface.Read(PCWSTR pszPropName, VARIANT* pVar, IErrorLog object? value = _bag[name]; *pVar = VARIANT.FromObject(value); - s_axHTraceSwitch.TraceVerbose($"\tValue={value ?? ""}"); // The EE returns a VT_EMPTY for a null. The problem is that Visual Basic 6 expects the caller to respect // the "hint" it gives in the VariantType. For eg., for a VT_BSTR, it expects that the callee will null @@ -93,7 +89,6 @@ HRESULT IPropertyBag.Interface.Write(PCWSTR pszPropName, VARIANT* pVar) string name = pszPropName.ToString(); object? value = pVar->ToObject(); - s_axHTraceSwitch.TraceVerbose($"Writing property {name} [{*pVar}] into OCXState propertybag."); _bag[name] = value; return HRESULT.S_OK; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.State.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.State.cs index 017a31675a6..07f5f64422f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.State.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.State.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.InteropServices; @@ -34,17 +33,20 @@ public class State : ISerializable, IDisposable private const string DataSerializationName = "Data"; // Create on save from IPersistStream. - internal State(MemoryStream memoryStream, int storageType, AxHost control, PropertyBagStream propertyBag) + internal State(MemoryStream memoryStream, StorageType storageType, AxHost control) { Type = storageType; - _propertyBag = propertyBag; _length = checked((int)memoryStream.Length); _memoryStream = memoryStream; ManualUpdate = control.GetAxState(s_manualUpdate); LicenseKey = control.GetLicenseKey(); } - internal State(PropertyBagStream propertyBag) => _propertyBag = propertyBag; + internal State(PropertyBagStream propertyBag) + { + Type = StorageType.PropertyBag; + _propertyBag = propertyBag; + } // Construct State using StateConverter information. // We do not want to save the memoryStream since it contains @@ -58,12 +60,13 @@ internal State(AxHost control) CreateStorage(); ManualUpdate = control.GetAxState(s_manualUpdate); LicenseKey = control.GetLicenseKey(); - Type = STG_STORAGE; + Type = StorageType.Storage; } public State(Stream ms, int storageType, bool manualUpdate, string? licKey) { - Type = storageType; + // Translate by +1 to match our internal storage values + Type = (StorageType)(storageType + 1); _length = checked((int)ms.Length); ManualUpdate = manualUpdate; LicenseKey = licKey; @@ -104,7 +107,6 @@ protected State(SerializationInfo info, StreamingContext context) { try { - s_axHTraceSwitch.TraceVerbose("Loading up property bag from stream..."); byte[]? data = enumerator.Value as byte[]; if (data is not null) { @@ -120,7 +122,7 @@ protected State(SerializationInfo info, StreamingContext context) } } - internal int Type { get; set; } + internal StorageType Type { get; set; } internal bool ManualUpdate { get; private set; } @@ -180,7 +182,8 @@ private unsafe void CreateStorage() _storage = new(storage, takeOwnership: true); } - internal IPropertyBag.Interface? GetPropBag() => _propertyBag; + internal ComScope GetPropBag() + => _propertyBag is null ? default : ComHelpers.GetComScope(_propertyBag); internal unsafe ComScope GetStorage() { @@ -192,14 +195,14 @@ internal unsafe ComScope GetStorage() return _storage is null ? default : _storage.GetInterface(); } - internal IStream.Interface? GetStream() + internal ComScope GetStream() { if (_memoryStream is null) { Debug.Assert(_buffer is not null); if (_buffer is null) { - return null; + return default; } _memoryStream = new MemoryStream(_buffer); @@ -209,7 +212,7 @@ internal unsafe ComScope GetStorage() _memoryStream.Seek(0, SeekOrigin.Begin); } - return new Ole32.GPStream(_memoryStream); + return ComHelpers.GetComScope(new Ole32.GPStream(_memoryStream)); } private void InitializeFromStream(Stream dataStream, bool initializeBufferOnly = false) @@ -218,7 +221,9 @@ private void InitializeFromStream(Stream dataStream, bool initializeBufferOnly = if (!initializeBufferOnly) { - Type = binaryReader.ReadInt32(); + // For compatibility, always translate by adding 1 to match our new internal + // storage values (unknown = 0, stream = 1, etc.). + Type = (StorageType)(binaryReader.ReadInt32() + 1); int version = binaryReader.ReadInt32(); ManualUpdate = binaryReader.ReadBoolean(); int cc = binaryReader.ReadInt32(); @@ -241,7 +246,7 @@ private void InitializeFromStream(Stream dataStream, bool initializeBufferOnly = } } - internal unsafe State? RefreshStorage(IPersistStorage.Interface iPersistStorage) + internal unsafe State? RefreshStorage(IPersistStorage* iPersistStorage) { Debug.Assert(_storage is not null, "how can we not have a storage object?"); Debug.Assert(_lockBytes is not null, "how can we have a storage w/o ILockBytes?"); @@ -251,9 +256,9 @@ private void InitializeFromStream(Stream dataStream, bool initializeBufferOnly = } using var storage = _storage.GetInterface(); - iPersistStorage.Save(storage, fSameAsLoad: true).ThrowOnFailure(); + iPersistStorage->Save(storage, fSameAsLoad: true).ThrowOnFailure(); storage.Value->Commit(0); - iPersistStorage.HandsOffStorage().ThrowOnFailure(); + iPersistStorage->HandsOffStorage().ThrowOnFailure(); try { _buffer = null; @@ -285,7 +290,7 @@ private void InitializeFromStream(Stream dataStream, bool initializeBufferOnly = } finally { - iPersistStorage.SaveCompleted(storage).ThrowOnFailure(); + iPersistStorage->SaveCompleted(storage).ThrowOnFailure(); } return this; @@ -295,7 +300,9 @@ internal void Save(MemoryStream stream) { using BinaryWriter binaryWriter = new(stream); - binaryWriter.Write(Type); + // For compatibility, always translate back to the original storage type values + // (unknown = -1, stream = 0, etc.) by subtracting 1 when saving. + binaryWriter.Write(((int)Type) - 1); binaryWriter.Write(VERSION); binaryWriter.Write(ManualUpdate); if (LicenseKey is { } licenseKey) @@ -340,9 +347,8 @@ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext contex _propertyBag.Save(propertyBagBinaryStream); info.AddValue(PropertyBagSerializationName, propertyBagBinaryStream.ToArray()); } - catch (Exception e) + catch (Exception) { - s_axHTraceSwitch.TraceVerbose($"Failed to serialize the property bag into ResX : {e}"); } } } @@ -351,10 +357,8 @@ protected virtual void Dispose(bool disposing) { if (disposing) { - _lockBytes?.Dispose(); - _storage?.Dispose(); - _lockBytes = null; - _storage = null; + DisposeHelper.NullAndDispose(ref _lockBytes); + DisposeHelper.NullAndDispose(ref _storage); } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.StateConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.StateConverter.cs index 4bd96f10a1a..10696a1a0c7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.StateConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.StateConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.StorageType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.StorageType.cs new file mode 100644 index 00000000000..b9b45688533 --- /dev/null +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.StorageType.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Windows.Forms; + +public abstract partial class AxHost +{ + internal enum StorageType + { + Unknown, + Stream, + StreamInit, + Storage, + PropertyBag + } +} diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.TypeLibraryTimeStampAttribute.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.TypeLibraryTimeStampAttribute.cs index d99ba48f322..2d7e96474e8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.TypeLibraryTimeStampAttribute.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.TypeLibraryTimeStampAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.VBFormat.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.VBFormat.cs index c8817be57dd..9a88f8510ef 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.VBFormat.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.VBFormat.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Com; using Windows.Win32.System.Ole; @@ -22,7 +21,6 @@ HRESULT IVBFormat.Interface.Format( ushort sFirstWeekOfYear, ushort* rcb) { - s_axHTraceSwitch.TraceVerbose("in Format"); if (rcb is null) { return HRESULT.E_INVALIDARG; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.cs index a21d498e5ee..7e2d5f4997f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -26,10 +25,6 @@ namespace System.Windows.Forms; [Designer($"System.Windows.Forms.Design.AxHostDesigner, {AssemblyRef.SystemDesign}")] public abstract unsafe partial class AxHost : Control, ISupportInitialize, ICustomTypeDescriptor { - private static readonly TraceSwitch s_axHTraceSwitch = new("AxHTrace", "ActiveX handle tracing"); - private static readonly TraceSwitch s_axPropTraceSwitch = new("AxPropTrace", "ActiveX property tracing"); - private static readonly TraceSwitch s_axHostSwitch = new("AxHost", "ActiveX host creation"); - #if DEBUG private static readonly BooleanSwitch s_axAlwaysSaveSwitch = new( "AxAlwaysSave", @@ -50,11 +45,6 @@ public abstract unsafe partial class AxHost : Control, ISupportInitialize, ICust private const int EDITM_OBJECT = 1; // object provided an edit verb and we invoked it private const int EDITM_HOST = 2; // we invoked our own edit verb - private const int STG_UNKNOWN = -1; - private const int STG_STREAM = 0; - private const int STG_STREAMINIT = 1; - private const int STG_STORAGE = 2; - private readonly uint _subclassCheckMessage = PInvoke.RegisterWindowMessage($"{Application.WindowMessagesVersion}_subclassCheck"); @@ -107,7 +97,7 @@ private readonly uint _subclassCheckMessage private BitVector32 _axState; - private int _storageType = STG_UNKNOWN; + private StorageType _storageType = StorageType.Unknown; private int _ocState = OC_PASSIVE; private OLEMISC _miscStatusBits; private int _freezeCount; @@ -142,10 +132,6 @@ private readonly uint _subclassCheckMessage private object? _instance; private AgileComPointer? _iOleInPlaceActiveObjectExternal; - private IPersistPropertyBag.Interface? _iPersistPropBag; - private IPersistStream.Interface? _iPersistStream; - private IPersistStreamInit.Interface? _iPersistStreamInit; - private IPersistStorage.Interface? _iPersistStorage; private AboutBoxDelegate? _aboutBoxDelegate; private readonly EventHandler _selectionChangeHandler; @@ -437,28 +423,28 @@ public void EndInit() { ParentInternal.CreateControl(true); - ContainerControl f = ContainingControl; - if (f is not null) + ContainerControl? containingControl = ContainingControl; + if (containingControl is not null) { - f.VisibleChanged += _onContainerVisibleChanged; + containingControl.VisibleChanged += _onContainerVisibleChanged; } } } private void OnContainerVisibleChanged(object? sender, EventArgs e) { - ContainerControl f = ContainingControl; - if (f is not null) + ContainerControl? containingControl = ContainingControl; + if (containingControl is not null) { - if (f.Visible && Visible && !_axState[s_fOwnWindow]) + if (containingControl.Visible && Visible && !_axState[s_fOwnWindow]) { MakeVisibleWithShow(); } - else if (!f.Visible && Visible && IsHandleCreated && GetOcState() >= OC_INPLACE) + else if (!containingControl.Visible && Visible && IsHandleCreated && GetOcState() >= OC_INPLACE) { HideAxControl(); } - else if (f.Visible && !GetState(States.Visible) && IsHandleCreated && GetOcState() >= OC_INPLACE) + else if (containingControl.Visible && !GetState(States.Visible) && IsHandleCreated && GetOcState() >= OC_INPLACE) { HideAxControl(); } @@ -951,8 +937,8 @@ public override ISite? Site { TransitionDownTo(OC_LOADED); TransitionUpTo(OC_INPLACE); - ContainerControl f = ContainingControl; - if (f is not null && f.Visible && Visible) + ContainerControl? containingControl = ContainingControl; + if (containingControl is not null && containingControl.Visible && Visible) { MakeVisibleWithShow(); } @@ -1006,8 +992,7 @@ private void OnNewSelection(object? sender, EventArgs e) if (GetOcState() >= OC_UIACTIVE && !selectionService.GetComponentSelected(this)) { // Need to deactivate. - HRESULT hr = UiDeactivate(); - Debug.Assert(hr.Succeeded, $"Failed to UiDeactivate: {hr}"); + UiDeactivate().AssertSuccess(); } if (!selectionService.GetComponentSelected(this)) @@ -1090,14 +1075,13 @@ private static HRESULT SetupLogPixels(bool force) if (s_logPixelsX == -1 || force) { using var dc = GetDcScope.ScreenDC; - if (dc == IntPtr.Zero) + if (dc.IsNull) { return HRESULT.E_FAIL; } s_logPixelsX = PInvoke.GetDeviceCaps(dc, GET_DEVICE_CAPS_INDEX.LOGPIXELSX); s_logPixelsY = PInvoke.GetDeviceCaps(dc, GET_DEVICE_CAPS_INDEX.LOGPIXELSY); - s_axHTraceSwitch.TraceVerbose($"log pixels are: {s_logPixelsX} {s_logPixelsY}"); } return HRESULT.S_OK; @@ -1152,7 +1136,6 @@ private static int Twip2Pixel(int v, bool xDirection) private unsafe Size SetExtent(int width, int height) { - s_axHTraceSwitch.TraceVerbose($"setting extent to {width} {height}"); Size size = new(width, height); bool resetExtents = !IsUserMode(); Pixel2hiMetric(ref size); @@ -1294,7 +1277,6 @@ private bool CheckSubclassing() } // We were resubclassed, we need to resublass ourselves. - s_axHostSwitch.TraceVerbose("The control subclassed itself w/o calling the old wndproc."); Debug.Assert(!OwnWindow(), "Why are we here if we own our window?"); WindowReleaseHandle(); PInvoke.SetWindowLong(this, WINDOW_LONG_PTR_INDEX.GWL_WNDPROC, currentWndproc); @@ -1303,7 +1285,7 @@ private bool CheckSubclassing() _axState[s_manualUpdate] = true; return false; } -#nullable disable + /// /// Destroys the handle associated with this control. /// User code should in general not call this function. @@ -1324,7 +1306,6 @@ private void TransitionDownTo(int state) { if (_axState[s_inTransition]) { - s_axHTraceSwitch.TraceVerbose("Recursively entering TransitionDownTo..."); return; } @@ -1341,9 +1322,7 @@ private void TransitionDownTo(int state) SetOcState(OC_UIACTIVE); break; case OC_UIACTIVE: - HRESULT hr = UiDeactivate(); - Debug.Assert(hr.Succeeded, $"Failed in UiDeactivate: {hr}"); - Debug.WriteLineIf(s_axHTraceSwitch.TraceVerbose && GetOcState() == OC_INPLACE, "failed transition"); + UiDeactivate().AssertSuccess(); SetOcState(OC_INPLACE); break; case OC_INPLACE: @@ -1357,7 +1336,6 @@ private void TransitionDownTo(int state) InPlaceDeactivate(); } - Debug.WriteLineIf(s_axHTraceSwitch.TraceVerbose && GetOcState() == OC_RUNNING, "failed transition"); SetOcState(OC_RUNNING); break; case OC_RUNNING: @@ -1388,7 +1366,6 @@ private void TransitionUpTo(int state) { if (_axState[s_inTransition]) { - s_axHTraceSwitch.TraceVerbose("Recursively entering TransitionUpTo..."); return; } @@ -1398,7 +1375,6 @@ private void TransitionUpTo(int state) while (state > GetOcState()) { - s_axHTraceSwitch.TraceVerbose($"Transitioning up from: {GetOcState()} to: {state}"); switch (GetOcState()) { case OC_PASSIVE: @@ -1508,12 +1484,12 @@ private void InPlaceActivate() private HRESULT InPlaceDeactivate() { _axState[s_ownDisposing] = true; - ContainerControl f = ContainingControl; - if (f is not null) + ContainerControl? containingControl = ContainingControl; + if (containingControl is not null) { - if (f.ActiveControl == this) + if (containingControl.ActiveControl == this) { - f.ActiveControl = null; + containingControl.ActiveControl = null; } } @@ -1523,7 +1499,6 @@ private HRESULT InPlaceDeactivate() private void UiActivate() { - s_axHTraceSwitch.TraceVerbose($"calling uiActivate for {ToString()}"); Debug.Assert(CanUIActivate, "we have to be able to uiactivate"); if (CanUIActivate) { @@ -1550,7 +1525,6 @@ private void EnsureWindowPresent() // if the ctl didn't call showobject, we need to do it for it... if (!IsHandleCreated) { - s_axHTraceSwitch.TraceVerbose("Naughty control didn't call showObject..."); try { ((IOleClientSite.Interface)_oleSite).ShowObject(); @@ -1605,7 +1579,6 @@ protected override void SetVisibleCore(bool value) } catch { - s_axHTraceSwitch.TraceVerbose("Could not make ctl visible by using INPLACE. Will try SHOW"); MakeVisibleWithShow(); } } @@ -1640,8 +1613,8 @@ protected override void SetVisibleCore(bool value) private void MakeVisibleWithShow() { - ContainerControl container = ContainingControl; - Control control = container?.ActiveControl; + ContainerControl? container = ContainingControl; + Control? control = container?.ActiveControl; try { DoVerb((int)OLEIVERB.OLEIVERB_SHOW); @@ -1669,7 +1642,6 @@ private void HideAxControl() DoVerb((int)OLEIVERB.OLEIVERB_HIDE); if (GetOcState() < OC_INPLACE) { - s_axHTraceSwitch.TraceVerbose("Naughty control inplace deactivated on a hide verb..."); Debug.Assert(!IsHandleCreated, "if we are inplace deactivated we should not have a window."); // Set a flag saying that we need the window to be created if create handle is ever called. @@ -1709,8 +1681,6 @@ private void HideAxControl() /// public override unsafe bool PreProcessMessage(ref Message msg) { - s_controlKeyboardRouting.TraceVerbose($"AxHost.PreProcessMessage {msg}"); - if (!IsUserMode()) { return false; @@ -1749,7 +1719,6 @@ public override unsafe bool PreProcessMessage(ref Message msg) if (hr == HRESULT.S_OK) { - s_controlKeyboardRouting.TraceVerbose($"\t Message translated by control to {msg}"); return true; } else if (hr == HRESULT.S_FALSE) @@ -1764,17 +1733,9 @@ public override unsafe bool PreProcessMessage(ref Message msg) _ignoreDialogKeys = false; } } - else if (_axState[s_siteProcessedInputKey]) - { - s_controlKeyboardRouting.TraceVerbose( - $"\t Message processed by site. Calling base.PreProcessMessage() {msg}"); - return base.PreProcessMessage(ref msg); - } else { - s_controlKeyboardRouting.TraceVerbose( - $"\t Message not processed by site. Returning false. {msg}"); - return false; + return _axState[s_siteProcessedInputKey] ? base.PreProcessMessage(ref msg) : false; } } finally @@ -1789,7 +1750,6 @@ public override unsafe bool PreProcessMessage(ref Message msg) /// protected internal override unsafe bool ProcessMnemonic(char charCode) { - s_controlKeyboardRouting.TraceVerbose($"In AxHost.ProcessMnemonic: {(int)charCode}"); if (!CanSelect) { return false; @@ -1826,7 +1786,6 @@ protected internal override unsafe bool ProcessMnemonic(char charCode) if (PInvoke.IsAccelerator(new HandleRef(this, ctlInfo.hAccel), ctlInfo.cAccel, &msg, lpwCmd: null)) { oleControl.Value->OnMnemonic(&msg).AssertSuccess(); - s_controlKeyboardRouting.TraceVerbose($"\t Processed mnemonic {msg}"); try { @@ -1872,7 +1831,7 @@ protected void SetAboutBoxDelegate(AboutBoxDelegate d) [RefreshProperties(RefreshProperties.All)] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Advanced)] - public State OcxState + public State? OcxState { get { @@ -1893,7 +1852,7 @@ public State OcxState return; } - if (_storageType != STG_UNKNOWN && _storageType != value.Type) + if (_storageType != StorageType.Unknown && _storageType != value.Type) { Debug.Fail("Trying to reload with a OcxState that is of a different type."); throw new InvalidOperationException(SR.AXOcxStateLoaded); @@ -1924,7 +1883,7 @@ public State OcxState } } - private State CreateNewOcxState(State oldOcxState) + private State? CreateNewOcxState(State? oldOcxState) { NoComponentChangeEvents++; @@ -1935,59 +1894,53 @@ private State CreateNewOcxState(State oldOcxState) return null; } - PropertyBagStream propBag = null; - - if (_iPersistPropBag is not null) - { - propBag = new PropertyBagStream(); - using var propertyBag = ComHelpers.GetComScope(propBag); - _iPersistPropBag.Save(propertyBag, fClearDirty: true, fSaveAllProperties: true); - } - - MemoryStream ms = null; + PropertyBagStream? propBag = null; + MemoryStream? ms = null; switch (_storageType) { - case STG_STREAM: - case STG_STREAMINIT: + case StorageType.Stream: + case StorageType.StreamInit: ms = new MemoryStream(); using (var stream = ComHelpers.GetComScope(new Interop.Ole32.GPStream(ms))) { - if (_storageType == STG_STREAM) + if (_storageType == StorageType.Stream) { - _iPersistStream.Save(stream, true); + using var persistStream = ComHelpers.GetComScope(_instance); + persistStream.Value->Save(stream, fClearDirty: true).AssertSuccess(); } else { - _iPersistStreamInit.Save(stream, true); + using var persistStreamInit = ComHelpers.GetComScope(_instance); + persistStreamInit.Value->Save(stream, fClearDirty: true).AssertSuccess(); } } - break; - case STG_STORAGE: + return new State(ms, _storageType, this); + case StorageType.Storage: Debug.Assert(oldOcxState is not null, "we got to have an old state which holds out scribble storage..."); if (oldOcxState is not null) { - return oldOcxState.RefreshStorage(_iPersistStorage); + using var persistStorage = ComHelpers.GetComScope(_instance); + return oldOcxState.RefreshStorage(persistStorage); } return null; + case StorageType.PropertyBag: + propBag = new PropertyBagStream(); + using (var propertyBag = ComHelpers.GetComScope(propBag)) + using (var persistPropBag = ComHelpers.GetComScope(_instance)) + { + persistPropBag.Value->Save(propertyBag, fClearDirty: true, fSaveAllProperties: true).AssertSuccess(); + } + + return new State(propBag); default: Debug.Fail("unknown storage type."); return null; } - - if (ms is not null) - { - return new State(ms, _storageType, this, propBag); - } - else if (propBag is not null) - { - return new State(propBag); - } } - catch (Exception e) + catch (Exception) { - s_axHTraceSwitch.TraceVerbose($"Could not create new OCX State: {e}"); } finally { @@ -2024,7 +1977,7 @@ private State CreateNewOcxState(State oldOcxState) [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Advanced)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ContainerControl ContainingControl + public ContainerControl? ContainingControl { get => _containingControl ??= FindContainerControlInternal(); set => _containingControl = value; @@ -2053,14 +2006,14 @@ internal override bool ShouldSerializeText() [EditorBrowsable(EditorBrowsableState.Never)] private bool ShouldSerializeContainingControl() => ContainingControl != ParentInternal; - private ContainerControl FindContainerControlInternal() + private ContainerControl? FindContainerControlInternal() { - if (Site.TryGetService(out IDesignerHost host) && host.RootComponent is ContainerControl rootControl) + if (Site.TryGetService(out IDesignerHost? host) && host.RootComponent is ContainerControl rootControl) { return rootControl; } - Control control = this; + Control? control = this; while (control is not null) { if (control is ContainerControl containerControl) @@ -2081,7 +2034,7 @@ private bool IsDirty() return false; } - Debug.Assert(_storageType != STG_UNKNOWN, "if we are loaded, out storage type must be set!"); + Debug.Assert(_storageType != StorageType.Unknown, "if we are loaded, out storage type must be set!"); if (_axState[s_valueChanged]) { @@ -2098,14 +2051,26 @@ private bool IsDirty() HRESULT hr = HRESULT.E_FAIL; switch (_storageType) { - case STG_STREAM: - hr = _iPersistStream.IsDirty(); + case StorageType.Stream: + using (var persistStream = ComHelpers.GetComScope(_instance)) + { + hr = persistStream.Value->IsDirty(); + } + break; - case STG_STREAMINIT: - hr = _iPersistStreamInit.IsDirty(); + case StorageType.StreamInit: + using (var persistStreamInit = ComHelpers.GetComScope(_instance)) + { + hr = persistStreamInit.Value->IsDirty(); + } + break; - case STG_STORAGE: - hr = _iPersistStorage.IsDirty(); + case StorageType.Storage: + using (var persistStorage = ComHelpers.GetComScope(_instance)) + { + hr = persistStorage.Value->IsDirty(); + } + break; default: Debug.Fail("unknown storage type"); @@ -2125,33 +2090,27 @@ private bool IsDirty() internal bool IsUserMode() { - ISite site = Site; + ISite? site = Site; return site is null || !site.DesignMode; } - private object GetAmbientProperty(int dispid) + private object? GetAmbientProperty(int dispid) { - Control richParent = ParentInternal; + Control? richParent = ParentInternal; switch (dispid) { case PInvoke.DISPID_AMBIENT_USERMODE: - s_axHTraceSwitch.TraceVerbose("asked for usermode"); return IsUserMode(); case PInvoke.DISPID_AMBIENT_AUTOCLIP: - s_axHTraceSwitch.TraceVerbose("asked for autoclip"); return true; case PInvoke.DISPID_AMBIENT_MESSAGEREFLECT: - s_axHTraceSwitch.TraceVerbose("asked for message reflect"); return true; case PInvoke.DISPID_AMBIENT_UIDEAD: - s_axHTraceSwitch.TraceVerbose("asked for uidead"); return false; case PInvoke.DISPID_AMBIENT_DISPLAYASDEFAULT: - s_axHTraceSwitch.TraceVerbose("asked for displayasdefault"); return false; case PInvoke.DISPID_AMBIENT_FONT: - s_axHTraceSwitch.TraceVerbose("asked for font"); if (richParent is not null) { return GetIFontFromFont(richParent.Font); @@ -2159,10 +2118,8 @@ private object GetAmbientProperty(int dispid) return null; case PInvoke.DISPID_AMBIENT_SHOWGRABHANDLES: - s_axHTraceSwitch.TraceVerbose("asked for showGrabHandles"); return false; case PInvoke.DISPID_AMBIENT_SHOWHATCHING: - s_axHTraceSwitch.TraceVerbose("asked for showHatching"); return false; case PInvoke.DISPID_AMBIENT_BACKCOLOR: if (richParent is not null) @@ -2181,11 +2138,9 @@ private object GetAmbientProperty(int dispid) case PInvoke.DISPID_AMBIENT_DISPLAYNAME: return AxContainer.GetNameForControl(this) ?? string.Empty; case PInvoke.DISPID_AMBIENT_LOCALEID: - s_axHTraceSwitch.TraceVerbose("asked for localeid"); return PInvoke.GetThreadLocale(); case PInvoke.DISPID_AMBIENT_RIGHTTOLEFT: - s_axHTraceSwitch.TraceVerbose("asked for right to left"); - Control control = this; + Control? control = this; while (control is not null) { if (control.RightToLeft == Forms.RightToLeft.No) @@ -2206,17 +2161,16 @@ private object GetAmbientProperty(int dispid) return null; default: - s_axHTraceSwitch.TraceVerbose($"unsupported ambient {dispid}"); return null; } } public unsafe void DoVerb(int verb) { - Control parent = ParentInternal; + Control? parent = ParentInternal; RECT posRect = Bounds; using var pClientSite = ComHelpers.TryGetComScope(_oleSite, out HRESULT hr); - Debug.Assert(hr.Succeeded); + hr.AssertSuccess(); using var oleObject = GetComScope(); oleObject.Value->DoVerb( verb, @@ -2231,8 +2185,6 @@ public unsafe void DoVerb(int verb) private void FreezeEvents(bool freeze) { - s_axHTraceSwitch.TraceVerbose($"freezing {freeze}"); - using var oleControl = GetComScope(); if (freeze) @@ -2251,7 +2203,6 @@ private void FreezeEvents(bool freeze) private HRESULT UiDeactivate() { - s_axHTraceSwitch.TraceVerbose($"calling uiDeactivate for {ToString()}"); bool ownDispose = _axState[s_ownDisposing]; _axState[s_ownDisposing] = true; try @@ -2275,12 +2226,12 @@ private void SetOcState(int nv) _ocState = nv; } - private string GetLicenseKey() + private string? GetLicenseKey() { return GetLicenseKey(_clsid); } - private unsafe string GetLicenseKey(Guid clsid) + private unsafe string? GetLicenseKey(Guid clsid) { if (_licenseKey is not null || !_axState[s_needLicenseKey]) { @@ -2307,7 +2258,7 @@ private unsafe string GetLicenseKey(Guid clsid) return null; } - var licInfo = new LICINFO + LICINFO licInfo = new() { cbLicInfo = sizeof(LICINFO) }; @@ -2326,7 +2277,6 @@ private unsafe string GetLicenseKey(Guid clsid) private void CreateWithoutLicense(Guid clsid) { - s_axHTraceSwitch.TraceVerbose($"Creating object without license: {clsid}"); IUnknown* unknown; HRESULT hr = PInvoke.CoCreateInstance( &clsid, @@ -2336,16 +2286,13 @@ private void CreateWithoutLicense(Guid clsid) (void**)&unknown); hr.ThrowOnFailure(); - _instance = Marshal.GetObjectForIUnknown((nint)unknown); - s_axHTraceSwitch.TraceVerbose($"\t{(_instance is not null)}"); + _instance = ComHelpers.GetObjectForIUnknown(unknown); } - private void CreateWithLicense(string license, Guid clsid) + private void CreateWithLicense(string? license, Guid clsid) { if (license is not null) { - s_axHTraceSwitch.TraceVerbose($"Creating object with license: {clsid}"); - using ComScope factory = new(null); HRESULT hr = PInvoke.CoGetClassObject( @@ -2361,8 +2308,7 @@ private void CreateWithLicense(string license, Guid clsid) hr = factory.Value->CreateInstanceLic(null, null, IID.Get(), new BSTR(license), (void**)&unknown); hr.ThrowOnFailure(); - _instance = Marshal.GetObjectForIUnknown((nint)unknown); - s_axHTraceSwitch.TraceVerbose($"\t{(_instance is not null)}"); + _instance = ComHelpers.GetObjectForIUnknown(unknown); } } @@ -2391,7 +2337,6 @@ private void CreateInstance() throw; } - s_axHTraceSwitch.TraceVerbose("created"); SetOcState(OC_LOADED); } @@ -2399,7 +2344,7 @@ private void CreateInstance() /// Called to create the ActiveX control. Override this member to perform your own creation logic /// or call base to do the default creation logic. /// - protected virtual object CreateInstanceCore(Guid clsid) + protected virtual object? CreateInstanceCore(Guid clsid) { if (IsUserMode()) { @@ -2413,7 +2358,7 @@ protected virtual object CreateInstanceCore(Guid clsid) return _instance; } - private unsafe CategoryAttribute GetCategoryForDispid(int dispid) + private unsafe CategoryAttribute? GetCategoryForDispid(int dispid) { using var categorizeProperties = ComHelpers.TryGetComScope(_instance, out HRESULT hr); if (hr.Failed) @@ -2434,7 +2379,7 @@ private unsafe CategoryAttribute GetCategoryForDispid(int dispid) return s_categoryNames[index]; } - if (_objectDefinedCategoryNames?.TryGetValue(propcat, out CategoryAttribute category) ?? false + if (_objectDefinedCategoryNames?.TryGetValue(propcat, out CategoryAttribute? category) ?? false && category is not null) { return category; @@ -2464,7 +2409,7 @@ private void SetSelectionStyle(int selectionStyle) Debug.Assert(selectionStyle is >= 0 and <= 2, "Invalid selection style"); _selectionStyle = selectionStyle; - if (Site.TryGetService(out ISelectionService selectionService) && selectionService.GetComponentSelected(this)) + if (Site.TryGetService(out ISelectionService? selectionService) && selectionService.GetComponentSelected(this)) { // The AX Host designer will offer an extender property called "SelectionStyle" if (TypeDescriptor.GetProperties(this)["SelectionStyle"] is { } property && property.PropertyType == typeof(int)) @@ -2477,7 +2422,6 @@ private void SetSelectionStyle(int selectionStyle) [EditorBrowsable(EditorBrowsableState.Advanced)] public void InvokeEditMode() { - s_axHTraceSwitch.TraceVerbose($"invoking EditMode for {ToString()}"); Debug.Assert((_flags & AxFlags.PreventEditMode) == 0, "edit mode should have been disabled"); if (_editMode != EDITM_NONE) { @@ -2496,7 +2440,7 @@ public void InvokeEditMode() { } } - +#nullable disable // // ICustomTypeDescriptor implementation. // @@ -2633,7 +2577,6 @@ private PropertyDescriptorCollection FillProperties(Attribute[] attributes) { if (attributes is null && _attribsStash is null) { - s_axHTraceSwitch.TraceVerbose("Returning stashed values for : "); return _propsStash; } else if (attributes is not null && _attribsStash is not null && attributes.Length == _attribsStash.Length) @@ -2651,7 +2594,6 @@ private PropertyDescriptorCollection FillProperties(Attribute[] attributes) if (attribsEqual) { - s_axHTraceSwitch.TraceVerbose($"Returning stashed values for : {attributes.Length}"); return _propsStash; } } @@ -2700,13 +2642,11 @@ private PropertyDescriptorCollection FillProperties(Attribute[] attributes) { if (propInfo is not null) { - s_axPropTraceSwitch.TraceVerbose($"Added AxPropertyDescriptor for: {propName}"); prop = new AxPropertyDescriptor(baseProps[i], this); ((AxPropertyDescriptor)prop).UpdateAttributes(); } else { - s_axPropTraceSwitch.TraceVerbose($"Added PropertyDescriptor for: {propName}"); prop = baseProps[i]; } @@ -2721,7 +2661,6 @@ private PropertyDescriptorCollection FillProperties(Attribute[] attributes) if ((propInfo is null && axPropDesc is not null) || (propInfo is not null && axPropDesc is null)) { Debug.Fail($"Duplicate property with same name: {propName}"); - s_axPropTraceSwitch.TraceVerbose($"Duplicate property with same name: {propName}"); } else { @@ -2771,7 +2710,6 @@ private PropertyDescriptorCollection FillProperties(Attribute[] attributes) } // Update our stashed values. - s_axHTraceSwitch.TraceVerbose($"Updating stashed values for : {attributes?.Length.ToString() ?? ""}"); _propsStash = new PropertyDescriptorCollection(returnProperties.ToArray()); _attribsStash = attributes; @@ -2828,41 +2766,6 @@ private void ActivateAxControl() SetOcState(OC_RUNNING); } - private void DepersistFromIPropertyBag(IPropertyBag.Interface propBag) - { - using var pPropBag = ComHelpers.TryGetComScope(propBag, out HRESULT hr); - Debug.Assert(hr.Succeeded); - _iPersistPropBag.Load(pPropBag, pErrorLog: null).ThrowOnFailure(); - } - - private void DepersistFromIStream(IStream.Interface istream) - { - _storageType = STG_STREAM; - using var pStream = ComHelpers.TryGetComScope(istream, out HRESULT hr); - Debug.Assert(hr.Succeeded); - _iPersistStream.Load(pStream).ThrowOnFailure(); - } - - private void DepersistFromIStreamInit(IStream.Interface istream) - { - _storageType = STG_STREAMINIT; - using var pStream = ComHelpers.TryGetComScope(istream, out HRESULT hr); - Debug.Assert(hr.Succeeded); - _iPersistStreamInit.Load(pStream).ThrowOnFailure(); - } - - private void DepersistFromIStorage(IStorage* storage) - { - _storageType = STG_STORAGE; - - // MapPoint control does not create a valid IStorage until some property has changed. - // Since we end up creating an empty storage, we are not able to re-create a valid one and this would fail. - if (storage is not null) - { - _iPersistStorage.Load(storage).ThrowOnFailure(); - } - } - private void DepersistControl() { FreezeEvents(true); @@ -2870,53 +2773,36 @@ private void DepersistControl() if (_ocxState is null) { // Must init new: - if (_instance is IPersistStreamInit.Interface init) + using var persistStreamInit = ComHelpers.TryGetComScope(_instance, out HRESULT hr); + if (hr.Succeeded) { - _iPersistStreamInit = init; - _storageType = STG_STREAMINIT; - HRESULT hr = _iPersistStreamInit.InitNew(); - if (hr.Failed) - { - s_axHTraceSwitch.TraceVerbose( - $"Failure trying to IPersistStreamInit.InitNew(). Is this good? {hr}"); - } - + _storageType = StorageType.StreamInit; + persistStreamInit.Value->InitNew().AssertSuccess(); return; } - if (_instance is IPersistStream.Interface persistStream) + if (ComHelpers.SupportsInterface(_instance)) { - _storageType = STG_STREAM; - _iPersistStream = persistStream; + _storageType = StorageType.Stream; return; } - if (_instance is IPersistStorage.Interface persistStorage) + using var persistStoragePtr = ComHelpers.TryGetComScope(_instance, out hr); + if (hr.Succeeded) { - _storageType = STG_STORAGE; + _storageType = StorageType.Storage; _ocxState = new State(this); - _iPersistStorage = persistStorage; using var storage = _ocxState.GetStorage(); - HRESULT hr = _iPersistStorage.InitNew(storage); - if (hr.Failed) - { - s_axHTraceSwitch.TraceVerbose( - $"Failure trying to IPersistStorage.InitNew(). Is this good? {hr}"); - } - + persistStoragePtr.Value->InitNew(storage).AssertSuccess(); return; } - if (_instance is IPersistPropertyBag.Interface persistPropertyBag) + using var persistPropBag = ComHelpers.TryGetComScope(_instance, out hr); + if (hr.Succeeded) { - s_axHTraceSwitch.TraceVerbose($"{this} supports IPersistPropertyBag."); - _iPersistPropBag = persistPropertyBag; - HRESULT hr = _iPersistPropBag.InitNew(); - if (hr.Failed) - { - s_axHTraceSwitch.TraceVerbose( - $"Exception thrown trying to IPersistPropertyBag.InitNew(). Is this good? {hr}"); - } + _storageType = StorageType.PropertyBag; + persistPropBag.Value->InitNew().AssertSuccess(); + return; } Debug.Fail("no implemented persistence interfaces on object"); @@ -2926,54 +2812,62 @@ private void DepersistControl() // Otherwise, we have state to depersist from: switch (_ocxState.Type) { - case STG_STREAM: - try - { - _iPersistStream = (IPersistStream.Interface)_instance; - DepersistFromIStream(_ocxState.GetStream()); - } - catch (Exception e) + case StorageType.Stream: + using (var stream = _ocxState.GetStream()) { - s_axHTraceSwitch.TraceVerbose( - $"Exception thrown trying to IPersistStream.DepersistFromIStream(). Is this good? {e}"); + _storageType = StorageType.Stream; + using var persistStream = ComHelpers.GetComScope(_instance); + persistStream.Value->Load(stream).AssertSuccess(); } break; - case STG_STREAMINIT: - if (_instance is IPersistStreamInit.Interface persistStreamInit) + case StorageType.StreamInit: + using (var persistStreamInit = ComHelpers.TryGetComScope(_instance, out HRESULT hr)) { - try + if (hr.Succeeded) { - _iPersistStreamInit = persistStreamInit; - DepersistFromIStreamInit(_ocxState.GetStream()); + using (var stream = _ocxState.GetStream()) + { + _storageType = StorageType.StreamInit; + persistStreamInit.Value->Load(stream).AssertSuccess(); + } + + GetControlEnabled(); } - catch (Exception e) + else { - s_axHTraceSwitch.TraceVerbose( - $"Exception thrown trying to IPersistStreamInit.DepersistFromIStreamInit(). Is this good? {e}"); + _ocxState.Type = StorageType.Stream; + DepersistControl(); + return; } - - GetControlEnabled(); - } - else - { - _ocxState.Type = STG_STREAM; - DepersistControl(); - return; } break; - case STG_STORAGE: - try + case StorageType.Storage: + using (var storage = _ocxState.GetStorage()) { - _iPersistStorage = (IPersistStorage.Interface)_instance; - using var storage = _ocxState.GetStorage(); - DepersistFromIStorage(storage); + _storageType = StorageType.Storage; + + // MapPoint control does not create a valid IStorage until some property has changed. + // Since we end up creating an empty storage, we are not able to re-create a valid one and this would fail. + if (!storage.IsNull) + { + using var persistStorage = ComHelpers.GetComScope(_instance); + persistStorage.Value->Load(storage).AssertSuccess(); + } } - catch (Exception e) + + break; + case StorageType.PropertyBag: + using (var propBag = _ocxState.GetPropBag()) { - s_axHTraceSwitch.TraceVerbose( - $"Exception thrown trying to IPersistStorage.DepersistFromIStorage(). Is this good? {e}"); + _storageType = StorageType.PropertyBag; + + if (!propBag.IsNull) + { + using var persistPropBag = ComHelpers.GetComScope(_instance); + persistPropBag.Value->Load(propBag, pErrorLog: null).AssertSuccess(); + } } break; @@ -2981,20 +2875,6 @@ private void DepersistControl() Debug.Fail("unknown storage type."); throw new InvalidOperationException(SR.UnableToInitComponent); } - - if (_ocxState.GetPropBag() is not null) - { - try - { - _iPersistPropBag = (IPersistPropertyBag.Interface)_instance; - DepersistFromIPropertyBag(_ocxState.GetPropBag()); - } - catch (Exception e) - { - s_axHTraceSwitch.TraceVerbose( - $"Exception thrown trying to IPersistPropertyBag.DepersistFromIPropertyBag(). Is this good? {e}"); - } - } } /// @@ -3025,7 +2905,6 @@ private void StartEvents() { try { - s_axHTraceSwitch.TraceVerbose("Creating sink for events..."); CreateSink(); _oleSite.StartEvents(); } @@ -3130,8 +3009,7 @@ private unsafe void ShowPropertyPageForDispid(int dispid, Guid guid) dispidInitialProperty = dispid }; - hr = PInvoke.OleCreatePropertyFrameIndirect(¶meters); - Debug.Assert(hr.Succeeded); + PInvoke.OleCreatePropertyFrameIndirect(¶meters).AssertSuccess(); } } @@ -3178,7 +3056,7 @@ public unsafe void ShowPropertyPages(Control control) HWND handle = ContainingControl is null ? HWND.Null : ContainingControl.HWND; IUnknown* unknown = ComHelpers.GetComPointer(_instance); - hr = PInvoke.OleCreatePropertyFrame( + PInvoke.OleCreatePropertyFrame( handle, 0, 0, @@ -3189,7 +3067,7 @@ public unsafe void ShowPropertyPages(Control control) uuids.pElems, PInvoke.GetThreadLocale(), 0, - (void*)null); + (void*)null).AssertSuccess(); } finally { @@ -3283,13 +3161,6 @@ protected override unsafe void WndProc(ref Message m) break; case PInvoke.WM_DESTROY: -#if DEBUG - if (!OwnWindow()) - { - s_axHTraceSwitch.TraceVerbose( - $"WM_DESTROY control is destroying the window from under us... {GetType()}"); - } -#endif // If we are currently in a state of InPlaceActive or above, we should first reparent the ActiveX // control to our parking window before we transition to a state below InPlaceActive. Otherwise we // face all sorts of problems when we try to transition back to a state >= InPlaceActive. @@ -3345,13 +3216,6 @@ protected override unsafe void WndProc(ref Message m) break; case PInvoke.WM_NCDESTROY: -#if DEBUG - if (!OwnWindow()) - { - s_axHTraceSwitch.TraceVerbose( - $"WM_NCDESTROY control is destroying the window from under us...{GetType()}"); - } -#endif // Need to detach it now. DetachAndForward(ref m); break; @@ -3403,7 +3267,6 @@ private void InformOfNewHandle() private void AttachWindow(HWND hwnd) { - s_axHTraceSwitch.TraceVerbose($"attaching window for {ToString()} {hwnd}"); if (!_axState[s_fFakingWindow]) { WindowAssignHandle(hwnd, _axState[s_assignUniqueID]); @@ -3413,12 +3276,10 @@ private void AttachWindow(HWND hwnd) // Get the latest bounds set by the user. Size setExtent = Size; - s_axHTraceSwitch.TraceVerbose($"SetBounds {setExtent}"); // Get the default bounds set by the ActiveX control. UpdateBounds(); Size ocxExtent = GetExtent(); - s_axHTraceSwitch.TraceVerbose($"OcxBounds {ocxExtent}"); Point location = Location; @@ -3520,7 +3381,6 @@ private unsafe bool QuickActivate() HRESULT hr = iqa.QuickActivate(&qaContainer, &qaControl); if (!hr.Succeeded) { - s_axHTraceSwitch.TraceVerbose($"Failed to QuickActivate: {hr}"); DisposeAxControl(); return false; } @@ -3607,10 +3467,7 @@ private void ReleaseAxControl() { Marshal.ReleaseComObject(_instance); _instance = null; - _iOleInPlaceActiveObjectExternal = null; - _iPersistStream = null; - _iPersistStreamInit = null; - _iPersistStorage = null; + DisposeHelper.NullAndDispose(ref _iOleInPlaceActiveObjectExternal); } _axState[s_disposed] = true; @@ -3681,7 +3538,6 @@ private AxContainer GetParentContainer() } else { - s_axHTraceSwitch.TraceVerbose($"calling upon {container} to create a container"); _container = container.CreateAxContainer(); _container.AddControl(this); _containingControl = container; @@ -3784,7 +3640,7 @@ private static FONTDESC GetFONTDESCFromFont(Font font) } LOGFONTW logfont = LOGFONTW.FromFont(font); - var fdesc = new FONTDESC + FONTDESC fdesc = new() { cbSizeofstruct = (uint)sizeof(FONTDESC), cySize = (CY)font.SizeInPoints, @@ -3833,7 +3689,7 @@ protected static object GetIFontFromFont(Font font) try { - return Marshal.GetObjectForIUnknown((nint)ifont); + return ComHelpers.GetObjectForIUnknown((IUnknown*)ifont); } catch { @@ -3865,7 +3721,6 @@ protected static object GetIFontFromFont(Font font) } } - s_axHTraceSwitch.TraceVerbose($"Failed to create IFrom from font: {font}"); return null; } @@ -3888,9 +3743,8 @@ protected static Font GetFontFromIFont(object font) ? f : new(f.Name, f.SizeInPoints, f.Style, GraphicsUnit.Point, f.GdiCharSet, f.GdiVerticalFont); } - catch (Exception e) + catch (Exception) { - s_axHTraceSwitch.TraceVerbose($"Could not create font. {e.Message}"); return DefaultFont; } } @@ -3916,7 +3770,7 @@ protected static object GetIFontDispFromFont(Font font) FONTDESC fontdesc = GetFONTDESCFromFont(font); fontdesc.lpstrName = n; PInvoke.OleCreateFontIndirect(in fontdesc, in IID.GetRef(), out void* lplpvObj).ThrowOnFailure(); - return Marshal.GetObjectForIUnknown((nint)lplpvObj); + return ComHelpers.GetObjectForIUnknown((IUnknown*)lplpvObj); } } @@ -3977,9 +3831,8 @@ protected static Font GetFontFromIFontDisp(object font) GraphicsUnit.Point, (byte)(short)dispatch.Value->GetProperty(PInvoke.DISPID_FONT_CHARSET)); } - catch (Exception e) + catch (Exception) { - s_axHTraceSwitch.TraceVerbose($"Could not create font from IFontDisp: {e.Message}"); return DefaultFont; } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BaseCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BaseCollection.cs index 4a1c9ac6647..0745e74844e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BaseCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BaseCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BatteryChargeStatus.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BatteryChargeStatus.cs index 7c6c7768aa7..1a26f21bfe7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BatteryChargeStatus.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BatteryChargeStatus.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindableComponent.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindableComponent.cs index dc13cc4bd94..d6cac0efa5d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindableComponent.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindableComponent.cs @@ -1,9 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; -using System.Runtime.Versioning; namespace System.Windows.Forms; @@ -11,7 +9,6 @@ namespace System.Windows.Forms; /// Base class for components which provide properties which can be /// data bound with the WinForms Designer. /// -[RequiresPreviewFeatures] public abstract class BindableComponent : Component, IBindableComponent { internal static readonly object s_bindingContextChangedEvent = new(); @@ -76,6 +73,7 @@ protected virtual void OnBindingContextChanged(EventArgs e) [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] [RefreshProperties(RefreshProperties.All)] [ParenthesizePropertyName(true)] + [SRCategory(nameof(SR.CatData))] public ControlBindingsCollection DataBindings => _dataBindings ??= new ControlBindingsCollection(this); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Binding.BindToObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Binding.BindToObject.cs new file mode 100644 index 00000000000..fae5906cd05 --- /dev/null +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Binding.BindToObject.cs @@ -0,0 +1,245 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; + +namespace System.Windows.Forms; + +public partial class Binding +{ + private class BindToObject + { + private BindingManagerBase? _bindingManager; + private readonly Binding _owner; + private bool _dataSourceInitialized; + private bool _waitingOnDataSource; + + private void PropValueChanged(object? sender, EventArgs e) + { + _bindingManager?.OnCurrentChanged(EventArgs.Empty); + } + + private bool IsDataSourceInitialized + { + get + { + Debug.Assert(_owner.DataSource is not null, "how can we determine if DataSource is initialized or not if we have no data source?"); + if (_dataSourceInitialized) + { + return true; + } + + if (_owner.DataSource is not ISupportInitializeNotification ds || ds.IsInitialized) + { + _dataSourceInitialized = true; + return true; + } + + // We have an ISupportInitializeNotification which was not initialized yet. + // We already hooked up the Initialized event and the data source is not initialized yet. + if (_waitingOnDataSource) + { + return false; + } + + // Hook up the Initialized event. + ds.Initialized += new EventHandler(DataSource_Initialized); + _waitingOnDataSource = true; + return false; + } + } + + internal BindToObject(Binding owner) + { + Debug.Assert(owner is not null); + _owner = owner; + CheckBinding(); + } + + private void DataSource_Initialized(object? sender, EventArgs e) + { + Debug.Assert(sender == _owner.DataSource, "data source should not change"); + Debug.Assert(_owner.DataSource is ISupportInitializeNotification, "data source should not change on the BindToObject"); + Debug.Assert(_waitingOnDataSource); + + // Unhook the Initialized event. + if (_owner.DataSource is ISupportInitializeNotification ds) + { + ds.Initialized -= new EventHandler(DataSource_Initialized); + } + + // The wait is over: DataSource is initialized. + _waitingOnDataSource = false; + _dataSourceInitialized = true; + + // Rebind. + CheckBinding(); + } + + internal void SetBindingManagerBase(BindingManagerBase? lManager) + { + if (_bindingManager == lManager) + { + return; + } + + // remove notification from the backEnd + if (_bindingManager is not null && + FieldInfo is not null && + _bindingManager.IsBinding && + _bindingManager is not CurrencyManager) + { + FieldInfo.RemoveValueChanged(_bindingManager.Current!, new EventHandler(PropValueChanged)); + FieldInfo = null; + } + + _bindingManager = lManager; + CheckBinding(); + } + + internal string DataErrorText { get; private set; } = string.Empty; + + /// + /// Returns any data error info on the data source for the bound data field + /// in the current row + /// + private string GetErrorText(object? value) + { + if (value is not IDataErrorInfo errorInfo) + { + return string.Empty; + } + + // Get the row error if there is no DataMember + if (FieldInfo is null) + { + return errorInfo.Error ?? string.Empty; + } + + // Get the column error if there is a DataMember. + // The DataTable uses its own Locale to lookup column names . + // So passing the DataMember from the BindingField could cause problems. + // Pass the name from the PropertyDescriptor that the DataTable gave us. + // (If there is no fieldInfo, data binding would have failed already ) + return errorInfo[FieldInfo.Name] ?? string.Empty; + } + + internal object? GetValue() + { + object? obj = _bindingManager?.Current; + + // Update IDataErrorInfo text: it's ok to get this now because we're going to need + // this as part of the BindingCompleteEventArgs anyway. + DataErrorText = GetErrorText(obj); + + if (FieldInfo is not null) + { + obj = FieldInfo.GetValue(obj); + } + + return obj; + } + + internal Type? BindToType + { + get + { + if (_owner.BindingMemberInfo.BindingField.Length == 0) + { + // if we are bound to a list w/o any properties, then + // take the type from the BindingManager + Type? type = _bindingManager?.BindType; + if (typeof(Array).IsAssignableFrom(type)) + { + type = type.GetElementType(); + } + + return type; + } + + return FieldInfo?.PropertyType; + } + } + + internal void SetValue(object? value) + { + object? obj = null; + + if (FieldInfo is not null) + { + obj = _bindingManager?.Current; + if (obj is IEditableObject editableObject) + { + editableObject.BeginEdit(); + } + + if (!FieldInfo.IsReadOnly) + { + FieldInfo.SetValue(obj, value); + } + } + else + { + if (_bindingManager is CurrencyManager cm) + { + cm[cm.Position] = value; + obj = value; + } + } + + // Update IDataErrorInfo text. + DataErrorText = GetErrorText(obj); + } + + internal PropertyDescriptor? FieldInfo { get; private set; } + + internal void CheckBinding() + { + // At design time, don't check anything. + if (_owner.BindableComponent is not null && _owner.ControlAtDesignTime()) + { + return; + } + + // Remove propertyChangedNotification when this binding is deleted + if (_bindingManager is not null && + FieldInfo is not null && + _bindingManager.IsBinding && + _bindingManager is not CurrencyManager) + { + FieldInfo.RemoveValueChanged(_bindingManager.Current!, new EventHandler(PropValueChanged)); + } + + if (_bindingManager is not null && + _owner.BindableComponent is not null && + _owner.ComponentCreated && + IsDataSourceInitialized) + { + string dataField = _owner.BindingMemberInfo.BindingField; + + FieldInfo = _bindingManager.GetItemProperties().Find(dataField, true); + if (_bindingManager.DataSource is not null && FieldInfo is null && dataField.Length > 0) + { + throw new ArgumentException(string.Format(SR.ListBindingBindField, dataField), "dataMember"); + } + + // Do not add propertyChange notification if the fieldInfo is null + // + // We add an event handler to the dataSource in the BindingManagerBase because + // if the binding is of the form (Control, ControlProperty, DataSource, Property1.Property2.Property3) + // then we want to get notification from Current.Property1.Property2 and not from DataSource + // when we get the backEnd notification we push the new value into the Control's property + if (FieldInfo is not null && + _bindingManager.IsBinding && + _bindingManager is not CurrencyManager) + { + FieldInfo.AddValueChanged(_bindingManager.Current!, new EventHandler(PropValueChanged)); + } + } + else + { + FieldInfo = null; + } + } + } +} diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Binding.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Binding.cs index 0b95628a1e5..392ad563b73 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Binding.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Binding.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -13,7 +12,7 @@ namespace System.Windows.Forms; /// Represents a simple binding of a value in a list and the property of a control. /// [TypeConverter(typeof(ListBindingConverter))] -public class Binding +public partial class Binding { private BindingManagerBase _bindingManagerBase; @@ -608,11 +607,11 @@ private object ParseObject(object value) if (_formattingEnabled) { // Fire the Parse event so that user code gets a chance to supply the parsed value for us - var e = new ConvertEventArgs(value, type); + ConvertEventArgs e = new(value, type); OnParse(e); object newValue = e.Value; - if (!object.Equals(value, newValue)) + if (!Equals(value, newValue)) { // If event handler replaced formatted value with parsed value, use that return newValue; @@ -626,27 +625,36 @@ private object ParseObject(object value) fieldInfoConverter = _bindToObject.FieldInfo.Converter; } - return Formatter.ParseObject(value, type, (value is null ? _propInfo.PropertyType : value.GetType()), fieldInfoConverter, _propInfoConverter, _formatInfo, _nullValue, GetDataSourceNullValue(type)); + return Formatter.ParseObject( + value, + type, + (value is null ? _propInfo.PropertyType : value.GetType()), + fieldInfoConverter, + _propInfoConverter, + _formatInfo, + _nullValue, + GetDataSourceNullValue(type)); } } else { - var e = new ConvertEventArgs(value, type); - // first try: use the OnParse event + ConvertEventArgs e = new(value, type); + + // First try: use the OnParse event OnParse(e); if (e.Value is not null && (e.Value.GetType().IsSubclassOf(type) || e.Value.GetType() == type || e.Value is DBNull)) { return e.Value; } - // second try: use the TypeConverter + // Second try: use the TypeConverter TypeConverter typeConverter = TypeDescriptor.GetConverter(value is not null ? value.GetType() : typeof(object)); if (typeConverter is not null && typeConverter.CanConvertTo(type)) { return typeConverter.ConvertTo(value, type); } - // last try: use Convert.ToType + // Last try: use Convert.ToType if (value is IConvertible) { object ret = Convert.ChangeType(value, type, CultureInfo.CurrentCulture); @@ -674,7 +682,7 @@ private object FormatObject(object value) if (_formattingEnabled) { // Fire the Format event so that user code gets a chance to supply the formatted value for us - var e = new ConvertEventArgs(value, type); + ConvertEventArgs e = new(value, type); OnFormat(e); if (e.Value != value) @@ -697,7 +705,7 @@ private object FormatObject(object value) else { // first try: use the Format event - var e = new ConvertEventArgs(value, type); + ConvertEventArgs e = new(value, type); OnFormat(e); object ret = e.Value; @@ -1082,241 +1090,4 @@ internal void UpdateIsBinding() } } } - - private class BindToObject - { - private BindingManagerBase _bindingManager; - private readonly Binding _owner; - private bool _dataSourceInitialized; - private bool _waitingOnDataSource; - - private void PropValueChanged(object sender, EventArgs e) - { - _bindingManager?.OnCurrentChanged(EventArgs.Empty); - } - - private bool IsDataSourceInitialized - { - get - { - Debug.Assert(_owner.DataSource is not null, "how can we determine if DataSource is initialized or not if we have no data source?"); - if (_dataSourceInitialized) - { - return true; - } - - if (!(_owner.DataSource is ISupportInitializeNotification ds) || ds.IsInitialized) - { - _dataSourceInitialized = true; - return true; - } - - // We have an ISupportInitializeNotification which was not initialized yet. - // We already hooked up the Initialized event and the data source is not initialized yet. - if (_waitingOnDataSource) - { - return false; - } - - // Hook up the Initialized event. - ds.Initialized += new EventHandler(DataSource_Initialized); - _waitingOnDataSource = true; - return false; - } - } - - internal BindToObject(Binding owner) - { - Debug.Assert(owner is not null); - _owner = owner; - CheckBinding(); - } - - private void DataSource_Initialized(object sender, EventArgs e) - { - Debug.Assert(sender == _owner.DataSource, "data source should not change"); - Debug.Assert(_owner.DataSource is ISupportInitializeNotification, "data source should not change on the BindToObject"); - Debug.Assert(_waitingOnDataSource); - - // Unhook the Initialized event. - if (_owner.DataSource is ISupportInitializeNotification ds) - { - ds.Initialized -= new EventHandler(DataSource_Initialized); - } - - // The wait is over: DataSource is initialized. - _waitingOnDataSource = false; - _dataSourceInitialized = true; - - // Rebind. - CheckBinding(); - } - - internal void SetBindingManagerBase(BindingManagerBase lManager) - { - if (_bindingManager == lManager) - { - return; - } - - // remove notification from the backEnd - if (_bindingManager is not null && FieldInfo is not null && _bindingManager.IsBinding && !(_bindingManager is CurrencyManager)) - { - FieldInfo.RemoveValueChanged(_bindingManager.Current, new EventHandler(PropValueChanged)); - FieldInfo = null; - } - - _bindingManager = lManager; - CheckBinding(); - } - - internal string DataErrorText { get; private set; } = string.Empty; - - /// - /// Returns any data error info on the data source for the bound data field - /// in the current row - /// - private string GetErrorText(object value) - { - string text = string.Empty; - - if (value is IDataErrorInfo errorInfo) - { - // Get the row error if there is no DataMember - if (FieldInfo is null) - { - text = errorInfo.Error; - } - - // Get the column error if there is a DataMember. - // The DataTable uses its own Locale to lookup column names . - // So passing the DataMember from the BindingField could cause problems. - // Pass the name from the PropertyDescriptor that the DataTable gave us. - // (If there is no fieldInfo, data binding would have failed already ) - else - { - text = errorInfo[FieldInfo.Name]; - } - } - - return text ?? string.Empty; - } - - internal object GetValue() - { - object obj = _bindingManager.Current; - - // Update IDataErrorInfo text: it's ok to get this now because we're going to need - // this as part of the BindingCompleteEventArgs anyway. - DataErrorText = GetErrorText(obj); - - if (FieldInfo is not null) - { - obj = FieldInfo.GetValue(obj); - } - - return obj; - } - - internal Type BindToType - { - get - { - if (_owner.BindingMemberInfo.BindingField.Length == 0) - { - // if we are bound to a list w/o any properties, then - // take the type from the BindingManager - Type type = _bindingManager.BindType; - if (typeof(Array).IsAssignableFrom(type)) - { - type = type.GetElementType(); - } - - return type; - } - - return FieldInfo?.PropertyType; - } - } - - internal void SetValue(object value) - { - object obj = null; - - if (FieldInfo is not null) - { - obj = _bindingManager.Current; - if (obj is IEditableObject editableObject) - { - editableObject.BeginEdit(); - } - - if (!FieldInfo.IsReadOnly) - { - FieldInfo.SetValue(obj, value); - } - } - else - { - if (_bindingManager is CurrencyManager cm) - { - cm[cm.Position] = value; - obj = value; - } - } - - // Update IDataErrorInfo text. - DataErrorText = GetErrorText(obj); - } - - internal PropertyDescriptor FieldInfo { get; private set; } - - internal void CheckBinding() - { - // At design time, don't check anything. - if (_owner.BindableComponent is not null && _owner.ControlAtDesignTime()) - { - return; - } - - // Remove propertyChangedNotification when this binding is deleted - if (_bindingManager is not null && - FieldInfo is not null && - _bindingManager.IsBinding && - !(_bindingManager is CurrencyManager)) - { - FieldInfo.RemoveValueChanged(_bindingManager.Current, new EventHandler(PropValueChanged)); - } - - if (_bindingManager is not null && - _owner.BindableComponent is not null && - _owner.ComponentCreated && - IsDataSourceInitialized) - { - string dataField = _owner.BindingMemberInfo.BindingField; - - FieldInfo = _bindingManager.GetItemProperties().Find(dataField, true); - if (_bindingManager.DataSource is not null && FieldInfo is null && dataField.Length > 0) - { - throw new ArgumentException(string.Format(SR.ListBindingBindField, dataField), "dataMember"); - } - - // Do not add propertyChange notification if the fieldInfo is null - // - // We add an event handler to the dataSource in the BindingManagerBase because - // if the binding is of the form (Control, ControlProperty, DataSource, Property1.Property2.Property3) - // then we want to get notification from Current.Property1.Property2 and not from DataSource - // when we get the backEnd notification we push the new value into the Control's property - if (FieldInfo is not null && _bindingManager.IsBinding && - !(_bindingManager is CurrencyManager)) - { - FieldInfo.AddValueChanged(_bindingManager.Current, new EventHandler(PropValueChanged)); - } - } - else - { - FieldInfo = null; - } - } - } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteContext.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteContext.cs index 5ca24a3485e..e53c61265ca 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteContext.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteEventArgs.cs index 7d557a90709..5616f239f69 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteEventHandler.cs index ccf0857164c..32d4271307a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteState.cs index 26a34cf72b5..2f586a7a2e1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindingCompleteState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindingContext.HashKey.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindingContext.HashKey.cs index f86671573eb..0ff4467e25a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindingContext.HashKey.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindingContext.HashKey.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindingContext.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindingContext.cs index 02cf2a7cf32..04ae1e3a8fd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindingContext.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindingContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindingManagerBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindingManagerBase.cs index 0fc486214e2..9ccaccd1347 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindingManagerBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindingManagerBase.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindingManagerDataErrorEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindingManagerDataErrorEventArgs.cs index bed9be60d54..32e4bf0737d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindingManagerDataErrorEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindingManagerDataErrorEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindingManagerDataErrorEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindingManagerDataErrorEventHandler.cs index d3a9780b317..b589dbd6f70 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindingManagerDataErrorEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindingManagerDataErrorEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindingMemberInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindingMemberInfo.cs index 0ca3cab3df3..430e399f583 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindingMemberInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindingMemberInfo.cs @@ -1,10 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; -public struct BindingMemberInfo : IEquatable +public readonly struct BindingMemberInfo : IEquatable { private readonly string? _dataList; private readonly string? _dataField; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindingNavigator.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindingNavigator.cs index 6622fd134d5..7286bff0dc6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindingNavigator.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindingNavigator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindingSource.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindingSource.cs index eeafd8f7017..f60fc4f1cc0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindingSource.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindingSource.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -26,16 +25,16 @@ public class BindingSource : Component, ICurrencyManagerProvider { // Public events - private static readonly object s_eventAddingNew = new object(); - private static readonly object s_eventBindingComplete = new object(); - private static readonly object s_eventCurrentChanged = new object(); - private static readonly object s_eventCurrentItemChanged = new object(); - private static readonly object s_eventDataError = new object(); - private static readonly object s_eventDataMemberChanged = new object(); - private static readonly object s_eventDataSourceChanged = new object(); - private static readonly object s_eventListChanged = new object(); - private static readonly object s_eventPositionChanged = new object(); - private static readonly object s_eventInitialized = new object(); + private static readonly object s_eventAddingNew = new(); + private static readonly object s_eventBindingComplete = new(); + private static readonly object s_eventCurrentChanged = new(); + private static readonly object s_eventCurrentItemChanged = new(); + private static readonly object s_eventDataError = new(); + private static readonly object s_eventDataMemberChanged = new(); + private static readonly object s_eventDataSourceChanged = new(); + private static readonly object s_eventListChanged = new(); + private static readonly object s_eventPositionChanged = new(); + private static readonly object s_eventInitialized = new(); // Public property values private object _dataSource; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindingsCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindingsCollection.cs index d6fc1dbe789..157e0e72b2e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindingsCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindingsCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -35,7 +34,7 @@ internal BindingsCollection() protected internal void Add(Binding binding) { - var eventArgs = new CollectionChangeEventArgs(CollectionChangeAction.Add, binding); + CollectionChangeEventArgs eventArgs = new(CollectionChangeAction.Add, binding); OnCollectionChanging(eventArgs); AddCore(binding); OnCollectionChanged(eventArgs); @@ -72,7 +71,7 @@ public event CollectionChangeEventHandler? CollectionChanged protected internal void Clear() { - var eventArgs = new CollectionChangeEventArgs(CollectionChangeAction.Refresh, null); + CollectionChangeEventArgs eventArgs = new(CollectionChangeAction.Refresh, null); OnCollectionChanging(eventArgs); ClearCore(); OnCollectionChanged(eventArgs); @@ -101,7 +100,7 @@ protected virtual void OnCollectionChanged(CollectionChangeEventArgs ccevent) protected internal void Remove(Binding binding) { - var eventArgs = new CollectionChangeEventArgs(CollectionChangeAction.Remove, binding); + CollectionChangeEventArgs eventArgs = new(CollectionChangeAction.Remove, binding); OnCollectionChanging(eventArgs); RemoveCore(binding); OnCollectionChanged(eventArgs); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BootMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BootMode.cs index 330a238da4c..a11dbb40cc4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BootMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BootMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Border3DSide.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Border3DSide.cs index 8ef3899ff29..98d2333a2d6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Border3DSide.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Border3DSide.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Border3DStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Border3DStyle.cs index 0659e32fbdf..66955674acb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Border3DStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Border3DStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BorderStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BorderStyle.cs index 8ebe788a55a..6c900060e00 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BorderStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BorderStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BoundsSpecified.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BoundsSpecified.cs index bdb931832e0..8cce402278d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BoundsSpecified.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BoundsSpecified.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Button.ButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Button.ButtonAccessibleObject.cs index a286f407d95..02f90ab1390 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Button.ButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Button.ButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.UiaCore; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Button.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Button.cs index fae62a4bb37..982f7d9f59e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Button.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Button.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -30,7 +29,7 @@ public partial class Button : ButtonBase, IButtonControl /// For buttons whose FlatStyle = FlatStyle.Flat, this property specifies the size, in pixels /// of the border around the button. /// - private Size _systemSize = new Size(InvalidDimensionValue, InvalidDimensionValue); + private Size _systemSize = new(InvalidDimensionValue, InvalidDimensionValue); /// /// Initializes a new instance of the diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBase.ButtonBaseAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBase.ButtonBaseAccessibleObject.cs index ec189200405..47e8f516afd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBase.ButtonBaseAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBase.ButtonBaseAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBase.cs index 0ef98736b40..ed461e3634b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBase.cs @@ -1,11 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; using System.Drawing.Design; -using System.Runtime.Versioning; using System.Windows.Forms.ButtonInternal; using System.Windows.Forms.Layout; using static Interop; @@ -22,7 +20,7 @@ public abstract partial class ButtonBase : Control, ICommandBindingTargetProvide private ContentAlignment _imageAlign = ContentAlignment.MiddleCenter; private ContentAlignment _textAlign = ContentAlignment.MiddleCenter; private TextImageRelation _textImageRelation = TextImageRelation.Overlay; - private readonly ImageList.Indexer _imageIndex = new ImageList.Indexer(); + private readonly ImageList.Indexer _imageIndex = new(); private FlatButtonAppearance? _flatAppearance; private ImageList? _imageList; private Image? _image; @@ -175,7 +173,6 @@ public override Color BackColor /// Gets or sets the whose /// method will be called when the event gets invoked. /// - [RequiresPreviewFeatures] [Bindable(true)] [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -191,7 +188,6 @@ public System.Windows.Input.ICommand? Command /// Occurs when the status of the /// which is assigned to the property has changed. /// - [RequiresPreviewFeatures] [SRCategory(nameof(SR.CatData))] [EditorBrowsable(EditorBrowsableState.Advanced)] [SRDescription(nameof(SR.CommandCanExecuteChangedEventDescr))] @@ -204,7 +200,6 @@ public event EventHandler? CommandCanExecuteChanged /// /// Occurs when the assigned of the property has changed. /// - [RequiresPreviewFeatures] [SRCategory(nameof(SR.CatData))] [EditorBrowsable(EditorBrowsableState.Advanced)] [SRDescription(nameof(SR.CommandChangedEventDescr))] @@ -225,12 +220,8 @@ public event EventHandler? CommandChanged [SRDescription(nameof(SR.CommandComponentCommandParameterDescr))] public object? CommandParameter { - [RequiresPreviewFeatures] get => _commandParameter; - // We need to opt into preview features on the getter and the setter rather than on top of the property, - // because we calling a preview feature from the setter. - [RequiresPreviewFeatures] set { if (!Equals(_commandParameter, value)) @@ -244,7 +235,6 @@ public object? CommandParameter /// /// Occurs when the value of the property has changed. /// - [RequiresPreviewFeatures] [SRCategory(nameof(SR.CatData))] [EditorBrowsable(EditorBrowsableState.Advanced)] [SRDescription(nameof(SR.CommandParameterChangedEventDescr))] @@ -254,7 +244,7 @@ public event EventHandler? CommandParameterChanged remove => Events.RemoveHandler(s_commandParameterChangedEvent, value); } - protected override Size DefaultSize => new Size(75, 23); + protected override Size DefaultSize => new(75, 23); protected override CreateParams CreateParams { @@ -887,11 +877,7 @@ private void ImageListRecreateHandle(object? sender, EventArgs e) protected override void OnClick(EventArgs e) { base.OnClick(e); - - // We won't let the preview feature warnings bubble further up beyond this point. -#pragma warning disable CA2252 // Suppress 'Opt in to preview features' (https://aka.ms/dotnet-warnings/preview-features) OnRequestCommandExecute(e); -#pragma warning restore CA2252 } /// @@ -1123,7 +1109,6 @@ internal virtual TextFormatFlags CreateTextFormatFlags() /// Raises the event. /// /// An empty instance. - [RequiresPreviewFeatures] [EditorBrowsable(EditorBrowsableState.Advanced)] protected virtual void OnCommandChanged(EventArgs e) => RaiseEvent(s_commandChangedEvent, e); @@ -1132,7 +1117,6 @@ protected virtual void OnCommandChanged(EventArgs e) /// Raises the event. /// /// An empty instance. - [RequiresPreviewFeatures] [EditorBrowsable(EditorBrowsableState.Advanced)] protected virtual void OnCommandCanExecuteChanged(EventArgs e) => ((EventHandler?)Events[s_commandCanExecuteChangedEvent])?.Invoke(this, e); @@ -1141,7 +1125,6 @@ protected virtual void OnCommandCanExecuteChanged(EventArgs e) /// Raises the event. /// /// An empty instance. - [RequiresPreviewFeatures] [EditorBrowsable(EditorBrowsableState.Advanced)] protected virtual void OnCommandParameterChanged(EventArgs e) => RaiseEvent(s_commandParameterChangedEvent, e); @@ -1149,17 +1132,14 @@ protected virtual void OnCommandCanExecuteChanged(EventArgs e) /// Called in the context of to invoke if the context allows. /// /// An empty instance. - [RequiresPreviewFeatures] protected virtual void OnRequestCommandExecute(EventArgs e) => ICommandBindingTargetProvider.RequestCommandExecute(this); // Called by the CommandProviderManager's command handling logic. - [RequiresPreviewFeatures] void ICommandBindingTargetProvider.RaiseCommandChanged(EventArgs e) => OnCommandChanged(e); // Called by the CommandProviderManager's command handling logic. - [RequiresPreviewFeatures] void ICommandBindingTargetProvider.RaiseCommandCanExecuteChanged(EventArgs e) => OnCommandCanExecuteChanged(e); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBorderStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBorderStyle.cs index 4b217b91659..f9832a521a3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBorderStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBorderStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.ColorData.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.ColorData.cs index c3ef2b5d15a..5cb100abcf5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.ColorData.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.ColorData.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.ColorOptions.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.ColorOptions.cs index 6e7fbbd328c..93a6b844225 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.ColorOptions.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.ColorOptions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; @@ -116,7 +115,7 @@ internal ColorData Calculate() colors.WindowText = colors.WindowFrame; } - using var hdc = new DeviceContextHdcScope(_deviceContext, applyGraphicsState: false); + using DeviceContextHdcScope hdc = new(_deviceContext, applyGraphicsState: false); colors.ButtonFace = hdc.FindNearestColor(colors.ButtonFace); colors.ButtonShadow = hdc.FindNearestColor(colors.ButtonShadow); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutData.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutData.cs index bffb92111e7..6ee78d1d1d8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutData.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutData.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutOptions.Composition.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutOptions.Composition.cs index 2c24d1cfe53..26c431e2a2f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutOptions.Composition.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutOptions.Composition.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.ButtonInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutOptions.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutOptions.cs index c79833e3354..26ab12aee35 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutOptions.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutOptions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.Drawing; @@ -176,7 +175,7 @@ static int xDecompose(Composition composition, int checkSize, int imageSize, int private Composition GetHorizontalComposition() { - BitVector32 action = default(BitVector32); + BitVector32 action = default; // Checks reserve space horizontally if possible, so only AnyLeft/AnyRight prevents combination. action[s_combineCheck] = @@ -239,7 +238,7 @@ internal Size GetPreferredSizeCore(Size proposedSize) private Composition GetVerticalComposition() { - BitVector32 action = default(BitVector32); + BitVector32 action = default; // Checks reserve space horizontally if possible, so only Top/Bottom prevents combination. action[s_combineCheck] = CheckAlign == ContentAlignment.MiddleCenter || !LayoutUtils.IsVerticalAlignment(CheckAlign); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.cs index 194b9487cff..45f1045bb09 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.CompilerServices; @@ -52,7 +51,7 @@ internal virtual Size GetPreferredSizeCore(Size proposedSize) { LayoutOptions? options = default; using (var screen = GdiCache.GetScreenHdc()) - using (PaintEventArgs pe = new PaintEventArgs(screen, default(Rectangle))) + using (PaintEventArgs pe = new PaintEventArgs(screen, default)) { options = Layout(pe); } @@ -138,7 +137,7 @@ private void Draw3DBorderHighContrastRaised(IDeviceContext deviceContext, ref Re bool stockColor = colors.ButtonFace.ToKnownColor() == SystemColors.Control.ToKnownColor(); bool disabledHighContrast = (!Control.Enabled) && SystemInformation.HighContrast; - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); // Draw counter-clock-wise Point p1 = new Point(bounds.X + bounds.Width - 1, bounds.Y); // Upper inner right @@ -193,7 +192,7 @@ private void Draw3DBorderHighContrastRaised(IDeviceContext deviceContext, ref Re private static void Draw3DBorderNormal(IDeviceContext deviceContext, ref Rectangle bounds, ColorData colors) { - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); // Draw counter-clock-wise Point p1 = new Point(bounds.X + bounds.Width - 1, bounds.Y); // Upper inner right @@ -241,7 +240,7 @@ private void Draw3DBorderRaised(IDeviceContext deviceContext, ref Rectangle boun bool stockColor = colors.ButtonFace.ToKnownColor() == SystemColors.Control.ToKnownColor(); bool disabledHighContrast = (!Control.Enabled) && SystemInformation.HighContrast; - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); // Draw counter-clock-wise. Point p1 = new Point(bounds.X + bounds.Width - 1, bounds.Y); // Upper inner right @@ -300,13 +299,13 @@ private void Draw3DBorderRaised(IDeviceContext deviceContext, ref Rectangle boun /// protected internal static void Draw3DLiteBorder(IDeviceContext deviceContext, Rectangle r, ColorData colors, bool up) { - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); // Draw counter-clock-wise. - Point p1 = new Point(r.Right - 1, r.Top); // Upper inner right - Point p2 = new Point(r.Left, r.Top); // Upper left - Point p3 = new Point(r.Left, r.Bottom - 1); // Bottom inner left - Point p4 = new Point(r.Right - 1, r.Bottom - 1); // Inner bottom right + Point p1 = new(r.Right - 1, r.Top); // Upper inner right + Point p2 = new(r.Left, r.Top); // Upper left + Point p3 = new(r.Left, r.Bottom - 1); // Bottom inner left + Point p4 = new(r.Right - 1, r.Bottom - 1); // Inner bottom right Color color = GetContrastingBorderColor(colors.ButtonShadow); // Top, left @@ -326,21 +325,20 @@ protected internal static void Draw3DLiteBorder(IDeviceContext deviceContext, Re /// /// Draws the flat border with specified bordersize. /// - /// - /// This function gets called only for Flatstyle == Flatstyle.Flat. - /// internal static void DrawFlatBorderWithSize( PaintEventArgs e, Rectangle bounds, Color color, int size) { + // This function gets called only for Flatstyle == Flatstyle.Flat. + size = Math.Min(size, Math.Min(bounds.Width, bounds.Height)); - var left = new Rectangle(bounds.X, bounds.Y, size, bounds.Height); - var right = new Rectangle(bounds.X + bounds.Width - size, bounds.Y, size, bounds.Height); - var top = new Rectangle(bounds.X + size, bounds.Y, bounds.Width - size * 2, size); - var bottom = new Rectangle(bounds.X + size, bounds.Y + bounds.Height - size, bounds.Width - size * 2, size); + Rectangle left = new(bounds.X, bounds.Y, size, bounds.Height); + Rectangle right = new(bounds.X + bounds.Width - size, bounds.Y, size, bounds.Height); + Rectangle top = new(bounds.X + size, bounds.Y, bounds.Width - size * 2, size); + Rectangle bottom = new(bounds.X + size, bounds.Y + bounds.Height - size, bounds.Width - size * 2, size); if (color.HasTransparency()) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonFlatAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonFlatAdapter.cs index 4b30b97dfa5..98db127cd00 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonFlatAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonFlatAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonPopupAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonPopupAdapter.cs index bae058a957d..815dd693f27 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonPopupAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonPopupAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonStandardAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonStandardAdapter.cs index e48c3ddbb3a..941e94996a3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonStandardAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonStandardAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Layout; @@ -89,7 +88,7 @@ private void PaintThemedButtonBackground(PaintEventArgs e, Rectangle bounds, boo } else { - using var hdc = new DeviceContextHdcScope(e); + using DeviceContextHdcScope hdc = new(e); hdc.FillRectangle( bounds, isHighContrastHighlighted diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxBaseAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxBaseAdapter.cs index 95b021a1c7a..b6dbd5a0380 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxBaseAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxBaseAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; @@ -98,7 +97,7 @@ internal static void DrawCheckBackground( Color checkBackground, bool disabledColors) { - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); Color color; @@ -212,13 +211,13 @@ internal static void DrawCheckOnly( internal static Rectangle DrawPopupBorder(Graphics g, Rectangle r, ColorData colors) { - using var hdc = new DeviceContextHdcScope(g); + using DeviceContextHdcScope hdc = new(g); return DrawPopupBorder(hdc, r, colors); } internal static Rectangle DrawPopupBorder(PaintEventArgs e, Rectangle r, ColorData colors) { - using var hdc = new DeviceContextHdcScope(e); + using DeviceContextHdcScope hdc = new(e); return DrawPopupBorder(hdc, r, colors); } @@ -324,7 +323,7 @@ private static Bitmap GetCheckBoxImage(Color checkColor, Rectangle fullSize, ref using (Graphics offscreen = Graphics.FromImage(bitmap)) { offscreen.Clear(Color.Transparent); - using var hdc = new DeviceContextHdcScope(offscreen, applyGraphicsState: false); + using DeviceContextHdcScope hdc = new(offscreen, applyGraphicsState: false); PInvoke.DrawFrameControl( hdc, ref rcCheck, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxFlatAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxFlatAdapter.cs index 37027da4fa0..56d0c0e6670 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxFlatAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxFlatAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxPopupAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxPopupAdapter.cs index 04c9dd9a286..9638a8d12b6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxPopupAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxPopupAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxStandardAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxStandardAdapter.cs index 91530cdd2b3..f72c3d622d6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxStandardAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxStandardAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Layout; @@ -96,7 +95,7 @@ internal override Size GetPreferredSizeCore(Size proposedSize) { LayoutOptions? options = default; using (var screen = GdiCache.GetScreenHdc()) - using (PaintEventArgs pe = new PaintEventArgs(screen, default(Rectangle))) + using (PaintEventArgs pe = new PaintEventArgs(screen, default)) { options = Layout(pe); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckableControlBaseAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckableControlBaseAdapter.cs index 757f7551ac1..b61a9fba49b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckableControlBaseAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckableControlBaseAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; @@ -38,7 +37,7 @@ internal override Size GetPreferredSizeCore(Size proposedSize) LayoutOptions? options = default; using (var screen = GdiCache.GetScreenHdc()) - using (PaintEventArgs pe = new PaintEventArgs(screen, default(Rectangle))) + using (PaintEventArgs pe = new PaintEventArgs(screen, default)) { options = Layout(pe); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonBaseAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonBaseAdapter.cs index c6adb44f316..872a8a2f120 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonBaseAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonBaseAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; @@ -202,7 +201,7 @@ protected void DrawCheckBox(PaintEventArgs e, LayoutData layout) if (Application.RenderWithVisualStyles) { - using var hdc = new DeviceContextHdcScope(e); + using DeviceContextHdcScope hdc = new(e); RadioButtonRenderer.DrawRadioButtonWithVisualStyles( hdc, new Point(check.Left, check.Top), diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonFlatAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonFlatAdapter.cs index 109773797f0..a1aeb7852a8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonFlatAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonFlatAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonPopupAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonPopupAdapter.cs index f408f1754ab..97514febb58 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonPopupAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonPopupAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonStandardAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonStandardAdapter.cs index 00eaf0bb576..7dd5a448f29 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonStandardAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonStandardAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.ButtonInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonRenderer.cs index e2987c5e5f7..ada56f5867d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; @@ -106,7 +105,7 @@ internal static void DrawButtonForHandle( { InitializeRenderer((int)state); - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); t_visualStyleRenderer.DrawBackground(hdc, bounds, hwnd); contentBounds = t_visualStyleRenderer.GetBackgroundContentRectangle(hdc, bounds); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonState.cs index 4dbb06a643e..09ba081348d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CacheVirtualItemsEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CacheVirtualItemsEventArgs.cs index 53636d74ce4..cfe872e38f6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CacheVirtualItemsEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CacheVirtualItemsEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CacheVirtualItemsEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CacheVirtualItemsEventHandler.cs index b4b443eb40d..31504562413 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CacheVirtualItemsEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CacheVirtualItemsEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CachedItemHdcInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CachedItemHdcInfo.cs index ee0774ed713..b1c0b5027f7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CachedItemHdcInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CachedItemHdcInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CaptionButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CaptionButton.cs index fc7a4821855..acdc63ab25b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CaptionButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CaptionButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CharacterCasing.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CharacterCasing.cs index 0d1bfb64aa8..136fe43e130 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CharacterCasing.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CharacterCasing.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CheckBox.CheckBoxAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CheckBox.CheckBoxAccessibleObject.cs index 7cb16576d29..ed42d804e9b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CheckBox.CheckBoxAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CheckBox.CheckBoxAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CheckBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CheckBox.cs index ac75c2b6219..7899e079da6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CheckBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CheckBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -21,9 +20,9 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionCheckBox))] public partial class CheckBox : ButtonBase { - private static readonly object EVENT_CHECKEDCHANGED = new object(); - private static readonly object EVENT_CHECKSTATECHANGED = new object(); - private static readonly object EVENT_APPEARANCECHANGED = new object(); + private static readonly object EVENT_CHECKEDCHANGED = new(); + private static readonly object EVENT_CHECKSTATECHANGED = new(); + private static readonly object EVENT_APPEARANCECHANGED = new(); private const ContentAlignment AnyRight = ContentAlignment.TopRight | ContentAlignment.MiddleRight | ContentAlignment.BottomRight; private ContentAlignment _checkAlign = ContentAlignment.MiddleLeft; @@ -280,7 +279,7 @@ protected override CreateParams CreateParams } } - protected override Size DefaultSize => new Size(104, 24); + protected override Size DefaultSize => new(104, 24); /// /// When overridden in a derived class, handles rescaling of any magic numbers used in control painting. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CheckBoxRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CheckBoxRenderer.cs index 927530d3c18..d11d75dc1f2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CheckBoxRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CheckBoxRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; @@ -89,7 +88,7 @@ internal static void DrawCheckBoxWithVisualStyles( { InitializeRenderer((int)state); - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); Rectangle glyphBounds = new Rectangle(glyphLocation, GetGlyphSize(hdc, state, hwnd)); t_visualStyleRenderer.DrawBackground(hdc, glyphBounds, hwnd); } @@ -260,7 +259,7 @@ internal static Size GetGlyphSize(IDeviceContext deviceContext, CheckBoxState st return new Size(13, 13); } - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); return GetGlyphSize(hdc, state, hwnd); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CheckState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CheckState.cs index 16873ae4c10..b0cbb328d8e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CheckState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CheckState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedIndexCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedIndexCollection.cs index e02ff76e6ae..4c32c2847b6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedIndexCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedIndexCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedItemCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedItemCollection.cs index a938e261f7f..bb44fddd5e5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedItemCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedItemCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedListBoxAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedListBoxAccessibleObject.cs index ae3e7f3dc7d..b0e4025716b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedListBoxAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedListBoxAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedListBoxItemAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedListBoxItemAccessibleObject.cs index 27a63ddb38a..6cbc5dcacac 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedListBoxItemAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.CheckedListBoxItemAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.ObjectCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.ObjectCollection.cs index b3a98478b75..3fd7ba1e20e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.ObjectCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.ObjectCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.cs index 3522b6a154e..6dc592e32f9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -163,6 +162,7 @@ public override int ItemHeight [Localizable(true)] [SRDescription(nameof(SR.ListBoxItemsDescr))] [Editor($"System.Windows.Forms.Design.ListControlStringCollectionEditor, {AssemblyRef.SystemDesign}", typeof(UITypeEditor))] + [MergableProperty(false)] public new ObjectCollection Items { get @@ -394,7 +394,7 @@ private unsafe void InvalidateItem(int index) { if (IsHandleCreated) { - var rect = default(RECT); + RECT rect = default; PInvoke.SendMessage(this, PInvoke.LB_GETITEMRECT, (WPARAM)index, ref rect); PInvoke.InvalidateRect(this, &rect, bErase: false); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Clipboard.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Clipboard.cs index 17d9d7572ff..d664798e7fb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Clipboard.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Clipboard.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CloseReason.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CloseReason.cs index b5b5fd2a997..a06339b14e5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CloseReason.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CloseReason.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColorDepth.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColorDepth.cs index 378ef9fcf32..3afe5021fb8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColorDepth.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColorDepth.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColorDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColorDialog.cs index 46f99b2325b..b2202d958e2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColorDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColorDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -162,7 +161,7 @@ protected override unsafe bool RunDialog(IntPtr hwndOwner) { WNDPROC hookProc = HookProcInternal; void* hookProcPtr = (void*)Marshal.GetFunctionPointerForDelegate(hookProc); - var cc = new Comdlg32.CHOOSECOLORW + Comdlg32.CHOOSECOLORW cc = new() { lStructSize = (uint)Marshal.SizeOf() }; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnClickEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnClickEventArgs.cs index 654b76ead32..4f99f2554cb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnClickEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnClickEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnClickEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnClickEventHandler.cs index f7ccf52d39b..43b31eadb68 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnClickEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnClickEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeader.ColumnHeaderImageListIndexer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeader.ColumnHeaderImageListIndexer.cs index f179e5c0e15..8df64adf724 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeader.ColumnHeaderImageListIndexer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeader.ColumnHeaderImageListIndexer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeader.ListViewColumnHeaderAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeader.ListViewColumnHeaderAccessibleObject.cs index 1435d973bfb..94e7380e5cb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeader.ListViewColumnHeaderAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeader.ListViewColumnHeaderAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.UiaCore; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeader.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeader.cs index c0a81c0e340..4a25574a5d1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeader.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeader.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeaderAutoResizeStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeaderAutoResizeStyle.cs index 6a787ce60dd..0854576d663 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeaderAutoResizeStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeaderAutoResizeStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeaderConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeaderConverter.cs index 163963bb1eb..58b0434d3f9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeaderConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeaderConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeaderStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeaderStyle.cs index 9832733ef26..b8402e5e934 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeaderStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnHeaderStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnReorderedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnReorderedEventArgs.cs index c2c905bb342..9e813f77c3d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnReorderedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnReorderedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnReorderedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnReorderedEventHandler.cs index c15ddcff0a5..a1d9a4afac5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnReorderedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnReorderedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnStyle.cs index 7b76c46b715..4e776755011 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangedEventArgs.cs index 7bb1b33661e..bc6eee902de 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangedEventHandler.cs index 9706dabfbb6..e6d1808b454 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangingEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangingEventArgs.cs index aeee596b9b4..dcfcd9447b3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangingEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangingEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangingEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangingEventHandler.cs index 97af507714b..0dbea389703 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangingEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColumnWidthChangingEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ACNativeWindow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ACNativeWindow.cs index e31f0fdb6b2..8d7089d031f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ACNativeWindow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ACNativeWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.AutoCompleteDropDownFinder.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.AutoCompleteDropDownFinder.cs index 6713b7c0b6f..38145b94df2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.AutoCompleteDropDownFinder.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.AutoCompleteDropDownFinder.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ChildAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ChildAccessibleObject.cs index cce47018e54..16a1ed8164f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ChildAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ChildAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ChildWindowType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ChildWindowType.cs index 832b9f70c20..aafd0675f70 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ChildWindowType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ChildWindowType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxAccessibleObject.cs index 644912bf18d..df80fc1f402 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static System.Windows.Forms.ComboBox.ObjectCollection; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildDropDownButtonUiaProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildDropDownButtonUiaProvider.cs index 79575c2c305..1014f8c7577 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildDropDownButtonUiaProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildDropDownButtonUiaProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildEditUiaProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildEditUiaProvider.cs index c1b5ae6a346..dbce325caed 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildEditUiaProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildEditUiaProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildListUiaProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildListUiaProvider.cs index cefef5718ec..877b7e83158 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildListUiaProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildListUiaProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildNativeWindow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildNativeWindow.cs index 1f3f915907e..1fa23920500 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildNativeWindow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildNativeWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildTextUiaProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildTextUiaProvider.cs index 894718e37b9..fa88dc6f575 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildTextUiaProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxChildTextUiaProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxItemAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxItemAccessibleObject.cs index a7fa58cef47..03513636580 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxItemAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxItemAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static System.Windows.Forms.ComboBox.ObjectCollection; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxItemAccessibleObjectCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxItemAccessibleObjectCollection.cs index 328ecdeb50d..a1b15a353c9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxItemAccessibleObjectCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxItemAccessibleObjectCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static System.Windows.Forms.ComboBox.ObjectCollection; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxUiaTextProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxUiaTextProvider.cs index bd3a9c8841f..bae94261e73 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxUiaTextProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ComboBoxUiaTextProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Automation; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.FlatComboAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.FlatComboAdapter.cs index fd643a7e57f..479429e0b6e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.FlatComboAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.FlatComboAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ObjectCollection.Entry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ObjectCollection.Entry.cs index 7fc87520982..65fe11057fe 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ObjectCollection.Entry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ObjectCollection.Entry.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ObjectCollection.EntryEnumerator.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ObjectCollection.EntryEnumerator.cs index ef0489828bf..5c8466f7ae3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ObjectCollection.EntryEnumerator.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ObjectCollection.EntryEnumerator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ObjectCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ObjectCollection.cs index 9ea9ac46dcf..cc9d40fe103 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ObjectCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.ObjectCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -175,7 +174,7 @@ int IList.Add(object? item) return Add(item!); } - public void AddRange(object[] items) + public void AddRange(params object[] items) { _owner.CheckNoDataSource(); _owner.BeginUpdate(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.cs index 1209cfeb906..5c9d98ed684 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -25,15 +24,15 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionComboBox))] public partial class ComboBox : ListControl { - private static readonly object EVENT_DROPDOWN = new object(); - private static readonly object EVENT_DRAWITEM = new object(); - private static readonly object EVENT_MEASUREITEM = new object(); - private static readonly object EVENT_SELECTEDINDEXCHANGED = new object(); - private static readonly object EVENT_SELECTIONCHANGECOMMITTED = new object(); - private static readonly object EVENT_SELECTEDITEMCHANGED = new object(); - private static readonly object EVENT_DROPDOWNSTYLE = new object(); - private static readonly object EVENT_TEXTUPDATE = new object(); - private static readonly object EVENT_DROPDOWNCLOSED = new object(); + private static readonly object EVENT_DROPDOWN = new(); + private static readonly object EVENT_DRAWITEM = new(); + private static readonly object EVENT_MEASUREITEM = new(); + private static readonly object EVENT_SELECTEDINDEXCHANGED = new(); + private static readonly object EVENT_SELECTIONCHANGECOMMITTED = new(); + private static readonly object EVENT_SELECTEDITEMCHANGED = new(); + private static readonly object EVENT_DROPDOWNSTYLE = new(); + private static readonly object EVENT_TEXTUPDATE = new(); + private static readonly object EVENT_DROPDOWNCLOSED = new(); private static readonly int PropMaxLength = PropertyStore.CreateKey(); private static readonly int PropItemHeight = PropertyStore.CreateKey(); @@ -88,7 +87,7 @@ public partial class ComboBox : ListControl private string _currentText = string.Empty; private string? _lastTextChangedValue; private bool _dropDown; - private readonly AutoCompleteDropDownFinder _finder = new AutoCompleteDropDownFinder(); + private readonly AutoCompleteDropDownFinder _finder = new(); private bool _selectedValueChangedFired; private AutoCompleteMode _autoCompleteMode = AutoCompleteMode.None; @@ -3740,7 +3739,7 @@ private unsafe void WmReflectDrawItem(ref Message m) { DRAWITEMSTRUCT* dis = (DRAWITEMSTRUCT*)(nint)m.LParamInternal; - using var e = new DrawItemEventArgs( + using DrawItemEventArgs e = new( dis->hDC, Font, dis->rcItem, @@ -4005,5 +4004,5 @@ private FlatComboAdapter FlatComboBoxAdapter } internal virtual FlatComboAdapter CreateFlatComboAdapterInstance() - => new FlatComboAdapter(this, smallButton: false); + => new(this, smallButton: false); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBoxRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBoxRenderer.cs index 1938ab8a070..af7498bf74f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBoxRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBoxRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; @@ -98,7 +97,7 @@ public static void DrawTextBox(Graphics g, Rectangle bounds, string? comboBoxTex /// public static void DrawDropDownButton(Graphics g, Rectangle bounds, ComboBoxState state) { - using var hdc = new DeviceContextHdcScope(g); + using DeviceContextHdcScope hdc = new(g); DrawDropDownButtonForHandle(hdc, bounds, state, HWND.Null); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBoxStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBoxStyle.cs index 4dccac239d1..3892849ed8e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBoxStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBoxStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Command.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Command.cs index 3eb2a06e2c0..5b5a4ca7a8b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Command.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Command.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -8,7 +7,7 @@ internal class Command : WeakReference { private static Command?[]? s_cmds; private static int s_icmdTry; - private static readonly object s_internalSyncObject = new object(); + private static readonly object s_internalSyncObject = new(); private const int IdMin = 0x00100; private const int IdLim = 0x10000; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CommonDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CommonDialog.cs index ed2ec8a0cf7..d49b6a46511 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CommonDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CommonDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2AboutBoxPropertyDescriptor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2AboutBoxPropertyDescriptor.cs index ce049d4e68d..f146cac5aa6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2AboutBoxPropertyDescriptor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2AboutBoxPropertyDescriptor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ColorConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ColorConverter.cs index 66a8561d3b8..ede664e7ada 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ColorConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ColorConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using Windows.Win32.System.Variant; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ComponentEditor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ComponentEditor.cs index 01fc340cf5d..abaefa9545f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ComponentEditor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ComponentEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.InteropServices; @@ -75,7 +74,7 @@ public override unsafe bool EditComponent(ITypeDescriptorContext? context, objec &guid, PInvoke.GetThreadLocale(), 0, - null); + null).ThrowOnFailure(); } return true; @@ -110,7 +109,7 @@ public override unsafe bool EditComponent(ITypeDescriptorContext? context, objec uuids.pElems, PInvoke.GetThreadLocale(), 0, - null); + null).ThrowOnFailure(); return true; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2DataTypeToManagedDataTypeConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2DataTypeToManagedDataTypeConverter.cs index 3d17a0270d5..7a9cc2a1db2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2DataTypeToManagedDataTypeConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2DataTypeToManagedDataTypeConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Ole; using Windows.Win32.System.Variant; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2Enum.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2Enum.cs index 374bfbe23ee..04fed9c5a1b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2Enum.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2Enum.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2EnumConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2EnumConverter.cs index 676d5864574..c8f7334f3ba 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2EnumConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2EnumConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedBrowsingHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedBrowsingHandler.cs index 79435350c7f..c1e697af33c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedBrowsingHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedBrowsingHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.ComponentModel.Com2Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedTypeConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedTypeConverter.cs index f4b338e6c58..d596910e94a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedTypeConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedTypeConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedUITypeEditor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedUITypeEditor.cs index c12618b724d..be45b142198 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedUITypeEditor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ExtendedUITypeEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2FontConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2FontConverter.cs index f5c35517717..72086189bb2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2FontConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2FontConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ICategorizePropertiesHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ICategorizePropertiesHandler.cs index 6009dbb367c..543ee3f3d3d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ICategorizePropertiesHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ICategorizePropertiesHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using Microsoft.VisualStudio.Shell; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IDispatchConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IDispatchConverter.cs index 7ef2774d962..f704297a9b1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IDispatchConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IDispatchConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IManagedPerPropertyBrowsingHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IManagedPerPropertyBrowsingHandler.cs index acda24df4fa..e6608723d9d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IManagedPerPropertyBrowsingHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IManagedPerPropertyBrowsingHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; using System.Runtime.InteropServices; @@ -68,7 +67,7 @@ internal static Attribute[] GetComponentAttributes(IVSMDPerPropertyBrowsing* pro } // Get the types. - for (int i= 0; i < typeNames.Length; i++) + for (int i = 0; i < typeNames.Length; i++) { string typeName = typeNames[i]; @@ -221,7 +220,7 @@ private static string[] GetStringsFromPtr(BSTR* values, uint count) private static unsafe object?[] GetVariantsFromPtr(VARIANT* values, uint count) { - var objects = new object?[count]; + object?[] objects = new object?[count]; for (int i = 0; i < count; i++) { try diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IPerPropertyBrowsingHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IPerPropertyBrowsingHandler.cs index 43437fad0d8..466feaa9c28 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IPerPropertyBrowsingHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IPerPropertyBrowsingHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IProvidePropertyBuilderHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IProvidePropertyBuilderHandler.cs index 023dec7e3f6..6d6c567524c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IProvidePropertyBuilderHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IProvidePropertyBuilderHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IVsPerPropertyBrowsingHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IVsPerPropertyBrowsingHandler.cs index ab4e607ef2a..a562f1f4e06 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IVsPerPropertyBrowsingHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IVsPerPropertyBrowsingHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using Microsoft.VisualStudio.Shell; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PictureConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PictureConverter.cs index 3fd4abe740e..7a97e825751 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PictureConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PictureConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2Properties.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2Properties.cs index 3a97b9ff97c..e8e3cc01153 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2Properties.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2Properties.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyBuilderUITypeEditor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyBuilderUITypeEditor.cs index 992bea91010..27fbe93c432 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyBuilderUITypeEditor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyBuilderUITypeEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; @@ -52,8 +51,8 @@ public Com2PropertyBuilderUITypeEditor( VARIANT_BOOL useValue = VARIANT_BOOL.VARIANT_FALSE; - // Is it actually necessary to pass the value in? - VARIANT variantValue = VARIANT.FromObject(value); + // This is always an out value. + using VARIANT variantValue = default; using BSTR guidString = new(_guidString); hr = propertyBuilder.Value->ExecuteBuilder( diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyDescriptor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyDescriptor.cs index d770d453089..0d7eeb5f771 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyDescriptor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyDescriptor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; @@ -10,7 +9,6 @@ using Windows.Win32.System.Diagnostics.Debug; using Windows.Win32.System.Ole; using Windows.Win32.System.Variant; -using static Interop; namespace System.Windows.Forms.ComponentModel.Com2Interop; @@ -847,11 +845,12 @@ public override unsafe void SetValue(object? component, object? value) } hr = dispatch.Value->SetPropertyValue(DISPID, nativeValue, out string? errorText); + nativeValue.Dispose(); if (hr == HRESULT.S_OK || hr == HRESULT.S_FALSE) { OnValueChanged(component, EventArgs.Empty); - _lastValue = nativeValue; + _lastValue = value; return; } @@ -868,16 +867,18 @@ public override unsafe void SetValue(object? component, object? value) { if (iSupportErrorInfo.Value->InterfaceSupportsErrorInfo(IID.Get()).Succeeded) { - Oleaut32.GetErrorInfo(out WinFormsComWrappers.ErrorInfoWrapper? errorInfo); + using ComScope errorInfo = new(null); + hr = PInvoke.GetErrorInfo(0, errorInfo); - if (errorInfo is not null) + if (hr.Succeeded && hr != HRESULT.S_FALSE && !errorInfo.IsNull) { - if (errorInfo.GetDescription(out string? description)) + using BSTR description = default; + hr = errorInfo.Value->GetDescription(&description); + + if (hr.Succeeded) { - errorText = description; + errorText = description.ToString(); } - - errorInfo.Dispose(); } } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyDescriptorRefresh.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyDescriptorRefresh.cs index 4563ec3e9c6..a010fe21c7e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyDescriptorRefresh.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyDescriptorRefresh.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.ComponentModel.Com2Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyPageUITypeConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyPageUITypeConverter.cs index e27e947a625..b8a6a2db49a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyPageUITypeConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2PropertyPageUITypeConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; @@ -53,7 +52,7 @@ public Com2PropertyPageUITypeEditor( { if (provider.TryGetService(out IUIService? uiService)) { - uiService?.ShowError(ex, SR.ErrorTypeConverterFailed); + uiService.ShowError(ex, SR.ErrorTypeConverterFailed); } } @@ -85,7 +84,7 @@ public void ShowPropertyPage(string title, object component, int dispid, Guid pa (IUnknown**)pObjAddrs, 1, pageGuid, - PInvoke.GetThreadLocale()); + PInvoke.GetThreadLocale()).ThrowOnFailure(); } } finally diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ShouldRefreshTypes.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ShouldRefreshTypes.cs index 40e7f609e02..5e03e6b8e8b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ShouldRefreshTypes.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2ShouldRefreshTypes.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.ComponentModel.Com2Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2TypeInfoProcessor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2TypeInfoProcessor.cs index 9e0ea1dbd2a..47afc528271 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2TypeInfoProcessor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2TypeInfoProcessor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; @@ -508,8 +507,8 @@ private static unsafe PropertyInfo ProcessDataCore( VARFLAGS flags) { // Get the name and the helpstring. - using var nameBstr = default(BSTR); - using var helpStringBstr = default(BSTR); + using BSTR nameBstr = default; + using BSTR helpStringBstr = default; HRESULT hr = typeInfo->GetDocumentation(dispid, &nameBstr, &helpStringBstr, null, null); if (!hr.Succeeded) { @@ -738,8 +737,8 @@ private static unsafe void ProcessFunctions( object? varValue = null; - using var enumNameBstr = default(BSTR); - using var enumHelpStringBstr = default(BSTR); + using BSTR enumNameBstr = default; + using BSTR enumHelpStringBstr = default; enumTypeInfo->GetDocumentation(PInvoke.MEMBERID_NIL, &enumNameBstr, &enumHelpStringBstr, null, null); // For each item in the enum type info, we just need it's name and value and @@ -783,7 +782,7 @@ private static unsafe void ProcessFunctions( // Get the value. try { - varValue = Marshal.GetObjectForNativeVariant((nint)(void*)pVarDesc->Anonymous.lpvarValue); + varValue = (*pVarDesc->Anonymous.lpvarValue).ToObject(); } catch (Exception ex) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2AboutBoxPropertyDescriptor.AboutBoxUITypeEditor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2AboutBoxPropertyDescriptor.AboutBoxUITypeEditor.cs index cd059d3d391..80fe3ba219c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2AboutBoxPropertyDescriptor.AboutBoxUITypeEditor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2AboutBoxPropertyDescriptor.AboutBoxUITypeEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; @@ -29,9 +28,9 @@ public unsafe class AboutBoxUITypeEditor : UITypeEditor PInvoke.GetThreadLocale(), DISPATCH_FLAGS.DISPATCH_METHOD, &dispParams, - null, + pVarResult: null, &pExcepInfo, - null); + puArgErr: null); Debug.Assert(hr.Succeeded, $"Failed to launch about box. {hr}"); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2IPerPropertyBrowsingHandler.Com2IPerPropertyBrowsingEnum.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2IPerPropertyBrowsingHandler.Com2IPerPropertyBrowsingEnum.cs index 82c417f5a01..5b54c87912b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2IPerPropertyBrowsingHandler.Com2IPerPropertyBrowsingEnum.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2IPerPropertyBrowsingHandler.Com2IPerPropertyBrowsingEnum.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; using Windows.Win32.System.Ole; @@ -60,7 +59,10 @@ private unsafe void EnsureArrays() try { // Marshal the items. - if (Target.TargetObject is not IPerPropertyBrowsing.Interface ppb) + + using var ppb = ComHelpers.TryGetComScope(Target.TargetObject, out HRESULT hr); + + if (hr.Failed) { PopulateArrays(Array.Empty(), Array.Empty()); return; @@ -100,7 +102,7 @@ private unsafe void EnsureArrays() } using VARIANT variant = default; - HRESULT hr = ppb.GetPredefinedValue(Target.DISPID, cookie, &variant); + hr = ppb.Value->GetPredefinedValue(Target.DISPID, cookie, &variant); if (hr.Succeeded && variant.Type != VARENUM.VT_EMPTY) { valueItems[i] = variant.ToObject()!; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2IPerPropertyBrowsingHandler.Com2IPerPropertyEnumConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2IPerPropertyBrowsingHandler.Com2IPerPropertyEnumConverter.cs index 0bdba8a7508..550d4a05b25 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2IPerPropertyBrowsingHandler.Com2IPerPropertyEnumConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2IPerPropertyBrowsingHandler.Com2IPerPropertyEnumConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2PropertyDescriptor.Com2PropDescMainConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2PropertyDescriptor.Com2PropDescMainConverter.cs index 35e6d15bafa..89b063e75d9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2PropertyDescriptor.Com2PropDescMainConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2PropertyDescriptor.Com2PropDescMainConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2PropertyDescriptor.ValidityScope.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2PropertyDescriptor.ValidityScope.cs index a66233ed166..36e72a7b8b9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2PropertyDescriptor.ValidityScope.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2PropertyDescriptor.ValidityScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.ComponentModel.Com2Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2TypeInfoProcessor.CachedProperties.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2TypeInfoProcessor.CachedProperties.cs index 7c382530309..ef6faf70b6d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2TypeInfoProcessor.CachedProperties.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2TypeInfoProcessor.CachedProperties.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.ComponentModel.Com2Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2TypeInfoProcessor.PropInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2TypeInfoProcessor.PropInfo.cs index 727fb8e8da0..0b76ef7866d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2TypeInfoProcessor.PropInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2TypeInfoProcessor.PropInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.ComponentModel.Com2Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2Variant.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2Variant.cs index 2ee153ad4c0..99af8a6db5c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2Variant.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/Com2Variant.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.ComponentModel.Com2Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.ComTypeDescriptor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.ComTypeDescriptor.cs index 2561374f87c..17fcdbf5c8c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.ComTypeDescriptor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.ComTypeDescriptor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using Windows.Win32.System.Com; @@ -46,10 +45,10 @@ internal ComTypeDescriptor(ComNativeDescriptor handler, object instance) [RequiresUnreferencedCode(EditorRequiresUnreferencedCode)] object? ICustomTypeDescriptor.GetEditor(Type editorBaseType) => GetEditor(_instance, editorBaseType); - EventDescriptorCollection ICustomTypeDescriptor.GetEvents() => new EventDescriptorCollection(null); + EventDescriptorCollection ICustomTypeDescriptor.GetEvents() => new(null); [RequiresUnreferencedCode(FilterRequiresUnreferencedCodeMessage)] - EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[]? attributes) => new EventDescriptorCollection(null); + EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[]? attributes) => new(null); [RequiresUnreferencedCode(PropertyDescriptorPropertyTypeMessage)] PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() => _handler.GetProperties(_instance); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.NullTypeDescriptor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.NullTypeDescriptor.cs index c6523d3cf30..f721f9ce9d6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.NullTypeDescriptor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.NullTypeDescriptor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using static System.TrimmingConstants; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.cs index b0830044692..786750dc25b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetAttributesEvent.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetAttributesEvent.cs index 73344a389d7..2b42343ea30 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetAttributesEvent.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetAttributesEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.ComponentModel.Com2Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetBoolValueEvent.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetBoolValueEvent.cs index 8385ef4067c..e06dc0cff5e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetBoolValueEvent.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetBoolValueEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.ComponentModel.Com2Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetNameItemEvent.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetNameItemEvent.cs index 274880fdeea..5c805e415e1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetNameItemEvent.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetNameItemEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.ComponentModel.Com2Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetRefreshStateEvent.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetRefreshStateEvent.cs index a7076025a11..958fc7e8a64 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetRefreshStateEvent.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetRefreshStateEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.ComponentModel.Com2Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetTypeConverterAndTypeEditorEvent.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetTypeConverterAndTypeEditorEvent.cs index 1c4cc719dfe..f9e55b21f4d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetTypeConverterAndTypeEditorEvent.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/GetTypeConverterAndTypeEditorEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ICOM2PropertyPageDisplayService.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ICOM2PropertyPageDisplayService.cs index 9360c433f3f..4849d953293 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ICOM2PropertyPageDisplayService.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ICOM2PropertyPageDisplayService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.ComponentModel.Com2Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ICom2ExtendedBrowsingHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ICom2ExtendedBrowsingHandler.cs index 9a976ef461d..291b42c5d94 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ICom2ExtendedBrowsingHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ICom2ExtendedBrowsingHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.ComponentModel.Com2Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/IComPropertyBrowser.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/IComPropertyBrowser.cs index 9636864a45f..96140bc482d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/IComPropertyBrowser.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/IComPropertyBrowser.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; using Microsoft.Win32; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ContainerControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ContainerControl.cs index 86ddc2e5f27..609a649fa3c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ContainerControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ContainerControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -726,7 +725,7 @@ internal override Rectangle GetToolNativeScreenRectangle() { // Get window's client rectangle (i.e. without chrome) expressed in screen coordinates PInvoke.GetClientRect(this, out RECT clientRectangle); - var topLeftPoint = default(Point); + Point topLeftPoint = default; PInvoke.ClientToScreen(this, ref topLeftPoint); return new Rectangle(topLeftPoint.X, topLeftPoint.Y, clientRectangle.right, clientRectangle.bottom); } @@ -744,7 +743,7 @@ private unsafe SizeF GetFontAutoScaleDimensions(HFONT fontHandle) // Windows uses CreateCompatibleDC(NULL) to get a memory DC for // the monitor the application is currently on. - using var dc = new PInvoke.CreateDcScope(default); + using PInvoke.CreateDcScope dc = new(default); if (dc.IsNull) { throw new Win32Exception(); @@ -820,7 +819,7 @@ private protected override void OnFrameWindowActivate(bool fActivate) { if (ActiveControl is null) { - SelectNextControl(null, true, true, true, false); + SelectNextControl(ctl: null, forward: true, tabStopOnly: true, nested: true, wrap: false); } InnerMostActiveContainerControl.FocusActiveControlInternal(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ContentsResizedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ContentsResizedEventArgs.cs index 1883a7946f1..e16bff01029 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ContentsResizedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ContentsResizedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ContentsResizedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ContentsResizedEventHandler.cs index 03bf1916e3e..f589b268856 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ContentsResizedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ContentsResizedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ContextMenuStrip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ContextMenuStrip.cs index 892819c13aa..2c8ab2a9efb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ContextMenuStrip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ContextMenuStrip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXFontMarshaler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXFontMarshaler.cs index acf9abb079a..5a3265ff8dc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXFontMarshaler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXFontMarshaler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXImpl.PropertyBagStream.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXImpl.PropertyBagStream.cs index 658cb4747a5..968c3263d1f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXImpl.PropertyBagStream.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXImpl.PropertyBagStream.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXImpl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXImpl.cs index 2fefc0dee9e..4039b788ce0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXImpl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXImpl.cs @@ -1,11 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. +using System.Buffers; using System.Collections.Specialized; using System.ComponentModel; using System.Drawing; using System.Globalization; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; @@ -116,6 +117,7 @@ private sealed unsafe partial class ActiveXImpl : MarshalByRefObject, IWindowTar private static readonly int s_uiActive = BitVector32.CreateMask(s_inPlaceVisible); private static readonly int s_uiDead = BitVector32.CreateMask(s_uiActive); private static readonly int s_adjustingRect = BitVector32.CreateMask(s_uiDead); + private static readonly SearchValues s_whitespace = SearchValues.Create(" \r\n"); private static Point s_logPixels = Point.Empty; private static OLEVERB[]? s_axVerbs; @@ -127,7 +129,7 @@ private sealed unsafe partial class ActiveXImpl : MarshalByRefObject, IWindowTar private AgileComPointer? _clientSite; private AgileComPointer? _inPlaceUiWindow; private AgileComPointer? _inPlaceFrame; - private readonly ComPointerList _adviseList = new(); + private AgileComPointer? _adviseHolder; private IAdviseSink* _viewAdviseSink; private BitVector32 _activeXState; private readonly AmbientProperty[] _ambientProperties; @@ -280,18 +282,26 @@ private static Point LogPixels } } - /// - /// Implements IOleObject::Advise - /// - internal unsafe uint Advise(IAdviseSink* pAdvSink) + /// + internal HRESULT Advise(IAdviseSink* pAdvSink, uint* token) { - _adviseList.Add(pAdvSink); - return (uint)_adviseList.Count; + if (_adviseHolder is null) + { + IOleAdviseHolder* holder = null; + HRESULT hr = PInvoke.CreateOleAdviseHolder(&holder); + if (hr.Failed) + { + return hr; + } + + _adviseHolder = new(holder, takeOwnership: true); + } + + using var adviseHolder = _adviseHolder.GetInterface(); + return adviseHolder.Value->Advise(pAdvSink, token); } - /// - /// Implements IOleObject::Close - /// + /// internal void Close(OLECLOSE dwSaveOption) { if (_activeXState[s_inPlaceActive]) @@ -312,9 +322,7 @@ internal void Close(OLECLOSE dwSaveOption) } } - /// - /// Implements IOleObject::DoVerb - /// + /// internal unsafe HRESULT DoVerb( OLEIVERB iVerb, MSG* lpmsg, @@ -346,11 +354,7 @@ internal unsafe HRESULT DoVerb( { // Must translate message coordinates over to our HWND. HWND hwndMap = hwnd.IsNull ? hwndParent : hwnd; - var pt = new Point - { - X = PARAM.LOWORD(lpmsg->lParam), - Y = PARAM.HIWORD(lpmsg->lParam) - }; + Point pt = new(PARAM.LOWORD(lpmsg->lParam), PARAM.HIWORD(lpmsg->lParam)); PInvoke.MapWindowPoints(hwndMap, _control, ref pt); @@ -406,9 +410,7 @@ internal unsafe HRESULT DoVerb( return HRESULT.S_OK; } - /// - /// Implements IViewObject2::Draw. - /// + /// internal HRESULT Draw( DVASPECT dwDrawAspect, int lindex, @@ -501,9 +503,7 @@ internal HRESULT Draw( return HRESULT.S_OK; } - /// - /// Returns a new verb enumerator. - /// + /// internal static IEnumOLEVERB* EnumVerbs() { if (s_axVerbs is null) @@ -531,7 +531,7 @@ internal HRESULT Draw( /// private static byte[] FromBase64WrappedString(string text) { - if (text.IndexOfAny(new char[] { ' ', '\r', '\n' }) != -1) + if (text.AsSpan().ContainsAny(s_whitespace)) { StringBuilder sb = new StringBuilder(text.Length); for (int i = 0; i < text.Length; i++) @@ -556,9 +556,7 @@ private static byte[] FromBase64WrappedString(string text) } } - /// - /// Implements IViewObject2::GetAdvise. - /// + /// internal unsafe HRESULT GetAdvise(DVASPECT* pAspects, ADVF* pAdvf, IAdviseSink** ppAdvSink) { if (pAspects is not null) @@ -584,6 +582,11 @@ internal unsafe HRESULT GetAdvise(DVASPECT* pAspects, ADVF* pAdvf, IAdviseSink** if (ppAdvSink is not null) { *ppAdvSink = _viewAdviseSink; + + if (_viewAdviseSink is not null) + { + _viewAdviseSink->AddRef(); + } } return HRESULT.S_OK; @@ -629,11 +632,10 @@ private VARIANT GetAmbientProperty(int dispid) return property; } - /// - /// Implements IOleObject::GetClientSite. - /// + /// internal ComScope GetClientSite() => _clientSite is null ? default : _clientSite.GetInterface(); + /// internal unsafe HRESULT GetControlInfo(CONTROLINFO* pControlInfo) { if (_accelCount == -1) @@ -719,9 +721,7 @@ internal unsafe HRESULT GetControlInfo(CONTROLINFO* pControlInfo) return HRESULT.S_OK; } - /// - /// Implements IOleObject::GetExtent. - /// + /// internal unsafe void GetExtent(DVASPECT dwDrawAspect, Size* pSizel) { if (!dwDrawAspect.HasFlag(DVASPECT.DVASPECT_CONTENT)) @@ -776,9 +776,7 @@ private string GetStreamName() return streamName; } - /// - /// Implements IOleWindow::GetWindow - /// + /// internal unsafe HRESULT GetWindow(HWND* phwnd) { if (phwnd is null) @@ -810,7 +808,7 @@ private static Point HiMetricToPixel(int x, int y) } /// - /// In place activates this Object. + /// In place activates this object. /// internal unsafe void InPlaceActivate(OLEIVERB verb) { @@ -869,11 +867,8 @@ internal unsafe void InPlaceActivate(OLEIVERB verb) RECT posRect = default; RECT clipRect = default; - _inPlaceUiWindow?.Dispose(); - _inPlaceUiWindow = null; - - _inPlaceFrame?.Dispose(); - _inPlaceFrame = null; + DisposeHelper.NullAndDispose(ref _inPlaceUiWindow); + DisposeHelper.NullAndDispose(ref _inPlaceFrame); IOleInPlaceFrame* pFrame; IOleInPlaceUIWindow* pWindow; @@ -937,14 +932,13 @@ internal unsafe void InPlaceActivate(OLEIVERB verb) // Set ourselves up in the host. Debug.Assert(_inPlaceFrame is not null, "Setting us to visible should have created the in place frame"); - var activeObject = ComHelpers.GetComPointer(_control); + using var activeObject = ComHelpers.GetComScope(_control); using var inPlaceFrame = _inPlaceFrame.GetInterface(); inPlaceFrame.Value->SetActiveObject(activeObject, (PCWSTR)null); using var inPlaceUiWindow = _inPlaceUiWindow is null ? default : _inPlaceUiWindow.GetInterface(); if (_inPlaceUiWindow is not null) { - activeObject->AddRef(); inPlaceUiWindow.Value->SetActiveObject(activeObject, (PCWSTR)null); } @@ -971,9 +965,7 @@ internal unsafe void InPlaceActivate(OLEIVERB verb) } } - /// - /// Implements IOleInPlaceObject::InPlaceDeactivate. - /// + /// internal HRESULT InPlaceDeactivate() { // Only do this if we're already in place active. @@ -1006,18 +998,13 @@ internal HRESULT InPlaceDeactivate() _control.Visible = false; HWNDParent = default; - _inPlaceUiWindow?.Dispose(); - _inPlaceUiWindow = null; - - _inPlaceFrame?.Dispose(); - _inPlaceFrame = null; + DisposeHelper.NullAndDispose(ref _inPlaceUiWindow); + DisposeHelper.NullAndDispose(ref _inPlaceFrame); return HRESULT.S_OK; } - /// - /// Implements IPersistStreamInit::IsDirty. - /// + /// internal HRESULT IsDirty() => _activeXState[s_isDirty] ? HRESULT.S_OK : HRESULT.S_FALSE; /// @@ -1045,9 +1032,7 @@ private bool IsResourceProperty(PropertyDescriptor property) || property.GetValue(_control) is ISerializable; } - /// - /// Implements IPersistStorage::Load - /// + /// internal HRESULT Load(IStorage* stg) { using ComScope stream = new(null); @@ -1076,29 +1061,24 @@ internal HRESULT Load(IStorage* stg) return hr; } - /// - /// Implements IPersistStreamInit::Load - /// + /// internal void Load(IStream* stream) { // We do everything through property bags because we support full fidelity - // in them. So, load through that method. + // in them. So, load through that method. PropertyBagStream bagStream = new(); bagStream.Read(stream); - Load(ComHelpers.GetComPointer(bagStream), errorLog: null); + using var propertyBag = ComHelpers.GetComScope(bagStream); + Load(propertyBag, errorLog: null); } - /// - /// Implements IPersistPropertyBag::Load - /// + /// internal unsafe void Load(IPropertyBag* propertyBag, IErrorLog* errorLog) { PropertyDescriptorCollection props = TypeDescriptor.GetProperties( _control, new Attribute[] { DesignerSerializationVisibilityAttribute.Visible }); - using ComScope scope = new(propertyBag); - for (int i = 0; i < props.Count; i++) { PropertyDescriptor currentProperty = props[i]; @@ -1312,9 +1292,7 @@ private static void CallParentPropertyChanged(Control control, string propName) } } - /// - /// Implements IOleControl::OnAmbientPropertyChanged - /// + /// internal void OnAmbientPropertyChange(int dispID) { if (dispID != PInvoke.DISPID_UNKNOWN) @@ -1369,9 +1347,7 @@ internal void OnAmbientPropertyChange(int dispID) } } - /// - /// Implements IOleInPlaceActiveObject::OnDocWindowActivate. - /// + /// internal void OnDocWindowActivate(BOOL fActivate) { if (_activeXState[s_uiActive] && fActivate && _inPlaceFrame is not null) @@ -1416,9 +1392,7 @@ internal void OnFocus(bool focus) Y = (HiMetricPerInch * y + (LogPixels.Y >> 1)) / LogPixels.Y }; - /// - /// Our implementation of IQuickActivate::QuickActivate - /// + /// internal unsafe HRESULT QuickActivate(QACONTAINER* pQaContainer, QACONTROL* pQaControl) { if (pQaControl is null) @@ -1476,17 +1450,17 @@ internal unsafe HRESULT QuickActivate(QACONTAINER* pQaContainer, QACONTROL* pQaC if ((pQaContainer->pUnkEventSink is not null) && (_control is UserControl)) { // Check if this control exposes events to COM. - Type? eventInterface = GetDefaultEventsInterface(_control.GetType()); - - if (eventInterface is not null) + if (GetDefaultEventsInterface(_control.GetType()) is { } eventInterface) { // Control doesn't explicitly implement IConnectionPointContainer, but it is generated with a CCW by // COM interop. - using var container = ComHelpers.GetComScope(_control); + using var container = ComHelpers.TryGetComScope(_control, out HRESULT hr); + + hr.AssertSuccess(); + using ComScope connectionPoint = new(null); - HRESULT hr = container.Value->FindConnectionPoint(eventInterface.GUID, connectionPoint); - if (hr.Failed) + if (hr.Failed || container.Value->FindConnectionPoint(eventInterface.GUID, connectionPoint).Failed) { throw new ArgumentException(string.Format(SR.AXNoConnectionPoint, eventInterface.Name)); } @@ -1496,43 +1470,27 @@ internal unsafe HRESULT QuickActivate(QACONTAINER* pQaContainer, QACONTROL* pQaC } } - if (pQaContainer->pPropertyNotifySink is not null) - { - pQaContainer->pPropertyNotifySink->Release(); - } + return HRESULT.S_OK; - if (pQaContainer->pUnkEventSink is not null) + // Get the default COM events interface declared on a .NET class. + static Type? GetDefaultEventsInterface(Type controlType) { - pQaContainer->pUnkEventSink->Release(); - } + Type? eventInterface = null; - return HRESULT.S_OK; - } - - /// - /// Return the default COM events interface declared on a .NET class. - /// This looks for the ComSourceInterfacesAttribute and returns the .NET - /// interface type of the first interface declared. - /// - private static Type? GetDefaultEventsInterface(Type controlType) - { - Type? eventInterface = null; - object[] custom = controlType.GetCustomAttributes(typeof(ComSourceInterfacesAttribute), inherit: false); + // Get the first declared interface, if any. + if (controlType.GetCustomAttributes(inherit: false).FirstOrDefault() + is { } comSourceInterfaces) + { + string eventName = comSourceInterfaces.Value.Split('\0')[0]; + eventInterface = controlType.Module.Assembly.GetType(eventName, throwOnError: false); + eventInterface ??= Type.GetType(eventName, throwOnError: false); + } - if (custom.Length > 0) - { - ComSourceInterfacesAttribute coms = (ComSourceInterfacesAttribute)custom[0]; - string eventName = coms.Value.Split('\0')[0]; - eventInterface = controlType.Module.Assembly.GetType(eventName, throwOnError: false); - eventInterface ??= Type.GetType(eventName, throwOnError: false); + return eventInterface; } - - return eventInterface; } - /// - /// Implements IPersistStorage::Save - /// + /// internal HRESULT Save(IStorage* storage, BOOL fSameAsLoad) { using ComScope stream = new(null); @@ -1553,29 +1511,25 @@ internal HRESULT Save(IStorage* storage, BOOL fSameAsLoad) return hr; } - /// - /// Implements IPersistStreamInit::Save - /// + /// internal void Save(IStream* stream, BOOL fClearDirty) { // We do everything through property bags because we support full fidelity in them. // So, save through that method. PropertyBagStream bagStream = new(); - Save(ComHelpers.GetComPointer(bagStream), fClearDirty, saveAllProperties: false); + + using var propertyBag = ComHelpers.GetComScope(bagStream); + Save(propertyBag, fClearDirty, saveAllProperties: false); bagStream.Write(stream); } - /// - /// Implements IPersistPropertyBag::Save. Releases when finished. - /// + /// internal void Save(IPropertyBag* propertyBag, BOOL clearDirty, BOOL saveAllProperties) { PropertyDescriptorCollection props = TypeDescriptor.GetProperties( _control, new Attribute[] { DesignerSerializationVisibilityAttribute.Visible }); - using ComScope scope = new(propertyBag); - for (int i = 0; i < props.Count; i++) { PropertyDescriptor currentProperty = props[i]; @@ -1661,18 +1615,16 @@ internal void Save(IPropertyBag* propertyBag, BOOL clearDirty, BOOL saveAllPrope /// private void SendOnSave() { - int cnt = _adviseList.Count; - for (int i = 0; i < cnt; i++) + if (_adviseHolder is null) { - IAdviseSink* s = _adviseList[i]; - Debug.Assert(s is not null, "NULL in our advise list"); - s->OnSave(); + return; } + + using var holder = _adviseHolder.GetInterface(); + holder.Value->SendOnSave(); } - /// - /// Implements IViewObject2::SetAdvise. - /// + /// internal HRESULT SetAdvise(DVASPECT aspects, ADVF advf, IAdviseSink* pAdvSink) { // If it's not a content aspect, we don't support it. @@ -1685,14 +1637,16 @@ internal HRESULT SetAdvise(DVASPECT aspects, ADVF advf, IAdviseSink* pAdvSink) _activeXState[s_viewAdvisePrimeFirst] = advf.HasFlag(ADVF.ADVF_PRIMEFIRST); _activeXState[s_viewAdviseOnlyOnce] = advf.HasFlag(ADVF.ADVF_ONLYONCE); - if (_viewAdviseSink is not null) + DisposeHelper.NullAndRelease(ref _viewAdviseSink); + + if (pAdvSink is not null) { - _viewAdviseSink->Release(); + pAdvSink->AddRef(); } _viewAdviseSink = pAdvSink; - // prime them if they want it [we need to store this so they can get flags later] + // Prime them if they want it [we need to store this so they can get flags later] if (_activeXState[s_viewAdvisePrimeFirst]) { ViewChanged(); @@ -1701,17 +1655,26 @@ internal HRESULT SetAdvise(DVASPECT aspects, ADVF advf, IAdviseSink* pAdvSink) return HRESULT.S_OK; } - /// - /// Implements IOleObject::SetClientSite. - /// + /// internal void SetClientSite(IOleClientSite* value) { - _clientSite?.Dispose(); - _clientSite = value is null ? null : new(value, takeOwnership: true); + DisposeHelper.NullAndDispose(ref _clientSite); + + if (value is not null) + { + // Callers don't increment the ref count when they pass IOleClientSite, it is up to us to do so as we're + // maintaining a reference to the pointer. Validated this behavior with the ATL/MFC sources. + // + // https://learn.microsoft.com/windows/win32/api/oleidl/nf-oleidl-ioleobject-setclientsite#notes-to-implementers - _control.Site = _clientSite is not null - ? new AxSourcingSite(_control, _clientSite, "ControlAxSourcingSite") - : (ISite?)null; + value->AddRef(); + _clientSite = new(value, takeOwnership: true); + _control.Site = new AxSourcingSite(_control, _clientSite, "ControlAxSourcingSite"); + } + else + { + _control.Site = null; + } // Get the ambient properties that effect us. using VARIANT property = GetAmbientProperty(PInvoke.DISPID_AMBIENT_UIDEAD); @@ -1736,9 +1699,7 @@ internal void SetClientSite(IOleClientSite* value) _control.OnTopMostActiveXParentChanged(EventArgs.Empty); } - /// - /// Implements IOleObject::SetExtent - /// + /// internal unsafe void SetExtent(DVASPECT dwDrawAspect, Size* pSizel) { if (!dwDrawAspect.HasFlag(DVASPECT.DVASPECT_CONTENT)) @@ -1827,9 +1788,7 @@ private void SetInPlaceVisible(bool visible) _control.Visible = visible; } - /// - /// Implements IOleInPlaceObject::SetObjectRects. - /// + /// internal unsafe HRESULT SetObjectRects(RECT* lprcPosRect, RECT* lprcClipRect) { if (lprcPosRect is null || lprcClipRect is null) @@ -1947,9 +1906,7 @@ internal unsafe HRESULT SetObjectRects(RECT* lprcPosRect, RECT* lprcClipRect) [DoesNotReturn] internal static void ThrowHr(HRESULT hr) => throw new ExternalException(SR.ExternalException, (int)hr); - /// - /// Handles IOleControl::TranslateAccelerator - /// + /// internal unsafe HRESULT TranslateAccelerator(MSG* lpmsg) { if (lpmsg is null) @@ -1970,7 +1927,7 @@ internal unsafe HRESULT TranslateAccelerator(MSG* lpmsg) Debug.WriteLine($"AxSource: TranslateAccelerator : {m}"); } } -#endif // DEBUG +#endif bool needPreProcess = false; switch (lpmsg->message) @@ -2054,9 +2011,7 @@ internal unsafe HRESULT TranslateAccelerator(MSG* lpmsg) return controlSite.Value->TranslateAccelerator(lpmsg, keyState); } - /// - /// Implements IOleInPlaceObject::UIDeactivate. - /// + /// internal HRESULT UIDeactivate() { // Only do this if we're UI active @@ -2088,27 +2043,23 @@ internal HRESULT UIDeactivate() using var inPlaceSite = _clientSite.TryGetInterface(out HRESULT hr); if (hr.Succeeded) { - inPlaceSite.Value->OnUIDeactivate(BOOL.FALSE); + inPlaceSite.Value->OnUIDeactivate(fUndoable: BOOL.FALSE); } } return HRESULT.S_OK; } - /// - /// Implements IOleObject::Unadvise - /// + /// internal HRESULT Unadvise(uint dwConnection) { - if (dwConnection > _adviseList.Count || _adviseList[(int)dwConnection - 1] is null) + if (_adviseHolder is null) { - return HRESULT.OLE_E_NOCONNECTION; + return HRESULT.E_FAIL; } - IAdviseSink* sink = _adviseList[(int)dwConnection - 1]; - _adviseList.RemoveAt((int)dwConnection - 1); - sink->Release(); - return HRESULT.S_OK; + using var holder = _adviseHolder.GetInterface(); + return holder.Value->Unadvise(dwConnection); } /// @@ -2223,8 +2174,7 @@ private void ViewChanged() if (_activeXState[s_viewAdviseOnlyOnce]) { - _viewAdviseSink->Release(); - _viewAdviseSink = null; + DisposeHelper.NullAndRelease(ref _viewAdviseSink); } } @@ -2261,12 +2211,14 @@ void IWindowTarget.OnMessage(ref Message m) public void Dispose() { - _inPlaceFrame?.Dispose(); - _inPlaceFrame = null; - _inPlaceUiWindow?.Dispose(); - _inPlaceUiWindow = null; - _clientSite?.Dispose(); - _clientSite = null; + // Disposing the client site handle can get us called back with SetClientSite(null). We need to + // make sure that we clear the field before disposing it. To avoid similar problems, we do the same + // pattern for every COM pointer. + + DisposeHelper.NullAndDispose(ref _inPlaceFrame); + DisposeHelper.NullAndDispose(ref _inPlaceUiWindow); + DisposeHelper.NullAndDispose(ref _clientSite); + DisposeHelper.NullAndDispose(ref _adviseHolder); } } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXVerbEnum.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXVerbEnum.cs index 04ae05bb722..189abcff75b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXVerbEnum.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXVerbEnum.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #if DEBUG using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.AmbientProperty.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.AmbientProperty.cs index 3c263558ef6..4d6a30dfc38 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.AmbientProperty.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.AmbientProperty.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.Annotated.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.Annotated.cs index 9ca2c34a47a..72b3b06c55b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.Annotated.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.Annotated.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.AxSourcingSite.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.AxSourcingSite.cs index 1518f3ccff7..ac65dccbb94 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.AxSourcingSite.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.AxSourcingSite.cs @@ -1,9 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; -using System.Runtime.InteropServices; +using Windows.Win32.System.Com; using Windows.Win32.System.Ole; using static Interop; @@ -42,7 +41,7 @@ internal AxSourcingSite(IComponent component, AgileComPointer cl using ComScope container = new(null); clientSite.Value->GetContainer(container); - if (Marshal.GetObjectForIUnknown((nint)container) is Mshtml.IHTMLDocument document) + if (ComHelpers.GetObjectForIUnknown((IUnknown*)container) is Mshtml.IHTMLDocument document) { _shimManager ??= new HtmlShimManager(); return new HtmlDocument(_shimManager, document); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlAccessibleObject.cs index 92dba3aa392..81eaf1d40ce 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; @@ -133,11 +132,11 @@ internal override bool GetSysChild(AccessibleNavigation navdir, out AccessibleOb // Get the owning control's parent, if it has one Control? parentControl = owner.ParentInternal; - // ctrls[index] will indicate the control at the destination of this navigation operation + // ctrls[index] will indicate the control at the destination of this navigation operation. int index = -1; Control[]? ctrls = null; - // Now handle any 'appropriate' navigation requests... + // Now handle any 'appropriate' navigation requests. switch (navdir) { case AccessibleNavigation.FirstChild: @@ -497,7 +496,7 @@ UiaCore.UIA.IsKeyboardFocusablePropertyId when UiaCore.UIA.LiveSettingPropertyId => Owner is IAutomationLiveRegion owner ? owner.LiveSetting : base.GetPropertyValue(propertyID), - UiaCore.UIA.NativeWindowHandlePropertyId => Owner?.InternalHandle ?? HWND.Null, + UiaCore.UIA.NativeWindowHandlePropertyId => (nint)(Owner?.InternalHandle ?? HWND.Null), _ => base.GetPropertyValue(propertyID) }; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlCollection.ControlCollectionEnumerator.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlCollection.ControlCollectionEnumerator.cs index d2267a05078..d14248a42ea 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlCollection.ControlCollectionEnumerator.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlCollection.ControlCollectionEnumerator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlCollection.cs index ac8e0642d6c..02f308c3846 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -149,7 +148,7 @@ int IList.Add(object? control) } [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public virtual void AddRange(Control[] controls) + public virtual void AddRange(params Control[] controls) { ArgumentNullException.ThrowIfNull(controls); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlNativeWindow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlNativeWindow.cs index 64647829009..2769ffe12b4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlNativeWindow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlNativeWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlTabOrderComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlTabOrderComparer.cs index 089cfa44b58..22aa3025c08 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlTabOrderComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlTabOrderComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -11,17 +10,24 @@ public partial class Control /// private class ControlTabOrderComparer : IComparer { - public int Compare(ControlTabOrderHolder? x, ControlTabOrderHolder? y) + private ControlTabOrderComparer() { } + + internal static ControlTabOrderComparer Instance { get; } = new(); + + public int Compare(ControlTabOrderHolder x, ControlTabOrderHolder y) { if (IComparerHelpers.CompareReturnIfNull(x, y, out int? returnValue)) { return (int)returnValue; } - int delta = x._newOrder - y._newOrder; + // If there is a specified tab index, use it for comparison, otherwise use the original index (which + // would be the index in the control collection or how Windows returns children using GW_HWNDNEXT from + // GW_HWNDCHILD). + int delta = x.TabIndex - y.TabIndex; if (delta == 0) { - delta = x._oldOrder - y._oldOrder; + delta = x.OriginalIndex - y.OriginalIndex; } return delta; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlTabOrderHolder.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlTabOrderHolder.cs index 837c1e4caa5..86ac1f51b5b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlTabOrderHolder.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlTabOrderHolder.cs @@ -1,27 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; public partial class Control { /// - /// This class contains a control and associates it with a z-order. - /// This is used when sorting controls based on tab index first, - /// z-order second. + /// This record contains a control and associates it with a z-order. + /// This is used when sorting controls based on tab index first, z-order second. /// - private class ControlTabOrderHolder + private readonly record struct ControlTabOrderHolder(int OriginalIndex, int TabIndex, Control? Control) { - internal readonly int _oldOrder; - internal readonly int _newOrder; - internal readonly Control? _control; - - internal ControlTabOrderHolder(int oldOrder, int newOrder, Control? control) - { - _oldOrder = oldOrder; - _newOrder = newOrder; - _control = control; - } } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlVersionInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlVersionInfo.cs index e68b684cb9c..303e62df10f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlVersionInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlVersionInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ExtendedStates.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ExtendedStates.cs index db71c7322a5..30580b04bf0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ExtendedStates.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ExtendedStates.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.FontHandleWrapper.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.FontHandleWrapper.cs index f2cc1f3e5c5..c71e4b0d464 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.FontHandleWrapper.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.FontHandleWrapper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.Ime.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.Ime.cs index 569886396f9..63c2c021b37 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.Ime.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.Ime.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using Windows.Win32.Globalization; @@ -1254,8 +1253,8 @@ public static void SetImeStatus(ImeMode imeMode, IntPtr handle) PInvoke.ImmGetConversionStatus(inputContext, &conversion, &sentence); } - conversion |= conversionEntry.setBits; - conversion &= ~conversionEntry.clearBits; + conversion |= conversionEntry.SetBits; + conversion &= ~conversionEntry.ClearBits; Debug.WriteLineIf(CompModSwitches.ImeMode.Level >= TraceLevel.Verbose, $"ImmSetConversionStatus({inputContext}, conversion, sentence)"); PInvoke.ImmSetConversionStatus(inputContext, conversion, sentence); @@ -1311,12 +1310,12 @@ public static void SetOpenStatus(bool open, IntPtr handle) /// Helper class that provides information about IME conversion mode. Conversion mode refers to how IME interprets input like /// ALPHANUMERIC or HIRAGANA and depending on its value the IME enables/disables the IME conversion window appropriately. /// -public struct ImeModeConversion +public readonly struct ImeModeConversion { - private static Dictionary? imeModeConversionBits; + private static volatile Dictionary? s_imeModeConversionBits; - internal IME_CONVERSION_MODE setBits; - internal IME_CONVERSION_MODE clearBits; + internal IME_CONVERSION_MODE SetBits { get; init; } + internal IME_CONVERSION_MODE ClearBits { get; init; } // Tables of conversions from IME context bits to IME mode // @@ -1457,65 +1456,88 @@ internal static ImeMode[] InputLanguageTable /// public static Dictionary ImeModeConversionBits { - get + get => s_imeModeConversionBits ??= new(7) { - if (imeModeConversionBits is null) + // Hiragana, On { - // Create ImeModeConversionBits dictionary - imeModeConversionBits = new Dictionary(7); - ImeModeConversion conversion; - - // Hiragana, On - // - conversion.setBits = IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE | IME_CONVERSION_MODE.IME_CMODE_NATIVE; - conversion.clearBits = IME_CONVERSION_MODE.IME_CMODE_KATAKANA; - imeModeConversionBits.Add(ImeMode.Hiragana, conversion); - - // Katakana - // - conversion.setBits = IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE | IME_CONVERSION_MODE.IME_CMODE_KATAKANA | IME_CONVERSION_MODE.IME_CMODE_NATIVE; - conversion.clearBits = 0; - imeModeConversionBits.Add(ImeMode.Katakana, conversion); - - // KatakanaHalf - // - conversion.setBits = IME_CONVERSION_MODE.IME_CMODE_KATAKANA | IME_CONVERSION_MODE.IME_CMODE_NATIVE; - conversion.clearBits = IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE; - imeModeConversionBits.Add(ImeMode.KatakanaHalf, conversion); - - // AlphaFull - // - conversion.setBits = IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE; - conversion.clearBits = IME_CONVERSION_MODE.IME_CMODE_KATAKANA | IME_CONVERSION_MODE.IME_CMODE_NATIVE; - imeModeConversionBits.Add(ImeMode.AlphaFull, conversion); - - // Alpha - // - conversion.setBits = 0; - conversion.clearBits = IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE | IME_CONVERSION_MODE.IME_CMODE_KATAKANA | IME_CONVERSION_MODE.IME_CMODE_NATIVE; - imeModeConversionBits.Add(ImeMode.Alpha, conversion); - - // HangulFull - // - conversion.setBits = IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE | IME_CONVERSION_MODE.IME_CMODE_NATIVE; - conversion.clearBits = 0; - imeModeConversionBits.Add(ImeMode.HangulFull, conversion); - - // Hangul - // - conversion.setBits = IME_CONVERSION_MODE.IME_CMODE_NATIVE; - conversion.clearBits = IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE; - imeModeConversionBits.Add(ImeMode.Hangul, conversion); - - // OnHalf - // - conversion.setBits = IME_CONVERSION_MODE.IME_CMODE_NATIVE; - conversion.clearBits = IME_CONVERSION_MODE.IME_CMODE_KATAKANA | IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE; - imeModeConversionBits.Add(ImeMode.OnHalf, conversion); - } + ImeMode.Hiragana, + new() + { + SetBits = IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE | IME_CONVERSION_MODE.IME_CMODE_NATIVE, + ClearBits = IME_CONVERSION_MODE.IME_CMODE_KATAKANA + } + }, - return imeModeConversionBits; - } + // Katakana + { + ImeMode.Katakana, + new() + { + SetBits = IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE | IME_CONVERSION_MODE.IME_CMODE_KATAKANA | IME_CONVERSION_MODE.IME_CMODE_NATIVE, + ClearBits = 0 + } + }, + + // KatakanaHalf + { + ImeMode.KatakanaHalf, + new() + { + SetBits = IME_CONVERSION_MODE.IME_CMODE_KATAKANA | IME_CONVERSION_MODE.IME_CMODE_NATIVE, + ClearBits = IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE + } + }, + + // AlphaFull + { + ImeMode.AlphaFull, + new() + { + SetBits = IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE, + ClearBits = IME_CONVERSION_MODE.IME_CMODE_KATAKANA | IME_CONVERSION_MODE.IME_CMODE_NATIVE + } + }, + + // Alpha + { + ImeMode.Alpha, + new() + { + SetBits = 0, + ClearBits = IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE | IME_CONVERSION_MODE.IME_CMODE_KATAKANA | IME_CONVERSION_MODE.IME_CMODE_NATIVE + } + }, + + // HangulFull + { + ImeMode.HangulFull, + new() + { + SetBits = IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE | IME_CONVERSION_MODE.IME_CMODE_NATIVE, + ClearBits = 0 + } + }, + + // Hangul + { + ImeMode.Hangul, + new() + { + SetBits = IME_CONVERSION_MODE.IME_CMODE_NATIVE, + ClearBits = IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE + } + }, + + // OnHalf + { + ImeMode.OnHalf, + new() + { + SetBits = IME_CONVERSION_MODE.IME_CMODE_NATIVE, + ClearBits = IME_CONVERSION_MODE.IME_CMODE_KATAKANA | IME_CONVERSION_MODE.IME_CMODE_FULLSHAPE + } + } + }; } public static bool IsCurrentConversionTableSupported diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.MetafileDCWrapper.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.MetafileDCWrapper.cs index 0a14c8f1636..ac6b803092c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.MetafileDCWrapper.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.MetafileDCWrapper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.MultithreadSafeCallScope.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.MultithreadSafeCallScope.cs index 1b53d1ebcfa..51ffbfe89a4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.MultithreadSafeCallScope.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.MultithreadSafeCallScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.PrintPaintEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.PrintPaintEventArgs.cs index 03fa4d3bae5..aaaac46beb7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.PrintPaintEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.PrintPaintEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.States.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.States.cs index d62c3fb2bd6..f23ab2dfa83 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.States.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.States.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ThreadMethodEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ThreadMethodEntry.cs index 30f8bf9000e..3bb54189fa9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ThreadMethodEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ThreadMethodEntry.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -19,7 +18,7 @@ private class ThreadMethodEntry : IAsyncResult internal Exception? _exception; internal bool _synchronous; private ManualResetEvent? _resetEvent; - private readonly object _invokeSyncObject = new object(); + private readonly object _invokeSyncObject = new(); // Store the execution context associated with the caller thread, and // information about which thread actually got the stack applied to it. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.UICuesStates.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.UICuesStates.cs index 5d08b2379b5..1c7aa42a0a4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.UICuesStates.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.UICuesStates.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs index ead40be032d..d90366ec2bc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; @@ -126,76 +125,76 @@ private protected void TraceCanProcessMnemonic() private static readonly uint WM_GETCONTROLNAME = PInvoke.RegisterWindowMessage("WM_GETCONTROLNAME"); private static readonly uint WM_GETCONTROLTYPE = PInvoke.RegisterWindowMessage("WM_GETCONTROLTYPE"); - private static readonly object s_autoSizeChangedEvent = new object(); - private static readonly object s_keyDownEvent = new object(); - private static readonly object s_keyPressEvent = new object(); - private static readonly object s_keyUpEvent = new object(); - private static readonly object s_mouseDownEvent = new object(); - private static readonly object s_mouseEnterEvent = new object(); - private static readonly object s_mouseLeaveEvent = new object(); - private static readonly object s_dpiChangedBeforeParentEvent = new object(); - private static readonly object s_dpiChangedAfterParentEvent = new object(); - private static readonly object s_mouseHoverEvent = new object(); - private static readonly object s_mouseMoveEvent = new object(); - private static readonly object s_mouseUpEvent = new object(); - private static readonly object s_mouseWheelEvent = new object(); - private static readonly object s_clickEvent = new object(); - private static readonly object s_clientSizeEvent = new object(); - private static readonly object s_doubleClickEvent = new object(); - private static readonly object s_mouseClickEvent = new object(); - private static readonly object s_mouseDoubleClickEvent = new object(); - private static readonly object s_mouseCaptureChangedEvent = new object(); - private static readonly object s_moveEvent = new object(); - private static readonly object s_resizeEvent = new object(); - private static readonly object s_layoutEvent = new object(); - private static readonly object s_gotFocusEvent = new object(); - private static readonly object s_lostFocusEvent = new object(); - private static readonly object s_enterEvent = new object(); - private static readonly object s_leaveEvent = new object(); - private static readonly object s_handleCreatedEvent = new object(); - private static readonly object s_handleDestroyedEvent = new object(); - private static readonly object s_controlAddedEvent = new object(); - private static readonly object s_controlRemovedEvent = new object(); - private static readonly object s_changeUICuesEvent = new object(); - private static readonly object s_systemColorsChangedEvent = new object(); - private static readonly object s_validatingEvent = new object(); - private static readonly object s_validatedEvent = new object(); - private static readonly object s_styleChangedEvent = new object(); - private static readonly object s_imeModeChangedEvent = new object(); - private static readonly object s_helpRequestedEvent = new object(); - private static readonly object s_paintEvent = new object(); - private static readonly object s_invalidatedEvent = new object(); - private static readonly object s_queryContinueDragEvent = new object(); - private static readonly object s_giveFeedbackEvent = new object(); - private static readonly object s_dragEnterEvent = new object(); - private static readonly object s_dragLeaveEvent = new object(); - private static readonly object s_dragOverEvent = new object(); - private static readonly object s_dragDropEvent = new object(); - private static readonly object s_queryAccessibilityHelpEvent = new object(); - private static readonly object s_backgroundImageEvent = new object(); - private static readonly object s_backgroundImageLayoutEvent = new object(); - private static readonly object s_bindingContextEvent = new object(); - private static readonly object s_backColorEvent = new object(); - private static readonly object s_parentEvent = new object(); - private static readonly object s_visibleEvent = new object(); - private static readonly object s_textEvent = new object(); - private static readonly object s_tabStopEvent = new object(); - private static readonly object s_tabIndexEvent = new object(); - private static readonly object s_sizeEvent = new object(); - private static readonly object s_rightToLeftEvent = new object(); - private static readonly object s_locationEvent = new object(); - private static readonly object s_foreColorEvent = new object(); - private static readonly object s_fontEvent = new object(); - private static readonly object s_enabledEvent = new object(); - private static readonly object s_dockEvent = new object(); - private static readonly object s_cursorEvent = new object(); - private static readonly object s_contextMenuStripEvent = new object(); - private static readonly object s_causesValidationEvent = new object(); - private static readonly object s_regionChangedEvent = new object(); - private static readonly object s_marginChangedEvent = new object(); - private protected static readonly object s_paddingChangedEvent = new object(); - private static readonly object s_previewKeyDownEvent = new object(); - private static readonly object s_dataContextEvent = new object(); + private static readonly object s_autoSizeChangedEvent = new(); + private static readonly object s_keyDownEvent = new(); + private static readonly object s_keyPressEvent = new(); + private static readonly object s_keyUpEvent = new(); + private static readonly object s_mouseDownEvent = new(); + private static readonly object s_mouseEnterEvent = new(); + private static readonly object s_mouseLeaveEvent = new(); + private static readonly object s_dpiChangedBeforeParentEvent = new(); + private static readonly object s_dpiChangedAfterParentEvent = new(); + private static readonly object s_mouseHoverEvent = new(); + private static readonly object s_mouseMoveEvent = new(); + private static readonly object s_mouseUpEvent = new(); + private static readonly object s_mouseWheelEvent = new(); + private static readonly object s_clickEvent = new(); + private static readonly object s_clientSizeEvent = new(); + private static readonly object s_doubleClickEvent = new(); + private static readonly object s_mouseClickEvent = new(); + private static readonly object s_mouseDoubleClickEvent = new(); + private static readonly object s_mouseCaptureChangedEvent = new(); + private static readonly object s_moveEvent = new(); + private static readonly object s_resizeEvent = new(); + private static readonly object s_layoutEvent = new(); + private static readonly object s_gotFocusEvent = new(); + private static readonly object s_lostFocusEvent = new(); + private static readonly object s_enterEvent = new(); + private static readonly object s_leaveEvent = new(); + private static readonly object s_handleCreatedEvent = new(); + private static readonly object s_handleDestroyedEvent = new(); + private static readonly object s_controlAddedEvent = new(); + private static readonly object s_controlRemovedEvent = new(); + private static readonly object s_changeUICuesEvent = new(); + private static readonly object s_systemColorsChangedEvent = new(); + private static readonly object s_validatingEvent = new(); + private static readonly object s_validatedEvent = new(); + private static readonly object s_styleChangedEvent = new(); + private static readonly object s_imeModeChangedEvent = new(); + private static readonly object s_helpRequestedEvent = new(); + private static readonly object s_paintEvent = new(); + private static readonly object s_invalidatedEvent = new(); + private static readonly object s_queryContinueDragEvent = new(); + private static readonly object s_giveFeedbackEvent = new(); + private static readonly object s_dragEnterEvent = new(); + private static readonly object s_dragLeaveEvent = new(); + private static readonly object s_dragOverEvent = new(); + private static readonly object s_dragDropEvent = new(); + private static readonly object s_queryAccessibilityHelpEvent = new(); + private static readonly object s_backgroundImageEvent = new(); + private static readonly object s_backgroundImageLayoutEvent = new(); + private static readonly object s_bindingContextEvent = new(); + private static readonly object s_backColorEvent = new(); + private static readonly object s_parentEvent = new(); + private static readonly object s_visibleEvent = new(); + private static readonly object s_textEvent = new(); + private static readonly object s_tabStopEvent = new(); + private static readonly object s_tabIndexEvent = new(); + private static readonly object s_sizeEvent = new(); + private static readonly object s_rightToLeftEvent = new(); + private static readonly object s_locationEvent = new(); + private static readonly object s_foreColorEvent = new(); + private static readonly object s_fontEvent = new(); + private static readonly object s_enabledEvent = new(); + private static readonly object s_dockEvent = new(); + private static readonly object s_cursorEvent = new(); + private static readonly object s_contextMenuStripEvent = new(); + private static readonly object s_causesValidationEvent = new(); + private static readonly object s_regionChangedEvent = new(); + private static readonly object s_marginChangedEvent = new(); + private protected static readonly object s_paddingChangedEvent = new(); + private static readonly object s_previewKeyDownEvent = new(); + private static readonly object s_dataContextEvent = new(); private static MessageId s_threadCallbackMessage; private static ContextCallback? s_invokeMarshaledCallbackHelperDelegate; @@ -4914,7 +4913,7 @@ protected virtual void CreateHandle() public void CreateControl() { bool controlIsAlreadyCreated = Created; - CreateControl(false); + CreateControl(ignoreVisible: false); if (!Properties.ContainsObjectThatIsNotNull(s_bindingManagerProperty) && ParentInternal is not null && !controlIsAlreadyCreated) { @@ -5267,7 +5266,7 @@ public void DrawToBitmap(Bitmap bitmap, Rectangle targetBounds) using Bitmap image = new Bitmap(width, height, bitmap.PixelFormat); using Graphics g = Graphics.FromImage(image); - using var hDc = new DeviceContextHdcScope(g, applyGraphicsState: false); + using DeviceContextHdcScope hDc = new(g, applyGraphicsState: false); // Send the WM_PRINT message. PInvoke.SendMessage( @@ -5278,7 +5277,7 @@ public void DrawToBitmap(Bitmap bitmap, Rectangle targetBounds) // Now BLT the result to the destination bitmap. using Graphics destGraphics = Graphics.FromImage(bitmap); - using var desthDC = new DeviceContextHdcScope(destGraphics, applyGraphicsState: false); + using DeviceContextHdcScope desthDC = new(destGraphics, applyGraphicsState: false); PInvoke.BitBlt( desthDC, targetBounds.X, @@ -5784,12 +5783,12 @@ private int[] GetChildWindowsInTabOrder() holders.Add(new ControlTabOrderHolder(holders.Count, tabIndex, ctl)); } - holders.Sort(new ControlTabOrderComparer()); + holders.Sort(ControlTabOrderComparer.Instance); int[] indexes = new int[holders.Count]; for (int i = 0; i < holders.Count; i++) { - indexes[i] = holders[i]._oldOrder; + indexes[i] = holders[i].OriginalIndex; } return indexes; @@ -5803,7 +5802,7 @@ private int[] GetChildWindowsInTabOrder() /// internal Control[] GetChildControlsInTabOrder(bool handleCreatedOnly) { - List holders = new List(); + List holders = new(Controls.Count); foreach (Control c in Controls) { @@ -5813,44 +5812,46 @@ internal Control[] GetChildControlsInTabOrder(bool handleCreatedOnly) } } - holders.Sort(new ControlTabOrderComparer()); + holders.Sort(ControlTabOrderComparer.Instance); - Control[] ctls = new Control[holders.Count]; + Control[] controls = new Control[holders.Count]; for (int i = 0; i < holders.Count; i++) { - ctls[i] = holders[i]._control!; + controls[i] = holders[i].Control!; } - return ctls; + return controls; } internal virtual Control? GetFirstChildControlInTabOrder(bool forward) { - ControlCollection? ctlControls = (ControlCollection?)Properties.GetObject(s_controlsCollectionProperty); + ControlCollection? controls = (ControlCollection?)Properties.GetObject(s_controlsCollectionProperty); + + if (controls is null) + { + return null; + } Control? found = null; - if (ctlControls is not null) + if (forward) { - if (forward) + for (int c = 0; c < controls.Count; c++) { - for (int c = 0; c < ctlControls.Count; c++) + if (found is null || found._tabIndex > controls[c]._tabIndex) { - if (found is null || found._tabIndex > ctlControls[c]._tabIndex) - { - found = ctlControls[c]; - } + found = controls[c]; } } - else + } + else + { + // Cycle through the controls in reverse z-order looking for the one with the highest + // tab index. + for (int c = controls.Count - 1; c >= 0; c--) { - // Cycle through the controls in reverse z-order looking for the one with the highest - // tab index. - for (int c = ctlControls.Count - 1; c >= 0; c--) + if (found is null || found._tabIndex < controls[c]._tabIndex) { - if (found is null || found._tabIndex < ctlControls[c]._tabIndex) - { - found = ctlControls[c]; - } + found = controls[c]; } } } @@ -5919,11 +5920,11 @@ private protected virtual IList GetNeighboringToolsRectangles() if (forward) { - ControlCollection? ctlControls = (ControlCollection?)ctl!.Properties.GetObject(s_controlsCollectionProperty); + ControlCollection? controls = (ControlCollection?)ctl!.Properties.GetObject(s_controlsCollectionProperty); - if (ctlControls is not null && ctlControls.Count > 0 && (ctl == this || !IsFocusManagingContainerControl(ctl))) + if (controls is not null && controls.Count > 0 && (ctl == this || !IsFocusManagingContainerControl(ctl))) { - Control? found = ctl.GetFirstChildControlInTabOrder(/*forward=*/true); + Control? found = ctl.GetFirstChildControlInTabOrder(forward: true); if (found is not null) { return found; @@ -6241,7 +6242,7 @@ public unsafe void Invalidate(Region? region, bool invalidateChildren) else if (IsHandleCreated) { using Graphics graphics = CreateGraphicsInternal(); - using var regionHandle = new PInvoke.RegionScope(region, graphics); + using PInvoke.RegionScope regionHandle = new(region, graphics); if (invalidateChildren) { @@ -7282,7 +7283,6 @@ private protected virtual void OnFrameWindowActivate(bool fActivate) [EditorBrowsable(EditorBrowsableState.Advanced)] protected virtual void OnFontChanged(EventArgs e) { - // bail if disposing if (GetAnyDisposingInHierarchy()) { return; @@ -7295,7 +7295,7 @@ protected virtual void OnFontChanged(EventArgs e) Properties.SetInteger(s_fontHeightProperty, -1); } - // Cleanup any font handle wrapper... + // Cleanup any font handle wrapper. DisposeFontHandle(); if (IsHandleCreated) @@ -7597,8 +7597,8 @@ protected virtual void OnPrint(PaintEventArgs e) { uint flags = PInvoke.PRF_CHILDREN | PInvoke.PRF_CLIENT | PInvoke.PRF_ERASEBKGND | PInvoke.PRF_NONCLIENT; - using var hdc = new DeviceContextHdcScope(e); - Message m = Message.Create(HWND, (uint)PInvoke.WM_PRINTCLIENT, (WPARAM)hdc, (LPARAM)flags); + using DeviceContextHdcScope hdc = new DeviceContextHdcScope(e); + Message m = Message.Create(HWND, PInvoke.WM_PRINTCLIENT, (WPARAM)hdc, (LPARAM)flags); DefWndProc(ref m); } else @@ -8725,7 +8725,7 @@ internal unsafe void PaintTransparentBackground(PaintEventArgs e, Rectangle rect if (transparentRegion is not null) { Graphics g = e.GraphicsInternal; - using var saveState = new GraphicsStateScope(g); + using GraphicsStateScope saveState = new(g); g.Clip = transparentRegion; ButtonRenderer.DrawParentBackground(g, rectangle, this); } @@ -8756,7 +8756,7 @@ internal unsafe void PaintTransparentBackground(PaintEventArgs e, Rectangle rect if (transparentRegion is not null) { - using var saveState = new GraphicsStateScope(newArgs.Graphics); + using GraphicsStateScope saveState = new GraphicsStateScope(newArgs.Graphics); // Is this clipping something we can apply directly to the HDC? newArgs.Graphics.Clip = transparentRegion; @@ -9520,22 +9520,25 @@ protected virtual bool ProcessKeyPreview(ref Message m) } /// - /// Processes a mnemonic character. This method is called to give a control - /// the opportunity to process a mnemonic character. The method should check - /// if the control is in a state to process mnemonics and if the given - /// character represents a mnemonic. If so, the method should perform the - /// action associated with the mnemonic and return true. If not, the method - /// should return false. - /// Implementations of this method often use the isMnemonic() method to - /// check if the given character matches a mnemonic in the control's text, - /// for example: - /// - /// if (canSelect() && isMnemonic(charCode, getText()) { - /// // perform action associated with mnemonic - /// } - /// - /// This default implementation of processMnemonic() simply returns false - /// to indicate that the control has no mnemonic. + /// + /// Processes a mnemonic character. This method is called to give a control + /// the opportunity to process a mnemonic character. The method should check + /// if the control is in a state to process mnemonics and if the given + /// character represents a mnemonic. If so, the method should perform the + /// action associated with the mnemonic and return . + /// If not, the method should return . + /// + /// + /// Implementations of this method often use the isMnemonic() method to + /// check if the given character matches a mnemonic in the control's text, + /// for example: + /// + /// + /// if (CanSelect() && IsMnemonic(charCode, GetText()) + /// { + /// // Perform action associated with mnemonic... + /// } + /// /// protected internal virtual bool ProcessMnemonic(char charCode) { @@ -11428,7 +11431,7 @@ public void Update() [EditorBrowsable(EditorBrowsableState.Advanced)] protected internal void UpdateBounds() { - RECT rect = default(RECT); + RECT rect = default; int clientWidth = 0; int clientHeight = 0; @@ -12605,7 +12608,7 @@ private void WmQueryNewPalette(ref Message m) { s_paletteTracing.TraceVerbose($"{Handle}: WM_QUERYNEWPALETTE"); - using var dc = new GetDcScope(HWND); + using GetDcScope dc = new(HWND); // We don't want to unset the palette in this case so we don't do this in a using var paletteScope = PInvoke.SelectPaletteScope.HalftonePalette( diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ControlBindingsCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ControlBindingsCollection.cs index f25b2fd36a8..307ab672bef 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ControlBindingsCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ControlBindingsCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -89,7 +88,7 @@ public Binding Add(string propertyName, object dataSource, string dataMember, bo { ArgumentNullException.ThrowIfNull(dataSource); - var binding = new Binding(propertyName, dataSource, dataMember, formattingEnabled, updateMode, nullValue, formatString, formatInfo); + Binding binding = new(propertyName, dataSource, dataMember, formattingEnabled, updateMode, nullValue, formatString, formatInfo); Add(binding); return binding; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ControlEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ControlEventArgs.cs index 16b6f1e0d6e..13f2dd372b6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ControlEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ControlEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ControlEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ControlEventHandler.cs index 11c82896a90..e7298a8b14e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ControlEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ControlEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ControlPaint.HLSColor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ControlPaint.HLSColor.cs index eed417a6aec..1396db75bcc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ControlPaint.HLSColor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ControlPaint.HLSColor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ControlPaint.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ControlPaint.cs index db36c19561c..e920050cc25 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ControlPaint.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ControlPaint.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -581,14 +580,10 @@ internal static unsafe void DrawBorder( Color bottomColor, int bottomWidth, ButtonBorderStyle bottomStyle) { // Very general, and very slow - if (leftWidth < 0) - throw new ArgumentOutOfRangeException(nameof(leftWidth)); - if (topWidth < 0) - throw new ArgumentOutOfRangeException(nameof(topWidth)); - if (rightWidth < 0) - throw new ArgumentOutOfRangeException(nameof(rightWidth)); - if (bottomWidth < 0) - throw new ArgumentOutOfRangeException(nameof(bottomWidth)); + ArgumentOutOfRangeException.ThrowIfNegative(leftWidth); + ArgumentOutOfRangeException.ThrowIfNegative(topWidth); + ArgumentOutOfRangeException.ThrowIfNegative(rightWidth); + ArgumentOutOfRangeException.ThrowIfNegative(bottomWidth); int totalData = (topWidth + leftWidth + bottomWidth + rightWidth) * 2; Span allData; @@ -773,7 +768,7 @@ internal static unsafe void DrawBorder( { HLSColor hlsColor = new HLSColor(topColor); float inc = InfinityToOne(1.0f / (topWidth - 1)); - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); for (int i = 0; i < topWidth; i++) { using PInvoke.CreatePenScope hpen = new( @@ -836,7 +831,7 @@ internal static unsafe void DrawBorder( { HLSColor hlsColor = new HLSColor(leftColor); float inc = InfinityToOne(1.0f / (leftWidth - 1)); - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); for (int i = 0; i < leftWidth; i++) { using PInvoke.CreatePenScope hpen = new( @@ -1081,7 +1076,7 @@ public static void DrawBorder3D(Graphics graphics, int x, int y, int width, int } // Get Win32 dc with Graphics properties applied to it. - using var hdc = new DeviceContextHdcScope(graphics); + using DeviceContextHdcScope hdc = new(graphics); PInvoke.DrawEdge(hdc, ref rc, edge, flags); } @@ -1409,7 +1404,7 @@ private static void DrawFlatCheckBox( using (Graphics g2 = Graphics.FromImage(bitmap)) { g2.Clear(Color.Transparent); - using var dc = new DeviceContextHdcScope(g2, applyGraphicsState: false); + using DeviceContextHdcScope dc = new(g2, applyGraphicsState: false); PInvoke.DrawFrameControl(dc, ref rcCheck, DFC_TYPE.DFC_MENU, DFCS_STATE.DFCS_MENUCHECK); } @@ -1472,17 +1467,15 @@ private static void DrawFrameControl( Color backColor) { ArgumentNullException.ThrowIfNull(graphics); - if (width < 0) - throw new ArgumentOutOfRangeException(nameof(width)); - if (height < 0) - throw new ArgumentOutOfRangeException(nameof(height)); + ArgumentOutOfRangeException.ThrowIfNegative(width); + ArgumentOutOfRangeException.ThrowIfNegative(height); RECT rcFrame = new RECT(0, 0, width, height); using Bitmap bitmap = new Bitmap(width, height); using Graphics g2 = Graphics.FromImage(bitmap); g2.Clear(Color.Transparent); - using (var hdc = new DeviceContextHdcScope(g2, applyGraphicsState: false)) + using (DeviceContextHdcScope hdc = new(g2, applyGraphicsState: false)) { // Get Win32 dc with Graphics properties applied to it. PInvoke.DrawFrameControl(hdc, ref rcFrame, kind, state); @@ -1496,13 +1489,13 @@ private static void DrawFrameControl( { // Replace black/white with foreColor/backColor. ImageAttributes attrs = new ImageAttributes(); - ColorMap cm1 = new ColorMap + ColorMap cm1 = new() { OldColor = Color.Black, NewColor = foreColor }; - ColorMap cm2 = new ColorMap + ColorMap cm2 = new() { OldColor = Color.White, NewColor = backColor @@ -1605,7 +1598,7 @@ internal static void DrawImageColorized( { ArgumentNullException.ThrowIfNull(graphics); - using var attributes = new ImageAttributes(); + using ImageAttributes attributes = new(); attributes.SetColorMatrix(RemapBlackAndWhitePreserveTransparentMatrix(replaceBlack, Color.White)); graphics.DrawImage( image, @@ -1624,9 +1617,9 @@ internal static bool IsImageTransparent(Image? backgroundImage) // the supplied Graphics object. internal static void DrawImageReplaceColor(Graphics g, Image image, Rectangle dest, Color oldColor, Color newColor) { - ImageAttributes attrs = new ImageAttributes(); + ImageAttributes attrs = new(); - ColorMap cm = new ColorMap + ColorMap cm = new() { OldColor = oldColor, NewColor = newColor @@ -1683,8 +1676,8 @@ internal static void DrawImageDisabled(Graphics graphics, Image image, Rectangle if (unscaledImage) { - using Bitmap bmp = new Bitmap(image.Width, image.Height); - using (Graphics g = Graphics.FromImage(bmp)) + using Bitmap bitmap = new(image.Width, image.Height); + using (Graphics g = Graphics.FromImage(bitmap)) { g.DrawImage( image, @@ -1694,7 +1687,7 @@ internal static void DrawImageDisabled(Graphics graphics, Image image, Rectangle t_disabledImageAttr); } - graphics.DrawImageUnscaled(bmp, imageBounds); + graphics.DrawImageUnscaled(bitmap, imageBounds); } else { @@ -2036,7 +2029,7 @@ public static void DrawStringDisabled( // This must come before creating the scope. FONT_QUALITY quality = TextRenderer.FontQualityFromTextRenderingHint(dc); - using var hdc = new DeviceContextHdcScope(dc, TextRenderer.GetApplyStateFlags(dc, format)); + using DeviceContextHdcScope hdc = new(dc, TextRenderer.GetApplyStateFlags(dc, format)); DrawStringDisabled(hdc, s, font, color, layoutRectangle, format, quality); } @@ -2090,7 +2083,7 @@ public static void FillReversibleRectangle(Rectangle rectangle, Color backColor) 0x5a0049); // RasterOp.BRUSH.XorWith(RasterOp.TARGET)); R2_MODE rop2 = R2_MODE.R2_NOT; - using var desktopDC = new GetDcScope( + using GetDcScope desktopDC = new( PInvoke.GetDesktopWindow(), HRGN.Null, GET_DCX_FLAGS.DCX_WINDOW | GET_DCX_FLAGS.DCX_LOCKWINDOWUPDATE | GET_DCX_FLAGS.DCX_CACHE); @@ -2109,7 +2102,7 @@ public static void FillReversibleRectangle(Rectangle rectangle, Color backColor) /// function -- when used on something not obtained from ChooseFont, it may round away some precision. /// internal static Font FontInPoints(Font font) - => new Font( + => new( font.FontFamily, font.SizeInPoints, font.Style, @@ -2468,7 +2461,7 @@ internal static void InvertForeColorIfNeeded(Bitmap bitmap, Color backgroundColo var pixel = bitmap.GetPixel(x, y); if (pixel != backgroundColor) { - var pixelColorWrapper = new HLSColor(pixel); + HLSColor pixelColorWrapper = new(pixel); if (Math.Abs(pixelColorWrapper.Luminosity - backgroundColorWrapper.Luminosity) > MaximumLuminosityDifference) { bitmap.SetPixel(x, y, pixel.InvertColor()); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ControlStyles.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ControlStyles.cs index 9ae3cf9979b..9a41f738ec5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ControlStyles.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ControlStyles.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ControlUpdateMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ControlUpdateMode.cs index 18f541852d1..3fc165cfd2e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ControlUpdateMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ControlUpdateMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control_ActiveXControlInterfaces.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control_ActiveXControlInterfaces.cs index bd0f2bec236..ababa4f4154 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control_ActiveXControlInterfaces.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control_ActiveXControlInterfaces.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -26,6 +25,7 @@ public unsafe partial class Control : IPersistStorage.Interface, IQuickActivate.Interface { + /// unsafe HRESULT IOleControl.Interface.GetControlInfo(CONTROLINFO* pCI) { if (pCI is null) @@ -52,6 +52,7 @@ unsafe HRESULT IOleControl.Interface.GetControlInfo(CONTROLINFO* pCI) return ActiveXInstance.GetControlInfo(pCI); } + /// unsafe HRESULT IOleControl.Interface.OnMnemonic(MSG* pMsg) { if (pMsg is null) @@ -66,6 +67,7 @@ unsafe HRESULT IOleControl.Interface.OnMnemonic(MSG* pMsg) return HRESULT.S_OK; } + /// HRESULT IOleControl.Interface.OnAmbientPropertyChange(int dispID) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, $"AxSource:OnAmbientPropertyChange. Dispid: {dispID}"); @@ -75,6 +77,7 @@ HRESULT IOleControl.Interface.OnAmbientPropertyChange(int dispID) return HRESULT.S_OK; } + /// HRESULT IOleControl.Interface.FreezeEvents(BOOL bFreeze) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, $"AxSource:FreezeEvents. Freeze: {bFreeze}"); @@ -83,15 +86,19 @@ HRESULT IOleControl.Interface.FreezeEvents(BOOL bFreeze) return HRESULT.S_OK; } - unsafe HRESULT IOleInPlaceActiveObject.Interface.GetWindow(HWND* phwnd) + /// + HRESULT IOleInPlaceActiveObject.Interface.GetWindow(HWND* phwnd) => ((IOleInPlaceObject.Interface)this).GetWindow(phwnd); + /// HRESULT IOleInPlaceActiveObject.Interface.ContextSensitiveHelp(BOOL fEnterMode) => ((IOleInPlaceObject.Interface)this).ContextSensitiveHelp(fEnterMode); - unsafe HRESULT IOleInPlaceActiveObject.Interface.TranslateAccelerator(MSG* lpmsg) + /// + HRESULT IOleInPlaceActiveObject.Interface.TranslateAccelerator(MSG* lpmsg) => ActiveXInstance.TranslateAccelerator(lpmsg); + /// HRESULT IOleInPlaceActiveObject.Interface.OnFrameWindowActivate(BOOL fActivate) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:OnFrameWindowActivate"); @@ -99,6 +106,7 @@ HRESULT IOleInPlaceActiveObject.Interface.OnFrameWindowActivate(BOOL fActivate) return HRESULT.S_OK; } + /// HRESULT IOleInPlaceActiveObject.Interface.OnDocWindowActivate(BOOL fActivate) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, $"AxSource:OnDocWindowActivate. Activate: {(bool)fActivate}"); @@ -108,19 +116,22 @@ HRESULT IOleInPlaceActiveObject.Interface.OnDocWindowActivate(BOOL fActivate) return HRESULT.S_OK; } - unsafe HRESULT IOleInPlaceActiveObject.Interface.ResizeBorder(RECT* prcBorder, IOleInPlaceUIWindow* pUIWindow, BOOL fFrameWindow) + /// + HRESULT IOleInPlaceActiveObject.Interface.ResizeBorder(RECT* prcBorder, IOleInPlaceUIWindow* pUIWindow, BOOL fFrameWindow) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:ResizesBorder"); return HRESULT.S_OK; } + /// HRESULT IOleInPlaceActiveObject.Interface.EnableModeless(BOOL fEnable) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:EnableModeless"); return HRESULT.E_NOTIMPL; } - unsafe HRESULT IOleInPlaceObject.Interface.GetWindow(HWND* phwnd) + /// + HRESULT IOleInPlaceObject.Interface.GetWindow(HWND* phwnd) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:GetWindow"); HRESULT hr = ActiveXInstance.GetWindow(phwnd); @@ -128,6 +139,7 @@ unsafe HRESULT IOleInPlaceObject.Interface.GetWindow(HWND* phwnd) return hr; } + /// HRESULT IOleInPlaceObject.Interface.ContextSensitiveHelp(BOOL fEnterMode) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, $"AxSource:ContextSensitiveHelp. Mode: {fEnterMode}"); @@ -139,6 +151,7 @@ HRESULT IOleInPlaceObject.Interface.ContextSensitiveHelp(BOOL fEnterMode) return HRESULT.S_OK; } + /// HRESULT IOleInPlaceObject.Interface.InPlaceDeactivate() { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:InPlaceDeactivate"); @@ -148,13 +161,15 @@ HRESULT IOleInPlaceObject.Interface.InPlaceDeactivate() return hr; } + /// HRESULT IOleInPlaceObject.Interface.UIDeactivate() { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:UIDeactivate"); return ActiveXInstance.UIDeactivate(); } - unsafe HRESULT IOleInPlaceObject.Interface.SetObjectRects(RECT* lprcPosRect, RECT* lprcClipRect) + /// + HRESULT IOleInPlaceObject.Interface.SetObjectRects(RECT* lprcPosRect, RECT* lprcClipRect) { if (lprcClipRect is not null) { @@ -168,20 +183,23 @@ unsafe HRESULT IOleInPlaceObject.Interface.SetObjectRects(RECT* lprcPosRect, REC return hr; } + /// HRESULT IOleInPlaceObject.Interface.ReactivateAndUndo() { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:ReactivateAndUndo"); return HRESULT.S_OK; } - unsafe HRESULT IOleObject.Interface.SetClientSite(IOleClientSite* pClientSite) + /// + HRESULT IOleObject.Interface.SetClientSite(IOleClientSite* pClientSite) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:SetClientSite"); ActiveXInstance.SetClientSite(pClientSite); return HRESULT.S_OK; } - unsafe HRESULT IOleObject.Interface.GetClientSite(IOleClientSite** ppClientSite) + /// + HRESULT IOleObject.Interface.GetClientSite(IOleClientSite** ppClientSite) { if (ppClientSite is null) { @@ -193,6 +211,7 @@ unsafe HRESULT IOleObject.Interface.GetClientSite(IOleClientSite** ppClientSite) return HRESULT.S_OK; } + /// HRESULT IOleObject.Interface.SetHostNames(PCWSTR szContainerApp, PCWSTR szContainerObj) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:SetHostNames"); @@ -201,6 +220,7 @@ HRESULT IOleObject.Interface.SetHostNames(PCWSTR szContainerApp, PCWSTR szContai return HRESULT.S_OK; } + /// HRESULT IOleObject.Interface.Close(uint dwSaveOption) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, $"AxSource:Close. Save option: {dwSaveOption}"); @@ -208,12 +228,14 @@ HRESULT IOleObject.Interface.Close(uint dwSaveOption) return HRESULT.S_OK; } - unsafe HRESULT IOleObject.Interface.SetMoniker(uint dwWhichMoniker, IMoniker* pmk) + /// + HRESULT IOleObject.Interface.SetMoniker(uint dwWhichMoniker, IMoniker* pmk) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:SetMoniker"); return HRESULT.E_NOTIMPL; } + /// HRESULT IOleObject.Interface.GetMoniker(uint dwAssign, uint dwWhichMoniker, IMoniker** ppmk) { if (ppmk is null) @@ -226,12 +248,14 @@ HRESULT IOleObject.Interface.GetMoniker(uint dwAssign, uint dwWhichMoniker, IMon return HRESULT.E_NOTIMPL; } + /// HRESULT IOleObject.Interface.InitFromData(ComIDataObject* pDataObject, BOOL fCreation, uint dwReserved) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:InitFromData"); return HRESULT.E_NOTIMPL; } + /// HRESULT IOleObject.Interface.GetClipboardData(uint dwReserved, ComIDataObject** ppDataObject) { if (ppDataObject is null) @@ -244,6 +268,7 @@ HRESULT IOleObject.Interface.GetClipboardData(uint dwReserved, ComIDataObject** return HRESULT.E_NOTIMPL; } + /// HRESULT IOleObject.Interface.DoVerb( int iVerb, MSG* lpmsg, @@ -281,7 +306,8 @@ HRESULT IOleObject.Interface.DoVerb( } } - unsafe HRESULT IOleObject.Interface.EnumVerbs(IEnumOLEVERB** ppEnumOleVerb) + /// + HRESULT IOleObject.Interface.EnumVerbs(IEnumOLEVERB** ppEnumOleVerb) { if (ppEnumOleVerb is null) { @@ -293,19 +319,22 @@ unsafe HRESULT IOleObject.Interface.EnumVerbs(IEnumOLEVERB** ppEnumOleVerb) return HRESULT.S_OK; } + /// HRESULT IOleObject.Interface.Update() { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:OleUpdate"); return HRESULT.S_OK; } + /// HRESULT IOleObject.Interface.IsUpToDate() { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:IsUpToDate"); return HRESULT.S_OK; } - unsafe HRESULT IOleObject.Interface.GetUserClassID(Guid* pClsid) + /// + HRESULT IOleObject.Interface.GetUserClassID(Guid* pClsid) { if (pClsid is null) { @@ -317,6 +346,7 @@ unsafe HRESULT IOleObject.Interface.GetUserClassID(Guid* pClsid) return HRESULT.S_OK; } + /// HRESULT IOleObject.Interface.GetUserType(uint dwFormOfType, PWSTR* pszUserType) { if (pszUserType is null) @@ -331,6 +361,7 @@ HRESULT IOleObject.Interface.GetUserType(uint dwFormOfType, PWSTR* pszUserType) return HRESULT.S_OK; } + /// HRESULT IOleObject.Interface.SetExtent(DVASPECT dwDrawAspect, SIZE* psizel) { if (psizel is null) @@ -345,6 +376,7 @@ HRESULT IOleObject.Interface.SetExtent(DVASPECT dwDrawAspect, SIZE* psizel) return HRESULT.S_OK; } + /// HRESULT IOleObject.Interface.GetExtent(DVASPECT dwDrawAspect, SIZE* psizel) { if (psizel is null) @@ -360,6 +392,7 @@ HRESULT IOleObject.Interface.GetExtent(DVASPECT dwDrawAspect, SIZE* psizel) return HRESULT.S_OK; } + /// HRESULT IOleObject.Interface.Advise(IAdviseSink* pAdvSink, uint* pdwConnection) { if (pdwConnection is null) @@ -368,10 +401,10 @@ HRESULT IOleObject.Interface.Advise(IAdviseSink* pAdvSink, uint* pdwConnection) } Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:Advise"); - *pdwConnection = ActiveXInstance.Advise(pAdvSink); - return HRESULT.S_OK; + return ActiveXInstance.Advise(pAdvSink, pdwConnection); } + /// HRESULT IOleObject.Interface.Unadvise(uint dwConnection) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:Unadvise"); @@ -381,6 +414,7 @@ HRESULT IOleObject.Interface.Unadvise(uint dwConnection) return hr; } + /// HRESULT IOleObject.Interface.EnumAdvise(IEnumSTATDATA** ppenumAdvise) { if (ppenumAdvise is null) @@ -393,6 +427,7 @@ HRESULT IOleObject.Interface.EnumAdvise(IEnumSTATDATA** ppenumAdvise) return HRESULT.E_NOTIMPL; } + /// HRESULT IOleObject.Interface.GetMiscStatus(DVASPECT dwAspect, OLEMISC* pdwStatus) { if (pdwStatus is null) @@ -423,15 +458,19 @@ HRESULT IOleObject.Interface.GetMiscStatus(DVASPECT dwAspect, OLEMISC* pdwStatus return HRESULT.S_OK; } + /// HRESULT IOleObject.Interface.SetColorScheme(LOGPALETTE* pLogpal) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:SetColorScheme"); return HRESULT.S_OK; } + /// HRESULT IOleWindow.Interface.GetWindow(HWND* phwnd) => ((IOleInPlaceObject.Interface)this).GetWindow(phwnd); - HRESULT IOleWindow.Interface.ContextSensitiveHelp(BOOL fEnterMode) => ((IOleInPlaceObject.Interface)this).ContextSensitiveHelp(fEnterMode); + /// + HRESULT IOleWindow.Interface.ContextSensitiveHelp(BOOL fEnterMode) + => ((IOleInPlaceObject.Interface)this).ContextSensitiveHelp(fEnterMode); unsafe HRESULT IPersist.Interface.GetClassID(Guid* pClassID) { @@ -445,12 +484,14 @@ unsafe HRESULT IPersist.Interface.GetClassID(Guid* pClassID) return HRESULT.S_OK; } + /// HRESULT IPersistPropertyBag.Interface.InitNew() { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:IPersistPropertyBag.InitNew"); return HRESULT.S_OK; } + /// HRESULT IPersistPropertyBag.Interface.GetClassID(Guid* pClassID) { if (pClassID is null) @@ -463,6 +504,7 @@ HRESULT IPersistPropertyBag.Interface.GetClassID(Guid* pClassID) return HRESULT.S_OK; } + /// HRESULT IPersistPropertyBag.Interface.Load(IPropertyBag* pPropBag, IErrorLog* pErrorLog) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:Load (IPersistPropertyBag)"); @@ -472,6 +514,7 @@ HRESULT IPersistPropertyBag.Interface.Load(IPropertyBag* pPropBag, IErrorLog* pE return HRESULT.S_OK; } + /// HRESULT IPersistPropertyBag.Interface.Save(IPropertyBag* pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:Save (IPersistPropertyBag)"); @@ -481,6 +524,7 @@ HRESULT IPersistPropertyBag.Interface.Save(IPropertyBag* pPropBag, BOOL fClearDi return HRESULT.S_OK; } + /// HRESULT IPersistStorage.Interface.GetClassID(Guid* pClassID) { if (pClassID is null) @@ -493,18 +537,21 @@ HRESULT IPersistStorage.Interface.GetClassID(Guid* pClassID) return HRESULT.S_OK; } + /// HRESULT IPersistStorage.Interface.IsDirty() { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:IPersistStorage.IsDirty"); return ActiveXInstance.IsDirty(); } + /// HRESULT IPersistStorage.Interface.InitNew(IStorage* pStg) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:IPersistStorage.InitNew"); return HRESULT.S_OK; } + /// HRESULT IPersistStorage.Interface.Load(IStorage* pStg) { if (pStg is null) @@ -519,6 +566,7 @@ HRESULT IPersistStorage.Interface.Load(IStorage* pStg) return result; } + /// HRESULT IPersistStorage.Interface.Save(IStorage* pStgSave, BOOL fSameAsLoad) { if (pStgSave is null) @@ -533,18 +581,21 @@ HRESULT IPersistStorage.Interface.Save(IStorage* pStgSave, BOOL fSameAsLoad) return result; } + /// HRESULT IPersistStorage.Interface.SaveCompleted(IStorage* pStgNew) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:IPersistStorage.SaveCompleted"); return HRESULT.S_OK; } + /// HRESULT IPersistStorage.Interface.HandsOffStorage() { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:IPersistStorage.HandsOffStorage"); return HRESULT.S_OK; } + /// HRESULT IPersistStreamInit.Interface.GetClassID(Guid* pClassID) { if (pClassID is null) @@ -557,12 +608,14 @@ HRESULT IPersistStreamInit.Interface.GetClassID(Guid* pClassID) return HRESULT.S_OK; } + /// HRESULT IPersistStreamInit.Interface.IsDirty() { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:IPersistStreamInit.IsDirty"); return ActiveXInstance.IsDirty(); } + /// HRESULT IPersistStreamInit.Interface.Load(IStream* pStm) { if (pStm is null) @@ -577,6 +630,7 @@ HRESULT IPersistStreamInit.Interface.Load(IStream* pStm) return HRESULT.S_OK; } + /// HRESULT IPersistStreamInit.Interface.Save(IStream* pStm, BOOL fClearDirty) { if (pStm is null) @@ -591,18 +645,21 @@ HRESULT IPersistStreamInit.Interface.Save(IStream* pStm, BOOL fClearDirty) return HRESULT.S_OK; } + /// HRESULT IPersistStreamInit.Interface.GetSizeMax(ulong* pCbSize) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:GetSizeMax"); return HRESULT.S_OK; } + /// HRESULT IPersistStreamInit.Interface.InitNew() { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:IPersistStreamInit.InitNew"); return HRESULT.S_OK; } + /// HRESULT IQuickActivate.Interface.QuickActivate(QACONTAINER* pQaContainer, QACONTROL* pQaControl) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:QuickActivate"); @@ -612,6 +669,7 @@ HRESULT IQuickActivate.Interface.QuickActivate(QACONTAINER* pQaContainer, QACONT return hr; } + /// HRESULT IQuickActivate.Interface.SetContentExtent(SIZE* pSizel) { if (pSizel is null) @@ -626,6 +684,7 @@ HRESULT IQuickActivate.Interface.SetContentExtent(SIZE* pSizel) return HRESULT.S_OK; } + /// HRESULT IQuickActivate.Interface.GetContentExtent(SIZE* pSizel) { if (pSizel is null) @@ -640,6 +699,7 @@ HRESULT IQuickActivate.Interface.GetContentExtent(SIZE* pSizel) return HRESULT.S_OK; } + /// HRESULT IViewObject.Interface.Draw( DVASPECT dwDrawAspect, int lindex, @@ -670,6 +730,7 @@ HRESULT IViewObject.Interface.Draw( return HRESULT.S_OK; } + /// HRESULT IViewObject.Interface.GetColorSet( DVASPECT dwDrawAspect, int lindex, @@ -684,30 +745,35 @@ HRESULT IViewObject.Interface.GetColorSet( return HRESULT.E_NOTIMPL; } - unsafe HRESULT IViewObject.Interface.Freeze(DVASPECT dwDrawAspect, int lindex, void* pvAspect, uint* pdwFreeze) + /// + HRESULT IViewObject.Interface.Freeze(DVASPECT dwDrawAspect, int lindex, void* pvAspect, uint* pdwFreeze) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:Freezes"); return HRESULT.E_NOTIMPL; } + /// HRESULT IViewObject.Interface.Unfreeze(uint dwFreeze) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:Unfreeze"); return HRESULT.E_NOTIMPL; } + /// HRESULT IViewObject.Interface.SetAdvise(DVASPECT aspects, uint advf, IAdviseSink* pAdvSink) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:SetAdvise"); return ActiveXInstance.SetAdvise(aspects, (ADVF)advf, pAdvSink); } + /// HRESULT IViewObject.Interface.GetAdvise(uint* pAspects, uint* pAdvf, IAdviseSink** ppAdvSink) { Debug.WriteLineIf(CompModSwitches.ActiveX.TraceInfo, "AxSource:GetAdvise"); return ActiveXInstance.GetAdvise((DVASPECT*)pAspects, (ADVF*)pAdvf, ppAdvSink); } + /// HRESULT IViewObject2.Interface.Draw( DVASPECT dwDrawAspect, int lindex, @@ -731,6 +797,7 @@ HRESULT IViewObject2.Interface.Draw( pfnContinue, dwContinue); + /// HRESULT IViewObject2.Interface.GetColorSet( DVASPECT dwDrawAspect, int lindex, @@ -740,18 +807,23 @@ HRESULT IViewObject2.Interface.GetColorSet( LOGPALETTE** ppColorSet) => ((IViewObject.Interface)this).GetColorSet(dwDrawAspect, lindex, pvAspect, ptd, hdcTargetDev, ppColorSet); + /// HRESULT IViewObject2.Interface.Freeze(DVASPECT dwDrawAspect, int lindex, void* pvAspect, uint* pdwFreeze) => ((IViewObject.Interface)this).Freeze(dwDrawAspect, lindex, pvAspect, pdwFreeze); + /// HRESULT IViewObject2.Interface.Unfreeze(uint dwFreeze) => ((IViewObject.Interface)this).Unfreeze(dwFreeze); + /// HRESULT IViewObject2.Interface.SetAdvise(DVASPECT aspects, uint advf, IAdviseSink* pAdvSink) => ((IViewObject.Interface)this).SetAdvise(aspects, advf, pAdvSink); + /// HRESULT IViewObject2.Interface.GetAdvise(uint* pAspects, uint* pAdvf, IAdviseSink** ppAdvSink) => ((IViewObject.Interface)this).GetAdvise(pAspects, pAdvf, ppAdvSink); + /// HRESULT IViewObject2.Interface.GetExtent(DVASPECT dwDrawAspect, int lindex, DVTARGETDEVICE* ptd, SIZE* lpsizel) - => ((IOleObject.Interface)this).GetExtent((DVASPECT)dwDrawAspect, lpsizel); + => ((IOleObject.Interface)this).GetExtent(dwDrawAspect, lpsizel); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ConvertEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ConvertEventArgs.cs index e43d81b3f32..558bc1e327d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ConvertEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ConvertEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ConvertEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ConvertEventHandler.cs index 60c7e2dffac..5ee114315be 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ConvertEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ConvertEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CreateParams.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CreateParams.cs index cd9e1b766b9..fbed05971b7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CreateParams.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CreateParams.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CurrencyManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CurrencyManager.cs index 4f22cebb5ac..b289c5f05fd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CurrencyManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CurrencyManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -30,7 +29,7 @@ public class CurrencyManager : BindingManagerBase private bool suspendPushDataInCurrentChanged; private ItemChangedEventHandler onItemChanged; private ListChangedEventHandler onListChanged; - private readonly ItemChangedEventArgs resetEvent = new ItemChangedEventArgs(-1); + private readonly ItemChangedEventArgs resetEvent = new(-1); private EventHandler onMetaDataChangedHandler; /// diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs index f3c90caab03..0736523e293 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -25,9 +24,12 @@ public sealed class Cursor : IDisposable, ISerializable, IHandle, IHandle private readonly byte[]? _cursorData; private HCURSOR _handle; - private bool _ownHandle = true; + private readonly Flags _flags; private readonly PCWSTR _resourceId; + private bool OwnHandle => (_flags & Flags.OwnHandle) != 0; + private bool IsWellKnown => (_flags & Flags.InternalCursor) != 0; + /// /// Private constructor. If you want a standard system cursor, use one of the /// definitions in the Cursors class. @@ -35,7 +37,8 @@ public sealed class Cursor : IDisposable, ISerializable, IHandle, IHandle internal unsafe Cursor(PCWSTR nResourceId) { // We don't delete stock cursors. - _ownHandle = false; + _flags &= ~Flags.OwnHandle; + _flags |= Flags.InternalCursor; _resourceId = nResourceId; _handle = PInvoke.LoadCursor((HINSTANCE)0, nResourceId); if (_handle.IsNull) @@ -45,7 +48,7 @@ internal unsafe Cursor(PCWSTR nResourceId) } /// - /// Initializes a new instance of the class with the specified handle. + /// Initializes a new instance of the class from the specified . /// public Cursor(IntPtr handle) { @@ -55,31 +58,38 @@ public Cursor(IntPtr handle) } _handle = (HCURSOR)handle; - _ownHandle = false; + _flags &= ~Flags.OwnHandle; } /// - /// Initializes a new instance of the class with the specified filename. + /// Initializes a new instance of the class with the specified . /// public Cursor(string fileName) { _cursorData = File.ReadAllBytes(fileName); + _flags |= Flags.OwnHandle; LoadPicture( new Ole32.GPStream(new MemoryStream(_cursorData)), nameof(fileName)); } /// - /// Initializes a new instance of the class from the specified resource. + /// Initializes a new instance of the class from the specified . /// public Cursor(Type type, string resource) : this((type.OrThrowIfNull()).Module.Assembly.GetManifestResourceStream(type, resource)!) { + _flags |= Flags.OwnHandle; + + if (type == typeof(Cursor)) + { + _flags |= Flags.InternalCursor; + } } /// /// Initializes a new instance of the class from the - /// specified data stream. + /// specified data . /// public Cursor(Stream stream) { @@ -93,6 +103,7 @@ public Cursor(Stream stream) stream.CopyTo(memoryStream); _cursorData = memoryStream.ToArray(); + _flags |= Flags.OwnHandle; // stream.CopyTo causes both streams to advance. So reset it for LoadPicture. memoryStream.Position = 0; @@ -225,7 +236,7 @@ public void Dispose() private void Dispose(bool disposing) { - if (!_handle.IsNull && _ownHandle) + if (!_handle.IsNull && OwnHandle) { PInvoke.DestroyCursor(_handle); _handle = HCURSOR.Null; @@ -246,7 +257,7 @@ private void DrawImageCore(Graphics graphics, Rectangle imageRect, Rectangle tar targetRect.X += (int)graphics.Transform.OffsetX; targetRect.Y += (int)graphics.Transform.OffsetY; - using var dc = new DeviceContextHdcScope(graphics, applyGraphicsState: false); + using DeviceContextHdcScope dc = new(graphics, applyGraphicsState: false); int imageX = 0; int imageY = 0; @@ -433,8 +444,6 @@ private unsafe void LoadPicture(IStream.Interface stream, string paramName) { throw new Win32Exception(string.Format(SR.FailedToLoadCursor, Marshal.GetLastWin32Error())); } - - _ownHandle = true; } else { @@ -478,21 +487,13 @@ internal unsafe byte[] GetData() /// public override string ToString() { - string? s = !_ownHandle - ? TypeDescriptor.GetConverter(typeof(Cursor)).ConvertToString(this) - : base.ToString(); - - return $"[Cursor: {s}]"; + string? cursorName = IsWellKnown || !OwnHandle ? TypeDescriptor.GetConverter(typeof(Cursor)).ConvertToString(this) : base.ToString(); + return $"[Cursor: {cursorName}]"; } public static bool operator ==(Cursor? left, Cursor? right) { - if (right is null || left is null) - { - return left is null && right is null; - } - - return left._handle == right._handle; + return right is null || left is null ? left is null && right is null : left._handle == right._handle; } public static bool operator !=(Cursor? left, Cursor? right) => !(left == right); @@ -500,4 +501,12 @@ public override string ToString() public override int GetHashCode() => (int)_handle.Value; public override bool Equals(object? obj) => obj is Cursor cursor && this == cursor; + + [Flags] + private enum Flags : byte + { + None = 0, + OwnHandle = 1 << 0, + InternalCursor = 1 << 1, + } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CursorConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CursorConverter.cs index 485d339263d..d1953ed8445 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CursorConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CursorConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs index ffa1aee44f3..7a043f091d1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DCMapping.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DCMapping.cs index efca0ceec8c..6796a2d8946 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DCMapping.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DCMapping.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataFormats.Format.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataFormats.Format.cs index 5d38fe2671a..3b72a9c2e6c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataFormats.Format.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataFormats.Format.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataFormats.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataFormats.cs index e473aa8f6e6..dc40bc64c51 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataFormats.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataFormats.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.InteropServices; @@ -148,7 +147,7 @@ public static partial class DataFormats private static Format[]? s_formatList; private static int s_formatCount; - private static readonly object s_internalSyncObject = new object(); + private static readonly object s_internalSyncObject = new(); /// /// Gets a with the Windows Clipboard numeric ID and name for the specified format. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.AccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.AccessibleObject.cs index 0a5e63c3264..cbf33ae443f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.AccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.AccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.ControlCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.ControlCollection.cs index ce9c953b856..db8f21a8f23 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.ControlCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.ControlCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataConnection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataConnection.cs index 5ad5701ab0c..a5661276da6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataConnection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataConnection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewEditingPanel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewEditingPanel.cs index 76e2cd87898..e437a9c52ef 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewEditingPanel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewEditingPanel.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewEditingPanelAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewEditingPanelAccessibleObject.cs index 69a55589e1b..d0260d379fb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewEditingPanelAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewEditingPanelAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewHitTestTypeInternal.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewHitTestTypeInternal.cs index c5d3e87cc33..0eed5e41b09 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewHitTestTypeInternal.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewHitTestTypeInternal.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewMouseEvent.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewMouseEvent.cs index 8423c3aaa41..02385e01b3f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewMouseEvent.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewMouseEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewValidateCellInternal.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewValidateCellInternal.cs index f15eb6025bd..c7e96e478b4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewValidateCellInternal.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.DataGridViewValidateCellInternal.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.HitTestInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.HitTestInfo.cs index 7dc1f21da36..c5d7a2cca7d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.HitTestInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.HitTestInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -21,7 +20,7 @@ public sealed class HitTestInfo /// /// Allows the object to inform you the extent of the grid. /// - public static readonly HitTestInfo Nowhere = new HitTestInfo(); + public static readonly HitTestInfo Nowhere = new(); internal HitTestInfo() { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.LayoutData.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.LayoutData.cs index be0ee6d026a..fc32f833679 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.LayoutData.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.LayoutData.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.Methods.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.Methods.cs index ba4fd1c5127..c243b6dc3f4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.Methods.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.Methods.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -1735,10 +1734,8 @@ protected void AutoResizeColumn(int columnIndex, DataGridViewAutoSizeColumnMode throw new InvalidEnumArgumentException(nameof(autoSizeColumnMode), (int)autoSizeColumnMode, typeof(DataGridViewAutoSizeColumnMode)); } - if (columnIndex < 0 || columnIndex >= Columns.Count) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(columnIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(columnIndex, Columns.Count); if (autoSizeColumnMode == DataGridViewAutoSizeColumnMode.ColumnHeader && !ColumnHeadersVisible) { @@ -1831,10 +1828,8 @@ protected void AutoResizeColumnHeadersHeight(bool fixedRowHeadersWidth, bool fix protected void AutoResizeColumnHeadersHeight(int columnIndex, bool fixedRowHeadersWidth, bool fixedColumnWidth) { - if (columnIndex < -1 || columnIndex >= Columns.Count) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(columnIndex, -1); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(columnIndex, Columns.Count); if (!ColumnHeadersVisible) { @@ -1994,10 +1989,8 @@ public void AutoResizeRow(int rowIndex, DataGridViewAutoSizeRowMode autoSizeRowM protected void AutoResizeRow(int rowIndex, DataGridViewAutoSizeRowMode autoSizeRowMode, bool fixedWidth) { - if (rowIndex < 0 || rowIndex >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, Rows.Count); // not using ClientUtils here because it's a flags enum, masking instead. if (((DataGridViewAutoSizeRowCriteriaInternal)autoSizeRowMode & InvalidDataGridViewAutoSizeRowCriteriaInternalMask) != 0) @@ -2191,10 +2184,8 @@ protected void AutoResizeRowHeadersWidth(int rowIndex, bool fixedColumnHeadersHeight, bool fixedRowHeight) { - if (rowIndex < -1 || rowIndex >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(rowIndex, -1); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, Rows.Count); if (rowHeadersWidthSizeMode == DataGridViewRowHeadersWidthSizeMode.EnableResizing || rowHeadersWidthSizeMode == DataGridViewRowHeadersWidthSizeMode.DisableResizing) @@ -2479,15 +2470,9 @@ protected void AutoResizeRows(int rowIndexStart, int rowsCount, DataGridViewAuto throw new InvalidOperationException(SR.DataGridView_CannotAutoSizeRowsInvisibleRowHeader); } - if (rowsCount < 0) - { - throw new ArgumentOutOfRangeException(nameof(rowsCount)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowsCount); - if (rowIndexStart < 0) - { - throw new ArgumentOutOfRangeException(nameof(rowIndexStart)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndexStart); if (!IsHandleCreated) { @@ -3576,10 +3561,8 @@ protected void ClearSelection(int columnIndexException, int rowIndexException, b case DataGridViewSelectionMode.FullColumnSelect: case DataGridViewSelectionMode.ColumnHeaderSelect: { - if (columnIndexException < 0 || columnIndexException >= Columns.Count) - { - throw new ArgumentOutOfRangeException(nameof(columnIndexException)); - } + ArgumentOutOfRangeException.ThrowIfNegative(columnIndexException); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(columnIndexException, Columns.Count); break; } @@ -3587,10 +3570,8 @@ protected void ClearSelection(int columnIndexException, int rowIndexException, b case DataGridViewSelectionMode.FullRowSelect: case DataGridViewSelectionMode.RowHeaderSelect: { - if (columnIndexException < -1 || columnIndexException >= Columns.Count) - { - throw new ArgumentOutOfRangeException(nameof(columnIndexException)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(columnIndexException, -1); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(columnIndexException, Columns.Count); break; } @@ -3602,10 +3583,8 @@ protected void ClearSelection(int columnIndexException, int rowIndexException, b case DataGridViewSelectionMode.FullRowSelect: case DataGridViewSelectionMode.RowHeaderSelect: { - if (rowIndexException < 0 || rowIndexException >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndexException)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndexException); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndexException, Rows.Count); break; } @@ -3613,10 +3592,8 @@ protected void ClearSelection(int columnIndexException, int rowIndexException, b case DataGridViewSelectionMode.FullColumnSelect: case DataGridViewSelectionMode.ColumnHeaderSelect: { - if (rowIndexException < -1 || rowIndexException >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndexException)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(rowIndexException, -1); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndexException, Rows.Count); break; } @@ -7154,19 +7131,13 @@ public Rectangle GetCellDisplayRectangle(int columnIndex, int rowIndex, bool cut if (columnIndex >= 0) { - if (columnIndex >= Columns.Count) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(columnIndex, Columns.Count); columnRect = GetColumnDisplayRectanglePrivate(columnIndex, cutOverflow); } else { - if (columnIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(columnIndex, -1); if (rowIndex >= 0) { @@ -7180,19 +7151,13 @@ public Rectangle GetCellDisplayRectangle(int columnIndex, int rowIndex, bool cut if (rowIndex >= 0) { - if (rowIndex >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, Rows.Count); rowRect = GetRowDisplayRectanglePrivate(rowIndex, cutOverflow); } else { - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); if (columnIndex >= 0) { @@ -8271,10 +8236,8 @@ private static void GetClipboardContentForHtml(StringBuilder sbContent, out IO.M // Rectangle returned includes the potential column header public Rectangle GetColumnDisplayRectangle(int columnIndex, bool cutOverflow) { - if (columnIndex < 0 || columnIndex >= Columns.Count) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(columnIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(columnIndex, Columns.Count); return GetColumnDisplayRectanglePrivate(columnIndex, cutOverflow); } @@ -9167,10 +9130,8 @@ internal override Size GetPreferredSizeCore(Size proposedConstraints) // Rectangle returned includes the potential row header public Rectangle GetRowDisplayRectangle(int rowIndex, bool cutOverflow) { - if (rowIndex < 0 || rowIndex >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, Rows.Count); return GetRowDisplayRectanglePrivate(rowIndex, cutOverflow); } @@ -10037,15 +9998,11 @@ private void InvalidateCellPrivate(DataGridViewCell dataGridViewCell) public void InvalidateCell(int columnIndex, int rowIndex) { - if (columnIndex < -1 || columnIndex >= Columns.Count) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(columnIndex, -1); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(columnIndex, Columns.Count); - if (rowIndex < -1 || rowIndex >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(rowIndex, -1); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, Rows.Count); InvalidateCellPrivate(columnIndex, rowIndex); } @@ -10067,10 +10024,8 @@ private void InvalidateCellPrivate(int columnIndex, int rowIndex) /// public void InvalidateColumn(int columnIndex) { - if (columnIndex < 0 || columnIndex >= Columns.Count) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(columnIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(columnIndex, Columns.Count); InvalidateColumnInternal(columnIndex); } @@ -10113,10 +10068,8 @@ private void InvalidateInside() /// public void InvalidateRow(int rowIndex) { - if (rowIndex < 0 || rowIndex >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, Rows.Count); InvalidateRowPrivate(rowIndex); } @@ -10571,7 +10524,7 @@ private void LayoutScrollBars() } } - _layout.ResizeBoxRect = default(Rectangle); + _layout.ResizeBoxRect = default; if (needVertScrollbar && needHorizScrollbar) { _layout.ResizeBoxRect = new Rectangle( @@ -17219,7 +17172,7 @@ protected override void OnPaint(PaintEventArgs e) if (clipRect.IntersectsWith(gridRect)) { - using var clipScope = new GraphicsClipScope(g); + using GraphicsClipScope clipScope = new(g); g.SetClip(gridRect); PaintBackground(g, clipRect, gridRect); PaintGrid(g, gridRect, clipRect, SingleVerticalBorderAdded, SingleHorizontalBorderAdded); @@ -19974,7 +19927,7 @@ private void PaintColumnHeaders(Graphics g, Rectangle clipBounds, bool singleBor bool isFirstDisplayedColumn = true, isLastVisibleColumn = false; DataGridViewCell cell; DataGridViewCellStyle inheritedCellStyle = new DataGridViewCellStyle(); - DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new(), dgvabsEffective; DataGridViewColumn dataGridViewColumnNext = null; // first paint the visible frozen columns @@ -27224,18 +27177,21 @@ protected virtual bool SetCurrentCellAddressCore(int columnIndex, bool validateCurrentCell, bool throughMouseClick) { - if (columnIndex < -1 || - (columnIndex >= 0 && rowIndex == -1) || - columnIndex >= Columns.Count) + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(columnIndex, Columns.Count); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, Rows.Count); + + if (rowIndex == -1) { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); + ArgumentOutOfRangeException.ThrowIfNotEqual(columnIndex, -1); } - - if (rowIndex < -1 || - (columnIndex == -1 && rowIndex >= 0) || - rowIndex >= Rows.Count) + else if (columnIndex == -1) + { + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); + } + else { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); + ArgumentOutOfRangeException.ThrowIfNegative(columnIndex); + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); } if (columnIndex > -1 && @@ -28067,15 +28023,11 @@ internal void SetReadOnlyRowCore(int rowIndex, bool readOnly) protected virtual void SetSelectedCellCore(int columnIndex, int rowIndex, bool selected) { - if (columnIndex < 0 || columnIndex >= Columns.Count) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(columnIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(columnIndex, Columns.Count); - if (rowIndex < 0 || rowIndex >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, Rows.Count); // cell selection changes DataGridViewRow dataGridViewRow = Rows.SharedRow(rowIndex); @@ -28403,10 +28355,8 @@ internal void SetSelectedCellCoreInternal(int columnIndex, int rowIndex, bool se protected virtual void SetSelectedColumnCore(int columnIndex, bool selected) { - if (columnIndex < 0 || columnIndex >= Columns.Count) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(columnIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(columnIndex, Columns.Count); _noSelectionChangeCount++; try @@ -28524,10 +28474,8 @@ private void SetSelectedElementCore(int columnIndex, int rowIndex, bool selected protected virtual void SetSelectedRowCore(int rowIndex, bool selected) { - if (rowIndex < 0 || rowIndex >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, Rows.Count); _noSelectionChangeCount++; try @@ -29319,15 +29267,10 @@ private void UnwireScrollBarsEvents() public void UpdateCellErrorText(int columnIndex, int rowIndex) { - if (columnIndex < -1 || columnIndex >= Columns.Count) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } - - if (rowIndex < -1 || rowIndex >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(columnIndex, -1); + ArgumentOutOfRangeException.ThrowIfLessThan(rowIndex, -1); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(columnIndex, Columns.Count); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, Rows.Count); if (IsHandleCreated) { @@ -29337,15 +29280,11 @@ public void UpdateCellErrorText(int columnIndex, int rowIndex) public void UpdateCellValue(int columnIndex, int rowIndex) { - if (columnIndex < 0 || columnIndex >= Columns.Count) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(columnIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(columnIndex, Columns.Count); - if (rowIndex < 0 || rowIndex >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, Rows.Count); if (IsHandleCreated) { @@ -29399,10 +29338,8 @@ private void UpdateColumnsDisplayedState(bool displayed) public void UpdateRowErrorText(int rowIndex) { - if (rowIndex < 0 || rowIndex >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, Rows.Count); if (IsHandleCreated && _layout.RowHeadersVisible) { @@ -29412,20 +29349,13 @@ public void UpdateRowErrorText(int rowIndex) public void UpdateRowErrorText(int rowIndexStart, int rowIndexEnd) { - if (rowIndexStart < 0 || rowIndexStart >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndexStart)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndexStart); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndexStart, Rows.Count); - if (rowIndexEnd < 0 || rowIndexEnd >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndexEnd)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndexEnd); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndexEnd, Rows.Count); - if (rowIndexEnd < rowIndexStart) - { - throw new ArgumentOutOfRangeException(nameof(rowIndexEnd)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(rowIndexEnd, rowIndexStart); if (IsHandleCreated && _layout.RowHeadersVisible) { @@ -29452,10 +29382,8 @@ public void UpdateRowHeightInfo(int rowIndex, bool updateToEnd) private void UpdateRowHeightInfoPrivate(int rowIndex, bool updateToEnd, bool invalidInAdjustFillingColumns) { - if ((updateToEnd && rowIndex < 0) || (!updateToEnd && rowIndex < -1) || rowIndex >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(rowIndex, updateToEnd ? 0 : -1); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, Rows.Count); Rows.InvalidateCachedRowsHeights(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.MouseClickInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.MouseClickInfo.cs index c6176ada160..ee674a3158e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.MouseClickInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.MouseClickInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.SelectedCellsAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.SelectedCellsAccessibleObject.cs index 5b9b6ddf927..55be8bd6f42 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.SelectedCellsAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.SelectedCellsAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.ToolTip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.ToolTip.cs index 6675222b1e7..775873653c3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.ToolTip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.ToolTip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.TopRowAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.TopRowAccessibleObject.cs index 682d0096627..ee79dbb5ebb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.TopRowAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.TopRowAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; @@ -112,10 +111,7 @@ public override string Value throw new InvalidOperationException(SR.DataGridViewTopRowAccessibleObject_OwnerNotSet); } - if (index < 0) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } + ArgumentOutOfRangeException.ThrowIfNegative(index); if (index > GetChildCount() - 1) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs index 203cfbaa5b6..c02419b04f1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Collections.Specialized; using System.ComponentModel; @@ -19,124 +16,124 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionDataGridView))] public partial class DataGridView : Control, ISupportInitialize { - private static readonly object s_allowUserToAddRowsChangedEvent = new object(); - private static readonly object s_allowUserToDeleteRowsChangedEvent = new object(); - private static readonly object s_allowUserToOrderColumnsChangedEvent = new object(); - private static readonly object s_allowUserToResizeColumnsChangedEvent = new object(); - private static readonly object s_allowUserToResizeRowsChangedEvent = new object(); - private static readonly object s_alternatingRowsDefaultCellStyleChangedEvent = new object(); - private static readonly object s_autoGenerateColumnsChangedEvent = new object(); - private static readonly object s_autosizeColumnModeChangedEvent = new object(); - private static readonly object s_autosizeColumnsModeChangedEvent = new object(); - private static readonly object s_autosizeRowsModeChangedEvent = new object(); - private static readonly object s_backgroundColorChangedEvent = new object(); - private static readonly object s_borderStyleChangedEvent = new object(); - private static readonly object s_cancelRowEditEvent = new object(); - private static readonly object s_cellBeginEditEvent = new object(); - private static readonly object s_cellBorderStyleChangedEvent = new object(); - private static readonly object s_cellClickEvent = new object(); - private static readonly object s_cellContentClickEvent = new object(); - private static readonly object s_cellContentDoubleClickEvent = new object(); - private static readonly object s_cellContextMenuStripChangedEvent = new object(); - private static readonly object s_cellContextMenuStripNeededEvent = new object(); - private static readonly object s_cellDoubleClickEvent = new object(); - private static readonly object s_cellEndEditEvent = new object(); - private static readonly object s_cellEnterEvent = new object(); - private static readonly object s_cellErrorTextChangedEvent = new object(); - private static readonly object s_cellErrorTextNeededEvent = new object(); - private static readonly object s_cellFormattingEvent = new object(); - private static readonly object s_cellLeaveEvent = new object(); - private static readonly object s_cellMouseClickEvent = new object(); - private static readonly object s_cellMouseDoubleClickEvent = new object(); - private static readonly object s_cellMouseDownEvent = new object(); - private static readonly object s_cellMouseEnterEvent = new object(); - private static readonly object s_cellMouseLeaveEvent = new object(); - private static readonly object s_cellMouseMoveEvent = new object(); - private static readonly object s_cellMouseUpEvent = new object(); - private static readonly object s_cellPaintingEvent = new object(); - private static readonly object s_cellParsingEvent = new object(); - private static readonly object s_cellStateChangedEvent = new object(); - private static readonly object s_cellStyleChangedEvent = new object(); - private static readonly object s_cellStyleContentChangedEvent = new object(); - private static readonly object s_cellTooltipTextChangedEvent = new object(); - private static readonly object s_cellTooltipTextNeededEvent = new object(); - private static readonly object s_cellValidatingEvent = new object(); - private static readonly object s_cellValidatedEvent = new object(); - private static readonly object s_cellValueChangedEvent = new object(); - private static readonly object s_cellValueNeededEvent = new object(); - private static readonly object s_cellValuePushedEvent = new object(); - private static readonly object s_columnAddedEvent = new object(); - private static readonly object s_columnContextMenuStripChangedEvent = new object(); - private static readonly object s_columnDataPropertyNameChangedEvent = new object(); - private static readonly object s_columnDefaultCellStyleChangedEvent = new object(); - private static readonly object s_columnDisplayIndexChangedEvent = new object(); - private static readonly object s_columnDividerWidthChangedEvent = new object(); - private static readonly object s_columnHeaderCellChangedEvent = new object(); - private static readonly object s_columnDividerDoubleClickEvent = new object(); - private static readonly object s_columnHeaderMouseClickEvent = new object(); - private static readonly object s_columnHeaderMouseDoubleClickEvent = new object(); - private static readonly object s_columnHeadersBorderStyleChangedEvent = new object(); - private static readonly object s_columnHeadersDefaultCellStyleChangedEvent = new object(); - private static readonly object s_columnHeadersHeightChangedEvent = new object(); - private static readonly object s_columnHeadersHeightSizeModeChangedEvent = new object(); - private static readonly object s_columnMinimumWidthChangedEvent = new object(); - private static readonly object s_columnNameChangedEvent = new object(); - private static readonly object s_columnRemovedEvent = new object(); - private static readonly object s_columnSortModeChangedEvent = new object(); - private static readonly object s_columnStateChangedEvent = new object(); - private static readonly object s_columnTooltipTextChangedEvent = new object(); - private static readonly object s_columnWidthChangedEvent = new object(); - private static readonly object s_currentCellChangedEvent = new object(); - private static readonly object s_currentCellDirtyStateChangedEvent = new object(); - private static readonly object s_dataBindingCompleteEvent = new object(); - private static readonly object s_dataErrorEvent = new object(); - private static readonly object s_dataMemberChangedEvent = new object(); - private static readonly object s_dataSourceChangedEvent = new object(); - private static readonly object s_defaultCellStyleChangedEvent = new object(); - private static readonly object s_defaultValuesNeededEvent = new object(); - private static readonly object s_editingControlShowingEvent = new object(); - private static readonly object s_editModeChangedEvent = new object(); - private static readonly object s_gridColorChangedEvent = new object(); - private static readonly object s_multiselectChangedEvent = new object(); - private static readonly object s_newRowNeededEvent = new object(); - private static readonly object s_readOnlyChangedEvent = new object(); - private static readonly object s_rowContextMenuStripChangedEvent = new object(); - private static readonly object s_rowContextMenuStripNeededEvent = new object(); - private static readonly object s_rowDefaultCellStyleChangedEvent = new object(); - private static readonly object s_rowDirtyStateNeededEvent = new object(); - private static readonly object s_rowDividerHeightChangedEvent = new object(); - private static readonly object s_rowEnterEvent = new object(); - private static readonly object s_rowErrorTextChangedEvent = new object(); - private static readonly object s_rowErrorTextNeededEvent = new object(); - private static readonly object s_rowHeaderCellChangedEvent = new object(); - private static readonly object s_rowDividerDoubleClickEvent = new object(); - private static readonly object s_rowHeaderMouseClickEvent = new object(); - private static readonly object s_rowHeaderMouseDoubleClickEvent = new object(); - private static readonly object s_rowHeadersBorderStyleChangedEvent = new object(); - private static readonly object s_rowHeadersDefaultCellStyleChangedEvent = new object(); - private static readonly object s_rowHeadersWidthChangedEvent = new object(); - private static readonly object s_rowHeadersWidthSizeModeChangedEvent = new object(); - private static readonly object s_rowHeightChangedEvent = new object(); - private static readonly object s_rowHeightInfoNeededEvent = new object(); - private static readonly object s_rowHeightInfoPushedEvent = new object(); - private static readonly object s_rowLeaveEvent = new object(); - private static readonly object s_rowMinimumHeightChangeEvent = new object(); - private static readonly object s_rowPostPaintEvent = new object(); - private static readonly object s_rowPrePaintEvent = new object(); - private static readonly object s_rowsAddedEvent = new object(); - private static readonly object s_rowsDefaultCellStyleChangedEvent = new object(); - private static readonly object s_rowsRemovedEvent = new object(); - private static readonly object s_rowStateChangedEvent = new object(); - private static readonly object s_rowUnsharedEvent = new object(); - private static readonly object s_rowValidatedEvent = new object(); - private static readonly object s_rowValidatingEvent = new object(); - private static readonly object s_scrollEvent = new object(); - private static readonly object s_selectionChangedEvent = new object(); - private static readonly object s_sortCompareEvent = new object(); - private static readonly object s_sortedEvent = new object(); - private static readonly object s_userAddedRowEvent = new object(); - private static readonly object s_userDeletedRowEvent = new object(); - private static readonly object s_userDeletingRowEvent = new object(); + private static readonly object s_allowUserToAddRowsChangedEvent = new(); + private static readonly object s_allowUserToDeleteRowsChangedEvent = new(); + private static readonly object s_allowUserToOrderColumnsChangedEvent = new(); + private static readonly object s_allowUserToResizeColumnsChangedEvent = new(); + private static readonly object s_allowUserToResizeRowsChangedEvent = new(); + private static readonly object s_alternatingRowsDefaultCellStyleChangedEvent = new(); + private static readonly object s_autoGenerateColumnsChangedEvent = new(); + private static readonly object s_autosizeColumnModeChangedEvent = new(); + private static readonly object s_autosizeColumnsModeChangedEvent = new(); + private static readonly object s_autosizeRowsModeChangedEvent = new(); + private static readonly object s_backgroundColorChangedEvent = new(); + private static readonly object s_borderStyleChangedEvent = new(); + private static readonly object s_cancelRowEditEvent = new(); + private static readonly object s_cellBeginEditEvent = new(); + private static readonly object s_cellBorderStyleChangedEvent = new(); + private static readonly object s_cellClickEvent = new(); + private static readonly object s_cellContentClickEvent = new(); + private static readonly object s_cellContentDoubleClickEvent = new(); + private static readonly object s_cellContextMenuStripChangedEvent = new(); + private static readonly object s_cellContextMenuStripNeededEvent = new(); + private static readonly object s_cellDoubleClickEvent = new(); + private static readonly object s_cellEndEditEvent = new(); + private static readonly object s_cellEnterEvent = new(); + private static readonly object s_cellErrorTextChangedEvent = new(); + private static readonly object s_cellErrorTextNeededEvent = new(); + private static readonly object s_cellFormattingEvent = new(); + private static readonly object s_cellLeaveEvent = new(); + private static readonly object s_cellMouseClickEvent = new(); + private static readonly object s_cellMouseDoubleClickEvent = new(); + private static readonly object s_cellMouseDownEvent = new(); + private static readonly object s_cellMouseEnterEvent = new(); + private static readonly object s_cellMouseLeaveEvent = new(); + private static readonly object s_cellMouseMoveEvent = new(); + private static readonly object s_cellMouseUpEvent = new(); + private static readonly object s_cellPaintingEvent = new(); + private static readonly object s_cellParsingEvent = new(); + private static readonly object s_cellStateChangedEvent = new(); + private static readonly object s_cellStyleChangedEvent = new(); + private static readonly object s_cellStyleContentChangedEvent = new(); + private static readonly object s_cellTooltipTextChangedEvent = new(); + private static readonly object s_cellTooltipTextNeededEvent = new(); + private static readonly object s_cellValidatingEvent = new(); + private static readonly object s_cellValidatedEvent = new(); + private static readonly object s_cellValueChangedEvent = new(); + private static readonly object s_cellValueNeededEvent = new(); + private static readonly object s_cellValuePushedEvent = new(); + private static readonly object s_columnAddedEvent = new(); + private static readonly object s_columnContextMenuStripChangedEvent = new(); + private static readonly object s_columnDataPropertyNameChangedEvent = new(); + private static readonly object s_columnDefaultCellStyleChangedEvent = new(); + private static readonly object s_columnDisplayIndexChangedEvent = new(); + private static readonly object s_columnDividerWidthChangedEvent = new(); + private static readonly object s_columnHeaderCellChangedEvent = new(); + private static readonly object s_columnDividerDoubleClickEvent = new(); + private static readonly object s_columnHeaderMouseClickEvent = new(); + private static readonly object s_columnHeaderMouseDoubleClickEvent = new(); + private static readonly object s_columnHeadersBorderStyleChangedEvent = new(); + private static readonly object s_columnHeadersDefaultCellStyleChangedEvent = new(); + private static readonly object s_columnHeadersHeightChangedEvent = new(); + private static readonly object s_columnHeadersHeightSizeModeChangedEvent = new(); + private static readonly object s_columnMinimumWidthChangedEvent = new(); + private static readonly object s_columnNameChangedEvent = new(); + private static readonly object s_columnRemovedEvent = new(); + private static readonly object s_columnSortModeChangedEvent = new(); + private static readonly object s_columnStateChangedEvent = new(); + private static readonly object s_columnTooltipTextChangedEvent = new(); + private static readonly object s_columnWidthChangedEvent = new(); + private static readonly object s_currentCellChangedEvent = new(); + private static readonly object s_currentCellDirtyStateChangedEvent = new(); + private static readonly object s_dataBindingCompleteEvent = new(); + private static readonly object s_dataErrorEvent = new(); + private static readonly object s_dataMemberChangedEvent = new(); + private static readonly object s_dataSourceChangedEvent = new(); + private static readonly object s_defaultCellStyleChangedEvent = new(); + private static readonly object s_defaultValuesNeededEvent = new(); + private static readonly object s_editingControlShowingEvent = new(); + private static readonly object s_editModeChangedEvent = new(); + private static readonly object s_gridColorChangedEvent = new(); + private static readonly object s_multiselectChangedEvent = new(); + private static readonly object s_newRowNeededEvent = new(); + private static readonly object s_readOnlyChangedEvent = new(); + private static readonly object s_rowContextMenuStripChangedEvent = new(); + private static readonly object s_rowContextMenuStripNeededEvent = new(); + private static readonly object s_rowDefaultCellStyleChangedEvent = new(); + private static readonly object s_rowDirtyStateNeededEvent = new(); + private static readonly object s_rowDividerHeightChangedEvent = new(); + private static readonly object s_rowEnterEvent = new(); + private static readonly object s_rowErrorTextChangedEvent = new(); + private static readonly object s_rowErrorTextNeededEvent = new(); + private static readonly object s_rowHeaderCellChangedEvent = new(); + private static readonly object s_rowDividerDoubleClickEvent = new(); + private static readonly object s_rowHeaderMouseClickEvent = new(); + private static readonly object s_rowHeaderMouseDoubleClickEvent = new(); + private static readonly object s_rowHeadersBorderStyleChangedEvent = new(); + private static readonly object s_rowHeadersDefaultCellStyleChangedEvent = new(); + private static readonly object s_rowHeadersWidthChangedEvent = new(); + private static readonly object s_rowHeadersWidthSizeModeChangedEvent = new(); + private static readonly object s_rowHeightChangedEvent = new(); + private static readonly object s_rowHeightInfoNeededEvent = new(); + private static readonly object s_rowHeightInfoPushedEvent = new(); + private static readonly object s_rowLeaveEvent = new(); + private static readonly object s_rowMinimumHeightChangeEvent = new(); + private static readonly object s_rowPostPaintEvent = new(); + private static readonly object s_rowPrePaintEvent = new(); + private static readonly object s_rowsAddedEvent = new(); + private static readonly object s_rowsDefaultCellStyleChangedEvent = new(); + private static readonly object s_rowsRemovedEvent = new(); + private static readonly object s_rowStateChangedEvent = new(); + private static readonly object s_rowUnsharedEvent = new(); + private static readonly object s_rowValidatedEvent = new(); + private static readonly object s_rowValidatingEvent = new(); + private static readonly object s_scrollEvent = new(); + private static readonly object s_selectionChangedEvent = new(); + private static readonly object s_sortCompareEvent = new(); + private static readonly object s_sortedEvent = new(); + private static readonly object s_userAddedRowEvent = new(); + private static readonly object s_userDeletedRowEvent = new(); + private static readonly object s_userDeletingRowEvent = new(); private const int State1_AllowUserToAddRows = 0x00000001; private const int State1_AllowUserToDeleteRows = 0x00000002; @@ -255,24 +252,30 @@ private const DataGridViewAdvancedCellBorderStyle DefaultAdvancedColumnHeadersBo private const DataGridViewAutoSizeRowCriteriaInternal InvalidDataGridViewAutoSizeRowCriteriaInternalMask = ~(DataGridViewAutoSizeRowCriteriaInternal.Header | DataGridViewAutoSizeRowCriteriaInternal.AllColumns); - private Cursor _oldCursor; - - private HScrollBar _horizScrollBar = new HScrollBar(); - private VScrollBar _vertScrollBar = new VScrollBar(); - private DataGridViewHeaderCell _topLeftHeaderCell; - - private DataGridViewRow _rowTemplate; - private DataGridViewRowCollection _dataGridViewRows; - private DataGridViewColumnCollection _dataGridViewColumns; - - private DataGridViewCellStyle _placeholderCellStyle; - private StringFormat _placeholderStringFormat; - private object _uneditedFormattedValue; - private Control _latestEditingControl, _cachedEditingControl; - private Panel _editingPanel; - private DataGridViewEditingPanelAccessibleObject _editingPanelAccessibleObject; - private Point _ptCurrentCell, _ptCurrentCellCache = Point.Empty, _ptAnchorCell, _ptMouseDownCell, - _ptMouseEnteredCell, _ptToolTipCell, _ptMouseDownGridCoord; + private Cursor? _oldCursor; + + private HScrollBar _horizScrollBar = new(); + private VScrollBar _vertScrollBar = new(); + private DataGridViewHeaderCell? _topLeftHeaderCell; + + private DataGridViewRow? _rowTemplate; + private DataGridViewRowCollection? _dataGridViewRows; + private DataGridViewColumnCollection? _dataGridViewColumns; + + private DataGridViewCellStyle? _placeholderCellStyle; + private StringFormat? _placeholderStringFormat; + private object? _uneditedFormattedValue; + private Control? _latestEditingControl; + private Control? _cachedEditingControl; + private Panel? _editingPanel; + private DataGridViewEditingPanelAccessibleObject? _editingPanelAccessibleObject; + private Point _ptCurrentCell; + private Point _ptCurrentCellCache = Point.Empty; + private Point _ptAnchorCell; + private Point _ptMouseDownCell; + private Point _ptMouseEnteredCell; + private Point _ptToolTipCell; + private Point _ptMouseDownGridCoord; private DataGridViewSelectionMode _selectionMode; private DataGridViewEditMode _editMode; @@ -281,10 +284,13 @@ private const DataGridViewAutoSizeRowCriteriaInternal InvalidDataGridViewAutoSiz private readonly DataGridViewCellLinkedList _individualSelectedCells; private readonly DataGridViewCellLinkedList _individualReadOnlyCells; private readonly DataGridViewIntLinkedList _selectedBandIndexes; - private DataGridViewIntLinkedList _selectedBandSnapshotIndexes; + private DataGridViewIntLinkedList? _selectedBandSnapshotIndexes; - private DataGridViewCellStyle _defaultCellStyle, _columnHeadersDefaultCellStyle, _rowHeadersDefaultCellStyle; - private DataGridViewCellStyle _rowsDefaultCellStyle, _alternatingRowsDefaultCellStyle; + private DataGridViewCellStyle? _defaultCellStyle; + private DataGridViewCellStyle? _columnHeadersDefaultCellStyle; + private DataGridViewCellStyle? _rowHeadersDefaultCellStyle; + private DataGridViewCellStyle? _rowsDefaultCellStyle; + private DataGridViewCellStyle? _alternatingRowsDefaultCellStyle; private ScrollBars _scrollBars; private LayoutData _layout; private Rectangle _normalClientRectangle; @@ -309,12 +315,12 @@ private const DataGridViewAutoSizeRowCriteriaInternal InvalidDataGridViewAutoSiz private DataGridViewColumnHeadersHeightSizeMode _columnHeadersHeightSizeMode; private DataGridViewRowHeadersWidthSizeMode _rowHeadersWidthSizeMode; - private DataGridViewCellStyleChangedEventArgs _dgvcsce; - private DataGridViewCellPaintingEventArgs _dgvcpe; - private DataGridViewCellValueEventArgs _dgvcve; - private DataGridViewRowHeightInfoNeededEventArgs _dgvrhine; - private DataGridViewRowPostPaintEventArgs _dgvrpope; - private DataGridViewRowPrePaintEventArgs _dgvrprpe; + private DataGridViewCellStyleChangedEventArgs? _dgvcsce; + private DataGridViewCellPaintingEventArgs? _dgvcpe; + private DataGridViewCellValueEventArgs? _dgvcve; + private DataGridViewRowHeightInfoNeededEventArgs? _dgvrhine; + private DataGridViewRowPostPaintEventArgs? _dgvrpope; + private DataGridViewRowPrePaintEventArgs? _dgvrprpe; // The sum of the widths in pixels of the scrolling columns preceding the first visible scrolling column. private int _horizontalOffset; @@ -343,14 +349,15 @@ private const DataGridViewAutoSizeRowCriteriaInternal InvalidDataGridViewAutoSiz private int _keyboardResizeStep; private Rectangle _resizeClipRectangle; - private Timer _vertScrollTimer, _horizScrollTimer; + private Timer? _vertScrollTimer; + private Timer? _horizScrollTimer; private readonly Dictionary _converters; private static Color s_defaultBackColor = SystemColors.Window; private static Color s_defaultBackgroundColor = SystemColors.ControlDark; private Color _backgroundColor = s_defaultBackgroundColor; - private RECT[] _cachedScrollableRegion; + private RECT[]? _cachedScrollableRegion; // ToolTip private readonly DataGridViewToolTip _toolTipControl; @@ -684,7 +691,7 @@ internal bool AllowUserToAddRowsInternal [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.DataGridViewOnAllowUserToAddRowsChangedDescr))] - public event EventHandler AllowUserToAddRowsChanged + public event EventHandler? AllowUserToAddRowsChanged { add => Events.AddHandler(s_allowUserToAddRowsChangedEvent, value); remove => Events.RemoveHandler(s_allowUserToAddRowsChangedEvent, value); @@ -726,7 +733,7 @@ internal bool AllowUserToDeleteRowsInternal [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.DataGridViewOnAllowUserToDeleteRowsChangedDescr))] - public event EventHandler AllowUserToDeleteRowsChanged + public event EventHandler? AllowUserToDeleteRowsChanged { add => Events.AddHandler(s_allowUserToDeleteRowsChangedEvent, value); remove => Events.RemoveHandler(s_allowUserToDeleteRowsChangedEvent, value); @@ -753,7 +760,7 @@ public bool AllowUserToOrderColumns [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.DataGridViewOnAllowUserToOrderColumnsChangedDescr))] - public event EventHandler AllowUserToOrderColumnsChanged + public event EventHandler? AllowUserToOrderColumnsChanged { add => Events.AddHandler(s_allowUserToOrderColumnsChangedEvent, value); remove => Events.RemoveHandler(s_allowUserToOrderColumnsChangedEvent, value); @@ -784,7 +791,7 @@ public bool AllowUserToResizeColumns [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.DataGridViewOnAllowUserToResizeColumnsChangedDescr))] - public event EventHandler AllowUserToResizeColumnsChanged + public event EventHandler? AllowUserToResizeColumnsChanged { add => Events.AddHandler(s_allowUserToResizeColumnsChangedEvent, value); remove => Events.RemoveHandler(s_allowUserToResizeColumnsChangedEvent, value); @@ -815,7 +822,7 @@ public bool AllowUserToResizeRows [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.DataGridViewOnAllowUserToResizeRowsChangedDescr))] - public event EventHandler AllowUserToResizeRowsChanged + public event EventHandler? AllowUserToResizeRowsChanged { add => Events.AddHandler(s_allowUserToResizeRowsChangedEvent, value); remove => Events.RemoveHandler(s_allowUserToResizeRowsChangedEvent, value); @@ -823,6 +830,7 @@ public event EventHandler AllowUserToResizeRowsChanged [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.DataGridView_AlternatingRowsDefaultCellStyleDescr))] + [AllowNull] public DataGridViewCellStyle AlternatingRowsDefaultCellStyle { get @@ -840,10 +848,7 @@ public DataGridViewCellStyle AlternatingRowsDefaultCellStyle DataGridViewCellStyle cs = AlternatingRowsDefaultCellStyle; cs.RemoveScope(DataGridViewCellStyleScopes.AlternatingRows); _alternatingRowsDefaultCellStyle = value; - if (value is not null) - { - _alternatingRowsDefaultCellStyle.AddScope(this, DataGridViewCellStyleScopes.AlternatingRows); - } + _alternatingRowsDefaultCellStyle?.AddScope(this, DataGridViewCellStyleScopes.AlternatingRows); DataGridViewCellStyleDifferences dgvcsc = cs.GetDifferencesFrom(AlternatingRowsDefaultCellStyle); if (dgvcsc != DataGridViewCellStyleDifferences.None) @@ -856,7 +861,7 @@ public DataGridViewCellStyle AlternatingRowsDefaultCellStyle [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.DataGridViewAlternatingRowsDefaultCellStyleChangedDescr))] - public event EventHandler AlternatingRowsDefaultCellStyleChanged + public event EventHandler? AlternatingRowsDefaultCellStyleChanged { add => Events.AddHandler(s_alternatingRowsDefaultCellStyleChangedEvent, value); remove => Events.RemoveHandler(s_alternatingRowsDefaultCellStyleChangedEvent, value); @@ -899,7 +904,7 @@ public bool AutoGenerateColumns [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Advanced)] - public event EventHandler AutoGenerateColumnsChanged + public event EventHandler? AutoGenerateColumnsChanged { add => Events.AddHandler(s_autoGenerateColumnsChangedEvent, value); remove => Events.RemoveHandler(s_autoGenerateColumnsChangedEvent, value); @@ -990,7 +995,7 @@ public DataGridViewAutoSizeColumnsMode AutoSizeColumnsMode [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.DataGridViewAutoSizeColumnsModeChangedDescr))] - public event DataGridViewAutoSizeColumnsModeEventHandler AutoSizeColumnsModeChanged + public event DataGridViewAutoSizeColumnsModeEventHandler? AutoSizeColumnsModeChanged { add => Events.AddHandler(s_autosizeColumnsModeChangedEvent, value); remove => Events.RemoveHandler(s_autosizeColumnsModeChangedEvent, value); @@ -1041,7 +1046,7 @@ public DataGridViewAutoSizeRowsMode AutoSizeRowsMode [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.DataGridViewAutoSizeRowsModeChangedDescr))] - public event DataGridViewAutoSizeModeEventHandler AutoSizeRowsModeChanged + public event DataGridViewAutoSizeModeEventHandler? AutoSizeRowsModeChanged { add => Events.AddHandler(s_autosizeRowsModeChangedEvent, value); remove => Events.RemoveHandler(s_autosizeRowsModeChangedEvent, value); @@ -1058,7 +1063,7 @@ public override Color BackColor [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public new event EventHandler BackColorChanged + public new event EventHandler? BackColorChanged { add => base.BackColorChanged += value; remove => base.BackColorChanged -= value; @@ -1089,7 +1094,7 @@ public Color BackgroundColor [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.DataGridViewBackgroundColorChangedDescr))] - public event EventHandler BackgroundColorChanged + public event EventHandler? BackgroundColorChanged { add => Events.AddHandler(s_backgroundColorChangedEvent, value); remove => Events.RemoveHandler(s_backgroundColorChangedEvent, value); @@ -1097,7 +1102,7 @@ public event EventHandler BackgroundColorChanged [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public override Image BackgroundImage + public override Image? BackgroundImage { get => base.BackgroundImage; set => base.BackgroundImage = value; @@ -1113,7 +1118,7 @@ public override ImageLayout BackgroundImageLayout [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public new event EventHandler BackgroundImageChanged + public new event EventHandler? BackgroundImageChanged { add => base.BackgroundImageChanged += value; remove => base.BackgroundImageChanged -= value; @@ -1121,14 +1126,14 @@ public override ImageLayout BackgroundImageLayout [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public new event EventHandler BackgroundImageLayoutChanged + public new event EventHandler? BackgroundImageLayoutChanged { add => base.BackgroundImageLayoutChanged += value; remove => base.BackgroundImageLayoutChanged -= value; } private bool ShouldSerializeBackgroundColor() => !BackgroundColor.Equals(s_defaultBackgroundColor); - +#nullable disable [DefaultValue(BorderStyle.FixedSingle)] [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.DataGridView_BorderStyleDescr))] @@ -2624,10 +2629,8 @@ public int FirstDisplayedScrollingColumnIndex } set { - if (value < 0 || value >= Columns.Count) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } + ArgumentOutOfRangeException.ThrowIfNegative(value); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(value, Columns.Count); if (!Columns[value].Visible) { @@ -2701,10 +2704,8 @@ public int FirstDisplayedScrollingRowIndex } set { - if (value < 0 || value >= Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } + ArgumentOutOfRangeException.ThrowIfNegative(value); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(value, Rows.Count); if ((Rows.GetRowState(value) & DataGridViewElementStates.Visible) == 0) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAdvancedBorderStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAdvancedBorderStyle.cs index 8cb7e5d605c..de7eadd5c01 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAdvancedBorderStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAdvancedBorderStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAdvancedCellBorderStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAdvancedCellBorderStyle.cs index 2e500059cae..c9cd9cfdd14 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAdvancedCellBorderStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAdvancedCellBorderStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnCriteriaInternal.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnCriteriaInternal.cs index 7d95f61011f..e3a61601b9a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnCriteriaInternal.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnCriteriaInternal.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnMode.cs index 213c97a0ee1..17179645b2e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnModeEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnModeEventArgs.cs index 7202f60f557..a1012aeeaf5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnModeEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnModeEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnsMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnsMode.cs index 5a8ff73cfb8..b1d9a9ee014 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnsMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnsMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnsModeEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnsModeEventArgs.cs index cabc0c16714..512f6a14894 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnsModeEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeColumnsModeEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeModeEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeModeEventArgs.cs index e30fd0b12cb..4e6ada76121 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeModeEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeModeEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowCriteriaInternal.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowCriteriaInternal.cs index 39110cb91b1..c0f3da807fb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowCriteriaInternal.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowCriteriaInternal.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowMode.cs index 7f0c1189ebc..f1b09ae4b56 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowsMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowsMode.cs index 883812e6498..41e51cf8d50 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowsMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowsMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowsModeInternal.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowsModeInternal.cs index 980f59fbcc4..f3a8dbd275a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowsModeInternal.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewAutoSizeRowsModeInternal.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewBand.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewBand.cs index bcd3c5d3bcd..85a6b17bb41 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewBand.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewBand.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewBindingCompleteEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewBindingCompleteEventArgs.cs index 5f151a574cb..cd13f9712e9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewBindingCompleteEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewBindingCompleteEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.DataGridViewButtonCellAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.DataGridViewButtonCellAccessibleObject.cs index 96e82e14927..d5a0e4c1ac6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.DataGridViewButtonCellAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.DataGridViewButtonCellAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.DataGridViewButtonCellRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.DataGridViewButtonCellRenderer.cs index 0a3466c4e02..f9c8a6bb2af 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.DataGridViewButtonCellRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.DataGridViewButtonCellRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; @@ -17,7 +16,7 @@ public static VisualStyleRenderer DataGridViewButtonRenderer { get { - s_visualStyleRenderer ??= new VisualStyleRenderer(ButtonElement); + s_visualStyleRenderer ??= new VisualStyleRenderer(s_buttonElement); return s_visualStyleRenderer; } @@ -25,7 +24,7 @@ public static VisualStyleRenderer DataGridViewButtonRenderer public static void DrawButton(Graphics g, Rectangle bounds, int buttonState) { - DataGridViewButtonRenderer.SetParameters(ButtonElement.ClassName, ButtonElement.Part, buttonState); + DataGridViewButtonRenderer.SetParameters(s_buttonElement.ClassName, s_buttonElement.Part, buttonState); DataGridViewButtonRenderer.DrawBackground(g, bounds, Rectangle.Truncate(g.ClipBounds)); } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.cs index 75ae1f15d74..ab8286119cf 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.Drawing; @@ -17,22 +14,22 @@ namespace System.Windows.Forms; [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] public partial class DataGridViewButtonCell : DataGridViewCell { - private static readonly int PropButtonCellFlatStyle = PropertyStore.CreateKey(); - private static readonly int PropButtonCellState = PropertyStore.CreateKey(); - private static readonly int PropButtonCellUseColumnTextForButtonValue = PropertyStore.CreateKey(); - private static readonly VisualStyleElement ButtonElement = VisualStyleElement.Button.PushButton.Normal; + private static readonly int s_propButtonCellFlatStyle = PropertyStore.CreateKey(); + private static readonly int s_propButtonCellState = PropertyStore.CreateKey(); + private static readonly int s_propButtonCellUseColumnTextForButtonValue = PropertyStore.CreateKey(); + private static readonly VisualStyleElement s_buttonElement = VisualStyleElement.Button.PushButton.Normal; private const byte DATAGRIDVIEWBUTTONCELL_themeMargin = 100; // Used to calculate the margins required for theming rendering private const byte DATAGRIDVIEWBUTTONCELL_horizontalTextMargin = 2; private const byte DATAGRIDVIEWBUTTONCELL_verticalTextMargin = 1; private const byte DATAGRIDVIEWBUTTONCELL_textPadding = 5; - private static Rectangle rectThemeMargins = new Rectangle(-1, -1, 0, 0); - private static bool mouseInContentBounds; + private static Rectangle s_rectThemeMargins = new(-1, -1, 0, 0); + private static bool s_mouseInContentBounds; - private static readonly Type defaultFormattedValueType = typeof(string); - private static readonly Type defaultValueType = typeof(object); - private static readonly Type cellType = typeof(DataGridViewButtonCell); + private static readonly Type s_defaultFormattedValueType = typeof(string); + private static readonly Type s_defaultValueType = typeof(object); + private static readonly Type s_cellType = typeof(DataGridViewButtonCell); public DataGridViewButtonCell() { @@ -42,7 +39,7 @@ private ButtonState ButtonState { get { - int buttonState = Properties.GetInteger(PropButtonCellState, out bool found); + int buttonState = Properties.GetInteger(s_propButtonCellState, out bool found); if (found) { return (ButtonState)buttonState; @@ -57,13 +54,13 @@ private ButtonState ButtonState Debug.Assert((value & ~(ButtonState.Normal | ButtonState.Pushed | ButtonState.Checked)) == 0); if (ButtonState != value) { - Properties.SetInteger(PropButtonCellState, (int)value); + Properties.SetInteger(s_propButtonCellState, (int)value); } } } [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.Interfaces)] - public override Type EditType + public override Type? EditType { get { @@ -77,7 +74,7 @@ public FlatStyle FlatStyle { get { - int flatStyle = Properties.GetInteger(PropButtonCellFlatStyle, out bool found); + int flatStyle = Properties.GetInteger(s_propButtonCellFlatStyle, out bool found); if (found) { return (FlatStyle)flatStyle; @@ -91,7 +88,7 @@ public FlatStyle FlatStyle SourceGenerated.EnumValidator.Validate(value); if (value != FlatStyle) { - Properties.SetInteger(PropButtonCellFlatStyle, (int)value); + Properties.SetInteger(s_propButtonCellFlatStyle, (int)value); OnCommonChange(); } } @@ -104,26 +101,21 @@ internal FlatStyle FlatStyleInternal Debug.Assert(value >= FlatStyle.Flat && value <= FlatStyle.System); if (value != FlatStyle) { - Properties.SetInteger(PropButtonCellFlatStyle, (int)value); + Properties.SetInteger(s_propButtonCellFlatStyle, (int)value); } } } - public override Type FormattedValueType - { - get - { - // we return string for the formatted type - return defaultFormattedValueType; - } - } + public override Type FormattedValueType => + // We return string for the formatted type. + s_defaultFormattedValueType; [DefaultValue(false)] public bool UseColumnTextForButtonValue { get { - int useColumnTextForButtonValue = Properties.GetInteger(PropButtonCellUseColumnTextForButtonValue, out bool found); + int useColumnTextForButtonValue = Properties.GetInteger(s_propButtonCellUseColumnTextForButtonValue, out bool found); if (found) { return useColumnTextForButtonValue == 0 ? false : true; @@ -135,7 +127,7 @@ public bool UseColumnTextForButtonValue { if (value != UseColumnTextForButtonValue) { - Properties.SetInteger(PropButtonCellUseColumnTextForButtonValue, value ? 1 : 0); + Properties.SetInteger(s_propButtonCellUseColumnTextForButtonValue, value ? 1 : 0); OnCommonChange(); } } @@ -147,7 +139,7 @@ internal bool UseColumnTextForButtonValueInternal { if (value != UseColumnTextForButtonValue) { - Properties.SetInteger(PropButtonCellUseColumnTextForButtonValue, value ? 1 : 0); + Properties.SetInteger(s_propButtonCellUseColumnTextForButtonValue, value ? 1 : 0); } } } @@ -162,7 +154,7 @@ public override Type ValueType return valueType; } - return defaultValueType; + return s_defaultValueType; } } @@ -171,13 +163,13 @@ public override object Clone() DataGridViewButtonCell dataGridViewCell; Type thisType = GetType(); - if (thisType == cellType) //performance improvement + if (thisType == s_cellType) //performance improvement { dataGridViewCell = new DataGridViewButtonCell(); } else { - dataGridViewCell = (DataGridViewButtonCell)System.Activator.CreateInstance(thisType); + dataGridViewCell = (DataGridViewButtonCell)Activator.CreateInstance(thisType)!; } base.CloneInternal(dataGridViewCell); @@ -186,10 +178,7 @@ public override object Clone() return dataGridViewCell; } - protected override AccessibleObject CreateAccessibilityInstance() - { - return new DataGridViewButtonCellAccessibleObject(this); - } + protected override AccessibleObject CreateAccessibilityInstance() => new DataGridViewButtonCellAccessibleObject(this); protected override Rectangle GetContentBounds(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) { @@ -206,7 +195,8 @@ protected override Rectangle GetContentBounds(Graphics graphics, DataGridViewCel out DataGridViewElementStates cellState, out Rectangle cellBounds); - Rectangle contentBounds = PaintPrivate(graphics, + Rectangle contentBounds = PaintPrivate( + graphics, cellBounds, cellBounds, rowIndex, @@ -221,27 +211,28 @@ protected override Rectangle GetContentBounds(Graphics graphics, DataGridViewCel paint: false); #if DEBUG - object value = GetValue(rowIndex); - Rectangle contentBoundsDebug = PaintPrivate(graphics, + object? value = GetValue(rowIndex); + Rectangle contentBoundsDebug = PaintPrivate( + graphics, cellBounds, cellBounds, rowIndex, cellState, - GetFormattedValue(value, rowIndex, ref cellStyle, null, null, DataGridViewDataErrorContexts.Formatting), + GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter: null, formattedValueTypeConverter: null, DataGridViewDataErrorContexts.Formatting), GetErrorText(rowIndex), cellStyle, dgvabsEffective, DataGridViewPaintParts.ContentForeground, - true /*computeContentBounds*/, - false /*computeErrorIconBounds*/, - false /*paint*/); + computeContentBounds: true, + computeErrorIconBounds: false, + paint: false); Debug.Assert(contentBoundsDebug.Equals(contentBounds)); #endif return contentBounds; } - private protected override string GetDefaultToolTipText() + private protected override string? GetDefaultToolTipText() { if (string.IsNullOrEmpty(Value?.ToString()?.Trim(' ')) || Value is DBNull) { @@ -264,44 +255,54 @@ OwningColumn is null || return Rectangle.Empty; } - ComputeBorderStyleCellStateAndCellBounds(rowIndex, out DataGridViewAdvancedBorderStyle dgvabsEffective, out DataGridViewElementStates cellState, out Rectangle cellBounds); + ComputeBorderStyleCellStateAndCellBounds( + rowIndex, + out DataGridViewAdvancedBorderStyle dgvabsEffective, + out DataGridViewElementStates cellState, + out Rectangle cellBounds); - Rectangle errorIconBounds = PaintPrivate(graphics, + Rectangle errorIconBounds = PaintPrivate( + graphics, cellBounds, cellBounds, rowIndex, cellState, - null /*formattedValue*/, // errorIconBounds is independent of formattedValue + formattedValue: null, // errorIconBounds is independent of formattedValue GetErrorText(rowIndex), cellStyle, dgvabsEffective, DataGridViewPaintParts.ContentForeground, - false /*computeContentBounds*/, - true /*computeErrorIconBounds*/, - false /*paint*/); + computeContentBounds: false, + computeErrorIconBounds: true, + paint: false); #if DEBUG - object value = GetValue(rowIndex); - Rectangle errorIconBoundsDebug = PaintPrivate(graphics, + object? value = GetValue(rowIndex); + Rectangle errorIconBoundsDebug = PaintPrivate( + graphics, cellBounds, cellBounds, rowIndex, cellState, - GetFormattedValue(value, rowIndex, ref cellStyle, null, null, DataGridViewDataErrorContexts.Formatting), + GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter: null, formattedValueTypeConverter: null, DataGridViewDataErrorContexts.Formatting), GetErrorText(rowIndex), cellStyle, dgvabsEffective, DataGridViewPaintParts.ContentForeground, - false /*computeContentBounds*/, - true /*computeErrorIconBounds*/, - false /*paint*/); + computeContentBounds: false, + computeErrorIconBounds: true, + paint: false); Debug.Assert(errorIconBoundsDebug.Equals(errorIconBounds)); #endif return errorIconBounds; } - protected override Size GetPreferredSize(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) + protected override Size GetPreferredSize( + Graphics graphics, + DataGridViewCellStyle cellStyle, + int rowIndex, + Size constraintSize) { if (DataGridView is null) { @@ -316,7 +317,7 @@ protected override Size GetPreferredSize(Graphics graphics, DataGridViewCellStyl int borderAndPaddingHeights = borderWidthsRect.Top + borderWidthsRect.Height + cellStyle.Padding.Vertical; DataGridViewFreeDimension freeDimension = DataGridViewCell.GetFreeDimensionFromConstraint(constraintSize); int marginWidths, marginHeights; - string formattedString = GetFormattedValue(rowIndex, ref cellStyle, DataGridViewDataErrorContexts.Formatting | DataGridViewDataErrorContexts.PreferredSize) as string; + string? formattedString = GetFormattedValue(rowIndex, ref cellStyle, DataGridViewDataErrorContexts.Formatting | DataGridViewDataErrorContexts.PreferredSize) as string; if (string.IsNullOrEmpty(formattedString)) { formattedString = " "; @@ -349,8 +350,7 @@ protected override Size GetPreferredSize(Graphics graphics, DataGridViewCellStyl graphics, formattedString, cellStyle.Font, - constraintSize.Height - borderAndPaddingHeights - marginHeights - 2 - * DATAGRIDVIEWBUTTONCELL_verticalTextMargin, + constraintSize.Height - borderAndPaddingHeights - marginHeights - 2 * DATAGRIDVIEWBUTTONCELL_verticalTextMargin, flags), 0); } @@ -432,62 +432,49 @@ protected override Size GetPreferredSize(Graphics graphics, DataGridViewCellStyl private static Rectangle GetThemeMargins(Graphics g) { - if (rectThemeMargins.X == -1) + if (s_rectThemeMargins.X == -1) { Rectangle rectCell = new Rectangle(0, 0, DATAGRIDVIEWBUTTONCELL_themeMargin, DATAGRIDVIEWBUTTONCELL_themeMargin); Rectangle rectContent = DataGridViewButtonCellRenderer.DataGridViewButtonRenderer.GetBackgroundContentRectangle(g, rectCell); - rectThemeMargins.X = rectContent.X; - rectThemeMargins.Y = rectContent.Y; - rectThemeMargins.Width = DATAGRIDVIEWBUTTONCELL_themeMargin - rectContent.Right; - rectThemeMargins.Height = DATAGRIDVIEWBUTTONCELL_themeMargin - rectContent.Bottom; + s_rectThemeMargins.X = rectContent.X; + s_rectThemeMargins.Y = rectContent.Y; + s_rectThemeMargins.Width = DATAGRIDVIEWBUTTONCELL_themeMargin - rectContent.Right; + s_rectThemeMargins.Height = DATAGRIDVIEWBUTTONCELL_themeMargin - rectContent.Bottom; } - return rectThemeMargins; + return s_rectThemeMargins; } - protected override object GetValue(int rowIndex) + protected override object? GetValue(int rowIndex) { if (UseColumnTextForButtonValue && DataGridView is not null && DataGridView.NewRowIndex != rowIndex && - OwningColumn is not null && - OwningColumn is DataGridViewButtonColumn) + OwningColumn is DataGridViewButtonColumn dataGridViewButtonColumn) { - return ((DataGridViewButtonColumn)OwningColumn).Text; + return dataGridViewButtonColumn.Text; } return base.GetValue(rowIndex); } - protected override bool KeyDownUnsharesRow(KeyEventArgs e, int rowIndex) - { - return e.KeyCode == Keys.Space && !e.Alt && !e.Control && !e.Shift; - } + protected override bool KeyDownUnsharesRow(KeyEventArgs e, int rowIndex) => + e.KeyCode == Keys.Space && !e.Alt && !e.Control && !e.Shift; - protected override bool KeyUpUnsharesRow(KeyEventArgs e, int rowIndex) - { - return e.KeyCode == Keys.Space; - } + protected override bool KeyUpUnsharesRow(KeyEventArgs e, int rowIndex) => + e.KeyCode == Keys.Space; - protected override bool MouseDownUnsharesRow(DataGridViewCellMouseEventArgs e) - { - return e.Button == MouseButtons.Left; - } + protected override bool MouseDownUnsharesRow(DataGridViewCellMouseEventArgs e) => + e.Button == MouseButtons.Left; - protected override bool MouseEnterUnsharesRow(int rowIndex) - { - return ColumnIndex == DataGridView.MouseDownCellAddress.X && rowIndex == DataGridView.MouseDownCellAddress.Y; - } + protected override bool MouseEnterUnsharesRow(int rowIndex) => + ColumnIndex == DataGridView!.MouseDownCellAddress.X && rowIndex == DataGridView.MouseDownCellAddress.Y; - protected override bool MouseLeaveUnsharesRow(int rowIndex) - { - return (ButtonState & ButtonState.Pushed) != 0; - } + protected override bool MouseLeaveUnsharesRow(int rowIndex) => + (ButtonState & ButtonState.Pushed) != 0; - protected override bool MouseUpUnsharesRow(DataGridViewCellMouseEventArgs e) - { - return e.Button == MouseButtons.Left; - } + protected override bool MouseUpUnsharesRow(DataGridViewCellMouseEventArgs e) => + e.Button == MouseButtons.Left; protected override void OnKeyDown(KeyEventArgs e, int rowIndex) { @@ -549,7 +536,7 @@ protected override void OnMouseDown(DataGridViewCellMouseEventArgs e) return; } - if (e.Button == MouseButtons.Left && mouseInContentBounds) + if (e.Button == MouseButtons.Left && s_mouseInContentBounds) { Debug.Assert(DataGridView.CellMouseDownInContentBounds); UpdateButtonState(ButtonState | ButtonState.Pushed, e.RowIndex); @@ -563,9 +550,9 @@ protected override void OnMouseLeave(int rowIndex) return; } - if (mouseInContentBounds) + if (s_mouseInContentBounds) { - mouseInContentBounds = false; + s_mouseInContentBounds = false; if (ColumnIndex >= 0 && rowIndex >= 0 && (DataGridView.ApplyVisualStylesToInnerCells || FlatStyle == FlatStyle.Flat || FlatStyle == FlatStyle.Popup)) @@ -589,9 +576,9 @@ protected override void OnMouseMove(DataGridViewCellMouseEventArgs e) return; } - bool oldMouseInContentBounds = mouseInContentBounds; - mouseInContentBounds = GetContentBounds(e.RowIndex).Contains(e.X, e.Y); - if (oldMouseInContentBounds != mouseInContentBounds) + bool oldMouseInContentBounds = s_mouseInContentBounds; + s_mouseInContentBounds = GetContentBounds(e.RowIndex).Contains(e.X, e.Y); + if (oldMouseInContentBounds != s_mouseInContentBounds) { if (DataGridView.ApplyVisualStylesToInnerCells || FlatStyle == FlatStyle.Flat || FlatStyle == FlatStyle.Popup) { @@ -603,12 +590,12 @@ protected override void OnMouseMove(DataGridViewCellMouseEventArgs e) Control.MouseButtons == MouseButtons.Left) { if ((ButtonState & ButtonState.Pushed) == 0 && - mouseInContentBounds && + s_mouseInContentBounds && DataGridView.CellMouseDownInContentBounds) { UpdateButtonState(ButtonState | ButtonState.Pushed, e.RowIndex); } - else if ((ButtonState & ButtonState.Pushed) != 0 && !mouseInContentBounds) + else if ((ButtonState & ButtonState.Pushed) != 0 && !s_mouseInContentBounds) { UpdateButtonState(ButtonState & ~ButtonState.Pushed, e.RowIndex); } @@ -631,21 +618,23 @@ protected override void OnMouseUp(DataGridViewCellMouseEventArgs e) } } - protected override void Paint(Graphics graphics, + protected override void Paint( + Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, - object value, - object formattedValue, - string errorText, + object? value, + object? formattedValue, + string? errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { ArgumentNullException.ThrowIfNull(cellStyle); - PaintPrivate(graphics, + PaintPrivate( + graphics, clipBounds, cellBounds, rowIndex, @@ -655,9 +644,9 @@ protected override void Paint(Graphics graphics, cellStyle, advancedBorderStyle, paintParts, - false /*computeContentBounds*/, - false /*computeErrorIconBounds*/, - true /*paint*/); + computeContentBounds: false, + computeErrorIconBounds: false, + paint: true); } // PaintPrivate is used in three places that need to duplicate the paint code: @@ -668,13 +657,14 @@ protected override void Paint(Graphics graphics, // if computeContentBounds is true then PaintPrivate returns the contentBounds // else if computeErrorIconBounds is true then PaintPrivate returns the errorIconBounds // else it returns Rectangle.Empty; - private Rectangle PaintPrivate(Graphics g, + private Rectangle PaintPrivate( + Graphics g, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, - object formattedValue, - string errorText, + object? formattedValue, + string? errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts, @@ -690,12 +680,12 @@ private Rectangle PaintPrivate(Graphics g, Debug.Assert(!computeErrorIconBounds || !paint || !computeContentBounds); Debug.Assert(cellStyle is not null); - Point ptCurrentCell = DataGridView.CurrentCellAddress; + Point ptCurrentCell = DataGridView!.CurrentCellAddress; bool cellSelected = (elementState & DataGridViewElementStates.Selected) != 0; bool cellCurrent = (ptCurrentCell.X == ColumnIndex && ptCurrentCell.Y == rowIndex); Rectangle resultBounds; - string formattedString = formattedValue as string; + string? formattedString = formattedValue as string; Color backBrushColor = PaintSelectionBackground(paintParts) && cellSelected ? cellStyle.SelectionBackColor @@ -758,7 +748,7 @@ private Rectangle PaintPrivate(Graphics g, pbState = PushButtonState.Pressed; } else if (DataGridView.MouseEnteredCellAddress.Y == rowIndex && - DataGridView.MouseEnteredCellAddress.X == ColumnIndex && mouseInContentBounds) + DataGridView.MouseEnteredCellAddress.X == ColumnIndex && s_mouseInContentBounds) { pbState = PushButtonState.Hot; } @@ -814,7 +804,7 @@ private Rectangle PaintPrivate(Graphics g, hdc.FillRectangle(valBounds, hbrush); } else if (DataGridView.MouseEnteredCellAddress.Y == rowIndex && - DataGridView.MouseEnteredCellAddress.X == ColumnIndex && mouseInContentBounds) + DataGridView.MouseEnteredCellAddress.X == ColumnIndex && s_mouseInContentBounds) { using DeviceContextHdcScope hdc = new(g); using PInvoke.CreateBrushScope hbrush = new(SystemColors.ControlDark); @@ -852,7 +842,7 @@ private Rectangle PaintPrivate(Graphics g, } else if (DataGridView.MouseEnteredCellAddress.Y == rowIndex && DataGridView.MouseEnteredCellAddress.X == ColumnIndex && - mouseInContentBounds) + s_mouseInContentBounds) { // paint over ButtonBaseAdapter.ColorData colors = ButtonBaseAdapter.PaintPopupRender( @@ -1039,17 +1029,15 @@ private Rectangle PaintPrivate(Graphics g, return resultBounds; } - public override string ToString() - { - return $"DataGridViewButtonCell {{ ColumnIndex={ColumnIndex}, RowIndex={RowIndex} }}"; - } + public override string ToString() => + $"DataGridViewButtonCell {{ ColumnIndex={ColumnIndex}, RowIndex={RowIndex} }}"; private void UpdateButtonState(ButtonState newButtonState, int rowIndex) { if (ButtonState != newButtonState) { ButtonState = newButtonState; - DataGridView.InvalidateCell(ColumnIndex, rowIndex); + DataGridView!.InvalidateCell(ColumnIndex, rowIndex); } } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonColumn.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonColumn.cs index bc05c54b44e..187eac98251 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonColumn.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonColumn.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCell.DataGridViewCellAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCell.DataGridViewCellAccessibleObject.cs index 9d578c515b0..10977b3de4d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCell.DataGridViewCellAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCell.DataGridViewCellAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCell.cs index 8231653f71e..15c0ad2fca7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCell.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -697,7 +696,7 @@ private protected Rectangle StdBorderWidths { if (DataGridView is not null) { - DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new(), dgvabsEffective; dgvabsEffective = AdjustCellBorderStyle( DataGridView.AdvancedCellBorderStyle, dataGridViewAdvancedBorderStylePlaceholder, @@ -1472,10 +1471,8 @@ protected virtual object GetClipboardContent(int rowIndex, } // Header Cell classes override this implementation - this implementation is only for inner cells - if (rowIndex < 0 || rowIndex >= DataGridView.Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, DataGridView.Rows.Count); // Assuming (like in other places in this class) that the formatted value is independent of the style colors. DataGridViewCellStyle dataGridViewCellStyle = GetInheritedStyle(null, rowIndex, false); @@ -1502,7 +1499,7 @@ protected virtual object GetClipboardContent(int rowIndex, sb.Append(""); if (formattedValue is not null) { - using var sw = new StringWriter(sb, CultureInfo.CurrentCulture); + using StringWriter sw = new(sb, CultureInfo.CurrentCulture); FormatPlainTextAsHtml(formattedValue.ToString(), sw); } else @@ -1539,7 +1536,7 @@ protected virtual object GetClipboardContent(int rowIndex, { bool escapeApplied = false; int insertionPoint = sb.Length; - using var sw = new StringWriter(sb, CultureInfo.CurrentCulture); + using StringWriter sw = new(sb, CultureInfo.CurrentCulture); FormatPlainText(formattedValue.ToString(), csv, sw, ref escapeApplied); if (escapeApplied) { @@ -1571,12 +1568,13 @@ protected virtual object GetClipboardContent(int rowIndex, } } - internal object GetClipboardContentInternal(int rowIndex, - bool firstCell, - bool lastCell, - bool inFirstRow, - bool inLastRow, - string format) + internal object GetClipboardContentInternal( + int rowIndex, + bool firstCell, + bool lastCell, + bool inFirstRow, + bool inLastRow, + string format) { return GetClipboardContent(rowIndex, firstCell, lastCell, inFirstRow, inLastRow, format); } @@ -1870,10 +1868,8 @@ public virtual ContextMenuStrip GetInheritedContextMenuStrip(int rowIndex) { if (DataGridView is not null) { - if (rowIndex < 0 || rowIndex >= DataGridView.Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, DataGridView.Rows.Count); if (ColumnIndex < 0) { @@ -1942,10 +1938,8 @@ public virtual DataGridViewElementStates GetInheritedState(int rowIndex) } // Header Cell classes override this implementation - this implementation is only for inner cells - if (rowIndex < 0 || rowIndex >= DataGridView.Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, DataGridView.Rows.Count); Debug.Assert(OwningColumn is not null); Debug.Assert(OwningRow is not null); @@ -2024,10 +2018,8 @@ public virtual DataGridViewCellStyle GetInheritedStyle(DataGridViewCellStyle inh throw new InvalidOperationException(SR.DataGridView_CellNeedsDataGridViewForInheritedStyle); } - if (rowIndex < 0 || rowIndex >= DataGridView.Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, DataGridView.Rows.Count); if (ColumnIndex < 0) { @@ -2564,10 +2556,8 @@ protected virtual object GetValue(int rowIndex) DataGridView dataGridView = DataGridView; if (dataGridView is not null) { - if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, DataGridView.Rows.Count); if (ColumnIndex < 0) { @@ -3966,7 +3956,7 @@ public virtual Rectangle PositionEditingPanel(Rectangle cellBounds, throw new InvalidOperationException(); } - DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new(), dgvabsEffective; dgvabsEffective = AdjustCellBorderStyle(DataGridView.AdvancedCellBorderStyle, dataGridViewAdvancedBorderStylePlaceholder, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellBorderStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellBorderStyle.cs index 6b502bab1d0..b84f9b6ee54 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellBorderStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellBorderStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellCancelEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellCancelEventArgs.cs index 033d94166be..38daec46814 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellCancelEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellCancelEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; @@ -15,15 +14,8 @@ internal DataGridViewCellCancelEventArgs(DataGridViewCell dataGridViewCell) public DataGridViewCellCancelEventArgs(int columnIndex, int rowIndex) { - if (columnIndex < -1) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } - - if (rowIndex < -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(columnIndex, -1); + ArgumentOutOfRangeException.ThrowIfLessThan(rowIndex, -1); ColumnIndex = columnIndex; RowIndex = rowIndex; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellCollection.cs index 39b72192cdc..b143bd9fc2a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellContextMenuStripNeededEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellContextMenuStripNeededEventArgs.cs index 91c0b8e26a6..3eaea645a12 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellContextMenuStripNeededEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellContextMenuStripNeededEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellConverter.cs index 6fb8fdd3150..4a95d794266 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellErrorTextNeededEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellErrorTextNeededEventArgs.cs index 7b3842e03ad..4f9d342fb5f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellErrorTextNeededEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellErrorTextNeededEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellEventArgs.cs index 08af1dbad3e..7d073b3c862 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -13,15 +12,8 @@ internal DataGridViewCellEventArgs(DataGridViewCell dataGridViewCell) public DataGridViewCellEventArgs(int columnIndex, int rowIndex) { - if (columnIndex < -1) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } - - if (rowIndex < -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(columnIndex, -1); + ArgumentOutOfRangeException.ThrowIfLessThan(rowIndex, -1); ColumnIndex = columnIndex; RowIndex = rowIndex; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellFormattingEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellFormattingEventArgs.cs index 38197bf5da5..80072f363cb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellFormattingEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellFormattingEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -14,15 +13,8 @@ public DataGridViewCellFormattingEventArgs( DataGridViewCellStyle? cellStyle) : base(value, desiredType) { - if (columnIndex < -1) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } - - if (rowIndex < -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(columnIndex, -1); + ArgumentOutOfRangeException.ThrowIfLessThan(rowIndex, -1); ColumnIndex = columnIndex; RowIndex = rowIndex; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellLinkedList.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellLinkedList.cs index e04d3d6a39c..034f740fca7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellLinkedList.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellLinkedList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellLinkedListElement.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellLinkedListElement.cs index 48c79dd6e5e..5db6e8a3ebd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellLinkedListElement.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellLinkedListElement.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellLinkedListEnumerator.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellLinkedListEnumerator.cs index ba70c69d9ea..bc12862ff49 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellLinkedListEnumerator.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellLinkedListEnumerator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellMouseEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellMouseEventArgs.cs index 9d4a5f0e583..707ec46c275 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellMouseEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellMouseEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -14,16 +13,8 @@ public DataGridViewCellMouseEventArgs( MouseEventArgs? e) : base(e?.Button ?? MouseButtons.None, e?.Clicks ?? 0, localX, localY, e?.Delta ?? 0) { - if (columnIndex < -1) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } - - if (rowIndex < -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } - + ArgumentOutOfRangeException.ThrowIfLessThan(columnIndex, -1); + ArgumentOutOfRangeException.ThrowIfLessThan(rowIndex, -1); ArgumentNullException.ThrowIfNull(e); ColumnIndex = columnIndex; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellPaintingEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellPaintingEventArgs.cs index c5556001cde..8f5c8fbc61e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellPaintingEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellPaintingEventArgs.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.Drawing; @@ -13,19 +10,20 @@ public class DataGridViewCellPaintingEventArgs : HandledEventArgs { private readonly DataGridView _dataGridView; - public DataGridViewCellPaintingEventArgs(DataGridView dataGridView, - Graphics graphics, - Rectangle clipBounds, - Rectangle cellBounds, - int rowIndex, - int columnIndex, - DataGridViewElementStates cellState, - object value, - object formattedValue, - string errorText, - DataGridViewCellStyle cellStyle, - DataGridViewAdvancedBorderStyle advancedBorderStyle, - DataGridViewPaintParts paintParts) + public DataGridViewCellPaintingEventArgs( + DataGridView dataGridView, + Graphics graphics, + Rectangle clipBounds, + Rectangle cellBounds, + int rowIndex, + int columnIndex, + DataGridViewElementStates cellState, + object? value, + object? formattedValue, + string? errorText, + DataGridViewCellStyle cellStyle, + DataGridViewAdvancedBorderStyle? advancedBorderStyle, + DataGridViewPaintParts paintParts) { if ((paintParts & ~DataGridViewPaintParts.All) != 0) { @@ -53,9 +51,9 @@ internal DataGridViewCellPaintingEventArgs(DataGridView dataGridView) _dataGridView = dataGridView; } - public Graphics Graphics { get; private set; } + public Graphics? Graphics { get; private set; } - public DataGridViewAdvancedBorderStyle AdvancedBorderStyle { get; private set; } + public DataGridViewAdvancedBorderStyle? AdvancedBorderStyle { get; private set; } public Rectangle CellBounds { get; private set; } @@ -67,13 +65,13 @@ internal DataGridViewCellPaintingEventArgs(DataGridView dataGridView) public DataGridViewElementStates State { get; private set; } - public object Value { get; private set; } + public object? Value { get; private set; } - public object FormattedValue { get; private set; } + public object? FormattedValue { get; private set; } - public string ErrorText { get; private set; } + public string? ErrorText { get; private set; } - public DataGridViewCellStyle CellStyle { get; private set; } + public DataGridViewCellStyle? CellStyle { get; private set; } public DataGridViewPaintParts PaintParts { get; private set; } @@ -89,17 +87,20 @@ public void Paint(Rectangle clipBounds, DataGridViewPaintParts paintParts) throw new InvalidOperationException(SR.DataGridViewElementPaintingEventArgs_ColumnIndexOutOfRange); } - _dataGridView.GetCellInternal(ColumnIndex, RowIndex).PaintInternal(Graphics, - clipBounds, - CellBounds, - RowIndex, - State, - Value, - FormattedValue, - ErrorText, - CellStyle, - AdvancedBorderStyle, - paintParts); + _dataGridView + .GetCellInternal(ColumnIndex, RowIndex) + .PaintInternal( + Graphics, + clipBounds, + CellBounds, + RowIndex, + State, + Value, + FormattedValue, + ErrorText, + CellStyle, + AdvancedBorderStyle, + paintParts); } public void PaintBackground(Rectangle clipBounds, bool cellsPaintSelectionBackground) @@ -120,17 +121,20 @@ public void PaintBackground(Rectangle clipBounds, bool cellsPaintSelectionBackgr paintParts |= DataGridViewPaintParts.SelectionBackground; } - _dataGridView.GetCellInternal(ColumnIndex, RowIndex).PaintInternal(Graphics, - clipBounds, - CellBounds, - RowIndex, - State, - Value, - FormattedValue, - ErrorText, - CellStyle, - AdvancedBorderStyle, - paintParts); + _dataGridView + .GetCellInternal(ColumnIndex, RowIndex) + .PaintInternal( + Graphics, + clipBounds, + CellBounds, + RowIndex, + State, + Value, + FormattedValue, + ErrorText, + CellStyle, + AdvancedBorderStyle, + paintParts); } public void PaintContent(Rectangle clipBounds) @@ -145,31 +149,35 @@ public void PaintContent(Rectangle clipBounds) throw new InvalidOperationException(SR.DataGridViewElementPaintingEventArgs_ColumnIndexOutOfRange); } - _dataGridView.GetCellInternal(ColumnIndex, RowIndex).PaintInternal(Graphics, - clipBounds, - CellBounds, - RowIndex, - State, - Value, - FormattedValue, - ErrorText, - CellStyle, - AdvancedBorderStyle, - DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.ContentForeground | DataGridViewPaintParts.ErrorIcon); + _dataGridView + .GetCellInternal(ColumnIndex, RowIndex) + .PaintInternal( + Graphics, + clipBounds, + CellBounds, + RowIndex, + State, + Value, + FormattedValue, + ErrorText, + CellStyle, + AdvancedBorderStyle, + DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.ContentForeground | DataGridViewPaintParts.ErrorIcon); } - internal void SetProperties(Graphics graphics, - Rectangle clipBounds, - Rectangle cellBounds, - int rowIndex, - int columnIndex, - DataGridViewElementStates cellState, - object value, - object formattedValue, - string errorText, - DataGridViewCellStyle cellStyle, - DataGridViewAdvancedBorderStyle advancedBorderStyle, - DataGridViewPaintParts paintParts) + internal void SetProperties( + Graphics graphics, + Rectangle clipBounds, + Rectangle cellBounds, + int rowIndex, + int columnIndex, + DataGridViewElementStates cellState, + object? value, + object? formattedValue, + string? errorText, + DataGridViewCellStyle cellStyle, + DataGridViewAdvancedBorderStyle advancedBorderStyle, + DataGridViewPaintParts paintParts) { Debug.Assert(graphics is not null); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellParsingEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellParsingEventArgs.cs index affbf5da7e9..dfbd4be09b8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellParsingEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellParsingEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStateChangedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStateChangedEventArgs.cs index c25094a9969..d526b77ca89 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStateChangedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStateChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyle.cs index 8b3af67a577..9c6424b8af9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -642,7 +641,7 @@ internal DataGridViewCellStyleDifferences GetDifferencesFrom(DataGridViewCellSty public override int GetHashCode() { - var hash = default(HashCode); + HashCode hash = default; hash.Add(Alignment); hash.Add(WrapMode); hash.Add(Padding); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleChangedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleChangedEventArgs.cs index 6b873028107..a9f22d40597 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleChangedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleContentChangedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleContentChangedEventArgs.cs index 6f43e560a29..aa554c59f07 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleContentChangedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleContentChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleConverter.cs index ae76f3dd264..3009d5e4d9e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleDifferences.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleDifferences.cs index a6da2cdb9fe..526730f4965 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleDifferences.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleDifferences.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleScopes.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleScopes.cs index 1ab001619eb..44110262eed 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleScopes.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyleScopes.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellToolTipTextNeededEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellToolTipTextNeededEventArgs.cs index 4a21c9d392b..ec46381e667 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellToolTipTextNeededEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellToolTipTextNeededEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellValidatingEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellValidatingEventArgs.cs index 3b893005c24..86e0ca0940d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellValidatingEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellValidatingEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellValueEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellValueEventArgs.cs index d66d850f13a..7f99ef25bb8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellValueEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellValueEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -14,15 +13,8 @@ internal DataGridViewCellValueEventArgs() public DataGridViewCellValueEventArgs(int columnIndex, int rowIndex) { - if (columnIndex < 0) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } - - if (rowIndex < 0) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(columnIndex); + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); ColumnIndex = columnIndex; RowIndex = rowIndex; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.DataGridViewCheckBoxCellAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.DataGridViewCheckBoxCellAccessibleObject.cs index 0d7ecf5741a..c4430e786d4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.DataGridViewCheckBoxCellAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.DataGridViewCheckBoxCellAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.DataGridViewCheckBoxCellRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.DataGridViewCheckBoxCellRenderer.cs index 2b67f4c4762..4d1f3075b71 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.DataGridViewCheckBoxCellRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.DataGridViewCheckBoxCellRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.cs index 7bf243b9430..40959ac1036 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -1443,7 +1442,7 @@ private Rectangle PaintPrivate(Graphics g, using (Graphics offscreen = Graphics.FromImage(bitmap)) { offscreen.Clear(Color.Transparent); - using var hdc = new DeviceContextHdcScope(offscreen); + using DeviceContextHdcScope hdc = new(offscreen); PInvoke.DrawFrameControl( hdc, ref rcCheck, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxColumn.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxColumn.cs index 85b048afa54..06c0dd46b80 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxColumn.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxColumn.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewClipboardCopyMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewClipboardCopyMode.cs index b49fb9d9930..a7b29e570b8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewClipboardCopyMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewClipboardCopyMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumn.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumn.cs index 0274fb68af0..6dbaaa532d8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumn.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumn.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnCollection.ColumnOrderComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnCollection.ColumnOrderComparer.cs index c17836e8b3d..791acfb89c0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnCollection.ColumnOrderComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnCollection.ColumnOrderComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnCollection.cs index 2be2f5bae0a..f66936ad4db 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -24,7 +23,7 @@ public partial class DataGridViewColumnCollection : BaseCollection, IList private int _lastAccessedSortedIndex = -1; private int _columnCountsVisible, _columnCountsVisibleSelected; private int _columnsWidthVisible, _columnsWidthVisibleFrozen; - private static readonly ColumnOrderComparer s_columnOrderComparer = new ColumnOrderComparer(); + private static readonly ColumnOrderComparer s_columnOrderComparer = new(); /* IList interface implementation */ diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnConverter.cs index c55fac3ac2d..45bf538f25d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnDesignTimeVisibleAttribute.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnDesignTimeVisibleAttribute.cs index 66a130787f0..5039ce95730 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnDesignTimeVisibleAttribute.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnDesignTimeVisibleAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnDividerDoubleClickEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnDividerDoubleClickEventArgs.cs index 6a7bbd243bf..2aef74b90de 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnDividerDoubleClickEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnDividerDoubleClickEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -9,11 +8,7 @@ public class DataGridViewColumnDividerDoubleClickEventArgs : HandledMouseEventAr public DataGridViewColumnDividerDoubleClickEventArgs(int columnIndex, HandledMouseEventArgs? e) : base(e?.Button ?? MouseButtons.None, e?.Clicks ?? 0, e?.X ?? 0, e?.Y ?? 0, e?.Delta ?? 0, e?.Handled ?? false) { - if (columnIndex < -1) - { - throw new ArgumentOutOfRangeException(nameof(columnIndex)); - } - + ArgumentOutOfRangeException.ThrowIfLessThan(columnIndex, -1); ArgumentNullException.ThrowIfNull(e); ColumnIndex = columnIndex; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnEventArgs.cs index da79aa65c2b..66a34a7d688 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.DataGridViewColumnHeaderCellAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.DataGridViewColumnHeaderCellAccessibleObject.cs index 7bc761e887d..96cfc729f6a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.DataGridViewColumnHeaderCellAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.DataGridViewColumnHeaderCellAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.DataGridViewColumnHeaderCellRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.DataGridViewColumnHeaderCellRenderer.cs index 01de55f3272..4522ce3abf6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.DataGridViewColumnHeaderCellRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.DataGridViewColumnHeaderCellRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.cs index 7e652fde363..48c5bd80176 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -137,10 +136,7 @@ protected override object GetClipboardContent(int rowIndex, bool inLastRow, string format) { - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); if (DataGridView is null) { @@ -164,7 +160,7 @@ protected override object GetClipboardContent(int rowIndex, sb.Append(""); if (val is not null) { - using var sw = new StringWriter(sb, CultureInfo.CurrentCulture); + using StringWriter sw = new(sb, CultureInfo.CurrentCulture); FormatPlainTextAsHtml(val.ToString(), sw); } else @@ -195,7 +191,7 @@ protected override object GetClipboardContent(int rowIndex, { bool escapeApplied = false; int insertionPoint = sb.Length; - using var sw = new StringWriter(sb, CultureInfo.CurrentCulture); + using StringWriter sw = new(sb, CultureInfo.CurrentCulture); FormatPlainText(val.ToString(), csv, sw, ref escapeApplied); if (escapeApplied) { @@ -230,10 +226,7 @@ protected override Rectangle GetContentBounds(Graphics graphics, DataGridViewCel { ArgumentNullException.ThrowIfNull(cellStyle); - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); if (DataGridView is null || OwningColumn is null) { @@ -280,10 +273,7 @@ protected override Rectangle GetContentBounds(Graphics graphics, DataGridViewCel public override ContextMenuStrip GetInheritedContextMenuStrip(int rowIndex) { - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); ContextMenuStrip contextMenuStrip = GetContextMenuStrip(-1); if (contextMenuStrip is not null) @@ -308,10 +298,7 @@ public override DataGridViewCellStyle GetInheritedStyle(DataGridViewCellStyle in throw new InvalidOperationException(SR.DataGridView_CellNeedsDataGridViewForInheritedStyle); } - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); DataGridViewCellStyle inheritedCellStyleTmp = inheritedCellStyle ?? new DataGridViewCellStyle(); @@ -507,10 +494,7 @@ public override DataGridViewCellStyle GetInheritedStyle(DataGridViewCellStyle in protected override Size GetPreferredSize(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) { - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); if (DataGridView is null) { @@ -520,7 +504,7 @@ protected override Size GetPreferredSize(Graphics graphics, DataGridViewCellStyl ArgumentNullException.ThrowIfNull(cellStyle); DataGridViewFreeDimension freeDimension = DataGridViewCell.GetFreeDimensionFromConstraint(constraintSize); - DataGridViewAdvancedBorderStyle dgvabsPlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dgvabsPlaceholder = new(), dgvabsEffective; dgvabsEffective = DataGridView.AdjustColumnHeaderBorderStyle(DataGridView.AdvancedColumnHeadersBorderStyle, dgvabsPlaceholder, false /*isFirstDisplayedColumn*/, @@ -716,10 +700,7 @@ OwningColumn is not null && protected override object GetValue(int rowIndex) { - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); if (ContainsLocalValue) { @@ -1206,10 +1187,7 @@ DataGridView.CurrentCell is not null && DataGridView.CurrentCell.Selected && protected override bool SetValue(int rowIndex, object value) { - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); object originalValue = GetValue(rowIndex); Properties.SetObject(s_propCellValue, value); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeadersHeightSizeMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeadersHeightSizeMode.cs index 66c86f91db7..7c9fcc8234c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeadersHeightSizeMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeadersHeightSizeMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnSortMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnSortMode.cs index 24e75e88d94..98c88fb159e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnSortMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnSortMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnStateChangedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnStateChangedEventArgs.cs index 463c5e92e99..0dcac19ba04 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnStateChangedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnStateChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.DataGridViewComboBoxCellAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.DataGridViewComboBoxCellAccessibleObject.cs index 4b6af182460..13b9ac4b88c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.DataGridViewComboBoxCellAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.DataGridViewComboBoxCellAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.DataGridViewComboBoxCellRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.DataGridViewComboBoxCellRenderer.cs index 174380605a5..7c5cf83af53 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.DataGridViewComboBoxCellRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.DataGridViewComboBoxCellRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.ItemComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.ItemComparer.cs index c879baf9a2b..e0b14ed7322 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.ItemComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.ItemComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.ObjectCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.ObjectCollection.cs index 20d769a8509..1cad44a7016 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.ObjectCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.ObjectCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.cs index 9c2665814a1..95fad6f67b9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -488,13 +487,7 @@ internal FlatStyle FlatStyleInternal } } - public override Type FormattedValueType - { - get - { - return s_defaultFormattedValueType; - } - } + public override Type FormattedValueType => s_defaultFormattedValueType; internal bool HasItems => Properties.ContainsObjectThatIsNotNull(s_propComboBoxCellItems); @@ -695,7 +688,7 @@ internal override void CacheEditingControl() private void CheckDropDownList(int x, int y, int rowIndex) { Debug.Assert(EditingComboBox is not null); - DataGridViewAdvancedBorderStyle dgvabsPlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dgvabsPlaceholder = new(), dgvabsEffective; dgvabsEffective = AdjustCellBorderStyle(DataGridView.AdvancedCellBorderStyle, dgvabsPlaceholder, false /*singleVerticalBorderAdded*/, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxColumn.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxColumn.cs index 63fbf071a9f..dd41dbc129d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxColumn.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxColumn.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxDisplayStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxDisplayStyle.cs index dbc5fe2e6b7..d520aec4434 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxDisplayStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxDisplayStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxEditingControl.DataGridViewComboBoxEditingControlAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxEditingControl.DataGridViewComboBoxEditingControlAccessibleObject.cs index b9beaade196..d32010121c4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxEditingControl.DataGridViewComboBoxEditingControlAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxEditingControl.DataGridViewComboBoxEditingControlAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxEditingControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxEditingControl.cs index 7612fe4ee40..24d409661d5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxEditingControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxEditingControl.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Drawing; using System.Globalization; @@ -11,7 +8,7 @@ namespace System.Windows.Forms; public partial class DataGridViewComboBoxEditingControl : ComboBox, IDataGridViewEditingControl { - private DataGridView _dataGridView; + private DataGridView? _dataGridView; private bool _valueChanged; private int _rowIndex; @@ -20,14 +17,12 @@ public DataGridViewComboBoxEditingControl() : base() TabStop = false; } - protected override AccessibleObject CreateAccessibilityInstance() - { - return new DataGridViewComboBoxEditingControlAccessibleObject(this); - } + protected override AccessibleObject CreateAccessibilityInstance() => + new DataGridViewComboBoxEditingControlAccessibleObject(this); // IDataGridViewEditingControl interface implementation - public virtual DataGridView EditingControlDataGridView + public virtual DataGridView? EditingControlDataGridView { get { @@ -41,10 +36,7 @@ public virtual DataGridView EditingControlDataGridView public virtual object EditingControlFormattedValue { - get - { - return GetEditingControlFormattedValue(DataGridViewDataErrorContexts.Formatting); - } + get => GetEditingControlFormattedValue(DataGridViewDataErrorContexts.Formatting); set { if (value is string valueStr) @@ -60,43 +52,19 @@ public virtual object EditingControlFormattedValue public virtual int EditingControlRowIndex { - get - { - return _rowIndex; - } - set - { - _rowIndex = value; - } + get => _rowIndex; + set => _rowIndex = value; } public virtual bool EditingControlValueChanged { - get - { - return _valueChanged; - } - set - { - _valueChanged = value; - } + get => _valueChanged; + set => _valueChanged = value; } - public virtual Cursor EditingPanelCursor - { - get - { - return Cursors.Default; - } - } + public virtual Cursor EditingPanelCursor => Cursors.Default; - public virtual bool RepositionEditingControlOnValueChange - { - get - { - return false; - } - } + public virtual bool RepositionEditingControlOnValueChange => false; public virtual void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle) { @@ -106,7 +74,7 @@ public virtual void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGri // Our ComboBox does not support transparent back colors Color opaqueBackColor = Color.FromArgb(255, dataGridViewCellStyle.BackColor); BackColor = opaqueBackColor; - _dataGridView.EditingPanel.BackColor = opaqueBackColor; + _dataGridView!.EditingPanel.BackColor = opaqueBackColor; } else { @@ -130,10 +98,7 @@ public virtual bool EditingControlWantsInputKey(Keys keyData, bool dataGridViewW return !dataGridViewWantsInputKey; } - public virtual object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context) - { - return Text; - } + public virtual object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context) => Text; public virtual void PrepareEditingControlForEdit(bool selectAll) { @@ -146,7 +111,7 @@ public virtual void PrepareEditingControlForEdit(bool selectAll) private void NotifyDataGridViewOfValueChange() { _valueChanged = true; - _dataGridView.NotifyCurrentCellDirty(true); + _dataGridView!.NotifyCurrentCellDirty(true); } protected override void OnSelectedIndexChanged(EventArgs e) @@ -171,7 +136,7 @@ protected override void OnHandleCreated(EventArgs e) internal override void ReleaseUiaProvider(HWND handle) { - if (TryGetAccessibilityObject(out AccessibleObject accessibleObject)) + if (TryGetAccessibilityObject(out AccessibleObject? accessibleObject)) { ((DataGridViewComboBoxEditingControlAccessibleObject)accessibleObject).ClearParent(); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewContentAlignment.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewContentAlignment.cs index c1594b3f24d..6094440cc07 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewContentAlignment.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewContentAlignment.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewDataErrorContexts.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewDataErrorContexts.cs index bf7215d8a8b..a6f726cb70b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewDataErrorContexts.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewDataErrorContexts.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewDataErrorEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewDataErrorEventArgs.cs index 51041500e01..7b7c01c02da 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewDataErrorEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewDataErrorEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditMode.cs index a68a762d934..e7c035c86d0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditingCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditingCell.cs index 7399aff026d..c263eee4f41 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditingCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditingCell.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditingControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditingControl.cs index ff419df1459..5d2e1d74054 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditingControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditingControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditingControlShowingEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditingControlShowingEventArgs.cs index 1003198de2f..01bb3dabef1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditingControlShowingEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEditingControlShowingEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewElement.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewElement.cs index 2bba3c435ae..c861f7ebfb7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewElement.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewElement.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewElementStates.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewElementStates.cs index 22f6887c87e..3d7962d602c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewElementStates.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewElementStates.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEventHandlers.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEventHandlers.cs index 60beceb01d7..b15a0fd0373 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEventHandlers.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewEventHandlers.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewFreeDimension.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewFreeDimension.cs index 3b779eccd41..1331cd4c326 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewFreeDimension.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewFreeDimension.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderBorderStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderBorderStyle.cs index fe15818d62e..3406a58bc1d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderBorderStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderBorderStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderCell.DataGridViewHeaderCellRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderCell.DataGridViewHeaderCellRenderer.cs index fa9342871a9..10f0b837aca 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderCell.DataGridViewHeaderCellRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderCell.DataGridViewHeaderCellRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderCell.cs index 34dc253041d..cd179cc290d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderCell.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -19,7 +18,7 @@ public partial class DataGridViewHeaderCell : DataGridViewCell private static readonly Type s_defaultFormattedValueType = typeof(string); private static readonly Type s_defaultValueType = typeof(object); private static readonly Type s_cellType = typeof(DataGridViewHeaderCell); - private static Rectangle s_rectThemeMargins = new Rectangle(-1, -1, 0, 0); + private static Rectangle s_rectThemeMargins = new(-1, -1, 0, 0); private static readonly int s_propValueType = PropertyStore.CreateKey(); private static readonly int s_propButtonState = PropertyStore.CreateKey(); private static readonly int s_propFlipXPThemesBitmap = PropertyStore.CreateKey(); @@ -112,13 +111,7 @@ internal Bitmap FlipXPThemesBitmap } } - public override Type FormattedValueType - { - get - { - return s_defaultFormattedValueType; - } - } + public override Type FormattedValueType => s_defaultFormattedValueType; [Browsable(false)] public override bool Frozen @@ -328,10 +321,7 @@ public override DataGridViewElementStates GetInheritedState(int rowIndex) else if (OwningColumn is not null) { // column header cell - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); state |= (OwningColumn.State & DataGridViewElementStates.Frozen); if (OwningColumn.Resizable == DataGridViewTriState.True || @@ -352,10 +342,7 @@ public override DataGridViewElementStates GetInheritedState(int rowIndex) else if (DataGridView is not null) { // top left header cell - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); state |= DataGridViewElementStates.Frozen; if (DataGridView.RowHeadersWidthSizeMode == DataGridViewRowHeadersWidthSizeMode.EnableResizing || DataGridView.ColumnHeadersHeightSizeMode == DataGridViewColumnHeadersHeightSizeMode.EnableResizing) @@ -419,10 +406,7 @@ protected override Size GetSize(int rowIndex) if (DataGridView is null) { // detached cell - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); return new Size(-1, -1); } @@ -430,20 +414,15 @@ protected override Size GetSize(int rowIndex) if (OwningColumn is not null) { // must be a column header cell - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); return new Size(OwningColumn.Thickness, DataGridView.ColumnHeadersHeight); } else if (OwningRow is not null) { // must be a row header cell - if (rowIndex < 0 || rowIndex >= DataGridView.Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, DataGridView.Rows.Count); if (DataGridView.Rows.SharedRow(rowIndex) != OwningRow) { @@ -455,10 +434,7 @@ protected override Size GetSize(int rowIndex) else { // must be the top left header cell - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); return new Size(DataGridView.RowHeadersWidth, DataGridView.ColumnHeadersHeight); } @@ -504,10 +480,7 @@ internal static Rectangle GetThemeMargins(Graphics g) protected override object GetValue(int rowIndex) { - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); return Properties.GetObject(s_propCellValue); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHitTestCloseEdge.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHitTestCloseEdge.cs index 55dbf755e7f..65dcd17c61e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHitTestCloseEdge.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHitTestCloseEdge.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHitTestType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHitTestType.cs index 41583645889..2e486ba8a4a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHitTestType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHitTestType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageCell.DataGridViewImageCellAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageCell.DataGridViewImageCellAccessibleObject.cs index 01e39c4ffd3..3ebd79bb7a3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageCell.DataGridViewImageCellAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageCell.DataGridViewImageCellAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageCell.cs index cfd3f9c8228..b7090f0036c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageCell.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageCellLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageCellLayout.cs index c80abc06799..e0eac7d6333 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageCellLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageCellLayout.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageColumn.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageColumn.cs index dbe083c8600..e1860c4fe85 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageColumn.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewImageColumn.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewIntLinkedList.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewIntLinkedList.cs index 6760bab297a..033ae5a5f11 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewIntLinkedList.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewIntLinkedList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewIntLinkedListElement.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewIntLinkedListElement.cs index 07d23d5eff2..fc7c6b5634b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewIntLinkedListElement.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewIntLinkedListElement.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewIntLinkedListEnumerator.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewIntLinkedListEnumerator.cs index 52ddf9495b5..ba3ca7f4fce 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewIntLinkedListEnumerator.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewIntLinkedListEnumerator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewLinkCell.DataGridViewLinkCellAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewLinkCell.DataGridViewLinkCellAccessibleObject.cs index 9c4220b7fc9..abe13d76c47 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewLinkCell.DataGridViewLinkCellAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewLinkCell.DataGridViewLinkCellAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewLinkCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewLinkCell.cs index 18ebcc3fb95..da2f26c5ad2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewLinkCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewLinkCell.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -112,13 +111,7 @@ public override Type EditType } } - public override Type FormattedValueType - { - get - { - return s_defaultFormattedValueType; - } - } + public override Type FormattedValueType => s_defaultFormattedValueType; [DefaultValue(LinkBehavior.SystemDefault)] public LinkBehavior LinkBehavior @@ -733,10 +726,9 @@ protected override object GetValue(int rowIndex) if (UseColumnTextForLinkValue && DataGridView is not null && DataGridView.NewRowIndex != rowIndex && - OwningColumn is not null && - OwningColumn is DataGridViewLinkColumn) + OwningColumn is DataGridViewLinkColumn dataGridViewLinkColumn) { - return ((DataGridViewLinkColumn)OwningColumn).Text; + return dataGridViewLinkColumn.Text; } return base.GetValue(rowIndex); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewLinkColumn.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewLinkColumn.cs index a275fff95bd..c28c40391e8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewLinkColumn.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewLinkColumn.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewPaintParts.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewPaintParts.cs index 5013c608173..c84f3437fd2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewPaintParts.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewPaintParts.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.DataGridViewRowAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.DataGridViewRowAccessibleObject.cs index 65684ef8181..e99742fb6a5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.DataGridViewRowAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.DataGridViewRowAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Globalization; @@ -243,10 +242,7 @@ public override string Value public override AccessibleObject? GetChild(int index) { - if (index < 0) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } + ArgumentOutOfRangeException.ThrowIfNegative(index); if (_owningDataGridViewRow is null) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.DataGridViewSelectedRowCellsAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.DataGridViewSelectedRowCellsAccessibleObject.cs index d9f61e46ebb..0106b2fa314 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.DataGridViewSelectedRowCellsAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.DataGridViewSelectedRowCellsAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.cs index a5657bbe117..3fc7a175de6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -246,7 +245,7 @@ public override DataGridViewCellStyle InheritedStyle throw new InvalidOperationException(string.Format(SR.DataGridView_InvalidPropertyGetOnSharedRow, nameof(InheritedStyle))); } - var inheritedRowStyle = new DataGridViewCellStyle(); + DataGridViewCellStyle inheritedRowStyle = new(); BuildInheritedRowStyle(Index, inheritedRowStyle); return inheritedRowStyle; } @@ -1218,10 +1217,8 @@ public ContextMenuStrip GetContextMenuStrip(int rowIndex) throw new InvalidOperationException(SR.DataGridView_InvalidOperationOnSharedRow); } - if (rowIndex < 0 || rowIndex >= DataGridView.Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, DataGridView.Rows.Count); if (DataGridView.VirtualMode || DataGridView.DataSource is not null) { @@ -1247,10 +1244,8 @@ public string GetErrorText(int rowIndex) throw new InvalidOperationException(SR.DataGridView_InvalidOperationOnSharedRow); } - if (rowIndex < 0 || rowIndex >= DataGridView.Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, DataGridView.Rows.Count); if (string.IsNullOrEmpty(errorText) && DataGridView.DataSource is not null && @@ -1293,16 +1288,14 @@ public virtual int GetPreferredHeight(int rowIndex, DataGridViewAutoSizeRowMode throw new InvalidEnumArgumentException(nameof(autoSizeRowMode), (int)autoSizeRowMode, typeof(DataGridViewAutoSizeRowMode)); } - if (!(DataGridView is null || (rowIndex >= 0 && rowIndex < DataGridView.Rows.Count))) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } - if (DataGridView is null) { return -1; } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, DataGridView.Rows.Count); + int preferredRowThickness = 0, preferredCellThickness; // take into account the preferred height of the header cell if displayed and cared about if (DataGridView.RowHeadersVisible && @@ -1379,9 +1372,10 @@ internal bool GetSelected(int rowIndex) [EditorBrowsable(EditorBrowsableState.Advanced)] public virtual DataGridViewElementStates GetState(int rowIndex) { - if (!(DataGridView is null || (rowIndex >= 0 && rowIndex < DataGridView.Rows.Count))) + if (DataGridView is not null) { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, DataGridView.Rows.Count); } if (DataGridView is null || DataGridView.Rows.SharedRow(rowIndex).Index != -1) @@ -1522,7 +1516,7 @@ protected internal virtual void PaintCells(Graphics graphics, DataGridViewCell cell; DataGridViewCellStyle inheritedCellStyle = new DataGridViewCellStyle(); DataGridViewColumn dataGridViewColumnNext = null; - DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new(), dgvabsEffective; // first paint the potential visible frozen cells DataGridViewColumn dataGridViewColumn = dataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible | DataGridViewElementStates.Frozen); @@ -1720,7 +1714,7 @@ protected internal virtual void PaintHeader(Graphics graphics, if (clipBounds.IntersectsWith(cellBounds)) { DataGridViewCellStyle inheritedCellStyle = new DataGridViewCellStyle(); - DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new(), dgvabsEffective; BuildInheritedRowHeaderCellStyle(inheritedCellStyle); dgvabsEffective = AdjustRowHeaderBorderStyle(dataGridView.AdvancedRowHeadersBorderStyle, dataGridViewAdvancedBorderStylePlaceholder, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCancelEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCancelEventArgs.cs index 1115c355ae9..0f3f704fb87 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCancelEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCancelEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowArrayList.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowArrayList.cs index 31d91715185..ae0db46a2d5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowArrayList.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowArrayList.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Collections; @@ -12,12 +9,12 @@ public partial class DataGridViewRowCollection { private class RowArrayList : ArrayList { - private readonly DataGridViewRowCollection owner; - private RowComparer rowComparer; + private readonly DataGridViewRowCollection _owner; + private RowComparer? _rowComparer; public RowArrayList(DataGridViewRowCollection owner) { - this.owner = owner; + _owner = owner; } public void CustomSort(RowComparer rowComparer) @@ -25,7 +22,7 @@ public void CustomSort(RowComparer rowComparer) Debug.Assert(rowComparer is not null); Debug.Assert(Count > 0); - this.rowComparer = rowComparer; + _rowComparer = rowComparer; CustomQuickSort(0, Count - 1); } @@ -40,9 +37,9 @@ private void CustomQuickSort(int left, int right) { if (right - left < 2) // sort subarray of two elements { - if (right - left > 0 && rowComparer.CompareObjects(rowComparer.GetComparedObject(left), rowComparer.GetComparedObject(right), left, right) > 0) + if (right - left > 0 && _rowComparer!.CompareObjects(_rowComparer.GetComparedObject(left), _rowComparer.GetComparedObject(right), left, right) > 0) { - owner.SwapSortedRows(left, right); + _owner.SwapSortedRows(left, right); } return; @@ -54,12 +51,12 @@ private void CustomQuickSort(int left, int right) int j = right - 1; do { - while (k != i && rowComparer.CompareObjects(rowComparer.GetComparedObject(i), x, i, k) < 0) + while (k != i && _rowComparer!.CompareObjects(_rowComparer.GetComparedObject(i), x, i, k) < 0) { i++; } - while (k != j && rowComparer.CompareObjects(x, rowComparer.GetComparedObject(j), k, j) < 0) + while (k != j && _rowComparer!.CompareObjects(x, _rowComparer.GetComparedObject(j), k, j) < 0) { j--; } @@ -72,7 +69,7 @@ private void CustomQuickSort(int left, int right) if (i < j) { - owner.SwapSortedRows(i, j); + _owner.SwapSortedRows(i, j); if (i == k) { k = j; @@ -113,22 +110,22 @@ private void CustomQuickSort(int left, int right) private object Pivot(int left, int center, int right) { // find median-of-3 (left, center and right) and sort these 3 elements - if (rowComparer.CompareObjects(rowComparer.GetComparedObject(left), rowComparer.GetComparedObject(center), left, center) > 0) + if (_rowComparer!.CompareObjects(_rowComparer.GetComparedObject(left), _rowComparer.GetComparedObject(center), left, center) > 0) { - owner.SwapSortedRows(left, center); + _owner.SwapSortedRows(left, center); } - if (rowComparer.CompareObjects(rowComparer.GetComparedObject(left), rowComparer.GetComparedObject(right), left, right) > 0) + if (_rowComparer.CompareObjects(_rowComparer.GetComparedObject(left), _rowComparer.GetComparedObject(right), left, right) > 0) { - owner.SwapSortedRows(left, right); + _owner.SwapSortedRows(left, right); } - if (rowComparer.CompareObjects(rowComparer.GetComparedObject(center), rowComparer.GetComparedObject(right), center, right) > 0) + if (_rowComparer.CompareObjects(_rowComparer.GetComparedObject(center), _rowComparer.GetComparedObject(right), center, right) > 0) { - owner.SwapSortedRows(center, right); + _owner.SwapSortedRows(center, right); } - return rowComparer.GetComparedObject(center); + return _rowComparer.GetComparedObject(center); } } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowComparer.ComparedObjectMax.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowComparer.ComparedObjectMax.cs index 36afbbbfbdd..2daafbe9cf5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowComparer.ComparedObjectMax.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowComparer.ComparedObjectMax.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowComparer.cs index 02a808a9162..60e3890e9e6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowComparer.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Collections; @@ -12,54 +9,54 @@ public partial class DataGridViewRowCollection { private partial class RowComparer { - private readonly DataGridView dataGridView; - private readonly DataGridViewRowCollection dataGridViewRows; - private readonly DataGridViewColumn dataGridViewSortedColumn; - private readonly int sortedColumnIndex; - private readonly IComparer customComparer; - private readonly bool ascending; - private static readonly ComparedObjectMax max = new ComparedObjectMax(); + private readonly DataGridView _dataGridView; + private readonly DataGridViewRowCollection _dataGridViewRows; + private readonly DataGridViewColumn? _dataGridViewSortedColumn; + private readonly int _sortedColumnIndex; + private readonly IComparer _customComparer; + private readonly bool _ascending; + private static readonly ComparedObjectMax s_max = new(); public RowComparer(DataGridViewRowCollection dataGridViewRows, IComparer customComparer, bool ascending) { - dataGridView = dataGridViewRows.DataGridView; - this.dataGridViewRows = dataGridViewRows; - dataGridViewSortedColumn = dataGridView.SortedColumn; - if (dataGridViewSortedColumn is null) + _dataGridView = dataGridViewRows.DataGridView; + _dataGridViewRows = dataGridViewRows; + _dataGridViewSortedColumn = _dataGridView.SortedColumn; + if (_dataGridViewSortedColumn is null) { Debug.Assert(customComparer is not null); - sortedColumnIndex = -1; + _sortedColumnIndex = -1; } else { - sortedColumnIndex = dataGridViewSortedColumn.Index; + _sortedColumnIndex = _dataGridViewSortedColumn.Index; } - this.customComparer = customComparer; - this.ascending = ascending; + _customComparer = customComparer; + _ascending = ascending; } internal object GetComparedObject(int rowIndex) { - if (dataGridView.NewRowIndex != -1) + if (_dataGridView.NewRowIndex != -1) { - Debug.Assert(dataGridView.AllowUserToAddRowsInternal); - if (rowIndex == dataGridView.NewRowIndex) + Debug.Assert(_dataGridView.AllowUserToAddRowsInternal); + if (rowIndex == _dataGridView.NewRowIndex) { - return max; + return s_max; } } - if (customComparer is null) + if (_customComparer is null) { - DataGridViewRow dataGridViewRow = dataGridViewRows.SharedRow(rowIndex); + DataGridViewRow dataGridViewRow = _dataGridViewRows.SharedRow(rowIndex); Debug.Assert(dataGridViewRow is not null); - Debug.Assert(sortedColumnIndex >= 0); - return dataGridViewRow.Cells[sortedColumnIndex].GetValueInternal(rowIndex); + Debug.Assert(_sortedColumnIndex >= 0); + return dataGridViewRow.Cells[_sortedColumnIndex].GetValueInternal(rowIndex); } else { - return dataGridViewRows[rowIndex]; // Unsharing compared rows! + return _dataGridViewRows[rowIndex]; // Unsharing compared rows! } } @@ -75,9 +72,9 @@ internal int CompareObjects(object value1, object value2, int rowIndex1, int row } int result = 0; - if (customComparer is null) + if (_customComparer is null) { - if (!dataGridView.OnSortCompare(dataGridViewSortedColumn, value1, value2, rowIndex1, rowIndex2, out result)) + if (!_dataGridView.OnSortCompare(_dataGridViewSortedColumn, value1, value2, rowIndex1, rowIndex2, out result)) { if (!(value1 is IComparable) && !(value2 is IComparable)) { @@ -108,7 +105,7 @@ internal int CompareObjects(object value1, object value2, int rowIndex1, int row if (result == 0) { - if (ascending) + if (_ascending) { result = rowIndex1 - rowIndex2; } @@ -125,12 +122,11 @@ internal int CompareObjects(object value1, object value2, int rowIndex1, int row Debug.Assert(value2 is DataGridViewRow); Debug.Assert(value1 is not null); Debug.Assert(value2 is not null); - // - result = customComparer.Compare(value1, value2); + result = _customComparer.Compare(value1, value2); } - if (ascending) + if (_ascending) { return result; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.UnsharingRowEnumerator.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.UnsharingRowEnumerator.cs index 78eafaf01ae..d2bc39cbddd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.UnsharingRowEnumerator.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.UnsharingRowEnumerator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.cs index 34b82209ecc..f4a9a8afd37 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowContextMenuStripNeededEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowContextMenuStripNeededEventArgs.cs index abad0d7b8b9..acd47c18e65 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowContextMenuStripNeededEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowContextMenuStripNeededEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -8,10 +7,7 @@ public class DataGridViewRowContextMenuStripNeededEventArgs : EventArgs { public DataGridViewRowContextMenuStripNeededEventArgs(int rowIndex) { - if (rowIndex < -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(rowIndex, -1); RowIndex = rowIndex; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowConverter.cs index 8afcea4c655..af860d4c3b9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowDividerDoubleClickEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowDividerDoubleClickEventArgs.cs index 1a274576169..42776905256 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowDividerDoubleClickEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowDividerDoubleClickEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -9,10 +8,7 @@ public class DataGridViewRowDividerDoubleClickEventArgs : HandledMouseEventArgs public DataGridViewRowDividerDoubleClickEventArgs(int rowIndex, HandledMouseEventArgs e) : base((e.OrThrowIfNull()).Button, e.Clicks, e.X, e.Y, e.Delta, e.Handled) { - if (rowIndex < -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(rowIndex, -1); RowIndex = rowIndex; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowErrorTextNeededEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowErrorTextNeededEventArgs.cs index 7b78502fd49..76fd05d8503 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowErrorTextNeededEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowErrorTextNeededEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowEventArgs.cs index 3f2ced6ab0b..59bd6618912 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.DataGridViewRowHeaderCellAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.DataGridViewRowHeaderCellAccessibleObject.cs index e56cb616983..446afd5378e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.DataGridViewRowHeaderCellAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.DataGridViewRowHeaderCellAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.DataGridViewRowHeaderCellRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.DataGridViewRowHeaderCellRenderer.cs index e0a80424c81..d193ca1de4f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.DataGridViewRowHeaderCellRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.DataGridViewRowHeaderCellRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.cs index 30b1e7d5bfa..11865e2fce4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -179,10 +178,8 @@ protected override object GetClipboardContent(int rowIndex, return null; } - if (rowIndex < 0 || rowIndex >= DataGridView.Rows.Count) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, DataGridView.Rows.Count); // Not using formatted values for header cells. object val = GetValue(rowIndex); @@ -202,7 +199,7 @@ protected override object GetClipboardContent(int rowIndex, if (val is not null) { sb.Append(""); - using var sw = new StringWriter(sb, CultureInfo.CurrentCulture); + using StringWriter sw = new(sb, CultureInfo.CurrentCulture); FormatPlainTextAsHtml(val.ToString(), sw); sb.Append(""); } @@ -234,7 +231,7 @@ protected override object GetClipboardContent(int rowIndex, { bool escapeApplied = false; int insertionPoint = sb.Length; - using var sw = new StringWriter(sb, CultureInfo.CurrentCulture); + using StringWriter sw = new(sb, CultureInfo.CurrentCulture); FormatPlainText(val.ToString(), csv, sw, ref escapeApplied); if (escapeApplied) { @@ -366,9 +363,10 @@ protected internal override string GetErrorText(int rowIndex) public override ContextMenuStrip GetInheritedContextMenuStrip(int rowIndex) { - if (DataGridView is not null && (rowIndex < 0 || rowIndex >= DataGridView.Rows.Count)) + if (DataGridView is not null) { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); + ArgumentOutOfRangeException.ThrowIfNegative(rowIndex); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, DataGridView.Rows.Count); } ContextMenuStrip contextMenuStrip = GetContextMenuStrip(rowIndex); @@ -597,7 +595,7 @@ protected override Size GetPreferredSize(Graphics graphics, DataGridViewCellStyl ArgumentNullException.ThrowIfNull(cellStyle); - DataGridViewAdvancedBorderStyle dgvabsPlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dgvabsPlaceholder = new(), dgvabsEffective; dgvabsEffective = OwningRow.AdjustRowHeaderBorderStyle(DataGridView.AdvancedRowHeadersBorderStyle, dgvabsPlaceholder, false /*singleVerticalBorderAdded*/, @@ -642,9 +640,10 @@ protected override object GetValue(int rowIndex) { // We allow multiple rows to share the same row header value. The row header cell's cloning does this. // So here we need to allow rowIndex == -1. - if (DataGridView is not null && (rowIndex < -1 || rowIndex >= DataGridView.Rows.Count)) + if (DataGridView is not null) { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); + ArgumentOutOfRangeException.ThrowIfLessThan(rowIndex, -1); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(rowIndex, DataGridView.Rows.Count); } return Properties.GetObject(s_propCellValue); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeadersWidthSizeMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeadersWidthSizeMode.cs index 4d38a9c647e..6781a03e854 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeadersWidthSizeMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeadersWidthSizeMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeightInfoNeededEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeightInfoNeededEventArgs.cs index df270525fc9..2df2e849e31 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeightInfoNeededEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeightInfoNeededEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeightInfoPushedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeightInfoPushedEventArgs.cs index 14d4402e609..5a45ccc42e9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeightInfoPushedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeightInfoPushedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowPostPaintEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowPostPaintEventArgs.cs index e7aaa6668c6..9c341bde27f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowPostPaintEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowPostPaintEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowPrePaintEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowPrePaintEventArgs.cs index 3d9732a6c33..8178fb2cc05 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowPrePaintEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowPrePaintEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowStateChangedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowStateChangedEventArgs.cs index 0096a222f88..1a1971fb501 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowStateChangedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowStateChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowsAddedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowsAddedEventArgs.cs index 107d3a9e6bf..628eb4b0ca5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowsAddedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowsAddedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowsRemovedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowsRemovedEventArgs.cs index b34eec87da9..323c61b9db7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowsRemovedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowsRemovedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectedCellCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectedCellCollection.cs index 6cd24bac47a..3c06f0c3dc9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectedCellCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectedCellCollection.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Collections; using System.ComponentModel; @@ -18,7 +15,7 @@ public class DataGridViewSelectedCellCollection : BaseCollection, IList { private readonly List _items = new(); - int IList.Add(object value) + int IList.Add(object? value) { throw new NotSupportedException(SR.DataGridView_ReadOnlyCollection); } @@ -28,16 +25,16 @@ void IList.Clear() throw new NotSupportedException(SR.DataGridView_ReadOnlyCollection); } - bool IList.Contains(object value) => ((IList)_items).Contains(value); + bool IList.Contains(object? value) => ((IList)_items).Contains(value); - int IList.IndexOf(object value) => ((IList)_items).IndexOf(value); + int IList.IndexOf(object? value) => ((IList)_items).IndexOf(value); - void IList.Insert(int index, object value) + void IList.Insert(int index, object? value) { throw new NotSupportedException(SR.DataGridView_ReadOnlyCollection); } - void IList.Remove(object value) + void IList.Remove(object? value) { throw new NotSupportedException(SR.DataGridView_ReadOnlyCollection); } @@ -51,7 +48,7 @@ void IList.RemoveAt(int index) bool IList.IsReadOnly => true; - object IList.this[int index] + object? IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(SR.DataGridView_ReadOnlyCollection); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectedColumnCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectedColumnCollection.cs index eb22fbf323f..b6b1d551d1a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectedColumnCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectedColumnCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectedRowCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectedRowCollection.cs index f01750bebe5..4d65cf31cf3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectedRowCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectedRowCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectionMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectionMode.cs index 7bd40a7f012..ed69e92ef8b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectionMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSelectionMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSortCompareEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSortCompareEventArgs.cs index a6518f74332..532d0aa9c34 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSortCompareEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewSortCompareEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxCell.DataGridViewTextBoxCellAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxCell.DataGridViewTextBoxCellAccessibleObject.cs index 3e50c163b9b..84d6f5e2a9f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxCell.DataGridViewTextBoxCellAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxCell.DataGridViewTextBoxCellAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxCell.cs index 6007aac6b32..e5579ee1ff9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxCell.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxColumn.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxColumn.cs index 8ee87ed3d24..b09ec81c2b0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxColumn.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxColumn.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxEditingControl.DataGridViewTextBoxEditingControlAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxEditingControl.DataGridViewTextBoxEditingControlAccessibleObject.cs index 266a1c4f3fc..a5fe41dcf3c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxEditingControl.DataGridViewTextBoxEditingControlAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxEditingControl.DataGridViewTextBoxEditingControlAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxEditingControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxEditingControl.cs index d093b11ec3e..b9e3853f4b9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxEditingControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTextBoxEditingControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTopLeftHeaderCell.DataGridViewTopLeftHeaderCellAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTopLeftHeaderCell.DataGridViewTopLeftHeaderCellAccessibleObject.cs index b42a3d3a14e..86f67a483b3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTopLeftHeaderCell.DataGridViewTopLeftHeaderCellAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTopLeftHeaderCell.DataGridViewTopLeftHeaderCellAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTopLeftHeaderCell.DataGridViewTopLeftHeaderCellRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTopLeftHeaderCell.DataGridViewTopLeftHeaderCellRenderer.cs index 98d11fd17b1..52c34358eef 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTopLeftHeaderCell.DataGridViewTopLeftHeaderCellRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTopLeftHeaderCell.DataGridViewTopLeftHeaderCellRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTopLeftHeaderCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTopLeftHeaderCell.cs index 07850fcc8d7..c474b5d80b5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTopLeftHeaderCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTopLeftHeaderCell.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; @@ -28,10 +27,7 @@ protected override Rectangle GetContentBounds(Graphics graphics, DataGridViewCel { ArgumentNullException.ThrowIfNull(cellStyle); - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); if (DataGridView is null) { @@ -86,10 +82,7 @@ protected override Rectangle GetContentBounds(Graphics graphics, DataGridViewCel protected override Rectangle GetErrorIconBounds(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) { - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); if (DataGridView is null) { @@ -140,10 +133,7 @@ protected override Rectangle GetErrorIconBounds(Graphics graphics, DataGridViewC protected override Size GetPreferredSize(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) { - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); if (DataGridView is null) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTriState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTriState.cs index 2d35198b074..0a59ca69089 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTriState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewTriState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewUtilities.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewUtilities.cs index ad9f27766a9..6c2fe44d542 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewUtilities.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewUtilities.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.BitmapBinder.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.BitmapBinder.cs index ad471ebbbc9..23df236d142 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.BitmapBinder.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.BitmapBinder.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Reflection; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.ComDataObjectAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.ComDataObjectAdapter.cs index 98cb8083ecf..4ada977c5c1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.ComDataObjectAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.ComDataObjectAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Buffers; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.DataStore.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.DataStore.cs index d5162233e32..c48f00b9f33 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.DataStore.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.DataStore.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -25,7 +24,7 @@ public DataStoreEntry(object? data, bool autoConvert) } } - private readonly Dictionary _data = new Dictionary(BackCompatibleStringComparer.Default); + private readonly Dictionary _data = new(BackCompatibleStringComparer.Default); public DataStore() { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.FormatEnumerator.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.FormatEnumerator.cs index f0ca3565cba..954970fc20d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.FormatEnumerator.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.FormatEnumerator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using Windows.Win32.System.Com; @@ -16,7 +15,7 @@ public partial class DataObject private unsafe class FormatEnumerator : ComTypes.IEnumFORMATETC, IEnumFORMATETC.Interface, IManagedWrapper { private readonly IDataObject _parent; - private readonly List _formats = new List(); + private readonly List _formats = new(); private int _current; public FormatEnumerator(IDataObject parent) : this(parent, parent.GetFormats()) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.RestrictedTypeDeserializationException.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.RestrictedTypeDeserializationException.cs index b6b0829cb57..e9d7c81389d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.RestrictedTypeDeserializationException.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.RestrictedTypeDeserializationException.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.cs index a08a8e21dcf..c18935f1b4f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -969,7 +968,7 @@ HRESULT Com.IDataObject.Interface.EnumFormatEtc(uint dwDirection, Com.IEnumFORMA HRESULT Com.IDataObject.Interface.DAdvise(Com.FORMATETC* pformatetc, uint advf, Com.IAdviseSink* pAdvSink, uint* pdwConnection) { - var adviseSink = (IAdviseSink)Marshal.GetObjectForIUnknown((nint)(void*)pAdvSink); + var adviseSink = (IAdviseSink)ComHelpers.GetObjectForIUnknown((Com.IUnknown*)pAdvSink); return (HRESULT)((ComTypes.IDataObject)this).DAdvise(ref *(FORMATETC*)pformatetc, (ADVF)advf, adviseSink, out *(int*)pdwConnection); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataSourceUpdateMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataSourceUpdateMode.cs index 1e25f3fe799..580824ffebb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataSourceUpdateMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataSourceUpdateMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataStreamFromComStream.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataStreamFromComStream.cs index f57c5f98c08..0e695b8c190 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataStreamFromComStream.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataStreamFromComStream.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Com; @@ -57,7 +56,7 @@ public override int Read(byte[] buffer, int index, int count) int bytesRead = 0; if (count > 0 && index >= 0 && (count + index) <= buffer.Length) { - var span = new Span(buffer, index, count); + Span span = new(buffer, index, count); bytesRead = Read(span); } @@ -110,7 +109,7 @@ public override void Write(byte[] buffer, int index, int count) if (count > 0 && index >= 0 && (count + index) <= buffer.Length) { - var span = new ReadOnlySpan(buffer, index, count); + ReadOnlySpan span = new(buffer, index, count); Write(span); return; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Datagridview.DisplayedBandsData.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Datagridview.DisplayedBandsData.cs index 37ffcd8aab3..85f25595a65 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Datagridview.DisplayedBandsData.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Datagridview.DisplayedBandsData.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DateBoldEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DateBoldEventArgs.cs index 4738ce5a98a..330d541602e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DateBoldEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DateBoldEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DateBoldEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DateBoldEventHandler.cs index 018204a6b76..d58c106d10b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DateBoldEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DateBoldEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DateRangeEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DateRangeEventArgs.cs index 22e462379b2..f76244fca46 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DateRangeEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DateRangeEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DateRangeEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DateRangeEventHandler.cs index 87b4ce3d073..782a7a03d3e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DateRangeEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DateRangeEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.DateTimePickerAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.DateTimePickerAccessibleObject.cs index 13c2bd77333..e5a5d80cfa5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.DateTimePickerAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.DateTimePickerAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.EnumChildren.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.EnumChildren.cs index 04b31152ff6..1b4d3444bfa 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.EnumChildren.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.EnumChildren.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.cs index f2544e98653..b0a0152816b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -338,9 +337,9 @@ public bool Checked // The information from win32 DateTimePicker is reliable only when ShowCheckBoxes is True if (ShowCheckBox && IsHandleCreated) { - var sys = default(SYSTEMTIME); - NMDATETIMECHANGE_FLAGS gdt = (NMDATETIMECHANGE_FLAGS)PInvoke.SendMessage(this, PInvoke.DTM_GETSYSTEMTIME, 0, ref sys); - return gdt == NMDATETIMECHANGE_FLAGS.GDT_VALID; + SYSTEMTIME systemTime = default; + nint result = PInvoke.SendMessage(this, PInvoke.DTM_GETSYSTEMTIME, 0, ref systemTime); + return result == (nint)NMDATETIMECHANGE_FLAGS.GDT_VALID; } else { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePickerFormats.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePickerFormats.cs index f25dca4ded2..e53c5ae4a27 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePickerFormats.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePickerFormats.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Day.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Day.cs index 3f6aca4598a..5e6637b000b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Day.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Day.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.ComponentEditorPageSite.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.ComponentEditorPageSite.cs index 960da4f3c69..bbb93411116 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.ComponentEditorPageSite.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.ComponentEditorPageSite.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Reflection; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.PageSelector.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.PageSelector.cs index aa04612c684..ab58c98ec45 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.PageSelector.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.PageSelector.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; @@ -94,10 +93,10 @@ private unsafe void DrawTreeItem( COLORREF backColor, COLORREF textColor) { - Size size = default(Size); - RECT rc2 = default(RECT); + Size size = default; + RECT rc2 = default; RECT rc = rcIn; - ImageList imagelist = ImageList; + ImageList? imageList = ImageList; // Select the font of the dialog, so we don't get the underlined font // when the item is being tracked @@ -142,13 +141,16 @@ private unsafe void DrawTreeItem( DRAW_TEXT_FORMAT.DT_LEFT | DRAW_TEXT_FORMAT.DT_VCENTER | DRAW_TEXT_FORMAT.DT_END_ELLIPSIS | DRAW_TEXT_FORMAT.DT_NOPREFIX); } - PInvoke.ImageList.Draw( - imagelist, - imageIndex, - dc, - PADDING_HORZ, - rc.top + (((rc.bottom - rc.top) - SIZE_ICON_Y) >> 1), - (IMAGE_LIST_DRAW_STYLE)ComCtl32.ILD.TRANSPARENT); + if (imageList is not null) + { + PInvoke.ImageList.Draw( + imageList, + imageIndex, + dc, + PADDING_HORZ, + rc.top + (((rc.bottom - rc.top) - SIZE_ICON_Y) >> 1), + (IMAGE_LIST_DRAW_STYLE)ComCtl32.ILD.TRANSPARENT); + } // Draw the hot-tracking border if needed if ((state & STATE_HOT) != 0) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.cs index 67a8aa1263d..a8c78c3f8fb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; @@ -23,7 +22,7 @@ public partial class ComponentEditorForm : Form private bool _dirty; private bool _firstActivate; - private readonly Panel _pageHost = new Panel(); + private readonly Panel _pageHost = new(); private PageSelector _selector; private ImageList _selectorImageList; private Button _okButton; @@ -383,7 +382,7 @@ protected virtual void OnSelChangeSelector(object? source, TreeViewEventArgs e) return; } - int newPage = _selector.SelectedNode.Index; + int newPage = _selector.SelectedNode!.Index; Debug.Assert((newPage >= 0) && (newPage < _pageSites.Length), "Invalid page selected"); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorPage.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorPage.cs index 76a538130dc..4de8518b85f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorPage.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorPage.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/EventsTab.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/EventsTab.cs index 46b968f1319..b903727c557 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/EventsTab.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/EventsTab.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/IUIService.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/IUIService.cs index bedf7816ccb..bc4c497a4c6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/IUIService.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/IUIService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/IWindowsFormsEditorService.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/IWindowsFormsEditorService.cs index 95b48d46296..a70f2b2bfa1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/IWindowsFormsEditorService.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/IWindowsFormsEditorService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing.Design; using System.Windows.Forms.PropertyGridInternal; @@ -51,7 +50,7 @@ public interface IWindowsFormsEditorService /// no other stored reference to the control. /// /// - void DropDownControl(Control? control); + void DropDownControl(Control control); /// /// Shows the specified as a dialog and returns its result. You should always use this diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/PropertyTab.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/PropertyTab.cs index f21814dd914..7b54ff63155 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/PropertyTab.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/PropertyTab.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ToolStripDesignerAvailability.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ToolStripDesignerAvailability.cs index 9cd5a53877b..f55658ec939 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ToolStripDesignerAvailability.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ToolStripDesignerAvailability.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ToolStripItemDesignerAvailabilityAttribute.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ToolStripItemDesignerAvailabilityAttribute.cs index 67cf29ddd7b..449d5d11c28 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ToolStripItemDesignerAvailabilityAttribute.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ToolStripItemDesignerAvailabilityAttribute.cs @@ -1,13 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Design; [AttributeUsage(AttributeTargets.Class)] public sealed class ToolStripItemDesignerAvailabilityAttribute : Attribute { - public static readonly ToolStripItemDesignerAvailabilityAttribute Default = new ToolStripItemDesignerAvailabilityAttribute(); + public static readonly ToolStripItemDesignerAvailabilityAttribute Default = new(); /// /// Specifies which ToolStrip types the Item can appear in - ToolStrip,MenuStrip,StatusStrip,ContextMenuStrip diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/WindowsFormsComponentEditor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/WindowsFormsComponentEditor.cs index aa42c3df9ee..dc64318e3bb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/WindowsFormsComponentEditor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/WindowsFormsComponentEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DialogResult.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DialogResult.cs index 23df6edeb44..cea39eb14da 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DialogResult.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DialogResult.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DisplayInformation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DisplayInformation.cs index e67743ea072..a3c9d68aa06 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DisplayInformation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DisplayInformation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.Win32; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DockStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DockStyle.cs index 8153676c96a..856cdf5ace0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DockStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DockStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DockingAttribute.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DockingAttribute.cs index 56ee5715337..9e965efe228 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DockingAttribute.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DockingAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -20,7 +19,7 @@ public DockingAttribute(DockingBehavior dockingBehavior) DockingBehavior = dockingBehavior; } - public static readonly DockingAttribute Default = new DockingAttribute(); + public static readonly DockingAttribute Default = new(); public DockingBehavior DockingBehavior { get; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DockingBehavior.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DockingBehavior.cs index c68022c6db4..50e2379e287 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DockingBehavior.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DockingBehavior.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainItemAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainItemAccessibleObject.cs index 21b44af0dcd..816ce9e747c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainItemAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainItemAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainUpDownAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainUpDownAccessibleObject.cs index 19f34a3b3c8..207471dcff2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainUpDownAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainUpDownAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainUpDownItemCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainUpDownItemCollection.cs index af74373552e..0233e5aede2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainUpDownItemCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainUpDownItemCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainUpDownItemCompare.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainUpDownItemCompare.cs index 94b62b6b743..f24f8abdd2b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainUpDownItemCompare.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.DomainUpDownItemCompare.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.cs index d20020f464e..a470d7bd6f2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DomainUpDown.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DpiChangedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DpiChangedEventArgs.cs index 8bd79991299..9f7c4cb9233 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DpiChangedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DpiChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DpiChangedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DpiChangedEventHandler.cs index dc394d152a7..23b6dd40a60 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DpiChangedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DpiChangedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DragAction.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DragAction.cs index 8c7171a4ba7..7c312f5f8d4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DragAction.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DragAction.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DragDropEffects.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DragDropEffects.cs index f2146c8c6ce..c7241de0eae 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DragDropEffects.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DragDropEffects.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DragDropFormat.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DragDropFormat.cs index ce33b49c69f..99e99d81316 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DragDropFormat.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DragDropFormat.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DragDropHelper.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DragDropHelper.cs index f4380069282..bf235e14c56 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DragDropHelper.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DragDropHelper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DragEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DragEventArgs.cs index 5081000d7ca..44531838322 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DragEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DragEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DragEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DragEventHandler.cs index 24549497f52..dc2bbae0418 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DragEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DragEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DrawItemEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DrawItemEventArgs.cs index c519ff01dfc..7bd513bb175 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DrawItemEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DrawItemEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DrawItemEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DrawItemEventHandler.cs index 864ddc29265..fc94b96626d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DrawItemEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DrawItemEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DrawItemState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DrawItemState.cs index 30ac3e6b672..280255647d6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DrawItemState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DrawItemState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewColumnHeaderEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewColumnHeaderEventArgs.cs index f64791804e9..6b18c35bb84 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewColumnHeaderEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewColumnHeaderEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; @@ -88,7 +87,7 @@ public void DrawBackground() { if (Application.RenderWithVisualStyles) { - var vsr = new VisualStyleRenderer(VisualStyleElement.Header.Item.Normal); + VisualStyleRenderer vsr = new(VisualStyleElement.Header.Item.Normal); vsr.DrawBackground(Graphics, Bounds); } else diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewColumnHeaderEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewColumnHeaderEventHandler.cs index 6587096d708..0802c39d7cd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewColumnHeaderEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewColumnHeaderEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewItemEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewItemEventArgs.cs index 60ce0de4f3a..3e33f28f0d9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewItemEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewItemEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewItemEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewItemEventHandler.cs index 93c8e5713f7..f70d2e39a2c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewItemEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewItemEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewSubItemEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewSubItemEventArgs.cs index c8c6a242a6e..4f0ada95df3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewSubItemEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewSubItemEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewSubItemEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewSubItemEventHandler.cs index 865535dbc74..946a6bb4496 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewSubItemEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewSubItemEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DrawMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DrawMode.cs index 1d87be8d9af..1431c55adb9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DrawMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DrawMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DrawToolTipEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DrawToolTipEventArgs.cs index e0b7fd37450..c60441201b7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DrawToolTipEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DrawToolTipEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DrawToolTipEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DrawToolTipEventHandler.cs index 3d2c2a551bc..cacff66f3c9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DrawToolTipEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DrawToolTipEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DrawTreeNodeEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DrawTreeNodeEventArgs.cs index dbe14cfb044..107e78257ec 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DrawTreeNodeEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DrawTreeNodeEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DrawTreeNodeEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DrawTreeNodeEventHandler.cs index 3b101de3cda..12f31ed4387 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DrawTreeNodeEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DrawTreeNodeEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DropImageType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DropImageType.cs index 284f77f9921..58e28d7f36c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DropImageType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DropImageType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DropSource.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DropSource.cs index 070893e84bd..7f07ea5d1b8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DropSource.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DropSource.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DropTarget.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DropTarget.cs index 5ea981125e6..820b6ce3f16 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DropTarget.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DropTarget.cs @@ -1,13 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using Windows.Win32.System.SystemServices; using Ole = Windows.Win32.System.Ole; using Com = Windows.Win32.System.Com; using ComTypes = System.Runtime.InteropServices.ComTypes; -using System.Runtime.InteropServices; using Windows.Win32.System.Com; namespace System.Windows.Forms; @@ -60,7 +58,7 @@ private void ClearDropDescription() } else { - object? obj = Marshal.GetObjectForIUnknown((nint)pDataObj); + object obj = ComHelpers.GetObjectForIUnknown((Com.IUnknown*)pDataObj); if (obj is IDataObject dataObject) { data = dataObject; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorBlinkStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorBlinkStyle.cs index b0f8ec99009..ff2081f9210 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorBlinkStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorBlinkStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorIconAlignment.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorIconAlignment.cs index ee73d8d1de7..43ed5ffdc7e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorIconAlignment.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorIconAlignment.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ControlItem.ControlItemAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ControlItem.ControlItemAccessibleObject.cs index fe7ee51adf8..cedd5688507 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ControlItem.ControlItemAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ControlItem.ControlItemAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ControlItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ControlItem.cs index 4833db44246..0bf951cef58 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ControlItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ControlItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ErrorWindow.ErrorWindowAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ErrorWindow.ErrorWindowAccessibleObject.cs index 68d2f1f16ad..962b81a66ae 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ErrorWindow.ErrorWindowAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ErrorWindow.ErrorWindowAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ErrorWindow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ErrorWindow.cs index 3b8b93c65ea..7eaac7b61b9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ErrorWindow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ErrorWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -22,7 +21,7 @@ internal partial class ErrorWindow : NativeWindow { private static readonly int s_accessibilityProperty = PropertyStore.CreateKey(); - private readonly List _items = new List(); + private readonly List _items = new(); private readonly Control _parent; private readonly ErrorProvider _provider; private Rectangle _windowBounds; @@ -71,7 +70,7 @@ public void Add(ControlItem item) if (_tipWindow is not null) { - var toolInfo = new ComCtl32.ToolInfoWrapper(this, item.Id, TOOLTIP_FLAGS.TTF_SUBCLASS, item.Error); + ComCtl32.ToolInfoWrapper toolInfo = new(this, item.Id, TOOLTIP_FLAGS.TTF_SUBCLASS, item.Error); toolInfo.SendMessage(_tipWindow, PInvoke.TTM_ADDTOOLW); } @@ -287,7 +286,7 @@ public void Remove(ControlItem item) if (_tipWindow is not null) { - var info = new ComCtl32.ToolInfoWrapper(this, item.Id); + ComCtl32.ToolInfoWrapper info = new(this, item.Id); info.SendMessage(_tipWindow, PInvoke.TTM_DELTOOLW); } @@ -338,17 +337,10 @@ public unsafe void Update(bool timerCaused) { ControlItem item = _items[i]; Rectangle iconBounds = item.GetIconBounds(size); - if (_windowBounds.IsEmpty) - { - _windowBounds = iconBounds; - } - else - { - _windowBounds = Rectangle.Union(_windowBounds, iconBounds); - } + _windowBounds = _windowBounds.IsEmpty ? iconBounds : Rectangle.Union(_windowBounds, iconBounds); } - using var windowRegion = new Region(new Rectangle(0, 0, 0, 0)); + using Region windowRegion = new(new Rectangle(0, 0, 0, 0)); for (int i = 0; i < _items.Count; i++) { @@ -389,7 +381,7 @@ public unsafe void Update(bool timerCaused) flags |= TOOLTIP_FLAGS.TTF_RTLREADING; } - var toolInfo = new ComCtl32.ToolInfoWrapper(this, item.Id, flags, item.Error, iconBounds); + ComCtl32.ToolInfoWrapper toolInfo = new(this, item.Id, flags, item.Error, iconBounds); toolInfo.SendMessage(_tipWindow, PInvoke.TTM_SETTOOLINFOW); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.IconRegion.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.IconRegion.cs index 9b88de23796..1728ef52b56 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.IconRegion.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.IconRegion.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.cs index b71ebacb4fb..67969cec02c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; @@ -460,7 +459,7 @@ private void ErrorManager_CurrentChanged(object? sender, EventArgs e) } object? value = _errorManager.Current; - if (value is not IDataErrorInfo) + if (value is not IDataErrorInfo dataErrorInfo) { return; } @@ -487,7 +486,7 @@ private void ErrorManager_CurrentChanged(object? sender, EventArgs e) } Binding dataBinding = errBindings[j]; - string error = ((IDataErrorInfo)value)[dataBinding.BindingMemberInfo.BindingField]; + string error = dataErrorInfo[dataBinding.BindingMemberInfo.BindingField]; error ??= string.Empty; @@ -555,8 +554,7 @@ private static Icon DefaultIcon // Error provider uses small Icon. int width = PInvoke.GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CXSMICON); int height = PInvoke.GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CYSMICON); - using var defaultIcon = new Icon(typeof(ErrorProvider), "Error"); - + using Icon defaultIcon = new(typeof(ErrorProvider), "Error"); t_defaultIcon = new Icon(defaultIcon, width, height); } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FeatureSupport.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FeatureSupport.cs index 75790a0ccf5..4a1d1182ba2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FeatureSupport.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FeatureSupport.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FileDialog.Vista.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FileDialog.Vista.cs index db8e74896bf..6f52583e0ee 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FileDialog.Vista.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FileDialog.Vista.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using Windows.Win32.UI.Controls.Dialogs; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FileDialog.VistaDialogEvents.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FileDialog.VistaDialogEvents.cs index 318119b9637..0fba7356be6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FileDialog.VistaDialogEvents.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FileDialog.VistaDialogEvents.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FileDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FileDialog.cs index 609bf701b1c..1b2438f9850 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FileDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FileDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FixedPanel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FixedPanel.cs index 5e8b09a5f72..44dcee5a250 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FixedPanel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FixedPanel.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FlatButtonAppearance.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FlatButtonAppearance.cs index 4094776eeec..dc03d91ae35 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FlatButtonAppearance.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FlatButtonAppearance.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FlatButtonAppearanceConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FlatButtonAppearanceConverter.cs index 3211e85042b..06eebcb263f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FlatButtonAppearanceConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FlatButtonAppearanceConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FlatStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FlatStyle.cs index 874b719adbe..efc719533f3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FlatStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FlatStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FlowDirection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FlowDirection.cs index e6aa5563fde..0a1e1920390 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FlowDirection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FlowDirection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FlowLayoutPanel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FlowLayoutPanel.cs index dbd5cf6096a..8ccee9bea17 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FlowLayoutPanel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FlowLayoutPanel.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FlowLayoutSettings.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FlowLayoutSettings.cs index a8481247912..cbc0e6448aa 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FlowLayoutSettings.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FlowLayoutSettings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Windows.Forms.Layout; @@ -10,7 +9,8 @@ namespace System.Windows.Forms; [DefaultProperty(nameof(FlowDirection))] public class FlowLayoutSettings : LayoutSettings { - internal FlowLayoutSettings(IArrangedElement owner) : base(owner) + internal FlowLayoutSettings(IArrangedElement owner) + : base(owner) { } @@ -21,10 +21,10 @@ internal FlowLayoutSettings(IArrangedElement owner) : base(owner) [SRCategory(nameof(SR.CatLayout))] public FlowDirection FlowDirection { - get => FlowLayout.GetFlowDirection(Owner); + get => FlowLayout.GetFlowDirection(Owner!); set { - FlowLayout.SetFlowDirection(Owner, value); + FlowLayout.SetFlowDirection(Owner!, value); Debug.Assert(FlowDirection == value, "FlowDirection should be the same as we set it"); } } @@ -34,10 +34,10 @@ public FlowDirection FlowDirection [SRCategory(nameof(SR.CatLayout))] public bool WrapContents { - get => FlowLayout.GetWrapContents(Owner); + get => FlowLayout.GetWrapContents(Owner!); set { - FlowLayout.SetWrapContents(Owner, value); + FlowLayout.SetWrapContents(Owner!, value); Debug.Assert(WrapContents == value, "WrapContents should be the same as we set it"); } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FolderBrowserDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FolderBrowserDialog.cs index d04bc5127e3..32c5dfee71c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FolderBrowserDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FolderBrowserDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; @@ -185,11 +184,9 @@ public Environment.SpecialFolder RootFolder get => _rootFolder; set { - if (!Enum.IsDefined(typeof(Environment.SpecialFolder), value)) - { - throw new InvalidEnumArgumentException(nameof(value), (int)value, typeof(Environment.SpecialFolder)); - } - + // If users want to use other CSIDL values that aren't in SpecialFolder (as are exposed in + // FolderNameEditor.FolderBrowserFolder) then we'll let them as we're not calling Environment.GetFolderPath + // directly. _rootFolder = value; } } @@ -386,18 +383,8 @@ private unsafe void GetResult(IFileOpenDialog* dialog) } } - private unsafe bool RunDialogOld(HWND hWndOwner) + private unsafe bool RunDialogOld(HWND owner) { - PInvoke.SHGetSpecialFolderLocation((int)_rootFolder, out ITEMIDLIST* listHandle); - if (listHandle is null) - { - PInvoke.SHGetSpecialFolderLocation((int)Environment.SpecialFolder.Desktop, out listHandle); - if (listHandle is null) - { - throw new InvalidOperationException(SR.FolderBrowserDialogNoRootFolder); - } - } - uint mergedOptions = PInvoke.BIF_NEWDIALOGSTYLE; if (!ShowNewFolderButton) { @@ -408,46 +395,32 @@ private unsafe bool RunDialogOld(HWND hWndOwner) // threading model if the BIF_NEWDIALOGSTYLE flag has been requested (which we always do in mergedOptions // above). So make sure OLE is initialized, and throw an exception if caller attempts to invoke dialog // under the MTA threading model (...dialog does appear under MTA, but is totally non-functional). - if (Control.CheckForIllegalCrossThreadCalls && Application.OleRequired() != System.Threading.ApartmentState.STA) + if (Control.CheckForIllegalCrossThreadCalls && Application.OleRequired() != ApartmentState.STA) { throw new ThreadStateException(string.Format(SR.DebuggingExceptionOnly, SR.ThreadMustBeSTA)); } - delegate* unmanaged[Stdcall] callback = &FolderBrowserDialog_BrowseCallbackProc; - using BufferScope displayName = new(PInvoke.MAX_PATH + 1); - var handle = GCHandle.Alloc(this); + GCHandle handle = GCHandle.Alloc(this); + try { - fixed (char* pDisplayName = displayName) - fixed (char* title = _descriptionText) + string? folder = FolderBrowserHelper.BrowseForFolder( + _descriptionText, + (int)_rootFolder, + mergedOptions, + owner, + &FolderBrowserDialog_BrowseCallbackProc, + GCHandle.ToIntPtr(handle)); + + if (folder is not null) { - var bi = new BROWSEINFOW - { - pidlRoot = listHandle, - hwndOwner = hWndOwner, - pszDisplayName = pDisplayName, - lpszTitle = title, - ulFlags = mergedOptions, - lpfn = callback, - lParam = GCHandle.ToIntPtr(handle), - iImage = 0 - }; - - // Show the dialog - ITEMIDLIST* browseHandle = PInvoke.SHBrowseForFolder(in bi); - { - if (browseHandle is null) - { - return false; - } - - // Retrieve the path from the IDList. - fixed (char* path = _selectedPath!) - { - PInvoke.SHGetPathFromIDList(browseHandle, path); - return true; - } - } + _selectedPath = folder; + return true; + } + else + { + _selectedPath = string.Empty; + return false; } } finally @@ -489,9 +462,12 @@ private static unsafe int FolderBrowserDialog_BrowseCallbackProc(HWND hwnd, uint if (selectedPidl is not null) { // Try to retrieve the path from the IDList - char* buffer = stackalloc char[PInvoke.MAX_PATH + 1]; - bool isFileSystemFolder = PInvoke.SHGetPathFromIDList(selectedPidl, (PWSTR)buffer); - PInvoke.SendMessage(hwnd, PInvoke.BFFM_ENABLEOK, 0, (nint)(BOOL)isFileSystemFolder); + using BufferScope buffer = new(stackalloc char[PInvoke.MAX_PATH + 1]); + fixed (char* b = buffer) + { + bool isFileSystemFolder = PInvoke.SHGetPathFromIDListEx(selectedPidl, b, (uint)buffer.Length, GPFIDL_FLAGS.GPFIDL_UNCPRINTER); + PInvoke.SendMessage(hwnd, PInvoke.BFFM_ENABLEOK, 0, (nint)(BOOL)isFileSystemFolder); + } } break; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FontDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FontDialog.cs index 1bc50693bd7..96aac65a378 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FontDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FontDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -19,7 +18,7 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionFontDialog))] public class FontDialog : CommonDialog { - protected static readonly object EventApply = new object(); + protected static readonly object EventApply = new(); private const int defaultMinSize = 0; private const int defaultMaxSize = 0; @@ -430,7 +429,7 @@ protected override unsafe bool RunDialog(IntPtr hWndOwner) using Graphics graphics = Graphics.FromHdcInternal(dc); LOGFONTW logFont = LOGFONTW.FromFont(Font, graphics); - var cf = new Comdlg32.CHOOSEFONTW + Comdlg32.CHOOSEFONTW cf = new() { lStructSize = (uint)sizeof(Comdlg32.CHOOSEFONTW), hwndOwner = hWndOwner, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Form.AccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Form.AccessibleObject.cs index 59be2ee0b3f..7d965d841be 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Form.AccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Form.AccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Form.ControlCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Form.ControlCollection.cs index cc80ab4e5a0..3e167613bf7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Form.ControlCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Form.ControlCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Form.EnumThreadWindowsCallback.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Form.EnumThreadWindowsCallback.cs index 183cfe372bc..bf3a4638da6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Form.EnumThreadWindowsCallback.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Form.EnumThreadWindowsCallback.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs index 84c91b52bae..45dd6330a3d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -27,26 +26,26 @@ namespace System.Windows.Forms; [DesignerCategory("Form")] public partial class Form : ContainerControl { - private static readonly object EVENT_ACTIVATED = new object(); - private static readonly object EVENT_CLOSING = new object(); - private static readonly object EVENT_CLOSED = new object(); - private static readonly object EVENT_FORMCLOSING = new object(); - private static readonly object EVENT_FORMCLOSED = new object(); - private static readonly object EVENT_DEACTIVATE = new object(); - private static readonly object EVENT_LOAD = new object(); - private static readonly object EVENT_MDI_CHILD_ACTIVATE = new object(); - private static readonly object EVENT_INPUTLANGCHANGE = new object(); - private static readonly object EVENT_INPUTLANGCHANGEREQUEST = new object(); - private static readonly object EVENT_MENUSTART = new object(); - private static readonly object EVENT_MENUCOMPLETE = new object(); - private static readonly object EVENT_MAXIMUMSIZECHANGED = new object(); - private static readonly object EVENT_MINIMUMSIZECHANGED = new object(); - private static readonly object EVENT_HELPBUTTONCLICKED = new object(); - private static readonly object EVENT_SHOWN = new object(); - private static readonly object EVENT_RESIZEBEGIN = new object(); - private static readonly object EVENT_RESIZEEND = new object(); - private static readonly object EVENT_RIGHTTOLEFTLAYOUTCHANGED = new object(); - private static readonly object EVENT_DPI_CHANGED = new object(); + private static readonly object EVENT_ACTIVATED = new(); + private static readonly object EVENT_CLOSING = new(); + private static readonly object EVENT_CLOSED = new(); + private static readonly object EVENT_FORMCLOSING = new(); + private static readonly object EVENT_FORMCLOSED = new(); + private static readonly object EVENT_DEACTIVATE = new(); + private static readonly object EVENT_LOAD = new(); + private static readonly object EVENT_MDI_CHILD_ACTIVATE = new(); + private static readonly object EVENT_INPUTLANGCHANGE = new(); + private static readonly object EVENT_INPUTLANGCHANGEREQUEST = new(); + private static readonly object EVENT_MENUSTART = new(); + private static readonly object EVENT_MENUCOMPLETE = new(); + private static readonly object EVENT_MAXIMUMSIZECHANGED = new(); + private static readonly object EVENT_MINIMUMSIZECHANGED = new(); + private static readonly object EVENT_HELPBUTTONCLICKED = new(); + private static readonly object EVENT_SHOWN = new(); + private static readonly object EVENT_RESIZEBEGIN = new(); + private static readonly object EVENT_RESIZEEND = new(); + private static readonly object EVENT_RIGHTTOLEFTLAYOUTCHANGED = new(); + private static readonly object EVENT_DPI_CHANGED = new(); // // The following flags should be used with formState[..] not formStateEx[..] @@ -98,7 +97,7 @@ public partial class Form : ContainerControl private const int SizeGripSize = 16; private static Icon? defaultIcon; - private static readonly object internalSyncObject = new object(); + private static readonly object internalSyncObject = new(); // Property store keys for properties. The property store allocates most efficiently // in groups of four, so we try to lump properties in groups of four based on how @@ -135,21 +134,21 @@ public partial class Form : ContainerControl // Form per instance members // Note: Do not add anything to this list unless absolutely necessary. - private BitVector32 _formState = new BitVector32(0x21338); // magic value... all the defaults... see the ctor for details... + private BitVector32 _formState = new(0x21338); // magic value... all the defaults... see the ctor for details... private BitVector32 _formStateEx; private Icon? _icon; private Icon? _smallIcon; private Size _autoScaleBaseSize = Size.Empty; private Size _minAutoSize = Size.Empty; - private Rectangle _restoredWindowBounds = new Rectangle(-1, -1, -1, -1); + private Rectangle _restoredWindowBounds = new(-1, -1, -1, -1); private BoundsSpecified _restoredWindowBoundsSpecified; private DialogResult _dialogResult; private MdiClient? _ctlClient; private NativeWindow? _ownerWindow; private bool _rightToLeftLayout; - private Rectangle _restoreBounds = new Rectangle(-1, -1, -1, -1); + private Rectangle _restoreBounds = new(-1, -1, -1, -1); private CloseReason _closeReason = CloseReason.None; private VisualStyleRenderer? _sizeGripRenderer; @@ -1239,7 +1238,7 @@ protected Rectangle MaximizedBounds } } - private static readonly object EVENT_MAXIMIZEDBOUNDSCHANGED = new object(); + private static readonly object EVENT_MAXIMIZEDBOUNDSCHANGED = new(); [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.FormOnMaximizedBoundsChangedDescr))] @@ -3392,7 +3391,7 @@ protected override void Dispose(bool disposing) if (Properties.TryGetObject(PropDummyMdiMenu, out HMENU dummyMenu) && !dummyMenu.IsNull) { - Properties.SetObject(PropDummyMdiMenu, null); + Properties.RemoveObject(PropDummyMdiMenu); PInvoke.DestroyMenu(dummyMenu); } } @@ -3729,7 +3728,7 @@ protected void CenterToParent() return; } - Point p = default(Point); + Point p = default; Size s = Size; HWND ownerHandle = (HWND)PInvoke.GetWindowLong(this, WINDOW_LONG_PTR_INDEX.GWL_HWNDPARENT); @@ -3775,7 +3774,7 @@ protected void CenterToParent() /// protected void CenterToScreen() { - Point p = default(Point); + Point p = default; Screen desktop; if (OwnerInternal is not null) { @@ -4178,11 +4177,11 @@ protected override void OnVisibleChanged(EventArgs e) && data) { Control button = (Control)AcceptButton; - var ptToSnap = new Point(button.Left + button.Width / 2, button.Top + button.Height / 2); - PInvoke.ClientToScreen(this, ref ptToSnap); + Point pointToSnap = new(button.Left + button.Width / 2, button.Top + button.Height / 2); + PInvoke.ClientToScreen(this, ref pointToSnap); if (!button.IsWindowObscured) { - Cursor.Position = ptToSnap; + Cursor.Position = pointToSnap; } } } @@ -4231,7 +4230,7 @@ protected override void OnPaint(PaintEventArgs e) { _sizeGripRenderer ??= new VisualStyleRenderer(VisualStyleElement.Status.Gripper.Normal); - using var hdc = new DeviceContextHdcScope(e); + using DeviceContextHdcScope hdc = new(e); _sizeGripRenderer.DrawBackground( hdc, new Rectangle(size.Width - SizeGripSize, size.Height - SizeGripSize, SizeGripSize, SizeGripSize)); @@ -5814,7 +5813,7 @@ private void UpdateMdiControlStrip(bool maximized) } #endif - ToolStripManager.RevertMergeInternal(mdiControlStrip.MergedMenu, mdiControlStrip, /*revertMDIStuff*/true); + ToolStripManager.RevertMergeInternal(mdiControlStrip.MergedMenu, mdiControlStrip, revertMDIControls: true); #if DEBUG // double check that RevertMerge doesnt accidentally revert more than it should. @@ -5841,7 +5840,7 @@ private void UpdateMdiControlStrip(bool maximized) HMENU hMenu = PInvoke.GetMenu(this); if (hMenu == HMENU.Null) { - MenuStrip sourceMenuStrip = ToolStripManager.GetMainMenuStrip(this); + MenuStrip? sourceMenuStrip = ToolStripManager.GetMainMenuStrip(this); if (sourceMenuStrip is not null) { MdiControlStrip = new MdiControlStrip(ActiveMdiChildInternal); @@ -5867,10 +5866,10 @@ internal void UpdateMdiWindowListStrip() { if (MdiWindowListStrip is not null && MdiWindowListStrip.MergedMenu is not null) { - ToolStripManager.RevertMergeInternal(MdiWindowListStrip.MergedMenu, MdiWindowListStrip, /*revertMdiStuff*/true); + ToolStripManager.RevertMergeInternal(MdiWindowListStrip.MergedMenu, MdiWindowListStrip, revertMDIControls: true); } - MenuStrip sourceMenuStrip = ToolStripManager.GetMainMenuStrip(this); + MenuStrip? sourceMenuStrip = ToolStripManager.GetMainMenuStrip(this); if (sourceMenuStrip is not null && sourceMenuStrip.MdiWindowListItem is not null) { MdiWindowListStrip ??= new MdiWindowListStrip(); @@ -6239,7 +6238,7 @@ private void WmClose(ref Message m) if (m.MsgInternal == PInvoke.WM_QUERYENDSESSION) { - m.ResultInternal = (LRESULT)(nint)(BOOL)e.Cancel; + m.ResultInternal = (LRESULT)(BOOL)!e.Cancel; } else if (e.Cancel && (MdiParent is not null)) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FormBorderStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FormBorderStyle.cs index f2ac44381b7..7197a1a1d38 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FormBorderStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FormBorderStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FormClosedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FormClosedEventArgs.cs index 93f274a6af0..a047531439b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FormClosedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FormClosedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FormClosedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FormClosedEventHandler.cs index 2da756089ee..bc3cb6c0ccc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FormClosedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FormClosedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FormClosingEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FormClosingEventArgs.cs index fd1b095df1b..cb120559c53 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FormClosingEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FormClosingEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FormClosingEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FormClosingEventHandler.cs index bb217c3a883..f3f6ddd90bf 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FormClosingEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FormClosingEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FormCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FormCollection.cs index 035bca1a365..f39a79c658e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FormCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FormCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; @@ -12,7 +11,7 @@ namespace System.Windows.Forms; /// public class FormCollection : ReadOnlyCollectionBase { - internal static object CollectionSyncRoot = new object(); + internal static object CollectionSyncRoot = new(); /// /// Gets a form specified by name, if present, else returns null. If there are multiple diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FormStartPosition.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FormStartPosition.cs index dd320639e18..857ca835fda 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FormStartPosition.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FormStartPosition.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FormWindowState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FormWindowState.cs index 3f4103485b2..2ab73eb86a7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FormWindowState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FormWindowState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Formatter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Formatter.cs index 7fce86008db..2c05b4b53e1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Formatter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Formatter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; @@ -13,7 +12,7 @@ internal static class Formatter private static readonly Type stringType = typeof(string); private static readonly Type booleanType = typeof(bool); private static readonly Type checkStateType = typeof(CheckState); - private static readonly object parseMethodNotFound = new object(); + private static readonly object parseMethodNotFound = new(); private static readonly object defaultDataSourceNullValue = DBNull.Value; /// diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FrameStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FrameStyle.cs index 15d63d8a5bc..98412155c43 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FrameStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FrameStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/GetChildAtPointSkip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/GetChildAtPointSkip.cs index 5deb3cd2576..7c58ea3ec06 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/GetChildAtPointSkip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/GetChildAtPointSkip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/GiveFeedbackEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/GiveFeedbackEventArgs.cs index f784a7342f5..9e8ad297cee 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/GiveFeedbackEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/GiveFeedbackEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/GiveFeedbackEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/GiveFeedbackEventHandler.cs index d114b8915d1..20f6aa17b6c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/GiveFeedbackEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/GiveFeedbackEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/GridItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/GridItem.cs index 4c7da95c2b2..28aa4967760 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/GridItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/GridItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/GridItemCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/GridItemCollection.cs index 0719a13181e..9c0723d978c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/GridItemCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/GridItemCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/GridItemType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/GridItemType.cs index acb662f8c41..b7f61410137 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/GridItemType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/GridItemType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/GroupBox.GroupBoxAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/GroupBox.GroupBoxAccessibleObject.cs index bcea98d7e31..1097eb832d2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/GroupBox.GroupBoxAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/GroupBox.GroupBoxAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/GroupBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/GroupBox.cs index c2367c4fba1..b085dba7229 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/GroupBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/GroupBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -131,9 +130,9 @@ protected override CreateParams CreateParams } // Set the default Padding to 3 so that it is consistent with Everett - protected override Padding DefaultPadding => new Padding(3); + protected override Padding DefaultPadding => new(3); - protected override Size DefaultSize => new Size(200, 100); + protected override Size DefaultSize => new(200, 100); /// /// Gets a rectangle that represents the dimensions of the @@ -490,7 +489,7 @@ private void DrawGroupBox(PaintEventArgs e) } else { - using var hdc = new DeviceContextHdcScope(e); + using DeviceContextHdcScope hdc = new(e); DRAW_TEXT_FORMAT flags = DRAW_TEXT_FORMAT.DT_WORDBREAK | DRAW_TEXT_FORMAT.DT_EDITCONTROL; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/GroupBoxRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/GroupBoxRenderer.cs index 6eba2e32282..b88b168747b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/GroupBoxRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/GroupBoxRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; @@ -315,7 +314,7 @@ private static void DrawUnthemedGroupBoxWithText( boxTop += font.Height / 2; } - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); ReadOnlySpan darkLines = stackalloc int[] { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HScrollBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HScrollBar.cs index 704b535c97f..2ff672ba9f0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HScrollBar.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HScrollBar.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; namespace System.Windows.Forms; @@ -22,5 +21,5 @@ protected override CreateParams CreateParams } protected override Size DefaultSize - => new Size(80, SystemInformation.HorizontalScrollBarHeight); + => new(80, SystemInformation.HorizontalScrollBarHeight); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HScrollProperties.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HScrollProperties.cs index 7f599cd2fd7..a907859f14b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HScrollProperties.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HScrollProperties.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HandledMouseEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HandledMouseEventArgs.cs index 37e16d030ca..f8ef02a5966 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HandledMouseEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HandledMouseEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Help.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Help.cs index df847c06401..a152065d375 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Help.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Help.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Globalization; @@ -14,9 +13,9 @@ namespace System.Windows.Forms; public static class Help { #if DEBUG - internal static readonly TraceSwitch WindowsFormsHelpTrace = new TraceSwitch("WindowsFormsHelpTrace", "Debug help system"); + internal static readonly TraceSwitch s_windowsFormsHelpTrace = new("WindowsFormsHelpTrace", "Debug help system"); #else - internal static readonly TraceSwitch? WindowsFormsHelpTrace; + internal static readonly TraceSwitch? s_windowsFormsHelpTrace; #endif private const int HTML10HELP = 2; @@ -66,7 +65,7 @@ public static void ShowHelp(Control? parent, string? url, string? keyword) /// public static void ShowHelp(Control? parent, string? url, HelpNavigator command, object? parameter) { - WindowsFormsHelpTrace.TraceVerbose("Help:: ShowHelp"); + s_windowsFormsHelpTrace.TraceVerbose("Help:: ShowHelp"); switch (GetHelpFileType(url)) { @@ -84,7 +83,7 @@ public static void ShowHelp(Control? parent, string? url, HelpNavigator command, /// public static void ShowHelpIndex(Control? parent, string? url) { - WindowsFormsHelpTrace.TraceVerbose("Help:: ShowHelpIndex"); + s_windowsFormsHelpTrace.TraceVerbose("Help:: ShowHelpIndex"); ShowHelp(parent, url, HelpNavigator.Index, null); } @@ -94,9 +93,9 @@ public static void ShowHelpIndex(Control? parent, string? url) /// public static unsafe void ShowPopup(Control? parent, string caption, Point location) { - WindowsFormsHelpTrace.TraceVerbose("Help:: ShowPopup"); + s_windowsFormsHelpTrace.TraceVerbose("Help:: ShowPopup"); - var pop = new HH_POPUPW + HH_POPUPW pop = new() { cbStruct = sizeof(HH_POPUPW), pt = location, @@ -121,7 +120,7 @@ public static unsafe void ShowPopup(Control? parent, string caption, Point locat /// private static unsafe void ShowHTML10Help(Control? parent, string? url, HelpNavigator command, object? param) { - WindowsFormsHelpTrace.TraceVerbose($"Help:: ShowHTML10Help:: {url}, {command:G}, {param}"); + s_windowsFormsHelpTrace.TraceVerbose($"Help:: ShowHTML10Help:: {url}, {command:G}, {param}"); // See if we can get a full path and file name and if that will // resolve the out of memory condition with file names that include spaces. @@ -168,7 +167,7 @@ private static unsafe void ShowHTML10Help(Control? parent, string? url, HelpNavi } else if (htmlParam is int intParam) { - HtmlHelpW(handle, pathAndFileName, htmlCommand, (IntPtr)intParam); + HtmlHelpW(handle, pathAndFileName, htmlCommand, intParam); } else if (htmlParam is HH_FTS_QUERYW query) { @@ -215,14 +214,9 @@ private static unsafe void ShowHTML10Help(Control? parent, string? url, HelpNavi /// private static void ShowHTMLFile(Control? parent, string? url, HelpNavigator command, object? param) { - WindowsFormsHelpTrace.TraceVerbose($"Help:: ShowHTMLHelp:: {url}, {command:G}, {param}"); + s_windowsFormsHelpTrace.TraceVerbose($"Help:: ShowHTMLHelp:: {url}, {command:G}, {param}"); - Uri? file = Resolve(url); - - if (file is null) - { - throw new ArgumentException(string.Format(SR.HelpInvalidURL, url), nameof(url)); - } + Uri? file = Resolve(url) ?? throw new ArgumentException(string.Format(SR.HelpInvalidURL, url), nameof(url)); switch (command) { @@ -241,24 +235,32 @@ private static void ShowHTMLFile(Control? parent, string? url, HelpNavigator com break; } - HandleRef handle; - if (parent is not null) - { - handle = new(parent); - } - else + HandleRef handle = parent is not null ? new(parent) : Control.GetHandleRef(PInvoke.GetActiveWindow()); + s_windowsFormsHelpTrace.TraceVerbose($"\tExecuting '{file}'"); + string fileName = file.ToString(); + string? executable = file.IsFile ? FindExecutableInternal(file.LocalPath.ToString()) : null; + PInvoke.ShellExecute(handle.Handle, lpOperation: null, executable ?? fileName, executable is not null ? fileName : null, lpDirectory: null, SHOW_WINDOW_CMD.SW_NORMAL); + GC.KeepAlive(handle.Wrapper); + } + + private static unsafe string? FindExecutableInternal(string uri) + { + HINSTANCE result; + Span buffer = stackalloc char[PInvoke.MAX_PATH + 1]; + fixed (char* lpFileLocal = uri) { - handle = Control.GetHandleRef(PInvoke.GetActiveWindow()); + fixed (char* b = buffer) + { + result = PInvoke.FindExecutable(lpFileLocal, lpDirectory: null, lpResult: b); + } } - WindowsFormsHelpTrace.TraceVerbose($"\tExecuting '{file}'"); - PInvoke.ShellExecute(handle.Handle, lpOperation: null, file.ToString(), lpParameters: null, lpDirectory: null, SHOW_WINDOW_CMD.SW_NORMAL); - GC.KeepAlive(handle.Wrapper); + return result <= 32 ? null : buffer.SliceAtFirstNull().ToString(); } private static Uri? Resolve(string? partialUri) { - WindowsFormsHelpTrace.TraceVerbose($"Help:: Resolve {partialUri}"); + s_windowsFormsHelpTrace.TraceVerbose($"Help:: Resolve {partialUri}"); Debug.Indent(); Uri? file = null; @@ -278,7 +280,7 @@ private static void ShowHTMLFile(Control? parent, string? url, HelpNavigator com if (file is not null && file.Scheme == "file") { string localPath = file.LocalPath + file.Fragment; - WindowsFormsHelpTrace.TraceVerbose("file, check for existence"); + s_windowsFormsHelpTrace.TraceVerbose("file, check for existence"); if (!File.Exists(localPath)) { @@ -289,7 +291,7 @@ private static void ShowHTMLFile(Control? parent, string? url, HelpNavigator com if (file is null) { - WindowsFormsHelpTrace.TraceVerbose("try AppBase relative"); + s_windowsFormsHelpTrace.TraceVerbose("try AppBase relative"); try { // try relative to AppBase... @@ -304,7 +306,7 @@ private static void ShowHTMLFile(Control? parent, string? url, HelpNavigator com if (file is not null && file.Scheme == "file") { string localPath = file.LocalPath + file.Fragment; - WindowsFormsHelpTrace.TraceVerbose("file, check for existence"); + s_windowsFormsHelpTrace.TraceVerbose("file, check for existence"); if (!File.Exists(localPath)) { // clear - file isn't there... @@ -319,11 +321,11 @@ private static void ShowHTMLFile(Control? parent, string? url, HelpNavigator com private static int GetHelpFileType(string? url) { - WindowsFormsHelpTrace.TraceVerbose("Help:: GetHelpFileType {url}"); + s_windowsFormsHelpTrace.TraceVerbose("Help:: GetHelpFileType {url}"); if (url is null) { - WindowsFormsHelpTrace.TraceVerbose("\tnull, must be Html File"); + s_windowsFormsHelpTrace.TraceVerbose("\tnull, must be Html File"); return HTMLFILE; } @@ -331,17 +333,17 @@ private static int GetHelpFileType(string? url) if (file is null || file.Scheme == "file") { - WindowsFormsHelpTrace.TraceVerbose("\tfile"); + s_windowsFormsHelpTrace.TraceVerbose("\tfile"); string ext = Path.GetExtension(file is null ? url : file.LocalPath + file.Fragment).ToLower(CultureInfo.InvariantCulture); - if (ext == ".chm" || ext == ".col") + if (ext is ".chm" or ".col") { - WindowsFormsHelpTrace.TraceVerbose("\tchm or col, HtmlHelp 1.0 file"); + s_windowsFormsHelpTrace.TraceVerbose("\tchm or col, HtmlHelp 1.0 file"); return HTML10HELP; } } - WindowsFormsHelpTrace.TraceVerbose("\tnot file, or odd extension, but be HTML"); + s_windowsFormsHelpTrace.TraceVerbose("\tnot file, or odd extension, but be HTML"); return HTMLFILE; } @@ -370,7 +372,7 @@ private static unsafe HH MapCommandToHTMLCommand(HelpNavigator command, string? case HelpNavigator.Find: { - var ftsQuery = new HH_FTS_QUERYW + HH_FTS_QUERYW ftsQuery = new() { cbStruct = sizeof(HH_FTS_QUERYW), iProximity = HH_FTS_QUERYW.DEFAULT_PROXIMITY, @@ -396,7 +398,7 @@ private static unsafe HH MapCommandToHTMLCommand(HelpNavigator command, string? case HelpNavigator.KeywordIndex: case HelpNavigator.AssociateIndex: { - var alink = new HH_ALINKW + HH_ALINKW alink = new() { cbStruct = sizeof(HH_ALINKW), fIndexOnFail = true, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HelpEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HelpEventArgs.cs index 068e4a3f374..0bc252340d0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HelpEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HelpEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HelpEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HelpEventHandler.cs index 0e6a007ecda..a95090ea58e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HelpEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HelpEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HelpInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HelpInfo.cs index 357795c1889..98b850d5206 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HelpInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HelpInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HelpNavigator.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HelpNavigator.cs index b51eb7cae21..a76182bb1fd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HelpNavigator.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HelpNavigator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HelpProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HelpProvider.cs index 0765d42dfda..06a4ba71d5b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HelpProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HelpProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; @@ -123,7 +122,7 @@ private void OnControlHelp(object? sender, HelpEventArgs hevent) if (Control.MouseButtons != MouseButtons.None && !string.IsNullOrEmpty(helpString)) { - Help.WindowsFormsHelpTrace.TraceVerbose("HelpProvider:: Mouse down w/ helpstring"); + Help.s_windowsFormsHelpTrace.TraceVerbose("HelpProvider:: Mouse down w/ helpstring"); Help.ShowPopup(ctl, helpString, hevent.MousePos); hevent.Handled = true; return; @@ -132,7 +131,7 @@ private void OnControlHelp(object? sender, HelpEventArgs hevent) // If we have a help file, and help keyword we try F1 help next if (HelpNamespace is not null) { - Help.WindowsFormsHelpTrace.TraceVerbose("HelpProvider:: F1 help"); + Help.s_windowsFormsHelpTrace.TraceVerbose("HelpProvider:: F1 help"); if (!string.IsNullOrEmpty(keyword)) { Help.ShowHelp(ctl, HelpNamespace, navigator, keyword); @@ -149,7 +148,7 @@ private void OnControlHelp(object? sender, HelpEventArgs hevent) // So at this point we don't have a help keyword, so try to display the whats this help if (!string.IsNullOrEmpty(helpString)) { - Help.WindowsFormsHelpTrace.TraceVerbose("HelpProvider:: back to helpstring"); + Help.s_windowsFormsHelpTrace.TraceVerbose("HelpProvider:: back to helpstring"); Help.ShowPopup(ctl, helpString, hevent.MousePos); hevent.Handled = true; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HitArea.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HitArea.cs index 99a8afc8280..2de27ec65ea 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HitArea.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HitArea.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HorizontalAlignment.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HorizontalAlignment.cs index 4d5cb034cd4..0b41fe2fcb7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HorizontalAlignment.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HorizontalAlignment.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlDocument.HTMLDocumentEvents2.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlDocument.HTMLDocumentEvents2.cs index 87505de8532..243e39e68c3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlDocument.HTMLDocumentEvents2.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlDocument.HTMLDocumentEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop.Mshtml; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlDocument.HtmlDocumentShim.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlDocument.HtmlDocumentShim.cs index 824112a54b9..6cece2129ba 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlDocument.HtmlDocumentShim.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlDocument.HtmlDocumentShim.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop.Mshtml; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlDocument.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlDocument.cs index f831d21b8f7..66cb035ef7d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlDocument.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlDocument.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElement.HTMLElementEvents2.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElement.HTMLElementEvents2.cs index 0a7295d851c..5362f24ea2a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElement.HTMLElementEvents2.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElement.HTMLElementEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElement.HtmlElementShim.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElement.HtmlElementShim.cs index 57a767be8fb..f4b76810634 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElement.HtmlElementShim.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElement.HtmlElementShim.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop.Mshtml; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElement.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElement.cs index 706b0929a29..dcf31c6995f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElement.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElement.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementCollection.cs index db7472f3ff8..fbb7b2fc182 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using static Interop.Mshtml; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementErrorEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementErrorEventArgs.cs index d625ece6569..96c7fcb7e0c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementErrorEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementErrorEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementErrorEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementErrorEventHandler.cs index 0f3c1f34df3..b51ad6f0b2c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementErrorEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementErrorEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementEventArgs.cs index 9877255cbf6..a8c24dec627 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -49,17 +48,17 @@ public MouseButtons MouseButtonsPressed public Point ClientMousePosition { - get => new Point(NativeHTMLEventObj.GetClientX(), NativeHTMLEventObj.GetClientY()); + get => new(NativeHTMLEventObj.GetClientX(), NativeHTMLEventObj.GetClientY()); } public Point OffsetMousePosition { - get => new Point(NativeHTMLEventObj.GetOffsetX(), NativeHTMLEventObj.GetOffsetY()); + get => new(NativeHTMLEventObj.GetOffsetX(), NativeHTMLEventObj.GetOffsetY()); } public Point MousePosition { - get => new Point(NativeHTMLEventObj.GetX(), NativeHTMLEventObj.GetY()); + get => new(NativeHTMLEventObj.GetX(), NativeHTMLEventObj.GetY()); } public bool BubbleEvent diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementEventHandler.cs index c232fd64472..a2758e1697b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementInsertionOrientation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementInsertionOrientation.cs index f9814ff481f..caa0957caad 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementInsertionOrientation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementInsertionOrientation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlHistory.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlHistory.cs index ca8f617af61..1d8a63be2cb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlHistory.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlHistory.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.Mshtml; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlShim.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlShim.cs index 8748e7bf376..ea1f3f4ddb7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlShim.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlShim.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using static Interop.Mshtml; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlShimManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlShimManager.cs index 0938836ac6a..c15f5efe8e4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlShimManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlShimManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlToClrEventProxy.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlToClrEventProxy.cs index 2436bddaeaf..b2adce8e95d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlToClrEventProxy.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlToClrEventProxy.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; using System.Reflection; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindow.HTMLWindowEvents2.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindow.HTMLWindowEvents2.cs index af73ffedc07..7967dc277c4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindow.HTMLWindowEvents2.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindow.HTMLWindowEvents2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop.Mshtml; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindow.HtmlWindowShim.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindow.HtmlWindowShim.cs index f3ea0322e02..49217f7286f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindow.HtmlWindowShim.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindow.HtmlWindowShim.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop.Mshtml; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindow.cs index 94325a30b8a..e7b9c8e45fa 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindowCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindowCollection.cs index bcc8dbcfa24..4008911dab2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindowCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlWindowCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/IBindableComponent.cs b/src/System.Windows.Forms/src/System/Windows/Forms/IBindableComponent.cs index f9f784ffe64..396c38eafb3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/IBindableComponent.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/IBindableComponent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/IButtonControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/IButtonControl.cs index 15e55162a88..d40b37ccb59 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/IButtonControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/IButtonControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ICommandBindingTargetProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ICommandBindingTargetProvider.cs index b611988b5ed..c1fca8552bd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ICommandBindingTargetProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ICommandBindingTargetProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Input; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ICommandExecutor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ICommandExecutor.cs index ca59a6f9436..4aa81067df5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ICommandExecutor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ICommandExecutor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/IComponentEditorPageSite.cs b/src/System.Windows.Forms/src/System/Windows/Forms/IComponentEditorPageSite.cs index d62e4f83fe0..9edc749deca 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/IComponentEditorPageSite.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/IComponentEditorPageSite.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/IContainerControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/IContainerControl.cs index e91e2e0c451..bda3c2ab706 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/IContainerControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/IContainerControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ICurrencyManagerProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ICurrencyManagerProvider.cs index 8e06944ef47..23b8da01f10 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ICurrencyManagerProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ICurrencyManagerProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/IDataGridColumnStyleEditingNotificationService.cs b/src/System.Windows.Forms/src/System/Windows/Forms/IDataGridColumnStyleEditingNotificationService.cs index 1f5e4c7a7ef..7940f574b4b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/IDataGridColumnStyleEditingNotificationService.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/IDataGridColumnStyleEditingNotificationService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/IDataObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/IDataObject.cs index 361dc100629..4625685393c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/IDataObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/IDataObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/IFeatureSupport.cs b/src/System.Windows.Forms/src/System/Windows/Forms/IFeatureSupport.cs index 6e41d2b98ab..677378594cb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/IFeatureSupport.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/IFeatureSupport.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/IFileReaderService.cs b/src/System.Windows.Forms/src/System/Windows/Forms/IFileReaderService.cs index 8381e7c625c..2d96c17fc2f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/IFileReaderService.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/IFileReaderService.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/IKeyboardToolTip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/IKeyboardToolTip.cs index 3b030abb11e..4a74e5cde0b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/IKeyboardToolTip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/IKeyboardToolTip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/IMEMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/IMEMode.cs index 393eb85f0ff..c985ad7f288 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/IMEMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/IMEMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/IMessageFilter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/IMessageFilter.cs index 5c77b762aca..8fa34548e19 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/IMessageFilter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/IMessageFilter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/IMessageModifyAndFilter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/IMessageModifyAndFilter.cs index 3df3f32493c..a3c5b174ad7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/IMessageModifyAndFilter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/IMessageModifyAndFilter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/IOwnedObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/IOwnedObject.cs index b7ab1b32c28..7f3a92e5968 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/IOwnedObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/IOwnedObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ISupportOleDropSource.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ISupportOleDropSource.cs index 3782c1b61b2..0a45e623374 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ISupportOleDropSource.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ISupportOleDropSource.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ISupportOleDropTarget.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ISupportOleDropTarget.cs index 53a14e1b95a..65325871035 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ISupportOleDropTarget.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ISupportOleDropTarget.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ISupportToolStripPanel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ISupportToolStripPanel.cs index 4e588463116..0d67fb04ad6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ISupportToolStripPanel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ISupportToolStripPanel.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/IWin32window.cs b/src/System.Windows.Forms/src/System/Windows/Forms/IWin32window.cs index 464def88c27..8ccee05bb2d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/IWin32window.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/IWin32window.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/IWindowTarget.cs b/src/System.Windows.Forms/src/System/Windows/Forms/IWindowTarget.cs index 69ede077ce4..323cb83d156 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/IWindowTarget.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/IWindowTarget.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageIndexConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageIndexConverter.cs index edeaf9f01e8..4889b6b27b5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageIndexConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageIndexConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageKeyConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageKeyConverter.cs index 6ee9c523917..3690e222ff0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageKeyConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageKeyConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageLayout.cs index b3798d30229..0669a585f58 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageLayout.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.ImageInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.ImageInfo.cs index b0836672e70..d9b7c9f1921 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.ImageInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.ImageInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.cs index ea1cdc5d4ce..e1f9d310f1c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Collections.Specialized; @@ -18,7 +17,7 @@ public sealed partial class ImageList public sealed partial class ImageCollection : IList { private readonly ImageList _owner; - private readonly List _imageInfoCollection = new List(); + private readonly List _imageInfoCollection = new(); /// A caching mechanism for key accessor /// We use an index here rather than control so that we don't have lifetime @@ -235,13 +234,13 @@ public void Add(string key, Image image) Debug.Assert((Count == _imageInfoCollection.Count), "The count of these two collections should be equal."); // Store off the name. - var imageInfo = new ImageInfo + ImageInfo imageInfo = new() { Name = key }; // Add the image to the IList - var original = new Original(image, OriginalOptions.Default); + Original original = new(image, OriginalOptions.Default); Add(original, imageInfo); } @@ -253,13 +252,13 @@ public void Add(string key, Icon icon) Debug.Assert((Count == _imageInfoCollection.Count), "The count of these two collections should be equal."); // Store off the name. - var imageInfo = new ImageInfo + ImageInfo imageInfo = new() { Name = key }; // Add the image to the IList - var original = new Original(icon, OriginalOptions.Default); + Original original = new(icon, OriginalOptions.Default); Add(original, imageInfo); } @@ -289,7 +288,7 @@ public void Add(Image value) { ArgumentNullException.ThrowIfNull(value); - var original = new Original(value, OriginalOptions.Default); + Original original = new(value, OriginalOptions.Default); Add(original, null); } @@ -302,7 +301,7 @@ public int Add(Image value, Color transparentColor) { ArgumentNullException.ThrowIfNull(value); - var original = new Original(value, OriginalOptions.CustomTransparentColor, transparentColor); + Original original = new(value, OriginalOptions.CustomTransparentColor, transparentColor); return Add(original, null); } @@ -374,7 +373,7 @@ private int Add(Original original, ImageInfo? imageInfo) return index; } - public void AddRange(Image[] images) + public void AddRange(params Image[] images) { ArgumentNullException.ThrowIfNull(images); @@ -409,7 +408,7 @@ public int AddStrip(Image value) int nImages = value.Width / _owner.ImageSize.Width; - var original = new Original(value, OriginalOptions.ImageStrip, nImages); + Original original = new(value, OriginalOptions.ImageStrip, nImages); return Add(original, null); } @@ -437,7 +436,7 @@ public void Clear() bool IList.Contains(object? value) { - if (!(value is Image image)) + if (value is not Image image) { return false; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.Indexer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.Indexer.cs index 995d64d1442..b08571d4640 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.Indexer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.Indexer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.NativeImageList.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.NativeImageList.cs index d503c9858d1..ebd0b7fffa3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.NativeImageList.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.NativeImageList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using Windows.Win32.System.Com; @@ -17,7 +16,7 @@ internal class NativeImageList : IDisposable, IHandle private const int GrowBy = 4; private const int InitialCapacity = 4; - private static readonly object s_syncLock = new object(); + private static readonly object s_syncLock = new(); public unsafe NativeImageList(IStream.Interface pstm) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.Original.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.Original.cs index 079d7971f00..6538b912ba8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.Original.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.Original.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.OriginalOptions.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.OriginalOptions.cs index 1a1ae2dcedc..bd613ba84c4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.OriginalOptions.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.OriginalOptions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs index b0a8d1cb637..f89bde8f0e1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; @@ -26,7 +25,7 @@ namespace System.Windows.Forms; public sealed partial class ImageList : Component, IHandle { private static readonly Color s_fakeTransparencyColor = Color.FromArgb(0x0d, 0x0b, 0x0c); - private static readonly Size s_defaultImageSize = new Size(16, 16); + private static readonly Size s_defaultImageSize = new(16, 16); private const int MaxDimension = 256; private static int s_maxImageWidth = MaxDimension; @@ -44,7 +43,7 @@ public sealed partial class ImageList : Component, IHandle // lists are lossy. At runtime, we delay handle creation as long as possible, and store // away the original images until handle creation (and hope no one disposes of the images!). At design time, we keep the originals around indefinitely. // This variable will become null when the original images are lost. - private List? _originals = new List(); + private List? _originals = new(); private EventHandler? _recreateHandler; private EventHandler? _changeHandler; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageListConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageListConverter.cs index be77f5e5bd8..38130dacb2d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageListConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageListConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageListStreamer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageListStreamer.cs index eb4c6cdc6e3..8cff97c32cc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageListStreamer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageListStreamer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.Serialization; using static Interop; @@ -12,7 +11,7 @@ public sealed class ImageListStreamer : ISerializable, IDisposable { // Compressed magic header. If we see this, the image stream is compressed. private static ReadOnlySpan HeaderMagic => "MSFt"u8; - private static readonly object s_syncObject = new object(); + private static readonly object s_syncObject = new(); private readonly ImageList? _imageList; private ImageList.NativeImageList? _nativeImageList; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguage.cs b/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguage.cs index 8f92db7d831..c1a6dda565a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguage.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguage.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; using Microsoft.Win32; @@ -27,7 +26,7 @@ internal InputLanguage(IntPtr handle) /// /// Returns the culture of the current input language. /// - public CultureInfo Culture => new CultureInfo(LanguageTag); + public CultureInfo Culture => new(LanguageTag); /// /// Gets or sets the input language for the current thread. @@ -236,7 +235,7 @@ internal static InputLanguageChangedEventArgs CreateInputLanguageChangedEventArg /// internal static InputLanguageChangingEventArgs CreateInputLanguageChangingEventArgs(Message m) { - var inputLanguage = new InputLanguage(m.LParamInternal); + InputLanguage inputLanguage = new(m.LParamInternal); // NOTE: by default we should allow any locale switch bool localeSupportedBySystem = m.WParamInternal != 0u; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangedEventArgs.cs index ea07a1c7ea9..8eb5054d9a2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangedEventHandler.cs index b3133e198a5..7b8ba87af76 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangingEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangingEventArgs.cs index 5ef594afa44..7d871b00e3c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangingEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangingEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangingEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangingEventHandler.cs index 05bdc48b4fd..91446827b2a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangingEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageChangingEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageCollection.cs index fcedf06cb2f..ba7b72b56d8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguageCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/InsertKeyMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/InsertKeyMode.cs index 270661d299b..96b2093c1d4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/InsertKeyMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/InsertKeyMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/DrawingEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/DrawingEventArgs.cs index 6b457b0fc86..debf06f52d1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/DrawingEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/DrawingEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/DrawingEventFlags.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/DrawingEventFlags.cs index 77934d579a4..28005ae2fce 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/DrawingEventFlags.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/DrawingEventFlags.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.Data.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.Data.cs index 3d4e1f73ce9..58efeb63714 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.Data.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.Data.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.FontCacheEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.FontCacheEntry.cs index 8849c5ca91a..73d99c7e50d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.FontCacheEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.FontCacheEntry.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.cs index d6c0be0f057..3f96c55411d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; @@ -22,7 +21,7 @@ namespace System.Windows.Forms; /// internal sealed partial class FontCache : RefCountedCache { - private readonly object _lock = new object(); + private readonly object _lock = new(); /// /// Create a with the specified collection limits. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/GdiCache.ScreenGraphicsScope.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/GdiCache.ScreenGraphicsScope.cs index 9f7ad1fcd5e..38f19801fe2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/GdiCache.ScreenGraphicsScope.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/GdiCache.ScreenGraphicsScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/GdiCache.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/GdiCache.cs index 74d1f22a123..4db197a86f3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/GdiCache.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/GdiCache.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; @@ -14,7 +13,7 @@ internal static partial class GdiCache [ThreadStatic] private static ScreenDcCache? s_dcCache; - private static readonly FontCache s_fontCache = new FontCache(); + private static readonly FontCache s_fontCache = new(); /// /// Gets an based off of the primary display. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/ScreenDcCache.ScreenDcScope.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/ScreenDcCache.ScreenDcScope.cs index c44a16f36bf..ce8a96aba76 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/ScreenDcCache.ScreenDcScope.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/ScreenDcCache.ScreenDcScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/ScreenDcCache.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/ScreenDcCache.cs index f315abe4466..dffdea0df59 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/ScreenDcCache.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/ScreenDcCache.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Numerics; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/WinFormsMetadataUpdateHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/WinFormsMetadataUpdateHandler.cs index 97211c86f9f..ec327dee3f3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/WinFormsMetadataUpdateHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/WinFormsMetadataUpdateHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Reflection.Metadata; using System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/InvalidateEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/InvalidateEventArgs.cs index d338c49b661..1b9339b4c42 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/InvalidateEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/InvalidateEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/InvalidateEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/InvalidateEventHandler.cs index 564ffc03905..a404db75fc2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/InvalidateEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/InvalidateEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ItemActivation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ItemActivation.cs index 89b7de5acc9..15fb7854ddc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ItemActivation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ItemActivation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ItemArray.Entry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ItemArray.Entry.cs index 38709830022..e1316fca78d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ItemArray.Entry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ItemArray.Entry.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ItemArray.EntryEnumerator.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ItemArray.EntryEnumerator.cs index e3c62d69579..cc63e14b9e4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ItemArray.EntryEnumerator.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ItemArray.EntryEnumerator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ItemArray.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ItemArray.cs index 6e38516e2ea..ce9ca42b668 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ItemArray.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ItemArray.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ItemBoundsPortion.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ItemBoundsPortion.cs index ee9abe9dd34..2f6e55b5b68 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ItemBoundsPortion.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ItemBoundsPortion.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ItemChangedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ItemChangedEventArgs.cs index c369494ead4..d3523b8b819 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ItemChangedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ItemChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ItemChangedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ItemChangedEventHandler.cs index 9557ed03fbd..4904aed9e01 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ItemChangedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ItemChangedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckEventArgs.cs index 1af8b839aff..43152b4ea00 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckEventHandler.cs index 6a35a32d95b..9510526ebe3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckedEventArgs.cs index 8a15abd07c8..6524812c6ef 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckedEventHandler.cs index 7c5f0a7fa5d..7a9ae59b23d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ItemCheckedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ItemDragEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ItemDragEventArgs.cs index 3d9404983c8..11efeaf0cc6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ItemDragEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ItemDragEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ItemDragEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ItemDragEventHandler.cs index e55ab89a191..4e5b0d393b0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ItemDragEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ItemDragEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/KeyEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/KeyEventArgs.cs index 551353332f1..9b1d29e354e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/KeyEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/KeyEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/KeyEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/KeyEventHandler.cs index c104a03edaf..cd33e7ad270 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/KeyEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/KeyEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/KeyPressEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/KeyPressEventArgs.cs index b65ffc946f3..44378d9d71e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/KeyPressEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/KeyPressEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/KeyPressEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/KeyPressEventHandler.cs index feb5cacf9b3..5b2b19a3292 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/KeyPressEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/KeyPressEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.InternalStateMachineTimer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.InternalStateMachineTimer.cs index f0c23612f10..c514e0e19ee 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.InternalStateMachineTimer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.InternalStateMachineTimer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.SmEvent.cs b/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.SmEvent.cs index cf01f9d6a90..3225b03a759 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.SmEvent.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.SmEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.SmState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.SmState.cs index f598896dcc3..0524bc87ba5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.SmState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.SmState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.ToolToTipDictionary.cs b/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.ToolToTipDictionary.cs index fc00f33c537..a7c86f608ab 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.ToolToTipDictionary.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.ToolToTipDictionary.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.cs b/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.cs index e1be7565c81..794471364e6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/KeyboardToolTipStateMachine.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Keys.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Keys.cs index 55cdcbd5016..8fc584ad8dc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Keys.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Keys.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/KeysConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/KeysConverter.cs index 019500d6e16..da485491982 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/KeysConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/KeysConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -30,13 +29,13 @@ private void Initialize() private void AddLocalizedKeyNames(CultureInfo cultureInfo) { - if (CultureToDisplayOrder.ContainsKey(cultureInfo) && CultureToDisplayOrder.ContainsKey(cultureInfo)) + if (CultureToDisplayOrder.ContainsKey(cultureInfo) && CultureToKeyName.ContainsKey(cultureInfo)) { return; } - var localizedOrder = new List(34); - var localizedNames = new Dictionary(34); + List localizedOrder = new(34); + Dictionary localizedNames = new(34); AddLocalizedKey(nameof(SR.toStringEnter), Keys.Return); AddKey("F12", Keys.F12); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Label.LabelAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Label.LabelAccessibleObject.cs index da56be83e2d..a292f7e80c4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Label.LabelAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Label.LabelAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Label.LabelImageIndexer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Label.LabelImageIndexer.cs index 863af89b7c5..a85c10257a7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Label.LabelImageIndexer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Label.LabelImageIndexer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Label.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Label.cs index dbe5456d69b..955d43a80b2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Label.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Label.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -305,13 +304,13 @@ protected override CreateParams CreateParams protected override ImeMode DefaultImeMode => ImeMode.Disable; - protected override Padding DefaultMargin => new Padding(3, 0, 3, 0); + protected override Padding DefaultMargin => new(3, 0, 3, 0); /// /// Deriving classes can override this to configure a default size for their control. /// This is more efficient than setting the size in the control's constructor. /// - protected override Size DefaultSize => new Size(100, AutoSize ? PreferredHeight : 23); + protected override Size DefaultSize => new(100, AutoSize ? PreferredHeight : 23); [SRCategory(nameof(SR.CatAppearance))] [DefaultValue(FlatStyle.Standard)] @@ -1280,7 +1279,7 @@ protected override void OnPaint(PaintEventArgs e) } Color color; - using (var hdc = new DeviceContextHdcScope(e)) + using (DeviceContextHdcScope hdc = new(e)) { color = hdc.FindNearestColor(Enabled ? ForeColor : DisabledColor); } @@ -1373,7 +1372,7 @@ private protected override void PrintToMetaFileRecursive(HDC hDC, IntPtr lParam, { base.PrintToMetaFileRecursive(hDC, lParam, bounds); - using var mapping = new DCMapping(hDC, bounds); + using DCMapping mapping = new(hDC, bounds); using Graphics g = hDC.CreateGraphics(); ControlPaint.PrintBorder(g, new Rectangle(Point.Empty, Size), BorderStyle, Border3DStyle.SunkenOuter); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LabelEditEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LabelEditEventArgs.cs index 1120ca7da8f..40597ba7c9e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LabelEditEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LabelEditEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LabelEditEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LabelEditEventHandler.cs index b722c8c4235..82000ce8e18 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LabelEditEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LabelEditEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/ArrangedElementCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/ArrangedElementCollection.cs index 5eca446eedc..537eecb4c1f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/ArrangedElementCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/ArrangedElementCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; @@ -8,7 +7,7 @@ namespace System.Windows.Forms.Layout; public class ArrangedElementCollection : IList { - internal static ArrangedElementCollection Empty = new ArrangedElementCollection(0); + internal static ArrangedElementCollection Empty = new(0); internal ArrangedElementCollection() : this(4) @@ -49,7 +48,7 @@ public override bool Equals(object? obj) public override int GetHashCode() { - var hash = default(HashCode); + HashCode hash = default; foreach (object o in InnerList) { hash.Add(o); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.DockAnchorMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.DockAnchorMode.cs index 8e37b7916f0..d71338339c3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.DockAnchorMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.DockAnchorMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.cs index b2daddb5f22..9da6b236f79 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; #if DEBUG @@ -38,9 +37,9 @@ internal partial class CommonProperties internal const bool DefaultAutoSize = false; internal const DockStyle DefaultDock = DockStyle.None; - internal static readonly Padding DefaultMargin = new Padding(3); - internal static readonly Size DefaultMinimumSize = new Size(0, 0); - internal static readonly Size DefaultMaximumSize = new Size(0, 0); + internal static readonly Padding DefaultMargin = new(3); + internal static readonly Size DefaultMinimumSize = new(0, 0); + internal static readonly Size DefaultMaximumSize = new(0, 0); // DO NOT MOVE THE FOLLOWING 4 SECTIONS // We have done some special arranging here so that if the first 7 bits of state are zero, we know @@ -721,7 +720,7 @@ internal static void SetLayoutState(IArrangedElement element, BitVector32 state) #region DebugHelpers #if DEBUG - internal static readonly TraceSwitch PreferredSize = new TraceSwitch("PreferredSize", "Debug preferred size assertion"); + internal static readonly TraceSwitch PreferredSize = new("PreferredSize", "Debug preferred size assertion"); internal static string Debug_GetChangedProperties(IArrangedElement element) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.AnchorInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.AnchorInfo.cs index 9e5252bee5f..3ce6cd8c7eb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.AnchorInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.AnchorInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.GrowthDirection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.GrowthDirection.cs index f1a7f3e79dd..c4293f6c9c4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.GrowthDirection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.GrowthDirection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs index 83de206c8f8..99966ff8f27 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Collections; using System.Collections.Specialized; @@ -15,7 +12,7 @@ namespace System.Windows.Forms.Layout; internal partial class DefaultLayout : LayoutEngine { - internal static readonly DefaultLayout Instance = new DefaultLayout(); + internal static readonly DefaultLayout Instance = new(); private static readonly int s_layoutInfoProperty = PropertyStore.CreateKey(); private static readonly int s_cachedBoundsProperty = PropertyStore.CreateKey(); @@ -176,7 +173,7 @@ private static Rectangle ComputeAnchoredBoundsV2(IArrangedElement element, Recta return bounds; } - AnchorInfo anchorInfo = GetAnchorInfo(element); + AnchorInfo? anchorInfo = GetAnchorInfo(element); if (anchorInfo is null) { return bounds; @@ -249,7 +246,7 @@ private static Rectangle ComputeAnchoredBoundsV2(IArrangedElement element, Recta private static Rectangle ComputeAnchoredBounds(IArrangedElement element, Rectangle displayRect, bool measureOnly) { - AnchorInfo layout = GetAnchorInfo(element); + AnchorInfo layout = GetAnchorInfo(element)!; int left = layout.Left + displayRect.X; int top = layout.Top + displayRect.Y; @@ -406,7 +403,7 @@ private static Size LayoutDockedControls(IArrangedElement container, bool measur Rectangle remainingBounds = measureOnly ? Rectangle.Empty : container.DisplayRectangle; Size preferredSize = Size.Empty; - IArrangedElement mdiClient = null; + IArrangedElement? mdiClient = null; // Docking layout is order dependent. After much debate, we decided to use z-order as the // docking order. (Introducing a DockOrder property was a close second) @@ -543,7 +540,7 @@ private static void TryCalculatePreferredSizeDockedControl(IArrangedElement elem element.SetBounds(newElementBounds, BoundsSpecified.None); #if DEBUG - Control control = element as Control; + Control control = (Control)element; newElementBounds.Size = control.ApplySizeConstraints(newElementBounds.Size); // This usually happens when a Control overrides its SetBoundsCore or sets size during OnResize @@ -756,7 +753,7 @@ private static void UpdateAnchorInfo(IArrangedElement element) return; } - AnchorInfo anchorInfo = GetAnchorInfo(element); + AnchorInfo? anchorInfo = GetAnchorInfo(element); if (anchorInfo is null) { anchorInfo = new AnchorInfo(); @@ -868,7 +865,7 @@ internal static void UpdateAnchorInfoV2(Control control) } Debug.Assert(LocalAppContextSwitches.AnchorLayoutV2, $"AnchorLayoutV2 should be called only when {LocalAppContextSwitches.AnchorLayoutV2SwitchName} is enabled."); - Control parent = control.Parent; + Control? parent = control.Parent; // Check if control is ready for anchors calculation. if (parent is null) @@ -876,7 +873,7 @@ internal static void UpdateAnchorInfoV2(Control control) return; } - AnchorInfo anchorInfo = GetAnchorInfo(control); + AnchorInfo? anchorInfo = GetAnchorInfo(control); // AnchorsInfo is not computed yet. Check if control is ready for AnchorInfo calculation at this time. if (anchorInfo is null) @@ -910,7 +907,7 @@ internal static void UpdateAnchorInfoV2(Control control) // Reset parent flag as we now ready to iterate over all children requiring AnchorInfo calculation. parent._childControlsNeedAnchorLayout = false; - Rectangle displayRectangle = control.Parent.DisplayRectangle; + Rectangle displayRectangle = control.Parent!.DisplayRectangle; Rectangle elementBounds = GetCachedBounds(control); int x = elementBounds.X; int y = elementBounds.Y; @@ -944,7 +941,7 @@ public static void SetAnchor(IArrangedElement element, AnchorStyles value) } else { - SetAnchorInfo(element, null); + SetAnchorInfo(element, value: null); } if (element.Container is not null) @@ -1008,7 +1005,7 @@ public static void SetDock(IArrangedElement element, DockStyle value) public static void ScaleAnchorInfo(IArrangedElement element, SizeF factor) { - AnchorInfo anchorInfo = GetAnchorInfo(element); + AnchorInfo? anchorInfo = GetAnchorInfo(element); // some controls don't have AnchorInfo, i.e. Panels if (anchorInfo is not null) @@ -1018,10 +1015,10 @@ public static void ScaleAnchorInfo(IArrangedElement element, SizeF factor) if (UseAnchorLayoutV2(element)) { - // AutoScaleFactor is not alligned with Window's SuggestedRectangle applied on top-level window/Form. + // AutoScaleFactor is not aligned with Window's SuggestedRectangle applied on top-level window/Form. // So, compute factor with respect to the change in DisplayRectangle and apply it to scale anchors. // See https://github.com/dotnet/winforms/issues/8266 for more information. - Rectangle displayRect = element.Container.DisplayRectangle; + Rectangle displayRect = element.Container!.DisplayRectangle; heightFactor = ((double)displayRect.Height) / anchorInfo.DisplayRectangle.Height; widthFactor = ((double)displayRect.Width) / anchorInfo.DisplayRectangle.Width; anchorInfo.DisplayRectangle = displayRect; @@ -1040,10 +1037,10 @@ private static Rectangle GetCachedBounds(IArrangedElement element) { if (element.Container is not null) { - IDictionary dictionary = (IDictionary)element.Container.Properties.GetObject(s_cachedBoundsProperty); + IDictionary? dictionary = (IDictionary?)element.Container.Properties.GetObject(s_cachedBoundsProperty); if (dictionary is not null) { - object bounds = dictionary[element]; + object? bounds = dictionary[element]; if (bounds is not null) { return (Rectangle)bounds; @@ -1054,7 +1051,7 @@ private static Rectangle GetCachedBounds(IArrangedElement element) return element.Bounds; } - private static bool HasCachedBounds(IArrangedElement container) + private static bool HasCachedBounds(IArrangedElement? container) { return container is not null && container.Properties.ContainsObjectThatIsNotNull(s_cachedBoundsProperty); } @@ -1072,7 +1069,7 @@ private static void ApplyCachedBounds(IArrangedElement container) } } - IDictionary dictionary = (IDictionary)container.Properties.GetObject(s_cachedBoundsProperty); + IDictionary? dictionary = (IDictionary?)container.Properties.GetObject(s_cachedBoundsProperty); if (dictionary is not null) { #if DEBUG @@ -1093,7 +1090,7 @@ private static void ApplyCachedBounds(IArrangedElement container) // and will callback InitLayout with a different bounds and BoundsSpecified. dictionary.Remove(entry.Key); #endif - Rectangle bounds = (Rectangle)entry.Value; + Rectangle bounds = (Rectangle)entry.Value!; element.SetBounds(bounds, BoundsSpecified.None); #if DEBUG break; @@ -1114,7 +1111,7 @@ private static void SetCachedBounds(IArrangedElement element, Rectangle bounds) { if (bounds != GetCachedBounds(element)) { - IDictionary dictionary = (IDictionary)element.Container.Properties.GetObject(s_cachedBoundsProperty); + IDictionary? dictionary = (IDictionary?)element.Container!.Properties.GetObject(s_cachedBoundsProperty); if (dictionary is null) { dictionary = new HybridDictionary(); @@ -1125,12 +1122,12 @@ private static void SetCachedBounds(IArrangedElement element, Rectangle bounds) } } - internal static AnchorInfo GetAnchorInfo(IArrangedElement element) + internal static AnchorInfo? GetAnchorInfo(IArrangedElement element) { - return (AnchorInfo)element.Properties.GetObject(s_layoutInfoProperty); + return (AnchorInfo?)element.Properties.GetObject(s_layoutInfoProperty); } - internal static void SetAnchorInfo(IArrangedElement element, AnchorInfo value) + internal static void SetAnchorInfo(IArrangedElement element, AnchorInfo? value) { element.Properties.SetObject(s_layoutInfoProperty, value); } @@ -1190,7 +1187,7 @@ private static Size GetAnchorPreferredSize(IArrangedElement container) // the container is, and make sure our container is large enough to accomodate us. if (useV2Layout) { - AnchorInfo anchorInfo = GetAnchorInfo(element); + AnchorInfo? anchorInfo = GetAnchorInfo(element); Rectangle bounds = GetCachedBounds(element); prefSize.Width = Math.Max(prefSize.Width, anchorInfo is null ? bounds.Right : bounds.Right + anchorInfo.Right); } @@ -1210,7 +1207,7 @@ private static Size GetAnchorPreferredSize(IArrangedElement container) Rectangle anchorDest = GetAnchorDestination(element, Rectangle.Empty, measureOnly: true); if (useV2Layout) { - AnchorInfo anchorInfo = GetAnchorInfo(element); + AnchorInfo? anchorInfo = GetAnchorInfo(element); Rectangle bounds = GetCachedBounds(element); prefSize.Height = Math.Max(prefSize.Height, anchorInfo is null ? bounds.Bottom : bounds.Bottom + anchorInfo.Bottom); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.BottomUpProxy.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.BottomUpProxy.cs index 5cbdebeb9af..2fcb026071b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.BottomUpProxy.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.BottomUpProxy.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.ContainerProxy.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.ContainerProxy.cs index dbe622b6487..748e3248661 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.ContainerProxy.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.ContainerProxy.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.ElementProxy.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.ElementProxy.cs index 21711d5b910..b47ce08450a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.ElementProxy.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.ElementProxy.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.RightToLeftProxy.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.RightToLeftProxy.cs index 1eba32512be..25b7af383b4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.RightToLeftProxy.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.RightToLeftProxy.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.TopDownProxy.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.TopDownProxy.cs index c6e0e7d9e76..e27a64c3de1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.TopDownProxy.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.TopDownProxy.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.VerticalElementProxy.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.VerticalElementProxy.cs index 603045621c1..1f9209d411b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.VerticalElementProxy.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.VerticalElementProxy.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.cs index 1ff3aec92ee..d307fddec44 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable #if DEBUG using System.ComponentModel; @@ -13,7 +10,7 @@ namespace System.Windows.Forms.Layout; internal partial class FlowLayout : LayoutEngine { - internal static readonly FlowLayout Instance = new FlowLayout(); + internal static readonly FlowLayout Instance = new(); private static readonly int s_wrapContentsProperty = PropertyStore.CreateKey(); private static readonly int s_flowDirectionProperty = PropertyStore.CreateKey(); @@ -28,7 +25,7 @@ private protected override bool LayoutCore(IArrangedElement container, LayoutEve // ScrollableControl will first try to get the layoutbounds from the derived control when // trying to figure out if ScrollBars should be added. - CommonProperties.SetLayoutBounds(container, TryCalculatePreferredSize(container, container.DisplayRectangle, /* measureOnly = */ false)); + CommonProperties.SetLayoutBounds(container, TryCalculatePreferredSize(container, container.DisplayRectangle, measureOnly: false)); Debug.Unindent(); @@ -45,7 +42,7 @@ internal override Size GetPreferredSize(IArrangedElement container, Size propose } #endif Rectangle measureBounds = new Rectangle(new Point(0, 0), proposedConstraints); - Size prefSize = TryCalculatePreferredSize(container, measureBounds, /* measureOnly = */ true); + Size prefSize = TryCalculatePreferredSize(container, measureBounds, measureOnly: true); if (prefSize.Width > proposedConstraints.Width || prefSize.Height > proposedConstraints.Height) { @@ -53,7 +50,7 @@ internal override Size GetPreferredSize(IArrangedElement container, Size propose // shift around with the new bounds. We need to make a 2nd pass through the // controls using these bounds which are guaranteed to fit. measureBounds.Size = prefSize; - prefSize = TryCalculatePreferredSize(container, measureBounds, /* measureOnly = */ true); + prefSize = TryCalculatePreferredSize(container, measureBounds, measureOnly: true); } #if DEBUG @@ -66,21 +63,14 @@ internal override Size GetPreferredSize(IArrangedElement container, Size propose return prefSize; } - private static ContainerProxy CreateContainerProxy(IArrangedElement container, FlowDirection flowDirection) - { - switch (flowDirection) + private static ContainerProxy CreateContainerProxy(IArrangedElement container, FlowDirection flowDirection) => + flowDirection switch { - case FlowDirection.RightToLeft: - return new RightToLeftProxy(container); - case FlowDirection.TopDown: - return new TopDownProxy(container); - case FlowDirection.BottomUp: - return new BottomUpProxy(container); - case FlowDirection.LeftToRight: - default: - return new ContainerProxy(container); - } - } + FlowDirection.RightToLeft => new RightToLeftProxy(container), + FlowDirection.TopDown => new TopDownProxy(container), + FlowDirection.BottomUp => new BottomUpProxy(container), + _ => new ContainerProxy(container), + }; /// /// Both LayoutCore and GetPreferredSize forward to this method. @@ -147,9 +137,21 @@ private static Size TryCalculatePreferredSize(IArrangedElement container, Rectan /// index. RowBounds was computed by a call to measure row and is used for alignment/boxstretch. /// See the ElementProxy class for an explanation of the elementProxy parameter. /// - private static void LayoutRow(ContainerProxy containerProxy, ElementProxy elementProxy, int startIndex, int endIndex, Rectangle rowBounds) + private static void LayoutRow( + ContainerProxy containerProxy, + ElementProxy elementProxy, + int startIndex, + int endIndex, + Rectangle rowBounds) { - Size outSize = TryCalculatePreferredSizeRow(containerProxy, elementProxy, startIndex, endIndex, rowBounds, /* breakIndex = */ out int dummy, /* measureOnly = */ false); + Size outSize = TryCalculatePreferredSizeRow( + containerProxy, + elementProxy, + startIndex, + endIndex, + rowBounds, + breakIndex: out int dummy, + measureOnly: false); Debug.Assert(dummy == endIndex, "EndIndex / BreakIndex mismatch."); } @@ -159,16 +161,33 @@ private static void LayoutRow(ContainerProxy containerProxy, ElementProxy elemen /// controls from startIndex up to but not including breakIndex. See the ElementProxy /// class for an explanation of the elementProxy parameter. /// - private static Size MeasureRow(ContainerProxy containerProxy, ElementProxy elementProxy, int startIndex, Rectangle displayRectangle, out int breakIndex) - { - return TryCalculatePreferredSizeRow(containerProxy, elementProxy, startIndex, endIndex: containerProxy.Container.Children.Count, rowBounds: displayRectangle, breakIndex: out breakIndex, measureOnly: true); - } + private static Size MeasureRow( + ContainerProxy containerProxy, + ElementProxy elementProxy, + int startIndex, + Rectangle displayRectangle, + out int breakIndex) => + TryCalculatePreferredSizeRow( + containerProxy, + elementProxy, + startIndex, + endIndex: containerProxy.Container.Children.Count, + rowBounds: displayRectangle, + breakIndex: out breakIndex, + measureOnly: true); /// /// LayoutRow and MeasureRow both forward to this method. The measureOnly flag /// determines which behavior we get. /// - private static Size TryCalculatePreferredSizeRow(ContainerProxy containerProxy, ElementProxy elementProxy, int startIndex, int endIndex, Rectangle rowBounds, out int breakIndex, bool measureOnly) + private static Size TryCalculatePreferredSizeRow( + ContainerProxy containerProxy, + ElementProxy elementProxy, + int startIndex, + int endIndex, + Rectangle rowBounds, + out int breakIndex, + bool measureOnly) { Debug.Assert(startIndex < endIndex, "Loop should be in forward Z-order."); Point location = rowBounds.Location; @@ -287,10 +306,8 @@ private static Size TryCalculatePreferredSizeRow(ContainerProxy containerProxy, return rowSize; } - public static bool GetWrapContents(IArrangedElement container) - { - return container.Properties.GetInteger(s_wrapContentsProperty) == 0; - } + public static bool GetWrapContents(IArrangedElement container) => + container.Properties.GetInteger(s_wrapContentsProperty) == 0; public static void SetWrapContents(IArrangedElement container, bool value) { @@ -299,10 +316,8 @@ public static void SetWrapContents(IArrangedElement container, bool value) Debug.Assert(GetWrapContents(container) == value, "GetWrapContents should return the same value as we set"); } - public static FlowDirection GetFlowDirection(IArrangedElement container) - { - return (FlowDirection)container.Properties.GetInteger(s_flowDirectionProperty); - } + public static FlowDirection GetFlowDirection(IArrangedElement container) => + (FlowDirection)container.Properties.GetInteger(s_flowDirectionProperty); public static void SetFlowDirection(IArrangedElement container, FlowDirection value) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/IArrangedElement.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/IArrangedElement.cs index 8c84b5a8065..ae4ab7d0e37 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/IArrangedElement.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/IArrangedElement.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutEngine.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutEngine.cs index 80e9c7ca313..5af864fd652 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutEngine.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutEngine.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutTransaction.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutTransaction.cs index ea55aebb3db..e140fe8fae8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutTransaction.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutTransaction.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutUtils.MeasureTextCache.PreferredSizeCache.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutUtils.MeasureTextCache.PreferredSizeCache.cs index dd17ef5625a..b00e24a3214 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutUtils.MeasureTextCache.PreferredSizeCache.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutUtils.MeasureTextCache.PreferredSizeCache.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutUtils.MeasureTextCache.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutUtils.MeasureTextCache.cs index e471292d1f7..5326e001a52 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutUtils.MeasureTextCache.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutUtils.MeasureTextCache.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutUtils.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutUtils.cs index d757c9b5277..91f85d384ae 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutUtils.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/LayoutUtils.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/NullLayoutTransaction.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/NullLayoutTransaction.cs index 6f3cb4c21af..22213227e3d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/NullLayoutTransaction.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/NullLayoutTransaction.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/PropertyNames.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/PropertyNames.cs index 1111489afe0..058d55488ed 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/PropertyNames.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/PropertyNames.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ColumnSpanComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ColumnSpanComparer.cs index 2fa14a0eb65..f6bec7a14a3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ColumnSpanComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ColumnSpanComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; @@ -8,7 +7,7 @@ internal partial class TableLayout { private class ColumnSpanComparer : SpanComparer { - private static readonly ColumnSpanComparer instance = new ColumnSpanComparer(); + private static readonly ColumnSpanComparer instance = new(); public override int GetSpan(LayoutInfo layoutInfo) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ContainerInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ContainerInfo.cs index dd924699d25..e7b66d86732 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ContainerInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ContainerInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.Drawing; @@ -188,6 +187,7 @@ public TableLayoutPanelGrowStyle GrowStyle } } + [AllowNull] public TableLayoutRowStyleCollection RowStyles { get @@ -203,6 +203,7 @@ public TableLayoutRowStyleCollection RowStyles } } + [AllowNull] public TableLayoutColumnStyleCollection ColumnStyles { get diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.LayoutInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.LayoutInfo.cs index 7d3213f5ab7..370c5e8f1d2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.LayoutInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.LayoutInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; @@ -45,7 +44,7 @@ public LayoutInfo(IArrangedElement element) public int RowSpan { get; set; } = 1; #if DEBUG - public LayoutInfo Clone() => new LayoutInfo(Element) + public LayoutInfo Clone() => new(Element) { RowStart = RowStart, ColumnStart = ColumnStart, @@ -69,7 +68,7 @@ public override bool Equals(object? obj) public override int GetHashCode() { - var hash = default(HashCode); + HashCode hash = default; hash.Add(RowStart); hash.Add(ColumnStart); hash.Add(RowSpan); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MaxSizeProxy.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MaxSizeProxy.cs index 926ffba1f16..ee4c2d5a7b3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MaxSizeProxy.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MaxSizeProxy.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; @@ -8,7 +7,7 @@ internal partial class TableLayout { private class MaxSizeProxy : SizeProxy { - private static readonly MaxSizeProxy instance = new MaxSizeProxy(); + private static readonly MaxSizeProxy instance = new(); public override int Size { get { return strip.MaxSize; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MinSizeProxy.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MinSizeProxy.cs index d1718583a91..103d5bf4643 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MinSizeProxy.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MinSizeProxy.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; @@ -8,7 +7,7 @@ internal partial class TableLayout { private class MinSizeProxy : SizeProxy { - private static readonly MinSizeProxy instance = new MinSizeProxy(); + private static readonly MinSizeProxy instance = new(); public override int Size { get { return strip.MinSize; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PostAssignedPositionComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PostAssignedPositionComparer.cs index 76debff60c5..ff1dda81f0c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PostAssignedPositionComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PostAssignedPositionComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; @@ -8,7 +7,7 @@ internal partial class TableLayout { private class PostAssignedPositionComparer : IComparer { - private static readonly PostAssignedPositionComparer instance = new PostAssignedPositionComparer(); + private static readonly PostAssignedPositionComparer instance = new(); public static PostAssignedPositionComparer GetInstance { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PreAssignedPositionComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PreAssignedPositionComparer.cs index 580bbb66814..467f4ba3cf2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PreAssignedPositionComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PreAssignedPositionComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; @@ -8,7 +7,7 @@ internal partial class TableLayout { private class PreAssignedPositionComparer : IComparer { - private static readonly PreAssignedPositionComparer instance = new PreAssignedPositionComparer(); + private static readonly PreAssignedPositionComparer instance = new(); public static PreAssignedPositionComparer GetInstance { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ReservationGrid.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ReservationGrid.cs index bbe37db6e7a..d2941bfdfb7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ReservationGrid.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ReservationGrid.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.RowSpanComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.RowSpanComparer.cs index 6fd08124005..12c87f25cd2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.RowSpanComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.RowSpanComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; @@ -8,7 +7,7 @@ internal partial class TableLayout { private class RowSpanComparer : SpanComparer { - private static readonly RowSpanComparer instance = new RowSpanComparer(); + private static readonly RowSpanComparer instance = new(); public override int GetSpan(LayoutInfo layoutInfo) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.SizeProxy.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.SizeProxy.cs index 8c618305435..9ddd7b9a915 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.SizeProxy.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.SizeProxy.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.SorterObjectArray.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.SorterObjectArray.cs index 29dafed0a5b..bcf40121c3a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.SorterObjectArray.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.SorterObjectArray.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.SpanComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.SpanComparer.cs index 0e6f8fe7554..fd0f8c25745 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.SpanComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.SpanComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.Strip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.Strip.cs index 5ded548e1e9..f6e2eded41c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.Strip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.Strip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.cs index 637f00fd829..d5da43dec84 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -38,7 +37,7 @@ private static void Sort(LayoutInfo[] array, IComparer comparer) // End of sorting code // Singleton instance shared by all containers. - internal static readonly TableLayout Instance = new TableLayout(); + internal static readonly TableLayout Instance = new(); private static readonly int _containerInfoProperty = PropertyStore.CreateKey(); private static readonly int _layoutInfoProperty = PropertyStore.CreateKey(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LayoutEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LayoutEventArgs.cs index f94ba030aa2..6072ab6e5d7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LayoutEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LayoutEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LayoutEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LayoutEventHandler.cs index d1bec307403..624105863a9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LayoutEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LayoutEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LayoutSettings.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LayoutSettings.cs index 61aa8d47908..26005f59d2b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LayoutSettings.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LayoutSettings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LeftRightAlignment.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LeftRightAlignment.cs index 0383abc4dc8..c4fdf7ba599 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LeftRightAlignment.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LeftRightAlignment.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkArea.LinkAreaConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkArea.LinkAreaConverter.cs index be044dae54b..252507057a5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkArea.LinkAreaConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkArea.LinkAreaConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkArea.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkArea.cs index d88e4239c6c..0a763eff6fe 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkArea.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkArea.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; @@ -23,21 +22,21 @@ public LinkArea(int start, int length) public int Start { - get => start; + readonly get => start; set => start = value; } public int Length { - get => length; + readonly get => length; set => length = value; } [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool IsEmpty => length == start && start == 0; + public readonly bool IsEmpty => length == start && start == 0; - public override bool Equals(object? o) + public override readonly bool Equals(object? o) { if (o is not LinkArea a) { @@ -47,10 +46,10 @@ public override bool Equals(object? o) return Equals(a); } - public bool Equals(LinkArea other) + public readonly bool Equals(LinkArea other) => other.Start == start && other.Length == length; - public override string ToString() => $"{{Start={Start}, Length={Length}}}"; + public override readonly string ToString() => $"{{Start={Start}, Length={Length}}}"; public static bool operator ==(LinkArea linkArea1, LinkArea linkArea2) => linkArea1.Equals(linkArea2); @@ -58,5 +57,5 @@ public bool Equals(LinkArea other) public static bool operator !=(LinkArea linkArea1, LinkArea linkArea2) => !linkArea1.Equals(linkArea2); - public override int GetHashCode() => HashCode.Combine(start, length); + public override readonly int GetHashCode() => HashCode.Combine(start, length); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkBehavior.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkBehavior.cs index e703cd7bc4a..30079257184 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkBehavior.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkBehavior.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkClickedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkClickedEventArgs.cs index 858b5357c95..34d323059d9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkClickedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkClickedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -28,10 +27,10 @@ public LinkClickedEventArgs(string? linkText) : this(linkText, 0, 0) { } /// public LinkClickedEventArgs(string? linkText, int linkStart, int linkLength) { - if (linkStart < 0) - throw new ArgumentOutOfRangeException(nameof(linkStart)); + ArgumentOutOfRangeException.ThrowIfNegative(linkStart); + ArgumentOutOfRangeException.ThrowIfNegative(linkLength); - if (linkLength < 0 || linkStart + linkLength < 0) + if (linkStart + linkLength < 0) throw new ArgumentOutOfRangeException(nameof(linkLength)); LinkText = linkText; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkClickedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkClickedEventHandler.cs index b610a1074b6..953d8259a38 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkClickedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkClickedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkConverter.cs index 13d1ef4d5e1..c435cacd76a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.Link.LinkAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.Link.LinkAccessibleObject.cs index 681a809d343..b9e18063cfa 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.Link.LinkAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.Link.LinkAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.Link.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.Link.cs index 8b3ee55b740..6985903a2d1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.Link.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.Link.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.LinkCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.LinkCollection.cs index c3324bf2714..27bc5981731 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.LinkCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.LinkCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.LinkComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.LinkComparer.cs index d6499dfaa82..c2b59f1fbcc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.LinkComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.LinkComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.LinkLabelAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.LinkLabelAccessibleObject.cs index dd741e2aa18..e933fd128dd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.LinkLabelAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.LinkLabelAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.cs index 1b671607b0d..af81598ebf9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -20,10 +19,10 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionLinkLabel))] public partial class LinkLabel : Label, IButtonControl { - private static readonly object s_eventLinkClicked = new object(); + private static readonly object s_eventLinkClicked = new(); private static Color s_iedisabledLinkColor = Color.Empty; - private static readonly LinkComparer s_linkComparer = new LinkComparer(); + private static readonly LinkComparer s_linkComparer = new(); private DialogResult _dialogResult; @@ -37,7 +36,7 @@ public partial class LinkLabel : Label, IButtonControl private bool _textLayoutValid; private bool _receivedDoubleClick; - private readonly List _links = new List(2); + private readonly List _links = new(2); private Link? _focusLink; private LinkCollection? _linkCollection; @@ -1120,7 +1119,7 @@ protected override void OnPaint(PaintEventArgs e) else { Color foreColor; - using (var scope = new DeviceContextHdcScope(e, applyGraphicsState: false)) + using (DeviceContextHdcScope scope = new(e, applyGraphicsState: false)) { foreColor = scope.HDC.FindNearestColor(DisabledColor); } @@ -1370,7 +1369,7 @@ private void PaintLink( else { Color color; - using (var hdc = new DeviceContextHdcScope(g, applyGraphicsState: false)) + using (DeviceContextHdcScope hdc = new(g, applyGraphicsState: false)) { color = ColorTranslator.FromWin32( (int)PInvoke.GetNearestColor(hdc, (COLORREF)(uint)ColorTranslator.ToWin32(foreBrush.Color)).Value); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabelLinkClickedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabelLinkClickedEventArgs.cs index 34c9e196024..ecaa262d7f0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabelLinkClickedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabelLinkClickedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabelLinkClickedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabelLinkClickedEventHandler.cs index dde4c53978f..8291bb634ae 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabelLinkClickedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabelLinkClickedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkState.cs index 825d8b03087..f0be031151e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkUtilities.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkUtilities.cs index 8cfd7ef5e47..a7c2041a79b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkUtilities.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkUtilities.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LisstView.DisposingContext.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LisstView.DisposingContext.cs index 74bc0847177..c13aff379be 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LisstView.DisposingContext.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LisstView.DisposingContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListBindingConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListBindingConverter.cs index cf98764c1b5..e3de36a67c9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListBindingConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListBindingConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListBindingHelper.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListBindingHelper.cs index 5dd4719f58a..99ff780bca0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListBindingHelper.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListBindingHelper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.AccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.AccessibleObject.cs index 47417b1a68c..acf4007f7bd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.AccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.AccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.IntegerCollection.CustomTabOffsetsEnumerator.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.IntegerCollection.CustomTabOffsetsEnumerator.cs index f61e3162ea5..b176df1073c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.IntegerCollection.CustomTabOffsetsEnumerator.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.IntegerCollection.CustomTabOffsetsEnumerator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.IntegerCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.IntegerCollection.cs index 15a1615aa49..70d59d6975a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.IntegerCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.IntegerCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -159,7 +158,7 @@ int IList.Add(object? item) return Add((int)item); } - public void AddRange(int[] items) + public void AddRange(params int[] items) { AddRangeInternal(items); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.ItemAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.ItemAccessibleObject.cs index 8f6fbefec96..71aded0b3aa 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.ItemAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.ItemAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.ObjectCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.ObjectCollection.cs index c38497902be..a3078674511 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.ObjectCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.ObjectCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -169,7 +168,7 @@ public void AddRange(ObjectCollection value) AddRangeInternal(value); } - public void AddRange(object[] items) + public void AddRange(params object[] items) { ArgumentNullException.ThrowIfNull(items); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.SelectedIndexCollection.SelectedIndexEnumerator.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.SelectedIndexCollection.SelectedIndexEnumerator.cs index af6b44e0f8f..e62658f0239 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.SelectedIndexCollection.SelectedIndexEnumerator.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.SelectedIndexCollection.SelectedIndexEnumerator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.SelectedIndexCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.SelectedIndexCollection.cs index b42bb1a72ed..283a7c0ab1f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.SelectedIndexCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.SelectedIndexCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.SelectedObjectCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.SelectedObjectCollection.cs index 7463ddb3d5f..3d03565e65d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.SelectedObjectCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.SelectedObjectCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.cs index 02b1acbef78..6851609e3c5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -36,9 +35,9 @@ public partial class ListBox : ListControl /// public const int DefaultItemHeight = 13; - private static readonly object EVENT_SELECTEDINDEXCHANGED = new object(); - private static readonly object EVENT_DRAWITEM = new object(); - private static readonly object EVENT_MEASUREITEM = new object(); + private static readonly object EVENT_SELECTEDINDEXCHANGED = new(); + private static readonly object EVENT_DRAWITEM = new(); + private static readonly object EVENT_MEASUREITEM = new(); private SelectedObjectCollection? _selectedItems; private SelectedIndexCollection? _selectedIndices; @@ -1459,7 +1458,7 @@ public int GetItemHeight(int index) public Rectangle GetItemRectangle(int index) { CheckIndex(index); - var rect = default(RECT); + RECT rect = default; if (PInvoke.SendMessage(this, PInvoke.LB_GETITEMRECT, (uint)index, ref rect) == 0) { return Rectangle.Empty; @@ -2382,7 +2381,7 @@ private unsafe void WmReflectDrawItem(ref Message m) bounds.Width = MultiColumn ? Math.Max(ColumnWidth, bounds.Width) : Math.Max(MaxItemWidth, bounds.Width); } - using var e = new DrawItemEventArgs( + using DrawItemEventArgs e = new( dis->hDC, Font, bounds, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListControl.cs index c3a903bab05..339dce88d29 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -12,14 +11,14 @@ namespace System.Windows.Forms; [LookupBindingProperties(nameof(DataSource), nameof(DisplayMember), nameof(ValueMember), nameof(SelectedValue))] public abstract class ListControl : Control { - private static readonly object s_dataSourceChangedEvent = new object(); - private static readonly object s_displayMemberChangedEvent = new object(); - private static readonly object s_valueMemberChangedEvent = new object(); - private static readonly object s_selectedValueChangedEvent = new object(); - private static readonly object s_formatInfoChangedEvent = new object(); - private static readonly object s_formatStringChangedEvent = new object(); - private static readonly object s_formattingEnabledChangedEvent = new object(); - private static readonly object s_formatEvent = new object(); + private static readonly object s_dataSourceChangedEvent = new(); + private static readonly object s_displayMemberChangedEvent = new(); + private static readonly object s_valueMemberChangedEvent = new(); + private static readonly object s_selectedValueChangedEvent = new(); + private static readonly object s_formatInfoChangedEvent = new(); + private static readonly object s_formatStringChangedEvent = new(); + private static readonly object s_formattingEnabledChangedEvent = new(); + private static readonly object s_formatEvent = new(); private object? _dataSource; private CurrencyManager? _dataManager; @@ -465,10 +464,8 @@ private protected int FindStringInternal(string? str, IList? items, int startInd return -1; } - if (startIndex < -1 || startIndex >= items.Count) - { - throw new ArgumentOutOfRangeException(nameof(startIndex)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(startIndex, -1); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(startIndex, items.Count); // Start from the start index and wrap around until we find the string // in question. Use a separate counter to ensure that we aren't cycling through the list infinitely. @@ -519,7 +516,7 @@ private protected int FindStringInternal(string? str, IList? items, int startInd object? filteredItem = FilterItemOnProperty(item, _displayMember.BindingField); // First try the OnFormat event - var e = new ListControlConvertEventArgs(filteredItem, typeof(string), item); + ListControlConvertEventArgs e = new(filteredItem, typeof(string), item); OnFormat(e); if (e.Value != item && e.Value is string stringValue) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListControlConvertEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListControlConvertEventArgs.cs index ac8eb9d63eb..4d443b62f59 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListControlConvertEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListControlConvertEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListControlConvertEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListControlConvertEventHandler.cs index df906cbd42e..59a25eb82a6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListControlConvertEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListControlConvertEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListManagerBindingsCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListManagerBindingsCollection.cs index 5c03e5191fa..88c46d57811 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListManagerBindingsCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListManagerBindingsCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.CheckedIndexCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.CheckedIndexCollection.cs index bba3267f5a0..c91e3c5d22c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.CheckedIndexCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.CheckedIndexCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.CheckedListViewItemCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.CheckedListViewItemCollection.cs index f7637e13b00..e97743590d3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.CheckedListViewItemCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.CheckedListViewItemCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ColumnHeaderCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ColumnHeaderCollection.cs index 5e77b407e3e..0869a2f2125 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ColumnHeaderCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ColumnHeaderCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -268,7 +267,7 @@ public virtual ColumnHeader Add(string? key, string? text, int width, Horizontal // END - NEW ADD OVERLOADS IN WHIDBEY --> - public virtual void AddRange(ColumnHeader[] values) + public virtual void AddRange(params ColumnHeader[] values) { ArgumentNullException.ThrowIfNull(values); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.IconComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.IconComparer.cs index a28c7abff59..fb6e427a469 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.IconComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.IconComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewAccessibleObject.cs index c04d0ffc31c..714acf5f13d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; @@ -96,11 +95,6 @@ internal override UiaCore.RowOrColumnMajor RowOrColumnMajor return null; } - if (owningListView._labelEdit is {} labelEdit && index == GetChildCount() - 1) - { - return labelEdit.AccessibilityObject; - } - if (owningListView.GroupsDisplayed) { IReadOnlyList visibleGroups = GetVisibleGroups(); @@ -118,10 +112,6 @@ public override int GetChildCount() } int count = owningListView.GroupsDisplayed ? GetVisibleGroups().Count : owningListView.Items.Count; - if (owningListView._labelEdit is not null) - { - count++; - } return count; } @@ -168,9 +158,7 @@ internal override int GetChildIndex(AccessibleObject? child) return base.GetChildIndex(child); } - return owningListView._labelEdit is { } labelEdit && child == labelEdit.AccessibilityObject - ? GetChildCount() - 1 - : owningListView.GroupsDisplayed ? GetGroupIndex(child) : GetItemIndex(child); + return owningListView.GroupsDisplayed ? GetGroupIndex(child) : GetItemIndex(child); } private string GetItemStatus() @@ -240,11 +228,6 @@ internal override string GetMultiViewProviderViewName(int viewId) return null; } - if (owningListView._labelEdit is {} labelEdit) - { - return labelEdit.AccessibilityObject; - } - if (owningListView.GroupsDisplayed) { IReadOnlyList visibleGroups = GetVisibleGroups(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewItemCollection.IInnerList.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewItemCollection.IInnerList.cs index 022c369037a..a41c43a54ae 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewItemCollection.IInnerList.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewItemCollection.IInnerList.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; @@ -18,7 +17,7 @@ internal interface IInnerList ListViewItem this[int index] { get; set; } ListViewItem Add(ListViewItem item); - void AddRange(ListViewItem[] items); + void AddRange(params ListViewItem[] items); void Clear(); bool Contains(ListViewItem item); void CopyTo(Array dest, int index); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewItemCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewItemCollection.cs index f9676446aee..522445c3179 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewItemCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewItemCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -246,7 +245,7 @@ public virtual ListViewItem Add(string? key, string? text, int imageIndex) // END - NEW ADD OVERLOADS IN WHIDBEY --> - public void AddRange(ListViewItem[] items) + public void AddRange(params ListViewItem[] items) { ArgumentNullException.ThrowIfNull(items); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewNativeItemCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewNativeItemCollection.cs index eb1390a6116..e754f8b85c1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewNativeItemCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewNativeItemCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using static Interop; @@ -122,7 +121,7 @@ public ListViewItem Add(ListViewItem value) } } - public void AddRange(ListViewItem[] values) + public void AddRange(params ListViewItem[] values) { ArgumentNullException.ThrowIfNull(values); @@ -190,7 +189,7 @@ private int DisplayIndexToID(int displayIndex) if (_owner.IsHandleCreated && !_owner.ListViewHandleDestroyed) { // Obtain internal index of the item - var lvItem = new LVITEMW + LVITEMW lvItem = new() { mask = LIST_VIEW_ITEM_FLAGS.LVIF_PARAM, iItem = displayIndex diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.SelectedIndexCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.SelectedIndexCollection.cs index 970d6082b26..f2ebaf9a379 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.SelectedIndexCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.SelectedIndexCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.SelectedListViewItemCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.SelectedListViewItemCollection.cs index 20257868d1f..05429bac08e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.SelectedListViewItemCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.SelectedListViewItemCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.cs index 804f8be834a..904f88083ba 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -13,6 +12,7 @@ using System.Windows.Forms.VisualStyles; using Windows.Win32.UI.Input.KeyboardAndMouse; using static System.Windows.Forms.ListViewGroup; +using static System.Windows.Forms.ListViewItem; using static Interop; using static Interop.ComCtl32; @@ -30,21 +30,21 @@ public partial class ListView : Control { private const int MASK_HITTESTFLAG = 0x00F7; - private static readonly object EVENT_CACHEVIRTUALITEMS = new object(); - private static readonly object EVENT_COLUMNREORDERED = new object(); - private static readonly object EVENT_COLUMNWIDTHCHANGED = new object(); - private static readonly object EVENT_COLUMNWIDTHCHANGING = new object(); - private static readonly object EVENT_DRAWCOLUMNHEADER = new object(); - private static readonly object EVENT_DRAWITEM = new object(); - private static readonly object EVENT_DRAWSUBITEM = new object(); - private static readonly object EVENT_ITEMSELECTIONCHANGED = new object(); - private static readonly object EVENT_RETRIEVEVIRTUALITEM = new object(); - private static readonly object EVENT_SEARCHFORVIRTUALITEM = new object(); - private static readonly object EVENT_SELECTEDINDEXCHANGED = new object(); - private static readonly object EVENT_VIRTUALITEMSSELECTIONRANGECHANGED = new object(); - private static readonly object EVENT_RIGHTTOLEFTLAYOUTCHANGED = new object(); - private static readonly object EVENT_GROUPCOLLAPSEDSTATECHANGED = new object(); - private static readonly object EVENT_GROUPTASKLINKCLICK = new object(); + private static readonly object EVENT_CACHEVIRTUALITEMS = new(); + private static readonly object EVENT_COLUMNREORDERED = new(); + private static readonly object EVENT_COLUMNWIDTHCHANGED = new(); + private static readonly object EVENT_COLUMNWIDTHCHANGING = new(); + private static readonly object EVENT_DRAWCOLUMNHEADER = new(); + private static readonly object EVENT_DRAWITEM = new(); + private static readonly object EVENT_DRAWSUBITEM = new(); + private static readonly object EVENT_ITEMSELECTIONCHANGED = new(); + private static readonly object EVENT_RETRIEVEVIRTUALITEM = new(); + private static readonly object EVENT_SEARCHFORVIRTUALITEM = new(); + private static readonly object EVENT_SELECTEDINDEXCHANGED = new(); + private static readonly object EVENT_VIRTUALITEMSSELECTIONRANGECHANGED = new(); + private static readonly object EVENT_RIGHTTOLEFTLAYOUTCHANGED = new(); + private static readonly object EVENT_GROUPCOLLAPSEDSTATECHANGED = new(); + private static readonly object EVENT_GROUPTASKLINKCLICK = new(); private ItemActivation _activation = ItemActivation.Standard; private ListViewAlignment _alignStyle = ListViewAlignment.Top; @@ -176,7 +176,10 @@ public partial class ListView : Control private bool _blockLabelEdit; - private ListViewLabelEditNativeWindow? _labelEdit; + internal ListViewLabelEditNativeWindow? _labelEdit; + + // Used to record the SubItem to which the Label Edit belongs. + internal ListViewSubItem? _listViewSubItem; // Background image stuff // Because we have to create a temporary file and the OS does not clean up the temporary files from the machine @@ -398,7 +401,7 @@ public unsafe bool BackgroundImageTiled // We don't need to delete it and this causes BAD problems w/ the Win32 list view control. fixed (char* pBackgroundImageFileName = _backgroundImageFileName) { - var lvbkImage = default(LVBKIMAGEW); + LVBKIMAGEW lvbkImage = default; if (BackgroundImageTiled) { lvbkImage.ulFlags = LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_STYLE_TILE; @@ -1679,7 +1682,7 @@ public unsafe Size TileSize return Size.Empty; } - var tileViewInfo = new LVTILEVIEWINFO + LVTILEVIEWINFO tileViewInfo = new() { cbSize = (uint)sizeof(LVTILEVIEWINFO), dwMask = LVTILEVIEWINFO_MASK.LVTVIM_TILESIZE @@ -1707,7 +1710,7 @@ public unsafe Size TileSize return; } - var tileViewInfo = new LVTILEVIEWINFO + LVTILEVIEWINFO tileViewInfo = new() { cbSize = (uint)sizeof(LVTILEVIEWINFO), dwMask = LVTILEVIEWINFO_MASK.LVTVIM_TILESIZE, @@ -3362,7 +3365,7 @@ public void EnsureVisible(int index) { fixed (char* pText = text) { - var lvFindInfo = default(LVFINDINFOW); + LVFINDINFOW lvFindInfo = default; if (isTextSearch) { lvFindInfo.flags = LVFINDINFOW_FLAGS.LVFI_STRING; @@ -3395,24 +3398,24 @@ public void EnsureVisible(int index) // win32 listView control can't search inside sub items for (int i = startIndex; i < Items.Count; i++) { - ListViewItem lvi = Items[i]; - for (int j = 0; j < lvi.SubItems.Count; j++) + ListViewItem listViewItem = Items[i]; + for (int j = 0; j < listViewItem.SubItems.Count; j++) { - ListViewItem.ListViewSubItem lvsi = lvi.SubItems[j]; + ListViewSubItem listViewSubItem = listViewItem.SubItems[j]; // the win32 list view search for items w/ text is case insensitive // do the same for sub items // because we are comparing user defined strings we have to do the slower String search // ie, use String.Compare(string, string, case sensitive, CultureInfo) // instead of new Whidbey String.Equals overload // String.Equals(string, string, StringComparison.OrdinalIgnoreCase - if (string.Equals(text, lvsi.Text, StringComparison.OrdinalIgnoreCase)) + if (string.Equals(text, listViewSubItem.Text, StringComparison.OrdinalIgnoreCase)) { - return lvi; + return listViewItem; } - if (isPrefixSearch && CultureInfo.CurrentCulture.CompareInfo.IsPrefix(lvsi.Text, text, CompareOptions.IgnoreCase)) + if (isPrefixSearch && CultureInfo.CurrentCulture.CompareInfo.IsPrefix(listViewSubItem.Text, text, CompareOptions.IgnoreCase)) { - return lvi; + return listViewItem; } } } @@ -3475,9 +3478,9 @@ internal int GetDisplayIndex(ListViewItem item, int lastIndex) ApplyUpdateCachedItems(); if (IsHandleCreated && !ListViewHandleDestroyed) { - var info = new LVFINDINFOW + LVFINDINFOW info = new() { - lParam = (IntPtr)item.ID, + lParam = item.ID, flags = LVFINDINFOW_FLAGS.LVFI_PARAM }; @@ -3545,7 +3548,7 @@ internal int GetColumnIndex(ColumnHeader ch) /// public ListViewItem? GetItemAt(int x, int y) { - var lvhi = new LVHITTESTINFO + LVHITTESTINFO lvhi = new() { pt = new Point(x, y) }; @@ -3585,7 +3588,7 @@ internal override unsafe ComCtl32.ToolInfoWrapper GetToolInfoWrapper(TO // The second condition is necessary for the correct display of the keyboard tooltip, // since the logic of the external tooltip blocks its display bool isExternalTooltip = ShowItemToolTips && tooltip != KeyboardToolTip; - var wrapper = new ComCtl32.ToolInfoWrapper(this, flags, isExternalTooltip ? null : caption); + ComCtl32.ToolInfoWrapper wrapper = new(this, flags, isExternalTooltip ? null : caption); if (isExternalTooltip) wrapper.Info.lpszText = (char*)(-1); @@ -3594,7 +3597,7 @@ internal override unsafe ComCtl32.ToolInfoWrapper GetToolInfoWrapper(TO internal void GetSubItemAt(int x, int y, out int iItem, out int iSubItem) { - var lvhi = new LVHITTESTINFO + LVHITTESTINFO lvhi = new() { pt = new Point(x, y) }; @@ -3614,9 +3617,9 @@ internal void GetSubItemAt(int x, int y, out int iItem, out int iSubItem) internal Point GetItemPosition(int index) { - var pt = default(Point); - PInvoke.SendMessage(this, PInvoke.LVM_GETITEMPOSITION, (WPARAM)index, ref pt); - return pt; + Point position = default; + PInvoke.SendMessage(this, PInvoke.LVM_GETITEMPOSITION, (WPARAM)index, ref position); + return position; } internal LIST_VIEW_ITEM_STATE_FLAGS GetItemState(int index) @@ -3660,7 +3663,7 @@ public Rectangle GetItemRect(int index, ItemBoundsPortion portion) return Rectangle.Empty; } - var itemrect = new RECT + RECT itemrect = new() { left = (int)portion }; @@ -3692,7 +3695,7 @@ private Rectangle GetItemRectOrEmpty(int index) return Rectangle.Empty; } - var itemrect = new RECT + RECT itemrect = new() { left = 0 }; @@ -3742,7 +3745,7 @@ internal Rectangle GetSubItemRect(int itemIndex, int subItemIndex, ItemBoundsPor return Rectangle.Empty; } - var itemrect = new RECT + RECT itemrect = new() { left = (int)portion, top = subItemIndex @@ -3791,7 +3794,7 @@ public ListViewHitTestInfo HitTest(int x, int y) return new ListViewHitTestInfo(hitItem: null, hitSubItem: null, hitLocation: ListViewHitTestLocations.None); } - var lvhi = new LVHITTESTINFO + LVHITTESTINFO lvhi = new() { pt = new Point(x, y) }; @@ -3826,7 +3829,8 @@ public ListViewHitTestInfo HitTest(int x, int y) { if (lvhi.iSubItem < item.SubItems.Count) { - return new ListViewHitTestInfo(item, item.SubItems[lvhi.iSubItem], location); + _listViewSubItem = item.SubItems[lvhi.iSubItem]; + return new ListViewHitTestInfo(item, _listViewSubItem, location); } else { @@ -3984,7 +3988,7 @@ internal ColumnHeader InsertColumn(int index, ColumnHeader ch, bool refreshSubIt private unsafe int InsertColumnNative(int index, ColumnHeader ch) { - var lvColumn = new LVCOLUMNW + LVCOLUMNW lvColumn = new() { mask = LVCOLUMNW_MASK.LVCF_FMT | LVCOLUMNW_MASK.LVCF_TEXT | LVCOLUMNW_MASK.LVCF_WIDTH }; @@ -4041,7 +4045,7 @@ internal void InsertGroupInListView(int index, ListViewGroup group) for (int i = 0; i < Items.Count; i++) { ListViewItem item = Items[i]; - var lvItem = new LVITEMW + LVITEMW lvItem = new() { iItem = item.Index, mask = LIST_VIEW_ITEM_FLAGS.LVIF_GROUPID @@ -4199,7 +4203,7 @@ private unsafe int InsertItemsNative(int index, ListViewItem[] items) Debug.Assert(Items.Contains(li), "Make sure ListView.Items contains this item before adding the native LVITEM. Otherwise, custom-drawing may break."); - var lvItem = new LVITEMW + LVITEMW lvItem = new() { mask = LIST_VIEW_ITEM_FLAGS.LVIF_TEXT | LIST_VIEW_ITEM_FLAGS.LVIF_IMAGE | LIST_VIEW_ITEM_FLAGS.LVIF_PARAM | LIST_VIEW_ITEM_FLAGS.LVIF_INDENT | @@ -4207,7 +4211,7 @@ private unsafe int InsertItemsNative(int index, ListViewItem[] items) iItem = index + i, iImage = li.ImageIndexer.ActualIndex, iIndent = li.IndentCount, - lParam = (IntPtr)li.ID, + lParam = li.ID, cColumns = _columnHeaders is not null ? Math.Min(MAXTILECOLUMNS, _columnHeaders.Length) : 0, }; @@ -4989,13 +4993,13 @@ private unsafe void PositionHeader() private void RealizeAllSubItems() { - var lvItem = default(LVITEMW); + LVITEMW item = default; for (int i = 0; i < _itemCount; i++) { int subItemCount = Items[i].SubItems.Count; for (int j = 0; j < subItemCount; j++) { - SetItemText(i, j, Items[i].SubItems[j].Text, ref lvItem); + SetItemText(i, j, Items[i].SubItems[j].Text, ref item); } } } @@ -5197,7 +5201,7 @@ private unsafe void SetBackgroundImage() // needed for OleInitialize Application.OleRequired(); - var lvbkImage = default(LVBKIMAGEW); + LVBKIMAGEW backgroundImage = default; // first, is there an existing temporary file to delete, remember its name // so that we can delete it if the list control doesn't... @@ -5210,27 +5214,27 @@ private unsafe void SetBackgroundImage() BackgroundImage.Save(_backgroundImageFileName, System.Drawing.Imaging.ImageFormat.Bmp); - lvbkImage.cchImageMax = (uint)(_backgroundImageFileName.Length + 1); - lvbkImage.ulFlags = LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_SOURCE_URL; + backgroundImage.cchImageMax = (uint)(_backgroundImageFileName.Length + 1); + backgroundImage.ulFlags = LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_SOURCE_URL; if (BackgroundImageTiled) { - lvbkImage.ulFlags |= LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_STYLE_TILE; + backgroundImage.ulFlags |= LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_STYLE_TILE; } else { - lvbkImage.ulFlags |= LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_STYLE_NORMAL; + backgroundImage.ulFlags |= LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_STYLE_NORMAL; } } else { - lvbkImage.ulFlags = LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_SOURCE_NONE; + backgroundImage.ulFlags = LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_SOURCE_NONE; _backgroundImageFileName = string.Empty; } fixed (char* pBackgroundImageFileName = _backgroundImageFileName) { - lvbkImage.pszImage = pBackgroundImageFileName; - PInvoke.SendMessage(this, PInvoke.LVM_SETBKIMAGEW, (WPARAM)0, ref lvbkImage); + backgroundImage.pszImage = pBackgroundImageFileName; + PInvoke.SendMessage(this, PInvoke.LVM_SETBKIMAGEW, (WPARAM)0, ref backgroundImage); } if (string.IsNullOrEmpty(fileNameToDelete)) @@ -5470,7 +5474,7 @@ internal void SetItemImage(int itemIndex, int imageIndex) return; } - var lvItem = new LVITEMW + LVITEMW lvItem = new() { mask = LIST_VIEW_ITEM_FLAGS.LVIF_IMAGE, iItem = itemIndex, @@ -5492,7 +5496,7 @@ internal void SetItemIndentCount(int index, int indentCount) return; } - var lvItem = new LVITEMW + LVITEMW lvItem = new() { mask = LIST_VIEW_ITEM_FLAGS.LVIF_INDENT, iItem = index, @@ -5516,7 +5520,7 @@ internal void SetItemPosition(int index, int x, int y) Debug.Assert(IsHandleCreated, "How did we add items without a handle?"); - var pt = new Point(x, y); + Point pt = new(x, y); PInvoke.SendMessage(this, PInvoke.LVM_SETITEMPOSITION32, (WPARAM)index, ref pt); } @@ -5532,7 +5536,7 @@ internal void SetItemState(int index, LIST_VIEW_ITEM_STATE_FLAGS state, LIST_VIE return; } - var lvItem = new LVITEMW + LVITEMW lvItem = new() { mask = LIST_VIEW_ITEM_FLAGS.LVIF_STATE, state = state, @@ -5544,7 +5548,7 @@ internal void SetItemState(int index, LIST_VIEW_ITEM_STATE_FLAGS state, LIST_VIE internal void SetItemText(int itemIndex, int subItemIndex, string text) { - var lvItem = default(LVITEMW); + LVITEMW lvItem = default; SetItemText(itemIndex, subItemIndex, text, ref lvItem); } @@ -5778,7 +5782,7 @@ private unsafe nint SendGroupMessage(ListViewGroup group, uint msg, nint lParam, string footer = group.Footer; string subtitle = group.Subtitle; string task = group.TaskLink; - var lvgroup = new LVGROUPW + LVGROUPW lvgroup = new() { cbSize = (uint)sizeof(LVGROUPW), mask = LVGF.HEADER | LVGF.ALIGN | LVGF.STATE | LVGF.TITLEIMAGE | additionalMask, @@ -5885,7 +5889,7 @@ private unsafe void UpdateTileView() Debug.Assert(Application.ComCtlSupportsVisualStyles, "this function works only when ComCtl 6.0 and higher is loaded"); Debug.Assert(_viewStyle == View.Tile, "this function should be called only in Tile view"); - var tileViewInfo = new LVTILEVIEWINFO + LVTILEVIEWINFO tileViewInfo = new() { cbSize = (uint)sizeof(LVTILEVIEWINFO), @@ -5909,7 +5913,7 @@ private void WmNmClick() return; } - var lvhi = new LVHITTESTINFO + LVHITTESTINFO lvhi = new() { pt = PointToClient(Cursor.Position) }; @@ -5951,7 +5955,7 @@ private void WmNmDblClick() return; } - var lvhi = new LVHITTESTINFO + LVHITTESTINFO lvhi = new() { pt = PointToClient(Cursor.Position) }; @@ -6057,7 +6061,7 @@ private unsafe bool WmNotify(ref Message m) Color foreColor = Color.FromArgb((int)PInvoke.GetTextColor(nmcd->hdc).Value); Color backColor = Color.FromArgb((int)PInvoke.GetBkColor(nmcd->hdc).Value); Font font = GetListHeaderFont(); - var e = new DrawListViewColumnHeaderEventArgs( + DrawListViewColumnHeaderEventArgs e = new( g, nmcd->rc, (int)nmcd->dwItemSpec, @@ -6389,7 +6393,7 @@ private int GetIndexOfClickedItem() private LVHITTESTINFO SetupHitTestInfo() { - var lvhi = new LVHITTESTINFO + LVHITTESTINFO lvhi = new() { pt = PointToClient(Cursor.Position) }; @@ -6937,10 +6941,10 @@ private unsafe void WmReflectNotify(ref Message m) startIndex = 0; } - var sviEvent = new SearchForVirtualItemEventArgs( + SearchForVirtualItemEventArgs sviEvent = new( isTextSearch, isPrefixSearch, - false, /* includeSubItemsInSearch */ + includeSubItemsInSearch: false, text, startingPoint, dir, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewAlignment.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewAlignment.cs index 9b95b0365ca..86d0435128a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewAlignment.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewAlignment.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.ListViewGroupAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.ListViewGroupAccessibleObject.cs index 3446af94e31..d6412b9f74e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.ListViewGroupAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.ListViewGroupAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static System.Windows.Forms.ListView; @@ -56,7 +55,7 @@ public override Rectangle Bounds : PInvoke.LVGGR_GROUP; // Get the native rectangle - RECT groupRect = default(RECT); + RECT groupRect = default; // Using the "top" property, we set which rectangle type of the group we want to get // This is described in more detail in https://docs.microsoft.com/windows/win32/controls/lvm-getgrouprect diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.cs index 1cc669b9c34..2436a31d5ec 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.Serialization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupCollapsedState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupCollapsedState.cs index 03b148487d5..941931081a8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupCollapsedState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupCollapsedState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupCollection.cs index 56ac68a2fa9..fdfc8e6372c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -149,7 +148,7 @@ int IList.Add(object? value) return Add(group); } - public void AddRange(ListViewGroup[] groups) + public void AddRange(params ListViewGroup[] groups) { ArgumentNullException.ThrowIfNull(groups); ThrowInvalidOperationExceptionIfVirtualMode(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupConverter.cs index 4bf461ffb7b..a6df0b61c95 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -118,7 +117,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destina { if (context is not null && context.Instance is ListViewItem item && item.ListView is not null) { - var list = new ArrayList(); + ArrayList list = new(); foreach (ListViewGroup group in item.ListView.Groups) { list.Add(group); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupEventArgs.cs index 2783303c45f..740d3a7932c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupImageIndexer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupImageIndexer.cs index b3993390097..cdc048f6d18 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupImageIndexer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupImageIndexer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupItemCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupItemCollection.cs index 639e6c864e8..9b712d7f637 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupItemCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupItemCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; @@ -47,7 +46,7 @@ public ListViewItem Add(ListViewItem value) return value; } - public void AddRange(ListViewItem[] items) + public void AddRange(params ListViewItem[] items) { for (int i = 0; i < items.Length; i++) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewHitTestInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewHitTestInfo.cs index 76fb1436692..ccf1aea37b3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewHitTestInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewHitTestInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewHitTestLocation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewHitTestLocation.cs index e20a53114b9..ab31acaefc7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewHitTestLocation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewHitTestLocation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewInsertionMark.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewInsertionMark.cs index 18881634045..e4821ad4f2a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewInsertionMark.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewInsertionMark.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop.ComCtl32; @@ -55,9 +54,9 @@ public Rectangle Bounds { get { - var rect = default(RECT); - PInvoke.SendMessage(_listView, PInvoke.LVM_GETINSERTMARKRECT, (WPARAM)0, ref rect); - return rect; + RECT bounds = default; + PInvoke.SendMessage(_listView, PInvoke.LVM_GETINSERTMARKRECT, (WPARAM)0, ref bounds); + return bounds; } } @@ -115,7 +114,7 @@ public int Index /// public unsafe int NearestIndex(Point pt) { - var lvInsertMark = new LVINSERTMARK + LVINSERTMARK lvInsertMark = new() { cbSize = (uint)sizeof(LVINSERTMARK) }; @@ -128,7 +127,7 @@ public unsafe int NearestIndex(Point pt) internal unsafe void UpdateListView() { Debug.Assert(_listView.IsHandleCreated, "ApplySavedState Precondition: List-view handle must be created"); - var lvInsertMark = new LVINSERTMARK + LVINSERTMARK lvInsertMark = new() { cbSize = (uint)sizeof(LVINSERTMARK), dwFlags = _appearsAfterItem ? LVIM.AFTER : LVIM.BEFORE, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.IKeyboardToolTip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.IKeyboardToolTip.cs index a08e9251a2e..52b3c2aa9f0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.IKeyboardToolTip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.IKeyboardToolTip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemBaseAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemBaseAccessibleObject.cs index 3907f3308fb..6fe4b810c18 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemBaseAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemBaseAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; @@ -178,7 +177,7 @@ public override int GetChildCount() UiaCore.UIA.IsKeyboardFocusablePropertyId => (State & AccessibleStates.Focusable) == AccessibleStates.Focusable, UiaCore.UIA.IsOffscreenPropertyId => OwningGroup?.CollapsedState == ListViewGroupCollapsedState.Collapsed || (bool)(base.GetPropertyValue(UiaCore.UIA.IsOffscreenPropertyId) ?? false), - UiaCore.UIA.NativeWindowHandlePropertyId => _owningListView.InternalHandle, + UiaCore.UIA.NativeWindowHandlePropertyId => (nint)_owningListView.InternalHandle, _ => base.GetPropertyValue(propertyID) }; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemDetailsAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemDetailsAccessibleObject.cs index 615e11894a5..0f285715f3d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemDetailsAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemDetailsAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemImageAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemImageAccessibleObject.cs index a7100569e35..2b887d11d28 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemImageAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemImageAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemLargeIconAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemLargeIconAccessibleObject.cs index 98e03381632..e7d34e1acda 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemLargeIconAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemLargeIconAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemListAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemListAccessibleObject.cs index f1ca775c5e4..c8685e32b83 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemListAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemListAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemSmallIconAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemSmallIconAccessibleObject.cs index cc915d3f257..d04154ad240 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemSmallIconAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemSmallIconAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemTileAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemTileAccessibleObject.cs index 24d14e49575..6ee4e8a5eb7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemTileAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemTileAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemWithImageAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemWithImageAccessibleObject.cs index 6b0237cd1c1..765931a1d3c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemWithImageAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemWithImageAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObject.cs index d77404814c1..1b4e434e221 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; @@ -77,6 +76,8 @@ public override Rectangle Bounds => ParentInternal.GetChildInternal(ParentInternal.GetChildIndex(this) + 1), UiaCore.NavigateDirection.PreviousSibling => ParentInternal.GetChildInternal(ParentInternal.GetChildIndex(this) - 1), + UiaCore.NavigateDirection.FirstChild => GetChild(), + UiaCore.NavigateDirection.LastChild => GetChild(), _ => base.FragmentNavigate(direction) }; @@ -162,6 +163,16 @@ internal override bool IsPatternSupported(UiaCore.UIA patternId) private protected override string AutomationId => $"{nameof(ListViewSubItem)}-{ParentInternal.GetChildIndex(this)}"; + + private AccessibleObject? GetChild() + { + if (_owningListView._labelEdit is { } labelEdit) + { + return labelEdit.AccessibilityObject; + } + + return null; + } } } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.SubItemStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.SubItemStyle.cs index dcc9d38e1cd..0afdc93fbce 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.SubItemStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.SubItemStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.cs index f4e87cf17f5..6276b714e53 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItemCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItemCollection.cs index bdc1f0c1aa3..3bd9f111c69 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItemCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItemCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -134,7 +133,7 @@ public ListViewSubItem Add(string? text, Color foreColor, Color backColor, Font return item; } - public void AddRange(ListViewSubItem[] items) + public void AddRange(params ListViewSubItem[] items) { ArgumentNullException.ThrowIfNull(items); @@ -152,7 +151,7 @@ public void AddRange(ListViewSubItem[] items) _owner.UpdateSubItems(-1); } - public void AddRange(string[] items) + public void AddRange(params string[] items) { ArgumentNullException.ThrowIfNull(items); @@ -305,11 +304,8 @@ public virtual int IndexOfKey(string? key) public void Insert(int index, ListViewSubItem item) { - if (index < 0 || index > Count) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } - + ArgumentOutOfRangeException.ThrowIfNegative(index); + ArgumentOutOfRangeException.ThrowIfGreaterThan(index, Count); ArgumentNullException.ThrowIfNull(item); item._owner = _owner; @@ -351,10 +347,8 @@ void IList.Remove(object? item) public void RemoveAt(int index) { - if (index < 0 || index >= Count) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } + ArgumentOutOfRangeException.ThrowIfNegative(index); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); // Remove ourselves as the owner. _owner._subItems[index]._owner = null; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.cs index e73143fb75b..61b14c41bef 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -32,7 +31,7 @@ public partial class ListViewItem : ICloneable, ISerializable private static readonly BitVector32.Section s_subItemCountSection = BitVector32.CreateSection(MaxSubItems, s_savedStateImageIndexSection); private int _indentCount; - private Point _position = new Point(-1, -1); + private Point _position = new(-1, -1); internal ListView? _listView; @@ -315,7 +314,7 @@ public Rectangle Bounds } else { - return default(Rectangle); + return default; } } } @@ -979,7 +978,7 @@ public Rectangle GetBounds(ItemBoundsPortion portion) return _listView.GetItemRect(Index, portion); } - return default(Rectangle); + return default; } public ListViewSubItem? GetSubItemAt(int x, int y) @@ -1058,8 +1057,8 @@ internal void UpdateGroupFromName() internal void UpdateStateToListView(int index) { - var lvItem = default(LVITEMW); - UpdateStateToListView(index, ref lvItem, true); + LVITEMW item = default; + UpdateStateToListView(index, ref item, updateOwner: true); } /// @@ -1122,7 +1121,7 @@ internal void UpdateStateFromListView(int displayIndex, bool checkSelection) if (_listView is not null && _listView.IsHandleCreated && displayIndex != -1) { // Get information from comctl control - var lvItem = new LVITEMW + LVITEMW lvItem = new() { mask = LIST_VIEW_ITEM_FLAGS.LVIF_PARAM | LIST_VIEW_ITEM_FLAGS.LVIF_STATE | LIST_VIEW_ITEM_FLAGS.LVIF_GROUPID }; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemConverter.cs index 9a759cd995c..a632ee3c841 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemImageIndexer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemImageIndexer.cs index f097a48af6a..de2bed8d573 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemImageIndexer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemImageIndexer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemMouseHoverEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemMouseHoverEventArgs.cs index a180b05a482..55f8b6ea5d7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemMouseHoverEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemMouseHoverEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemMouseHoverEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemMouseHoverEventHandler.cs index c8173ce84d9..b93b11ddc0b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemMouseHoverEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemMouseHoverEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemSelectionChangedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemSelectionChangedEventArgs.cs index 517996ca928..41028070077 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemSelectionChangedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemSelectionChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemSelectionChangedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemSelectionChangedEventHandler.cs index 28ea2bf3fca..971f8a7f3bf 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemSelectionChangedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemSelectionChangedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemState.cs index a503e87ac2f..b98e88c7cd0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemStateImageIndexConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemStateImageIndexConverter.cs index 89108a610fc..5b697793e10 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemStateImageIndexConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItemStateImageIndexConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditAccessibleObject.cs index 6769c7f48b4..394185c2515 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditAccessibleObject.cs @@ -1,8 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; +using static System.Windows.Forms.ListViewItem; using static Interop; namespace System.Windows.Forms; @@ -12,6 +12,7 @@ internal class ListViewLabelEditAccessibleObject : AccessibleObject private const string LIST_VIEW_LABEL_EDIT_AUTOMATION_ID = "1"; private readonly ListView _owningListView; + private readonly ListViewSubItem _owningListViewSubItem; private readonly WeakReference _labelEdit; private readonly ListViewLabelEditUiaTextProvider _textProvider; private int[]? _runtimeId; @@ -19,6 +20,7 @@ internal class ListViewLabelEditAccessibleObject : AccessibleObject public ListViewLabelEditAccessibleObject(ListView owningListView, ListViewLabelEditNativeWindow labelEdit) { _owningListView = owningListView.OrThrowIfNull(); + _owningListViewSubItem = owningListView._listViewSubItem.OrThrowIfNull(); _labelEdit = new(labelEdit); UseStdAccessibleObjects(labelEdit.Handle); _textProvider = new ListViewLabelEditUiaTextProvider(owningListView, labelEdit, this); @@ -26,15 +28,13 @@ public ListViewLabelEditAccessibleObject(ListView owningListView, ListViewLabelE private protected override string AutomationId => LIST_VIEW_LABEL_EDIT_AUTOMATION_ID; + public override AccessibleObject? Parent => _owningListViewSubItem.AccessibilityObject; + internal override UiaCore.IRawElementProviderFragment? FragmentNavigate(UiaCore.NavigateDirection direction) { - AccessibleObject parent = _owningListView.AccessibilityObject; - return direction switch { - UiaCore.NavigateDirection.Parent => parent, - UiaCore.NavigateDirection.NextSibling => parent.GetChildIndex(this) is int childId and >= 0 ? parent.GetChild(childId + 1) : null, - UiaCore.NavigateDirection.PreviousSibling => parent.GetChildIndex(this) is int childId and >= 0 ? parent.GetChild(childId - 1) : null, + UiaCore.NavigateDirection.Parent => Parent, _ => base.FragmentNavigate(direction), }; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditNativeWindow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditNativeWindow.cs index d61404cccda..22328959159 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditNativeWindow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditNativeWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.UI.Accessibility; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditUiaTextProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditUiaTextProvider.cs index 831e26aab02..6c9d5a806f1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditUiaTextProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditUiaTextProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Automation; @@ -299,7 +298,7 @@ private int GetCharIndexFromPosition(Point pt) private RECT GetFormattingRectangle() { // Send an EM_GETRECT message to find out the bounding rectangle. - RECT rectangle = default(RECT); + RECT rectangle = default; PInvoke.SendMessage(_owningChildEdit, PInvoke.EM_GETRECT, 0, ref rectangle); return rectangle; @@ -319,9 +318,9 @@ private Point GetPositionFromCharIndex(int index) private unsafe bool GetTextExtentPoint32(char item, out Size size) { - size = default(Size); + size = default; - using var hdc = new GetDcScope(_owningChildEdit.Handle); + using GetDcScope hdc = new(_owningChildEdit.Handle); if (hdc.IsNull) { return false; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewSubItemConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewSubItemConverter.cs index 32954a0b16a..5898a83a941 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewSubItemConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewSubItemConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewVirtualItemsSelectionRangeChangedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewVirtualItemsSelectionRangeChangedEventArgs.cs index 8ae4bdf4031..6f0f9e7bc46 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewVirtualItemsSelectionRangeChangedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewVirtualItemsSelectionRangeChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewVirtualItemsSelectionRangeChangedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewVirtualItemsSelectionRangeChangedEventHandler.cs index d697666535e..54c6bf86aed 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewVirtualItemsSelectionRangeChangedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewVirtualItemsSelectionRangeChangedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MDIClient.ControlCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MDIClient.ControlCollection.cs index 86b3ae7614d..f9ac3bd54c7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MDIClient.ControlCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MDIClient.ControlCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MDIClient.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MDIClient.cs index 57fa76f56bb..7b0b15e6c1c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MDIClient.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MDIClient.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -22,7 +21,7 @@ public sealed partial class MdiClient : Control { // kept in add order, not ZOrder. Need to return the correct // array of items... - private readonly List _children = new List(); + private readonly List _children = new(); /// /// Creates a new MdiClient. @@ -276,7 +275,7 @@ protected override unsafe void SetBoundsCore(int x, int y, int width, int height /// private void SetWindowRgn() { - RECT rect = default(RECT); + RECT rect = default; CreateParams cp = CreateParams; AdjustWindowRectExForControlDpi(ref rect, (WINDOW_STYLE)cp.Style, false, (WINDOW_EX_STYLE)cp.ExStyle); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MDIControlStrip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MDIControlStrip.cs index 5d936dc27b7..3be702cf179 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MDIControlStrip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MDIControlStrip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MDILayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MDILayout.cs index 0854e2085b3..919a2b58027 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MDILayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MDILayout.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MDIWindowDialog.ListItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MDIWindowDialog.ListItem.cs index 0f0a1f54b6b..08ea2030653 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MDIWindowDialog.ListItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MDIWindowDialog.ListItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MDIWindowDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MDIWindowDialog.cs index afa97c27824..3386fd933fb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MDIWindowDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MDIWindowDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MaskFormat.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MaskFormat.cs index 4220854496d..ed5c53fbc44 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MaskFormat.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MaskFormat.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MaskInputRejectedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MaskInputRejectedEventArgs.cs index 7b58753e9ba..c2005ea006a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MaskInputRejectedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MaskInputRejectedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MaskInputRejectedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MaskInputRejectedEventHandler.cs index 16b67c6c675..5a436b85b31 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MaskInputRejectedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MaskInputRejectedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MaskedTextBox.MaskedTextBoxAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MaskedTextBox.MaskedTextBoxAccessibleObject.cs index 0fe5dba40dd..31c822569d0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MaskedTextBox.MaskedTextBoxAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MaskedTextBox.MaskedTextBoxAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MaskedTextBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MaskedTextBox.cs index f1d5134e73b..5d7b832646d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MaskedTextBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MaskedTextBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -38,11 +37,11 @@ public partial class MaskedTextBox : TextBoxBase private const bool backward = false; private const string nullMask = "<>"; // any char/str is OK here. - private static readonly object EVENT_MASKINPUTREJECTED = new object(); - private static readonly object EVENT_VALIDATIONCOMPLETED = new object(); - private static readonly object EVENT_TEXTALIGNCHANGED = new object(); - private static readonly object EVENT_ISOVERWRITEMODECHANGED = new object(); - private static readonly object EVENT_MASKCHANGED = new object(); + private static readonly object EVENT_MASKINPUTREJECTED = new(); + private static readonly object EVENT_VALIDATIONCOMPLETED = new(); + private static readonly object EVENT_TEXTALIGNCHANGED = new(); + private static readonly object EVENT_ISOVERWRITEMODECHANGED = new(); + private static readonly object EVENT_MASKCHANGED = new(); // The native edit control's default password char (per thread). See corresponding property for more info. private static char systemPwdChar; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MdiControlStrip.ControlBoxMenuItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MdiControlStrip.ControlBoxMenuItem.cs index 3308ab6f7a9..967437f199d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MdiControlStrip.ControlBoxMenuItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MdiControlStrip.ControlBoxMenuItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MdiControlStrip.SystemMenuItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MdiControlStrip.SystemMenuItem.cs index 23b43733d8f..8f9ab26fbe2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MdiControlStrip.SystemMenuItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MdiControlStrip.SystemMenuItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MdiWindowListItemConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MdiWindowListItemConverter.cs index 3772c19f0d7..c7fbb784d5a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MdiWindowListItemConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MdiWindowListItemConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MdiWindowListStrip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MdiWindowListStrip.cs index 85ee455fde1..9074a637f65 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MdiWindowListStrip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MdiWindowListStrip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MeasureItemEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MeasureItemEventArgs.cs index 61d44804852..4540e08b56a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MeasureItemEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MeasureItemEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MeasureItemEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MeasureItemEventHandler.cs index cfafc93fbb7..967862f6fa6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MeasureItemEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MeasureItemEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MenuGlyph.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MenuGlyph.cs index 4ea42141f16..d74441956a1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MenuGlyph.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MenuGlyph.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MenuStrip.MenuStripAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MenuStrip.MenuStripAccessibleObject.cs index 7a650d450b9..4c67405e6d2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MenuStrip.MenuStripAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MenuStrip.MenuStripAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MenuStrip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MenuStrip.cs index 5e12b40450c..c630935cc0f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MenuStrip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MenuStrip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -13,8 +12,8 @@ public partial class MenuStrip : ToolStrip { private ToolStripMenuItem? _mdiWindowListItem; - private static readonly object EventMenuActivate = new object(); - private static readonly object EventMenuDeactivate = new object(); + private static readonly object EventMenuActivate = new(); + private static readonly object EventMenuDeactivate = new(); public MenuStrip() { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MenuTimer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MenuTimer.cs index 20223be40b2..b6829c19f36 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MenuTimer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MenuTimer.cs @@ -1,12 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; internal class MenuTimer { - private readonly Timer _autoMenuExpandTimer = new Timer(); + private readonly Timer _autoMenuExpandTimer = new(); // consider - weak reference? private ToolStripMenuItem? currentItem; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MergeAction.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MergeAction.cs index a5f05fd2cdc..3f9c2251324 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MergeAction.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MergeAction.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MergeHistory.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MergeHistory.cs index b06a0333dcb..d01204b727d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MergeHistory.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MergeHistory.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MergeHistoryItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MergeHistoryItem.cs index 737b45dfffe..2f061abafbb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MergeHistoryItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MergeHistoryItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MessageBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MessageBox.cs index d49370a457a..288004adffc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MessageBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MessageBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxButtons.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxButtons.cs index 314d6f4bc13..7c576ce83d9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxButtons.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxButtons.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxDefaultButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxDefaultButton.cs index 67a68ad46ce..a80ef25ec5e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxDefaultButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxDefaultButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxIcon.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxIcon.cs index bd5d84aead5..8473129c14f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxIcon.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxIcon.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxOptions.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxOptions.cs index bc0c5a8a9a5..f30cc37a65c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxOptions.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MessageBoxOptions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MethodInvoker.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MethodInvoker.cs index 44ca426445e..8566cf1e144 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MethodInvoker.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MethodInvoker.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarAccessibleObject.cs index c1a2a338376..721a151a134 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarBodyAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarBodyAccessibleObject.cs index 0698c4d78d0..ab53afaeda7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarBodyAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarBodyAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarButtonAccessibleObject.cs index b0b3d05b097..8f14aadae40 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.InteropServices; @@ -120,7 +119,7 @@ private static unsafe void SendMouseInput(int x, int y, MOUSE_EVENT_FLAGS flags) flags |= MOUSE_EVENT_FLAGS.MOUSEEVENTF_VIRTUALDESK; } - INPUT mouseInput = default(INPUT); + INPUT mouseInput = default; mouseInput.type = INPUT_TYPE.INPUT_MOUSE; mouseInput.Anonymous.mi.dx = x; mouseInput.Anonymous.mi.dy = y; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarCellAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarCellAccessibleObject.cs index 6ad4e2daaaf..93c04ef230c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarCellAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarCellAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarDayOfWeekCellAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarDayOfWeekCellAccessibleObject.cs index f1b54f815d7..93646a0c486 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarDayOfWeekCellAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarDayOfWeekCellAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarHeaderAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarHeaderAccessibleObject.cs index 0a10b0d9332..6ba632fbcdc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarHeaderAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarHeaderAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarNextButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarNextButtonAccessibleObject.cs index f694414db33..2c9aa9ed099 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarNextButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarNextButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarPreviousButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarPreviousButtonAccessibleObject.cs index 8a3c4f0d852..e5a3c7554e5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarPreviousButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarPreviousButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarRowAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarRowAccessibleObject.cs index e1ee90ab0d6..45a44d53b17 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarRowAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarRowAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarTodayLinkAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarTodayLinkAccessibleObject.cs index 53e32b1cfa6..ccd3f4a5f86 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarTodayLinkAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarTodayLinkAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarWeekNumberCellAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarWeekNumberCellAccessibleObject.cs index e4002adc4dd..66bc74229ff 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarWeekNumberCellAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarWeekNumberCellAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.HitTestInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.HitTestInfo.cs index eecaf37eed0..e3dd0c4c311 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.HitTestInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.HitTestInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.MonthCalendarAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.MonthCalendarAccessibleObject.cs index caca3d71b1f..eda7d1d13b5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.MonthCalendarAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.MonthCalendarAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.MonthCalendarChildAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.MonthCalendarChildAccessibleObject.cs index ddab2b213bf..8ceae1a959f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.MonthCalendarChildAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.MonthCalendarChildAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.cs index 4b34274aa47..83362dea105 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -322,7 +321,7 @@ protected override CreateParams CreateParams protected override ImeMode DefaultImeMode => ImeMode.Disable; - protected override Padding DefaultMargin => new Padding(9); + protected override Padding DefaultMargin => new(9); protected override Size DefaultSize => GetMinReqRect(); @@ -767,7 +766,7 @@ public DateTime SelectionStart [Bindable(true)] public SelectionRange SelectionRange { - get => new SelectionRange(SelectionStart, SelectionEnd); + get => new(SelectionStart, SelectionEnd); set => SetSelectionRange(value.Start, value.End); } @@ -857,7 +856,7 @@ public Size SingleMonthSize { if (IsHandleCreated) { - RECT rect = default(RECT); + RECT rect = default; if (PInvoke.SendMessage(this, PInvoke.MCM_GETMINREQRECT, 0, ref rect) == 0) { throw new InvalidOperationException(SR.InvalidSingleMonthSize); @@ -921,7 +920,7 @@ public DateTime TodayDate if (IsHandleCreated) { - SYSTEMTIME systemTime = default(SYSTEMTIME); + SYSTEMTIME systemTime = default; int result = (int)PInvoke.SendMessage(this, PInvoke.MCM_GETTODAY, 0, ref systemTime); Debug.Assert(result != 0, "MCM_GETTODAY failed"); return ((DateTime)systemTime).Date; @@ -1384,7 +1383,7 @@ public unsafe HitTestInfo HitTest(int x, int y) { cbSize = (uint)sizeof(MCHITTESTINFO), pt = new Point(x, y), - st = default(SYSTEMTIME) + st = default }; PInvoke.SendMessage(this, PInvoke.MCM_HITTEST, 0, ref mchi); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MouseButtons.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MouseButtons.cs index 27cc3271d0f..2c703ee9f4a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MouseButtons.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MouseButtons.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MouseEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MouseEventArgs.cs index 1c3f584c40e..9ce58ef91c0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MouseEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MouseEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MouseEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MouseEventHandler.cs index ea6880d2091..517d0ce00c5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MouseEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MouseEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MouseHoverTimer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MouseHoverTimer.cs index 251a2e19436..3be8b9018cc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MouseHoverTimer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MouseHoverTimer.cs @@ -1,12 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; internal class MouseHoverTimer : IDisposable { - private Timer _mouseHoverTimer = new Timer(); + private Timer _mouseHoverTimer = new(); // Consider - weak reference? private ToolStripItem? _currentItem; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/NativeWindow.WindowClass.cs b/src/System.Windows.Forms/src/System/Windows/Forms/NativeWindow.WindowClass.cs index 6c68b4a2e33..0e3aa2cdbba 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/NativeWindow.WindowClass.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/NativeWindow.WindowClass.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.InteropServices; @@ -118,7 +117,7 @@ private static string GetFullClassName(string className) /// private unsafe void RegisterClass() { - WNDCLASSW windowClass = default(WNDCLASSW); + WNDCLASSW windowClass = default; string? localClassName = _className; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/NativeWindow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/NativeWindow.cs index fe6b9ab3db0..02da170d023 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/NativeWindow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/NativeWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.ConstrainedExecution; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/NavigateEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/NavigateEventArgs.cs index aa9097d9d9e..4e3a9883fd4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/NavigateEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/NavigateEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/NavigateEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/NavigateEventHandler.cs index 23cc36234a1..3b3a2dea16f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/NavigateEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/NavigateEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/NodeLabelEditEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/NodeLabelEditEventArgs.cs index c075089d307..40561d1a1d8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/NodeLabelEditEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/NodeLabelEditEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/NodeLabelEditEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/NodeLabelEditEventHandler.cs index 9ecd22944be..1bb1bfcf38d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/NodeLabelEditEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/NodeLabelEditEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/NoneExcludedImageIndexConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/NoneExcludedImageIndexConverter.cs index ed0dc667451..d243c065668 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/NoneExcludedImageIndexConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/NoneExcludedImageIndexConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/NotifyIcon.NotifyIconNativeWindow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/NotifyIcon.NotifyIconNativeWindow.cs index 1a41eb866f9..22abf85528e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/NotifyIcon.NotifyIconNativeWindow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/NotifyIcon.NotifyIconNativeWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/NotifyIcon.cs b/src/System.Windows.Forms/src/System/Windows/Forms/NotifyIcon.cs index f935952518f..bb92ad1bdc3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/NotifyIcon.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/NotifyIcon.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -21,21 +20,21 @@ namespace System.Windows.Forms; public sealed partial class NotifyIcon : Component { internal const int MaxTextSize = 127; - private static readonly object EVENT_MOUSEDOWN = new object(); - private static readonly object EVENT_MOUSEMOVE = new object(); - private static readonly object EVENT_MOUSEUP = new object(); - private static readonly object EVENT_CLICK = new object(); - private static readonly object EVENT_DOUBLECLICK = new object(); - private static readonly object EVENT_MOUSECLICK = new object(); - private static readonly object EVENT_MOUSEDOUBLECLICK = new object(); - private static readonly object EVENT_BALLOONTIPSHOWN = new object(); - private static readonly object EVENT_BALLOONTIPCLICKED = new object(); - private static readonly object EVENT_BALLOONTIPCLOSED = new object(); + private static readonly object EVENT_MOUSEDOWN = new(); + private static readonly object EVENT_MOUSEMOVE = new(); + private static readonly object EVENT_MOUSEUP = new(); + private static readonly object EVENT_CLICK = new(); + private static readonly object EVENT_DOUBLECLICK = new(); + private static readonly object EVENT_MOUSECLICK = new(); + private static readonly object EVENT_MOUSEDOUBLECLICK = new(); + private static readonly object EVENT_BALLOONTIPSHOWN = new(); + private static readonly object EVENT_BALLOONTIPCLICKED = new(); + private static readonly object EVENT_BALLOONTIPCLOSED = new(); private const int WM_TRAYMOUSEMESSAGE = (int)PInvoke.WM_USER + 1024; private static readonly MessageId WM_TASKBARCREATED = PInvoke.RegisterWindowMessage("TaskbarCreated"); - private readonly object _syncObj = new object(); + private readonly object _syncObj = new(); private Icon? _icon; private string _text = string.Empty; @@ -569,13 +568,14 @@ public unsafe void ShowBalloonTip(int timeout, string tipTitle, string tipText, return; } - var data = new NOTIFYICONDATAW + NOTIFYICONDATAW data = new() { cbSize = (uint)sizeof(NOTIFYICONDATAW), uFlags = NIF.INFO, uID = _id, uTimeoutOrVersion = (uint)timeout }; + if (_window.Handle == IntPtr.Zero) { _window.CreateHandle(new CreateParams()); @@ -639,13 +639,14 @@ private unsafe void UpdateIcon(bool showIconInTray) _window.LockReference(showIconInTray); - var data = new NOTIFYICONDATAW + NOTIFYICONDATAW data = new() { cbSize = (uint)sizeof(NOTIFYICONDATAW), uCallbackMessage = WM_TRAYMOUSEMESSAGE, uFlags = NIF.MESSAGE, uID = _id }; + if (showIconInTray) { if (_window.Handle == IntPtr.Zero) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/NumericUpDown.cs b/src/System.Windows.Forms/src/System/Windows/Forms/NumericUpDown.cs index f8c0d3cadc4..ce3fccabeff 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/NumericUpDown.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/NumericUpDown.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/NumericUpDownAcceleration.cs b/src/System.Windows.Forms/src/System/Windows/Forms/NumericUpDownAcceleration.cs index 840add4a650..a69d1f47ecf 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/NumericUpDownAcceleration.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/NumericUpDownAcceleration.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/NumericUpDownAccelerationCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/NumericUpDownAccelerationCollection.cs index 3843cc30057..71a34368c5c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/NumericUpDownAccelerationCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/NumericUpDownAccelerationCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/OSFeature.cs b/src/System.Windows.Forms/src/System/Windows/Forms/OSFeature.cs index d40a15854e5..39896d024d3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/OSFeature.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/OSFeature.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -13,12 +12,12 @@ public class OSFeature : FeatureSupport /// Represents the layered, top-level windows feature. This field /// is read-only. /// - public static readonly object LayeredWindows = new object(); + public static readonly object LayeredWindows = new(); /// /// Determines if the OS supports themes /// - public static readonly object Themes = new object(); + public static readonly object Themes = new(); private static OSFeature? _feature; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/OpacityConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/OpacityConverter.cs index ba66670add2..304e0c58096 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/OpacityConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/OpacityConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/OpenFileDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/OpenFileDialog.cs index fb65827bf06..39e0c130f1c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/OpenFileDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/OpenFileDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Orientation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Orientation.cs index 7585426f6ec..3d72c0a485f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Orientation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Orientation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/OwnedObjectExtensions.cs b/src/System.Windows.Forms/src/System/Windows/Forms/OwnedObjectExtensions.cs index 7d5e3304ffb..5b77d7f6cf6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/OwnedObjectExtensions.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/OwnedObjectExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/OwnerDrawPropertyBag.cs b/src/System.Windows.Forms/src/System/Windows/Forms/OwnerDrawPropertyBag.cs index e9c75e69805..0e2c6984ad4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/OwnerDrawPropertyBag.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/OwnerDrawPropertyBag.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Runtime.Serialization; @@ -14,7 +13,7 @@ namespace System.Windows.Forms; public class OwnerDrawPropertyBag : MarshalByRefObject, ISerializable { private Control.FontHandleWrapper? _fontWrapper; - private static readonly object s_internalSyncObject = new object(); + private static readonly object s_internalSyncObject = new(); protected OwnerDrawPropertyBag(SerializationInfo info, StreamingContext context) { @@ -71,7 +70,7 @@ public static OwnerDrawPropertyBag Copy(OwnerDrawPropertyBag? value) { lock (s_internalSyncObject) { - var result = new OwnerDrawPropertyBag(); + OwnerDrawPropertyBag result = new(); if (value is null) { return result; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PaintEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PaintEventArgs.cs index 1bc8a7ab48c..78531064bde 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PaintEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PaintEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Drawing2D; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PaintEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PaintEventHandler.cs index 6cecc208dd9..2d907c2c0d8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PaintEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PaintEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Panel.PanelAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Panel.PanelAccessibleObject.cs index fed8bcdfbba..6eccbdbd00b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Panel.PanelAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Panel.PanelAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Panel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Panel.cs index fdfd8c3b3fb..d015f3b18be 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Panel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Panel.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -143,7 +142,7 @@ protected override CreateParams CreateParams /// Deriving classes can override this to configure a default size for their control. /// This is more efficient than setting the size in the control's constructor. /// - protected override Size DefaultSize => new Size(200, 100); + protected override Size DefaultSize => new(200, 100); internal override Size GetPreferredSizeCore(Size proposedSize) { @@ -226,7 +225,7 @@ private protected override void PrintToMetaFileRecursive(HDC hDC, IntPtr lParam, { base.PrintToMetaFileRecursive(hDC, lParam, bounds); - using var mapping = new DCMapping(hDC, bounds); + using DCMapping mapping = new(hDC, bounds); using Graphics g = hDC.CreateGraphics(); ControlPaint.PrintBorder(g, new Rectangle(Point.Empty, Size), BorderStyle, Border3DStyle.Sunken); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.ImageInstallationType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.ImageInstallationType.cs index 80e57dd5dfa..3d74ec61de0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.ImageInstallationType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.ImageInstallationType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.PictureBoxAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.PictureBoxAccessibleObject.cs index 3a92463556d..48b20676c3e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.PictureBoxAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.PictureBoxAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.cs index a3e01013643..fb60605bf0b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -62,7 +61,7 @@ public partial class PictureBox : Control, ISupportInitialize private SendOrPostCallback _loadCompletedDelegate; private SendOrPostCallback _loadProgressDelegate; private bool _handleValid; - private readonly object _internalSyncObject = new object(); + private readonly object _internalSyncObject = new(); // These default images will be demand loaded. private Image _defaultInitialImage; @@ -74,8 +73,8 @@ public partial class PictureBox : Control, ISupportInitialize [ThreadStatic] private static Image t_defaultErrorImageForThread; - private static readonly object s_loadCompletedKey = new object(); - private static readonly object s_loadProgressChangedKey = new object(); + private static readonly object s_loadCompletedKey = new(); + private static readonly object s_loadProgressChangedKey = new(); private const int AsyncOperationInProgressState = 0x00000001; private const int CancellationPendingState = 0x00000002; @@ -214,7 +213,7 @@ protected override CreateParams CreateParams /// Deriving classes can override this to configure a default size for their control. /// This is more efficient than setting the size in the control's constructor. /// - protected override Size DefaultSize => new Size(100, 50); + protected override Size DefaultSize => new(100, 50); [SRCategory(nameof(SR.CatAsynchronous))] [Localizable(true)] @@ -876,7 +875,7 @@ public PictureBoxSizeMode SizeMode } } - private static readonly object EVENT_SIZEMODECHANGED = new object(); + private static readonly object EVENT_SIZEMODECHANGED = new(); [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.PictureBoxOnSizeModeChangedDescr))] diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PictureBoxSizeMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PictureBoxSizeMode.cs index 986535a3670..d251c206818 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PictureBoxSizeMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PictureBoxSizeMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PopupEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PopupEventArgs.cs index 5d8d9234567..c10a065ca36 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PopupEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PopupEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PopupEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PopupEventHandler.cs index 955698e300b..a7d4295b50a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PopupEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PopupEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PowerLineStatus.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PowerLineStatus.cs index 16f2b8b2ab3..86d0f43e24f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PowerLineStatus.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PowerLineStatus.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PowerState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PowerState.cs index c4ac6d34d5f..342791a1d1d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PowerState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PowerState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PowerStatus.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PowerStatus.cs index 776fd91a492..eba3caa5f2d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PowerStatus.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PowerStatus.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Power; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PreProcessControlState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PreProcessControlState.cs index a42724d5cec..ffdf8d9f987 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PreProcessControlState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PreProcessControlState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PreviewKeyDownEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PreviewKeyDownEventArgs.cs index 70d84630e7d..2c903ea80ae 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PreviewKeyDownEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PreviewKeyDownEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PreviewKeyDownEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PreviewKeyDownEventHandler.cs index ad651deee04..a29addf8ba0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PreviewKeyDownEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PreviewKeyDownEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PrintPreviewControl.PrintPreviewControlAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PrintPreviewControl.PrintPreviewControlAccessibleObject.cs deleted file mode 100644 index c1f72860c3c..00000000000 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PrintPreviewControl.PrintPreviewControlAccessibleObject.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Drawing; -using static Interop; - -namespace System.Windows.Forms; - -public partial class PrintPreviewControl -{ - internal class PrintPreviewControlAccessibleObject : ControlAccessibleObject - { - public PrintPreviewControlAccessibleObject(PrintPreviewControl owner) : base(owner) - { - } - - internal override object? GetPropertyValue(UiaCore.UIA propertyID) - => !this.TryGetOwnerAs(out PrintPreviewControl? owner) ? null : propertyID switch - { - UiaCore.UIA.AutomationIdPropertyId => owner.Name, - UiaCore.UIA.HasKeyboardFocusPropertyId => owner.Focused, - UiaCore.UIA.IsKeyboardFocusablePropertyId => (State & AccessibleStates.Focusable) == AccessibleStates.Focusable, - _ => base.GetPropertyValue(propertyID) - }; - - internal override Rectangle BoundingRectangle - => this.IsOwnerHandleCreated(out PrintPreviewControl? owner) && owner.Parent is not null - ? owner.GetToolNativeScreenRectangle() - : Rectangle.Empty; - } -} diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PageSetupDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PageSetupDialog.cs index a09277599e7..c1e20a48ce0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PageSetupDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PageSetupDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Printing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintControllerWithStatusDialog.BackgroundThread.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintControllerWithStatusDialog.BackgroundThread.cs index 06b39858829..a8f5614c11d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintControllerWithStatusDialog.BackgroundThread.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintControllerWithStatusDialog.BackgroundThread.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintControllerWithStatusDialog.StatusDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintControllerWithStatusDialog.StatusDialog.cs index 70d8b5417ca..d8c0fd191ef 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintControllerWithStatusDialog.StatusDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintControllerWithStatusDialog.StatusDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintControllerWithStatusDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintControllerWithStatusDialog.cs index ea255de4688..e10b1e3d4ee 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintControllerWithStatusDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintControllerWithStatusDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Printing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintDialog.cs index 7f809852d0f..0c38d7e11e0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Printing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.HorizontalScrollBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.HorizontalScrollBar.cs new file mode 100644 index 00000000000..3e6d05c46a5 --- /dev/null +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.HorizontalScrollBar.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Windows.Forms; + +public partial class PrintPreviewControl : Control +{ + internal class HorizontalScrollBar : HScrollBar + { + protected override AccessibleObject CreateAccessibilityInstance() + { + return new PrintPreviewControl.ScrollBarAccessibleObject(this); + } + } +} diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.PrintPreviewControlAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.PrintPreviewControlAccessibleObject.cs new file mode 100644 index 00000000000..db377c0ac49 --- /dev/null +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.PrintPreviewControlAccessibleObject.cs @@ -0,0 +1,212 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using static Interop; +using IScrollProvider = Windows.Win32.UI.Accessibility.IScrollProvider; +using ScrollAmount = Windows.Win32.UI.Accessibility.ScrollAmount; + +namespace System.Windows.Forms; + +public partial class PrintPreviewControl +{ + internal class PrintPreviewControlAccessibleObject : ControlAccessibleObject, IScrollProvider.Interface + { + public PrintPreviewControlAccessibleObject(PrintPreviewControl owner) : base(owner) + { + } + + internal override object? GetPropertyValue(UiaCore.UIA propertyID) + => !this.TryGetOwnerAs(out PrintPreviewControl? owner) ? null : propertyID switch + { + UiaCore.UIA.AutomationIdPropertyId => owner.Name, + UiaCore.UIA.HasKeyboardFocusPropertyId => owner.Focused, + UiaCore.UIA.IsKeyboardFocusablePropertyId => (State & AccessibleStates.Focusable) == AccessibleStates.Focusable, + _ => base.GetPropertyValue(propertyID) + }; + + public override int GetChildCount() + { + if (!this.TryGetOwnerAs(out PrintPreviewControl? owner)) + { + return 0; + } + + return owner._vScrollBar.Visible + ? owner._hScrollBar.Visible ? 2 : 1 + : owner._hScrollBar.Visible ? 1 : 0; + } + + public override AccessibleObject? GetChild(int index) + { + if (!this.TryGetOwnerAs(out PrintPreviewControl? owner)) + { + return null; + } + + return index switch + { + 0 => owner._vScrollBar.Visible ? owner._vScrollBar.AccessibilityObject + : owner._hScrollBar.Visible ? owner._hScrollBar.AccessibilityObject : null, + + 1 => owner._vScrollBar.Visible && owner._hScrollBar.Visible ? owner._hScrollBar.AccessibilityObject : null, + + _ => null + }; + } + + internal override bool IsPatternSupported(UiaCore.UIA patternId) + => patternId switch + { + UiaCore.UIA.ScrollPatternId => this.TryGetOwnerAs(out PrintPreviewControl? owner) + && (owner._vScrollBar.Visible || owner._hScrollBar.Visible), + _ => base.IsPatternSupported(patternId) + }; + + internal override UiaCore.IRawElementProviderFragmentRoot FragmentRoot + => this; + + internal override UiaCore.IRawElementProviderFragment? FragmentNavigate(UiaCore.NavigateDirection direction) + { + if (!this.TryGetOwnerAs(out PrintPreviewControl? owner)) + { + return base.FragmentNavigate(direction); + } + + switch (direction) + { + case UiaCore.NavigateDirection.FirstChild: + return owner._vScrollBar.Visible ? owner._vScrollBar.AccessibilityObject + : owner._hScrollBar.Visible ? owner._hScrollBar.AccessibilityObject + : null; + + case UiaCore.NavigateDirection.LastChild: + return owner._hScrollBar.Visible ? owner._hScrollBar.AccessibilityObject + : owner._vScrollBar.Visible ? owner._vScrollBar.AccessibilityObject + : null; + + default: + return base.FragmentNavigate(direction); + } + } + + HRESULT IScrollProvider.Interface.Scroll(ScrollAmount horizontalAmount, ScrollAmount verticalAmount) + { + if (!this.TryGetOwnerAs(out PrintPreviewControl? owner)) + { + return HRESULT.E_FAIL; + } + + int scrollValue = 0; + if (owner._hScrollBar.Visible && horizontalAmount != ScrollAmount.ScrollAmount_NoAmount) + { + switch (horizontalAmount) + { + case ScrollAmount.ScrollAmount_LargeIncrement: + scrollValue = owner._hScrollBar.Value + owner._hScrollBar.LargeChange; + owner._hScrollBar.Value = (scrollValue > owner._hScrollBar.Maximum ? owner._hScrollBar.Maximum : scrollValue); + break; + case ScrollAmount.ScrollAmount_SmallIncrement: + scrollValue = owner._hScrollBar.Value + owner._hScrollBar.SmallChange; + owner._hScrollBar.Value = (scrollValue > owner._hScrollBar.Maximum ? owner._hScrollBar.Maximum : scrollValue); + break; + case ScrollAmount.ScrollAmount_LargeDecrement: + scrollValue = owner._hScrollBar.Value - owner._hScrollBar.LargeChange; + owner._hScrollBar.Value = (scrollValue < owner._hScrollBar.Minimum ? owner._hScrollBar.Minimum : scrollValue); + break; + case ScrollAmount.ScrollAmount_SmallDecrement: + scrollValue = owner._hScrollBar.Value - owner._hScrollBar.SmallChange; + owner._hScrollBar.Value = (scrollValue < owner._hScrollBar.Minimum ? owner._hScrollBar.Minimum : scrollValue); + break; + } + } + + if (owner._vScrollBar.Visible && verticalAmount != ScrollAmount.ScrollAmount_NoAmount) + { + switch (verticalAmount) + { + case ScrollAmount.ScrollAmount_LargeIncrement: + scrollValue = owner._vScrollBar.Value + owner._vScrollBar.LargeChange; + owner._vScrollBar.Value = (scrollValue > owner._vScrollBar.Maximum ? owner._vScrollBar.Maximum : scrollValue); + break; + case ScrollAmount.ScrollAmount_SmallIncrement: + scrollValue = owner._vScrollBar.Value + owner._vScrollBar.SmallChange; + owner._vScrollBar.Value = (scrollValue > owner._vScrollBar.Maximum ? owner._vScrollBar.Maximum : scrollValue); + break; + case ScrollAmount.ScrollAmount_LargeDecrement: + scrollValue = owner._vScrollBar.Value - owner._vScrollBar.LargeChange; + owner._vScrollBar.Value = (scrollValue < owner._vScrollBar.Minimum ? owner._vScrollBar.Minimum : scrollValue); + break; + case ScrollAmount.ScrollAmount_SmallDecrement: + scrollValue = owner._vScrollBar.Value - owner._vScrollBar.SmallChange; + owner._vScrollBar.Value = (scrollValue < owner._vScrollBar.Minimum ? owner._vScrollBar.Minimum : scrollValue); + break; + } + } + + return HRESULT.S_OK; + } + + HRESULT IScrollProvider.Interface.SetScrollPercent(double horizontalPercent, double verticalPercent) + { + if (!this.TryGetOwnerAs(out PrintPreviewControl? owner)) + { + return HRESULT.E_FAIL; + } + + int scrollValue = 0; + if (owner._hScrollBar.Visible && horizontalPercent >= 0 && horizontalPercent <= 100) + { + scrollValue = owner._hScrollBar.Minimum + (int)((owner._hScrollBar.Maximum - owner._hScrollBar.Minimum) * horizontalPercent); + owner._hScrollBar.Value = scrollValue; + } + + if (owner._vScrollBar.Visible && verticalPercent >= 0 && verticalPercent <= 100) + { + scrollValue = owner._vScrollBar.Minimum + (int)((owner._vScrollBar.Maximum - owner._vScrollBar.Minimum) * verticalPercent); + owner._vScrollBar.Value = scrollValue; + } + + return HRESULT.S_OK; + } + + public double HorizontalScrollPercent + { + get + { + if (this.TryGetOwnerAs(out PrintPreviewControl? owner) && owner._hScrollBar.Visible) + { + double percent = owner._hScrollBar.Value * 100.0 / (owner._hScrollBar.Maximum - owner._hScrollBar.LargeChange); + return percent > 100 ? 100 : percent; + } + + return 0; + } + } + + public double VerticalScrollPercent + { + get + { + if (this.TryGetOwnerAs(out PrintPreviewControl? owner) && owner._vScrollBar.Visible) + { + double percent = owner._vScrollBar.Value * 100.0 / (owner._vScrollBar.Maximum - owner._vScrollBar.LargeChange); + return percent > 100 ? 100 : percent; + } + + return 0; + } + } + + public double HorizontalViewSize => this.TryGetOwnerAs(out PrintPreviewControl? owner) + && owner._hScrollBar.Visible ? owner.HorizontalViewSize : 100; + + public double VerticalViewSize => this.TryGetOwnerAs(out PrintPreviewControl? owner) + && owner._vScrollBar.Visible ? owner.VerticalViewSize : 100; + + BOOL IScrollProvider.Interface.HorizontallyScrollable => + this.TryGetOwnerAs(out PrintPreviewControl? owner) && owner._hScrollBar.Visible; + + BOOL IScrollProvider.Interface.VerticallyScrollable => + this.TryGetOwnerAs(out PrintPreviewControl? owner) && owner._vScrollBar.Visible; + } +} diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.ScrollBarAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.ScrollBarAccessibleObject.cs new file mode 100644 index 00000000000..ffa53b78e17 --- /dev/null +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.ScrollBarAccessibleObject.cs @@ -0,0 +1,49 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using static Interop; + +namespace System.Windows.Forms; + +public partial class PrintPreviewControl +{ + internal class ScrollBarAccessibleObject : ScrollBar.ScrollBarAccessibleObject + { + public ScrollBarAccessibleObject(ScrollBar owner) : base(owner) + { + } + + public override AccessibleObject? Parent + => this.TryGetOwnerAs(out ScrollBar? scrollBar) && scrollBar.Parent is PrintPreviewControl printPreviewControl + ? printPreviewControl.AccessibilityObject : base.Parent; + + internal override UiaCore.IRawElementProviderFragment? FragmentNavigate(UiaCore.NavigateDirection direction) + { + if (!this.TryGetOwnerAs(out ScrollBar? scrollBar) || scrollBar.Parent is not PrintPreviewControl printPreviewControl) + { + return null; + } + + switch (direction) + { + case UiaCore.NavigateDirection.Parent: + return printPreviewControl.AccessibilityObject; + + case UiaCore.NavigateDirection.NextSibling: + return printPreviewControl._vScrollBar.Visible && + printPreviewControl._hScrollBar.Visible && + scrollBar == printPreviewControl._vScrollBar + ? printPreviewControl._hScrollBar.AccessibilityObject : null; + + case UiaCore.NavigateDirection.PreviousSibling: + return printPreviewControl._hScrollBar.Visible && + printPreviewControl._vScrollBar.Visible && + scrollBar == printPreviewControl._hScrollBar + ? printPreviewControl._vScrollBar.AccessibilityObject : null; + + default: + return base.FragmentNavigate(direction); + } + } + } +} diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.VerticalScrollBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.VerticalScrollBar.cs new file mode 100644 index 00000000000..421d6f64666 --- /dev/null +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.VerticalScrollBar.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Windows.Forms; + +public partial class PrintPreviewControl : Control +{ + internal class VerticalScrollBar : VScrollBar + { + protected override AccessibleObject CreateAccessibilityInstance() + { + return new PrintPreviewControl.ScrollBarAccessibleObject(this); + } + } +} diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.cs index cec0bb1a2cb..b48a0166526 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -18,31 +17,32 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionPrintPreviewControl))] public partial class PrintPreviewControl : Control { - private Size virtualSize = new Size(1, 1); - private Point position = new Point(0, 0); - private Point lastOffset; - private bool antiAlias; - - private const int SCROLL_PAGE = 100; - private const int SCROLL_LINE = 5; + private const int ScrollSmallChange = 5; private const double DefaultZoom = .3; - - private const int border = 10; // spacing per page, in mm - - private PrintDocument? document; - private PreviewPageInfo[]? pageInfo; // null if needs refreshing - private int startPage; // 0-based - private int rows = 1; - private int columns = 1; - private bool autoZoom = true; + private const int Border = 10; // spacing per page, in mm + + private PrintDocument? _document; + private PreviewPageInfo[]? _pageInfo; // null if needs refreshing + private int _startPage; // 0-based + private int _rows = 1; + private int _columns = 1; + private bool _autoZoom = true; + private Size _virtualSize = new(1, 1); + private Point _position = new(0, 0); + + private readonly int _focusHOffset = SystemInformation.HorizontalFocusThickness; + private readonly int _focusVOffset = SystemInformation.VerticalFocusThickness; + private HScrollBar _hScrollBar = new HorizontalScrollBar(); + private VScrollBar _vScrollBar = new VerticalScrollBar(); + private bool _scrollLayoutPending; // The following are all computed by ComputeLayout - private bool layoutOk; - private Size imageSize = System.Drawing.Size.Empty; // 100ths of inch, not pixels - private Point screendpi = Point.Empty; - private double zoom = DefaultZoom; - private bool pageInfoCalcPending; - private bool exceptionPrinting; + private bool _layoutOk; + private Size _imageSize = Size.Empty; // 100ths of inch, not pixels + private Point _screenDPI = Point.Empty; + private double _zoom = DefaultZoom; + private bool _pageInfoCalcPending; + private bool _exceptionPrinting; /// /// Initializes a new instance of the class. @@ -53,8 +53,27 @@ public PrintPreviewControl() ResetForeColor(); Size = new Size(100, 100); SetStyle(ControlStyles.ResizeRedraw, false); - SetStyle(ControlStyles.Opaque | ControlStyles.OptimizedDoubleBuffer, true); + SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true); TabStop = false; + + _hScrollBar.AccessibleName = SR.HScrollBarDefaultAccessibleName; + _hScrollBar.Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right; + _hScrollBar.Left = _focusHOffset; + _hScrollBar.SmallChange = ScrollSmallChange; + _hScrollBar.RightToLeft = RightToLeft.No; + _hScrollBar.Visible = false; + _hScrollBar.ValueChanged += scrollBar_ValueChanged; + _hScrollBar.TabStop = false; + Controls.Add(_hScrollBar); + + _vScrollBar.AccessibleName = SR.VScrollBarDefaultAccessibleName; + _vScrollBar.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; + _vScrollBar.SmallChange = ScrollSmallChange; + _vScrollBar.Top = _focusVOffset; + _vScrollBar.Visible = false; + _vScrollBar.ValueChanged += scrollBar_ValueChanged; + _vScrollBar.TabStop = false; + Controls.Add(_vScrollBar); } [SRCategory(nameof(SR.CatBehavior))] @@ -62,14 +81,7 @@ public PrintPreviewControl() [SRDescription(nameof(SR.PrintPreviewAntiAliasDescr))] public bool UseAntiAlias { - get - { - return antiAlias; - } - set - { - antiAlias = value; - } + get; set; } /// @@ -81,17 +93,39 @@ public bool UseAntiAlias [SRDescription(nameof(SR.PrintPreviewAutoZoomDescr))] public bool AutoZoom { - get { return autoZoom; } + get { return _autoZoom; } set { - if (autoZoom != value) + if (_autoZoom != value) { - autoZoom = value; + _autoZoom = value; InvalidateLayout(); } } } + /// + /// Gets or sets a value indicating how large the pages will appear. + /// + [SRCategory(nameof(SR.CatBehavior))] + [SRDescription(nameof(SR.PrintPreviewZoomDescr))] + [DefaultValue(DefaultZoom)] + public double Zoom + { + get { return _zoom; } + set + { + if (value <= 0) + { + throw new ArgumentException(SR.PrintPreviewControlZoomNegative); + } + + _autoZoom = false; + _zoom = value; + InvalidateLayout(); + } + } + /// /// Gets or sets a value indicating the document to preview. /// @@ -100,86 +134,110 @@ public bool AutoZoom [SRDescription(nameof(SR.PrintPreviewDocumentDescr))] public PrintDocument? Document { - get { return document; } + get { return _document; } set { - document = value; + _document = value; InvalidatePreview(); } } /// /// Gets or sets the number of pages - /// displayed horizontally across the screen. + /// displayed vertically down the screen. /// [DefaultValue(1)] - [SRCategory(nameof(SR.CatLayout))] - [SRDescription(nameof(SR.PrintPreviewColumnsDescr))] - public int Columns + [SRDescription(nameof(SR.PrintPreviewRowsDescr))] + [SRCategory(nameof(SR.CatBehavior))] + public int Rows { - get { return columns; } + get { return _rows; } set { if (value < 1) { - throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(SR.InvalidLowBoundArgumentEx, nameof(Columns), value, 1)); + throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(SR.InvalidLowBoundArgumentEx, nameof(Rows), value, 1)); } - columns = value; + _rows = value; InvalidateLayout(); } } /// - /// Gets the CreateParams used to create the window. - /// If a subclass overrides this function, it must call the base implementation. - /// - protected override CreateParams CreateParams - { - get - { - CreateParams cp = base.CreateParams; - cp.Style |= (int)WINDOW_STYLE.WS_HSCROLL; - cp.Style |= (int)WINDOW_STYLE.WS_VSCROLL; - return cp; - } - } - - /// - /// The virtual coordinate of the upper left visible pixel. + /// Gets or sets the number of pages + /// displayed horizontally across the screen. /// + [DefaultValue(1)] [SRCategory(nameof(SR.CatLayout))] - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [SRDescription(nameof(SR.ControlWithScrollbarsPositionDescr))] - private Point Position + [SRDescription(nameof(SR.PrintPreviewColumnsDescr))] + public int Columns { - get { return position; } + get { return _columns; } set { - SetPositionNoInvalidate(value); + if (value < 1) + { + throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(SR.InvalidLowBoundArgumentEx, nameof(Columns), value, 1)); + } + + _columns = value; + InvalidateLayout(); } } /// - /// Gets or sets the number of pages - /// displayed vertically down the screen. + /// Gets or sets the page number of the upper left page. /// - [DefaultValue(1)] - [SRDescription(nameof(SR.PrintPreviewRowsDescr))] + [DefaultValue(0)] + [SRDescription(nameof(SR.PrintPreviewStartPageDescr))] [SRCategory(nameof(SR.CatBehavior))] - public int Rows + public int StartPage { - get { return rows; } + get + { + int value = _startPage; + if (_pageInfo is not null) + { + value = Math.Min(value, _pageInfo.Length - (_rows * _columns)); + } + + value = Math.Max(value, 0); + + return value; + } set { - if (value < 1) + if (value < 0) { - throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(SR.InvalidLowBoundArgumentEx, nameof(Rows), value, 1)); + throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(SR.InvalidLowBoundArgumentEx, nameof(StartPage), value, 0)); } - rows = value; - InvalidateLayout(); + int oldValue = StartPage; + _startPage = value; + if (oldValue != _startPage) + { + InvalidateLayout(); + OnStartPageChanged(EventArgs.Empty); + } + } + } + + private static readonly object EVENT_STARTPAGECHANGED = new(); + + [SRCategory(nameof(SR.CatPropertyChanged))] + [SRDescription(nameof(SR.RadioButtonOnStartPageChangedDescr))] + public event EventHandler? StartPageChanged + { + add => Events.AddHandler(EVENT_STARTPAGECHANGED, value); + remove => Events.RemoveHandler(EVENT_STARTPAGECHANGED, value); + } + + protected virtual void OnStartPageChanged(EventArgs e) + { + if (Events[EVENT_STARTPAGECHANGED] is EventHandler eh) + { + eh(this, e); } } @@ -202,8 +260,6 @@ public override RightToLeft RightToLeft } } - internal override bool SupportsUiaProviders => true; - [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] [Bindable(false)] @@ -223,69 +279,134 @@ public override string Text remove => base.TextChanged -= value; } + [DefaultValue(false)] + [DispId(PInvoke.DISPID_TABSTOP)] + public new bool TabStop + { + get => base.TabStop; + set => base.TabStop = value; + } + /// - /// Gets or sets the page number of the upper left page. + /// Resets the back color to the defaults for the PrintPreviewControl. /// - [DefaultValue(0)] - [SRDescription(nameof(SR.PrintPreviewStartPageDescr))] - [SRCategory(nameof(SR.CatBehavior))] - public int StartPage + [EditorBrowsable(EditorBrowsableState.Never)] + public override void ResetBackColor() { - get - { - int value = startPage; - if (pageInfo is not null) - { - value = Math.Min(value, pageInfo.Length - (rows * columns)); - } + BackColor = SystemColors.AppWorkspace; + } - value = Math.Max(value, 0); + /// + /// Indicates whether the property should be persisted. + /// + internal override bool ShouldSerializeBackColor() + { + return !BackColor.Equals(SystemColors.AppWorkspace); + } - return value; - } - set + /// + /// Resets the back color to the defaults for the PrintPreviewControl. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override void ResetForeColor() + { + ForeColor = Color.White; + } + + /// + /// Indicates whether the property should be persisted. + /// + internal override bool ShouldSerializeForeColor() + { + return !ForeColor.Equals(Color.White); + } + + internal override bool SupportsUiaProviders => true; + + protected override AccessibleObject CreateAccessibilityInstance() + => new PrintPreviewControlAccessibleObject(this); + + /// + /// Invalidate the layout, if necessary. + /// + protected override void OnResize(EventArgs eventargs) + { + if (!IsHandleCreated) { - if (value < 0) - { - throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(SR.InvalidLowBoundArgumentEx, nameof(StartPage), value, 0)); - } + return; + } - int oldValue = StartPage; - startPage = value; - if (oldValue != startPage) - { - InvalidateLayout(); - OnStartPageChanged(EventArgs.Empty); - } + InvalidateLayout(); + base.OnResize(eventargs); + } + + protected override void OnMouseDown(MouseEventArgs e) + { + if (!Focused) + { + Focus(); } + + base.OnMouseDown(e); } - private static readonly object EVENT_STARTPAGECHANGED = new object(); + protected override void OnGotFocus(EventArgs e) + { + Invalidate(); - [SRCategory(nameof(SR.CatPropertyChanged))] - [SRDescription(nameof(SR.RadioButtonOnStartPageChangedDescr))] - public event EventHandler? StartPageChanged + base.OnGotFocus(e); + } + + protected override void OnLostFocus(EventArgs e) { - add => Events.AddHandler(EVENT_STARTPAGECHANGED, value); - remove => Events.RemoveHandler(EVENT_STARTPAGECHANGED, value); + Invalidate(); + + base.OnLostFocus(e); } - [DefaultValue(false)] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - [DispId(PInvoke.DISPID_TABSTOP)] - public new bool TabStop + protected override void OnPaintBackground(PaintEventArgs e) { - get => base.TabStop; - set => base.TabStop = value; + PaintTransparentBackground(e, ClientRectangle); } - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public new event EventHandler? TabStopChanged + /// + /// Paints the control. + /// + protected override void OnPaint(PaintEventArgs pevent) { - add => base.TabStopChanged += value; - remove => base.TabStopChanged -= value; + bool isHighContrast = SystemInformation.HighContrast; + Color backColor = GetBackColor(isHighContrast); + using var backBrush = backColor.GetCachedSolidBrushScope(); + + PaintResizeBox(pevent, isHighContrast); + PaintFocus(pevent, isHighContrast); + + if (_pageInfo is null || _pageInfo.Length == 0) + { + Rectangle rect = InsideRectangle; + + pevent.Graphics.FillRectangle(backBrush, rect); + + if (_pageInfo is not null || _exceptionPrinting) + { + DrawMessage(pevent.Graphics, rect, _exceptionPrinting, isHighContrast); + } + else + { + BeginInvoke(new MethodInvoker(CalculatePageInfo)); + } + } + else + { + if (!_layoutOk) + { + ComputeLayout(); + } + + DrawPages(pevent.Graphics, InsideRectangle, _pageInfo, backBrush); + } + + base.OnPaint(pevent); // raise paint event } /// @@ -298,7 +419,7 @@ public event EventHandler? StartPageChanged [SRDescription(nameof(SR.ControlWithScrollbarsVirtualSizeDescr))] private Size VirtualSize { - get { return virtualSize; } + get { return _virtualSize; } set { SetVirtualSizeNoInvalidate(value); @@ -307,121 +428,105 @@ private Size VirtualSize } /// - /// Gets or sets a value indicating how large the pages will appear. + /// The virtual coordinate of the upper left visible pixel. /// - [SRCategory(nameof(SR.CatBehavior))] - [SRDescription(nameof(SR.PrintPreviewZoomDescr))] - [DefaultValue(DefaultZoom)] - public double Zoom + [SRCategory(nameof(SR.CatLayout))] + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [SRDescription(nameof(SR.ControlWithScrollbarsPositionDescr))] + private Point Position { - get { return zoom; } + get { return _position; } set { - if (value <= 0) - { - throw new ArgumentException(SR.PrintPreviewControlZoomNegative); - } - - autoZoom = false; - zoom = value; - InvalidateLayout(); + SetPositionNoInvalidate(value); + Invalidate(); } } - private static unsafe int AdjustScroll(Message m, int pos, int maxPos, bool horizontal) - { - switch ((SCROLLBAR_COMMAND)m.WParamInternal.LOWORD) - { - case SCROLLBAR_COMMAND.SB_THUMBPOSITION: - case SCROLLBAR_COMMAND.SB_THUMBTRACK: - SCROLLINFO si = new() - { - cbSize = (uint)sizeof(SCROLLINFO), - fMask = SCROLLINFO_MASK.SIF_TRACKPOS - }; + /// + /// Equal to the vertical percentage of the entire control that is currently viewable. + /// + internal double VerticalViewSize => InsideRectangle.Height * 100.0 / VirtualSize.Height; - SCROLLBAR_CONSTANTS direction = horizontal ? SCROLLBAR_CONSTANTS.SB_HORZ : SCROLLBAR_CONSTANTS.SB_VERT; - pos = PInvoke.GetScrollInfo(m.HWND, direction, ref si) ? si.nTrackPos : m.WParamInternal.HIWORD; - break; - case SCROLLBAR_COMMAND.SB_LINELEFT: - if (pos > SCROLL_LINE) - { - pos -= SCROLL_LINE; - } - else - { - pos = 0; - } + /// + /// Equal to the horizontal percentage of the entire control that is currently viewable. + /// + internal double HorizontalViewSize => InsideRectangle.Width * 100.0 / VirtualSize.Width; - break; - case SCROLLBAR_COMMAND.SB_LINERIGHT: - if (pos < maxPos - SCROLL_LINE) - { - pos += SCROLL_LINE; - } - else - { - pos = maxPos; - } + private Rectangle InnerClientRectangle + { + get + { + Rectangle rect = ClientRectangle; + rect.Inflate(-_focusHOffset, -_focusVOffset); + rect.Width = Math.Max(0, rect.Width - 1); + rect.Height = Math.Max(0, rect.Height - 1); - break; - case SCROLLBAR_COMMAND.SB_PAGELEFT: - if (pos > SCROLL_PAGE) - { - pos -= SCROLL_PAGE; - } - else - { - pos = 0; - } + return rect; + } + } - break; - case SCROLLBAR_COMMAND.SB_PAGERIGHT: - if (pos < maxPos - SCROLL_PAGE) - { - pos += SCROLL_PAGE; - } - else + private Rectangle InsideRectangle + { + get + { + Rectangle rect = InnerClientRectangle; + + if (_hScrollBar.Visible) + { + rect.Height -= _hScrollBar.Height; + } + + if (_vScrollBar.Visible) + { + rect.Width -= _vScrollBar.Width; + + if (RightToLeft == RightToLeft.Yes) { - pos = maxPos; + rect.X += _vScrollBar.Width; } + } - break; + return rect; } - - return pos; } + private Rectangle FocusRectangle + => new(0, 0, Width - 1, Height - 1); + + private Rectangle ResizeBoxRectangle + => new(_vScrollBar.Left, _hScrollBar.Top, _vScrollBar.Width, _hScrollBar.Height); + // This function computes everything in terms of physical size (millimeters), not pixels private void ComputeLayout() { - Debug.Assert(pageInfo is not null, "Must call ComputePreview first"); - layoutOk = true; - if (pageInfo.Length == 0) + Debug.Assert(_pageInfo is not null, "Must call ComputePreview first"); + _layoutOk = true; + if (_pageInfo.Length == 0) { - ClientSize = Size; return; } using GetDcScope hdc = new(HWND); - screendpi = new Point( + _screenDPI = new Point( PInvoke.GetDeviceCaps(hdc, GET_DEVICE_CAPS_INDEX.LOGPIXELSX), PInvoke.GetDeviceCaps(hdc, GET_DEVICE_CAPS_INDEX.LOGPIXELSY)); - Size pageSize = pageInfo[StartPage].PhysicalSize; - Size controlPhysicalSize = new Size(PixelsToPhysical(new Point(Size), screendpi)); + Size pageSize = _pageInfo[StartPage].PhysicalSize; + Size controlPhysicalSize = PixelsToPhysical(Size, _screenDPI); - if (autoZoom) + if (_autoZoom) { - double zoomX = ((double)controlPhysicalSize.Width - border * (columns + 1)) / (columns * pageSize.Width); - double zoomY = ((double)controlPhysicalSize.Height - border * (rows + 1)) / (rows * pageSize.Height); - zoom = Math.Min(zoomX, zoomY); + double zoomX = ((double)controlPhysicalSize.Width - Border * (_columns + 1)) / (_columns * pageSize.Width); + double zoomY = ((double)controlPhysicalSize.Height - Border * (_rows + 1)) / (_rows * pageSize.Height); + _zoom = Math.Min(zoomX, zoomY); } - imageSize = new Size((int)(zoom * pageSize.Width), (int)(zoom * pageSize.Height)); - int virtualX = (imageSize.Width * columns) + border * (columns + 1); - int virtualY = (imageSize.Height * rows) + border * (rows + 1); - SetVirtualSizeNoInvalidate(new Size(PhysicalToPixels(new Point(virtualX, virtualY), screendpi))); + _imageSize = new Size((int)(_zoom * pageSize.Width), (int)(_zoom * pageSize.Height)); + int virtualX = (_imageSize.Width * _columns) + Border * (_columns + 1); + int virtualY = (_imageSize.Height * _rows) + Border * (_rows + 1); + SetVirtualSizeNoInvalidate(PhysicalToPixels(new Size(virtualX, virtualY), _screenDPI)); } // "Prints" the document to memory @@ -429,25 +534,25 @@ private void ComputePreview() { int oldStart = StartPage; - if (document is null) + if (_document is null) { - pageInfo = Array.Empty(); + _pageInfo = Array.Empty(); } else { - PrintController oldController = document.PrintController; + PrintController oldController = _document.PrintController; PreviewPrintController previewController = new PreviewPrintController { UseAntiAlias = UseAntiAlias }; - document.PrintController = new PrintControllerWithStatusDialog(previewController, + _document.PrintController = new PrintControllerWithStatusDialog(previewController, SR.PrintControllerWithStatusDialog_DialogTitlePreview); - document.Print(); - pageInfo = previewController.GetPreviewPageInfo(); - Debug.Assert(pageInfo is not null, $"{nameof(PreviewPrintController)} did not give us preview info."); + _document.Print(); + _pageInfo = previewController.GetPreviewPageInfo(); + Debug.Assert(_pageInfo is not null, $"{nameof(PreviewPrintController)} did not give us preview info."); - document.PrintController = oldController; + _document.PrintController = oldController; } if (oldStart != StartPage) @@ -456,13 +561,16 @@ private void ComputePreview() } } - protected override AccessibleObject CreateAccessibilityInstance() - => new PrintPreviewControlAccessibleObject(this); - // Recomputes the sizes and positions of pages without forcing a new "preview print" private void InvalidateLayout() { - layoutOk = false; + if (!IsHandleCreated) + { + return; + } + + _layoutOk = false; + LayoutScrollBars(); Invalidate(); } @@ -471,31 +579,28 @@ private void InvalidateLayout() /// public void InvalidatePreview() { - pageInfo = null; - exceptionPrinting = false; - InvalidateLayout(); - } + if (!IsHandleCreated) + { + return; + } - /// - /// Invalidate the layout, if necessary. - /// - protected override void OnResize(EventArgs eventargs) - { + _pageInfo = null; + _exceptionPrinting = false; + SetVirtualSizeNoInvalidate(Size.Empty); InvalidateLayout(); - base.OnResize(eventargs); } private void CalculatePageInfo() { - if (pageInfoCalcPending) + if (_pageInfoCalcPending) { return; } - pageInfoCalcPending = true; + _pageInfoCalcPending = true; try { - if (pageInfo is null) + if (_pageInfo is null) { try { @@ -503,7 +608,7 @@ private void CalculatePageInfo() } catch { - exceptionPrinting = true; + _exceptionPrinting = true; throw; } finally @@ -514,294 +619,328 @@ private void CalculatePageInfo() } finally { - pageInfoCalcPending = false; + _pageInfoCalcPending = false; } } - /// - /// Paints the control. - /// - protected override void OnPaint(PaintEventArgs pevent) + private void DrawMessage(Graphics g, Rectangle rect, bool isExceptionPrinting, bool isHighContrast) { - Color backColor = GetBackColor(SystemInformation.HighContrast); - using var backBrush = backColor.GetCachedSolidBrushScope(); + using var brush = ForeColor.GetCachedSolidBrushScope(); - if (pageInfo is null || pageInfo.Length == 0) + using StringFormat format = new() { - pevent.Graphics.FillRectangle(backBrush, ClientRectangle); + Alignment = StringAlignment.Center, + LineAlignment = StringAlignment.Center + }; - if (pageInfo is not null || exceptionPrinting) - { - // Calculate formats - using StringFormat format = new() - { - Alignment = StringAlignment.Center, - LineAlignment = StringAlignment.Center - }; - - // Do actual drawing - using var brush = ForeColor.GetCachedSolidBrushScope(); - pevent.Graphics.DrawString( - exceptionPrinting ? SR.PrintPreviewExceptionPrinting : SR.PrintPreviewNoPages, - Font, - brush, - ClientRectangle, - format); - } - else - { - BeginInvoke(new MethodInvoker(CalculatePageInfo)); - } - } - else - { - if (!layoutOk) - { - ComputeLayout(); - } + string message = isExceptionPrinting + ? SR.PrintPreviewExceptionPrinting + : SR.PrintPreviewNoPages; + + g.DrawString(message, Font, brush, rect, format); + } + + private void DrawPages(Graphics g, Rectangle rect, PreviewPageInfo[] pages, Brush backBrush) + { + using GraphicsClipScope clipScope = new(g); + g.SetClip(rect); - Size controlPhysicalSize = new Size(PixelsToPhysical(new Point(Size), screendpi)); + _position.X = _hScrollBar.Value; + _position.Y = _vScrollBar.Value; - //Point imagePixels = PhysicalToPixels(new Point(imageSize), screendpi); - Point virtualPixels = new Point(VirtualSize); + Size controlPhysicalSize = PixelsToPhysical(rect.Size, _screenDPI); - // center pages on screen if small enough - Point offset = new Point( - Math.Max(0, (Size.Width - virtualPixels.X) / 2), - Math.Max(0, (Size.Height - virtualPixels.Y) / 2)); - offset.X -= Position.X; - offset.Y -= Position.Y; - lastOffset = offset; + // center pages on screen if small enough + Point offset = new Point( + Math.Max(0, (rect.Width - _virtualSize.Width) / 2), + Math.Max(0, (rect.Height - _virtualSize.Height) / 2)); + offset.X -= Position.X; + offset.Y -= Position.Y; - int borderPixelsX = PhysicalToPixels(border, screendpi.X); - int borderPixelsY = PhysicalToPixels(border, screendpi.Y); + int borderPixelsX = PhysicalToPixels(Border, _screenDPI.X); + int borderPixelsY = PhysicalToPixels(Border, _screenDPI.Y); - Region originalClip = pevent.Graphics.Clip; - Rectangle[] pageRenderArea = new Rectangle[rows * columns]; - Point lastImageSize = Point.Empty; - int maxImageHeight = 0; + Rectangle[] pageRenderArea = new Rectangle[_rows * _columns]; + Point lastImageSize = Point.Empty; + int maxImageHeight = 0; - using (var clipScope = new GraphicsClipScope(pevent.GraphicsInternal)) + using (new GraphicsClipScope(g)) + { + for (int row = 0; row < _rows; row++) { - for (int row = 0; row < rows; row++) - { - // Initialize our LastImageSize variable... - lastImageSize.X = 0; - lastImageSize.Y = maxImageHeight * row; + // Initialize our LastImageSize variable... + lastImageSize.X = 0; + lastImageSize.Y = maxImageHeight * row; - for (int column = 0; column < columns; column++) + for (int column = 0; column < _columns; column++) + { + int imageIndex = StartPage + column + row * _columns; + if (imageIndex < pages.Length) { - int imageIndex = StartPage + column + row * columns; - if (imageIndex < pageInfo.Length) + Size pageSize = pages[imageIndex].PhysicalSize; + if (_autoZoom) { - Size pageSize = pageInfo[imageIndex].PhysicalSize; - if (autoZoom) - { - double zoomX = ((double)controlPhysicalSize.Width - border * (columns + 1)) - / (columns * pageSize.Width); - double zoomY = ((double)controlPhysicalSize.Height - border * (rows + 1)) - / (rows * pageSize.Height); - zoom = Math.Min(zoomX, zoomY); - } - - imageSize = new Size((int)(zoom * pageSize.Width), (int)(zoom * pageSize.Height)); - Point imagePixels = PhysicalToPixels(new Point(imageSize), screendpi); - - int x = offset.X + borderPixelsX * (column + 1) + lastImageSize.X; - int y = offset.Y + borderPixelsY * (row + 1) + lastImageSize.Y; - - lastImageSize.X += imagePixels.X; - //The Height is the Max of any PageHeight.. - maxImageHeight = Math.Max(maxImageHeight, imagePixels.Y); - - pageRenderArea[imageIndex - StartPage] = new Rectangle(x, y, imagePixels.X, imagePixels.Y); - pevent.Graphics.ExcludeClip(pageRenderArea[imageIndex - StartPage]); + double zoomX = ((double)controlPhysicalSize.Width - Border * (_columns + 1)) + / (_columns * pageSize.Width); + double zoomY = ((double)controlPhysicalSize.Height - Border * (_rows + 1)) + / (_rows * pageSize.Height); + _zoom = Math.Min(zoomX, zoomY); } + + _imageSize = new Size((int)(_zoom * pageSize.Width), (int)(_zoom * pageSize.Height)); + Size imagePixels = PhysicalToPixels(_imageSize, _screenDPI); + + int x = offset.X + borderPixelsX * (column + 1) + lastImageSize.X; + int y = offset.Y + borderPixelsY * (row + 1) + lastImageSize.Y; + + lastImageSize.X += imagePixels.Width; + + // The Height is the Max of any PageHeight.. + maxImageHeight = Math.Max(maxImageHeight, imagePixels.Height); + + pageRenderArea[imageIndex - StartPage] = new Rectangle(x, y, imagePixels.Width, imagePixels.Height); + g.ExcludeClip(pageRenderArea[imageIndex - StartPage]); } } - - pevent.Graphics.FillRectangle(backBrush, ClientRectangle); } - for (int i = 0; i < pageRenderArea.Length; i++) + g.FillRectangle(backBrush, rect); + } + + for (int i = 0; i < pageRenderArea.Length; i++) + { + if (i + StartPage < pages.Length) { - if (i + StartPage < pageInfo.Length) + Rectangle box = pageRenderArea[i]; + g.DrawRectangle(Pens.Black, box); + using (var brush = ForeColor.GetCachedSolidBrushScope()) { - Rectangle box = pageRenderArea[i]; - pevent.Graphics.DrawRectangle(Pens.Black, box); - using (var brush = ForeColor.GetCachedSolidBrushScope()) - { - pevent.Graphics.FillRectangle(brush, box); - } - - box.Inflate(-1, -1); - if (pageInfo[i + StartPage].Image is not null) - { - pevent.Graphics.DrawImage(pageInfo[i + StartPage].Image, box); - } + g.FillRectangle(brush, box); + } - box.Width--; - box.Height--; - pevent.Graphics.DrawRectangle(Pens.Black, box); + box.Inflate(-1, -1); + if (pages[i + StartPage].Image is not null) + { + g.DrawImage(pages[i + StartPage].Image, box); } + + box.Width--; + box.Height--; + g.DrawRectangle(Pens.Black, box); } } - - base.OnPaint(pevent); // raise paint event } - protected virtual void OnStartPageChanged(EventArgs e) + private void PaintResizeBox(PaintEventArgs e, bool isHighContrast) { - if (Events[EVENT_STARTPAGECHANGED] is EventHandler eh) + if (!_hScrollBar.Visible || !_vScrollBar.Visible) { - eh(this, e); + return; } - } - private static int PhysicalToPixels(int physicalSize, int dpi) - { - return (int)(physicalSize * dpi / 100.0); + e.Graphics.FillRectangle(SystemBrushes.Control, ResizeBoxRectangle); } - private static Point PhysicalToPixels(Point physical, Point dpi) + private void PaintFocus(PaintEventArgs e, bool isHighContrast) { - return new Point(PhysicalToPixels(physical.X, dpi.X), - PhysicalToPixels(physical.Y, dpi.Y)); - } + Rectangle focusRect = FocusRectangle; - private static Size PhysicalToPixels(Size physicalSize, Point dpi) - { - return new Size(PhysicalToPixels(physicalSize.Width, dpi.X), - PhysicalToPixels(physicalSize.Height, dpi.Y)); - } + if (!e.ClipRectangle.Contains(focusRect) || !Focused || !ShowFocusCues) + { + return; + } - private static int PixelsToPhysical(int pixels, int dpi) - { - return (int)(pixels * 100.0 / dpi); + if (isHighContrast) + { + ControlPaint.DrawHighContrastFocusRectangle(e.Graphics, focusRect, SystemColors.ControlText); + } + else + { + ControlPaint.DrawFocusRectangle(e.Graphics, focusRect); + } } - private static Point PixelsToPhysical(Point pixels, Point dpi) + /// + /// Gets back color respectively to the High Contrast theme is applied or not + /// and taking into account saved custom back color. + /// + /// Indicates whether High Contrast theme is applied or not. + /// + /// Standard back color for PrintPreview control in standard theme (1), + /// contrasted color if there is High Contrast theme applied (2) and + /// custom color if this is set irrespectively to HC or not HC mode (3). + /// + private Color GetBackColor(bool isHighContract) { - return new Point(PixelsToPhysical(pixels.X, dpi.X), - PixelsToPhysical(pixels.Y, dpi.Y)); + return (isHighContract && !ShouldSerializeBackColor()) ? SystemColors.ControlDark : BackColor; } + private static int PixelsToPhysical(int pixels, int dpi) + => (int)(pixels * 100.0 / dpi); + private static Size PixelsToPhysical(Size pixels, Point dpi) - { - return new Size(PixelsToPhysical(pixels.Width, dpi.X), - PixelsToPhysical(pixels.Height, dpi.Y)); - } + => new (PixelsToPhysical(pixels.Width, dpi.X), + PixelsToPhysical(pixels.Height, dpi.Y)); - /// - /// Resets the back color to the defaults for the PrintPreviewControl. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override void ResetBackColor() - { - BackColor = SystemColors.AppWorkspace; - } + private static int PhysicalToPixels(int physicalSize, int dpi) + => (int)(physicalSize * dpi / 100.0); - /// - /// Resets the back color to the defaults for the PrintPreviewControl. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override void ResetForeColor() + private static Size PhysicalToPixels(Size physical, Point dpi) + => new (PhysicalToPixels(physical.Width, dpi.X), + PhysicalToPixels(physical.Height, dpi.Y)); + + private void SetPositionNoInvalidate(Point value) { - ForeColor = Color.White; + _scrollLayoutPending = true; + + _hScrollBar.Value = Clamp(value.X, _hScrollBar.Minimum, _hScrollBar.Maximum); + _vScrollBar.Value = Clamp(value.Y, _vScrollBar.Minimum, _vScrollBar.Maximum); + + _scrollLayoutPending = false; + + static int Clamp(int value, int min, int max) + { + if (value < min) + { + return min; + } + + if (max < value) + { + return max; + } + + return value; + } } - /// - /// WM_HSCROLL handler. - /// - private void WmHScroll(ref Message m) + internal void SetVirtualSizeNoInvalidate(Size value) { - // The lparam is the handle of the sending scrollbar, or NULL when the scrollbar sending - // the message is the built-in Window scrollbar. - if (m.LParamInternal != 0) + if (!IsHandleCreated) { - base.WndProc(ref m); return; } - Point locPos = position; - int pos = locPos.X; - int maxPos = Math.Max(Width, virtualSize.Width /*- Width*/); + _virtualSize = value; - locPos.X = AdjustScroll(m, pos, maxPos, true); - Position = locPos; + LayoutScrollBars(); } - private unsafe void SetPositionNoInvalidate(Point value) + private void LayoutScrollBars() { - Point current = position; + if (!IsHandleCreated) + { + return; + } + + _scrollLayoutPending = true; + SuspendLayout(); + + Rectangle availableRect = InnerClientRectangle; - position = value; - position.X = Math.Min(position.X, virtualSize.Width - Width); - position.Y = Math.Min(position.Y, virtualSize.Height - Height); - if (position.X < 0) + (bool horizontalScrollNeeded, bool verticalScrollNeeded) = IsScrollNeeded(availableRect.Size); + + bool scrollBarsVisibilityChanged = (_vScrollBar.Visible ^ verticalScrollNeeded) || (_hScrollBar.Visible ^ horizontalScrollNeeded); + + _hScrollBar.Visible = horizontalScrollNeeded; + if (horizontalScrollNeeded) { - position.X = 0; + _hScrollBar.Top = availableRect.Bottom - _hScrollBar.Height; + _hScrollBar.Width = availableRect.Width - (verticalScrollNeeded ? _vScrollBar.Width : 0); + + AdjustScroll( + _hScrollBar, + virtualDimension: _virtualSize.Width, + displayDimension: availableRect.Width, + offset: (verticalScrollNeeded ? _vScrollBar.Width : 0)); + } + else if (_hScrollBar.Value > 0) + { + _hScrollBar.Value = 0; } - if (position.Y < 0) + _vScrollBar.Visible = verticalScrollNeeded; + if (verticalScrollNeeded) { - position.Y = 0; + _vScrollBar.Height = availableRect.Height - (horizontalScrollNeeded ? _hScrollBar.Height : 0); + + if (RightToLeft == RightToLeft.Yes) + { + _vScrollBar.Left = availableRect.Left; + _vScrollBar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom; + } + else + { + _vScrollBar.Left = availableRect.Right - _vScrollBar.Width; + _vScrollBar.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; + } + + AdjustScroll( + _vScrollBar, + virtualDimension: _virtualSize.Height, + displayDimension: availableRect.Height, + offset: (horizontalScrollNeeded ? _hScrollBar.Height : 0)); + } + else if (_vScrollBar.Value > 0) + { + _vScrollBar.Value = 0; } - RECT scroll = ClientRectangle; - PInvoke.ScrollWindow( - this, - current.X - position.X, - current.Y - position.Y, - &scroll, - &scroll); + ResumeLayout(true); + _scrollLayoutPending = false; - PInvoke.SetScrollPos(this, SCROLLBAR_CONSTANTS.SB_HORZ, position.X, true); - PInvoke.SetScrollPos(this, SCROLLBAR_CONSTANTS.SB_VERT, position.Y, true); - } + if (scrollBarsVisibilityChanged && + IsAccessibilityObjectCreated && + AccessibilityObject is PrintPreviewControlAccessibleObject ao) + { + ao.RaiseStructureChangedEvent(Interop.UiaCore.StructureChangeType.ChildrenInvalidated, Array.Empty()); + } - internal unsafe void SetVirtualSizeNoInvalidate(Size value) - { - virtualSize = value; - SetPositionNoInvalidate(position); // Make sure it's within range + (bool horizontal, bool vertical) IsScrollNeeded(Size displaySize) + { + bool horizontal = _virtualSize.Width > displaySize.Width && displaySize.Width > _vScrollBar.Width; + bool vertical = _virtualSize.Height > displaySize.Height && displaySize.Height > _hScrollBar.Height; + + if (!horizontal && vertical) + { + horizontal = _virtualSize.Width > (displaySize.Width - _vScrollBar.Width); + } + + if (!vertical && horizontal) + { + vertical = _virtualSize.Height > (displaySize.Height - _hScrollBar.Height); + } + + return (horizontal, vertical); + } - SCROLLINFO info = new() + void AdjustScroll(ScrollBar scrollBar, int virtualDimension, int displayDimension, int offset) { - cbSize = (uint)sizeof(SCROLLINFO), - fMask = SCROLLINFO_MASK.SIF_RANGE | SCROLLINFO_MASK.SIF_PAGE, - nMin = 0, - nMax = Math.Max(Height, virtualSize.Height) - 1, - nPage = (uint)Height - }; + var oldLargeChange = scrollBar.LargeChange; - PInvoke.SetScrollInfo(this, SCROLLBAR_CONSTANTS.SB_VERT, ref info, true); + scrollBar.Maximum = virtualDimension; + scrollBar.LargeChange = displayDimension - offset; - info.fMask = SCROLLINFO_MASK.SIF_RANGE | SCROLLINFO_MASK.SIF_PAGE; - info.nMin = 0; - info.nMax = Math.Max(Width, virtualSize.Width) - 1; - info.nPage = (uint)Width; - PInvoke.SetScrollInfo(this, SCROLLBAR_CONSTANTS.SB_HORZ, ref info, true); + if (scrollBar.Value > 0) + { + var diff = scrollBar.LargeChange - oldLargeChange; + + if (scrollBar.Value >= diff) + { + scrollBar.Value -= diff; + } + } + } } - /// - /// WM_VSCROLL handler. - /// - private void WmVScroll(ref Message m) + private void scrollBar_ValueChanged(object? sender, EventArgs e) { - // The lparam is the handle of the sending scrollbar, or NULL when the scrollbar sending - // the message is the built-in Window scrollbar. - if (m.LParamInternal != 0) + if (_scrollLayoutPending) { - base.WndProc(ref m); return; } - Point locPos = Position; - int pos = locPos.Y; - int maxPos = Math.Max(Height, virtualSize.Height/* - Height*/); - - locPos.Y = AdjustScroll(m, pos, maxPos, false); - Position = locPos; + Invalidate(InsideRectangle); } /// @@ -813,24 +952,38 @@ private void WmKeyDown(ref Message msg) Point locPos = Position; int pos; int maxPos; + bool scrollVisible = _vScrollBar.Visible || _hScrollBar.Visible; + bool vertical = _vScrollBar.Visible; + int largeChange = vertical ? _vScrollBar.LargeChange : _hScrollBar.LargeChange; switch (keyData & Keys.KeyCode) { case Keys.PageUp: if ((keyData & Keys.Modifiers) == Keys.Control) { - pos = locPos.X; - if (pos > SCROLL_PAGE) - { - pos -= SCROLL_PAGE; - } - else + if (scrollVisible) { - pos = 0; - } + pos = vertical ? locPos.Y : locPos.X; + if (pos > largeChange) + { + pos -= largeChange; + } + else + { + pos = 0; + } - locPos.X = pos; - Position = locPos; + if (vertical) + { + locPos.Y = pos; + } + else + { + locPos.X = pos; + } + + Position = locPos; + } } else if (StartPage > 0) { @@ -841,21 +994,32 @@ private void WmKeyDown(ref Message msg) case Keys.PageDown: if ((keyData & Keys.Modifiers) == Keys.Control) { - pos = locPos.X; - maxPos = Math.Max(Width, virtualSize.Width); - if (pos < maxPos - SCROLL_PAGE) + if (scrollVisible) { - pos += SCROLL_PAGE; - } - else - { - pos = maxPos; - } + pos = vertical ? locPos.Y : locPos.X; + maxPos = vertical ? _vScrollBar.Maximum : _hScrollBar.Maximum; + if (pos < maxPos - largeChange) + { + pos += largeChange; + } + else + { + pos = maxPos; + } - locPos.X = pos; - Position = locPos; + if (vertical) + { + locPos.Y = pos; + } + else + { + locPos.X = pos; + } + + Position = locPos; + } } - else if (pageInfo is not null && StartPage < pageInfo.Length) + else if (_pageInfo is not null && StartPage < _pageInfo.Length) { StartPage++; } @@ -869,73 +1033,88 @@ private void WmKeyDown(ref Message msg) break; case Keys.End: - if (pageInfo is not null && (keyData & Keys.Modifiers) == Keys.Control) + if (_pageInfo is not null && (keyData & Keys.Modifiers) == Keys.Control) { - StartPage = pageInfo.Length; + StartPage = _pageInfo.Length; } break; case Keys.Up: - pos = locPos.Y; - if (pos > SCROLL_LINE) - { - pos -= SCROLL_LINE; - } - else + if (_vScrollBar.Visible) { - pos = 0; + pos = locPos.Y; + if (pos > _vScrollBar.SmallChange) + { + pos -= _vScrollBar.SmallChange; + } + else + { + pos = 0; + } + + locPos.Y = pos; + Position = locPos; } - locPos.Y = pos; - Position = locPos; break; case Keys.Down: + if (_vScrollBar.Visible) + { + pos = locPos.Y; + maxPos = _vScrollBar.Maximum - _vScrollBar.SmallChange; - pos = locPos.Y; - maxPos = Math.Max(Height, virtualSize.Height); + if (pos < maxPos - _vScrollBar.SmallChange) + { + pos += _vScrollBar.SmallChange; + } + else + { + pos = maxPos; + } - if (pos < maxPos - SCROLL_LINE) - { - pos += SCROLL_LINE; - } - else - { - pos = maxPos; + locPos.Y = pos; + Position = locPos; } - locPos.Y = pos; - Position = locPos; break; case Keys.Left: - - pos = locPos.X; - if (pos > SCROLL_LINE) - { - pos -= SCROLL_LINE; - } - else + if (_hScrollBar.Visible) { - pos = 0; + pos = locPos.X; + if (pos > _hScrollBar.SmallChange) + { + pos -= _hScrollBar.SmallChange; + } + else + { + pos = 0; + } + + locPos.X = pos; + Position = locPos; } - locPos.X = pos; - Position = locPos; break; case Keys.Right: - pos = locPos.X; - maxPos = Math.Max(Width, virtualSize.Width); - if (pos < maxPos - SCROLL_LINE) + if (_hScrollBar.Visible) { - pos += SCROLL_LINE; - } - else - { - pos = maxPos; + pos = locPos.X; + maxPos = _hScrollBar.Maximum - _hScrollBar.SmallChange; + + if (pos < maxPos - _hScrollBar.SmallChange) + { + pos += _hScrollBar.SmallChange; + } + else + { + pos = maxPos; + } + + locPos.X = pos; + Position = locPos; } - locPos.X = pos; - Position = locPos; break; } } @@ -944,12 +1123,6 @@ protected override void WndProc(ref Message m) { switch (m.MsgInternal) { - case PInvoke.WM_VSCROLL: - WmVScroll(ref m); - break; - case PInvoke.WM_HSCROLL: - WmHScroll(ref m); - break; case PInvoke.WM_KEYDOWN: WmKeyDown(ref m); break; @@ -958,35 +1131,4 @@ protected override void WndProc(ref Message m) break; } } - - /// - /// Indicates whether the property should be persisted. - /// - internal override bool ShouldSerializeBackColor() - { - return !BackColor.Equals(SystemColors.AppWorkspace); - } - - /// - /// Indicates whether the property should be persisted. - /// - internal override bool ShouldSerializeForeColor() - { - return !ForeColor.Equals(Color.White); - } - - /// - /// Gets back color respectively to the High Contrast theme is applied or not - /// and taking into account saved custom back color. - /// - /// Indicates whether High Contrast theme is applied or not. - /// - /// Standard back color for PrintPreview control in standard theme (1), - /// contrasted color if there is High Contrast theme applied (2) and - /// custom color if this is set irrespectively to HC or not HC mode (3). - /// - private Color GetBackColor(bool isHighContract) - { - return (isHighContract && !ShouldSerializeBackColor()) ? SystemColors.ControlDark : BackColor; - } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewDialog.PrintPreviewDialogToolStripButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewDialog.PrintPreviewDialogToolStripButton.cs index 75fb1e4db62..f8968373113 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewDialog.PrintPreviewDialogToolStripButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewDialog.PrintPreviewDialogToolStripButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewDialog.cs index 0758d48c719..7a3ffff7956 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ProfessionalColorTable.KnownColors.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ProfessionalColorTable.KnownColors.cs index 7c8cdeaa324..4b84526c349 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ProfessionalColorTable.KnownColors.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ProfessionalColorTable.KnownColors.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ProfessionalColorTable.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ProfessionalColorTable.cs index 4b3facc78db..02ea34fb66e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ProfessionalColorTable.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ProfessionalColorTable.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ProfessionalColors.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ProfessionalColors.cs index 38094faf2c8..336bac11137 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ProfessionalColors.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ProfessionalColors.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBar.ProgressBarAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBar.ProgressBarAccessibleObject.cs index 45464a65d58..43f7bc058f6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBar.ProgressBarAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBar.ProgressBarAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBar.cs index 4452c2703dd..38090eed60d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBar.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBar.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -158,7 +157,7 @@ public override ImageLayout BackgroundImageLayout protected override ImeMode DefaultImeMode => ImeMode.Disable; - protected override Size DefaultSize => new Size(100, 23); + protected override Size DefaultSize => new(100, 23); [EditorBrowsable(EditorBrowsableState.Never)] protected override bool DoubleBuffered diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBarRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBarRenderer.cs index aea86f6183c..251840c9dce 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBarRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBarRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBarStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBarStyle.cs index 77755ebb849..e239a4bed17 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBarStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBarStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.Flags.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.Flags.cs index 4ceef4b8133..3bbbe5c773c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.Flags.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.Flags.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.FreezePaintScope.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.FreezePaintScope.cs index f85626d74de..c77f46cdce0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.FreezePaintScope.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.FreezePaintScope.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.MeasureTextHelper.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.MeasureTextHelper.cs index 73111b9fe72..a7acfc8a757 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.MeasureTextHelper.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.MeasureTextHelper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.PropertyGridAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.PropertyGridAccessibleObject.cs index 3ee651f5571..ad3dbf2407c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.PropertyGridAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.PropertyGridAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.PropertyGridServiceProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.PropertyGridServiceProvider.cs index 811dcc7540b..ee393633338 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.PropertyGridServiceProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.PropertyGridServiceProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.PropertyGridInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.PropertyTabCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.PropertyTabCollection.cs index bd8ea79abe9..048ccf71c35 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.PropertyTabCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.PropertyTabCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.RegistryStateNames.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.RegistryStateNames.cs index 3c9836d75d8..5047c27e315 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.RegistryStateNames.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.RegistryStateNames.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.SelectedObjectConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.SelectedObjectConverter.cs index d0d1a6cc235..7782f59a1a2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.SelectedObjectConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.SelectedObjectConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.SnappableControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.SnappableControl.cs index 83db85aec34..932e84aff75 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.SnappableControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.SnappableControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.TabInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.TabInfo.cs index 8e190190cd5..6bd49bee413 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.TabInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.TabInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.cs index 1d38c15559e..4215aafaf99 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -909,7 +908,7 @@ public object[] SelectedObjects get => _selectedObjects is null ? Array.Empty() : (object[])_selectedObjects.Clone(); set { - using var _ = new FreezePaintScope(this); + using FreezePaintScope _ = new(this); SetFlag(Flags.FullRefreshAfterBatch, false); if (GetFlag(Flags.BatchMode)) @@ -2572,7 +2571,7 @@ private void OnLayoutInternal(bool dividerOnly) return; } - using var _ = new FreezePaintScope(this); + using FreezePaintScope _ = new(this); if (!dividerOnly) { @@ -3030,7 +3029,7 @@ private void OnTypeDescriptorRefreshedInvoke(RefreshEventArgs e) private void OnViewSortButtonClick(object sender, EventArgs e) { - using (var _ = new FreezePaintScope(this)) + using (FreezePaintScope _ = new(this)) { // Is this tab selected? If so, do nothing. if (sender == _viewSortButtons[_selectedViewSort]) @@ -3079,7 +3078,7 @@ private void OnViewSortButtonClick(object sender, EventArgs e) private void OnViewTabButtonClick(object sender, EventArgs e) { - using (var _ = new FreezePaintScope(this)) + using (FreezePaintScope _ = new(this)) { SelectViewTabButton((ToolStripButton)sender, true); OnLayoutInternal(dividerOnly: false); @@ -3792,7 +3791,7 @@ private void SetupToolbar(bool fullRebuild) return; } - using var _ = new FreezePaintScope(this); + using FreezePaintScope _ = new(this); if (_normalButtonImages is null || fullRebuild) { @@ -4060,7 +4059,7 @@ private bool ShouldForwardChildMouseMessage(Control child, MouseEventArgs e, ref if (e.Y <= 1 || (size.Height - e.Y) <= 1) { // Convert the coordinates. - var temp = new Point(e.X, e.Y); + Point temp = new(e.X, e.Y); temp = WindowsFormsUtils.TranslatePoint(temp, child, this); // Forward the message. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/ArrayElementGridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/ArrayElementGridEntry.cs index 46d5accf911..f4da5385b3d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/ArrayElementGridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/ArrayElementGridEntry.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.PropertyGridInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/AttributeTypeSorter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/AttributeTypeSorter.cs index 3e2f94358ca..c8d83b033de 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/AttributeTypeSorter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/AttributeTypeSorter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CategoryGridEntry.CategoryGridEntryAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CategoryGridEntry.CategoryGridEntryAccessibleObject.cs index 86f67405d8c..6c63275c555 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CategoryGridEntry.CategoryGridEntryAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CategoryGridEntry.CategoryGridEntryAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CategoryGridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CategoryGridEntry.cs index a666d269d46..33b2f87597b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CategoryGridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CategoryGridEntry.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CommandsPane.CommandsPaneAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CommandsPane.CommandsPaneAccessibleObject.cs index bb4f4b2f14e..29786a3de3b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CommandsPane.CommandsPaneAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CommandsPane.CommandsPaneAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CommandsPane.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CommandsPane.cs index f186fb83371..f9382c0eef4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CommandsPane.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CommandsPane.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DetailsButton.DetailsButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DetailsButton.DetailsButtonAccessibleObject.cs index f6f8f649c41..8384bca2492 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DetailsButton.DetailsButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DetailsButton.DetailsButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DetailsButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DetailsButton.cs index 6f49df845c1..e515d2d98b5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DetailsButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DetailsButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.PropertyGridInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.DropDownButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.DropDownButtonAccessibleObject.cs index 11f159fa846..a54bb6f0d4c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.DropDownButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.DropDownButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.DropDownButtonAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.DropDownButtonAdapter.cs index 1ebfee21dee..fa535aa3ff1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.DropDownButtonAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.DropDownButtonAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Imaging; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.cs index 7831f5a6ff3..45d699fe39e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.ButtonInternal; @@ -82,13 +81,13 @@ protected override void OnPaint(PaintEventArgs pevent) state = ComboBoxState.Hot; } - Rectangle dropDownButtonRect = new Rectangle(0, 0, Width, Height); + Rectangle dropDownButtonRect = new(0, 0, Width, Height); if (state == ComboBoxState.Normal) { pevent.Graphics.FillRectangle(SystemBrushes.Window, dropDownButtonRect); } - using (var hdc = new DeviceContextHdcScope(pevent)) + using (DeviceContextHdcScope hdc = new(pevent)) { ComboBoxRenderer.DrawDropDownButtonForHandle( hdc, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.CacheItems.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.CacheItems.cs index 734a3c591a7..b642deaf73b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.CacheItems.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.CacheItems.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.DisplayNameSortComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.DisplayNameSortComparer.cs index eb98c5a9021..0fa2cf820d0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.DisplayNameSortComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.DisplayNameSortComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.EventEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.EventEntry.cs index 7f428517a32..d5bfd251cbe 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.EventEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.EventEntry.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.PropertyGridInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.Flags.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.Flags.cs index cef20b95257..fa32947acfd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.Flags.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.Flags.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.GridEntryAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.GridEntryAccessibleObject.cs index 2137407ec42..cb55bea5099 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.GridEntryAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.GridEntryAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.Notify.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.Notify.cs index f1775d9dc28..da2e04e0e1f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.Notify.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.Notify.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.PropertyGridInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.PaintValueFlags.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.PaintValueFlags.cs index c5c7676f23a..5b3a392ba1c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.PaintValueFlags.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.PaintValueFlags.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.PropertyGridInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.cs index 89d62b727ac..a2a8554b06c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -1635,7 +1634,7 @@ void PaintOutlineWithExplorerTreeStyle(Graphics g, Rectangle r, HWND hwnd) } else { - using var hdc = new DeviceContextHdcScope(g); + using DeviceContextHdcScope hdc = new(g); VisualStyleRenderer explorerTreeRenderer = new(VisualStyleElement.ExplorerTreeView.Glyph.Opened); explorerTreeRenderer.DrawBackground(hdc, outline, hwnd); } @@ -1647,7 +1646,7 @@ unsafe void RedrawExplorerTreeViewClosedGlyph( HWND hwnd) { Color backgroundColor = ColorInversionNeededInHighContrast ? InvertColor(OwnerGrid.LineColor) : OwnerGrid.LineColor; - using var compatibleDC = new PInvoke.CreateDcScope(default); + using PInvoke.CreateDcScope compatibleDC = new(default); int planes = PInvoke.GetDeviceCaps(compatibleDC, GET_DEVICE_CAPS_INDEX.PLANES); int bitsPixel = PInvoke.GetDeviceCaps(compatibleDC, GET_DEVICE_CAPS_INDEX.BITSPIXEL); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntryCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntryCollection.cs index 74c392f6a0d..acc2f181422 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntryCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntryCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.PropertyGridInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntryComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntryComparer.cs index 7caa1b1a20d..a19d6893492 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntryComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntryComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.PropertyGridInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntryRecreateChildrenEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntryRecreateChildrenEventArgs.cs index 6e26958ccc1..f0d14113ea7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntryRecreateChildrenEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntryRecreateChildrenEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.PropertyGridInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridErrorDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridErrorDialog.cs index e36485087a8..3c1c807433b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridErrorDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridErrorDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridToolTip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridToolTip.cs index 37202d7391a..7a8fee27c96 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridToolTip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridToolTip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HelpPane.HelpPaneAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HelpPane.HelpPaneAccessibleObject.cs index b15fda4ca0d..a5085aff849 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HelpPane.HelpPaneAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HelpPane.HelpPaneAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HelpPane.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HelpPane.cs index 43ace381d38..5722c3f06d0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HelpPane.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HelpPane.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/IRootGridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/IRootGridEntry.cs index b7bb0215f2f..f8c25fed445 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/IRootGridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/IRootGridEntry.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/ImmutablePropertyDescriptorGridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/ImmutablePropertyDescriptorGridEntry.cs index 87f491ecd00..c841eeeef11 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/ImmutablePropertyDescriptorGridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/ImmutablePropertyDescriptorGridEntry.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MergePropertyDescriptor.MergedAttributeCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MergePropertyDescriptor.MergedAttributeCollection.cs index ffb6cf7c7c0..a1d9c42dce3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MergePropertyDescriptor.MergedAttributeCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MergePropertyDescriptor.MergedAttributeCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MergePropertyDescriptor.MultiMergeCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MergePropertyDescriptor.MultiMergeCollection.cs index 29a774ad84c..557f433edc0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MergePropertyDescriptor.MultiMergeCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MergePropertyDescriptor.MultiMergeCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MergePropertyDescriptor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MergePropertyDescriptor.cs index cfe204879b3..a14401617bc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MergePropertyDescriptor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MergePropertyDescriptor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiPropertyDescriptorGridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiPropertyDescriptorGridEntry.cs index d6db197f4ca..8933ac5a848 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiPropertyDescriptorGridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiPropertyDescriptorGridEntry.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiSelectRootGridEntry.PropertyDescriptorComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiSelectRootGridEntry.PropertyDescriptorComparer.cs index 9aa828691b2..8aa122d5319 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiSelectRootGridEntry.PropertyDescriptorComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiSelectRootGridEntry.PropertyDescriptorComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiSelectRootGridEntry.PropertyMerger.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiSelectRootGridEntry.PropertyMerger.cs index e53696ed045..f638775eb2d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiSelectRootGridEntry.PropertyMerger.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiSelectRootGridEntry.PropertyMerger.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiSelectRootGridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiSelectRootGridEntry.cs index 4ea6627e454..251b4ba756e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiSelectRootGridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/MultiSelectRootGridEntry.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertiesTab.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertiesTab.cs index 0a39705f331..2859609182d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertiesTab.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertiesTab.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.ExceptionConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.ExceptionConverter.cs index e500694e16a..acceff3e652 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.ExceptionConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.ExceptionConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.ExceptionEditor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.ExceptionEditor.cs index 465b79dce96..683b4e06d6f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.ExceptionEditor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.ExceptionEditor.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.PropertyDescriptorGridEntryAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.PropertyDescriptorGridEntryAccessibleObject.cs index c59789a9cd4..25d586089b0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.PropertyDescriptorGridEntryAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.PropertyDescriptorGridEntryAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.cs index 063002fcfad..5046d2f0a63 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyDescriptorGridEntry.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridCommands.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridCommands.cs index 4119f1159ac..2cbe9d33390 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridCommands.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridCommands.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.DropDownHolder.DropDownHolderAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.DropDownHolder.DropDownHolderAccessibleObject.cs index 6bd87001ac3..6bdddf17aef 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.DropDownHolder.DropDownHolderAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.DropDownHolder.DropDownHolderAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.DropDownHolder.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.DropDownHolder.cs index 6c82cadf48a..ecd6f23ee7a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.DropDownHolder.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.DropDownHolder.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.ErrorState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.ErrorState.cs index 1aff8328ecb..c820c3994cf 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.ErrorState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.ErrorState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.PropertyGridInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.Flags.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.Flags.cs index c59f851cb15..a02f11f883f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.Flags.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.Flags.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.PropertyGridInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridPositionData.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridPositionData.cs index b39b4ef6e9d..62c854d73ce 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridPositionData.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridPositionData.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.PropertyGridInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewListBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewListBox.cs index 06522143275..bc999da0d38 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewListBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewListBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.PropertyGridInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewListBoxAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewListBoxAccessibleObject.cs index e8cd2f18ca6..98f5afa535f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewListBoxAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewListBoxAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewListBoxItemAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewListBoxItemAccessibleObject.cs index 4d614d5a905..f005fe42fe8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewListBoxItemAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewListBoxItemAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static System.Windows.Forms.ListBox; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewTextBox.GridViewTextBoxAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewTextBox.GridViewTextBoxAccessibleObject.cs index 1618b6ddd39..9c3ca527139 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewTextBox.GridViewTextBoxAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewTextBox.GridViewTextBoxAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs index 0f2fe1770a5..b70876de235 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.GridViewTextBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.IMouseHookClient.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.IMouseHookClient.cs index 3dfd563c100..132a6e968d5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.IMouseHookClient.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.IMouseHookClient.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.PropertyGridInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.MouseHook.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.MouseHook.cs index e928354e26b..e0e293627ed 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.MouseHook.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.MouseHook.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.PropertyGridViewAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.PropertyGridViewAccessibleObject.cs index 699407593d9..42550e0e3ec 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.PropertyGridViewAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.PropertyGridViewAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; @@ -423,7 +422,7 @@ public override int GetChildCount() => } // Convert to client coordinates - var point = new Point(x, y); + Point point = new(x, y); PInvoke.ScreenToClient(owner, ref point); // Find the grid entry at the given client coordinates diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.cs index eaf12681ba3..38b3562d2d1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -605,7 +604,7 @@ internal Rectangle AccessibilityGetGridEntryBounds(GridEntry gridEntry) Rectangle rect = GetRectangle(row, RowValue | RowLabel); // Translate rect to screen coordinates - var pt = new Point(rect.X, rect.Y); + Point pt = new(rect.X, rect.Y); PInvoke.ClientToScreen(this, ref pt); Rectangle parent = gridEntry.OwnerGrid.GridViewAccessibleObject.Bounds; @@ -1154,7 +1153,7 @@ private void DrawLabel(Graphics g, int row, Rectangle rect, bool selected, bool s_gridViewDebugPaint.TraceVerbose($"Drawing label for property {gridEntry.PropertyLabel}"); - var newOrigin = new Point(rect.X, rect.Y); + Point newOrigin = new(rect.X, rect.Y); clipRect = Rectangle.Intersect(rect, clipRect); if (clipRect.IsEmpty) @@ -1206,7 +1205,7 @@ private void DrawValue(Graphics g, int row, Rectangle clipRect) s_gridViewDebugPaint.TraceVerbose($"Drawing value for property {gridEntry.PropertyLabel}"); Rectangle rect = GetRectangle(row, RowValue); - var newOrigin = new Point(rect.X, rect.Y); + Point newOrigin = new(rect.X, rect.Y); clipRect = Rectangle.Intersect(clipRect, rect); if (clipRect.IsEmpty) @@ -1711,7 +1710,7 @@ private Point FindPosition(int x, int y) return InvalidPosition; } - var pt = new Point(RowLabel, 0); + Point pt = new(RowLabel, 0); if (x > LabelWidth + _location.X) { pt.X = RowValue; @@ -1934,7 +1933,7 @@ private Size GetOurSize() public Rectangle GetRectangle(int row, int flRow) { - var rect = new Rectangle(0, 0, 0, 0); + Rectangle rect = new(0, 0, 0, 0); Size size = GetOurSize(); rect.X = _location.X; @@ -2021,7 +2020,7 @@ public string GetTestingInfo(int entry) private void LayoutWindow(bool invalidate) { Rectangle rect = ClientRectangle; - var sizeWindow = new Size(rect.Width, rect.Height); + Size sizeWindow = new(rect.Width, rect.Height); if (_scrollBar is not null) { @@ -2424,7 +2423,7 @@ protected override void OnLostFocus(EventArgs e) // For empty GridView, clear the focus indicator that was painted in OnGotFocus() if (TotalProperties <= 0) { - var clearRect = new Rectangle(1, 1, Size.Width - 2, Size.Height - 2); + Rectangle clearRect = new(1, 1, Size.Width - 2, Size.Height - 2); s_gridViewDebugPaint.TraceVerbose($"Filling empty gridview rect={clearRect}"); Color color = BackColor; @@ -3447,7 +3446,7 @@ protected override void OnPaint(PaintEventArgs e) if (yPosition < Size.Height) { yPosition++; - var clearRect = new Rectangle(1, yPosition, Size.Width - 2, Size.Height - yPosition - 1); + Rectangle clearRect = new(1, yPosition, Size.Width - 2, Size.Height - yPosition - 1); s_gridViewDebugPaint.TraceVerbose($"Filling remaining area rect={clearRect}"); using var backBrush = BackColor.GetCachedSolidBrushScope(); @@ -3683,13 +3682,13 @@ protected override void OnResize(EventArgs e) if (!_lastClientRect.IsEmpty && newRect.Width > _lastClientRect.Width) { - var rectInvalidate = new Rectangle(_lastClientRect.Width - 1, 0, newRect.Width - _lastClientRect.Width + 1, _lastClientRect.Height); + Rectangle rectInvalidate = new(_lastClientRect.Width - 1, 0, newRect.Width - _lastClientRect.Width + 1, _lastClientRect.Height); Invalidate(rectInvalidate); } if (!_lastClientRect.IsEmpty && yDelta > 0) { - var rectInvalidate = new Rectangle(0, _lastClientRect.Height - 1, _lastClientRect.Width, newRect.Height - _lastClientRect.Height + 1); + Rectangle rectInvalidate = new(0, _lastClientRect.Height - 1, _lastClientRect.Width, newRect.Height - _lastClientRect.Height + 1); Invalidate(rectInvalidate); } @@ -3793,7 +3792,7 @@ public unsafe void PopupEditor(int row) // The listbox draws with GDI, not GDI+. So we use a normal DC here. - using var hdc = new GetDcScope(DropDownListBox.HWND); + using GetDcScope hdc = new(DropDownListBox.HWND); TEXTMETRICW tm = default; int selectionIndex = -1; @@ -4447,7 +4446,7 @@ private void SelectRow(int row) ? new Size(SystemInformation.VerticalScrollBarArrowHeightForDpi(_deviceDpi), RowHeight) : new Size(SystemInformation.VerticalScrollBarArrowHeight, RowHeight); - var rectTarget = new Rectangle( + Rectangle rectTarget = new( rect.X + rect.Width - sizeBtn.Width, rect.Y, sizeBtn.Width, rect.Height); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/SingleSelectRootGridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/SingleSelectRootGridEntry.cs index 1680869785a..059d6569794 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/SingleSelectRootGridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/SingleSelectRootGridEntry.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStrip.PropertyGridToolStripAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStrip.PropertyGridToolStripAccessibleObject.cs index a2cecfecc87..c33d22cba91 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStrip.PropertyGridToolStripAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStrip.PropertyGridToolStripAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStrip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStrip.cs index cb9bef920d3..f7581a85e57 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStrip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStrip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStripButton.PropertyGridToolStripButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStripButton.PropertyGridToolStripButtonAccessibleObject.cs index 151af77389d..d740ae18930 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStripButton.PropertyGridToolStripButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStripButton.PropertyGridToolStripButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStripButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStripButton.cs index 8c4a84bb1e2..ace444af3ca 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStripButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStripButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; @@ -43,16 +42,16 @@ private void DrawDashedBorer(Graphics graphics) private void DrawHightContrastDashedBorer(Graphics graphics) { - var bounds = ClientBounds; + Rectangle bounds = ClientBounds; float[] dashValues = { 2, 2 }; int penWidth = 2; - var focusPen1 = new Pen(SystemColors.ControlText, penWidth) + Pen focusPen1 = new(SystemColors.ControlText, penWidth) { DashPattern = dashValues }; - var focusPen2 = new Pen(SystemColors.Control, penWidth) + Pen focusPen2 = new(SystemColors.Control, penWidth) { DashPattern = dashValues, DashOffset = 2 diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyManager.cs index 7de37c77b80..cda490d611f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertySort.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertySort.cs index 17959fce310..8f03cbe7c1c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertySort.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertySort.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.ColorWrapper.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.ColorWrapper.cs index e96fb568c29..dbfb11a2cb0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.ColorWrapper.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.ColorWrapper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.PaddingWrapper.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.PaddingWrapper.cs index 98926cdefed..9e31326432d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.PaddingWrapper.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.PaddingWrapper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.RectangleWrapper.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.RectangleWrapper.cs index 59579caccff..6d457112313 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.RectangleWrapper.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.RectangleWrapper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.SizeWrapper.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.SizeWrapper.cs index ad191e33c1c..07bd0461896 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.SizeWrapper.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.SizeWrapper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.cs index 2164902e909..23725f56e2b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyStore.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; @@ -185,10 +184,29 @@ public int GetInteger(int key, out bool found) /// public object? GetObject(int key) => GetObject(key, out _); - public bool TryGetObject(int key, [NotNullWhen(true)] out T? value) + /// + /// Retrieves an object value from our property list. + /// This will set value to null and return false if the + /// list does not contain the given key. + /// + /// The type of object to retrieve. + /// The key corresponding to the object in the property list. + /// Output parameter where the object will be set if found. + /// Will be set to null if the key is not present. + /// If a null value is set for a given key + /// it will return true and a null value. + /// True if an object (including null) is found for the given key; otherwise, false. + public bool TryGetObject(int key, out T? value) { object? entry = GetObject(key, out bool found); - value = !found ? default : (T?)entry; + Debug.Assert(!found || entry is null || entry is T, $"Entry is not of type {typeof(T)}, but of type {entry?.GetType()}"); + if (typeof(T).IsValueType || typeof(T).IsEnum || typeof(T).IsPrimitive) + { + value = found && entry is not null ? (T?)entry : default; + return found; + } + + value = found ? (T?)entry : default; return found; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyTabChangedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyTabChangedEventArgs.cs index 58788539e3c..5b2718b6d77 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyTabChangedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyTabChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyTabChangedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyTabChangedEventHandler.cs index 0ddee41b71a..e4d7cae9914 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyTabChangedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyTabChangedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyValueChangedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyValueChangedEventArgs.cs index a69779949c4..35e8af6c590 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyValueChangedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyValueChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyValueChangedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyValueChangedEventHandler.cs index 089c6ee7298..2128d66bc98 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyValueChangedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyValueChangedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/QueryAccessibilityHelpEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/QueryAccessibilityHelpEventArgs.cs index e01f6418054..ace5bcfd7ad 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/QueryAccessibilityHelpEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/QueryAccessibilityHelpEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/QueryAccessibilityHelpEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/QueryAccessibilityHelpEventHandler.cs index 44c678cb267..9d6364b7655 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/QueryAccessibilityHelpEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/QueryAccessibilityHelpEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/QueryContinueDragEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/QueryContinueDragEventArgs.cs index 3f2ebe20fb2..337cec38dcf 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/QueryContinueDragEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/QueryContinueDragEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/QueryContinueDragEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/QueryContinueDragEventHandler.cs index 1cd59252117..bf43789b282 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/QueryContinueDragEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/QueryContinueDragEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/QuestionEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/QuestionEventArgs.cs index 8dd53261676..ce3dc3b0bef 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/QuestionEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/QuestionEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/QuestionEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/QuestionEventHandler.cs index 5f793c05e38..40e1c252ba4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/QuestionEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/QuestionEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RadioButton.RadioButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RadioButton.RadioButtonAccessibleObject.cs index cb8765e144a..0eadf7620d1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RadioButton.RadioButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RadioButton.RadioButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RadioButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RadioButton.cs index 6c638d554f5..18bf4101627 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RadioButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RadioButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -23,7 +22,7 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionRadioButton))] public partial class RadioButton : ButtonBase { - private static readonly object EVENT_CHECKEDCHANGED = new object(); + private static readonly object EVENT_CHECKEDCHANGED = new(); private const ContentAlignment AnyRight = ContentAlignment.TopRight | ContentAlignment.MiddleRight | ContentAlignment.BottomRight; // Used to see if we need to iterate through the autochecked items and modify their tabstops. @@ -125,7 +124,7 @@ public Appearance Appearance } } - private static readonly object EVENT_APPEARANCECHANGED = new object(); + private static readonly object EVENT_APPEARANCECHANGED = new(); [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.RadioButtonOnAppearanceChangedDescr))] @@ -250,7 +249,7 @@ protected override CreateParams CreateParams } } - protected override Size DefaultSize => new Size(104, 24); + protected override Size DefaultSize => new(104, 24); /// /// When overridden in a derived class, handles rescaling of any magic numbers used in control painting. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RadioButtonRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RadioButtonRenderer.cs index 8a57616f87d..bac7453f901 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RadioButtonRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RadioButtonRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; @@ -80,7 +79,7 @@ internal static void DrawRadioButtonWithVisualStyles( HWND hwnd) { InitializeRenderer((int)state); - Rectangle glyphBounds = new Rectangle(glyphLocation, GetGlyphSize(hdc, state, hwnd)); + Rectangle glyphBounds = new(glyphLocation, GetGlyphSize(hdc, state, hwnd)); t_visualStyleRenderer.DrawBackground(hdc, glyphBounds, hwnd); } @@ -93,12 +92,12 @@ internal static void DrawRadioButton( Rectangle glyphBounds; if (RenderWithVisualStyles) { - using var hdc = new DeviceContextHdcScope(graphics); + using DeviceContextHdcScope hdc = new(graphics); DrawRadioButtonWithVisualStyles(hdc, glyphLocation, state, hwnd); } else { - using (var hdc = new DeviceContextHdcScope(graphics)) + using (DeviceContextHdcScope hdc = new(graphics)) { glyphBounds = new Rectangle(glyphLocation, GetGlyphSize(hdc, state, hwnd)); } @@ -152,7 +151,7 @@ internal static void DrawRadioButton( HWND hwnd) { Rectangle glyphBounds; - using (var hdc = new DeviceContextHdcScope(g)) + using (DeviceContextHdcScope hdc = new(g)) { glyphBounds = new Rectangle(glyphLocation, GetGlyphSize(hdc, state, hwnd)); } @@ -244,7 +243,7 @@ internal static void DrawRadioButton( HWND hwnd) { Rectangle glyphBounds; - using (var hdc = new DeviceContextHdcScope(g)) + using (DeviceContextHdcScope hdc = new(g)) { glyphBounds = new Rectangle(glyphLocation, GetGlyphSize(hdc, state, hwnd)); } @@ -280,7 +279,7 @@ internal static void DrawRadioButton( /// public static Size GetGlyphSize(Graphics g, RadioButtonState state) { - using var hdc = new DeviceContextHdcScope(g); + using DeviceContextHdcScope hdc = new(g); return GetGlyphSize(hdc, state, HWND.Null); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ReadOnlyControlCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ReadOnlyControlCollection.cs index 2e3c0380c5c..560adb82044 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ReadOnlyControlCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ReadOnlyControlCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RegistryKeyExtensions.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RegistryKeyExtensions.cs index 4ab773fa6e2..71b2826ea26 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RegistryKeyExtensions.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RegistryKeyExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Microsoft.Win32; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RelatedCurrencyManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RelatedCurrencyManager.cs index b979c831bcd..8e492874323 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RelatedCurrencyManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RelatedCurrencyManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -18,7 +17,7 @@ internal class RelatedCurrencyManager : CurrencyManager private BindingManagerBase parentManager; private string dataField; private PropertyDescriptor fieldInfo; - private static readonly List IgnoreItemChangedTable = new List(); + private static readonly List IgnoreItemChangedTable = new(); internal RelatedCurrencyManager(BindingManagerBase parentManager, string dataField) : base(null) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RelatedImageListAttribute.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RelatedImageListAttribute.cs index 9b796a172df..9b605f18023 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RelatedImageListAttribute.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RelatedImageListAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RelatedPropertyManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RelatedPropertyManager.cs index 3b8534ced85..f06e42f89cd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RelatedPropertyManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RelatedPropertyManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RetrieveVirtualItemEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RetrieveVirtualItemEventArgs.cs index 6fc47f0d264..47954c7b4d7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RetrieveVirtualItemEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RetrieveVirtualItemEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RetrieveVirtualItemEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RetrieveVirtualItemEventHandler.cs index d3bf4d3dea9..a45ce381298 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RetrieveVirtualItemEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RetrieveVirtualItemEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.OleCallback.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.OleCallback.cs index 178f7ec99ce..bafd2e42965 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.OleCallback.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.OleCallback.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Com; using Windows.Win32.System.Com.StructuredStorage; @@ -88,6 +87,7 @@ public HRESULT DeleteObject(IOleObject* lpoleobj) return HRESULT.S_OK; } + /// public HRESULT QueryAcceptData(Com.IDataObject* lpdataobj, ushort* lpcfFormat, RECO_FLAGS reco, BOOL fReally, HGLOBAL hMetaPict) { RichTextDbg.TraceVerbose($"IRichEditOleCallback::QueryAcceptData(reco={reco})"); @@ -163,7 +163,7 @@ public HRESULT QueryAcceptData(Com.IDataObject* lpdataobj, ushort* lpcfFormat, R _lastDragEventArgs.Message ?? string.Empty, _lastDragEventArgs.MessageReplacementToken ?? string.Empty); - if (fReally == 0) + if (!fReally) { // We are just querying diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.cs index 7e74c813453..abdad4bbac2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -59,13 +58,13 @@ private static TraceSwitch RichTextDbg // Event objects // - private static readonly object EVENT_HSCROLL = new object(); - private static readonly object EVENT_LINKACTIVATE = new object(); - private static readonly object EVENT_IMECHANGE = new object(); - private static readonly object EVENT_PROTECTED = new object(); - private static readonly object EVENT_REQUESTRESIZE = new object(); - private static readonly object EVENT_SELCHANGE = new object(); - private static readonly object EVENT_VSCROLL = new object(); + private static readonly object EVENT_HSCROLL = new(); + private static readonly object EVENT_LINKACTIVATE = new(); + private static readonly object EVENT_IMECHANGE = new(); + private static readonly object EVENT_PROTECTED = new(); + private static readonly object EVENT_REQUESTRESIZE = new(); + private static readonly object EVENT_SELCHANGE = new(); + private static readonly object EVENT_VSCROLL = new(); // Persistent state // @@ -366,7 +365,7 @@ public bool DetectUrls } } - protected override Size DefaultSize => new Size(100, 96); + protected override Size DefaultSize => new(100, 96); /// /// We can't just enable drag/drop of text by default: it's a breaking change. @@ -687,7 +686,7 @@ public unsafe HorizontalAlignment SelectionAlignment HorizontalAlignment selectionAlignment = HorizontalAlignment.Left; ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT) }; @@ -722,7 +721,7 @@ public unsafe HorizontalAlignment SelectionAlignment SourceGenerated.EnumValidator.Validate(value); ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT), dwMask = PFM.ALIGNMENT @@ -763,7 +762,7 @@ public unsafe bool SelectionBullet RichTextBoxSelectionAttribute selectionBullet = RichTextBoxSelectionAttribute.None; ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT) }; @@ -791,7 +790,7 @@ public unsafe bool SelectionBullet { ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT), dwMask = PFM.NUMBERING | PFM.OFFSET @@ -841,7 +840,7 @@ public unsafe int SelectionCharOffset } ForceHandleCreate(); - var cf = new CHARFORMAT2W + CHARFORMAT2W cf = new() { cbSize = (uint)sizeof(CHARFORMAT2W), dwMask = CFM.OFFSET, @@ -933,10 +932,11 @@ public unsafe Color SelectionBackColor _selectionBackColorToSetOnHandleCreated = value; if (IsHandleCreated) { - var cf2 = new CHARFORMAT2W + CHARFORMAT2W cf2 = new() { cbSize = (uint)sizeof(CHARFORMAT2W) }; + if (value == Color.Empty) { cf2.dwEffects = CFE.AUTOBACKCOLOR; @@ -983,7 +983,7 @@ public unsafe int SelectionHangingIndent int selHangingIndent = 0; ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT) }; @@ -1003,7 +1003,7 @@ public unsafe int SelectionHangingIndent { ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT), dwMask = PFM.OFFSET, @@ -1031,7 +1031,7 @@ public unsafe int SelectionIndent int selIndent = 0; ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT) }; @@ -1051,7 +1051,7 @@ public unsafe int SelectionIndent { ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT), dwMask = PFM.STARTINDENT, @@ -1153,7 +1153,7 @@ public unsafe int SelectionRightIndent ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT) }; @@ -1180,7 +1180,7 @@ public unsafe int SelectionRightIndent } ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT), dwMask = PFM.RIGHTINDENT, @@ -1206,7 +1206,7 @@ public unsafe int[] SelectionTabs int[] selTabs = Array.Empty(); ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT) }; @@ -1235,7 +1235,7 @@ public unsafe int[] SelectionTabs } ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT) }; @@ -1414,7 +1414,7 @@ public override unsafe int TextLength { get { - var gtl = new GETTEXTLENGTHEX + GETTEXTLENGTHEX gtl = new() { flags = GTL.NUMCHARS, codepage = 1200u /* CP_UNICODE */ @@ -1844,7 +1844,7 @@ public unsafe int Find(string str, int start, int end, RichTextBoxFinds options) throw new ArgumentException(string.Format(SR.RichTextFindEndInvalid, end)); } - var ft = default(FINDTEXTW); + FINDTEXTW ft = default; if ((options & RichTextBoxFinds.Reverse) != RichTextBoxFinds.Reverse) { // normal @@ -2156,7 +2156,7 @@ private bool InternalSetForeColor(Color value) private unsafe CHARFORMAT2W GetCharFormat(bool fSelection) { - var cf = new CHARFORMAT2W + CHARFORMAT2W cf = new() { cbSize = (uint)sizeof(CHARFORMAT2W) }; @@ -2244,7 +2244,7 @@ private RichTextBoxSelectionAttribute GetCharFormat(CFM mask, CFE effect) /// public override int GetCharIndexFromPosition(Point pt) { - var wpt = new Point(pt.X, pt.Y); + Point wpt = new(pt.X, pt.Y); int index = (int)PInvoke.SendMessage(this, PInvoke.EM_CHARFROMPOS, 0, ref wpt); string t = Text; @@ -2299,9 +2299,9 @@ public override unsafe Point GetPositionFromCharIndex(int index) return Point.Empty; } - var pt = default(Point); - PInvoke.SendMessage(this, PInvoke.EM_POSFROMCHAR, (WPARAM)(&pt), index); - return pt; + Point position = default; + PInvoke.SendMessage(this, PInvoke.EM_POSFROMCHAR, (WPARAM)(&position), index); + return position; } private bool GetProtectedError() @@ -2742,7 +2742,7 @@ private unsafe bool SetCharFormat(CFM mask, CFE effect, RichTextBoxSelectionAttr // check to see if the control has been created if (IsHandleCreated) { - var cf = new CHARFORMAT2W + CHARFORMAT2W cf = new() { cbSize = (uint)sizeof(CHARFORMAT2W), dwMask = mask @@ -2760,7 +2760,7 @@ private unsafe bool SetCharFormat(CFM mask, CFE effect, RichTextBoxSelectionAttr throw new ArgumentException(SR.UnknownAttr); } - // set the format information + // Set the format information. return PInvoke.SendMessage(this, PInvoke.EM_SETCHARFORMAT, (WPARAM)(uint)SCF.SELECTION, ref cf) != 0; } @@ -2886,11 +2886,11 @@ private void StreamIn(string str, SF flags) private void StreamIn(Stream data, SF flags) { - // clear out the selection only if we are replacing all the text + // Clear out the selection only if we are replacing all the text. if ((flags & SF.F_SELECTION) == 0) { - var cr = default(CHARRANGE); - PInvoke.SendMessage(this, PInvoke.EM_EXSETSEL, 0, ref cr); + CHARRANGE range = default; + PInvoke.SendMessage(this, PInvoke.EM_EXSETSEL, 0, ref range); } try @@ -2921,7 +2921,7 @@ private void StreamIn(Stream data, SF flags) int cookieVal = 0; // set up structure to do stream operation - var es = default(EDITSTREAM); + EDITSTREAM es = default; if ((flags & SF.UNICODE) != 0) { @@ -2942,7 +2942,7 @@ private void StreamIn(Stream data, SF flags) } es.dwCookie = (UIntPtr)cookieVal; - var callback = new EDITSTREAMCALLBACK(EditStreamProc); + EDITSTREAMCALLBACK callback = EditStreamProc; es.pfnCallback = Marshal.GetFunctionPointerForDelegate(callback); // gives us TextBox compatible behavior, programatic text change shouldn't @@ -3025,15 +3025,9 @@ private void StreamOut(Stream data, SF flags, bool includeCrLfs) try { int cookieVal = 0; - var es = default(EDITSTREAM); - if ((flags & SF.UNICODE) != 0) - { - cookieVal = OUTPUT | UNICODE; - } - else - { - cookieVal = OUTPUT | ANSI; - } + EDITSTREAM es = default; + + cookieVal = (flags & SF.UNICODE) != 0 ? OUTPUT | UNICODE : OUTPUT | ANSI; if ((flags & SF.RTF) != 0) { @@ -3052,7 +3046,7 @@ private void StreamOut(Stream data, SF flags, bool includeCrLfs) } es.dwCookie = (UIntPtr)cookieVal; - var callback = new EDITSTREAMCALLBACK(EditStreamProc); + EDITSTREAMCALLBACK callback = EditStreamProc; es.pfnCallback = Marshal.GetFunctionPointerForDelegate(callback); // Get Text @@ -3225,7 +3219,7 @@ private unsafe void EnLinkMsgHandler(ref Message m) /// private string CharRangeToString(CHARRANGE c) { - var txrg = new Richedit.TEXTRANGE + Richedit.TEXTRANGE txrg = new() { chrg = c }; @@ -3237,7 +3231,7 @@ private string CharRangeToString(CHARRANGE c) } int characters = (c.cpMax - c.cpMin) + 1; // +1 for null termination - var charBuffer = new UnicodeCharBuffer(characters); + UnicodeCharBuffer charBuffer = new(characters); IntPtr unmanagedBuffer = charBuffer.AllocCoTaskMem(); if (unmanagedBuffer == IntPtr.Zero) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxConstants.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxConstants.cs index 2bcf1095cf5..c41695df2e1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxConstants.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxConstants.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxFinds.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxFinds.cs index 5333e7469c5..6f1e2c30540 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxFinds.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxFinds.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxLanguageOptions.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxLanguageOptions.cs index 91d4321a5df..9c9684c3146 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxLanguageOptions.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxLanguageOptions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxScrollBars.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxScrollBars.cs index d9346fcd25e..8b75a06c3a2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxScrollBars.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxScrollBars.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxSelectionAttribute.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxSelectionAttribute.cs index b6d1917072b..6b0e1f54a34 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxSelectionAttribute.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxSelectionAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxSelectionTypes.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxSelectionTypes.cs index b427e3dd5d6..0bfe7908ec9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxSelectionTypes.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxSelectionTypes.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxStreamType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxStreamType.cs index 618069565ef..cd402b79396 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxStreamType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxStreamType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxWordPunctuations.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxWordPunctuations.cs index f5725c43e61..0a1e00d98da 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxWordPunctuations.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBoxWordPunctuations.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RightToLeft.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RightToLeft.cs index 3586b69646c..0c9057839a1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RightToLeft.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RightToLeft.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RowStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RowStyle.cs index a0473a7682e..e7d4c337cff 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RowStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RowStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SaveFileDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SaveFileDialog.cs index 68244ba846d..c223d09ffdb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SaveFileDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SaveFileDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Screen.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Screen.cs index 00300275596..8125cd0055c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Screen.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Screen.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using Microsoft.Win32; @@ -37,7 +36,7 @@ public partial class Screen private readonly int _bitDepth; - private static readonly object s_syncLock = new object(); //used to lock this class before syncing to SystemEvents + private static readonly object s_syncLock = new(); //used to lock this class before syncing to SystemEvents private static int s_desktopChangedCount = -1; //static counter of desktop size changes diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarAccessibleObject.cs index 0c7a0265c8b..477934e2660 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarChildAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarChildAccessibleObject.cs index 91187e12fe5..8f40b0c50b7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarChildAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarChildAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarFirstLineButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarFirstLineButtonAccessibleObject.cs index e162d720511..5868052c7d0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarFirstLineButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarFirstLineButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.UiaCore; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarFirstPageButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarFirstPageButtonAccessibleObject.cs index 3dd1ac8d31a..82ede37c394 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarFirstPageButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarFirstPageButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.UiaCore; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarLastLineButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarLastLineButtonAccessibleObject.cs index d9224d4d88b..d261a011cd4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarLastLineButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarLastLineButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.UiaCore; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarLastPageButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarLastPageButtonAccessibleObject.cs index 5f7f42903a4..ac45f42c092 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarLastPageButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarLastPageButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.UiaCore; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarThumbAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarThumbAccessibleObject.cs index 3e54a8d78d2..fff91c44710 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarThumbAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.ScrollBarThumbAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.UiaCore; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.cs index f5743c8d231..1c0f1c542b2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -15,8 +14,8 @@ namespace System.Windows.Forms; [DefaultEvent(nameof(Scroll))] public abstract partial class ScrollBar : Control { - private static readonly object s_scrollEvent = new object(); - private static readonly object s_valueChangedEvent = new object(); + private static readonly object s_scrollEvent = new(); + private static readonly object s_valueChangedEvent = new(); private int _minimum; private int _maximum = 100; @@ -719,7 +718,7 @@ private unsafe void DoScroll(ScrollEventType type) break; } - var se = new ScrollEventArgs(type, oldValue, newValue, _scrollOrientation); + ScrollEventArgs se = new(type, oldValue, newValue, _scrollOrientation); OnScroll(se); Value = se.NewValue; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBarRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBarRenderer.cs index 008a84449e7..dcfc4b2af9f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBarRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBarRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBars.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBars.cs index d9d136f98e5..258956b74b1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBars.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBars.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollButton.cs index 294b06bd289..be9eec5609e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollEventArgs.cs index dc5971bee69..d59c6c96c03 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollEventHandler.cs index a63f3a4c62c..91b4037f211 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollEventType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollEventType.cs index 23d4d39d0e9..6af46f43b0d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollEventType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollEventType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollOrientation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollOrientation.cs index 6e5d9ce4548..9d5379b0d43 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollOrientation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollOrientation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollProperties.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollProperties.cs index 9060c816177..fc31678a449 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollProperties.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollProperties.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.DockPaddingEdges.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.DockPaddingEdges.cs index 6e873cac4cc..f6f65eeb56a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.DockPaddingEdges.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.DockPaddingEdges.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.DockPaddingEdgesConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.DockPaddingEdgesConverter.cs index 0d0c2a37ef3..d27cf8f0333 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.DockPaddingEdgesConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.DockPaddingEdgesConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.cs index 3d7c48a1442..a6265fc62e1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -15,7 +14,7 @@ namespace System.Windows.Forms; public partial class ScrollableControl : Control, IArrangedElement { #if DEBUG - internal static readonly TraceSwitch s_autoScrolling = new TraceSwitch("AutoScrolling", "Debug autoscrolling logic"); + internal static readonly TraceSwitch s_autoScrolling = new("AutoScrolling", "Debug autoscrolling logic"); #else internal static readonly TraceSwitch? s_autoScrolling; #endif @@ -60,7 +59,7 @@ public partial class ScrollableControl : Control, IArrangedElement private HScrollProperties? _horizontalScroll; - private static readonly object s_scrollEvent = new object(); + private static readonly object s_scrollEvent = new(); /// /// Used to figure out what the horizontal scroll value should be set to when the horizontal diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SearchDirectionHint.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SearchDirectionHint.cs index 2fb7ae8781b..53208736003 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SearchDirectionHint.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SearchDirectionHint.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.UI.Input.KeyboardAndMouse; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SearchForVirtualItemEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SearchForVirtualItemEventArgs.cs index 14921dfe255..5eebab61e46 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SearchForVirtualItemEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SearchForVirtualItemEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SearchForVirtualItemEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SearchForVirtualItemEventHandler.cs index f08efc2c5e6..734618f9292 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SearchForVirtualItemEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SearchForVirtualItemEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SecurityIDType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SecurityIDType.cs index c20ae276bbf..a9b307fd8ec 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SecurityIDType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SecurityIDType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SelectedGridItemChangedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SelectedGridItemChangedEventArgs.cs index 11818e44e09..71fe82556c7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SelectedGridItemChangedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SelectedGridItemChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SelectedGridItemChangedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SelectedGridItemChangedEventHandler.cs index c96583e3fe8..c76fca793ad 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SelectedGridItemChangedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SelectedGridItemChangedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SelectionMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SelectionMode.cs index afc0ce56cba..042045b0794 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SelectionMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SelectionMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SelectionRange.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SelectionRange.cs index 86f97fb3950..cb8e109378b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SelectionRange.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SelectionRange.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SelectionRangeConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SelectionRangeConverter.cs index f99a85b9734..4316adb6810 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SelectionRangeConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SelectionRangeConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.KeywordVk.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.KeywordVk.cs index 8fa11b65b2b..0e2caac874c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.KeywordVk.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.KeywordVk.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SKEvent.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SKEvent.cs index 6998c492391..785f0242c0d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SKEvent.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SKEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SKWindow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SKWindow.cs index ac4399583a2..e05c02cddee 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SKWindow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SKWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SendKeysHookProc.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SendKeysHookProc.cs index fc0da64fe3e..61dd4865130 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SendKeysHookProc.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SendKeysHookProc.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SendMethodTypes.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SendMethodTypes.cs index 45c81792a4c..3f9c95d9abd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SendMethodTypes.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.SendMethodTypes.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.cs index b1e7542736b..fd73f3b844e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; @@ -85,9 +84,9 @@ public partial class SendKeys /// /// Vector of events that we have yet to post to the journaling hook. /// - private static readonly Queue s_events = new Queue(); + private static readonly Queue s_events = new(); - private static object s_lock = new object(); + private static object s_lock = new(); private static bool s_startNewChar; private static readonly SKWindow s_messageWindow; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Shortcut.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Shortcut.cs index 03bab09db0f..ca3e28fe2df 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Shortcut.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Shortcut.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SizeGripStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SizeGripStyle.cs index 5f2534fe5fc..fb9dfab761f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SizeGripStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SizeGripStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SizeType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SizeType.cs index 78477535b95..c0522593845 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SizeType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SizeType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SortOrder.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SortOrder.cs index 50406ef1d29..2fc0939a7cc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SortOrder.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SortOrder.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SpecialFolderEnumConverter.SpecialFolderEnumComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SpecialFolderEnumConverter.SpecialFolderEnumComparer.cs index 9d37c5d9019..a7b3ced8c56 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SpecialFolderEnumConverter.SpecialFolderEnumComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SpecialFolderEnumConverter.SpecialFolderEnumComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; @@ -10,7 +9,7 @@ internal partial class SpecialFolderEnumConverter { private class SpecialFolderEnumComparer : IComparer { - public static readonly SpecialFolderEnumComparer Default = new SpecialFolderEnumComparer(); + public static readonly SpecialFolderEnumComparer Default = new(); public int Compare(object? a, object? b) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SpecialFolderEnumConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SpecialFolderEnumConverter.cs index a346bff7023..b7c48b426fd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SpecialFolderEnumConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SpecialFolderEnumConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.SplitContainerAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.SplitContainerAccessibleObject.cs index bac19e2e472..0f34150256b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.SplitContainerAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.SplitContainerAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.SplitContainerMessageFilter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.SplitContainerMessageFilter.cs index 759cd92b8da..0b3405fa2e1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.SplitContainerMessageFilter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.SplitContainerMessageFilter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.SplitContainerTypedControlCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.SplitContainerTypedControlCollection.cs index 024d6479a01..142d7618187 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.SplitContainerTypedControlCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.SplitContainerTypedControlCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.cs index 8c9f4631c2e..41f526477d3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -79,8 +78,8 @@ public partial class SplitContainer : ContainerControl, ISupportInitialize private bool _setSplitterDistance; // Events - private static readonly object s_eventMoving = new object(); - private static readonly object s_eventMoved = new object(); + private static readonly object s_eventMoving = new(); + private static readonly object s_eventMoved = new(); // IMessageFilter implementation private SplitContainerMessageFilter? _splitContainerMessageFilter; @@ -99,7 +98,7 @@ public SplitContainer() // either the right or bottom panel - LTR // either the left or bottom panel - RTL Panel2 = new SplitterPanel(this); - _splitterRect = default(Rectangle); + _splitterRect = default; SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true); @@ -1388,7 +1387,7 @@ private void ApplySplitterDistance() /// private Rectangle CalcSplitLine(int splitSize, int minWeight) { - Rectangle r = default(Rectangle); + Rectangle r = default; switch (Orientation) { case Orientation.Vertical: diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.SplitData.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.SplitData.cs index 14131470968..f0fe98ca7a7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.SplitData.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.SplitData.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.SplitterAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.SplitterAccessibleObject.cs index a47f69b540b..0ab3a626f12 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.SplitterAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.SplitterAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.SplitterMessageFilter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.SplitterMessageFilter.cs index 6737c813923..6e96e3952e2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.SplitterMessageFilter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.SplitterMessageFilter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.cs index 56bc1170e62..6ac70322512 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -36,8 +35,8 @@ public partial class Splitter : Control private int _initTargetSize; private int _lastDrawSplit = -1; private int _maxSize; - private static readonly object EVENT_MOVING = new object(); - private static readonly object EVENT_MOVED = new object(); + private static readonly object EVENT_MOVING = new(); + private static readonly object EVENT_MOVED = new(); // Cannot expose IMessageFilter.PreFilterMessage through this unsealed class private SplitterMessageFilter? _splitterMessageFilter; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SplitterCancelEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SplitterCancelEventArgs.cs index 36524d0c02a..6c68f065dfc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SplitterCancelEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SplitterCancelEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SplitterCancelEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SplitterCancelEventHandler.cs index f100b4da64e..2aae9804744 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SplitterCancelEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SplitterCancelEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SplitterEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SplitterEventArgs.cs index 3b87fa2191b..9424515bde4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SplitterEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SplitterEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SplitterEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SplitterEventHandler.cs index 6e0d86fafa6..1e4d27b5577 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SplitterEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SplitterEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SplitterPanel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SplitterPanel.cs index ee291bef083..5533fc7c5f8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SplitterPanel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SplitterPanel.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -151,7 +150,7 @@ internal int HeightInternal /// /// A new instance of the struct with the padding set to 0 for all edges. /// - protected override Padding DefaultMargin => new Padding(0, 0, 0, 0); + protected override Padding DefaultMargin => new(0, 0, 0, 0); /// /// Override AutoSize to make it hidden from the user in the designer diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/StatusStrip.StatusStripAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/StatusStrip.StatusStripAccessibleObject.cs index 5002d89a1ea..dd7f09d16f0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/StatusStrip.StatusStripAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/StatusStrip.StatusStripAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/StatusStrip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/StatusStrip.cs index 1cc56b82d7a..ea109e276f8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/StatusStrip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/StatusStrip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/StringSource.cs b/src/System.Windows.Forms/src/System/Windows/Forms/StringSource.cs index 48ed5e692f9..be1c79fb177 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/StringSource.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/StringSource.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using Windows.Win32.System.Com; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/StructFormat.cs b/src/System.Windows.Forms/src/System/Windows/Forms/StructFormat.cs index cfaa0539c60..e106962e513 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/StructFormat.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/StructFormat.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SystemInformation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SystemInformation.cs index 228d39452c3..26407f27681 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SystemInformation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SystemInformation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -196,9 +195,9 @@ public static Rectangle WorkingArea { get { - var rect = default(RECT); - PInvoke.SystemParametersInfo(SPI_GETWORKAREA, ref rect); - return rect; + RECT workingArea = default; + PInvoke.SystemParametersInfo(SPI_GETWORKAREA, ref workingArea); + return workingArea; } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SystemParameter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SystemParameter.cs index 77be9172a48..0b6c0952da6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SystemParameter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SystemParameter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabAlignment.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabAlignment.cs index 4ce8ae7886e..8db93263803 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabAlignment.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabAlignment.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabAppearance.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabAppearance.cs index c32e03124a3..433f74e258f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabAppearance.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabAppearance.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.ControlCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.ControlCollection.cs index 3d3670c2e8d..7152813fec6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.ControlCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.ControlCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.State.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.State.cs index 66f755a1afc..fc82a91bdb4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.State.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.State.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.TabControlAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.TabControlAccessibleObject.cs index 2b3a66ec720..60acbd20134 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.TabControlAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.TabControlAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop.UiaCore; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.TabPageCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.TabPageCollection.cs index 539df1e2c94..ba295fa6129 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.TabPageCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.TabPageCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -97,48 +96,32 @@ int IList.Add(object? value) return IndexOf(tabPage); } - public void Add(string? text) + public void Add(string? text) => Add(new TabPage { - var page = new TabPage - { - Text = text - }; - Add(page); - } + Text = text + }); - public void Add(string? key, string? text) + public void Add(string? key, string? text) => Add(new TabPage { - var page = new TabPage - { - Name = key, - Text = text - }; - Add(page); - } + Name = key, + Text = text + }); - public void Add(string? key, string? text, int imageIndex) + public void Add(string? key, string? text, int imageIndex) => Add(new TabPage { - var page = new TabPage - { - Name = key, - Text = text, - ImageIndex = imageIndex - }; - Add(page); - } + Name = key, + Text = text, + ImageIndex = imageIndex + }); - public void Add(string? key, string? text, string imageKey) + public void Add(string? key, string? text, string imageKey) => Add(new TabPage { - var page = new TabPage - { - Name = key, - Text = text, - ImageKey = imageKey - }; - Add(page); - } + Name = key, + Text = text, + ImageKey = imageKey + }); - public void AddRange(TabPage[] pages) + public void AddRange(params TabPage[] pages) { ArgumentNullException.ThrowIfNull(pages); @@ -262,32 +245,25 @@ void IList.Insert(int index, object? tabPage) Insert(index, actualTabPage); } - public void Insert(int index, string? text) + public void Insert(int index, string? text) => Insert(index, new TabPage { - var page = new TabPage - { - Text = text - }; - Insert(index, page); - } + Text = text + }); - public void Insert(int index, string? key, string? text) + public void Insert(int index, string? key, string? text) => Insert(index, new TabPage { - var page = new TabPage - { - Name = key, - Text = text - }; - Insert(index, page); - } + Name = key, + Text = text + }); public void Insert(int index, string? key, string? text, int imageIndex) { - var page = new TabPage + TabPage page = new() { Name = key, Text = text }; + Insert(index, page); // ImageKey and ImageIndex require parenting. @@ -296,11 +272,12 @@ public void Insert(int index, string? key, string? text, int imageIndex) public void Insert(int index, string? key, string? text, string imageKey) { - var page = new TabPage + TabPage page = new() { Name = key, Text = text }; + Insert(index, page); // ImageKey and ImageIndex require parenting. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.cs index 892b5ec30c1..f4d034a0a4c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -24,7 +23,7 @@ namespace System.Windows.Forms; public partial class TabControl : Control { private static readonly Size DefaultItemSize = Size.Empty; - private static readonly Point DefaultPaddingPoint = new Point(6, 3); + private static readonly Point DefaultPaddingPoint = new(6, 3); // Properties private readonly TabPageCollection _tabCollection; @@ -45,11 +44,11 @@ public partial class TabControl : Control private EventHandler? _onSelectedIndexChanged; private DrawItemEventHandler? _onDrawItem; - private static readonly object s_deselectingEvent = new object(); - private static readonly object s_deselectedEvent = new object(); - private static readonly object s_selectingEvent = new object(); - private static readonly object s_selectedEvent = new object(); - private static readonly object s_rightToLeftLayoutChangedEvent = new object(); + private static readonly object s_deselectingEvent = new(); + private static readonly object s_deselectedEvent = new(); + private static readonly object s_selectingEvent = new(); + private static readonly object s_selectedEvent = new(); + private static readonly object s_rightToLeftLayoutChangedEvent = new(); // Perf: take all the bools and put them into a state variable: see TabControlState consts above private BitVector32 _tabControlState; @@ -1111,7 +1110,7 @@ public Rectangle GetTabRect(int index) } SetState(State.GetTabRectfromItemSize, false); - RECT rect = default(RECT); + RECT rect = default; // normally, we would not want to create the handle for this, but since // it is dependent on the actual physical display, we simply must. @@ -1945,7 +1944,7 @@ private unsafe void WmReflectDrawItem(ref Message m) { DRAWITEMSTRUCT* dis = (DRAWITEMSTRUCT*)(nint)m.LParamInternal; - using var e = new DrawItemEventArgs( + using DrawItemEventArgs e = new( dis->hDC.CreateGraphics(), Font, dis->rcItem, @@ -2158,7 +2157,7 @@ private static void PrefixAmpersands(ref string value) } // Insert extra ampersands - var newString = new StringBuilder(); + StringBuilder newString = new(); newString.Append(value.AsSpan(0, firstAmpersand)); for (int i = firstAmpersand; i < value.Length; ++i) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabControlAction.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabControlAction.cs index e2641451722..2ae7e8fb9fe 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabControlAction.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabControlAction.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabControlCancelEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabControlCancelEventArgs.cs index d68aa758363..3db0d1218ef 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabControlCancelEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabControlCancelEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabControlCancelEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabControlCancelEventHandler.cs index e37e078afcf..a751b8b6eca 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabControlCancelEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabControlCancelEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabControlEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabControlEventArgs.cs index 805dc32d71c..b89580c9a3b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabControlEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabControlEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabControlEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabControlEventHandler.cs index ea324ec47be..59cf7a63a30 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabControlEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabControlEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabDrawMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabDrawMode.cs index fd80623444d..98f65dedcd6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabDrawMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabDrawMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.TabAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.TabAccessibleObject.cs index f86f10ce45f..29573af1b0d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.TabAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.TabAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using Windows.Win32.UI.Accessibility; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.TabPageAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.TabPageAccessibleObject.cs index cccacdf99b8..ce9b8c9db70 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.TabPageAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.TabPageAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.TabPageControlCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.TabPageControlCollection.cs index 78e2c0a315a..504e420c0cd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.TabPageControlCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.TabPageControlCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.cs index e38b808e383..0152ef8a3a2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -28,7 +27,7 @@ public partial class TabPage : Panel private bool _useVisualStyleBackColor; private List? _associatedToolTips; private ToolTip? _externalToolTip; - private readonly ToolTip _internalToolTip = new ToolTip(); + private readonly ToolTip _internalToolTip = new(); private TabAccessibleObject? _tabAccessibilityObject; /// diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabRenderer.cs index 07cf5a3c89a..dd849b4ca06 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabSizeMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabSizeMode.cs index 4dc761979d5..e4321b4954f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabSizeMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabSizeMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutCellPaintEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutCellPaintEventArgs.cs index 2404e50da1f..5f8c688e042 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutCellPaintEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutCellPaintEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutCellPaintEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutCellPaintEventHandler.cs index e2c24e0fbd4..610aa094dff 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutCellPaintEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutCellPaintEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutColumnStyleCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutColumnStyleCollection.cs index 5be7f300cab..2101ac96ef2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutColumnStyleCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutColumnStyleCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutControlCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutControlCollection.cs index 3778629c334..16fdf349bed 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutControlCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutControlCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanel.cs index 1f4a5e65e67..83a527df12d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanel.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; @@ -23,7 +22,7 @@ namespace System.Windows.Forms; public class TableLayoutPanel : Panel, IExtenderProvider { private readonly TableLayoutSettings _tableLayoutSettings; - private static readonly object s_eventCellPaint = new object(); + private static readonly object s_eventCellPaint = new(); public TableLayoutPanel() { @@ -441,7 +440,7 @@ protected override void OnPaintBackground(PaintEventArgs e) if (clipRect.IntersectsWith(insideCellBounds)) { // First, call user's painting code - using (var pcea = new TableLayoutCellPaintEventArgs(e, clipRect, insideCellBounds, i, j)) + using (TableLayoutCellPaintEventArgs pcea = new(e, clipRect, insideCellBounds, i, j)) { OnCellPaint(pcea); if (!((IGraphicsHdcProvider)pcea).IsGraphicsStateClean) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelCellBorderStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelCellBorderStyle.cs index 909afc02083..7cb0524022c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelCellBorderStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelCellBorderStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelCellPosition.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelCellPosition.cs index 8284b942d6b..3400b217518 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelCellPosition.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelCellPosition.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; @@ -29,7 +28,7 @@ public TableLayoutPanelCellPosition(int column, int row) public int Column { get; set; } - public override bool Equals(object? other) + public override readonly bool Equals(object? other) { if (other is not TableLayoutPanelCellPosition otherCellPosition) { @@ -39,7 +38,7 @@ public override bool Equals(object? other) return Equals(otherCellPosition); } - public bool Equals(TableLayoutPanelCellPosition other) + public readonly bool Equals(TableLayoutPanelCellPosition other) => Row == other.Row && Column == other.Column; public static bool operator ==(TableLayoutPanelCellPosition p1, TableLayoutPanelCellPosition p2) @@ -52,7 +51,7 @@ public bool Equals(TableLayoutPanelCellPosition other) return !(p1 == p2); } - public override string ToString() => $"{Column},{Row}"; + public override readonly string ToString() => $"{Column},{Row}"; - public override int GetHashCode() => HashCode.Combine(Row, Column); + public override readonly int GetHashCode() => HashCode.Combine(Row, Column); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelCellPositionTypeConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelCellPositionTypeConverter.cs index 04f8bed3527..aa9a80a15dd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelCellPositionTypeConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelCellPositionTypeConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelGrowStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelGrowStyle.cs index 0ade8e57d7b..f160e980f61 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelGrowStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanelGrowStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutRowStyleCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutRowStyleCollection.cs index 230bd8ce6a4..b391679e7e3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutRowStyleCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutRowStyleCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.ControlInformation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.ControlInformation.cs index ce856b2cf1c..e14596ffd31 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.ControlInformation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.ControlInformation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.StyleConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.StyleConverter.cs index 894856cc273..9c70ccd49c6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.StyleConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.StyleConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.TableLayoutSettingsStub.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.TableLayoutSettingsStub.cs index 88cca7dc85c..bdabf06e221 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.TableLayoutSettingsStub.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.TableLayoutSettingsStub.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.ComponentModel; using System.Windows.Forms.Layout; @@ -13,10 +10,10 @@ public sealed partial class TableLayoutSettings { private class TableLayoutSettingsStub { - private static ControlInformation s_defaultControlInfo = new ControlInformation(null, -1, -1, 1, 1); - private TableLayoutColumnStyleCollection _columnStyles; - private TableLayoutRowStyleCollection _rowStyles; - private Dictionary _controlsInfo; + private static ControlInformation s_defaultControlInfo = new(null, -1, -1, 1, 1); + private TableLayoutColumnStyleCollection? _columnStyles; + private TableLayoutRowStyleCollection? _rowStyles; + private Dictionary? _controlsInfo; public TableLayoutSettingsStub() { @@ -48,8 +45,8 @@ internal void ApplySettings(TableLayoutSettings settings) { if (tableControl is not null) { - string name = null; - PropertyDescriptor prop = TypeDescriptor.GetProperties(tableControl)["Name"]; + string? name = null; + PropertyDescriptor? prop = TypeDescriptor.GetProperties(tableControl)["Name"]; if (prop is not null && prop.PropertyType == typeof(string)) { name = prop.GetValue(tableControl) as string; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.cs index 3ad37862cb0..0887eca057c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.Serialization; @@ -29,14 +28,17 @@ public sealed partial class TableLayoutSettings : LayoutSettings, ISerializable private TableLayoutSettingsStub? _stub; // used by TableLayoutSettingsTypeConverter - internal TableLayoutSettings() : base(null) + internal TableLayoutSettings() + : base(null) { _stub = new TableLayoutSettingsStub(); } - internal TableLayoutSettings(IArrangedElement owner) : base(owner) { } + internal TableLayoutSettings(IArrangedElement owner) + : base(owner) { } - private TableLayoutSettings(SerializationInfo serializationInfo, StreamingContext context) : this() + private TableLayoutSettings(SerializationInfo serializationInfo, StreamingContext context) + : this() { TypeConverter converter = TypeDescriptor.GetConverter(this); string? stringVal = serializationInfo.GetString("SerializedString"); @@ -518,7 +520,7 @@ internal List GetControlsInformation() { if (element is Control c) { - ControlInformation controlInfo = default(ControlInformation); + ControlInformation controlInfo = default; // We need to go through the PropertyDescriptor for the Name property // since it is shadowed. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettingsTypeConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettingsTypeConverter.cs index 1330c962cfd..6483d33b363 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettingsTypeConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettingsTypeConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutStyle.cs index 8ddd5e33d3f..b9152f23f46 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutStyleCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutStyleCollection.cs index 9dcb7d69adc..2d221bceb47 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutStyleCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutStyleCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.WindowSubclassHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.WindowSubclassHandler.cs index 9471136de4d..293647a82e5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.WindowSubclassHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.WindowSubclassHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.cs index ac34a96b26a..7c92744095b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.InteropServices; @@ -73,7 +72,7 @@ public partial class TaskDialog : IWin32Window /// notification was /// not yet received. /// - private readonly Queue _waitingNavigationPages = new Queue(); + private readonly Queue _waitingNavigationPages = new(); /// /// The of a that represents this @@ -613,10 +612,7 @@ internal void SwitchProgressBarMode(bool marqueeProgressBar) => SendTaskDialogMe /// internal unsafe void SetProgressBarMarquee(bool enableMarquee, int animationSpeed = 0) { - if (animationSpeed < 0) - { - throw new ArgumentOutOfRangeException(nameof(animationSpeed)); - } + ArgumentOutOfRangeException.ThrowIfNegative(animationSpeed); SendTaskDialogMessage( TASKDIALOG_MESSAGES.TDM_SET_PROGRESS_BAR_MARQUEE, @@ -634,15 +630,11 @@ internal unsafe void SetProgressBarMarquee(bool enableMarquee, int animationSpee /// internal unsafe void SetProgressBarRange(int min, int max) { - if (min < 0 || min > ushort.MaxValue) - { - throw new ArgumentOutOfRangeException(nameof(min)); - } + ArgumentOutOfRangeException.ThrowIfNegative(min); + ArgumentOutOfRangeException.ThrowIfGreaterThan(min, ushort.MaxValue); - if (max < 0 || max > ushort.MaxValue) - { - throw new ArgumentOutOfRangeException(nameof(max)); - } + ArgumentOutOfRangeException.ThrowIfNegative(max); + ArgumentOutOfRangeException.ThrowIfGreaterThan(max, ushort.MaxValue); SendTaskDialogMessage( TASKDIALOG_MESSAGES.TDM_SET_PROGRESS_BAR_RANGE, @@ -656,10 +648,8 @@ internal unsafe void SetProgressBarRange(int min, int max) /// internal void SetProgressBarPosition(int pos) { - if (pos < 0 || pos > ushort.MaxValue) - { - throw new ArgumentOutOfRangeException(nameof(pos)); - } + ArgumentOutOfRangeException.ThrowIfNegative(pos); + ArgumentOutOfRangeException.ThrowIfGreaterThan(pos, ushort.MaxValue); SendTaskDialogMessage( TASKDIALOG_MESSAGES.TDM_SET_PROGRESS_BAR_POS, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButton.cs index 32989224d34..3a2598e8730 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; @@ -95,7 +94,7 @@ internal TaskDialogButton(TaskDialogResult standardButtonResult) /// /// Gets a standard instance representing the OK button. /// - public static TaskDialogButton OK => new TaskDialogButton(TaskDialogResult.OK); + public static TaskDialogButton OK => new(TaskDialogResult.OK); /// /// Gets a standard instance representing the Cancel button. @@ -108,37 +107,37 @@ internal TaskDialogButton(TaskDialogResult standardButtonResult) /// ). /// /// - public static TaskDialogButton Cancel => new TaskDialogButton(TaskDialogResult.Cancel); + public static TaskDialogButton Cancel => new(TaskDialogResult.Cancel); /// /// Gets a standard instance representing the Abort button. /// - public static TaskDialogButton Abort => new TaskDialogButton(TaskDialogResult.Abort); + public static TaskDialogButton Abort => new(TaskDialogResult.Abort); /// /// Gets a standard instance representing the Retry button. /// - public static TaskDialogButton Retry => new TaskDialogButton(TaskDialogResult.Retry); + public static TaskDialogButton Retry => new(TaskDialogResult.Retry); /// /// Gets a standard instance representing the Ignore button. /// - public static TaskDialogButton Ignore => new TaskDialogButton(TaskDialogResult.Ignore); + public static TaskDialogButton Ignore => new(TaskDialogResult.Ignore); /// /// Gets a standard instance representing the Yes button. /// - public static TaskDialogButton Yes => new TaskDialogButton(TaskDialogResult.Yes); + public static TaskDialogButton Yes => new(TaskDialogResult.Yes); /// /// Gets a standard instance representing the No button. /// - public static TaskDialogButton No => new TaskDialogButton(TaskDialogResult.No); + public static TaskDialogButton No => new(TaskDialogResult.No); /// /// Gets a standard instance representing the Close button. /// - public static TaskDialogButton Close => new TaskDialogButton(TaskDialogResult.Close); + public static TaskDialogButton Close => new(TaskDialogResult.Close); /// /// Gets a standard instance representing the Help button. @@ -149,17 +148,17 @@ internal TaskDialogButton(TaskDialogResult standardButtonResult) /// event. /// /// - public static TaskDialogButton Help => new TaskDialogButton(TaskDialogResult.Help); + public static TaskDialogButton Help => new(TaskDialogResult.Help); /// /// Gets a standard instance representing the Try Again button. /// - public static TaskDialogButton TryAgain => new TaskDialogButton(TaskDialogResult.TryAgain); + public static TaskDialogButton TryAgain => new(TaskDialogResult.TryAgain); /// /// Gets a standard instance representing the Continue button. /// - public static TaskDialogButton Continue => new TaskDialogButton(TaskDialogResult.Continue); + public static TaskDialogButton Continue => new(TaskDialogResult.Continue); /// /// Gets or sets a value that indicates whether the task dialog should close diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButtonCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButtonCollection.cs index 780c0a8492e..afd514672a7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButtonCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButtonCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.ObjectModel; @@ -12,7 +11,7 @@ namespace System.Windows.Forms; public class TaskDialogButtonCollection : Collection { // HashSet to detect duplicate items. - private readonly HashSet _itemSet = new HashSet(); + private readonly HashSet _itemSet = new(); /// /// Initializes a new instance of the class. @@ -37,7 +36,7 @@ public TaskDialogButtonCollection() /// public TaskDialogButton Add(string? text, bool enabled = true, bool allowCloseDialog = true) { - var button = new TaskDialogButton(text, enabled, allowCloseDialog); + TaskDialogButton button = new(text, enabled, allowCloseDialog); Add(button); return button; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogCommandLinkButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogCommandLinkButton.cs index 4f28ce9f9c5..d004782f9ef 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogCommandLinkButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogCommandLinkButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogControl.cs index 2d06d46080f..2dd25eb3474 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogExpander.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogExpander.cs index 57f774f9223..ccf2f8118b6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogExpander.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogExpander.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogExpanderPosition.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogExpanderPosition.cs index aeb2b7650c4..8ff6206c620 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogExpanderPosition.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogExpanderPosition.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogFootnote.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogFootnote.cs index 8c5d69a7bbe..2a7cbb4e1e9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogFootnote.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogFootnote.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; @@ -35,7 +34,7 @@ public TaskDialogFootnote(string? text) } public static implicit operator TaskDialogFootnote(string footnoteText) - => new TaskDialogFootnote(footnoteText); + => new(footnoteText); /// /// Gets or sets the text to be displayed in the dialog's footnote area. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogIcon.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogIcon.cs index 101ea5c4321..52215aacefc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogIcon.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogIcon.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; @@ -35,61 +34,61 @@ public class TaskDialogIcon : IDisposable /// Gets a standard instance where the task dialog /// does not display an icon. /// - public static readonly TaskDialogIcon None = new TaskDialogIcon(TaskDialogStandardIcon.None); + public static readonly TaskDialogIcon None = new(TaskDialogStandardIcon.None); /// /// Gets a standard instance where the task dialog /// contains a symbol consisting of a lowercase letter i in a circle. /// - public static readonly TaskDialogIcon Information = new TaskDialogIcon(TaskDialogStandardIcon.Information); + public static readonly TaskDialogIcon Information = new(TaskDialogStandardIcon.Information); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of an exclamation point in a triangle with a yellow background. /// - public static readonly TaskDialogIcon Warning = new TaskDialogIcon(TaskDialogStandardIcon.Warning); + public static readonly TaskDialogIcon Warning = new(TaskDialogStandardIcon.Warning); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of white X in a circle with a red background. /// - public static readonly TaskDialogIcon Error = new TaskDialogIcon(TaskDialogStandardIcon.Error); + public static readonly TaskDialogIcon Error = new(TaskDialogStandardIcon.Error); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of an user account control (UAC) shield. /// - public static readonly TaskDialogIcon Shield = new TaskDialogIcon(TaskDialogStandardIcon.Shield); + public static readonly TaskDialogIcon Shield = new(TaskDialogStandardIcon.Shield); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of an user account control (UAC) shield and shows a blue bar around the icon. /// - public static readonly TaskDialogIcon ShieldBlueBar = new TaskDialogIcon(TaskDialogStandardIcon.ShieldBlueBar); + public static readonly TaskDialogIcon ShieldBlueBar = new(TaskDialogStandardIcon.ShieldBlueBar); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of an user account control (UAC) shield and shows a gray bar around the icon. /// - public static readonly TaskDialogIcon ShieldGrayBar = new TaskDialogIcon(TaskDialogStandardIcon.ShieldGrayBar); + public static readonly TaskDialogIcon ShieldGrayBar = new(TaskDialogStandardIcon.ShieldGrayBar); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of an exclamation point in a yellow shield and shows a yellow bar around the icon. /// - public static readonly TaskDialogIcon ShieldWarningYellowBar = new TaskDialogIcon(TaskDialogStandardIcon.ShieldWarningYellowBar); + public static readonly TaskDialogIcon ShieldWarningYellowBar = new(TaskDialogStandardIcon.ShieldWarningYellowBar); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of white X in a red shield and shows a red bar around the icon. /// - public static readonly TaskDialogIcon ShieldErrorRedBar = new TaskDialogIcon(TaskDialogStandardIcon.ShieldErrorRedBar); + public static readonly TaskDialogIcon ShieldErrorRedBar = new(TaskDialogStandardIcon.ShieldErrorRedBar); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of white tick in a green shield and shows a green bar around the icon. /// - public static readonly TaskDialogIcon ShieldSuccessGreenBar = new TaskDialogIcon(TaskDialogStandardIcon.ShieldSuccessGreenBar); + public static readonly TaskDialogIcon ShieldSuccessGreenBar = new(TaskDialogStandardIcon.ShieldSuccessGreenBar); #pragma warning restore IDE1006 // Naming Styles private readonly TaskDialogStandardIcon? _standardIcon; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogLinkClickedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogLinkClickedEventArgs.cs index 7d6dfb96ce1..2101e8525c6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogLinkClickedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogLinkClickedEventArgs.cs @@ -1,4 +1,7 @@ -namespace System.Windows.Forms; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Windows.Forms; /// /// Provides data for the event. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogPage.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogPage.cs index ad41e0f777b..0c9d08f7db0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogPage.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogPage.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogProgressBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogProgressBar.cs index 7b83ab3b3c8..b50112a3a64 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogProgressBar.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogProgressBar.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -131,10 +130,8 @@ public int Minimum get => _minimum; set { - if (value < 0 || value > ushort.MaxValue) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } + ArgumentOutOfRangeException.ThrowIfNegative(value); + ArgumentOutOfRangeException.ThrowIfGreaterThan(value, ushort.MaxValue); DenyIfBoundAndNotCreated(); @@ -179,10 +176,8 @@ public int Maximum get => _maximum; set { - if (value < 0 || value > ushort.MaxValue) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } + ArgumentOutOfRangeException.ThrowIfNegative(value); + ArgumentOutOfRangeException.ThrowIfGreaterThan(value, ushort.MaxValue); DenyIfBoundAndNotCreated(); @@ -227,10 +222,8 @@ public int Value get => _value; set { - if (value < 0 || value > ushort.MaxValue) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } + ArgumentOutOfRangeException.ThrowIfNegative(value); + ArgumentOutOfRangeException.ThrowIfGreaterThan(value, ushort.MaxValue); DenyIfBoundAndNotCreated(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogProgressBarState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogProgressBarState.cs index 3651353c58a..93993e07b87 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogProgressBarState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogProgressBarState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogRadioButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogRadioButton.cs index dd048d3da4d..87e36a94d0a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogRadioButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogRadioButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogRadioButtonCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogRadioButtonCollection.cs index bb0174eaafa..0087f59e7e1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogRadioButtonCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogRadioButtonCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.ObjectModel; @@ -12,7 +11,7 @@ namespace System.Windows.Forms; public class TaskDialogRadioButtonCollection : Collection { // HashSet to detect duplicate items. - private readonly HashSet _itemSet = new HashSet(); + private readonly HashSet _itemSet = new(); /// /// Initializes a new instance of the class. @@ -33,7 +32,7 @@ public TaskDialogRadioButtonCollection() /// public TaskDialogRadioButton Add(string? text) { - var button = new TaskDialogRadioButton() + TaskDialogRadioButton button = new() { Text = text }; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogResult.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogResult.cs index c48e3eedcc9..0cc293c4773 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogResult.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogResult.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogStandardIcon.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogStandardIcon.cs index d89a67fd524..41ea772b2f7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogStandardIcon.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogStandardIcon.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogStartupLocation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogStartupLocation.cs index 86492a2afe4..a87ca897ed7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogStartupLocation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogStartupLocation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogVerificationCheckBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogVerificationCheckBox.cs index edf5a31806b..358f439c159 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogVerificationCheckBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogVerificationCheckBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; @@ -40,7 +39,7 @@ public TaskDialogVerificationCheckBox(string? text, bool isChecked = false) } public static implicit operator TaskDialogVerificationCheckBox(string verificationText) - => new TaskDialogVerificationCheckBox(verificationText); + => new(verificationText); /// /// Gets or sets the text associated with this control. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextBox.TextBoxAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextBox.TextBoxAccessibleObject.cs index b30008e415b..abb1dbbb63c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextBox.TextBoxAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextBox.TextBoxAccessibleObject.cs @@ -1,4 +1,7 @@ -using static Interop; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using static Interop; namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextBox.cs index 9d3d1839230..30f740198cc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -17,7 +16,7 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionTextBox))] public partial class TextBox : TextBoxBase { - private static readonly object EVENT_TEXTALIGNCHANGED = new object(); + private static readonly object EVENT_TEXTALIGNCHANGED = new(); /// /// Controls whether or not the edit box consumes/respects ENTER key @@ -967,7 +966,7 @@ protected override unsafe void WndProc(ref Message m) PInvoke.InvalidateRect(this, lpRect: null, bErase: true); // Use BeginPaint instead of GetDC to prevent flicker and support print-to-image scenarios. - using var paintScope = new PInvoke.BeginPaintScope((HWND)Handle); + using PInvoke.BeginPaintScope paintScope = new((HWND)Handle); DrawPlaceholderText(paintScope); PInvoke.ValidateRect(this, lpRect: null); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxAutoCompleteSourceConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxAutoCompleteSourceConverter.cs index 52fc562a9ee..a028fe507bd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxAutoCompleteSourceConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxAutoCompleteSourceConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.TextBoxBaseAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.TextBoxBaseAccessibleObject.cs index bac4ef969e7..ec5267bdbca 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.TextBoxBaseAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.TextBoxBaseAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static System.Windows.Forms.ButtonBase; @@ -45,9 +44,17 @@ internal void ClearObjects() internal override object? GetPropertyValue(UIA propertyID) { - if (propertyID == UIA.IsPasswordPropertyId && this.TryGetOwnerAs(out TextBoxBase? owner)) + if (this.TryGetOwnerAs(out TextBoxBase? owner)) { - return owner.PasswordProtect; + if (propertyID == UIA.IsPasswordPropertyId) + { + return owner.PasswordProtect; + } + + if (propertyID == UIA.HasKeyboardFocusPropertyId) + { + return owner.Focused; + } } return base.GetPropertyValue(propertyID); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.TextBoxBaseUiaTextProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.TextBoxBaseUiaTextProvider.cs index 4b0d747a47b..a5573b980cd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.TextBoxBaseUiaTextProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.TextBoxBaseUiaTextProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Automation; @@ -206,7 +205,16 @@ public override LOGFONTW Logfont public override string Text => Owner is not null && Owner.IsHandleCreated - ? Owner.Text + ? Owner.PasswordProtect + ? PasswordString + : Owner.Text + : string.Empty; + + private string PasswordString + => Owner is not null + ? new string(Owner is TextBox + ? ((TextBox)Owner).PasswordChar + : ((MaskedTextBox)Owner).PasswordChar, Owner.Text.Length) : string.Empty; public override int TextLength => Text.Length; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.cs index 3654c5abfed..0e53dafa0d1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -9,6 +8,7 @@ using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms.Layout; +using Windows.Win32.System.Com; using static Interop; namespace System.Windows.Forms; @@ -39,12 +39,12 @@ public abstract partial class TextBoxBase : Control private static readonly int scrollToCaretOnHandleCreated = BitVector32.CreateMask(shortcutsEnabled); private static readonly int setSelectionOnHandleCreated = BitVector32.CreateMask(scrollToCaretOnHandleCreated); - private static readonly object EVENT_ACCEPTSTABCHANGED = new object(); - private static readonly object EVENT_BORDERSTYLECHANGED = new object(); - private static readonly object EVENT_HIDESELECTIONCHANGED = new object(); - private static readonly object EVENT_MODIFIEDCHANGED = new object(); - private static readonly object EVENT_MULTILINECHANGED = new object(); - private static readonly object EVENT_READONLYCHANGED = new object(); + private static readonly object EVENT_ACCEPTSTABCHANGED = new(); + private static readonly object EVENT_BORDERSTYLECHANGED = new(); + private static readonly object EVENT_HIDESELECTIONCHANGED = new(); + private static readonly object EVENT_MODIFIEDCHANGED = new(); + private static readonly object EVENT_MULTILINECHANGED = new(); + private static readonly object EVENT_READONLYCHANGED = new(); /// /// The current border for this edit control. @@ -1694,9 +1694,9 @@ public unsafe void ScrollToCaret() try { - Marshal.QueryInterface(editOlePtr, ref iiTextDocumentGuid, out iTextDocument); + Marshal.QueryInterface(editOlePtr, in iiTextDocumentGuid, out iTextDocument); - if (Marshal.GetObjectForIUnknown(iTextDocument) is Richedit.ITextDocument textDocument) + if (ComHelpers.GetObjectForIUnknown((IUnknown*)iTextDocument) is Richedit.ITextDocument textDocument) { // When the user calls RichTextBox::ScrollToCaret we want the RichTextBox to show as // much text as possible. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxRenderer.cs index b6016b6690e..6dd639b84b2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextDataFormat.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextDataFormat.cs index d896bfad7cb..9601bc8ddb7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextDataFormat.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextDataFormat.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextExtensions.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextExtensions.cs index 472868bdc66..87ad6d74123 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextExtensions.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Internal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextFormatFlags.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextFormatFlags.cs index 0d4ad12c2d1..812cf1f9423 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextFormatFlags.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextFormatFlags.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextImageRelation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextImageRelation.cs index dd81e668a0a..9e72857f86a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextImageRelation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextImageRelation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextRenderer.cs index 48eb36a7852..7a0e7b69ba4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Text; @@ -305,7 +304,7 @@ internal static void DrawTextInternal( // This MUST come before retrieving the HDC, which locks the Graphics object FONT_QUALITY quality = FontQualityFromTextRenderingHint(dc); - using var hdc = new DeviceContextHdcScope(dc, GetApplyStateFlags(dc, flags)); + using DeviceContextHdcScope hdc = new(dc, GetApplyStateFlags(dc, flags)); DrawTextInternal(hdc, text, font, bounds, foreColor, quality, backColor, flags); } @@ -334,7 +333,7 @@ internal static void DrawTextInternal( // This MUST come before retrieving the HDC, which locks the Graphics object FONT_QUALITY quality = FontQualityFromTextRenderingHint(e.GraphicsInternal); - using var graphicsHdc = new DeviceContextHdcScope(e.GraphicsInternal, applyGraphicsState: false); + using DeviceContextHdcScope graphicsHdc = new(e.GraphicsInternal, applyGraphicsState: false); DrawTextInternal(graphicsHdc, text, font, bounds, foreColor, quality, backColor, flags); } else @@ -539,7 +538,7 @@ private static Size MeasureTextInternal( // Applying state may not impact text size measurements. Rather than risk missing some // case we'll apply as we have historically to avoid surprise regressions. - using var hdc = new DeviceContextHdcScope(dc, GetApplyStateFlags(dc, flags)); + using DeviceContextHdcScope hdc = new(dc, GetApplyStateFlags(dc, flags)); using var hfont = GdiCache.GetHFONT(font, quality, hdc); return hdc.HDC.MeasureText(text, hfont, proposedSize, flags); } @@ -619,6 +618,18 @@ internal static ApplyGraphicsProperties GetApplyStateFlags(IDeviceContext device #if DEBUG if ((textFormatFlags & SkipAssertFlag) == 0) { + // Clipping and translation transforms applied to Graphics objects are not done on the underlying HDC. + // When we're rendering text to the HDC we, by default, should apply both. If it is *known* that these + // aren't wanted we can get a _slight_ performance benefit by not applying them and in that case the + // SkipAssertFlag bit can be set to skip this check. + // + // This application of clipping and translation is meant to make Graphics.DrawText and TextRenderer.DrawText + // roughly equivalent in the way they render. + // + // Note that there aren't flags for other transforms. Windows 9x doesn't support HDC transforms outside of + // translation (rotation for example), and this likely impacted the decision to only have a translation + // flag when this was originally written. + Debug.Assert(apply.HasFlag(ApplyGraphicsProperties.Clipping) || graphics.Clip is null || graphics.Clip.GetHrgn(graphics) == IntPtr.Zero, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ThreadExceptionDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ThreadExceptionDialog.cs index 976eb091b14..e528374df0e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ThreadExceptionDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ThreadExceptionDialog.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -58,13 +57,13 @@ public class ThreadExceptionDialog : Form private readonly int _scaledPictureHeight = PICTUREHEIGHT; private readonly int _scaledExceptionMessageVerticalPadding = EXCEPTIONMESSAGEVERTICALPADDING; - private readonly PictureBox _pictureBox = new PictureBox(); - private readonly Label _message = new Label(); - private readonly Button _continueButton = new Button(); - private readonly Button _quitButton = new Button(); - private readonly Button _detailsButton = new Button(); - private readonly Button _helpButton = new Button(); - private readonly TextBox _details = new TextBox(); + private readonly PictureBox _pictureBox = new(); + private readonly Label _message = new(); + private readonly Button _continueButton = new(); + private readonly Button _quitButton = new(); + private readonly Button _detailsButton = new(); + private readonly Button _helpButton = new(); + private readonly TextBox _details = new(); private Bitmap? _expandImage; private Bitmap? _collapseImage; private bool _detailsVisible; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TickStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TickStyle.cs index de720d6c537..56fcc8ec710 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TickStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TickStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Timer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Timer.cs index 790bbec4dd4..e74c29636e9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Timer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Timer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.InteropServices; @@ -28,7 +27,7 @@ public class Timer : Component // Holder for the HWND that handles our Timer messages. private TimerNativeWindow? _timerWindow; - private readonly object _syncObj = new object(); + private readonly object _syncObj = new(); /// /// Initializes a new instance of the class. @@ -207,7 +206,7 @@ private bool EnsureHandle() if (HWND.IsNull) { // Create a totally vanilla invisible window just for WM_TIMER messages - var cp = new CreateParams + CreateParams cp = new() { Style = 0, ExStyle = 0, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.RestoreFocusMessageFilter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.RestoreFocusMessageFilter.cs index 05606a78787..06911182c6b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.RestoreFocusMessageFilter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.RestoreFocusMessageFilter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.ToolStripAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.ToolStripAccessibleObject.cs index 8deea3b2c56..667e14dfffc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.ToolStripAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.ToolStripAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.ToolStripAccessibleObjectWrapperForItemsOnOverflow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.ToolStripAccessibleObjectWrapperForItemsOnOverflow.cs index ab3b255b1a3..dcc56ffa96f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.ToolStripAccessibleObjectWrapperForItemsOnOverflow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.ToolStripAccessibleObjectWrapperForItemsOnOverflow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.cs index d81732a9be6..b97dbe4b8c1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; @@ -24,8 +23,8 @@ namespace System.Windows.Forms; [DefaultEvent(nameof(ItemClicked))] public partial class ToolStrip : ScrollableControl, IArrangedElement, ISupportToolStripPanel { - private static Size s_onePixel = new Size(1, 1); - internal static Point s_invalidMouseEnter = new Point(int.MaxValue, int.MaxValue); + private static Size s_onePixel = new(1, 1); + internal static Point s_invalidMouseEnter = new(int.MaxValue, int.MaxValue); private ToolStripItemCollection? _toolStripItemCollection; private ToolStripOverflowButton? _toolStripOverflowButton; @@ -63,8 +62,8 @@ public partial class ToolStrip : ScrollableControl, IArrangedElement, ISupportTo private Font? _defaultFont; private RestoreFocusMessageFilter? _restoreFocusFilter; - private static readonly Padding s_defaultPadding = new Padding(0, 0, 1, 0); - private static readonly Padding s_defaultGripMargin = new Padding(2); + private static readonly Padding s_defaultPadding = new(0, 0, 1, 0); + private static readonly Padding s_defaultGripMargin = new(2); private Padding _scaledDefaultPadding = s_defaultPadding; private Padding _scaledDefaultGripMargin = s_defaultGripMargin; @@ -74,16 +73,16 @@ public partial class ToolStrip : ScrollableControl, IArrangedElement, ISupportTo internal static int s_insertionBeamWidth = InsertionBeamWidth; - private static readonly object s_eventPaintGrip = new object(); - private static readonly object s_eventLayoutCompleted = new object(); - private static readonly object s_eventItemAdded = new object(); - private static readonly object s_eventItemRemoved = new object(); - private static readonly object s_eventLayoutStyleChanged = new object(); - private static readonly object s_eventRendererChanged = new object(); - private static readonly object s_eventItemClicked = new object(); - private static readonly object s_eventLocationChanging = new object(); - private static readonly object s_eventBeginDrag = new object(); - private static readonly object s_eventEndDrag = new object(); + private static readonly object s_eventPaintGrip = new(); + private static readonly object s_eventLayoutCompleted = new(); + private static readonly object s_eventItemAdded = new(); + private static readonly object s_eventItemRemoved = new(); + private static readonly object s_eventLayoutStyleChanged = new(); + private static readonly object s_eventRendererChanged = new(); + private static readonly object s_eventItemClicked = new(); + private static readonly object s_eventLocationChanging = new(); + private static readonly object s_eventBeginDrag = new(); + private static readonly object s_eventEndDrag = new(); private static readonly int s_propBindingContext = PropertyStore.CreateKey(); private static readonly int s_propTextDirection = PropertyStore.CreateKey(); @@ -108,17 +107,17 @@ public partial class ToolStrip : ScrollableControl, IArrangedElement, ISupportTo internal const int STATE_MENUACTIVE = 0x00008000; #if DEBUG - internal static readonly TraceSwitch s_selectionDebug = new TraceSwitch("SelectionDebug", "Debug ToolStrip Selection code"); - internal static readonly TraceSwitch s_dropTargetDebug = new TraceSwitch("DropTargetDebug", "Debug ToolStrip Drop code"); - internal static readonly TraceSwitch s_layoutDebugSwitch = new TraceSwitch("Layout debug", "Debug ToolStrip layout code"); - internal static readonly TraceSwitch s_mouseActivateDebug = new TraceSwitch("ToolStripMouseActivate", "Debug ToolStrip WM_MOUSEACTIVATE code"); - internal static readonly TraceSwitch s_mergeDebug = new TraceSwitch("ToolStripMergeDebug", "Debug toolstrip merging"); - internal static readonly TraceSwitch s_snapFocusDebug = new TraceSwitch("SnapFocus", "Debug snapping/restoration of focus"); - internal static readonly TraceSwitch s_flickerDebug = new TraceSwitch("FlickerDebug", "Debug excessive calls to Invalidate()"); - internal static readonly TraceSwitch s_itemReorderDebug = new TraceSwitch("ItemReorderDebug", "Debug excessive calls to Invalidate()"); - internal static readonly TraceSwitch s_mdiMergeDebug = new TraceSwitch("MDIMergeDebug", "Debug toolstrip MDI merging"); - internal static readonly TraceSwitch s_menuAutoExpandDebug = new TraceSwitch("MenuAutoExpand", "Debug menu auto expand"); - internal static readonly TraceSwitch s_controlTabDebug = new TraceSwitch("ControlTab", "Debug ToolStrip Control+Tab selection"); + internal static readonly TraceSwitch s_selectionDebug = new("SelectionDebug", "Debug ToolStrip Selection code"); + internal static readonly TraceSwitch s_dropTargetDebug = new("DropTargetDebug", "Debug ToolStrip Drop code"); + internal static readonly TraceSwitch s_layoutDebugSwitch = new("Layout debug", "Debug ToolStrip layout code"); + internal static readonly TraceSwitch s_mouseActivateDebug = new("ToolStripMouseActivate", "Debug ToolStrip WM_MOUSEACTIVATE code"); + internal static readonly TraceSwitch s_mergeDebug = new("ToolStripMergeDebug", "Debug toolstrip merging"); + internal static readonly TraceSwitch s_snapFocusDebug = new("SnapFocus", "Debug snapping/restoration of focus"); + internal static readonly TraceSwitch s_flickerDebug = new("FlickerDebug", "Debug excessive calls to Invalidate()"); + internal static readonly TraceSwitch s_itemReorderDebug = new("ItemReorderDebug", "Debug excessive calls to Invalidate()"); + internal static readonly TraceSwitch s_mdiMergeDebug = new("MDIMergeDebug", "Debug toolstrip MDI merging"); + internal static readonly TraceSwitch s_menuAutoExpandDebug = new("MenuAutoExpand", "Debug menu auto expand"); + internal static readonly TraceSwitch s_controlTabDebug = new("ControlTab", "Debug ToolStrip Control+Tab selection"); #else internal static readonly TraceSwitch? s_selectionDebug; internal static readonly TraceSwitch? s_dropTargetDebug; @@ -1759,7 +1758,7 @@ internal ToolTip ToolTip { get { - if (!Properties.TryGetObject(ToolStrip.s_propToolTip, out ToolTip? toolTip)) + if (!Properties.TryGetObject(ToolStrip.s_propToolTip, out ToolTip? toolTip) || toolTip is null) { toolTip = new ToolTip(); Properties.SetObject(ToolStrip.s_propToolTip, toolTip); @@ -2790,7 +2789,7 @@ private protected override void PrintToMetaFileRecursive(HDC hDC, IntPtr lParam, { using Bitmap image = new Bitmap(bounds.Width, bounds.Height); using Graphics g = Graphics.FromImage(image); - using var imageHdc = new DeviceContextHdcScope(g, applyGraphicsState: false); + using DeviceContextHdcScope imageHdc = new(g, applyGraphicsState: false); // Send the actual wm_print message PInvoke.SendMessage( @@ -3690,7 +3689,7 @@ protected override void OnPaint(PaintEventArgs e) // using WindowsGraphics here because we want to preserve the clipping information. // calling GetHdc by itself does not set up the clipping info. - using (var toolStripHDC = new DeviceContextHdcScope(toolstripGraphics, ApplyGraphicsProperties.Clipping)) + using (DeviceContextHdcScope toolStripHDC = new(toolstripGraphics, ApplyGraphicsProperties.Clipping)) { // Get the cached item HDC. HDC itemHDC = ItemHdcInfo.GetCachedItemDC(toolStripHDC, bitmapSize); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripArrowRenderEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripArrowRenderEventArgs.cs index e27017ea93d..48dd73071e0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripArrowRenderEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripArrowRenderEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripArrowRenderEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripArrowRenderEventHandler.cs index 9e76c997336..2d00c071eeb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripArrowRenderEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripArrowRenderEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripButton.ToolStripButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripButton.ToolStripButtonAccessibleObject.cs index 08ec040dbf6..1f1f3c3be94 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripButton.ToolStripButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripButton.ToolStripButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripButton.cs index 988e0097aca..9c337576752 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -16,8 +15,8 @@ public partial class ToolStripButton : ToolStripItem private const int StandardButtonWidth = 23; private int _standardButtonWidth = StandardButtonWidth; - private static readonly object s_checkedChangedEvent = new object(); - private static readonly object s_checkStateChangedEvent = new object(); + private static readonly object s_checkedChangedEvent = new(); + private static readonly object s_checkStateChangedEvent = new(); public ToolStripButton() { @@ -211,7 +210,7 @@ protected override void OnPaint(PaintEventArgs e) if ((DisplayStyle & ToolStripItemDisplayStyle.Image) == ToolStripItemDisplayStyle.Image) { - var rea = new ToolStripItemImageRenderEventArgs(e.Graphics, this, InternalLayout.ImageRectangle) + ToolStripItemImageRenderEventArgs rea = new(e.Graphics, this, InternalLayout.ImageRectangle) { ShiftOnPress = true }; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxControlAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxControlAccessibleObject.cs index ab51d97ba22..263f2d5e5a2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxControlAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxControlAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxFlatComboAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxFlatComboAdapter.cs index 6f4e7e4e196..51e301da927 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxFlatComboAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxFlatComboAdapter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Drawing2D; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.ToolStripComboBoxControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.ToolStripComboBoxControl.cs index 1c84a482ab6..64749288164 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.ToolStripComboBoxControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.ToolStripComboBoxControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.cs index ca4b99092ef..94b64f4bd0c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -13,15 +12,15 @@ namespace System.Windows.Forms; [DefaultProperty(nameof(Items))] public partial class ToolStripComboBox : ToolStripControlHost { - internal static readonly object s_eventDropDown = new object(); - internal static readonly object s_eventDropDownClosed = new object(); - internal static readonly object s_eventDropDownStyleChanged = new object(); - internal static readonly object s_eventSelectedIndexChanged = new object(); - internal static readonly object s_eventSelectionChangeCommitted = new object(); - internal static readonly object s_eventTextUpdate = new object(); + internal static readonly object s_eventDropDown = new(); + internal static readonly object s_eventDropDownClosed = new(); + internal static readonly object s_eventDropDownStyleChanged = new(); + internal static readonly object s_eventSelectedIndexChanged = new(); + internal static readonly object s_eventSelectionChangeCommitted = new(); + internal static readonly object s_eventTextUpdate = new(); - private static readonly Padding s_dropDownPadding = new Padding(2); - private static readonly Padding s_padding = new Padding(1, 0, 1, 0); + private static readonly Padding s_dropDownPadding = new(2); + private static readonly Padding s_padding = new(1, 0, 1, 0); private Padding _scaledDropDownPadding = s_dropDownPadding; private Padding _scaledPadding = s_padding; @@ -398,7 +397,6 @@ private void HandleTextUpdate(object? sender, EventArgs e) OnTextUpdate(e); } -#pragma warning disable CA2252 // Suppress 'Opt in to preview features' (https://aka.ms/dotnet-warnings/preview-features) protected virtual void OnDropDown(EventArgs e) { if (ParentInternal is not null) @@ -442,7 +440,6 @@ protected virtual void OnTextUpdate(EventArgs e) { RaiseEvent(s_eventTextUpdate, e); } -#pragma warning restore CA2252 protected override void OnSubscribeControlEvents(Control? control) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContainer.ToolStripContainerAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContainer.ToolStripContainerAccessibleObject.cs index 86bb50b799d..f43c9b67750 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContainer.ToolStripContainerAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContainer.ToolStripContainerAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContainer.ToolStripContainerTypedControlCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContainer.ToolStripContainerTypedControlCollection.cs index cf6d390e37a..55cd508a6d2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContainer.ToolStripContainerTypedControlCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContainer.ToolStripContainerTypedControlCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContainer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContainer.cs index bced0b94976..87bd2ee26ab 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContainer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContainer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanel.cs index 5c7f02c6d45..67bf7d42cba 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanel.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -19,8 +18,8 @@ public class ToolStripContentPanel : Panel private BitVector32 _state; private static readonly int s_stateLastDoubleBuffer = BitVector32.CreateMask(); - private static readonly object EventRendererChanged = new object(); - private static readonly object EventLoad = new object(); + private static readonly object EventRendererChanged = new(); + private static readonly object EventLoad = new(); public ToolStripContentPanel() { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanelRenderEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanelRenderEventArgs.cs index 6e630d25a77..83a2e71604b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanelRenderEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanelRenderEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanelRenderEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanelRenderEventHandler.cs index d2ba979c65d..8f8ee9a7558 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanelRenderEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanelRenderEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.StubSite.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.StubSite.cs index dbd80c19c7d..d02e96cf74c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.StubSite.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.StubSite.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.ToolStripControlHostAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.ToolStripControlHostAccessibleObject.cs index 387c767486c..17d1c7726a5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.ToolStripControlHostAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.ToolStripControlHostAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.ToolStripHostedControlAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.ToolStripHostedControlAccessibleObject.cs index 802a59e4ee4..becc1597856 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.ToolStripHostedControlAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.ToolStripHostedControlAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.cs index eb003d753f3..d3b1627f4c1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -19,15 +18,15 @@ public partial class ToolStripControlHost : ToolStripItem private ContentAlignment _controlAlign = ContentAlignment.MiddleCenter; private bool _inSetVisibleCore; - internal static readonly object s_gotFocusEvent = new object(); - internal static readonly object s_lostFocusEvent = new object(); - internal static readonly object s_keyDownEvent = new object(); - internal static readonly object s_keyPressEvent = new object(); - internal static readonly object s_keyUpEvent = new object(); - internal static readonly object s_enterEvent = new object(); - internal static readonly object s_leaveEvent = new object(); - internal static readonly object s_validatedEvent = new object(); - internal static readonly object s_validatingEvent = new object(); + internal static readonly object s_gotFocusEvent = new(); + internal static readonly object s_lostFocusEvent = new(); + internal static readonly object s_keyDownEvent = new(); + internal static readonly object s_keyPressEvent = new(); + internal static readonly object s_keyUpEvent = new(); + internal static readonly object s_enterEvent = new(); + internal static readonly object s_leaveEvent = new(); + internal static readonly object s_validatedEvent = new(); + internal static readonly object s_validatingEvent = new(); /// /// Constructs a ToolStripControlHost @@ -522,7 +521,6 @@ private void HandleMouseDown(object? sender, MouseEventArgs e) RaiseMouseEvent(s_mouseDownEvent, e); } -#pragma warning disable CA2252 // Suppress 'Opt in to preview features' (https://aka.ms/dotnet-warnings/preview-features) private void HandleMouseEnter(object? sender, EventArgs e) { OnMouseEnter(e); @@ -540,7 +538,6 @@ private void HandleMouseHover(object? sender, EventArgs e) OnMouseHover(e); RaiseEvent(s_mouseHoverEvent, e); } -#pragma warning restore CA2252 private void HandleMouseMove(object? sender, MouseEventArgs e) { @@ -618,7 +615,6 @@ internal override void OnAccessibleRoleChanged(EventArgs e) ControlInternal.AccessibleRole = AccessibleRole; } -#pragma warning disable CA2252 // Suppress 'Opt in to preview features' (https://aka.ms/dotnet-warnings/preview-features) protected virtual void OnEnter(EventArgs e) => RaiseEvent(s_enterEvent, e); /// @@ -632,7 +628,6 @@ internal override void OnAccessibleRoleChanged(EventArgs e) /// called when the control has lost focus /// protected virtual void OnLostFocus(EventArgs e) => RaiseEvent(s_lostFocusEvent, e); -#pragma warning restore CA2252 protected virtual void OnKeyDown(KeyEventArgs e) => RaiseKeyEvent(s_keyDownEvent, e); @@ -796,9 +791,7 @@ protected virtual void OnUnsubscribeControlEvents(Control? control) protected virtual void OnValidating(CancelEventArgs e) => RaiseCancelEvent(s_validatingEvent, e); -#pragma warning disable CA2252 // Suppress 'Opt in to preview features' (https://aka.ms/dotnet-warnings/preview-features) protected virtual void OnValidated(EventArgs e) => RaiseEvent(s_validatedEvent, e); -#pragma warning restore CA2252 private static ReadOnlyControlCollection? GetControlCollection(ToolStrip? toolStrip) => (ReadOnlyControlCollection?)toolStrip?.Controls; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripCustomIComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripCustomIComparer.cs index 8df0fccf104..fafcfabc4be 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripCustomIComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripCustomIComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDown.ToolStripDropDownAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDown.ToolStripDropDownAccessibleObject.cs index 525b2c53034..b5797e63fa9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDown.ToolStripDropDownAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDown.ToolStripDropDownAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDown.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDown.cs index c0d80f11c58..56356817a6a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDown.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDown.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -20,7 +19,7 @@ public partial class ToolStripDropDown : ToolStrip private bool autoSize = true; private int countDropDownItemsAssignedTo; // the number of dropdown items using this as their dropdown.. private BitVector32 state; - private Point displayLocation = new Point(0, 0); + private Point displayLocation = new(0, 0); private bool saveSourceControl; private ToolStripDropDownDirection childDropDownDirection = ToolStripDropDownDirection.Default; @@ -29,17 +28,17 @@ public partial class ToolStripDropDown : ToolStrip private static readonly int PropOpacity = PropertyStore.CreateKey(); private static readonly int PropSourceControl = PropertyStore.CreateKey(); - private static readonly object EventOpening = new object(); - private static readonly object EventOpened = new object(); - private static readonly object EventClosed = new object(); - private static readonly object EventClosing = new object(); + private static readonly object EventOpening = new(); + private static readonly object EventOpened = new(); + private static readonly object EventClosed = new(); + private static readonly object EventClosing = new(); - private static readonly Padding defaultPadding = new Padding(1, 2, 1, 2); + private static readonly Padding defaultPadding = new(1, 2, 1, 2); private Padding scaledDefaultPadding = defaultPadding; #if DEBUG - internal static TraceSwitch DropDownActivateDebug = new TraceSwitch("DropDownActivateDebug", "Debug activation code for dropDown controls"); - internal static TraceSwitch DropDownDebugBounds = new TraceSwitch("DropDownDebugBounds", "Debug GetDropDownBounds"); + internal static TraceSwitch DropDownActivateDebug = new("DropDownActivateDebug", "Debug activation code for dropDown controls"); + internal static TraceSwitch DropDownDebugBounds = new("DropDownDebugBounds", "Debug GetDropDownBounds"); #else internal static TraceSwitch? DropDownActivateDebug; internal static TraceSwitch? DropDownDebugBounds; @@ -1816,7 +1815,7 @@ protected override void SetVisibleCore(bool visible) ToolStripDropDownCloseReason reason = closeReason; ResetCloseReason(); - var e = new ToolStripDropDownClosingEventArgs(reason); + ToolStripDropDownClosingEventArgs e = new(reason); // Fire Closing Event // Cancel is prepopulated based on AutoClose feature. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownButton.ToolStripDropDownButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownButton.ToolStripDropDownButtonAccessibleObject.cs index a8747442840..fe1cc14a4b6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownButton.ToolStripDropDownButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownButton.ToolStripDropDownButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownButton.ToolStripDropDownButtonInternalLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownButton.ToolStripDropDownButtonInternalLayout.cs index 047935c0c05..fa71edec6cb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownButton.ToolStripDropDownButtonInternalLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownButton.ToolStripDropDownButtonInternalLayout.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownButton.cs index a921f4a0e98..ffaf26309af 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownCloseReason.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownCloseReason.cs index b2645ac8cf7..5c27302cdfe 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownCloseReason.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownCloseReason.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosedEventArgs.cs index eb3eeba910f..24ac4dc007d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosedEventHandler.cs index 6c2bed111fc..3d5deaa6fb1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosingEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosingEventArgs.cs index 6e6aea1266c..7d443326cc7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosingEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosingEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosingEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosingEventHandler.cs index 510716546cc..e3515ddb1d0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosingEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownClosingEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownDirection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownDirection.cs index 3af859cb2c7..d8374e8e2a4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownDirection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownDirection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownItem.cs index 195471e20a2..ed6049004ac 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -19,11 +18,11 @@ public abstract class ToolStripDropDownItem : ToolStripItem private ToolStripDropDown? _dropDown; private ToolStripDropDownDirection _toolStripDropDownDirection = ToolStripDropDownDirection.Default; private ToolTip? _hookedKeyboardTooltip; - private static readonly object EventDropDownShow = new object(); - private static readonly object EventDropDownHide = new object(); - private static readonly object EventDropDownOpened = new object(); - private static readonly object EventDropDownClosed = new object(); - private static readonly object EventDropDownItemClicked = new object(); + private static readonly object EventDropDownShow = new(); + private static readonly object EventDropDownHide = new(); + private static readonly object EventDropDownOpened = new(); + private static readonly object EventDropDownClosed = new(); + private static readonly object EventDropDownItemClicked = new(); /// /// Protected ctor so you can't create one of these without deriving from it. @@ -775,7 +774,7 @@ internal override void ToolStrip_RescaleConstants(int oldDpi, int newDpi) // Traversing the tree of DropDownMenuItems non-recursively to set new // Font (where necessary because not inherited from parent), DeviceDpi and reset the scaling. - var itemsStack = new Stack(); + Stack itemsStack = new(); itemsStack.Push(this); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownItemAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownItemAccessibleObject.cs index 60335f12cac..e80fcc99430 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownItemAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownItemAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.Layout; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.ToolStripDropDownLayoutEngine.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.ToolStripDropDownLayoutEngine.cs index aab2188d98d..56488e9cb99 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.ToolStripDropDownLayoutEngine.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.ToolStripDropDownLayoutEngine.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.ToolStripDropDownMenuAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.ToolStripDropDownMenuAccessibleObject.cs index d7f9a4edc2a..dcbfc3037e1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.ToolStripDropDownMenuAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.ToolStripDropDownMenuAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.cs index dd2d82b2ad2..81ef2f30811 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -12,10 +11,10 @@ namespace System.Windows.Forms; [Designer($"System.Windows.Forms.Design.ToolStripDropDownDesigner, {AssemblyRef.SystemDesign}")] public partial class ToolStripDropDownMenu : ToolStripDropDown { - private static readonly Padding ImagePadding = new Padding(2); - private static readonly Padding TextPadding = new Padding(8, 1, 9, 1); - private static readonly Padding CheckPadding = new Padding(5, 2, 2, 2); - private static readonly Padding ArrowPadding = new Padding(0, 0, 8, 0); + private static readonly Padding ImagePadding = new(2); + private static readonly Padding TextPadding = new(8, 1, 9, 1); + private static readonly Padding CheckPadding = new(5, 2, 2, 2); + private static readonly Padding ArrowPadding = new(0, 0, 8, 0); // This is totally a UI Fudge - if we have an image or check margin with // no image or checks in it use this - which is consistent with office @@ -45,7 +44,7 @@ public partial class ToolStripDropDownMenu : ToolStripDropDown private static readonly int stateShowCheckMargin = BitVector32.CreateMask(stateShowImageMargin); private static readonly int stateMaxItemSizeValid = BitVector32.CreateMask(stateShowCheckMargin); - private static readonly Size DefaultImageSize = new Size(16, 16); + private static readonly Size DefaultImageSize = new(16, 16); private Size _scaledDefaultImageSize = DefaultImageSize; private int _scaledDefaultImageMarginWidth = DefaultImageMarginWidth + 1; // 1px for border diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropTargetManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropTargetManager.cs index 6229b8dae5f..79222015b14 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropTargetManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropTargetManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -23,7 +22,7 @@ internal class ToolStripDropTargetManager : IDropTarget #endif #if DEBUG - internal static readonly TraceSwitch DragDropDebug = new TraceSwitch("DragDropDebug", "Debug ToolStrip DragDrop code"); + internal static readonly TraceSwitch DragDropDebug = new("DragDropDebug", "Debug ToolStrip DragDrop code"); #else internal static readonly TraceSwitch? DragDropDebug; #endif diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGrip.ToolStripGripAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGrip.ToolStripGripAccessibleObject.cs index c22bb2e12d7..06cf6fa15c7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGrip.ToolStripGripAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGrip.ToolStripGripAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGrip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGrip.cs index 21c1de31196..3a56247d788 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGrip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGrip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Layout; @@ -15,7 +14,7 @@ internal partial class ToolStripGrip : ToolStripButton private Point _lastEndLocation = ToolStrip.s_invalidMouseEnter; private static Size s_dragSize = LayoutUtils.s_maxSize; - private static readonly Padding _defaultPadding = new Padding(2); + private static readonly Padding _defaultPadding = new(2); private const int GripThicknessDefault = 3; private const int GripThicknessVisualStylesEnabled = 5; private Padding _scaledDefaultPadding = _defaultPadding; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripDisplayStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripDisplayStyle.cs index 3f7136f4b6b..4415b624a1d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripDisplayStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripDisplayStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripRenderEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripRenderEventArgs.cs index a6613f291a8..cae191e3c69 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripRenderEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripRenderEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripRenderEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripRenderEventHandler.cs index 6631eb970d5..a8ee14a824f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripRenderEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripRenderEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripStyle.cs index 77c8edc6b88..45bc0e4219f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGripStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripHighContrastRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripHighContrastRenderer.cs index 74871d962d4..be33d285e94 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripHighContrastRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripHighContrastRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.Drawing; @@ -444,16 +443,16 @@ private static void RenderItemInternalFilled(ToolStripItemRenderEventArgs e, boo private static void DrawHightContrastDashedBorder(Graphics graphics, ToolStripItem item) { - var bounds = item.ClientBounds; + Rectangle bounds = item.ClientBounds; float[] dashValues = { 2, 2 }; int penWidth = 2; - var focusPen1 = new Pen(SystemColors.ControlText, penWidth) + Pen focusPen1 = new(SystemColors.ControlText, penWidth) { DashPattern = dashValues }; - var focusPen2 = new Pen(SystemColors.Control, penWidth) + Pen focusPen2 = new(SystemColors.Control, penWidth) { DashPattern = dashValues, DashOffset = 2 diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemAccessibleObject.cs index 90d1a553185..ddfcde31d45 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemImageIndexer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemImageIndexer.cs index e09704c3ac2..1ff87e65adb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemImageIndexer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemImageIndexer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.ToolStripItemLayoutOptions.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.ToolStripItemLayoutOptions.cs index a1929964c04..66f6db983ef 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.ToolStripItemLayoutOptions.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.ToolStripItemLayoutOptions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.ButtonInternal; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.ToolStripLayoutData.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.ToolStripLayoutData.cs index f27fccad1e3..5493ba92634 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.ToolStripLayoutData.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.ToolStripLayoutData.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.cs index 6ba64600b04..6a08655c2c8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.ButtonInternal; @@ -18,7 +17,7 @@ internal partial class ToolStripItemInternalLayout private readonly ToolStripItem _ownerItem; private ButtonBaseAdapter.LayoutData? _layoutData; private const int BorderWidth = 2; - private static readonly Size s_invalidSize = new Size(int.MinValue, int.MinValue); + private static readonly Size s_invalidSize = new(int.MinValue, int.MinValue); private Size _lastPreferredSize = s_invalidSize; private ToolStripLayoutData? _parentLayoutData; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.cs index 7941f56faba..61c0d494469 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.cs @@ -1,13 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; using System.Drawing; using System.Drawing.Design; using System.Drawing.Imaging; -using System.Runtime.Versioning; using System.Windows.Forms.Layout; using Windows.Win32.System.Ole; using static Interop; @@ -15,7 +13,6 @@ namespace System.Windows.Forms; -#pragma warning disable CA2252 // Suppress 'Opt in to preview features' (https://aka.ms/dotnet-warnings/preview-features) [DesignTimeVisible(false)] [Designer($"System.Windows.Forms.Design.ToolStripItemDesigner, {AssemblyRef.SystemDesign}")] [DefaultEvent(nameof(Click))] @@ -29,7 +26,7 @@ public abstract partial class ToolStripItem : BindableComponent, IKeyboardToolTip { #if DEBUG - internal static readonly TraceSwitch s_mouseDebugging = new TraceSwitch("MouseDebugging", "Debug ToolStripItem mouse debugging code"); + internal static readonly TraceSwitch s_mouseDebugging = new("MouseDebugging", "Debug ToolStripItem mouse debugging code"); #else internal static readonly TraceSwitch? s_mouseDebugging; #endif @@ -52,8 +49,8 @@ public abstract partial class ToolStripItem : BindableComponent, private ToolStripItemImageScaling _imageScaling = ToolStripItemImageScaling.SizeToFit; private Size _cachedTextSize; - private static readonly Padding s_defaultMargin = new Padding(0, 1, 0, 2); - private static readonly Padding s_defaultStatusStripMargin = new Padding(0, 2, 0, 0); + private static readonly Padding s_defaultMargin = new(0, 1, 0, 2); + private static readonly Padding s_defaultStatusStripMargin = new(0, 2, 0, 0); private Padding _scaledDefaultMargin = s_defaultMargin; private Padding _scaledDefaultStatusStripMargin = s_defaultStatusStripMargin; @@ -63,36 +60,36 @@ public abstract partial class ToolStripItem : BindableComponent, private Input.ICommand? _command; private object? _commandParameter; - private static readonly ArrangedElementCollection s_emptyChildCollection = new ArrangedElementCollection(); - - internal static readonly object s_mouseDownEvent = new object(); - internal static readonly object s_mouseEnterEvent = new object(); - internal static readonly object s_mouseLeaveEvent = new object(); - internal static readonly object s_mouseHoverEvent = new object(); - internal static readonly object s_mouseMoveEvent = new object(); - internal static readonly object s_mouseUpEvent = new object(); - internal static readonly object s_clickEvent = new object(); - internal static readonly object s_doubleClickEvent = new object(); - internal static readonly object s_dragDropEvent = new object(); - internal static readonly object s_dragEnterEvent = new object(); - internal static readonly object s_dragLeaveEvent = new object(); - internal static readonly object s_dragOverEvent = new object(); - internal static readonly object s_displayStyleChangedEvent = new object(); - internal static readonly object s_enabledChangedEvent = new object(); - internal static readonly object s_internalEnabledChangedEvent = new object(); - internal static readonly object s_fontChangedEvent = new object(); - internal static readonly object s_foreColorChangedEvent = new object(); - internal static readonly object s_backColorChangedEvent = new object(); - internal static readonly object s_giveFeedbackEvent = new object(); - internal static readonly object s_queryContinueDragEvent = new object(); - internal static readonly object s_queryAccessibilityHelpEvent = new object(); - internal static readonly object s_locationChangedEvent = new object(); - internal static readonly object s_rightToLeftChangedEvent = new object(); - internal static readonly object s_visibleChangedEvent = new object(); - internal static readonly object s_availableChangedEvent = new object(); - internal static readonly object s_ownerChangedEvent = new object(); - internal static readonly object s_paintEvent = new object(); - internal static readonly object s_textChangedEvent = new object(); + private static readonly ArrangedElementCollection s_emptyChildCollection = new(); + + internal static readonly object s_mouseDownEvent = new(); + internal static readonly object s_mouseEnterEvent = new(); + internal static readonly object s_mouseLeaveEvent = new(); + internal static readonly object s_mouseHoverEvent = new(); + internal static readonly object s_mouseMoveEvent = new(); + internal static readonly object s_mouseUpEvent = new(); + internal static readonly object s_clickEvent = new(); + internal static readonly object s_doubleClickEvent = new(); + internal static readonly object s_dragDropEvent = new(); + internal static readonly object s_dragEnterEvent = new(); + internal static readonly object s_dragLeaveEvent = new(); + internal static readonly object s_dragOverEvent = new(); + internal static readonly object s_displayStyleChangedEvent = new(); + internal static readonly object s_enabledChangedEvent = new(); + internal static readonly object s_internalEnabledChangedEvent = new(); + internal static readonly object s_fontChangedEvent = new(); + internal static readonly object s_foreColorChangedEvent = new(); + internal static readonly object s_backColorChangedEvent = new(); + internal static readonly object s_giveFeedbackEvent = new(); + internal static readonly object s_queryContinueDragEvent = new(); + internal static readonly object s_queryAccessibilityHelpEvent = new(); + internal static readonly object s_locationChangedEvent = new(); + internal static readonly object s_rightToLeftChangedEvent = new(); + internal static readonly object s_visibleChangedEvent = new(); + internal static readonly object s_availableChangedEvent = new(); + internal static readonly object s_ownerChangedEvent = new(); + internal static readonly object s_paintEvent = new(); + internal static readonly object s_textChangedEvent = new(); internal static readonly object s_commandChangedEvent = new(); internal static readonly object s_commandParameterChangedEvent = new(); @@ -426,7 +423,6 @@ public virtual Image? BackgroundImage /// Gets or sets the whose /// method will be called when the ToolStripItem's event gets invoked. /// - [RequiresPreviewFeatures] [Bindable(true)] [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -442,7 +438,6 @@ public Input.ICommand? Command /// Occurs when the status of the /// which is assigned to the property has changed. /// - [RequiresPreviewFeatures] [SRCategory(nameof(SR.CatData))] [EditorBrowsable(EditorBrowsableState.Advanced)] [SRDescription(nameof(SR.CommandCanExecuteChangedEventDescr))] @@ -455,7 +450,6 @@ public event EventHandler? CommandCanExecuteChanged /// /// Occurs when the assigned of the property has changed. /// - [RequiresPreviewFeatures] [SRCategory(nameof(SR.CatData))] [EditorBrowsable(EditorBrowsableState.Advanced)] [SRDescription(nameof(SR.CommandChangedEventDescr))] @@ -476,11 +470,8 @@ public event EventHandler? CommandChanged [SRDescription(nameof(SR.CommandComponentCommandParameterDescr))] public object? CommandParameter { - [RequiresPreviewFeatures] get => _commandParameter; - // We need to opt into previre features here, because we calling a preview feature from the setter. - [RequiresPreviewFeatures] set { if (!Equals(_commandParameter, value)) @@ -494,7 +485,6 @@ public object? CommandParameter /// /// Occurs when the value of the property has changed. /// - [RequiresPreviewFeatures] [SRCategory(nameof(SR.CatData))] [EditorBrowsable(EditorBrowsableState.Advanced)] [SRDescription(nameof(SR.CommandParameterChangedEventDescr))] @@ -2131,7 +2121,7 @@ protected virtual AccessibleObject CreateAccessibilityInstance() /// gets laid out in the ToolStripItem /// private protected virtual ToolStripItemInternalLayout CreateInternalLayout() - => new ToolStripItemInternalLayout(this); + => new(this); /// /// Disposes this ToolStrip item. @@ -2702,8 +2692,6 @@ protected virtual void OnBoundsChanged() protected virtual void OnClick(EventArgs e) { RaiseEvent(s_clickEvent, e); - - // We won't let the preview feature warnings bubble further up beyond this point. OnRequestCommandExecute(e); } @@ -2751,7 +2739,6 @@ private void OnAnimationFrameChanged(object? o, EventArgs e) /// Raises the event. /// /// An empty instance. - [RequiresPreviewFeatures] [EditorBrowsable(EditorBrowsableState.Advanced)] protected virtual void OnCommandChanged(EventArgs e) => RaiseEvent(s_commandChangedEvent, e); @@ -2760,7 +2747,6 @@ protected virtual void OnCommandChanged(EventArgs e) /// Raises the event. /// /// An empty instance. - [RequiresPreviewFeatures] [EditorBrowsable(EditorBrowsableState.Advanced)] protected virtual void OnCommandCanExecuteChanged(EventArgs e) => ((EventHandler?)Events[s_commandCanExecuteChangedEvent])?.Invoke(this, e); @@ -2769,25 +2755,22 @@ protected virtual void OnCommandCanExecuteChanged(EventArgs e) /// Raises the event. /// /// An empty instance. - [RequiresPreviewFeatures] [EditorBrowsable(EditorBrowsableState.Advanced)] protected virtual void OnCommandParameterChanged(EventArgs e) => RaiseEvent(s_commandParameterChangedEvent, e); /// - /// Called in the context of to invoke if the context allows. + /// Called in the context of to invoke + /// if the context allows. /// /// An empty instance. - [RequiresPreviewFeatures] protected virtual void OnRequestCommandExecute(EventArgs e) => ICommandBindingTargetProvider.RequestCommandExecute(this); // Called by the CommandProviderManager's command handling logic. - [RequiresPreviewFeatures] void ICommandBindingTargetProvider.RaiseCommandChanged(EventArgs e) => OnCommandChanged(e); // Called by the CommandProviderManager's command handling logic. - [RequiresPreviewFeatures] void ICommandBindingTargetProvider.RaiseCommandCanExecuteChanged(EventArgs e) => OnCommandCanExecuteChanged(e); @@ -3742,5 +3725,3 @@ internal bool TryGetExplicitlySetFont([NotNullWhen(true)] out Font? local) return local is not null; } } -#pragma warning restore CA2252 - diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemAlignment.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemAlignment.cs index 0fe3c3ff18e..a82da573db0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemAlignment.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemAlignment.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemClickedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemClickedEventArgs.cs index c246644a1a4..3c7eaf0a279 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemClickedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemClickedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemClickedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemClickedEventHandler.cs index 7bdbdb60bf8..b22b2400d70 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemClickedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemClickedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemCollection.cs index ed75873a293..519c4d74ede 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -113,7 +112,7 @@ public int Add(ToolStripItem value) return retVal; } - public void AddRange(ToolStripItem[] toolStripItems) + public void AddRange(params ToolStripItem[] toolStripItems) { ArgumentNullException.ThrowIfNull(toolStripItems); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemDisplayStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemDisplayStyle.cs index 57bcca8b854..bc051ba0db6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemDisplayStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemDisplayStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemEventArgs.cs index 56748b22eb3..cd03bc67c91 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemEventHandler.cs index 09e5107aa37..acbde41e3e0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemEventType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemEventType.cs index cbc34746929..79506a0090e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemEventType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemEventType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemImageRenderEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemImageRenderEventArgs.cs index 37dc9b76319..1b9a445cd72 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemImageRenderEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemImageRenderEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Imaging; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemImageRenderEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemImageRenderEventHandler.cs index fcda28ce224..bfcc24a04cc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemImageRenderEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemImageRenderEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemImageScaling.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemImageScaling.cs index 0ef39d47889..c7ebffb84c2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemImageScaling.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemImageScaling.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemOverflow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemOverflow.cs index 30b37243024..302e975271f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemOverflow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemOverflow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemPlacement.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemPlacement.cs index 8ab6fdd1ed5..fd2427ab588 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemPlacement.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemPlacement.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemRenderEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemRenderEventArgs.cs index a97c074f974..5626c2026c1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemRenderEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemRenderEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemRenderEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemRenderEventHandler.cs index fffa9f397f7..5a86ef7c063 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemRenderEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemRenderEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemStates.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemStates.cs index f84d4b9a395..6b9e38351ed 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemStates.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemStates.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemTextRenderEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemTextRenderEventArgs.cs index 4a3f4a9f016..c49b85f0f1b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemTextRenderEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemTextRenderEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemTextRenderEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemTextRenderEventHandler.cs index f3866d1097e..6751bd34e4e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemTextRenderEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItemTextRenderEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLabel.ToolStripLabelAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLabel.ToolStripLabelAccessibleObject.cs index ad2de5b4fff..c6e26230187 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLabel.ToolStripLabelAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLabel.ToolStripLabelAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLabel.ToolStripLabelLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLabel.ToolStripLabelLayout.cs index acde317ebbe..50725f64745 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLabel.ToolStripLabelLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLabel.ToolStripLabelLayout.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLabel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLabel.cs index e613de87351..9e7b592d564 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLabel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLabel.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLayoutStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLayoutStyle.cs index 0d70d95ef77..903aa5650b5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLayoutStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLayoutStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLocationCancelEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLocationCancelEventArgs.cs index b21106c344c..e26ae7e936e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLocationCancelEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLocationCancelEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLocationCancelEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLocationCancelEventHandler.cs index 30bf4714e0e..7758c020bc4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLocationCancelEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripLocationCancelEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.ModalMenuFilter.HostedWindowsFormsMessageHook.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.ModalMenuFilter.HostedWindowsFormsMessageHook.cs index 29276013eb6..420a9d25097 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.ModalMenuFilter.HostedWindowsFormsMessageHook.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.ModalMenuFilter.HostedWindowsFormsMessageHook.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.ModalMenuFilter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.ModalMenuFilter.cs index f888cdfec6b..07a811d6088 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.ModalMenuFilter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.ModalMenuFilter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; @@ -43,7 +42,7 @@ internal partial class ModalMenuFilter : IMessageModifyAndFilter private ToolStrip? _toplevelToolStrip; - private readonly WeakReference _lastFocusedTool = new WeakReference(null); + private readonly WeakReference _lastFocusedTool = new(null); #if DEBUG private bool _justEnteredMenuMode; @@ -571,7 +570,7 @@ public bool PreFilterMessage(ref Message m) return false; } - var activeToolStripHandle = new HandleRef(activeToolStrip); + HandleRef activeToolStripHandle = new(activeToolStrip); var activeWindowHandle = Control.GetHandleRef(PInvoke.GetActiveWindow()); // if the active window has changed... diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs index 2d20269eca4..86a4be771a8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Collections.Concurrent; using System.Drawing; @@ -15,26 +12,26 @@ public static partial class ToolStripManager // WARNING: ThreadStatic initialization happens only on the first thread at class CTOR time. // use InitializeThread mechanism to initialize ThreadStatic members [ThreadStatic] - private static WeakRefCollection t_toolStripWeakArrayList; + private static WeakRefCollection? t_toolStripWeakArrayList; [ThreadStatic] - private static WeakRefCollection t_toolStripPanelWeakArrayList; + private static WeakRefCollection? t_toolStripPanelWeakArrayList; [ThreadStatic] private static bool t_initialized; - private static Font s_defaultFont; - private static ConcurrentDictionary s_defaultFontCache = new ConcurrentDictionary(); + private static Font? s_defaultFont; + private static ConcurrentDictionary s_defaultFontCache = new(); // WARNING: When subscribing to static event handlers - make sure you unhook from them // otherwise you can leak USER objects on process shutdown. // Consider: use WeakRefCollection [ThreadStatic] - private static Delegate[] t_staticEventHandlers; + private static Delegate?[]? t_staticEventHandlers; private const int StaticEventDefaultRendererChanged = 0; private const int StaticEventCount = 1; - private static readonly object s_internalSyncObject = new object(); + private static readonly object s_internalSyncObject = new(); private static void InitializeThread() { @@ -54,33 +51,30 @@ internal static Font DefaultFont { get { - Font sysFont = null; + Font? sysFont = null; // We need to cache the default fonts for the different DPIs. if (DpiHelper.IsPerMonitorV2Awareness) { int dpi = CurrentDpi; - Font retFont = null; - if (s_defaultFontCache.TryGetValue(dpi, out retFont) == false || retFont is null) + if (!s_defaultFontCache.TryGetValue(dpi, out Font? retFont)) { // Default to menu font sysFont = SystemInformation.GetMenuFontForDpi(dpi); - if (sysFont is not null) - { - // Ensure font is in pixels so it displays properly in the property grid at design time. - if (sysFont.Unit != GraphicsUnit.Point) - { - retFont = ControlPaint.FontInPoints(sysFont); - sysFont.Dispose(); - } - else - { - retFont = sysFont; - } - s_defaultFontCache[dpi] = retFont; + // Ensure font is in pixels so it displays properly in the property grid at design time. + if (sysFont.Unit != GraphicsUnit.Point) + { + retFont = ControlPaint.FontInPoints(sysFont); + sysFont.Dispose(); + } + else + { + retFont = sysFont; } + + s_defaultFontCache[dpi] = retFont; } return retFont; @@ -88,7 +82,7 @@ internal static Font DefaultFont else { // Threadsafe local reference - Font retFont = s_defaultFont; + Font? retFont = s_defaultFont; if (retFont is null) { @@ -101,23 +95,21 @@ internal static Font DefaultFont { // Default to menu font sysFont = SystemFonts.MenuFont; + // ...or to control font if menu font unavailable sysFont ??= Control.DefaultFont; - if (sysFont is not null) + // Ensure font is in pixels so it displays properly in the property grid at design time. + if (sysFont.Unit != GraphicsUnit.Point) { - // Ensure font is in pixels so it displays properly in the property grid at design time. - if (sysFont.Unit != GraphicsUnit.Point) - { - s_defaultFont = ControlPaint.FontInPoints(sysFont); - retFont = s_defaultFont; - sysFont.Dispose(); - } - else - { - s_defaultFont = sysFont; - retFont = s_defaultFont; - } + s_defaultFont = ControlPaint.FontInPoints(sysFont); + retFont = s_defaultFont; + sysFont.Dispose(); + } + else + { + s_defaultFont = sysFont; + retFont = s_defaultFont; } return retFont; @@ -136,7 +128,7 @@ internal static WeakRefCollection ToolStrips => t_toolStripWeakArrayList ??= new WeakRefCollection(); /// Static events only!!! - private static void AddEventHandler(int key, Delegate value) + private static void AddEventHandler(int key, Delegate? value) { lock (s_internalSyncObject) { @@ -148,14 +140,14 @@ private static void AddEventHandler(int key, Delegate value) /// /// Find a toolstrip in the weak ref ArrayList, return null if nothing was found /// - public static ToolStrip FindToolStrip(string toolStripName) + public static ToolStrip? FindToolStrip(string toolStripName) { - ToolStrip result = null; + ToolStrip? result = null; for (int i = 0; i < ToolStrips.Count; i++) { - if (ToolStrips[i] is not null && string.Equals(((ToolStrip)ToolStrips[i]).Name, toolStripName, StringComparison.Ordinal)) + if (ToolStrips[i] is ToolStrip toolStrip && string.Equals(toolStrip.Name, toolStripName, StringComparison.Ordinal)) { - result = (ToolStrip)ToolStrips[i]; + result = toolStrip; break; } } @@ -166,14 +158,14 @@ public static ToolStrip FindToolStrip(string toolStripName) /// /// Find a toolstrip in the weak ref ArrayList, return null if nothing was found /// - internal static ToolStrip FindToolStrip(Form owningForm, string toolStripName) + internal static ToolStrip? FindToolStrip(Form owningForm, string toolStripName) { - ToolStrip result = null; + ToolStrip? result = null; for (int i = 0; i < ToolStrips.Count; i++) { - if (ToolStrips[i] is not null && string.Equals(((ToolStrip)ToolStrips[i]).Name, toolStripName, StringComparison.Ordinal)) + if (ToolStrips[i] is ToolStrip toolStrip && string.Equals(toolStrip.Name, toolStripName, StringComparison.Ordinal)) { - result = (ToolStrip)ToolStrips[i]; + result = toolStrip; if (result.FindForm() == owningForm) { break; @@ -249,7 +241,7 @@ private static bool ChangeSelection(ToolStrip start, ToolStrip toolStrip) return true; } - private static Delegate GetEventHandler(int key) + private static Delegate? GetEventHandler(int key) { lock (s_internalSyncObject) { @@ -300,7 +292,7 @@ internal static void NotifyMenuModeChange(bool invalidateText, bool activationCh // If we've toggled the ShowUnderlines value, we'll need to invalidate for (int i = 0; i < ToolStrips.Count; i++) { - if (!(ToolStrips[i] is ToolStrip toolStrip)) + if (ToolStrips[i] is not ToolStrip toolStrip) { toolStripPruneNeeded = true; continue; @@ -342,7 +334,7 @@ internal static void PruneToolStripList() } } - private static void RemoveEventHandler(int key, Delegate value) + private static void RemoveEventHandler(int key, Delegate? value) { lock (s_internalSyncObject) { @@ -366,8 +358,8 @@ internal static bool SelectNextToolStrip(ToolStrip start, bool forward) return false; } - ToolStrip wrappedControl = null; - ToolStrip nextControl = null; + ToolStrip? wrappedControl = null; + ToolStrip? nextControl = null; int startTabIndex = start.TabIndex; int index = ToolStrips.IndexOf(start); @@ -377,7 +369,7 @@ internal static bool SelectNextToolStrip(ToolStrip start, bool forward) index = (forward) ? (index + 1) % totalCount : (index + totalCount - 1) % totalCount; - if (!(ToolStrips[index] is ToolStrip toolStrip) || + if (ToolStrips[index] is not ToolStrip toolStrip || toolStrip == start) { continue; @@ -473,7 +465,7 @@ internal static bool SelectNextToolStrip(ToolStrip start, bool forward) /// locks in painting code. /// [ThreadStatic] - private static ToolStripRenderer t_defaultRenderer; + private static ToolStripRenderer? t_defaultRenderer; // types cached for perf. internal static Type s_systemRendererType = typeof(ToolStripSystemRenderer); @@ -481,14 +473,14 @@ internal static bool SelectNextToolStrip(ToolStrip start, bool forward) private static bool s_visualStylesEnabledIfPossible = true; [ThreadStatic] - private static Type t_currentRendererType; + private static Type? t_currentRendererType; private static Type CurrentRendererType { get { InitializeThread(); - return t_currentRendererType; + return t_currentRendererType!; } set => t_currentRendererType = value; } @@ -499,6 +491,7 @@ private static Type CurrentRendererType /// The default renderer for the thread. When ToolStrip.RenderMode is set /// to manager - this is the property used. /// + [AllowNull] public static ToolStripRenderer Renderer { get @@ -514,7 +507,7 @@ public static ToolStripRenderer Renderer CurrentRendererType = (value is null) ? s_defaultRendererType : value.GetType(); t_defaultRenderer = value; - ((EventHandler)GetEventHandler(StaticEventDefaultRendererChanged))?.Invoke(null, EventArgs.Empty); + ((EventHandler?)GetEventHandler(StaticEventDefaultRendererChanged))?.Invoke(null, EventArgs.Empty); } } } @@ -524,7 +517,7 @@ public static ToolStripRenderer Renderer /// Warning: When subscribing to static event handlers - make sure you unhook from them /// otherwise you can leak user objects on process shutdown. /// - public static event EventHandler RendererChanged + public static event EventHandler? RendererChanged { add => AddEventHandler(StaticEventDefaultRendererChanged, value); remove => RemoveEventHandler(StaticEventDefaultRendererChanged, value); @@ -589,7 +582,7 @@ public static bool VisualStylesEnabled if (oldVis != VisualStylesEnabled) { - ((EventHandler)GetEventHandler(StaticEventDefaultRendererChanged))?.Invoke(null, EventArgs.Empty); + ((EventHandler?)GetEventHandler(StaticEventDefaultRendererChanged))?.Invoke(null, EventArgs.Empty); } } } @@ -625,11 +618,11 @@ internal static ToolStripRenderer CreateRenderer(ToolStripRenderMode renderMode) internal static WeakRefCollection ToolStripPanels => t_toolStripPanelWeakArrayList ??= new WeakRefCollection(); - internal static ToolStripPanel ToolStripPanelFromPoint(Control draggedControl, Point screenLocation) + internal static ToolStripPanel? ToolStripPanelFromPoint(Control draggedControl, Point screenLocation) { if (t_toolStripPanelWeakArrayList is not null) { - ISupportToolStripPanel draggedItem = draggedControl as ISupportToolStripPanel; + ISupportToolStripPanel draggedItem = (ISupportToolStripPanel)draggedControl; bool rootWindowCheck = draggedItem.IsCurrentlyDragging; for (int i = 0; i < t_toolStripPanelWeakArrayList.Count; i++) @@ -663,7 +656,7 @@ public static void LoadSettings(Form targetForm) { ArgumentNullException.ThrowIfNull(targetForm); - LoadSettings(targetForm, targetForm.GetType().FullName); + LoadSettings(targetForm, targetForm.GetType().FullName!); } /// @@ -686,7 +679,7 @@ public static void SaveSettings(Form sourceForm) { ArgumentNullException.ThrowIfNull(sourceForm); - SaveSettings(sourceForm, sourceForm.GetType().FullName); + SaveSettings(sourceForm, sourceForm.GetType().FullName!); } /// @@ -697,7 +690,7 @@ public static void SaveSettings(Form sourceForm, string key) ArgumentNullException.ThrowIfNull(sourceForm); ArgumentNullException.ThrowIfNull(key); - var settingsManager = new ToolStripSettingsManager(sourceForm, key); + ToolStripSettingsManager settingsManager = new(sourceForm, key); settingsManager.Save(); } @@ -820,8 +813,8 @@ internal static bool ProcessShortcut(ref Message m, Keys shortcut) return false; } - Control activeControl = Control.FromChildHandle(m.HWnd); - Control activeControlInChain = activeControl; + Control? activeControl = Control.FromChildHandle(m.HWnd); + Control? activeControlInChain = activeControl; if (activeControlInChain is not null && IsValidShortcut(shortcut)) { @@ -833,7 +826,7 @@ internal static bool ProcessShortcut(ref Message m, Keys shortcut) // Check the context menu strip first. if (activeControlInChain.ContextMenuStrip is not null) { - if (activeControlInChain.ContextMenuStrip.Shortcuts.TryGetValue(shortcut, out ToolStripMenuItem item)) + if (activeControlInChain.ContextMenuStrip.Shortcuts.TryGetValue(shortcut, out ToolStripMenuItem? item)) { if (item.ProcessCmdKey(ref m, shortcut)) { @@ -864,7 +857,7 @@ internal static bool ProcessShortcut(ref Message m, Keys shortcut) bool isAssociatedContextMenu = false; bool isDoublyAssignedContextMenuStrip = false; - if (!(ToolStrips[i] is ToolStrip toolStrip)) + if (ToolStrips[i] is not ToolStrip toolStrip) { // Consider prune tree. needsPrune = true; @@ -881,17 +874,17 @@ internal static bool ProcessShortcut(ref Message m, Keys shortcut) // We don't want to process someone else's context menu (e.g. button1 and button2 have context menus) // button2's context menu should not be processed if button1 is the one we're processing. - ToolStripDropDown dropDown = toolStrip as ToolStripDropDown; + ToolStripDropDown dropDown = (ToolStripDropDown)toolStrip; // If a context menu is re-used between the main menu and the // and some other control's context menu, we should go ahead and evaluate it. - if (dropDown.GetFirstDropDown() is ContextMenuStrip toplevelContextMenu) + if (dropDown.GetFirstDropDown() is ContextMenuStrip topLevelContextMenu) { - isDoublyAssignedContextMenuStrip = toplevelContextMenu.IsAssignedToDropDownItem; + isDoublyAssignedContextMenuStrip = topLevelContextMenu.IsAssignedToDropDownItem; if (!isDoublyAssignedContextMenuStrip) { - if (toplevelContextMenu != activeControl.ContextMenuStrip) + if (topLevelContextMenu != activeControl!.ContextMenuStrip) { // The toplevel context menu is NOT the same as the active control's context menu. continue; @@ -913,7 +906,7 @@ internal static bool ProcessShortcut(ref Message m, Keys shortcut) // Make sure that were processing shortcuts for the correct window. // since the shortcut lookup is faster than this check we've postponed this to the last // possible moment. - ToolStrip topMostToolStrip = toolStrip.GetToplevelOwnerToolStrip(); + ToolStrip? topMostToolStrip = toolStrip.GetToplevelOwnerToolStrip(); if (topMostToolStrip is not null && activeControl is not null) { HWND rootWindowOfToolStrip = PInvoke.GetAncestor(topMostToolStrip, GET_ANCESTOR_FLAGS.GA_ROOT); @@ -925,7 +918,7 @@ internal static bool ProcessShortcut(ref Message m, Keys shortcut) // Double check this is not an MDIContainer type situation... if (Control.FromHandle(rootWindowOfControl) is Form mainForm && mainForm.IsMdiContainer) { - Form toolStripForm = topMostToolStrip.FindForm(); + Form? toolStripForm = topMostToolStrip.FindForm(); if (toolStripForm != mainForm && toolStripForm is not null) { // We should only process shortcuts of the ActiveMDIChild or the Main Form. @@ -938,7 +931,7 @@ internal static bool ProcessShortcut(ref Message m, Keys shortcut) if (isAssociatedContextMenu || rootWindowsMatch || isDoublyAssignedContextMenuStrip) { - if (toolStrip.Shortcuts.TryGetValue(shortcut, out ToolStripMenuItem item)) + if (toolStrip.Shortcuts.TryGetValue(shortcut, out ToolStripMenuItem? item)) { if (item.ProcessCmdKey(ref m, shortcut)) { @@ -982,10 +975,10 @@ internal static bool ProcessMenuKey(ref Message m) Keys keyData = (Keys)(nint)m.LParamInternal; // Search for our menu to work with - Control intendedControl = Control.FromHandle(m.HWnd); - Control toplevelControl = null; + Control? intendedControl = Control.FromHandle(m.HWnd); + Control? toplevelControl = null; - MenuStrip menuStripToActivate = null; + MenuStrip? menuStripToActivate = null; if (intendedControl is not null) { // Search for a menustrip to select. @@ -1059,7 +1052,7 @@ internal static bool ProcessMenuKey(ref Message m) return false; } - internal static MenuStrip GetMainMenuStrip(Control control) + internal static MenuStrip? GetMainMenuStrip(Control control) { if (control is null) { @@ -1068,7 +1061,7 @@ internal static MenuStrip GetMainMenuStrip(Control control) } // Look for a particular main menu strip to be set. - Form mainForm = control.FindForm(); + Form? mainForm = control.FindForm(); if (mainForm is not null && mainForm.MainMenuStrip is not null) { return mainForm.MainMenuStrip; @@ -1078,7 +1071,7 @@ internal static MenuStrip GetMainMenuStrip(Control control) return GetFirstMenuStripRecursive(control.Controls); } - private static MenuStrip GetFirstMenuStripRecursive(Control.ControlCollection controlsToLookIn) + private static MenuStrip? GetFirstMenuStripRecursive(Control.ControlCollection controlsToLookIn) { try { @@ -1091,9 +1084,9 @@ private static MenuStrip GetFirstMenuStripRecursive(Control.ControlCollection co continue; } - if (controlsToLookIn[i] is MenuStrip) + if (controlsToLookIn[i] is MenuStrip menuStrip) { - return controlsToLookIn[i] as MenuStrip; + return menuStrip; } } @@ -1108,7 +1101,7 @@ private static MenuStrip GetFirstMenuStripRecursive(Control.ControlCollection co if ((controlsToLookIn[i].Controls is not null) && controlsToLookIn[i].Controls.Count > 0) { // If it has a valid child collection, append those results to our collection - MenuStrip menuStrip = GetFirstMenuStripRecursive(controlsToLookIn[i].Controls); + MenuStrip? menuStrip = GetFirstMenuStripRecursive(controlsToLookIn[i].Controls); if (menuStrip is not null) { return menuStrip; @@ -1123,11 +1116,11 @@ private static MenuStrip GetFirstMenuStripRecursive(Control.ControlCollection co return null; } - private static ToolStripItem FindMatch(ToolStripItem source, ToolStripItemCollection destinationItems) + private static ToolStripItem? FindMatch(ToolStripItem source, ToolStripItemCollection destinationItems) { // Based on MergeAction: // Append, return the last sibling - ToolStripItem result = null; + ToolStripItem? result = null; if (source is not null) { for (int i = 0; i < destinationItems.Count; i++) @@ -1151,14 +1144,14 @@ private static ToolStripItem FindMatch(ToolStripItem source, ToolStripItemCollec return result; } - internal static List FindMergeableToolStrips(ContainerControl container) + internal static List FindMergeableToolStrips(ContainerControl? container) { List result = new(); if (container is not null) { for (int i = 0; i < ToolStrips.Count; i++) { - ToolStrip candidateTS = (ToolStrip)ToolStrips[i]; + ToolStrip? candidateTS = (ToolStrip?)ToolStrips[i]; if (candidateTS is not null && candidateTS.AllowMerge && container == candidateTS.FindForm()) { result.Add(candidateTS); @@ -1192,7 +1185,7 @@ public static bool Merge(ToolStrip sourceToolStrip, ToolStrip targetToolStrip) canMerge = (canMerge || (sourceToolStrip.AllowMerge && targetToolStrip.AllowMerge && (sourceToolStrip.GetType().IsAssignableFrom(targetToolStrip.GetType()) || targetToolStrip.GetType().IsAssignableFrom(sourceToolStrip.GetType())))); - MergeHistory mergeHistory = null; + MergeHistory? mergeHistory = null; if (canMerge) { Debug.Indent(); @@ -1246,7 +1239,7 @@ private static void MergeRecursive(ToolStripItem source, ToolStripItemCollection case MergeAction.MatchOnly: case MergeAction.Replace: case MergeAction.Remove: - ToolStripItem item = FindMatch(source, destinationItems); + ToolStripItem? item = FindMatch(source, destinationItems); if (item is not null) { switch (source.MergeAction) @@ -1298,7 +1291,7 @@ private static void MergeRecursive(ToolStripItem source, ToolStripItemCollection { maction = new MergeHistoryItem(MergeAction.Remove) { - PreviousIndexCollection = source.Owner.Items + PreviousIndexCollection = source.Owner!.Items }; maction.PreviousIndex = maction.PreviousIndexCollection.IndexOf(source); maction.TargetItem = source; @@ -1318,7 +1311,7 @@ private static void MergeRecursive(ToolStripItem source, ToolStripItemCollection { maction = new MergeHistoryItem(MergeAction.Remove) { - PreviousIndexCollection = source.Owner.Items + PreviousIndexCollection = source.Owner!.Items }; maction.PreviousIndex = maction.PreviousIndexCollection.IndexOf(source); maction.TargetItem = source; @@ -1333,7 +1326,7 @@ private static void MergeRecursive(ToolStripItem source, ToolStripItemCollection case MergeAction.Append: maction = new MergeHistoryItem(MergeAction.Remove) { - PreviousIndexCollection = source.Owner.Items + PreviousIndexCollection = source.Owner!.Items }; maction.PreviousIndex = maction.PreviousIndexCollection.IndexOf(source); maction.TargetItem = source; @@ -1355,7 +1348,7 @@ public static bool Merge(ToolStrip sourceToolStrip, string targetName) ArgumentNullException.ThrowIfNull(sourceToolStrip); ArgumentNullException.ThrowIfNull(targetName); - ToolStrip target = FindToolStrip(targetName); + ToolStrip? target = FindToolStrip(targetName); if (target is null) { return false; @@ -1369,7 +1362,7 @@ public static bool Merge(ToolStrip sourceToolStrip, string targetName) /// /// Doesn't do a null check on source - if it's null we unmerge everything /// - internal static bool RevertMergeInternal(ToolStrip targetToolStrip, ToolStrip sourceToolStrip, bool revertMDIControls) + internal static bool RevertMergeInternal(ToolStrip targetToolStrip, ToolStrip? sourceToolStrip, bool revertMDIControls) { bool result = false; ArgumentNullException.ThrowIfNull(targetToolStrip); @@ -1436,12 +1429,12 @@ internal static bool RevertMergeInternal(ToolStrip targetToolStrip, ToolStrip so switch (historyItem.MergeAction) { case MergeAction.Remove: - historyItem.IndexCollection.Remove(historyItem.TargetItem); + historyItem.IndexCollection!.Remove(historyItem.TargetItem!); // Put it back - historyItem.PreviousIndexCollection.Insert(Math.Min(historyItem.PreviousIndex, historyItem.PreviousIndexCollection.Count), historyItem.TargetItem); + historyItem.PreviousIndexCollection!.Insert(Math.Min(historyItem.PreviousIndex, historyItem.PreviousIndexCollection.Count), historyItem.TargetItem!); break; case MergeAction.Insert: - historyItem.IndexCollection.Insert(Math.Min(historyItem.Index, historyItem.IndexCollection.Count), historyItem.TargetItem); + historyItem.IndexCollection!.Insert(Math.Min(historyItem.Index, historyItem.IndexCollection.Count), historyItem.TargetItem!); // No need to put it back, inserting it in a new collection, moved it at the correct location break; } @@ -1470,7 +1463,7 @@ internal static bool RevertMergeInternal(ToolStrip targetToolStrip, ToolStrip so /// Unmerge two toolstrips /// public static bool RevertMerge(ToolStrip targetToolStrip) - => RevertMergeInternal(targetToolStrip, null, revertMDIControls: false); + => RevertMergeInternal(targetToolStrip, sourceToolStrip: null, revertMDIControls: false); /// /// Unmerge two toolstrips @@ -1487,7 +1480,7 @@ public static bool RevertMerge(ToolStrip targetToolStrip, ToolStrip sourceToolSt /// public static bool RevertMerge(string targetName) { - ToolStrip target = FindToolStrip(targetName); + ToolStrip? target = FindToolStrip(targetName); if (target is null) { return false; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManagerRenderMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManagerRenderMode.cs index 607e1aec288..954e736efa1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManagerRenderMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManagerRenderMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.ToolStripMenuItemAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.ToolStripMenuItemAccessibleObject.cs index 58dbc44b23f..57536a3a4bf 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.ToolStripMenuItemAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.ToolStripMenuItemAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.ToolStripMenuItemInternalLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.ToolStripMenuItemInternalLayout.cs index 393246a5dcb..d62402bc50f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.ToolStripMenuItemInternalLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.ToolStripMenuItemInternalLayout.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.cs index c3d1519a85e..aacafe70cd9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; @@ -19,7 +18,7 @@ namespace System.Windows.Forms; $"System.ComponentModel.Design.Serialization.CodeDomSerializer, {AssemblyRef.SystemDesign}")] public partial class ToolStripMenuItem : ToolStripDropDownItem { - private static readonly MenuTimer s_menuTimer = new MenuTimer(); + private static readonly MenuTimer s_menuTimer = new(); private static readonly int s_propShortcutKeys = PropertyStore.CreateKey(); private static readonly int s_propCheckState = PropertyStore.CreateKey(); @@ -48,17 +47,17 @@ public partial class ToolStripMenuItem : ToolStripDropDownItem private string? _cachedShortcutText; private Size _cachedShortcutSize = Size.Empty; - private static readonly Padding s_defaultPadding = new Padding(4, 0, 4, 0); - private static readonly Padding s_defaultDropDownPadding = new Padding(0, 1, 0, 1); - private static readonly Size s_checkMarkBitmapSize = new Size(16, 16); + private static readonly Padding s_defaultPadding = new(4, 0, 4, 0); + private static readonly Padding s_defaultDropDownPadding = new(0, 1, 0, 1); + private static readonly Size s_checkMarkBitmapSize = new(16, 16); private Padding _scaledDefaultPadding = s_defaultPadding; private Padding _scaledDefaultDropDownPadding = s_defaultDropDownPadding; private Size _scaledCheckMarkBitmapSize = s_checkMarkBitmapSize; private byte _openMouseId; - private static readonly object s_eventCheckedChanged = new object(); - private static readonly object s_eventCheckStateChanged = new object(); + private static readonly object s_eventCheckedChanged = new(); + private static readonly object s_eventCheckStateChanged = new(); public ToolStripMenuItem() : base() diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripNumericUpDown.ToolStripNumericUpDownControl.ToolStripNumericUpDownAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripNumericUpDown.ToolStripNumericUpDownControl.ToolStripNumericUpDownAccessibleObject.cs index ba3902e392a..3a89de9aef2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripNumericUpDown.ToolStripNumericUpDownControl.ToolStripNumericUpDownAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripNumericUpDown.ToolStripNumericUpDownControl.ToolStripNumericUpDownAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripNumericUpDown.ToolStripNumericUpDownControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripNumericUpDown.ToolStripNumericUpDownControl.cs index 1f5353c8a89..cdaa8582a14 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripNumericUpDown.ToolStripNumericUpDownControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripNumericUpDown.ToolStripNumericUpDownControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripNumericUpDown.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripNumericUpDown.cs index c7f84547235..f09a103d815 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripNumericUpDown.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripNumericUpDown.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflow.ToolStripOverflowAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflow.ToolStripOverflowAccessibleObject.cs index 0c7b8c11de0..17d3a7070b5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflow.ToolStripOverflowAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflow.ToolStripOverflowAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.UiaCore; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflow.cs index 29de44f2ffa..713344d65fe 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.Layout; @@ -10,7 +9,7 @@ namespace System.Windows.Forms; public partial class ToolStripOverflow : ToolStripDropDown, IArrangedElement { #if DEBUG - internal static readonly TraceSwitch PopupLayoutDebug = new TraceSwitch("PopupLayoutDebug", "Debug ToolStripPopup Layout code"); + internal static readonly TraceSwitch PopupLayoutDebug = new("PopupLayoutDebug", "Debug ToolStripPopup Layout code"); #else internal static readonly TraceSwitch? PopupLayoutDebug; #endif diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflowButton.ToolStripOverflowButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflowButton.ToolStripOverflowButtonAccessibleObject.cs index b4c437bfcb2..4047686b34d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflowButton.ToolStripOverflowButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflowButton.ToolStripOverflowButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflowButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflowButton.cs index 972bf5221cc..3ca1ddde078 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflowButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflowButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.FeedbackRectangle.FeedbackDropDown.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.FeedbackRectangle.FeedbackDropDown.cs index 61a9aa20401..b8948eae1e7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.FeedbackRectangle.FeedbackDropDown.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.FeedbackRectangle.FeedbackDropDown.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.FeedbackRectangle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.FeedbackRectangle.cs index 3f7cc7a94b2..4e8cf2c2366 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.FeedbackRectangle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.FeedbackRectangle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelAccessibleObject.cs index 005ad70d027..b98d33d818d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelAccessibleObject.cs @@ -1,6 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. + using static Interop; namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelControlCollection.XYComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelControlCollection.XYComparer.cs index 39b476ddaae..54a43521264 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelControlCollection.XYComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelControlCollection.XYComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelControlCollection.YXComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelControlCollection.YXComparer.cs index 3411fbb9236..689a29e07d4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelControlCollection.YXComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelControlCollection.YXComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelControlCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelControlCollection.cs index 80aa45276e5..64a600d8260 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelControlCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelControlCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms.Layout; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelRowCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelRowCollection.cs index 191b3d3b458..811a8b0646a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelRowCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.ToolStripPanelRowCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -46,7 +45,7 @@ public int Add(ToolStripPanelRow value) return retVal; } - public void AddRange(ToolStripPanelRow[] value) + public void AddRange(params ToolStripPanelRow[] value) { ArgumentNullException.ThrowIfNull(value); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.cs index fc35de47e34..fc791eec043 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -15,16 +14,16 @@ namespace System.Windows.Forms; public partial class ToolStripPanel : ContainerControl, IArrangedElement { private Orientation _orientation = Orientation.Horizontal; - private static readonly Padding s_rowMargin = new Padding(3, 0, 0, 0); + private static readonly Padding s_rowMargin = new(3, 0, 0, 0); private Padding _scaledRowMargin = s_rowMargin; private ToolStripRendererSwitcher? _rendererSwitcher; private BitVector32 _state; private readonly ToolStripContainer? _owner; #if DEBUG - internal static TraceSwitch s_toolStripPanelDebug = new TraceSwitch("ToolStripPanelDebug", "Debug code for rafting mouse movement"); - internal static TraceSwitch s_toolStripPanelFeedbackDebug = new TraceSwitch("ToolStripPanelFeedbackDebug", "Debug code for rafting feedback"); - internal static TraceSwitch s_toolStripPanelMissingRowDebug = new TraceSwitch("ToolStripPanelMissingRowDebug", "Debug code for rafting feedback"); + internal static TraceSwitch s_toolStripPanelDebug = new("ToolStripPanelDebug", "Debug code for rafting mouse movement"); + internal static TraceSwitch s_toolStripPanelFeedbackDebug = new("ToolStripPanelFeedbackDebug", "Debug code for rafting feedback"); + internal static TraceSwitch s_toolStripPanelMissingRowDebug = new("ToolStripPanelMissingRowDebug", "Debug code for rafting feedback"); #else internal static TraceSwitch? s_toolStripPanelDebug; internal static TraceSwitch? s_toolStripPanelFeedbackDebug; @@ -41,9 +40,9 @@ public partial class ToolStripPanel : ContainerControl, IArrangedElement private static readonly int s_stateLayoutSuspended = BitVector32.CreateMask(s_stateEndInit); private static readonly int s_stateRightToLeftChanged = BitVector32.CreateMask(s_stateLayoutSuspended); - internal static readonly Padding s_dragMargin = new Padding(10); + internal static readonly Padding s_dragMargin = new(10); - private static readonly object s_eventRendererChanged = new object(); + private static readonly object s_eventRendererChanged = new(); public ToolStripPanel() { @@ -1049,7 +1048,7 @@ private void MoveInsideContainer(ToolStrip toolStripToDrag, Point clientLocation private void MoveOutsideContainer(ToolStrip toolStripToDrag, Point screenLocation) { // look for another rafting container. - ToolStripPanel panel = ToolStripManager.ToolStripPanelFromPoint(toolStripToDrag, screenLocation); + ToolStripPanel? panel = ToolStripManager.ToolStripPanelFromPoint(toolStripToDrag, screenLocation); if (panel is not null) { using (new LayoutTransaction(panel, panel, null)) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelCell.cs index 096983153fe..e2d2109518e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelCell.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRenderEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRenderEventArgs.cs index 86b63aced56..6d4715680ca 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRenderEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRenderEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRenderEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRenderEventHandler.cs index a1ad73994f2..90d774d4410 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRenderEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRenderEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.HorizontalRowManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.HorizontalRowManager.cs index 884b3e8e2b6..a226901d223 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.HorizontalRowManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.HorizontalRowManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.ToolStripPanelRowControlCollection.ToolStripPanelCellToControlEnumerator.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.ToolStripPanelRowControlCollection.ToolStripPanelCellToControlEnumerator.cs index 9ab73a1a20a..875d68dc68d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.ToolStripPanelRowControlCollection.ToolStripPanelCellToControlEnumerator.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.ToolStripPanelRowControlCollection.ToolStripPanelCellToControlEnumerator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.ToolStripPanelRowControlCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.ToolStripPanelRowControlCollection.cs index 45606475a68..fb903b0d13e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.ToolStripPanelRowControlCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.ToolStripPanelRowControlCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.ComponentModel; @@ -86,7 +85,7 @@ public int Add(Control value) } [EditorBrowsable(EditorBrowsableState.Never)] - public void AddRange(Control[] value) + public void AddRange(params Control[] value) { ArgumentNullException.ThrowIfNull(value); @@ -286,10 +285,7 @@ public void CopyTo(Control[] array, int index) { ArgumentNullException.ThrowIfNull(array); - if (index < 0) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } + ArgumentOutOfRangeException.ThrowIfNegative(index); if (index >= array.Length || InnerList.Count > array.Length - index) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.ToolStripPanelRowManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.ToolStripPanelRowManager.cs index c501493226f..2525f4c01b4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.ToolStripPanelRowManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.ToolStripPanelRowManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.VerticalRowManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.VerticalRowManager.cs index 723e83ba25a..c41625d12f4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.VerticalRowManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.VerticalRowManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.cs index a3149080b6b..ebc89d8d5b5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -33,7 +32,7 @@ public partial class ToolStripPanelRow : Component, IArrangedElement private static readonly int s_propControlsCollection = PropertyStore.CreateKey(); #if DEBUG - internal static TraceSwitch s_toolStripPanelRowCreationDebug = new TraceSwitch("ToolStripPanelRowCreationDebug", "Debug code for rafting row creation"); + internal static TraceSwitch s_toolStripPanelRowCreationDebug = new("ToolStripPanelRowCreationDebug", "Debug code for rafting row creation"); #else internal static TraceSwitch? s_toolStripPanelRowCreationDebug; #endif @@ -730,7 +729,7 @@ void IArrangedElement.PerformLayout(IArrangedElement container, string? property #region MouseStuff #if DEBUG - internal static readonly TraceSwitch ToolStripPanelMouseDebug = new TraceSwitch("ToolStripPanelMouse", "Debug ToolStrip WM_MOUSEACTIVATE code"); + internal static readonly TraceSwitch ToolStripPanelMouseDebug = new("ToolStripPanelMouse", "Debug ToolStrip WM_MOUSEACTIVATE code"); #else internal static readonly TraceSwitch? ToolStripPanelMouseDebug; #endif diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPointType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPointType.cs index d0ddea03b07..8044702d25d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPointType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPointType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProfessionalLowResolutionRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProfessionalLowResolutionRenderer.cs index 831502bab5f..86d10c7adad 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProfessionalLowResolutionRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProfessionalLowResolutionRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Drawing2D; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.ToolStripProgressBarControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.ToolStripProgressBarControl.cs index f3d8c8fe3cb..b8f460719d3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.ToolStripProgressBarControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.ToolStripProgressBarControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.ToolStripProgressBarControlAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.ToolStripProgressBarControlAccessibleObject.cs index 6195aba6a20..b6c28936777 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.ToolStripProgressBarControlAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.ToolStripProgressBarControlAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.cs index 43c62e36739..bba09dffe48 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -10,10 +9,10 @@ namespace System.Windows.Forms; [DefaultProperty(nameof(Value))] public partial class ToolStripProgressBar : ToolStripControlHost { - internal static readonly object EventRightToLeftLayoutChanged = new object(); + internal static readonly object EventRightToLeftLayoutChanged = new(); - private static readonly Padding defaultMargin = new Padding(1, 2, 1, 1); - private static readonly Padding defaultStatusStripMargin = new Padding(1, 3, 1, 3); + private static readonly Padding defaultMargin = new(1, 2, 1, 1); + private static readonly Padding defaultStatusStripMargin = new(1, 3, 1, 3); private Padding scaledDefaultMargin = defaultMargin; private Padding scaledDefaultStatusStripMargin = defaultStatusStripMargin; @@ -257,9 +256,7 @@ private void HandleRightToLeftLayoutChanged(object? sender, EventArgs e) protected virtual void OnRightToLeftLayoutChanged(EventArgs e) { -#pragma warning disable CA2252 // Suppress 'Opt in to preview features' (https://aka.ms/dotnet-warnings/preview-features) RaiseEvent(EventRightToLeftLayoutChanged, e); -#pragma warning restore CA2252 } protected override void OnSubscribeControlEvents(Control? control) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderEventArgs.cs index 9c03d2089f7..d101dbdc578 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderEventHandler.cs index a10d73caa3e..6760ba8f9c0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderMode.cs index 372b342ab50..bdeac11a54c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderer.cs index 848f38230d0..13f65b111d5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -12,27 +11,27 @@ namespace System.Windows.Forms; public abstract class ToolStripRenderer { - private static readonly object EventRenderSplitButtonBackground = new object(); - private static readonly object EventRenderItemBackground = new object(); - private static readonly object EventRenderItemImage = new object(); - private static readonly object EventRenderItemText = new object(); - private static readonly object EventRenderToolStripBackground = new object(); - private static readonly object EventRenderGrip = new object(); - private static readonly object EventRenderButtonBackground = new object(); - private static readonly object EventRenderLabelBackground = new object(); - private static readonly object EventRenderMenuItemBackground = new object(); - private static readonly object EventRenderDropDownButtonBackground = new object(); - private static readonly object EventRenderOverflowButtonBackground = new object(); - private static readonly object EventRenderImageMargin = new object(); - private static readonly object EventRenderBorder = new object(); - private static readonly object EventRenderArrow = new object(); - private static readonly object EventRenderToolStripStatusLabelBackground = new object(); - private static readonly object EventRenderSeparator = new object(); - private static readonly object EventRenderItemCheck = new object(); - private static readonly object EventRenderToolStripPanelBackground = new object(); - private static readonly object EventRenderToolStripContentPanelBackground = new object(); - - private static readonly object EventRenderStatusStripSizingGrip = new object(); + private static readonly object EventRenderSplitButtonBackground = new(); + private static readonly object EventRenderItemBackground = new(); + private static readonly object EventRenderItemImage = new(); + private static readonly object EventRenderItemText = new(); + private static readonly object EventRenderToolStripBackground = new(); + private static readonly object EventRenderGrip = new(); + private static readonly object EventRenderButtonBackground = new(); + private static readonly object EventRenderLabelBackground = new(); + private static readonly object EventRenderMenuItemBackground = new(); + private static readonly object EventRenderDropDownButtonBackground = new(); + private static readonly object EventRenderOverflowButtonBackground = new(); + private static readonly object EventRenderImageMargin = new(); + private static readonly object EventRenderBorder = new(); + private static readonly object EventRenderArrow = new(); + private static readonly object EventRenderToolStripStatusLabelBackground = new(); + private static readonly object EventRenderSeparator = new(); + private static readonly object EventRenderItemCheck = new(); + private static readonly object EventRenderToolStripPanelBackground = new(); + private static readonly object EventRenderToolStripContentPanelBackground = new(); + + private static readonly object EventRenderStatusStripSizingGrip = new(); private static ColorMatrix? s_disabledImageColorMatrix; @@ -842,13 +841,27 @@ protected virtual void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) if (imageRect != Rectangle.Empty && image is not null) { - if (e.Item is not null && !e.Item.Enabled) + if (e.Item is not null) { - image = CreateDisabledImage(image, e.ImageAttributes); + if (!e.Item.Enabled) + { + image = CreateDisabledImage(image, e.ImageAttributes); + } + + if (SystemInformation.HighContrast && image is Bitmap bitmap) + { + Color backgroundColor = e.Item.Selected ? SystemColors.Highlight : e.Item.BackColor; + + if (ControlPaint.IsDark(backgroundColor)) + { + Image invertedImage = ControlPaint.CreateBitmapWithInvertedForeColor(bitmap, e.Item.BackColor); + image = invertedImage; + } + } } e.Graphics.DrawImage(image, imageRect, 0, 0, imageRect.Width, - imageRect.Height, GraphicsUnit.Pixel, e.ImageAttributes); + imageRect.Height, GraphicsUnit.Pixel, e.ImageAttributes); } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRendererSwitcher.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRendererSwitcher.cs index 07d8f79df38..8e7681ecaeb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRendererSwitcher.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRendererSwitcher.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripScrollButton.StickyLabel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripScrollButton.StickyLabel.cs index 6270a19d0ff..fa6b7b0cfb6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripScrollButton.StickyLabel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripScrollButton.StickyLabel.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripScrollButton.StickyLabelAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripScrollButton.StickyLabelAccessibleObject.cs index 3db476d2293..ab6cd234929 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripScrollButton.StickyLabelAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripScrollButton.StickyLabelAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripScrollButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripScrollButton.cs index 51f511c7396..8db5ff23da0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripScrollButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripScrollButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparator.ToolStripSeparatorAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparator.ToolStripSeparatorAccessibleObject.cs index 7c8385cf333..325a78f29b7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparator.ToolStripSeparatorAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparator.ToolStripSeparatorAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparator.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparator.cs index 47075ec2ae0..8450cd4be57 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparator.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparator.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -52,7 +51,7 @@ public override ImageLayout BackgroundImageLayout /// Deriving classes can override this to configure a default size for their control. /// This is more efficient than setting the size in the control's constructor. /// - protected override Size DefaultSize => new Size(SeparatorThickness, SeparatorThickness); + protected override Size DefaultSize => new(SeparatorThickness, SeparatorThickness); protected internal override Padding DefaultMargin => Padding.Empty; @@ -301,9 +300,7 @@ protected override void OnPaint(PaintEventArgs e) protected override void OnFontChanged(EventArgs e) { // Perf: don't call base, we don't care if the font changes -#pragma warning disable CA2252 // Suppress 'Opt in to preview features' (https://aka.ms/dotnet-warnings/preview-features) RaiseEvent(s_fontChangedEvent, e); -#pragma warning restore CA2252 } [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparatorRenderEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparatorRenderEventArgs.cs index 9ece8c246e8..376343e44e6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparatorRenderEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparatorRenderEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparatorRenderEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparatorRenderEventHandler.cs index d0b552bac62..dfe391e0ae3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparatorRenderEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparatorRenderEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettings.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettings.cs index 75bb3a7c2b3..6e73926aec3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettings.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Configuration; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettingsManager.SettingsStub.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettingsManager.SettingsStub.cs index 548b02d993d..c14ddaa0b4c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettingsManager.SettingsStub.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettingsManager.SettingsStub.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettingsManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettingsManager.cs index 0176ab8802c..190bcd26148 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettingsManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettingsManager.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Text; using System.Text.RegularExpressions; @@ -114,7 +113,7 @@ private void ApplySettings(List toolStripSettingsToApply) if (!string.IsNullOrEmpty(toolStripSettings.Name)) { // apply the toolstrip settings. - ToolStrip toolStrip = ToolStripManager.FindToolStrip(form, toolStripSettings.Name); + ToolStrip? toolStrip = ToolStripManager.FindToolStrip(form, toolStripSettings.Name); ApplyToolStripSettings(toolStrip, toolStripSettings, itemLocationHash); } } @@ -159,9 +158,9 @@ private void ApplySettings(List toolStripSettingsToApply) if (!string.IsNullOrEmpty(settings.Name)) { // apply the toolstrip settings. - ToolStrip toolStrip = ToolStripManager.FindToolStrip(form, settings.Name); + ToolStrip? toolStrip = ToolStripManager.FindToolStrip(form, settings.Name); ApplyToolStripSettings(toolStrip, settings, itemLocationHash); - toolStripPanel.Join(toolStrip, settings.Location); + toolStripPanel.Join(toolStrip!, settings.Location); } } } @@ -172,31 +171,33 @@ private void ApplySettings(List toolStripSettingsToApply) ResumeAllLayout(form, true); } - private static void ApplyToolStripSettings(ToolStrip toolStrip, SettingsStub settings, Dictionary itemLocationHash) + private static void ApplyToolStripSettings(ToolStrip? toolStrip, SettingsStub settings, Dictionary itemLocationHash) { - if (toolStrip is not null) + if (toolStrip is null) { - toolStrip.Visible = settings.Visible; - toolStrip.Size = settings.Size; + return; + } - // Apply the item order changes. - string? itemNames = settings.ItemOrder; - if (!string.IsNullOrEmpty(itemNames)) - { - string[] keys = itemNames.Split(','); - Regex r = ContiguousNonWhitespace(); + toolStrip.Visible = settings.Visible; + toolStrip.Size = settings.Size; - // Shuffle items according to string. - for (int i = 0; ((i < toolStrip.Items.Count) && (i < keys.Length)); i++) + // Apply the item order changes. + string? itemNames = settings.ItemOrder; + if (!string.IsNullOrEmpty(itemNames)) + { + string[] keys = itemNames.Split(','); + Regex r = ContiguousNonWhitespace(); + + // Shuffle items according to string. + for (int i = 0; ((i < toolStrip.Items.Count) && (i < keys.Length)); i++) + { + Match match = r.Match(keys[i]); + if (match.Success) { - Match match = r.Match(keys[i]); - if (match.Success) + string key = match.Value; + if (!string.IsNullOrEmpty(key) && itemLocationHash.TryGetValue(key, out ToolStrip? value)) { - string key = match.Value; - if (!string.IsNullOrEmpty(key) && itemLocationHash.TryGetValue(key, out ToolStrip? value)) - { - toolStrip.Items.Insert(i, value.Items[key]!); - } + toolStrip.Items.Insert(i, value.Items[key]!); } } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonAccessibleObject.cs index 89fd9a860bf..ab3c8f59d8e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonButton.cs index 9bb6d3af124..308e8d315ff 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonButtonLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonButtonLayout.cs index 6d5df651ce8..5eb58c02ed5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonButtonLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonButtonLayout.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonExAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonExAccessibleObject.cs index 7908908dedd..fe75bdcb9a1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonExAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonExAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonUiaProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonUiaProvider.cs index 93fa1b97136..f76e6cde633 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonUiaProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.ToolStripSplitButtonUiaProvider.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop.UiaCore; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.cs index a762a968557..4c824291005 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -25,9 +24,9 @@ public partial class ToolStripSplitButton : ToolStripDropDownItem private const int DefaultDropDownWidth = 11; - private static readonly object s_eventDefaultItemChanged = new object(); - private static readonly object s_eventButtonClick = new object(); - private static readonly object s_eventButtonDoubleClick = new object(); + private static readonly object s_eventDefaultItemChanged = new(); + private static readonly object s_eventButtonClick = new(); + private static readonly object s_eventButtonDoubleClick = new(); private static bool s_isScalingInitialized; private static int s_scaledDropDownButtonWidth = DefaultDropDownWidth; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackDragDropHandler.RelativeLocation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackDragDropHandler.RelativeLocation.cs index 664c93fe67f..179e43cae3e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackDragDropHandler.RelativeLocation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackDragDropHandler.RelativeLocation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackDragDropHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackDragDropHandler.cs index 34e938ead81..700fc5b3da9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackDragDropHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackDragDropHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackLayout.cs index 4944add5a93..7d2b66d732e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackLayout.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Drawing; using System.Windows.Forms.Layout; @@ -15,9 +12,9 @@ internal class ToolStripSplitStackLayout : LayoutEngine private Rectangle displayRectangle = Rectangle.Empty; #if DEBUG - internal static readonly TraceSwitch DebugLayoutTraceSwitch = new TraceSwitch("DebugLayout", "Debug ToolStrip Layout code"); + internal static readonly TraceSwitch DebugLayoutTraceSwitch = new("DebugLayout", "Debug ToolStrip Layout code"); #else - internal static readonly TraceSwitch DebugLayoutTraceSwitch; + internal static readonly TraceSwitch? DebugLayoutTraceSwitch; #endif internal ToolStripSplitStackLayout(ToolStrip owner) { @@ -257,20 +254,20 @@ private bool LayoutHorizontal() for (int j = -1; j < toolStrip.Items.Count; j++) { - ToolStripItem item = null; + ToolStripItem? item = null; if (j == -1) { - // the first time through place the overflow button if its required. + item = toolStrip.OverflowButton; + + // The first time through place the overflow button if its required. if (needOverflow) { - item = toolStrip.OverflowButton; item.SetPlacement(ToolStripItemPlacement.Main); itemSize = OverflowButtonSize; } else { - item = toolStrip.OverflowButton; item.SetPlacement(ToolStripItemPlacement.None); continue; } @@ -302,7 +299,7 @@ private bool LayoutHorizontal() // We need to honor left to right and head and tail. // In RTL.Yes, Head is to the Right, Tail is to the Left // In RTL.No, Head is to the Left, Tail is to the Right - if ((item is not null) && (item.Placement == ToolStripItemPlacement.Main)) + if (item.Placement == ToolStripItemPlacement.Main) { int x = displayRectangle.Left; int y = displayRectangle.Top; @@ -407,19 +404,19 @@ Vertical Layout{displayRectangle} for (int j = -1; j < ToolStrip.Items.Count; j++) { - ToolStripItem item = null; + ToolStripItem? item = null; if (j == -1) { - // the first time through place the overflow button if its required. + item = toolStrip.OverflowButton; + + // The first time through place the overflow button if its required. if (needOverflow) { - item = toolStrip.OverflowButton; item.SetPlacement(ToolStripItemPlacement.Main); } else { - item = toolStrip.OverflowButton; item.SetPlacement(ToolStripItemPlacement.None); continue; } @@ -452,7 +449,7 @@ Vertical Layout{displayRectangle} // Vertical split stack management ignores left to right. // Items aligned to the Head are placed from Top to Bottom // Items aligned to the Tail are placed from Bottom to Top - if ((item is not null) && (item.Placement == ToolStripItemPlacement.Main)) + if (item.Placement == ToolStripItemPlacement.Main) { Padding itemMargin = item.Margin; int x = displayRectangle.Left + itemMargin.Left; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.ToolStripStatusLabelAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.ToolStripStatusLabelAccessibleObject.cs index f4ba202f5c0..af41bf2f9c7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.ToolStripStatusLabelAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.ToolStripStatusLabelAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.ToolStripStatusLabelLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.ToolStripStatusLabelLayout.cs index 896b436f0be..5ab4b89496a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.ToolStripStatusLabelLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.ToolStripStatusLabelLayout.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.cs index bee54a12f3d..d105ba1b0fe 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -16,7 +15,7 @@ namespace System.Windows.Forms; [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.StatusStrip)] public partial class ToolStripStatusLabel : ToolStripLabel, IAutomationLiveRegion { - private static readonly Padding defaultMargin = new Padding(0, 3, 0, 2); + private static readonly Padding defaultMargin = new(0, 3, 0, 2); private Padding _scaledDefaultMargin = defaultMargin; private Border3DStyle _borderStyle = Border3DStyle.Flat; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabelBorderSides.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabelBorderSides.cs index 796b2c85820..fd56f2a0cef 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabelBorderSides.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabelBorderSides.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing.Design; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSystemRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSystemRenderer.cs index fd34c28c741..23562751fd9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSystemRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSystemRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.ToolStripTextBoxControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.ToolStripTextBoxControl.cs index c8abe58ece0..79f2d9ef73d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.ToolStripTextBoxControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.ToolStripTextBoxControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -232,7 +231,7 @@ private void WmNCPaint(ref Message m) // Note that GetWindowDC just calls GetDCEx with DCX_WINDOW | DCX_USESTYLE. - using var hdc = new GetDcScope(m.HWND, HRGN.Null, GET_DCX_FLAGS.DCX_WINDOW | (GET_DCX_FLAGS)0x00010000 /* DCX_USESTYLE */); + using GetDcScope hdc = new(m.HWND, HRGN.Null, GET_DCX_FLAGS.DCX_WINDOW | (GET_DCX_FLAGS)0x00010000 /* DCX_USESTYLE */); if (hdc.IsNull) { throw new Win32Exception(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.ToolStripTextBoxControlAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.ToolStripTextBoxControlAccessibleObject.cs index da8e0c91cc9..76728d7ca85 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.ToolStripTextBoxControlAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.ToolStripTextBoxControlAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static System.Windows.Forms.TextBoxBase; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.cs index 586e6f1c261..f0df7371ff5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -14,16 +13,16 @@ namespace System.Windows.Forms; [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.MenuStrip | ToolStripItemDesignerAvailability.ToolStrip | ToolStripItemDesignerAvailability.ContextMenuStrip)] public partial class ToolStripTextBox : ToolStripControlHost { - internal static readonly object s_eventTextBoxTextAlignChanged = new object(); - internal static readonly object s_eventAcceptsTabChanged = new object(); - internal static readonly object s_eventBorderStyleChanged = new object(); - internal static readonly object s_eventHideSelectionChanged = new object(); - internal static readonly object s_eventReadOnlyChanged = new object(); - internal static readonly object s_eventMultilineChanged = new object(); - internal static readonly object s_eventModifiedChanged = new object(); - - private static readonly Padding s_defaultMargin = new Padding(1, 0, 1, 0); - private static readonly Padding s_defaultDropDownMargin = new Padding(1); + internal static readonly object s_eventTextBoxTextAlignChanged = new(); + internal static readonly object s_eventAcceptsTabChanged = new(); + internal static readonly object s_eventBorderStyleChanged = new(); + internal static readonly object s_eventHideSelectionChanged = new(); + internal static readonly object s_eventReadOnlyChanged = new(); + internal static readonly object s_eventMultilineChanged = new(); + internal static readonly object s_eventModifiedChanged = new(); + + private static readonly Padding s_defaultMargin = new(1, 0, 1, 0); + private static readonly Padding s_defaultDropDownMargin = new(1); private Padding _scaledDefaultMargin = s_defaultMargin; private Padding _scaledDefaultDropDownMargin = s_defaultDropDownMargin; @@ -155,7 +154,6 @@ private void HandleReadOnlyChanged(object? sender, EventArgs e) OnReadOnlyChanged(e); } -#pragma warning disable CA2252 // Suppress 'Opt in to preview features' (https://aka.ms/dotnet-warnings/preview-features) private void HandleTextBoxTextAlignChanged(object? sender, EventArgs e) { RaiseEvent(s_eventTextBoxTextAlignChanged, e); @@ -190,7 +188,6 @@ protected virtual void OnReadOnlyChanged(EventArgs e) { RaiseEvent(s_eventReadOnlyChanged, e); } -#pragma warning restore CA2252 protected override void OnSubscribeControlEvents(Control? control) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextDirection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextDirection.cs index d5a4ade753d..fbd8610f669 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextDirection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextDirection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.TipInfo.Type.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.TipInfo.Type.cs index 81c1bb38ad5..ad983925497 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.TipInfo.Type.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.TipInfo.Type.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.TipInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.TipInfo.cs index 6ca6d81e635..43f2edd5d55 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.TipInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.TipInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.ToolTipNativeWindow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.ToolTipNativeWindow.cs index bbb109469f6..a70d5eb452a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.ToolTipNativeWindow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.ToolTipNativeWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.ToolTipTimer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.ToolTipTimer.cs index 53bda43dd95..616c9d524c6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.ToolTipTimer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.ToolTipTimer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.cs index 04801a5e602..04cdc38adf7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -1829,7 +1828,7 @@ private void SetTool(IWin32Window window, string? text, TipInfo.Type type, Point Control? tool = window as Control; if (tool is not null && _tools.ContainsKey(tool)) { - var toolInfo = new ToolInfoWrapper(tool); + ToolInfoWrapper toolInfo = new(tool); if (toolInfo.SendMessage(this, PInvoke.TTM_GETTOOLINFOW) != IntPtr.Zero) { TOOLTIP_FLAGS flags = TOOLTIP_FLAGS.TTF_TRACK; @@ -1990,7 +1989,7 @@ private void Reposition(Point tipPosition, Size tipSize) private HWND GetCurrentToolHwnd() { - var toolInfo = default(ToolInfoWrapper); + ToolInfoWrapper toolInfo = default; if (toolInfo.SendMessage(this, PInvoke.TTM_GETCURRENTTOOLW) != 0) { return (HWND)toolInfo.Info.hwnd; @@ -2348,7 +2347,7 @@ private unsafe void WndProc(ref Message message) case (int)PInvoke.WM_PAINT: if (OwnerDraw && !_isBalloon && !_trackPosition) { - using var paintScope = new PInvoke.BeginPaintScope((HWND)Handle); + using PInvoke.BeginPaintScope paintScope = new((HWND)Handle); Rectangle bounds = paintScope.PaintRectangle; if (bounds == Rectangle.Empty) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTipBuffer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTipBuffer.cs index 85786b5633d..67eba069afe 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTipBuffer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTipBuffer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTipIcon.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTipIcon.cs index 6f1a09a642d..11a92d94c92 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTipIcon.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTipIcon.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolstripProfessionalRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolstripProfessionalRenderer.cs index 7956058d950..c50a3b6bf53 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolstripProfessionalRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolstripProfessionalRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Drawing2D; @@ -19,7 +18,7 @@ public class ToolStripProfessionalRenderer : ToolStripRenderer private const int ICON_WELL_GRADIENT_WIDTH = 12; private int iconWellGradientWidth = ICON_WELL_GRADIENT_WIDTH; - private static readonly Size onePix = new Size(1, 1); + private static readonly Size onePix = new(1, 1); private bool isScalingInitialized; private const int OVERFLOW_BUTTON_WIDTH = 12; @@ -32,7 +31,7 @@ public class ToolStripProfessionalRenderer : ToolStripRenderer private int overflowArrowOffsetY = OVERFLOW_ARROW_OFFSETY; private const int DROP_DOWN_MENU_ITEM_PAINT_PADDING_SIZE = 1; - private Padding scaledDropDownMenuItemPaintPadding = new Padding(DROP_DOWN_MENU_ITEM_PAINT_PADDING_SIZE + 1, 0, DROP_DOWN_MENU_ITEM_PAINT_PADDING_SIZE, 0); + private Padding scaledDropDownMenuItemPaintPadding = new(DROP_DOWN_MENU_ITEM_PAINT_PADDING_SIZE + 1, 0, DROP_DOWN_MENU_ITEM_PAINT_PADDING_SIZE, 0); private readonly ProfessionalColorTable? professionalColorTable; private bool roundedEdges = true; private ToolStripRenderer? toolStripHighContrastRenderer; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarAccessibleObject.cs index ff8e5e09929..144cb5b8218 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarChildAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarChildAccessibleObject.cs index cd94cabd7a7..d2f8672548a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarChildAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarChildAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarFirstButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarFirstButtonAccessibleObject.cs index 46fa7ec4b3d..9c5f7ea5db7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarFirstButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarFirstButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarLastButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarLastButtonAccessibleObject.cs index 9a949780539..848c7530635 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarLastButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarLastButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarThumbAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarThumbAccessibleObject.cs index 766e7fb5d51..4c7c1777638 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarThumbAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.TrackBarThumbAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.cs index fca3e42d39f..31638d79978 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -24,9 +23,9 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionTrackBar))] public partial class TrackBar : Control, ISupportInitialize { - private static readonly object s_scrollEvent = new object(); - private static readonly object s_valueChangedEvent = new object(); - private static readonly object s_rightToLeftChangedEvent = new object(); + private static readonly object s_scrollEvent = new(); + private static readonly object s_valueChangedEvent = new(); + private static readonly object s_rightToLeftChangedEvent = new(); private bool _autoSize = true; private int _largeChange = 5; private int _maximum = 10; @@ -195,7 +194,7 @@ void EnableAutoTicksIfRequired() protected override ImeMode DefaultImeMode => ImeMode.Disable; - protected override Size DefaultSize => new Size(104, PreferredDimension); + protected override Size DefaultSize => new(104, PreferredDimension); /// /// This property is overridden and hidden from statement completion diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBarRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBarRenderer.cs index fb8fbe63f9b..f4d4a9a91f4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBarRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBarRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.IKeyboardToolTip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.IKeyboardToolTip.cs index db1b9a52e9a..a3d8a6ced46 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.IKeyboardToolTip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.IKeyboardToolTip.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.TreeNodeAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.TreeNodeAccessibleObject.cs index 145c49f333b..8e8150c2c26 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.TreeNodeAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.TreeNodeAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.TreeNodeImageIndexer.ImageListType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.TreeNodeImageIndexer.ImageListType.cs index a4db83ca6dd..29be1888124 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.TreeNodeImageIndexer.ImageListType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.TreeNodeImageIndexer.ImageListType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.TreeNodeImageIndexer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.TreeNodeImageIndexer.cs index 1b69bb1d811..e28a0ee8b41 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.TreeNodeImageIndexer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.TreeNodeImageIndexer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.cs index 41902d2b8d2..5cf94790116 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. #nullable disable @@ -112,7 +111,7 @@ internal TreeNodeImageIndexer StateImageIndexer /// public TreeNode() { - treeNodeState = default(Collections.Specialized.BitVector32); + treeNodeState = default; } internal TreeNode(TreeView treeView) : this() @@ -228,7 +227,7 @@ public Rectangle Bounds return Rectangle.Empty; } - RECT rc = default(RECT); + RECT rc = default; unsafe { *((IntPtr*)&rc.left) = Handle; } // wparam: 1=include only text, 0=include entire line @@ -251,7 +250,7 @@ internal Rectangle RowBounds get { TreeView tv = TreeView; - RECT rc = default(RECT); + RECT rc = default; unsafe { *((IntPtr*)&rc.left) = Handle; } @@ -305,7 +304,7 @@ internal unsafe bool CheckedInternal return; } - var item = new TVITEMW + TVITEMW item = new() { mask = TVITEM_MASK.TVIF_HANDLE | TVITEM_MASK.TVIF_STATE, hItem = _handle, @@ -331,7 +330,7 @@ public bool Checked if (_handle != IntPtr.Zero && !treeView.IsDisposed) { TreeView tv = TreeView; - var item = new TVITEMW + TVITEMW item = new() { mask = TVITEM_MASK.TVIF_HANDLE | TVITEM_MASK.TVIF_STATE, hItem = _handle, @@ -583,7 +582,7 @@ public bool IsEditing if (tv is not null) { - return tv.editNode == this; + return tv._editNode == this; } return false; @@ -643,7 +642,7 @@ public bool IsVisible return false; } - RECT rc = default(RECT); + RECT rc = default; unsafe { *((IntPtr*)&rc.left) = Handle; } @@ -828,7 +827,7 @@ public TreeNode Parent TreeView tv = TreeView; // Don't expose the virtual root publicly - if (tv is not null && parent == tv.root) + if (tv is not null && parent == tv._root) { return null; } @@ -998,7 +997,7 @@ internal TVIS State return 0; } - var item = new TVITEMW + TVITEMW item = new() { hItem = Handle, mask = TVITEM_MASK.TVIF_HANDLE | TVITEM_MASK.TVIF_STATE, @@ -1309,7 +1308,7 @@ internal void Clear() { if (tv is not null) { - tv.nodesCollectionClear = true; + tv._nodesCollectionClear = true; if (childNodes.Count > MAX_TREENODES_OPS) { @@ -1334,7 +1333,7 @@ internal void Clear() { if (tv is not null) { - tv.nodesCollectionClear = false; + tv._nodesCollectionClear = false; } nodesCleared = true; @@ -1777,7 +1776,7 @@ internal void InsertNodeAt(int index, TreeNode node) node.Realize(false); - if (TreeView is not null && node == TreeView.selectedNode) + if (TreeView is not null && node == TreeView._selectedNode) { TreeView.SelectedNode = node; // communicate this to the handle } @@ -1810,10 +1809,11 @@ internal unsafe void Realize(bool insertFirst) throw new InvalidOperationException(SR.InvalidCrossThreadControlCall); } - var tvis = new TVINSERTSTRUCTW + TVINSERTSTRUCTW tvis = new() { hParent = parent._handle }; + tvis.item.mask = InsertMask; TreeNode prev = PrevNode; @@ -2009,7 +2009,7 @@ private unsafe void ResetExpandedState(TreeView tv) { Debug.Assert(tv.IsHandleCreated, "nonexistent handle"); - var item = new TVITEMW + TVITEMW item = new() { mask = TVITEM_MASK.TVIF_HANDLE | TVITEM_MASK.TVIF_STATE, hItem = _handle, @@ -2125,11 +2125,12 @@ private void UpdateNode(TVITEM_MASK mask) return; } - var item = new TVITEMW + TVITEMW item = new() { mask = TVITEM_MASK.TVIF_HANDLE | mask, hItem = _handle }; + if ((mask & TVITEM_MASK.TVIF_TEXT) != 0) { item.pszText = Marshal.StringToHGlobalAuto(text); @@ -2138,15 +2139,15 @@ private void UpdateNode(TVITEM_MASK mask) if ((mask & TVITEM_MASK.TVIF_IMAGE) != 0) { item.iImage = IsSpecialImageIndex(ImageIndexer.ActualIndex) - ? tv.ImageIndexer.ActualIndex - : ImageIndexer.ActualIndex; + ? tv.ImageIndexer.ActualIndex + : ImageIndexer.ActualIndex; } if ((mask & TVITEM_MASK.TVIF_SELECTEDIMAGE) != 0) { item.iSelectedImage = IsSpecialImageIndex(SelectedImageIndexer.ActualIndex) - ? tv.SelectedImageIndexer.ActualIndex - : SelectedImageIndexer.ActualIndex; + ? tv.SelectedImageIndexer.ActualIndex + : SelectedImageIndexer.ActualIndex; } if ((mask & TVITEM_MASK.TVIF_STATE) != 0) @@ -2191,7 +2192,7 @@ internal unsafe void UpdateImage() return; } - var item = new TVITEMW + TVITEMW item = new() { mask = TVITEM_MASK.TVIF_HANDLE | TVITEM_MASK.TVIF_IMAGE, hItem = Handle, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeCollection.cs index 2e32eeaaa12..0efb2497b05 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeCollection.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Collections; using System.ComponentModel; @@ -10,62 +7,46 @@ namespace System.Windows.Forms; -[ -Editor($"System.Windows.Forms.Design.TreeNodeCollectionEditor, {AssemblyRef.SystemDesign}", typeof(UITypeEditor)) -] +[Editor($"System.Windows.Forms.Design.TreeNodeCollectionEditor, {AssemblyRef.SystemDesign}", typeof(UITypeEditor))] public class TreeNodeCollection : IList { - private readonly TreeNode owner; + private readonly TreeNode _owner; /// A caching mechanism for key accessor /// We use an index here rather than control so that we don't have lifetime /// issues by holding on to extra references. - private int lastAccessedIndex = -1; - - //this index is used to optimize performance of AddRange - //items are added from last to first after this index - //(to work around TV_INSertItem comctl32 perf issue with consecutive adds in the end of the list) - private int fixedIndex = -1; + private int _lastAccessedIndex = -1; internal TreeNodeCollection(TreeNode owner) { - this.owner = owner; + _owner = owner; } - internal int FixedIndex - { - get - { - return fixedIndex; - } - set - { - fixedIndex = value; - } - } + // This index is used to optimize performance of AddRange + // items are added from last to first after this index + // (to work around TV_INSertItem comctl32 perf issue with consecutive adds in the end of the list) + internal int FixedIndex { get; set; } = -1; public virtual TreeNode this[int index] { get { - if (index < 0 || index >= owner.childNodes.Count) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } + ArgumentOutOfRangeException.ThrowIfNegative(index); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, _owner.childNodes.Count); - return owner.childNodes[index]; + return _owner.childNodes[index]; } set { - if (index < 0 || index >= owner.childNodes.Count) + if (index < 0 || index >= _owner.childNodes.Count) { throw new ArgumentOutOfRangeException(nameof(index), index, string.Format(SR.InvalidArgument, nameof(index), index)); } ArgumentNullException.ThrowIfNull(value); - TreeView tv = owner.treeView; - TreeNode actual = owner.childNodes[index]; + TreeView tv = _owner.treeView; + TreeNode actual = _owner.childNodes[index]; if (value.treeView is not null && value.treeView.Handle != tv.Handle) { @@ -89,17 +70,14 @@ public virtual TreeNode this[int index] } } - object IList.this[int index] + object? IList.this[int index] { - get - { - return this[index]; - } + get => this[index]; set { - if (value is TreeNode) + if (value is TreeNode treeNode) { - this[index] = (TreeNode)value; + this[index] = treeNode; } else { @@ -111,7 +89,7 @@ object IList.this[int index] /// /// Retrieves the child control with the specified key. /// - public virtual TreeNode this[string key] + public virtual TreeNode? this[string? key] { get { @@ -136,50 +114,20 @@ public virtual TreeNode this[string key] // Make this property available to Intellisense. (Removed the EditorBrowsable attribute.) [Browsable(false)] - public int Count - { - get - { - return owner.childNodes.Count; - } - } + public int Count => _owner.childNodes.Count; - object ICollection.SyncRoot - { - get - { - return this; - } - } + object ICollection.SyncRoot => this; - bool ICollection.IsSynchronized - { - get - { - return false; - } - } + bool ICollection.IsSynchronized => false; - bool IList.IsFixedSize - { - get - { - return false; - } - } + bool IList.IsFixedSize => false; - public bool IsReadOnly - { - get - { - return false; - } - } + public bool IsReadOnly => false; /// /// Creates a new child node under this node. Child node is positioned after siblings. /// - public virtual TreeNode Add(string text) + public virtual TreeNode Add(string? text) { TreeNode tn = new TreeNode(text); Add(tn); @@ -191,7 +139,7 @@ public virtual TreeNode Add(string text) /// /// Creates a new child node under this node. Child node is positioned after siblings. /// - public virtual TreeNode Add(string key, string text) + public virtual TreeNode Add(string? key, string? text) { TreeNode tn = new TreeNode(text) { @@ -204,7 +152,7 @@ public virtual TreeNode Add(string key, string text) /// /// Creates a new child node under this node. Child node is positioned after siblings. /// - public virtual TreeNode Add(string key, string text, int imageIndex) + public virtual TreeNode Add(string? key, string? text, int imageIndex) { TreeNode tn = new TreeNode(text) { @@ -218,7 +166,7 @@ public virtual TreeNode Add(string key, string text, int imageIndex) /// /// Creates a new child node under this node. Child node is positioned after siblings. /// - public virtual TreeNode Add(string key, string text, string imageKey) + public virtual TreeNode Add(string? key, string? text, string? imageKey) { TreeNode tn = new TreeNode(text) { @@ -232,7 +180,7 @@ public virtual TreeNode Add(string key, string text, string imageKey) /// /// Creates a new child node under this node. Child node is positioned after siblings. /// - public virtual TreeNode Add(string key, string text, int imageIndex, int selectedImageIndex) + public virtual TreeNode Add(string? key, string? text, int imageIndex, int selectedImageIndex) { TreeNode tn = new TreeNode(text, imageIndex, selectedImageIndex) { @@ -245,7 +193,7 @@ public virtual TreeNode Add(string key, string text, int imageIndex, int selecte /// /// Creates a new child node under this node. Child node is positioned after siblings. /// - public virtual TreeNode Add(string key, string text, string imageKey, string selectedImageKey) + public virtual TreeNode Add(string? key, string? text, string? imageKey, string? selectedImageKey) { TreeNode tn = new TreeNode(text) { @@ -259,7 +207,7 @@ public virtual TreeNode Add(string key, string text, string imageKey, string sel // END - NEW ADD OVERLOADS IN WHIDBEY --> - public virtual void AddRange(TreeNode[] nodes) + public virtual void AddRange(params TreeNode[] nodes) { ArgumentNullException.ThrowIfNull(nodes); @@ -268,20 +216,20 @@ public virtual void AddRange(TreeNode[] nodes) return; } - TreeView tv = owner.TreeView; + TreeView tv = _owner.TreeView; if (tv is not null && nodes.Length > TreeNode.MAX_TREENODES_OPS) { tv.BeginUpdate(); } - owner.Nodes.FixedIndex = owner.childNodes.Count; - owner.childNodes.EnsureCapacity(nodes.Length); + _owner.Nodes.FixedIndex = _owner.childNodes.Count; + _owner.childNodes.EnsureCapacity(nodes.Length); for (int i = 0; i < nodes.Length; i++) { AddInternal(nodes[i], i); } - owner.Nodes.FixedIndex = -1; + _owner.Nodes.FixedIndex = -1; if (tv is not null && nodes.Length > TreeNode.MAX_TREENODES_OPS) { tv.EndUpdate(); @@ -297,7 +245,11 @@ public TreeNode[] Find(string key, bool searchAllChildren) return foundNodes.ToArray(); } - private static List FindInternal(string key, bool searchAllChildren, TreeNodeCollection treeNodeCollectionToLookIn, List foundTreeNodes) + private static List FindInternal( + string key, + bool searchAllChildren, + TreeNodeCollection treeNodeCollectionToLookIn, + List foundTreeNodes) { // Perform breadth first search - as it's likely people will want tree nodes belonging // to the same parent close to each other. @@ -338,10 +290,7 @@ private static List FindInternal(string key, bool searchAllChildren, T /// /// Adds a new child node to this node. Child node is positioned after siblings. /// - public virtual int Add(TreeNode node) - { - return AddInternal(node, 0); - } + public virtual int Add(TreeNode node) => AddInternal(node, 0); private int AddInternal(TreeNode node, int delta) { @@ -353,10 +302,10 @@ private int AddInternal(TreeNode node, int delta) } // Check for ParentingCycle - owner.CheckParentingCycle(node); + _owner.CheckParentingCycle(node); // If the TreeView is sorted, index is ignored - TreeView tv = owner.TreeView; + TreeView tv = _owner.TreeView; if (tv is not null) { @@ -368,11 +317,11 @@ private int AddInternal(TreeNode node, int delta) if (tv is not null && tv.Sorted) { - return owner.AddSorted(node); + return _owner.AddSorted(node); } - node.parent = owner; - int fixedIndex = owner.Nodes.FixedIndex; + node.parent = _owner; + int fixedIndex = _owner.Nodes.FixedIndex; if (fixedIndex != -1) { node.index = fixedIndex + delta; @@ -381,13 +330,13 @@ private int AddInternal(TreeNode node, int delta) { //if fixedIndex != -1 capacity was ensured by AddRange Debug.Assert(delta == 0, "delta should be 0"); - node.index = owner.childNodes.Count; + node.index = _owner.childNodes.Count; } - owner.childNodes.Add(node); + _owner.childNodes.Add(node); node.Realize(false); - if (tv is not null && node == tv.selectedNode) + if (tv is not null && node == tv._selectedNode) { tv.SelectedNode = node; // communicate this to the handle } @@ -400,13 +349,13 @@ private int AddInternal(TreeNode node, int delta) return node.index; } - int IList.Add(object node) + int IList.Add(object? node) { ArgumentNullException.ThrowIfNull(node); - if (node is TreeNode) + if (node is TreeNode treeNode) { - return Add((TreeNode)node); + return Add(treeNode); } else { @@ -414,30 +363,17 @@ int IList.Add(object node) } } - public bool Contains(TreeNode node) - { - return IndexOf(node) != -1; - } + public bool Contains(TreeNode node) => IndexOf(node) != -1; /// /// Returns true if the collection contains an item with the specified key, false otherwise. /// - public virtual bool ContainsKey(string key) - { - return IsValidIndex(IndexOfKey(key)); - } + public virtual bool ContainsKey(string? key) => IsValidIndex(IndexOfKey(key)); - bool IList.Contains(object node) - { - if (node is TreeNode) - { - return Contains((TreeNode)node); - } - else - { - return false; - } - } + bool IList.Contains(object? node) => + node is TreeNode treeNode + ? Contains(treeNode) + : false; public int IndexOf(TreeNode node) { @@ -452,22 +388,15 @@ public int IndexOf(TreeNode node) return -1; } - int IList.IndexOf(object node) - { - if (node is TreeNode) - { - return IndexOf((TreeNode)node); - } - else - { - return -1; - } - } + int IList.IndexOf(object? node) => + node is TreeNode treeNode + ? IndexOf(treeNode) + : -1; /// /// The zero-based index of the first occurrence of value within the entire CollectionBase, if found; otherwise, -1. /// - public virtual int IndexOfKey(string key) + public virtual int IndexOfKey(string? key) { // Step 0 - Arg validation if (string.IsNullOrEmpty(key)) @@ -476,26 +405,26 @@ public virtual int IndexOfKey(string key) } // step 1 - check the last cached item - if (IsValidIndex(lastAccessedIndex)) + if (IsValidIndex(_lastAccessedIndex)) { - if (WindowsFormsUtils.SafeCompareStrings(this[lastAccessedIndex].Name, key, /* ignoreCase = */ true)) + if (WindowsFormsUtils.SafeCompareStrings(this[_lastAccessedIndex].Name, key, ignoreCase: true)) { - return lastAccessedIndex; + return _lastAccessedIndex; } } // step 2 - search for the item for (int i = 0; i < Count; i++) { - if (WindowsFormsUtils.SafeCompareStrings(this[i].Name, key, /* ignoreCase = */ true)) + if (WindowsFormsUtils.SafeCompareStrings(this[i].Name, key, ignoreCase: true)) { - lastAccessedIndex = i; + _lastAccessedIndex = i; return i; } } // step 3 - we didn't find it. Invalidate the last accessed index and return -1. - lastAccessedIndex = -1; + _lastAccessedIndex = -1; return -1; } @@ -510,10 +439,10 @@ public virtual void Insert(int index, TreeNode node) } // Check for ParentingCycle - owner.CheckParentingCycle(node); + _owner.CheckParentingCycle(node); // If the TreeView is sorted, index is ignored - TreeView tv = owner.TreeView; + TreeView tv = _owner.TreeView; if (tv is not null) { @@ -525,7 +454,7 @@ public virtual void Insert(int index, TreeNode node) if (tv is not null && tv.Sorted) { - owner.AddSorted(node); + _owner.AddSorted(node); return; } @@ -534,19 +463,19 @@ public virtual void Insert(int index, TreeNode node) index = 0; } - if (index > owner.childNodes.Count) + if (index > _owner.childNodes.Count) { - index = owner.childNodes.Count; + index = _owner.childNodes.Count; } - owner.InsertNodeAt(index, node); + _owner.InsertNodeAt(index, node); } - void IList.Insert(int index, object node) + void IList.Insert(int index, object? node) { - if (node is TreeNode) + if (node is TreeNode treeNode) { - Insert(index, (TreeNode)node); + Insert(index, treeNode); } else { @@ -559,7 +488,7 @@ void IList.Insert(int index, object node) /// /// Inserts a new child node on this node. Child node is positioned as specified by index. /// - public virtual TreeNode Insert(int index, string text) + public virtual TreeNode Insert(int index, string? text) { TreeNode tn = new TreeNode(text); Insert(index, tn); @@ -569,7 +498,7 @@ public virtual TreeNode Insert(int index, string text) /// /// Inserts a new child node on this node. Child node is positioned as specified by index. /// - public virtual TreeNode Insert(int index, string key, string text) + public virtual TreeNode Insert(int index, string? key, string? text) { TreeNode tn = new TreeNode(text) { @@ -582,7 +511,7 @@ public virtual TreeNode Insert(int index, string key, string text) /// /// Inserts a new child node on this node. Child node is positioned as specified by index. /// - public virtual TreeNode Insert(int index, string key, string text, int imageIndex) + public virtual TreeNode Insert(int index, string? key, string? text, int imageIndex) { TreeNode tn = new TreeNode(text) { @@ -596,7 +525,7 @@ public virtual TreeNode Insert(int index, string key, string text, int imageInde /// /// Inserts a new child node on this node. Child node is positioned as specified by index. /// - public virtual TreeNode Insert(int index, string key, string text, string imageKey) + public virtual TreeNode Insert(int index, string? key, string? text, string? imageKey) { TreeNode tn = new TreeNode(text) { @@ -610,7 +539,7 @@ public virtual TreeNode Insert(int index, string key, string text, string imageK /// /// Inserts a new child node on this node. Child node is positioned as specified by index. /// - public virtual TreeNode Insert(int index, string key, string text, int imageIndex, int selectedImageIndex) + public virtual TreeNode Insert(int index, string? key, string? text, int imageIndex, int selectedImageIndex) { TreeNode tn = new TreeNode(text, imageIndex, selectedImageIndex) { @@ -623,7 +552,7 @@ public virtual TreeNode Insert(int index, string key, string text, int imageInde /// /// Inserts a new child node on this node. Child node is positioned as specified by index. /// - public virtual TreeNode Insert(int index, string key, string text, string imageKey, string selectedImageKey) + public virtual TreeNode Insert(int index, string? key, string? text, string? imageKey, string? selectedImageKey) { TreeNode tn = new TreeNode(text) { @@ -640,24 +569,21 @@ public virtual TreeNode Insert(int index, string key, string text, string imageK /// /// Determines if the index is valid for the collection. /// - private bool IsValidIndex(int index) - { - return ((index >= 0) && (index < Count)); - } + private bool IsValidIndex(int index) => (index >= 0) && (index < Count); /// /// Remove all nodes from the tree view. /// public virtual void Clear() { - owner.Clear(); + _owner.Clear(); } public void CopyTo(Array dest, int index) { - if (owner.childNodes.Count > 0) + if (_owner.childNodes.Count > 0) { - ((ICollection)owner.childNodes).CopyTo(dest, index); + ((ICollection)_owner.childNodes).CopyTo(dest, index); } } @@ -666,11 +592,11 @@ public void Remove(TreeNode node) node.Remove(); } - void IList.Remove(object node) + void IList.Remove(object? node) { - if (node is TreeNode) + if (node is TreeNode treeNode) { - Remove((TreeNode)node); + Remove(treeNode); } } @@ -682,7 +608,7 @@ public virtual void RemoveAt(int index) /// /// Removes the child control with the specified key. /// - public virtual void RemoveByKey(string key) + public virtual void RemoveByKey(string? key) { int index = IndexOfKey(key); if (IsValidIndex(index)) @@ -691,8 +617,5 @@ public virtual void RemoveByKey(string key) } } - public IEnumerator GetEnumerator() - { - return owner.childNodes.GetEnumerator(); - } + public IEnumerator GetEnumerator() => _owner.childNodes.GetEnumerator(); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeConverter.cs index 0d417ecaa16..fbe0bde0a40 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design.Serialization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseClickEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseClickEventArgs.cs index 1f1d4d789d2..27ab4fb8536 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseClickEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseClickEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseClickEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseClickEventHandler.cs index a990cac6178..321d4bfeb01 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseClickEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseClickEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseHoverEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseHoverEventArgs.cs index d0c85e8e8c8..4304909c874 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseHoverEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseHoverEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseHoverEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseHoverEventHandler.cs index b064ff0fc20..b5bb849ee3c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseHoverEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeMouseHoverEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeState.cs index 60651b78bcf..d98d932438c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNodeState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeView.TreeViewAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeView.TreeViewAccessibleObject.cs index 95d6783aa84..d8b6efeae76 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeView.TreeViewAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeView.TreeViewAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; @@ -58,7 +57,7 @@ internal override int GetChildIndex(AccessibleObject? child) } Point p = owningTreeView.PointToClient(new Point(x, y)); - TreeNode node = owningTreeView.GetNodeAt(p); + TreeNode? node = owningTreeView.GetNodeAt(p); if (node is not null) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeView.cs index 67b9d11c2b5..ae6ff195f02 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeView.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeView.cs @@ -1,8 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable using System.Collections; using System.ComponentModel; @@ -29,31 +26,31 @@ namespace System.Windows.Forms; public partial class TreeView : Control { private const int MaxIndent = 32000; // Maximum allowable TreeView indent - private const string backSlash = "\\"; + private const string BackSlash = "\\"; private const int DefaultTreeViewIndent = 19; - private DrawTreeNodeEventHandler onDrawNode; - private NodeLabelEditEventHandler onBeforeLabelEdit; - private NodeLabelEditEventHandler onAfterLabelEdit; - private TreeViewCancelEventHandler onBeforeCheck; - private TreeViewEventHandler onAfterCheck; - private TreeViewCancelEventHandler onBeforeCollapse; - private TreeViewEventHandler onAfterCollapse; - private TreeViewCancelEventHandler onBeforeExpand; - private TreeViewEventHandler onAfterExpand; - private TreeViewCancelEventHandler onBeforeSelect; - private TreeViewEventHandler onAfterSelect; - private ItemDragEventHandler onItemDrag; - private TreeNodeMouseHoverEventHandler onNodeMouseHover; - private EventHandler onRightToLeftLayoutChanged; - - internal TreeNode selectedNode; - private ImageList.Indexer imageIndexer; - private ImageList.Indexer selectedImageIndexer; - private bool setOddHeight; - private TreeNode prevHoveredNode; - private bool hoveredAlready; - private bool rightToLeftLayout; + private DrawTreeNodeEventHandler? _onDrawNode; + private NodeLabelEditEventHandler? _onBeforeLabelEdit; + private NodeLabelEditEventHandler? _onAfterLabelEdit; + private TreeViewCancelEventHandler? _onBeforeCheck; + private TreeViewEventHandler? _onAfterCheck; + private TreeViewCancelEventHandler? _onBeforeCollapse; + private TreeViewEventHandler? _onAfterCollapse; + private TreeViewCancelEventHandler? _onBeforeExpand; + private TreeViewEventHandler? _onAfterExpand; + private TreeViewCancelEventHandler? _onBeforeSelect; + private TreeViewEventHandler? _onAfterSelect; + private ItemDragEventHandler? _onItemDrag; + private TreeNodeMouseHoverEventHandler? _onNodeMouseHover; + private EventHandler? _onRightToLeftLayoutChanged; + + internal TreeNode? _selectedNode; + private ImageList.Indexer? _imageIndexer; + private ImageList.Indexer? _selectedImageIndexer; + private bool _setOddHeight; + private TreeNode? _prevHoveredNode; + private bool _hoveredAlready; + private bool _rightToLeftLayout; private nint _mouseDownNode = 0; // ensures we fire nodeclick on the correct node @@ -77,25 +74,25 @@ public partial class TreeView : Control private const int TREEVIEWSTATE_doubleBufferedPropertySet = 0x00020000; // PERF: take all the bools and put them into a state variable - private Collections.Specialized.BitVector32 treeViewState; // see TREEVIEWSTATE_ consts above + private Collections.Specialized.BitVector32 _treeViewState; // see TREEVIEWSTATE_ consts above - private static bool isScalingInitialized; - private static Size? scaledStateImageSize; + private static bool s_isScalingInitialized; + private static Size? s_scaledStateImageSize; private static Size? ScaledStateImageSize { get { - if (!isScalingInitialized) + if (!s_isScalingInitialized) { if (DpiHelper.IsScalingRequired) { - scaledStateImageSize = DpiHelper.LogicalToDeviceUnits(new Size(16, 16)); + s_scaledStateImageSize = DpiHelper.LogicalToDeviceUnits(new Size(16, 16)); } - isScalingInitialized = true; + s_isScalingInitialized = true; } - return scaledStateImageSize; + return s_scaledStateImageSize; } } @@ -103,10 +100,10 @@ internal ImageList.Indexer ImageIndexer { get { - imageIndexer ??= new ImageList.Indexer(); + _imageIndexer ??= new ImageList.Indexer(); - imageIndexer.ImageList = ImageList; - return imageIndexer; + _imageIndexer.ImageList = ImageList; + return _imageIndexer; } } @@ -114,41 +111,41 @@ internal ImageList.Indexer SelectedImageIndexer { get { - selectedImageIndexer ??= new ImageList.Indexer(); + _selectedImageIndexer ??= new ImageList.Indexer(); - selectedImageIndexer.ImageList = ImageList; + _selectedImageIndexer.ImageList = ImageList; - return selectedImageIndexer; + return _selectedImageIndexer; } } - private ImageList imageList; - private int indent = -1; - private int itemHeight = -1; - private string pathSeparator = backSlash; - private BorderStyle borderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + private ImageList? _imageList; + private int _indent = -1; + private int _itemHeight = -1; + private string _pathSeparator = BackSlash; + private BorderStyle _borderStyle = BorderStyle.Fixed3D; - internal TreeNodeCollection nodes; - internal TreeNode editNode; - internal TreeNode root; + internal TreeNodeCollection? _nodes; + internal TreeNode? _editNode; + internal TreeNode _root; internal Dictionary _nodesByHandle = new(); - internal bool nodesCollectionClear; //this is set when the treeNodeCollection is getting cleared and used by TreeView - private MouseButtons downButton; - private TreeViewDrawMode drawMode = TreeViewDrawMode.Normal; + internal bool _nodesCollectionClear; //this is set when the treeNodeCollection is getting cleared and used by TreeView + private MouseButtons _downButton; + private TreeViewDrawMode _drawMode = TreeViewDrawMode.Normal; //Properties newly added to TreeView.... - private ImageList internalStateImageList; - private TreeNode topNode; - private ImageList stateImageList; - private Color lineColor; - private string controlToolTipText; + private ImageList? _internalStateImageList; + private TreeNode? _topNode; + private ImageList? _stateImageList; + private Color _lineColor; + private string? _controlToolTipText; // Sorting - private IComparer treeViewNodeSorter; + private IComparer? _treeViewNodeSorter; //Events - private TreeNodeMouseClickEventHandler onNodeMouseClick; - private TreeNodeMouseClickEventHandler onNodeMouseDoubleClick; + private TreeNodeMouseClickEventHandler? _onNodeMouseClick; + private TreeNodeMouseClickEventHandler? _onNodeMouseDoubleClick; private ToolTipBuffer _toolTipBuffer; @@ -156,15 +153,16 @@ internal ImageList.Indexer SelectedImageIndexer /// Creates a TreeView control /// public TreeView() - : base() + : base() { - treeViewState = new Collections.Specialized.BitVector32(TREEVIEWSTATE_showRootLines | - TREEVIEWSTATE_showPlusMinus | - TREEVIEWSTATE_showLines | - TREEVIEWSTATE_scrollable | - TREEVIEWSTATE_hideSelection); + _treeViewState = new Collections.Specialized.BitVector32( + TREEVIEWSTATE_showRootLines | + TREEVIEWSTATE_showPlusMinus | + TREEVIEWSTATE_showLines | + TREEVIEWSTATE_scrollable | + TREEVIEWSTATE_hideSelection); - root = new TreeNode(this); + _root = new TreeNode(this); // TreeView must always have an ImageIndex. SelectedImageIndexer.Index = 0; @@ -195,18 +193,7 @@ internal override void ReleaseUiaProvider(HWND handle) /// public override Color BackColor { - get - { - if (ShouldSerializeBackColor()) - { - return base.BackColor; - } - else - { - return SystemColors.Window; - } - } - + get => ShouldSerializeBackColor() ? base.BackColor : SystemColors.Window; set { base.BackColor = value; @@ -224,7 +211,7 @@ public override Color BackColor [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public override Image BackgroundImage + public override Image? BackgroundImage { get => base.BackgroundImage; set => base.BackgroundImage = value; @@ -232,7 +219,7 @@ public override Image BackgroundImage [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public new event EventHandler BackgroundImageChanged + public new event EventHandler? BackgroundImageChanged { add => base.BackgroundImageChanged += value; remove => base.BackgroundImageChanged -= value; @@ -248,7 +235,7 @@ public override ImageLayout BackgroundImageLayout [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public new event EventHandler BackgroundImageLayoutChanged + public new event EventHandler? BackgroundImageLayoutChanged { add => base.BackgroundImageLayoutChanged += value; remove => base.BackgroundImageLayoutChanged -= value; @@ -263,14 +250,14 @@ public override ImageLayout BackgroundImageLayout [SRDescription(nameof(SR.borderStyleDescr))] public BorderStyle BorderStyle { - get => borderStyle; + get => _borderStyle; set { - if (borderStyle != value) + if (_borderStyle != value) { SourceGenerated.EnumValidator.Validate(value); - borderStyle = value; + _borderStyle = value; UpdateStyles(); } } @@ -286,16 +273,13 @@ public BorderStyle BorderStyle [SRDescription(nameof(SR.TreeViewCheckBoxesDescr))] public bool CheckBoxes { - get - { - return treeViewState[TREEVIEWSTATE_checkBoxes]; - } + get => _treeViewState[TREEVIEWSTATE_checkBoxes]; set { if (CheckBoxes != value) { - treeViewState[TREEVIEWSTATE_checkBoxes] = value; + _treeViewState[TREEVIEWSTATE_checkBoxes] = value; if (IsHandleCreated) { if (CheckBoxes) @@ -309,7 +293,7 @@ public bool CheckBoxes // Reset the Checked state after setting the checkboxes (this was Everett behavior) // The implementation of the TreeNode.Checked property has changed in Whidbey // So we need to explicit set the Checked state to false to keep the everett behavior. - UpdateCheckedState(root, false); + UpdateCheckedState(_root, false); RecreateHandle(); } } @@ -332,7 +316,7 @@ protected override CreateParams CreateParams cp.Style |= currentStyle & (int)(WINDOW_STYLE.WS_HSCROLL | WINDOW_STYLE.WS_VSCROLL); } - switch (borderStyle) + switch (_borderStyle) { case BorderStyle.Fixed3D: cp.ExStyle |= (int)WINDOW_EX_STYLE.WS_EX_CLIENTEDGE; @@ -382,7 +366,7 @@ protected override CreateParams CreateParams cp.Style |= (int)PInvoke.TVS_FULLROWSELECT; } - if (setOddHeight) + if (_setOddHeight) { cp.Style |= (int)PInvoke.TVS_NONEVENHEIGHT; } @@ -426,13 +410,7 @@ protected override CreateParams CreateParams /// Deriving classes can override this to configure a default size for their control. /// This is more efficient than setting the size in the control's constructor. /// - protected override Size DefaultSize - { - get - { - return new Size(121, 97); - } - } + protected override Size DefaultSize => new(121, 97); /// /// This property is overridden and hidden from statement completion @@ -447,7 +425,7 @@ protected override bool DoubleBuffered if (DoubleBuffered != value) { base.DoubleBuffered = value; - treeViewState[TREEVIEWSTATE_doubleBufferedPropertySet] = true; + _treeViewState[TREEVIEWSTATE_doubleBufferedPropertySet] = true; UpdateTreeViewExtendedStyles(); } } @@ -459,18 +437,7 @@ protected override bool DoubleBuffered /// public override Color ForeColor { - get - { - if (ShouldSerializeForeColor()) - { - return base.ForeColor; - } - else - { - return SystemColors.WindowText; - } - } - + get => ShouldSerializeForeColor() ? base.ForeColor : SystemColors.WindowText; set { base.ForeColor = value; @@ -490,12 +457,12 @@ public override Color ForeColor [SRDescription(nameof(SR.TreeViewFullRowSelectDescr))] public bool FullRowSelect { - get { return treeViewState[TREEVIEWSTATE_fullRowSelect]; } + get => _treeViewState[TREEVIEWSTATE_fullRowSelect]; set { if (FullRowSelect != value) { - treeViewState[TREEVIEWSTATE_fullRowSelect] = value; + _treeViewState[TREEVIEWSTATE_fullRowSelect] = value; if (IsHandleCreated) { UpdateStyles(); @@ -513,16 +480,12 @@ public bool FullRowSelect [SRDescription(nameof(SR.TreeViewHideSelectionDescr))] public bool HideSelection { - get - { - return treeViewState[TREEVIEWSTATE_hideSelection]; - } - + get => _treeViewState[TREEVIEWSTATE_hideSelection]; set { if (HideSelection != value) { - treeViewState[TREEVIEWSTATE_hideSelection] = value; + _treeViewState[TREEVIEWSTATE_hideSelection] = value; if (IsHandleCreated) { UpdateStyles(); @@ -541,16 +504,12 @@ public bool HideSelection [SRDescription(nameof(SR.TreeViewHotTrackingDescr))] public bool HotTracking { - get - { - return treeViewState[TREEVIEWSTATE_hotTracking]; - } - + get => _treeViewState[TREEVIEWSTATE_hotTracking]; set { if (HotTracking != value) { - treeViewState[TREEVIEWSTATE_hotTracking] = value; + _treeViewState[TREEVIEWSTATE_hotTracking] = value; if (IsHandleCreated) { UpdateStyles(); @@ -574,14 +533,14 @@ public int ImageIndex { get { - if (imageList is null) + if (_imageList is null) { return ImageList.Indexer.DefaultIndex; } - if (ImageIndexer.Index >= imageList.Images.Count) + if (ImageIndexer.Index >= _imageList.Images.Count) { - return Math.Max(0, imageList.Images.Count - 1); + return Math.Max(0, _imageList.Images.Count - 1); } return ImageIndexer.Index; @@ -592,7 +551,6 @@ public int ImageIndex // If (none) is selected in the image index editor, we'll just adjust this to // mean image index 0. This is because a treeview must always have an image index - // even if no imagelist exists we want the image index to be 0. - // if (value == ImageList.Indexer.DefaultIndex) { value = 0; @@ -625,13 +583,10 @@ public int ImageIndex [RefreshProperties(RefreshProperties.Repaint)] [SRDescription(nameof(SR.TreeViewImageKeyDescr))] [RelatedImageList("ImageList")] + [AllowNull] public string ImageKey { - get - { - return ImageIndexer.Key; - } - + get => ImageIndexer.Key; set { if (ImageIndexer.Key != value) @@ -657,19 +612,16 @@ public string ImageKey [DefaultValue(null)] [SRDescription(nameof(SR.TreeViewImageListDescr))] [RefreshProperties(RefreshProperties.Repaint)] - public ImageList ImageList + public ImageList? ImageList { - get - { - return imageList; - } + get => _imageList; set { - if (value != imageList) + if (value != _imageList) { DetachImageListHandlers(); - imageList = value; + _imageList = value; AttachImageListHandlers(); @@ -677,56 +629,56 @@ public ImageList ImageList if (IsHandleCreated) { PInvoke.SendMessage(this, PInvoke.TVM_SETIMAGELIST, 0, value is null ? 0 : value.Handle); - if (StateImageList is not null && StateImageList.Images.Count > 0 && internalStateImageList is not null) + if (StateImageList is not null && StateImageList.Images.Count > 0 && _internalStateImageList is not null) { - SetStateImageList(internalStateImageList.Handle); + SetStateImageList(_internalStateImageList.Handle); } } - UpdateCheckedState(root, true); + UpdateCheckedState(_root, true); } } } private void AttachImageListHandlers() { - if (imageList is not null) + if (_imageList is not null) { //NOTE: any handlers added here should be removed in DetachImageListHandlers - imageList.RecreateHandle += new EventHandler(ImageListRecreateHandle); - imageList.Disposed += new EventHandler(DetachImageList); - imageList.ChangeHandle += new EventHandler(ImageListChangedHandle); + _imageList.RecreateHandle += new EventHandler(ImageListRecreateHandle); + _imageList.Disposed += new EventHandler(DetachImageList); + _imageList.ChangeHandle += new EventHandler(ImageListChangedHandle); } } private void DetachImageListHandlers() { - if (imageList is not null) + if (_imageList is not null) { - imageList.RecreateHandle -= new EventHandler(ImageListRecreateHandle); - imageList.Disposed -= new EventHandler(DetachImageList); - imageList.ChangeHandle -= new EventHandler(ImageListChangedHandle); + _imageList.RecreateHandle -= new EventHandler(ImageListRecreateHandle); + _imageList.Disposed -= new EventHandler(DetachImageList); + _imageList.ChangeHandle -= new EventHandler(ImageListChangedHandle); } } private void AttachStateImageListHandlers() { - if (stateImageList is not null) + if (_stateImageList is not null) { //NOTE: any handlers added here should be removed in DetachStateImageListHandlers - stateImageList.RecreateHandle += new EventHandler(StateImageListRecreateHandle); - stateImageList.Disposed += new EventHandler(DetachStateImageList); - stateImageList.ChangeHandle += new EventHandler(StateImageListChangedHandle); + _stateImageList.RecreateHandle += new EventHandler(StateImageListRecreateHandle); + _stateImageList.Disposed += new EventHandler(DetachStateImageList); + _stateImageList.ChangeHandle += new EventHandler(StateImageListChangedHandle); } } private void DetachStateImageListHandlers() { - if (stateImageList is not null) + if (_stateImageList is not null) { - stateImageList.RecreateHandle -= new EventHandler(StateImageListRecreateHandle); - stateImageList.Disposed -= new EventHandler(DetachStateImageList); - stateImageList.ChangeHandle -= new EventHandler(StateImageListChangedHandle); + _stateImageList.RecreateHandle -= new EventHandler(StateImageListRecreateHandle); + _stateImageList.Disposed -= new EventHandler(DetachStateImageList); + _stateImageList.ChangeHandle -= new EventHandler(StateImageListChangedHandle); } } @@ -736,31 +688,27 @@ private void DetachStateImageListHandlers() [SRCategory(nameof(SR.CatBehavior))] [DefaultValue(null)] [SRDescription(nameof(SR.TreeViewStateImageListDescr))] - public ImageList StateImageList + public ImageList? StateImageList { - get - { - return stateImageList; - } + get => _stateImageList; set { - if (value != stateImageList) + if (value != _stateImageList) { DetachStateImageListHandlers(); - stateImageList = value; + _stateImageList = value; AttachStateImageListHandlers(); - // Update TreeView's images - // + // Update TreeView's images. if (IsHandleCreated) { UpdateNativeStateImageList(); // We need to update the checks // and stateimage value for each node. - UpdateCheckedState(root, true); + UpdateCheckedState(_root, true); - if ((value is null || stateImageList.Images.Count == 0) && CheckBoxes) + if ((_stateImageList is null || _stateImageList.Images.Count == 0) && CheckBoxes) { // Requires Handle Recreate to force on the checkBoxes and states.. RecreateHandle(); @@ -787,9 +735,9 @@ public int Indent { get { - if (indent != -1) + if (_indent != -1) { - return indent; + return _indent; } else if (IsHandleCreated) { @@ -800,7 +748,7 @@ public int Indent } set { - if (indent != value) + if (_indent != value) { if (value < 0) { @@ -812,11 +760,11 @@ public int Indent throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(SR.InvalidHighBoundArgumentEx, nameof(Indent), value, MaxIndent)); } - indent = value; + _indent = value; if (IsHandleCreated) { PInvoke.SendMessage(this, PInvoke.TVM_SETINDENT, (WPARAM)value); - indent = (int)PInvoke.SendMessage(this, PInvoke.TVM_GETINDENT); + _indent = (int)PInvoke.SendMessage(this, PInvoke.TVM_GETINDENT); } } } @@ -831,9 +779,9 @@ public int ItemHeight { get { - if (itemHeight != -1) + if (_itemHeight != -1) { - return itemHeight; + return _itemHeight; } if (IsHandleCreated) @@ -852,7 +800,7 @@ public int ItemHeight } set { - if (itemHeight != value) + if (_itemHeight != value) { if (value < 1) { @@ -864,24 +812,24 @@ public int ItemHeight throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(SR.InvalidHighBoundArgument, nameof(ItemHeight), value, short.MaxValue)); } - itemHeight = value; + _itemHeight = value; if (IsHandleCreated) { - if (itemHeight % 2 != 0) + if (_itemHeight % 2 != 0) { - setOddHeight = true; + _setOddHeight = true; try { RecreateHandle(); } finally { - setOddHeight = false; + _setOddHeight = false; } } PInvoke.SendMessage(this, PInvoke.TVM_SETITEMHEIGHT, (WPARAM)value); - itemHeight = (int)PInvoke.SendMessage(this, PInvoke.TVM_GETITEMHEIGHT); + _itemHeight = (int)PInvoke.SendMessage(this, PInvoke.TVM_GETITEMHEIGHT); } } } @@ -898,15 +846,12 @@ public int ItemHeight [SRDescription(nameof(SR.TreeViewLabelEditDescr))] public bool LabelEdit { - get - { - return treeViewState[TREEVIEWSTATE_labelEdit]; - } + get => _treeViewState[TREEVIEWSTATE_labelEdit]; set { if (LabelEdit != value) { - treeViewState[TREEVIEWSTATE_labelEdit] = value; + _treeViewState[TREEVIEWSTATE_labelEdit] = value; if (IsHandleCreated) { UpdateStyles(); @@ -931,16 +876,16 @@ public Color LineColor return ColorTranslator.FromWin32(intColor); } - return lineColor; + return _lineColor; } set { - if (lineColor != value) + if (_lineColor != value) { - lineColor = value; + _lineColor = value; if (IsHandleCreated) { - PInvoke.SendMessage(this, PInvoke.TVM_SETLINECOLOR, 0, lineColor.ToWin32()); + PInvoke.SendMessage(this, PInvoke.TVM_SETLINECOLOR, 0, _lineColor.ToWin32()); } } } @@ -958,9 +903,9 @@ public TreeNodeCollection Nodes { get { - nodes ??= new TreeNodeCollection(root); + _nodes ??= new TreeNodeCollection(_root); - return nodes; + return _nodes; } } @@ -972,19 +917,15 @@ public TreeNodeCollection Nodes [SRDescription(nameof(SR.TreeViewDrawModeDescr))] public TreeViewDrawMode DrawMode { - get - { - return drawMode; - } - + get => _drawMode; set { //valid values are 0x0 to 0x2 SourceGenerated.EnumValidator.Validate(value); - if (drawMode != value) + if (_drawMode != value) { - drawMode = value; + _drawMode = value; Invalidate(); // We need to invalidate when the Control resizes when the we support custom draw. if (DrawMode == TreeViewDrawMode.OwnerDrawAll) @@ -1003,14 +944,8 @@ public TreeViewDrawMode DrawMode [SRDescription(nameof(SR.TreeViewPathSeparatorDescr))] public string PathSeparator { - get - { - return pathSeparator; - } - set - { - pathSeparator = value; - } + get => _pathSeparator; + set => _pathSeparator = value; } [Browsable(false)] @@ -1024,7 +959,7 @@ public string PathSeparator [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public new event EventHandler PaddingChanged + public new event EventHandler? PaddingChanged { add => base.PaddingChanged += value; remove => base.PaddingChanged -= value; @@ -1041,16 +976,12 @@ public string PathSeparator [SRDescription(nameof(SR.ControlRightToLeftLayoutDescr))] public virtual bool RightToLeftLayout { - get - { - return rightToLeftLayout; - } - + get => _rightToLeftLayout; set { - if (value != rightToLeftLayout) + if (value != _rightToLeftLayout) { - rightToLeftLayout = value; + _rightToLeftLayout = value; using (new LayoutTransaction(this, this, PropertyNames.RightToLeftLayout)) { OnRightToLeftLayoutChanged(EventArgs.Empty); @@ -1064,15 +995,12 @@ public virtual bool RightToLeftLayout [SRDescription(nameof(SR.TreeViewScrollableDescr))] public bool Scrollable { - get - { - return treeViewState[TREEVIEWSTATE_scrollable]; - } + get => _treeViewState[TREEVIEWSTATE_scrollable]; set { if (Scrollable != value) { - treeViewState[TREEVIEWSTATE_scrollable] = value; + _treeViewState[TREEVIEWSTATE_scrollable] = value; RecreateHandle(); } } @@ -1093,14 +1021,14 @@ public int SelectedImageIndex { get { - if (imageList is null) + if (_imageList is null) { return ImageList.Indexer.DefaultIndex; } - if (SelectedImageIndexer.Index >= imageList.Images.Count) + if (SelectedImageIndexer.Index >= _imageList.Images.Count) { - return Math.Max(0, imageList.Images.Count - 1); + return Math.Max(0, _imageList.Images.Count - 1); } return SelectedImageIndexer.Index; @@ -1143,13 +1071,10 @@ public int SelectedImageIndex [RefreshProperties(RefreshProperties.Repaint)] [SRDescription(nameof(SR.TreeViewSelectedImageKeyDescr))] [RelatedImageList("ImageList")] + [AllowNull] public string SelectedImageKey { - get - { - return SelectedImageIndexer.Key; - } - + get => SelectedImageIndexer.Key; set { if (SelectedImageIndexer.Key != value) @@ -1176,7 +1101,7 @@ public string SelectedImageKey [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [SRDescription(nameof(SR.TreeViewSelectedNodeDescr))] - public TreeNode SelectedNode + public TreeNode? SelectedNode { get { @@ -1190,9 +1115,9 @@ public TreeNode SelectedNode return NodeFromHandle(hItem); } - else if (selectedNode is not null && selectedNode.TreeView == this) + else if (_selectedNode is not null && _selectedNode.TreeView == this) { - return selectedNode; + return _selectedNode; } else { @@ -1206,15 +1131,15 @@ public TreeNode SelectedNode // This class invariant is not quite correct -- if the selected node does not belong to this Treeview, // selectedNode is not null even though the handle is created. We will call set_SelectedNode // to inform the handle that the selected node has been added to the TreeView. - Debug.Assert(selectedNode is null || selectedNode.TreeView != this, "handle is created, but we're still caching selectedNode"); + Debug.Assert(_selectedNode is null || _selectedNode.TreeView != this, "handle is created, but we're still caching selectedNode"); nint hnode = (value is null ? 0 : value.Handle); PInvoke.SendMessage(this, PInvoke.TVM_SELECTITEM, (WPARAM)(uint)PInvoke.TVGN_CARET, (LPARAM)hnode); - selectedNode = null; + _selectedNode = null; } else { - selectedNode = value; + _selectedNode = value; } } } @@ -1228,15 +1153,12 @@ public TreeNode SelectedNode [SRDescription(nameof(SR.TreeViewShowLinesDescr))] public bool ShowLines { - get - { - return treeViewState[TREEVIEWSTATE_showLines]; - } + get => _treeViewState[TREEVIEWSTATE_showLines]; set { if (ShowLines != value) { - treeViewState[TREEVIEWSTATE_showLines] = value; + _treeViewState[TREEVIEWSTATE_showLines] = value; if (IsHandleCreated) { UpdateStyles(); @@ -1253,15 +1175,12 @@ public bool ShowLines [SRDescription(nameof(SR.TreeViewShowShowNodeToolTipsDescr))] public bool ShowNodeToolTips { - get - { - return treeViewState[TREEVIEWSTATE_showNodeToolTips]; - } + get => _treeViewState[TREEVIEWSTATE_showNodeToolTips]; set { if (ShowNodeToolTips != value) { - treeViewState[TREEVIEWSTATE_showNodeToolTips] = value; + _treeViewState[TREEVIEWSTATE_showNodeToolTips] = value; if (ShowNodeToolTips) { RecreateHandle(); @@ -1279,15 +1198,12 @@ public bool ShowNodeToolTips [SRDescription(nameof(SR.TreeViewShowPlusMinusDescr))] public bool ShowPlusMinus { - get - { - return treeViewState[TREEVIEWSTATE_showPlusMinus]; - } + get => _treeViewState[TREEVIEWSTATE_showPlusMinus]; set { if (ShowPlusMinus != value) { - treeViewState[TREEVIEWSTATE_showPlusMinus] = value; + _treeViewState[TREEVIEWSTATE_showPlusMinus] = value; if (IsHandleCreated) { UpdateStyles(); @@ -1305,12 +1221,12 @@ public bool ShowPlusMinus [SRDescription(nameof(SR.TreeViewShowRootLinesDescr))] public bool ShowRootLines { - get { return treeViewState[TREEVIEWSTATE_showRootLines]; } + get => _treeViewState[TREEVIEWSTATE_showRootLines]; set { if (ShowRootLines != value) { - treeViewState[TREEVIEWSTATE_showRootLines] = value; + _treeViewState[TREEVIEWSTATE_showRootLines] = value; if (IsHandleCreated) { UpdateStyles(); @@ -1329,15 +1245,12 @@ public bool ShowRootLines [EditorBrowsable(EditorBrowsableState.Never)] public bool Sorted { - get - { - return treeViewState[TREEVIEWSTATE_sorted]; - } + get => _treeViewState[TREEVIEWSTATE_sorted]; set { if (Sorted != value) { - treeViewState[TREEVIEWSTATE_sorted] = value; + _treeViewState[TREEVIEWSTATE_sorted] = value; if (Sorted && TreeViewNodeSorter is null && Nodes.Count >= 1) { RefreshNodes(); @@ -1353,17 +1266,14 @@ public bool Sorted [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [SRDescription(nameof(SR.TreeViewNodeSorterDescr))] - public IComparer TreeViewNodeSorter + public IComparer? TreeViewNodeSorter { - get - { - return treeViewNodeSorter; - } + get => _treeViewNodeSorter; set { - if (treeViewNodeSorter != value) + if (_treeViewNodeSorter != value) { - treeViewNodeSorter = value; + _treeViewNodeSorter = value; if (value is not null) { Sort(); @@ -1375,6 +1285,7 @@ public IComparer TreeViewNodeSorter [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] [Bindable(false)] + [AllowNull] public override string Text { get => base.Text; @@ -1383,7 +1294,7 @@ public override string Text [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public new event EventHandler TextChanged + public new event EventHandler? TextChanged { add => base.TextChanged += value; remove => base.TextChanged -= value; @@ -1398,7 +1309,7 @@ public override string Text [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [SRDescription(nameof(SR.TreeViewTopNodeDescr))] - public TreeNode TopNode + public TreeNode? TopNode { get { @@ -1408,7 +1319,7 @@ public TreeNode TopNode return (hitem == IntPtr.Zero ? null : NodeFromHandle(hitem)); } - return topNode; + return _topNode; } set { @@ -1417,15 +1328,15 @@ public TreeNode TopNode // This class invariant is not quite correct -- if the selected node does not belong to this Treeview, // selectedNode is not null even though the handle is created. We will call set_SelectedNode // to inform the handle that the selected node has been added to the TreeView. - Debug.Assert(topNode is null || topNode.TreeView != this, "handle is created, but we're still caching selectedNode"); + Debug.Assert(_topNode is null || _topNode.TreeView != this, "handle is created, but we're still caching selectedNode"); nint hnode = (value is null ? 0 : value.Handle); PInvoke.SendMessage(this, PInvoke.TVM_SELECTITEM, (WPARAM)(uint)PInvoke.TVGN_FIRSTVISIBLE, (LPARAM)hnode); - topNode = null; + _topNode = null; } else { - topNode = value; + _topNode = value; } } } @@ -1444,66 +1355,66 @@ public TreeNode TopNode [SRCategory(nameof(SR.CatBehavior))] [SRDescription(nameof(SR.TreeViewBeforeEditDescr))] - public event NodeLabelEditEventHandler BeforeLabelEdit + public event NodeLabelEditEventHandler? BeforeLabelEdit { - add => onBeforeLabelEdit += value; - remove => onBeforeLabelEdit -= value; + add => _onBeforeLabelEdit += value; + remove => _onBeforeLabelEdit -= value; } [SRCategory(nameof(SR.CatBehavior))] [SRDescription(nameof(SR.TreeViewAfterEditDescr))] - public event NodeLabelEditEventHandler AfterLabelEdit + public event NodeLabelEditEventHandler? AfterLabelEdit { - add => onAfterLabelEdit += value; - remove => onAfterLabelEdit -= value; + add => _onAfterLabelEdit += value; + remove => _onAfterLabelEdit -= value; } [SRCategory(nameof(SR.CatBehavior))] [SRDescription(nameof(SR.TreeViewBeforeCheckDescr))] - public event TreeViewCancelEventHandler BeforeCheck + public event TreeViewCancelEventHandler? BeforeCheck { - add => onBeforeCheck += value; - remove => onBeforeCheck -= value; + add => _onBeforeCheck += value; + remove => _onBeforeCheck -= value; } [SRCategory(nameof(SR.CatBehavior))] [SRDescription(nameof(SR.TreeViewAfterCheckDescr))] - public event TreeViewEventHandler AfterCheck + public event TreeViewEventHandler? AfterCheck { - add => onAfterCheck += value; - remove => onAfterCheck -= value; + add => _onAfterCheck += value; + remove => _onAfterCheck -= value; } [SRCategory(nameof(SR.CatBehavior))] [SRDescription(nameof(SR.TreeViewBeforeCollapseDescr))] - public event TreeViewCancelEventHandler BeforeCollapse + public event TreeViewCancelEventHandler? BeforeCollapse { - add => onBeforeCollapse += value; - remove => onBeforeCollapse -= value; + add => _onBeforeCollapse += value; + remove => _onBeforeCollapse -= value; } [SRCategory(nameof(SR.CatBehavior))] [SRDescription(nameof(SR.TreeViewAfterCollapseDescr))] - public event TreeViewEventHandler AfterCollapse + public event TreeViewEventHandler? AfterCollapse { - add => onAfterCollapse += value; - remove => onAfterCollapse -= value; + add => _onAfterCollapse += value; + remove => _onAfterCollapse -= value; } [SRCategory(nameof(SR.CatBehavior))] [SRDescription(nameof(SR.TreeViewBeforeExpandDescr))] - public event TreeViewCancelEventHandler BeforeExpand + public event TreeViewCancelEventHandler? BeforeExpand { - add => onBeforeExpand += value; - remove => onBeforeExpand -= value; + add => _onBeforeExpand += value; + remove => _onBeforeExpand -= value; } [SRCategory(nameof(SR.CatBehavior))] [SRDescription(nameof(SR.TreeViewAfterExpandDescr))] - public event TreeViewEventHandler AfterExpand + public event TreeViewEventHandler? AfterExpand { - add => onAfterExpand += value; - remove => onAfterExpand -= value; + add => _onAfterExpand += value; + remove => _onAfterExpand -= value; } /// @@ -1511,42 +1422,42 @@ public event TreeViewEventHandler AfterExpand /// [SRCategory(nameof(SR.CatBehavior))] [SRDescription(nameof(SR.TreeViewDrawNodeEventDescr))] - public event DrawTreeNodeEventHandler DrawNode + public event DrawTreeNodeEventHandler? DrawNode { - add => onDrawNode += value; - remove => onDrawNode -= value; + add => _onDrawNode += value; + remove => _onDrawNode -= value; } [SRCategory(nameof(SR.CatAction))] [SRDescription(nameof(SR.ListViewItemDragDescr))] - public event ItemDragEventHandler ItemDrag + public event ItemDragEventHandler? ItemDrag { - add => onItemDrag += value; - remove => onItemDrag -= value; + add => _onItemDrag += value; + remove => _onItemDrag -= value; } [SRCategory(nameof(SR.CatAction))] [SRDescription(nameof(SR.TreeViewNodeMouseHoverDescr))] - public event TreeNodeMouseHoverEventHandler NodeMouseHover + public event TreeNodeMouseHoverEventHandler? NodeMouseHover { - add => onNodeMouseHover += value; - remove => onNodeMouseHover -= value; + add => _onNodeMouseHover += value; + remove => _onNodeMouseHover -= value; } [SRCategory(nameof(SR.CatBehavior))] [SRDescription(nameof(SR.TreeViewBeforeSelectDescr))] - public event TreeViewCancelEventHandler BeforeSelect + public event TreeViewCancelEventHandler? BeforeSelect { - add => onBeforeSelect += value; - remove => onBeforeSelect -= value; + add => _onBeforeSelect += value; + remove => _onBeforeSelect -= value; } [SRCategory(nameof(SR.CatBehavior))] [SRDescription(nameof(SR.TreeViewAfterSelectDescr))] - public event TreeViewEventHandler AfterSelect + public event TreeViewEventHandler? AfterSelect { - add => onAfterSelect += value; - remove => onAfterSelect -= value; + add => _onAfterSelect += value; + remove => _onAfterSelect -= value; } /// @@ -1555,7 +1466,7 @@ public event TreeViewEventHandler AfterSelect /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] - public new event PaintEventHandler Paint + public new event PaintEventHandler? Paint { add => base.Paint += value; remove => base.Paint -= value; @@ -1563,26 +1474,26 @@ public event TreeViewEventHandler AfterSelect [SRCategory(nameof(SR.CatBehavior))] [SRDescription(nameof(SR.TreeViewNodeMouseClickDescr))] - public event TreeNodeMouseClickEventHandler NodeMouseClick + public event TreeNodeMouseClickEventHandler? NodeMouseClick { - add => onNodeMouseClick += value; - remove => onNodeMouseClick -= value; + add => _onNodeMouseClick += value; + remove => _onNodeMouseClick -= value; } [SRCategory(nameof(SR.CatBehavior))] [SRDescription(nameof(SR.TreeViewNodeMouseDoubleClickDescr))] - public event TreeNodeMouseClickEventHandler NodeMouseDoubleClick + public event TreeNodeMouseClickEventHandler? NodeMouseDoubleClick { - add => onNodeMouseDoubleClick += value; - remove => onNodeMouseDoubleClick -= value; + add => _onNodeMouseDoubleClick += value; + remove => _onNodeMouseDoubleClick -= value; } [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.ControlOnRightToLeftLayoutChangedDescr))] - public event EventHandler RightToLeftLayoutChanged + public event EventHandler? RightToLeftLayoutChanged { - add => onRightToLeftLayoutChanged += value; - remove => onRightToLeftLayoutChanged -= value; + add => _onRightToLeftLayoutChanged += value; + remove => _onRightToLeftLayoutChanged -= value; } /// @@ -1601,7 +1512,7 @@ public void BeginUpdate() /// public void CollapseAll() { - root.Collapse(); + _root.Collapse(); } /// @@ -1632,7 +1543,7 @@ protected override unsafe void CreateHandle() /// Resets the imageList to null. We wire this method up to the imageList's /// Dispose event, so that we don't hang onto an imageList that's gone away. /// - private void DetachImageList(object sender, EventArgs e) + private void DetachImageList(object? sender, EventArgs e) { ImageList = null; } @@ -1641,9 +1552,9 @@ private void DetachImageList(object sender, EventArgs e) /// Resets the stateimageList to null. We wire this method up to the stateimageList's /// Dispose event, so that we don't hang onto an stateimageList that's gone away. /// - private void DetachStateImageList(object sender, EventArgs e) + private void DetachStateImageList(object? sender, EventArgs e) { - internalStateImageList = null; + _internalStateImageList = null; StateImageList = null; } @@ -1654,9 +1565,9 @@ protected override void Dispose(bool disposing) lock (this) { DetachImageListHandlers(); - imageList = null; + _imageList = null; DetachStateImageListHandlers(); - stateImageList = null; + _stateImageList = null; } } @@ -1683,7 +1594,7 @@ public void EndUpdate() /// public void ExpandAll() { - root.ExpandAll(); + _root.ExpandAll(); } /// @@ -1725,31 +1636,28 @@ internal override void SetToolTip(ToolTip toolTip) PInvoke.SendMessage(toolTip, PInvoke.TTM_SETMAXTIPWIDTH, 0, SystemInformation.MaxWindowTrackSize.Width); PInvoke.SendMessage(this, PInvoke.TVM_SETTOOLTIPS, (WPARAM)toolTip.Handle); - controlToolTipText = toolTip.GetToolTip(this); + _controlToolTipText = toolTip.GetToolTip(this); } /// /// Gives the information about which part of the treeNode is at the given point. /// - public TreeViewHitTestInfo HitTest(Point pt) - { - return HitTest(pt.X, pt.Y); - } + public TreeViewHitTestInfo HitTest(Point pt) => HitTest(pt.X, pt.Y); /// /// Gives the information about which part of the treeNode is at the given x, y. /// public TreeViewHitTestInfo HitTest(int x, int y) { - var tvhi = new TVHITTESTINFO + TVHITTESTINFO tvhi = new() { pt = new Point(x, y) }; nint hnode = PInvoke.SendMessage(this, PInvoke.TVM_HITTEST, 0, ref tvhi); - TreeNode node = hnode == 0 ? null : NodeFromHandle(hnode); + TreeNode? node = hnode == 0 ? null : NodeFromHandle(hnode); TreeViewHitTestLocations loc = (TreeViewHitTestLocations)tvhi.flags; - return (new TreeViewHitTestInfo(node, loc)); + return new TreeViewHitTestInfo(node, loc); } /// @@ -1770,25 +1678,19 @@ internal void TreeViewAfterCheck(TreeNode node, TreeViewAction actionTaken) /// /// Returns count of nodes at root, optionally including all subtrees. /// - public int GetNodeCount(bool includeSubTrees) - { - return root.GetNodeCount(includeSubTrees); - } + public int GetNodeCount(bool includeSubTrees) => _root.GetNodeCount(includeSubTrees); /// /// Returns the TreeNode at the given location in tree view coordinates. /// - public TreeNode GetNodeAt(Point pt) - { - return GetNodeAt(pt.X, pt.Y); - } + public TreeNode? GetNodeAt(Point pt) => GetNodeAt(pt.X, pt.Y); /// /// Returns the TreeNode at the given location in tree view coordinates. /// - public TreeNode GetNodeAt(int x, int y) + public TreeNode? GetNodeAt(int x, int y) { - var tvhi = new TVHITTESTINFO + TVHITTESTINFO tvhi = new() { pt = new Point(x, y) }; @@ -1797,7 +1699,7 @@ public TreeNode GetNodeAt(int x, int y) return (hnode == 0 ? null : NodeFromHandle(hnode)); } - private void ImageListRecreateHandle(object sender, EventArgs e) + private void ImageListRecreateHandle(object? sender, EventArgs e) { if (IsHandleCreated) { @@ -1809,6 +1711,7 @@ private void ImageListRecreateHandle(object sender, EventArgs e) private static void UpdateImagesRecursive(TreeNode node) { node.UpdateImage(); + // Iterate only through the Nodes collection rather than the // array since an item might have been removed from the collection, and // correspondingly "removed" from the array, but still exist in the array @@ -1819,9 +1722,9 @@ private static void UpdateImagesRecursive(TreeNode node) } } - private void ImageListChangedHandle(object sender, EventArgs e) + private void ImageListChangedHandle(object? sender, EventArgs e) { - if ((sender is not null) && (sender == imageList) && IsHandleCreated) + if ((sender is not null) && (sender == _imageList) && IsHandleCreated) { BeginUpdate(); foreach (TreeNode node in Nodes) @@ -1841,7 +1744,7 @@ private static void NotifyAboutGotFocus(TreeNode treeNode) } } - private static void NotifyAboutLostFocus(TreeNode treeNode) + private static void NotifyAboutLostFocus(TreeNode? treeNode) { if (treeNode is not null) { @@ -1849,61 +1752,62 @@ private static void NotifyAboutLostFocus(TreeNode treeNode) } } - private void StateImageListRecreateHandle(object sender, EventArgs e) + private void StateImageListRecreateHandle(object? sender, EventArgs e) { if (IsHandleCreated) { IntPtr handle = IntPtr.Zero; - if (internalStateImageList is not null) + if (_internalStateImageList is not null) { - handle = internalStateImageList.Handle; + handle = _internalStateImageList.Handle; } SetStateImageList(handle); } } - private void StateImageListChangedHandle(object sender, EventArgs e) + private void StateImageListChangedHandle(object? sender, EventArgs e) { - if ((sender is not null) && (sender == stateImageList) && IsHandleCreated) + if (sender is null || sender != _stateImageList || !IsHandleCreated) { - // Since the native treeview requires the state imagelist to be 1-indexed we need to - // re add the images if the original collection had changed. - if (stateImageList is not null && stateImageList.Images.Count > 0) - { - Image[] images = new Image[stateImageList.Images.Count + 1]; - images[0] = stateImageList.Images[0]; - for (int i = 1; i <= stateImageList.Images.Count; i++) - { - images[i] = stateImageList.Images[i - 1]; - } + return; + } - if (internalStateImageList is not null) - { - internalStateImageList.Images.Clear(); - internalStateImageList.Images.AddRange(images); - } - else - { - internalStateImageList = new ImageList(); - internalStateImageList.Images.AddRange(images); - } + // Since the native treeview requires the state imagelist to be 1-indexed we need to + // re add the images if the original collection had changed. + if (_stateImageList is null || _stateImageList.Images.Count <= 0) + { + UpdateCheckedState(_root, true); + return; + } - Debug.Assert(internalStateImageList is not null, "Why are changing images when the Imagelist is null?"); - if (internalStateImageList is not null) - { - if (ScaledStateImageSize is not null) - { - internalStateImageList.ImageSize = (Size)ScaledStateImageSize; - } + Image[] images = new Image[_stateImageList.Images.Count + 1]; + images[0] = _stateImageList.Images[0]; + for (int i = 1; i <= _stateImageList.Images.Count; i++) + { + images[i] = _stateImageList.Images[i - 1]; + } - SetStateImageList(internalStateImageList.Handle); - } - } - else //stateImageList is null || stateImageList.Images.Count = 0; + if (_internalStateImageList is not null) + { + _internalStateImageList.Images.Clear(); + _internalStateImageList.Images.AddRange(images); + } + else + { + _internalStateImageList = new ImageList(); + _internalStateImageList.Images.AddRange(images); + } + + Debug.Assert(_internalStateImageList is not null, "Why are changing images when the Imagelist is null?"); + if (_internalStateImageList is not null) + { + if (ScaledStateImageSize is not null) { - UpdateCheckedState(root, true); + _internalStateImageList.ImageSize = (Size)ScaledStateImageSize; } + + SetStateImageList(_internalStateImageList.Handle); } } @@ -1915,7 +1819,7 @@ protected override bool IsInputKey(Keys keyData) // If in edit mode, treat Return as an input key, so the form doesn't grab it // and treat it as clicking the Form.AcceptButton. Similarly for Escape // and Form.CancelButton. - if (editNode is not null && (keyData & Keys.Alt) == 0) + if (_editNode is not null && (keyData & Keys.Alt) == 0) { switch (keyData & Keys.KeyCode) { @@ -1936,9 +1840,9 @@ protected override bool IsInputKey(Keys keyData) /// Note this can be null - particularly if any windows messages get generated during /// the insertion of a tree node (TVM_INSERTITEM) /// - internal TreeNode NodeFromHandle(IntPtr handle) + internal TreeNode? NodeFromHandle(IntPtr handle) { - _nodesByHandle.TryGetValue(handle, out TreeNode treeNode); + _nodesByHandle.TryGetValue(handle, out TreeNode? treeNode); return treeNode; } @@ -1947,7 +1851,7 @@ internal TreeNode NodeFromHandle(IntPtr handle) /// protected virtual void OnDrawNode(DrawTreeNodeEventArgs e) { - onDrawNode?.Invoke(this, e); + _onDrawNode?.Invoke(this, e); } protected override void OnHandleCreated(EventArgs e) @@ -1958,8 +1862,8 @@ protected override void OnHandleCreated(EventArgs e) return; } - TreeNode savedSelectedNode = selectedNode; - selectedNode = null; + TreeNode? savedSelectedNode = _selectedNode; + _selectedNode = null; base.OnHandleCreated(e); @@ -2005,27 +1909,27 @@ protected override void OnHandleCreated(EventArgs e) } // Put the linecolor into the native control only if set. - if (lineColor != Color.Empty) + if (_lineColor != Color.Empty) { - PInvoke.SendMessage(this, PInvoke.TVM_SETLINECOLOR, 0, lineColor.ToWin32()); + PInvoke.SendMessage(this, PInvoke.TVM_SETLINECOLOR, 0, _lineColor.ToWin32()); } - if (imageList is not null) + if (_imageList is not null) { - PInvoke.SendMessage(this, PInvoke.TVM_SETIMAGELIST, 0, imageList.Handle); + PInvoke.SendMessage(this, PInvoke.TVM_SETIMAGELIST, 0, _imageList.Handle); } - if (stateImageList is not null) + if (_stateImageList is not null) { UpdateNativeStateImageList(); } - if (indent != -1) + if (_indent != -1) { - PInvoke.SendMessage(this, PInvoke.TVM_SETINDENT, (WPARAM)indent); + PInvoke.SendMessage(this, PInvoke.TVM_SETINDENT, (WPARAM)_indent); } - if (itemHeight != -1) + if (_itemHeight != -1) { PInvoke.SendMessage(this, PInvoke.TVM_SETITEMHEIGHT, (WPARAM)ItemHeight); } @@ -2037,7 +1941,7 @@ protected override void OnHandleCreated(EventArgs e) // This is set back to the oldSize after the Realize method. try { - treeViewState[TREEVIEWSTATE_stopResizeWindowMsgs] = true; + _treeViewState[TREEVIEWSTATE_stopResizeWindowMsgs] = true; int oldSize = Width; SET_WINDOW_POS_FLAGS flags = SET_WINDOW_POS_FLAGS.SWP_NOZORDER | SET_WINDOW_POS_FLAGS.SWP_NOACTIVATE @@ -2052,7 +1956,7 @@ protected override void OnHandleCreated(EventArgs e) Height, flags); - root.Realize(insertFirst: false); + _root.Realize(insertFirst: false); if (oldSize != 0) { @@ -2068,7 +1972,7 @@ protected override void OnHandleCreated(EventArgs e) } finally { - treeViewState[TREEVIEWSTATE_stopResizeWindowMsgs] = false; + _treeViewState[TREEVIEWSTATE_stopResizeWindowMsgs] = false; } SelectedNode = savedSelectedNode; @@ -2078,27 +1982,29 @@ protected override void OnHandleCreated(EventArgs e) // set the value of internalStateImageList to the new list private void UpdateNativeStateImageList() { - if (stateImageList is not null && stateImageList.Images.Count > 0) + if (_stateImageList is null || _stateImageList.Images.Count <= 0) { - ImageList newImageList = new ImageList(); - if (ScaledStateImageSize is not null) - { - newImageList.ImageSize = (Size)ScaledStateImageSize; - } - - Image[] images = new Image[stateImageList.Images.Count + 1]; - images[0] = stateImageList.Images[0]; - for (int i = 1; i <= stateImageList.Images.Count; i++) - { - images[i] = stateImageList.Images[i - 1]; - } + return; + } - newImageList.Images.AddRange(images); - PInvoke.SendMessage(this, PInvoke.TVM_SETIMAGELIST, (WPARAM)(uint)PInvoke.TVSIL_STATE, (LPARAM)newImageList.Handle); + ImageList newImageList = new(); + if (ScaledStateImageSize is not null) + { + newImageList.ImageSize = (Size)ScaledStateImageSize; + } - internalStateImageList?.Dispose(); - internalStateImageList = newImageList; + Image[] images = new Image[_stateImageList.Images.Count + 1]; + images[0] = _stateImageList.Images[0]; + for (int i = 1; i <= _stateImageList.Images.Count; i++) + { + images[i] = _stateImageList.Images[i - 1]; } + + newImageList.Images.AddRange(images); + PInvoke.SendMessage(this, PInvoke.TVM_SETIMAGELIST, (WPARAM)(uint)PInvoke.TVSIL_STATE, (LPARAM)newImageList.Handle); + + _internalStateImageList?.Dispose(); + _internalStateImageList = newImageList; } private void SetStateImageList(IntPtr handle) @@ -2129,7 +2035,7 @@ private void DestroyNativeStateImageList(bool reset) protected override void OnHandleDestroyed(EventArgs e) { - selectedNode = SelectedNode; + _selectedNode = SelectedNode; // Unfortunately, to avoid the native tree view leaking it's State Image List, we need to // destroy it ourselves here. @@ -2137,10 +2043,10 @@ protected override void OnHandleDestroyed(EventArgs e) // for the case when we are NOT being disposed, we'll be recreating the internal state imagelist // in OnHandleCreate, so it is ok to completely Dispose here - if (internalStateImageList is not null) + if (_internalStateImageList is not null) { - internalStateImageList.Dispose(); - internalStateImageList = null; + _internalStateImageList.Dispose(); + _internalStateImageList = null; } base.OnHandleDestroyed(e); @@ -2151,7 +2057,7 @@ protected override void OnHandleDestroyed(EventArgs e) /// protected override void OnMouseLeave(EventArgs e) { - hoveredAlready = false; + _hoveredAlready = false; base.OnMouseLeave(e); } @@ -2164,7 +2070,7 @@ protected override void OnMouseHover(EventArgs e) { // Hover events need to be caught for each node within the TreeView so // the appropriate NodeHovered event can be raised. - var tvhip = new TVHITTESTINFO + TVHITTESTINFO tvhip = new() { pt = PointToClient(Cursor.Position) }; @@ -2172,19 +2078,19 @@ protected override void OnMouseHover(EventArgs e) nint hnode = PInvoke.SendMessage(this, PInvoke.TVM_HITTEST, 0, ref tvhip); if (hnode != 0 && ((tvhip.flags & TVHT.ONITEM) != 0)) { - TreeNode tn = NodeFromHandle(hnode); - if (tn != prevHoveredNode && tn is not null) + TreeNode? tn = NodeFromHandle(hnode); + if (tn != _prevHoveredNode && tn is not null) { OnNodeMouseHover(new TreeNodeMouseHoverEventArgs(tn)); - prevHoveredNode = tn; + _prevHoveredNode = tn; NotifyAboutLostFocus(SelectedNode); } } - if (!hoveredAlready) + if (!_hoveredAlready) { base.OnMouseHover(e); - hoveredAlready = true; + _hoveredAlready = true; } ResetMouseEventArgs(); @@ -2195,7 +2101,7 @@ protected override void OnMouseHover(EventArgs e) /// protected virtual void OnBeforeLabelEdit(NodeLabelEditEventArgs e) { - onBeforeLabelEdit?.Invoke(this, e); + _onBeforeLabelEdit?.Invoke(this, e); } /// @@ -2203,13 +2109,13 @@ protected virtual void OnBeforeLabelEdit(NodeLabelEditEventArgs e) /// protected virtual void OnAfterLabelEdit(NodeLabelEditEventArgs e) { - onAfterLabelEdit?.Invoke(this, e); + _onAfterLabelEdit?.Invoke(this, e); // Raise an event to highlight & announce the edited node // if editing hasn't been canceled. if (IsAccessibilityObjectCreated && !e.CancelEdit) { - e.Node.AccessibilityObject.RaiseAutomationEvent(UiaCore.UIA.AutomationFocusChangedEventId); + e.Node!.AccessibilityObject.RaiseAutomationEvent(UiaCore.UIA.AutomationFocusChangedEventId); } } @@ -2218,7 +2124,7 @@ protected virtual void OnAfterLabelEdit(NodeLabelEditEventArgs e) /// protected virtual void OnBeforeCheck(TreeViewCancelEventArgs e) { - onBeforeCheck?.Invoke(this, e); + _onBeforeCheck?.Invoke(this, e); } /// @@ -2226,12 +2132,12 @@ protected virtual void OnBeforeCheck(TreeViewCancelEventArgs e) /// protected virtual void OnAfterCheck(TreeViewEventArgs e) { - onAfterCheck?.Invoke(this, e); + _onAfterCheck?.Invoke(this, e); // Raise an event to announce a toggle state change. if (IsAccessibilityObjectCreated) { - AccessibleObject nodeAccessibleObject = e.Node.AccessibilityObject; + AccessibleObject nodeAccessibleObject = e.Node!.AccessibilityObject; UiaCore.ToggleState newState = nodeAccessibleObject.ToggleState; UiaCore.ToggleState oldState = newState == UiaCore.ToggleState.On ? UiaCore.ToggleState.Off @@ -2249,7 +2155,7 @@ protected virtual void OnAfterCheck(TreeViewEventArgs e) /// protected internal virtual void OnBeforeCollapse(TreeViewCancelEventArgs e) { - onBeforeCollapse?.Invoke(this, e); + _onBeforeCollapse?.Invoke(this, e); } /// @@ -2257,12 +2163,12 @@ protected internal virtual void OnBeforeCollapse(TreeViewCancelEventArgs e) /// protected internal virtual void OnAfterCollapse(TreeViewEventArgs e) { - onAfterCollapse?.Invoke(this, e); + _onAfterCollapse?.Invoke(this, e); // Raise an event to announce the expand-collapse state change. if (IsAccessibilityObjectCreated) { - e.Node.AccessibilityObject.RaiseAutomationPropertyChangedEvent( + e.Node!.AccessibilityObject.RaiseAutomationPropertyChangedEvent( UiaCore.UIA.ExpandCollapseExpandCollapseStatePropertyId, oldValue: UiaCore.ExpandCollapseState.Expanded, newValue: UiaCore.ExpandCollapseState.Collapsed); @@ -2274,7 +2180,7 @@ protected internal virtual void OnAfterCollapse(TreeViewEventArgs e) /// protected virtual void OnBeforeExpand(TreeViewCancelEventArgs e) { - onBeforeExpand?.Invoke(this, e); + _onBeforeExpand?.Invoke(this, e); } /// @@ -2282,12 +2188,12 @@ protected virtual void OnBeforeExpand(TreeViewCancelEventArgs e) /// protected virtual void OnAfterExpand(TreeViewEventArgs e) { - onAfterExpand?.Invoke(this, e); + _onAfterExpand?.Invoke(this, e); // Raise anevent to announce the expand-collapse state change. if (IsAccessibilityObjectCreated) { - e.Node.AccessibilityObject.RaiseAutomationPropertyChangedEvent( + e.Node!.AccessibilityObject.RaiseAutomationPropertyChangedEvent( UiaCore.UIA.ExpandCollapseExpandCollapseStatePropertyId, oldValue: UiaCore.ExpandCollapseState.Collapsed, newValue: UiaCore.ExpandCollapseState.Expanded); @@ -2299,7 +2205,7 @@ protected virtual void OnAfterExpand(TreeViewEventArgs e) /// protected virtual void OnItemDrag(ItemDragEventArgs e) { - onItemDrag?.Invoke(this, e); + _onItemDrag?.Invoke(this, e); } /// @@ -2307,7 +2213,7 @@ protected virtual void OnItemDrag(ItemDragEventArgs e) /// protected virtual void OnNodeMouseHover(TreeNodeMouseHoverEventArgs e) { - onNodeMouseHover?.Invoke(this, e); + _onNodeMouseHover?.Invoke(this, e); } /// @@ -2315,7 +2221,7 @@ protected virtual void OnNodeMouseHover(TreeNodeMouseHoverEventArgs e) /// protected virtual void OnBeforeSelect(TreeViewCancelEventArgs e) { - onBeforeSelect?.Invoke(this, e); + _onBeforeSelect?.Invoke(this, e); } /// @@ -2323,12 +2229,12 @@ protected virtual void OnBeforeSelect(TreeViewCancelEventArgs e) /// protected virtual void OnAfterSelect(TreeViewEventArgs e) { - onAfterSelect?.Invoke(this, e); + _onAfterSelect?.Invoke(this, e); // Raise an event to highlight & announce the selected node. if (IsAccessibilityObjectCreated) { - AccessibleObject nodeAccessibleObject = e.Node.AccessibilityObject; + AccessibleObject nodeAccessibleObject = e.Node!.AccessibilityObject; nodeAccessibleObject.RaiseAutomationEvent(UiaCore.UIA.AutomationFocusChangedEventId); nodeAccessibleObject.RaiseAutomationEvent(UiaCore.UIA.SelectionItem_ElementSelectedEventId); @@ -2345,7 +2251,7 @@ protected virtual void OnAfterSelect(TreeViewEventArgs e) /// protected virtual void OnNodeMouseClick(TreeNodeMouseClickEventArgs e) { - onNodeMouseClick?.Invoke(this, e); + _onNodeMouseClick?.Invoke(this, e); } /// @@ -2353,7 +2259,7 @@ protected virtual void OnNodeMouseClick(TreeNodeMouseClickEventArgs e) /// protected virtual void OnNodeMouseDoubleClick(TreeNodeMouseClickEventArgs e) { - onNodeMouseDoubleClick?.Invoke(this, e); + _onNodeMouseDoubleClick?.Invoke(this, e); } /// @@ -2371,7 +2277,7 @@ protected override void OnKeyDown(KeyEventArgs e) // cancelled. if (CheckBoxes && (e.KeyData & Keys.KeyCode) == Keys.Space) { - TreeNode node = SelectedNode; + TreeNode? node = SelectedNode; if (node is not null) { bool eventReturn = TreeViewBeforeCheck(node, TreeViewAction.ByKeyboard); @@ -2437,7 +2343,7 @@ protected virtual void OnRightToLeftLayoutChanged(EventArgs e) RecreateHandle(); } - onRightToLeftLayoutChanged?.Invoke(this, e); + _onRightToLeftLayoutChanged?.Invoke(this, e); } // Refresh the nodes by clearing the tree and adding the nodes back again @@ -2456,7 +2362,7 @@ private void RefreshNodes() /// private void ResetIndent() { - indent = -1; + _indent = -1; // is this overkill? RecreateHandle(); } @@ -2466,29 +2372,23 @@ private void ResetIndent() /// private void ResetItemHeight() { - itemHeight = -1; + _itemHeight = -1; RecreateHandle(); } /// /// Retrieves true if the indent should be persisted in code gen. /// - private bool ShouldSerializeIndent() - { - return (indent != -1); - } + private bool ShouldSerializeIndent() => (_indent != -1); /// /// Retrieves true if the itemHeight should be persisted in code gen. /// - private bool ShouldSerializeItemHeight() - { - return (itemHeight != -1); - } + private bool ShouldSerializeItemHeight() => (_itemHeight != -1); private bool ShouldSerializeSelectedImageIndex() { - if (imageList is not null) + if (_imageList is not null) { return (SelectedImageIndex != 0); } @@ -2498,7 +2398,7 @@ private bool ShouldSerializeSelectedImageIndex() private bool ShouldSerializeImageIndex() { - if (imageList is not null) + if (_imageList is not null) { return (ImageIndex != 0); } @@ -2534,7 +2434,7 @@ public override string ToString() return s; } - +#nullable disable private unsafe void TvnBeginDrag(MouseButtons buttons, NMTREEVIEW* nmtv) { TVITEMW item = nmtv->itemNew; @@ -2603,7 +2503,7 @@ private unsafe void TvnExpanded(NMTREEVIEW* nmtv) private unsafe IntPtr TvnSelecting(NMTREEVIEW* nmtv) { - if (treeViewState[TREEVIEWSTATE_ignoreSelects]) + if (_treeViewState[TREEVIEWSTATE_ignoreSelects]) { return (IntPtr)1; } @@ -2637,7 +2537,7 @@ private unsafe IntPtr TvnSelecting(NMTREEVIEW* nmtv) private unsafe void TvnSelected(NMTREEVIEW* nmtv) { // If called from the TreeNodeCollection.Clear() then return. - if (nodesCollectionClear) + if (_nodesCollectionClear) { return; } @@ -2661,7 +2561,7 @@ private unsafe void TvnSelected(NMTREEVIEW* nmtv) } // TreeView doesn't properly revert back to the unselected image if the unselected image is blank. - var rc = default(RECT); + RECT rc = default; *((IntPtr*)&rc.left) = nmtv->itemOld.hItem; if (nmtv->itemOld.hItem != IntPtr.Zero) { @@ -2685,7 +2585,7 @@ private IntPtr TvnBeginLabelEdit(NMTVDISPINFOW nmtvdi) OnBeforeLabelEdit(e); if (!e.CancelEdit) { - editNode = editingNode; + _editNode = editingNode; } return (IntPtr)(e.CancelEdit ? 1 : 0); @@ -2693,7 +2593,7 @@ private IntPtr TvnBeginLabelEdit(NMTVDISPINFOW nmtvdi) private IntPtr TvnEndLabelEdit(NMTVDISPINFOW nmtvdi) { - editNode = null; + _editNode = null; // Check for invalid node handle if (nmtvdi.item.hItem == IntPtr.Zero) @@ -2727,9 +2627,9 @@ internal override void UpdateStylesCore() // Setting the TVS_CHECKBOXES window style also causes the TreeView to display the default checkbox // images rather than the user specified StateImageList. We send a TVM_SETIMAGELIST to restore the // user's images. - if (internalStateImageList is not null) + if (_internalStateImageList is not null) { - SetStateImageList(internalStateImageList.Handle); + SetStateImageList(_internalStateImageList.Handle); } } } @@ -2744,7 +2644,7 @@ private void UpdateTreeViewExtendedStyles() // Only set the TVS_EX_DOUBLEBUFFER style if the DoubleBuffered property setter has been executed. // This stops the style from being removed for any derived classes that set it using P/Invoke. - if (treeViewState[TREEVIEWSTATE_doubleBufferedPropertySet]) + if (_treeViewState[TREEVIEWSTATE_doubleBufferedPropertySet]) { PInvoke.SendMessage(this, PInvoke.TVM_SETEXTENDEDSTYLE, (WPARAM)(nint)PInvoke.TVS_EX_DOUBLEBUFFER, (LPARAM)(nint)(DoubleBuffered ? PInvoke.TVS_EX_DOUBLEBUFFER : 0)); } @@ -2829,13 +2729,13 @@ private unsafe void CustomDraw(ref Message m) // or nothing at all. The way we provide OwnerDrawText is by asking it // to draw everything but the text - to do this, we set text color same // as background color. - if (drawMode == TreeViewDrawMode.OwnerDrawText) + if (_drawMode == TreeViewDrawMode.OwnerDrawText) { nmtvcd->clrText = nmtvcd->clrTextBk; m.ResultInternal = (LRESULT)(nint)(PInvoke.CDRF_NEWFONT | PInvoke.CDRF_NOTIFYPOSTPAINT); return; } - else if (drawMode == TreeViewDrawMode.OwnerDrawAll) + else if (_drawMode == TreeViewDrawMode.OwnerDrawAll) { Graphics g = nmtvcd->nmcd.hdc.CreateGraphics(); @@ -2912,7 +2812,7 @@ private unsafe void CustomDraw(ref Message m) case NMCUSTOMDRAW_DRAW_STAGE.CDDS_ITEMPOSTPAINT: //User draws only the text in OwnerDrawText mode, as explained in comments above - if (drawMode == TreeViewDrawMode.OwnerDrawText) + if (_drawMode == TreeViewDrawMode.OwnerDrawText) { Debug.Assert(nmtvcd->nmcd.dwItemSpec != 0, "Invalid node handle in ITEMPOSTPAINT"); @@ -3008,7 +2908,7 @@ internal override unsafe ComCtl32.ToolInfoWrapper GetToolInfoWrapper(TO // The second condition is necessary for the correct display of the keyboard tooltip, // since the logic of the external tooltip blocks its display bool isExternalTooltip = ShowNodeToolTips && tooltip != KeyboardToolTip; - var wrapper = new ComCtl32.ToolInfoWrapper(this, flags, isExternalTooltip ? null : caption); + ComCtl32.ToolInfoWrapper wrapper = new(this, flags, isExternalTooltip ? null : caption); if (isExternalTooltip) wrapper.Info.lpszText = (char*)(-1); @@ -3020,7 +2920,7 @@ private unsafe bool WmShowToolTip(ref Message m) NMHDR* nmhdr = (NMHDR*)(nint)m.LParamInternal; HWND tooltipHandle = nmhdr->hwndFrom; - var tvhip = new TVHITTESTINFO + TVHITTESTINFO tvhip = new() { pt = PointToClient(Cursor.Position) }; @@ -3049,9 +2949,9 @@ private unsafe bool WmShowToolTip(ref Message m) private unsafe void WmNeedText(ref Message m) { NMTTDISPINFOW* ttt = (NMTTDISPINFOW*)(nint)m.LParamInternal; - string tipText = controlToolTipText; + string tipText = _controlToolTipText; - var tvhip = new TVHITTESTINFO + TVHITTESTINFO tvhip = new() { pt = PointToClient(Cursor.Position) }; @@ -3128,7 +3028,7 @@ private unsafe void WmNotify(ref Message m) case (int)NM.RCLICK: MouseButtons button = MouseButtons.Left; Point pos = PointToClient(Cursor.Position); - var tvhip = new TVHITTESTINFO + TVHITTESTINFO tvhip = new() { pt = pos }; @@ -3162,14 +3062,14 @@ private unsafe void WmNotify(ref Message m) } else { - treeViewState[TREEVIEWSTATE_showTreeViewContextMenu] = true; + _treeViewState[TREEVIEWSTATE_showTreeViewContextMenu] = true; PInvoke.SendMessage(this, PInvoke.WM_CONTEXTMENU, (WPARAM)HWND, (LPARAM)PInvoke.GetMessagePos()); } m.ResultInternal = (LRESULT)1; } - if (!treeViewState[TREEVIEWSTATE_mouseUpFired]) + if (!_treeViewState[TREEVIEWSTATE_mouseUpFired]) { if ((int)nmtv->nmhdr.code != (int)NM.CLICK || (tvhip.flags & TVHT.ONITEM) != 0) @@ -3178,7 +3078,7 @@ private unsafe void WmNotify(ref Message m) // LBUTTONUP happens on TVHT_ONITEM. This is a comctl quirk. // We work around that by calling OnMouseUp here. OnMouseUp(new MouseEventArgs(button, 1, pos.X, pos.Y, 0)); - treeViewState[TREEVIEWSTATE_mouseUpFired] = true; + _treeViewState[TREEVIEWSTATE_mouseUpFired] = true; } } @@ -3266,7 +3166,7 @@ protected override unsafe void WndProc(ref Message m) case PInvoke.WM_WINDOWPOSCHANGED: case PInvoke.WM_SIZE: // While we are changing size of treeView to avoid the scrollbar; don't respond to the window-sizing messages. - if (treeViewState[TREEVIEWSTATE_stopResizeWindowMsgs]) + if (_treeViewState[TREEVIEWSTATE_stopResizeWindowMsgs]) { DefWndProc(ref m); } @@ -3297,7 +3197,7 @@ protected override unsafe void WndProc(ref Message m) // Check for invalid node handle if (item->hItem != IntPtr.Zero) { - var item1 = new TVITEMW + TVITEMW item1 = new() { mask = TVITEM_MASK.TVIF_HANDLE | TVITEM_MASK.TVIF_STATE, hItem = item->hItem, @@ -3347,10 +3247,10 @@ protected override unsafe void WndProc(ref Message m) WmMouseDown(ref m, MouseButtons.Left, 2); // Just maintain state and fire double click in final mouseUp. - treeViewState[TREEVIEWSTATE_doubleclickFired] = true; + _treeViewState[TREEVIEWSTATE_doubleclickFired] = true; // Fire mouse up in the Wndproc. - treeViewState[TREEVIEWSTATE_mouseUpFired] = false; + _treeViewState[TREEVIEWSTATE_mouseUpFired] = false; // Make sure we get the mouse up if it happens outside the control. Capture = true; @@ -3358,17 +3258,17 @@ protected override unsafe void WndProc(ref Message m) case PInvoke.WM_LBUTTONDOWN: try { - treeViewState[TREEVIEWSTATE_ignoreSelects] = true; + _treeViewState[TREEVIEWSTATE_ignoreSelects] = true; Focus(); } finally { - treeViewState[TREEVIEWSTATE_ignoreSelects] = false; + _treeViewState[TREEVIEWSTATE_ignoreSelects] = false; } // Always reset the MouseupFired. - treeViewState[TREEVIEWSTATE_mouseUpFired] = false; - var tvhip = new TVHITTESTINFO + _treeViewState[TREEVIEWSTATE_mouseUpFired] = false; + TVHITTESTINFO tvhip = new() { pt = PARAM.ToPoint(m.LParamInternal) }; @@ -3399,13 +3299,13 @@ protected override unsafe void WndProc(ref Message m) WmMouseDown(ref m, MouseButtons.Left, 1); } - downButton = MouseButtons.Left; + _downButton = MouseButtons.Left; break; case PInvoke.WM_LBUTTONUP: case PInvoke.WM_RBUTTONUP: Point point = PARAM.ToPoint(m.LParamInternal); - var tvhi = new TVHITTESTINFO + TVHITTESTINFO tvhi = new() { pt = point }; @@ -3415,38 +3315,38 @@ protected override unsafe void WndProc(ref Message m) // Important for CheckBoxes. Click needs to be fired. if (hnode != 0) { - if (!ValidationCancelled && !treeViewState[TREEVIEWSTATE_doubleclickFired] & !treeViewState[TREEVIEWSTATE_mouseUpFired]) + if (!ValidationCancelled && !_treeViewState[TREEVIEWSTATE_doubleclickFired] & !_treeViewState[TREEVIEWSTATE_mouseUpFired]) { // If the hit-tested node here is the same as the node we hit-tested // on mouse down then we will fire our OnNodeMoseClick event. if (hnode == _mouseDownNode) { - OnNodeMouseClick(new TreeNodeMouseClickEventArgs(NodeFromHandle(hnode), downButton, 1, point.X, point.Y)); + OnNodeMouseClick(new TreeNodeMouseClickEventArgs(NodeFromHandle(hnode), _downButton, 1, point.X, point.Y)); } - OnClick(new MouseEventArgs(downButton, 1, point)); - OnMouseClick(new MouseEventArgs(downButton, 1, point)); + OnClick(new MouseEventArgs(_downButton, 1, point)); + OnMouseClick(new MouseEventArgs(_downButton, 1, point)); } - if (treeViewState[TREEVIEWSTATE_doubleclickFired]) + if (_treeViewState[TREEVIEWSTATE_doubleclickFired]) { - treeViewState[TREEVIEWSTATE_doubleclickFired] = false; + _treeViewState[TREEVIEWSTATE_doubleclickFired] = false; if (!ValidationCancelled) { - OnNodeMouseDoubleClick(new TreeNodeMouseClickEventArgs(NodeFromHandle(hnode), downButton, 2, point.X, point.Y)); - OnDoubleClick(new MouseEventArgs(downButton, 2, point)); - OnMouseDoubleClick(new MouseEventArgs(downButton, 2, point)); + OnNodeMouseDoubleClick(new TreeNodeMouseClickEventArgs(NodeFromHandle(hnode), _downButton, 2, point.X, point.Y)); + OnDoubleClick(new MouseEventArgs(_downButton, 2, point)); + OnMouseDoubleClick(new MouseEventArgs(_downButton, 2, point)); } } } - if (!treeViewState[TREEVIEWSTATE_mouseUpFired]) + if (!_treeViewState[TREEVIEWSTATE_mouseUpFired]) { - OnMouseUp(new MouseEventArgs(downButton, 1, point)); + OnMouseUp(new MouseEventArgs(_downButton, 1, point)); } - treeViewState[TREEVIEWSTATE_doubleclickFired] = false; - treeViewState[TREEVIEWSTATE_mouseUpFired] = false; + _treeViewState[TREEVIEWSTATE_doubleclickFired] = false; + _treeViewState[TREEVIEWSTATE_mouseUpFired] = false; Capture = false; // Always clear our hit-tested node we cached on mouse down @@ -3454,39 +3354,39 @@ protected override unsafe void WndProc(ref Message m) break; case PInvoke.WM_MBUTTONDBLCLK: // Fire mouse up in the Wndproc. - treeViewState[TREEVIEWSTATE_mouseUpFired] = false; + _treeViewState[TREEVIEWSTATE_mouseUpFired] = false; WmMouseDown(ref m, MouseButtons.Middle, 2); break; case PInvoke.WM_MBUTTONDOWN: // Always reset MouseupFired. - treeViewState[TREEVIEWSTATE_mouseUpFired] = false; + _treeViewState[TREEVIEWSTATE_mouseUpFired] = false; WmMouseDown(ref m, MouseButtons.Middle, 1); - downButton = MouseButtons.Middle; + _downButton = MouseButtons.Middle; break; case PInvoke.WM_MOUSELEAVE: // if the mouse leaves and then reenters the TreeView // NodeHovered events should be raised. - prevHoveredNode = null; + _prevHoveredNode = null; base.WndProc(ref m); break; case PInvoke.WM_RBUTTONDBLCLK: WmMouseDown(ref m, MouseButtons.Right, 2); // Just maintain state and fire double click in the final mouseUp. - treeViewState[TREEVIEWSTATE_doubleclickFired] = true; + _treeViewState[TREEVIEWSTATE_doubleclickFired] = true; // Fire mouse up in the Wndproc - treeViewState[TREEVIEWSTATE_mouseUpFired] = false; + _treeViewState[TREEVIEWSTATE_mouseUpFired] = false; // Make sure we get the mouse up if it happens outside the control. Capture = true; break; case PInvoke.WM_RBUTTONDOWN: // Always Reset the MouseupFired.... - treeViewState[TREEVIEWSTATE_mouseUpFired] = false; + _treeViewState[TREEVIEWSTATE_mouseUpFired] = false; //Cache the hit-tested node for verification when mouse up is fired - var tvhit = new TVHITTESTINFO + TVHITTESTINFO tvhit = new() { pt = PARAM.ToPoint(m.LParamInternal) }; @@ -3494,7 +3394,7 @@ protected override unsafe void WndProc(ref Message m) _mouseDownNode = PInvoke.SendMessage(this, PInvoke.TVM_HITTEST, 0, ref tvhit); WmMouseDown(ref m, MouseButtons.Right, 1); - downButton = MouseButtons.Right; + _downButton = MouseButtons.Right; break; case PInvoke.WM_SYSCOLORCHANGE: PInvoke.SendMessage(this, PInvoke.TVM_SETINDENT, (WPARAM)Indent); @@ -3503,9 +3403,9 @@ protected override unsafe void WndProc(ref Message m) case PInvoke.WM_SETFOCUS: // If we get focus through the LButtonDown .. we might have done the validation... // so skip it.. - if (treeViewState[TREEVIEWSTATE_lastControlValidated]) + if (_treeViewState[TREEVIEWSTATE_lastControlValidated]) { - treeViewState[TREEVIEWSTATE_lastControlValidated] = false; + _treeViewState[TREEVIEWSTATE_lastControlValidated] = false; WmImeSetFocus(); DefWndProc(ref m); InvokeGotFocus(this, EventArgs.Empty); @@ -3517,9 +3417,9 @@ protected override unsafe void WndProc(ref Message m) break; case PInvoke.WM_CONTEXTMENU: - if (treeViewState[TREEVIEWSTATE_showTreeViewContextMenu]) + if (_treeViewState[TREEVIEWSTATE_showTreeViewContextMenu]) { - treeViewState[TREEVIEWSTATE_showTreeViewContextMenu] = false; + _treeViewState[TREEVIEWSTATE_showTreeViewContextMenu] = false; base.WndProc(ref m); } else diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewAction.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewAction.cs index a45a8a46352..f881a00b555 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewAction.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewAction.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewCancelEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewCancelEventArgs.cs index 1ad57e75273..4756feeb4f6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewCancelEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewCancelEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewCancelEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewCancelEventHandler.cs index 7e22015a585..3c2848676a5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewCancelEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewCancelEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewDrawMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewDrawMode.cs index ecdb4349cf4..77df711137e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewDrawMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewDrawMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewEventArgs.cs index c61cff1615b..9c9676f484d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewEventHandler.cs index 8a9d5d37b81..715138f7d21 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewHitTestInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewHitTestInfo.cs index 958960327f7..c0121b94c5a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewHitTestInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewHitTestInfo.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewHitTestLocation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewHitTestLocation.cs index 5fdc786aa1b..8bf1b40e8d2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewHitTestLocation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewHitTestLocation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewImageIndexConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewImageIndexConverter.cs index 4df40cd6caf..052e6213aab 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewImageIndexConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewImageIndexConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewImageKeyConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewImageKeyConverter.cs index 18682a53fbe..648c7a147b2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewImageKeyConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeViewImageKeyConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Triangle.TriangleDirection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Triangle.TriangleDirection.cs index 6f6eb25415c..ada3cae0e87 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Triangle.TriangleDirection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Triangle.TriangleDirection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Triangle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Triangle.cs index 5993241ec64..f325981c890 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Triangle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Triangle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TypeValidationEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TypeValidationEventArgs.cs index f36ff605795..030d2b0ee93 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TypeValidationEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TypeValidationEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TypeValidationEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TypeValidationEventHandler.cs index 5d120a35e5c..238d09b0735 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TypeValidationEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TypeValidationEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TypedControlCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TypedControlCollection.cs index 1479252d99f..6c96c7995a6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TypedControlCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TypedControlCollection.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Globalization; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UICues.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UICues.cs index ac7d498edad..f2ed545fb85 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UICues.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UICues.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UICuesEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UICuesEventArgs.cs index 9d03df14a50..e9c9443ef3f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UICuesEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UICuesEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UICuesEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UICuesEventHandler.cs index 5d246b68a16..895338a5adf 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UICuesEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UICuesEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UnhandledExceptionMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UnhandledExceptionMode.cs index 36d4edb2435..288c54a6cd5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UnhandledExceptionMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UnhandledExceptionMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.ButtonID.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.ButtonID.cs index 87e1dc9d19e..c8abc04c322 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.ButtonID.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.ButtonID.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownBaseAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownBaseAccessibleObject.cs index fea011d01a7..cbff47bc333 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownBaseAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownBaseAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.UpDownButtonsAccessibleObject.DirectionButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.UpDownButtonsAccessibleObject.DirectionButtonAccessibleObject.cs index 342031a2c9f..c83ecff3538 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.UpDownButtonsAccessibleObject.DirectionButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.UpDownButtonsAccessibleObject.DirectionButtonAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.UpDownButtonsAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.UpDownButtonsAccessibleObject.cs index f4cbeba3f3e..ea7b811db65 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.UpDownButtonsAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.UpDownButtonsAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.cs index 5552d4fd0a3..7b381a16225 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms.VisualStyles; @@ -258,7 +257,7 @@ protected override void OnPaint(PaintEventArgs e) // Draw the up and down buttons if (Application.RenderWithVisualStyles) { - var vsr = new VisualStyleRenderer(_mouseOver == ButtonID.Up + VisualStyleRenderer vsr = new(_mouseOver == ButtonID.Up ? VisualStyleElement.Spin.Up.Hot : VisualStyleElement.Spin.Up.Normal); @@ -271,7 +270,7 @@ protected override void OnPaint(PaintEventArgs e) vsr.SetParameters(VisualStyleElement.Spin.Up.Pressed); } - using var hdc = new DeviceContextHdcScope(e); + using DeviceContextHdcScope hdc = new(e); vsr.DrawBackground( hdc, new Rectangle(0, 0, _parent._defaultButtonsWidth, half_height), diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownEdit.UpDownEditAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownEdit.UpDownEditAccessibleObject.cs index b227622b814..d0f8c530c28 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownEdit.UpDownEditAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownEdit.UpDownEditAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownEdit.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownEdit.cs index 0c802aaab90..e497e297d73 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownEdit.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownEdit.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.cs index fa68b0f93ff..e66f9641665 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -242,7 +241,7 @@ protected override CreateParams CreateParams /// Deriving classes can override this to configure a default size for their control. /// This is more efficient than setting the size in the control's constructor. /// - protected override Size DefaultSize => new Size(DefaultControlWidth, PreferredHeight); + protected override Size DefaultSize => new(DefaultControlWidth, PreferredHeight); [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] @@ -536,7 +535,7 @@ protected override void OnPaint(PaintEventArgs e) clipRight.Intersect(clipBounds); clipBottom.Intersect(clipBounds); - using var hdc = new DeviceContextHdcScope(e); + using DeviceContextHdcScope hdc = new(e); vsr.DrawBackground(hdc, bounds, clipLeft, HWNDInternal); vsr.DrawBackground(hdc, bounds, clipTop, HWNDInternal); vsr.DrawBackground(hdc, bounds, clipRight, HWNDInternal); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownEventArgs.cs index b6c4af993d6..515a9501376 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownEventHandler.cs index 2bc252f38a9..05ed799d273 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UserControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UserControl.cs index dda7c403803..e067911deee 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UserControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UserControl.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; @@ -20,7 +19,7 @@ namespace System.Windows.Forms; [DefaultEvent(nameof(Load))] public class UserControl : ContainerControl { - private static readonly object EVENT_LOAD = new object(); + private static readonly object EVENT_LOAD = new(); private BorderStyle _borderStyle = BorderStyle.None; /// diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VScrollBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VScrollBar.cs index 5545470d19c..b5f38eeddb7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VScrollBar.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VScrollBar.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VScrollProperties.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VScrollProperties.cs index 4201d56d39b..42433495fdb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VScrollProperties.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VScrollProperties.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ValidationConstraints.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ValidationConstraints.cs index b06dbc18856..19b03f7c8c0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ValidationConstraints.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ValidationConstraints.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/View.cs b/src/System.Windows.Forms/src/System/Windows/Forms/View.cs index 6db5041dffc..c0e0653d175 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/View.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/View.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/BackgroundType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/BackgroundType.cs index b4691ed4284..436804bde04 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/BackgroundType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/BackgroundType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/BooleanProperty.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/BooleanProperty.cs index f44ad63de6d..5455d671327 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/BooleanProperty.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/BooleanProperty.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/BorderType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/BorderType.cs index 14eb04405c7..fcb3f62470e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/BorderType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/BorderType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/CheckBoxState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/CheckBoxState.cs index 2074fb7a61d..994a23edd97 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/CheckBoxState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/CheckBoxState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ColorProperty.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ColorProperty.cs index 667f0732865..e494d9449e7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ColorProperty.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ColorProperty.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ComboBoxState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ComboBoxState.cs index d9e5beb500b..2b6c43a1820 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ComboBoxState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ComboBoxState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ContentAlignment.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ContentAlignment.cs index 896a9e0a106..d47195866bc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ContentAlignment.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ContentAlignment.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/EdgeEffects.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/EdgeEffects.cs index c8522e3b472..e4c74e92461 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/EdgeEffects.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/EdgeEffects.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/EdgeStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/EdgeStyle.cs index c556da6925e..92095f74b77 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/EdgeStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/EdgeStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/Edges.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/Edges.cs index c31d2cad468..260895ee289 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/Edges.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/Edges.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/EnumProperty.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/EnumProperty.cs index b62028e57db..b946122bcb1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/EnumProperty.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/EnumProperty.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/FilenameProperty.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/FilenameProperty.cs index 379a19466c9..1f811446e63 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/FilenameProperty.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/FilenameProperty.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/FillType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/FillType.cs index 411b11b06c6..60549411dfc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/FillType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/FillType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/FontProperty.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/FontProperty.cs index 2a7755bb6b8..215e1a5319b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/FontProperty.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/FontProperty.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/GlyphFontSizingType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/GlyphFontSizingType.cs index 0b36442dff9..23e3435c8fe 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/GlyphFontSizingType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/GlyphFontSizingType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/GlyphType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/GlyphType.cs index 4e9ec2bc9ca..db3bedde3bf 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/GlyphType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/GlyphType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/GroupBoxState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/GroupBoxState.cs index 9e3a80d9e83..e7985530f24 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/GroupBoxState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/GroupBoxState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HeaderItemState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HeaderItemState.cs index db96ed83ae7..7c1e5114530 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HeaderItemState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HeaderItemState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HitTestCode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HitTestCode.cs index 92da0fb3618..6ccb0a34e9a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HitTestCode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HitTestCode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HitTestOptions.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HitTestOptions.cs index 1932aad5db4..da82dca8f8a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HitTestOptions.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HitTestOptions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HorizontalAlign.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HorizontalAlign.cs index edfa40c835c..c7eb1b8ea65 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HorizontalAlign.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/HorizontalAlign.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/IconEffect.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/IconEffect.cs index 3ff0df3ddbf..5f5638a27f7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/IconEffect.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/IconEffect.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ImageOrientation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ImageOrientation.cs index 809b3989550..3b5abc46312 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ImageOrientation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ImageOrientation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ImageSelectType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ImageSelectType.cs index e334f4b11b1..d992cff262d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ImageSelectType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ImageSelectType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/IntegerProperty.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/IntegerProperty.cs index e1462d76830..18b0667dd76 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/IntegerProperty.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/IntegerProperty.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/MarginProperty.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/MarginProperty.cs index 31b8ddce6a5..5712aa5780c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/MarginProperty.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/MarginProperty.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/OffsetType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/OffsetType.cs index 64830a5409d..88dd3e94ed1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/OffsetType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/OffsetType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/PointProperty.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/PointProperty.cs index f0b882739ff..5088924996e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/PointProperty.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/PointProperty.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/PushButtonState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/PushButtonState.cs index 53e948d1d01..0c8323cf0f5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/PushButtonState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/PushButtonState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/RadioButtonState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/RadioButtonState.cs index 9c36872d43a..ed5c4d6ffc6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/RadioButtonState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/RadioButtonState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ScrollBarArrowButtonState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ScrollBarArrowButtonState.cs index 28e624c4ab7..9b2d8ee78bd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ScrollBarArrowButtonState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ScrollBarArrowButtonState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ScrollBarSizeBoxState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ScrollBarSizeBoxState.cs index 4a5e3f94869..0ebe7b28725 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ScrollBarSizeBoxState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ScrollBarSizeBoxState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ScrollBarState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ScrollBarState.cs index 82ba402e225..fbf9d3158de 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ScrollBarState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ScrollBarState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/SizingType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/SizingType.cs index a995b64c529..06ee22051cd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/SizingType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/SizingType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/StringProperty.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/StringProperty.cs index 09f12a70da7..df4d8bfed8c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/StringProperty.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/StringProperty.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TabItemState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TabItemState.cs index 9b9a001c716..ca4da17feed 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TabItemState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TabItemState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TextBoxState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TextBoxState.cs index 643834457af..f2193f29e54 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TextBoxState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TextBoxState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TextShadowType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TextShadowType.cs index 1067f4dce21..93c8d59c23c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TextShadowType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TextShadowType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ToolBarState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ToolBarState.cs index a53c74788b9..043b02b3ae0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ToolBarState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/ToolBarState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TrackBarThumbState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TrackBarThumbState.cs index 4b74b7073b5..ad00799ef56 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TrackBarThumbState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TrackBarThumbState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TrueSizeScalingType.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TrueSizeScalingType.cs index c237f7bfc72..4da3abb2709 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TrueSizeScalingType.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/TrueSizeScalingType.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VerticalAlignment.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VerticalAlignment.cs index b29d6d14083..15d0e0c6a96 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VerticalAlignment.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VerticalAlignment.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleElement.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleElement.cs index 9c8bc54aed6..a355448bda7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleElement.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleElement.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleInformation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleInformation.cs index bb6fae13897..47e5a4353d8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleInformation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleInformation.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleRenderer.cs index 18489e0b6b1..1901b50e1b9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleRenderer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Drawing.Interop; @@ -104,7 +103,7 @@ internal static bool IsCombinationDefined(string className, int part) // If the combo isn't defined, check the validity of our theme handle cache. if (!result) { - using var handle = new PInvoke.OpenThemeDataScope(HWND.Null, className); + using PInvoke.OpenThemeDataScope handle = new(HWND.Null, className); if (!handle.IsNull) { @@ -213,7 +212,7 @@ public void DrawBackground(IDeviceContext dc, Rectangle bounds) { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); DrawBackground(hdc, bounds, HWND.Null); } @@ -242,7 +241,7 @@ public void DrawBackground(IDeviceContext dc, Rectangle bounds, Rectangle clipRe { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); DrawBackground(hdc, bounds, clipRectangle, HWND.Null); } @@ -269,7 +268,7 @@ public Rectangle DrawEdge(IDeviceContext dc, Rectangle bounds, Edges edges, Edge { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); return DrawEdge(hdc, bounds, edges, style, effects); } @@ -345,7 +344,7 @@ public void DrawParentBackground(IDeviceContext dc, Rectangle bounds, Control ch if (childControl.IsHandleCreated) { - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.DrawThemeParentBackground(childControl.HWND, hdc, bounds); } } @@ -373,7 +372,7 @@ public void DrawText(IDeviceContext dc, Rectangle bounds, string? textToDraw, bo { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); DrawText(hdc, bounds, textToDraw, drawDisabled, flags); } @@ -407,7 +406,7 @@ public Rectangle GetBackgroundContentRectangle(IDeviceContext dc, Rectangle boun { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); return GetBackgroundContentRectangle(hdc, bounds); } @@ -434,7 +433,7 @@ public Rectangle GetBackgroundExtent(IDeviceContext dc, Rectangle contentBounds) return Rectangle.Empty; } - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.GetThemeBackgroundExtent(HTHEME, hdc, Part, State, contentBounds, out RECT extents); return extents; } @@ -573,7 +572,7 @@ public Size GetPartSize(IDeviceContext dc, ThemeSizeType type) { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); return GetPartSize(hdc, type, HWND.Null); } @@ -603,7 +602,7 @@ public unsafe Size GetPartSize(IDeviceContext dc, Rectangle bounds, ThemeSizeTyp // Valid values are 0x0 to 0x2 SourceGenerated.EnumValidator.Validate(type, nameof(type)); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.GetThemePartSize(HTHEME, hdc, Part, State, bounds, (THEMESIZE)type, out SIZE size); return size; } @@ -630,7 +629,7 @@ public unsafe Padding GetMargins(IDeviceContext dc, MarginProperty prop) // Valid values are 0xe11 to 0xe13 SourceGenerated.EnumValidator.Validate(prop, nameof(prop)); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.GetThemeMargins(HTHEME, hdc, Part, State, (THEME_PROPERTY_SYMBOL_ID)prop, null, out MARGINS margins); return new Padding(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight); @@ -661,7 +660,7 @@ public unsafe Rectangle GetTextExtent(IDeviceContext dc, string textToDraw, Text ArgumentNullException.ThrowIfNull(dc); textToDraw.ThrowIfNullOrEmpty(); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.GetThemeTextExtent( HTHEME, hdc, @@ -684,7 +683,7 @@ public unsafe Rectangle GetTextExtent(IDeviceContext dc, Rectangle bounds, strin ArgumentNullException.ThrowIfNull(dc); textToDraw.ThrowIfNullOrEmpty(); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.GetThemeTextExtent( HTHEME, hdc, @@ -706,7 +705,7 @@ public TextMetrics GetTextMetrics(IDeviceContext dc) { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.GetThemeTextMetrics(HTHEME, hdc, Part, State, out TEXTMETRICW tm); return TextMetrics.FromTEXTMETRICW(tm); } @@ -718,7 +717,7 @@ public HitTestCode HitTestBackground(IDeviceContext dc, Rectangle backgroundRect { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.HitTestThemeBackground( HTHEME, hdc, @@ -752,7 +751,7 @@ public HitTestCode HitTestBackground(IDeviceContext dc, Rectangle backgroundRect { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.HitTestThemeBackground( HTHEME, hdc, @@ -865,7 +864,7 @@ private static HTHEME GetHandle(string className, bool throwExceptionOnFail) private static PInvoke.OpenThemeDataScope OpenThemeData(HWND hwnd, string classList) { - var htheme = new PInvoke.OpenThemeDataScope(hwnd, classList); + PInvoke.OpenThemeDataScope htheme = new(hwnd, classList); return htheme.IsNull ? throw new InvalidOperationException(SR.VisualStyleHandleCreationFailed) : htheme; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleState.cs index 413d587de82..7b9333c7db8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.VisualStyles; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.WebBrowserAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.WebBrowserAccessibleObject.cs index 631367a649a..b3a0be821bc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.WebBrowserAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.WebBrowserAccessibleObject.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using static Interop; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.WebBrowserEvent.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.WebBrowserEvent.cs index e38bac04d54..df667609bd2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.WebBrowserEvent.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.WebBrowserEvent.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.InteropServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.WebBrowserSite.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.WebBrowserSite.cs index a0bf5a9b047..1215d6b8a44 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.WebBrowserSite.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.WebBrowserSite.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using Windows.Win32.System.Ole; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.cs index 4767f4776c5..3784fe5fb71 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; @@ -301,7 +300,7 @@ public string DocumentText return string.Empty; } - using var reader = new StreamReader(stream); + using StreamReader reader = new(stream); stream.Position = 0; return reader.ReadToEnd().TrimEnd('\0'); } @@ -1067,7 +1066,7 @@ protected override void Dispose(bool disposing) /// /// Overrides the default size property of Control to specify a bigger default size of 250 x 250. /// - protected override Size DefaultSize => new Size(250, 250); + protected override Size DefaultSize => new(250, 250); /// /// Retrieves IWebBrowser2 from the native object. Overriding classes should first call base.AttachInterfaces. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserBase.WebBrowserBaseNativeWindow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserBase.WebBrowserBaseNativeWindow.cs index 4b7c314d15c..aa9978ba37d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserBase.WebBrowserBaseNativeWindow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserBase.WebBrowserBaseNativeWindow.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserBase.cs index b3058ec05d1..eb98b9e2f7f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserBase.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -866,7 +865,7 @@ private void TransitionFromPassiveToLoaded() hr.ThrowOnFailure(); - _activeXInstance = Marshal.GetObjectForIUnknown((nint)unknown); + _activeXInstance = ComHelpers.GetObjectForIUnknown((IUnknown*)unknown); Debug.Assert(_activeXInstance is not null, "w/o an exception being thrown we must have an object..."); @@ -1104,7 +1103,7 @@ private void OnNewSelection(object? sender, EventArgs e) private unsafe Size SetExtent(int width, int height) { - var sz = new Size(width, height); + Size sz = new(width, height); bool resetExtents = DesignMode; Pixel2hiMetric(ref sz); HRESULT hr = _axOleObject!.SetExtent(DVASPECT.DVASPECT_CONTENT, (SIZE*)&sz); @@ -1219,7 +1218,7 @@ private void AmbientChanged(int dispid) // Overridden properties: // - protected override Size DefaultSize => new Size(75, 23); + protected override Size DefaultSize => new(75, 23); // // Overridden methods: diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserContainer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserContainer.cs index a943631a995..735d5f21899 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserContainer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserContainer.cs @@ -1,10 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.ComponentModel.Design; -using System.Runtime.InteropServices; using Windows.Win32.System.Com; using Windows.Win32.System.Ole; @@ -111,7 +109,7 @@ HRESULT IOleInPlaceFrame.Interface.SetActiveObject(IOleInPlaceActiveObject* pAct IOleClientSite* clientSite; oleObject.Value->GetClientSite(&clientSite); - var clientSiteObject = Marshal.GetObjectForIUnknown((nint)clientSite); + object clientSiteObject = ComHelpers.GetObjectForIUnknown((IUnknown*)clientSite); if (clientSiteObject is WebBrowserSiteBase webBrowserSiteBase) { control = webBrowserSiteBase.Host; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserDocumentCompletedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserDocumentCompletedEventArgs.cs index a7ece99158e..16710e8317a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserDocumentCompletedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserDocumentCompletedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserDocumentCompletedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserDocumentCompletedEventHandler.cs index caa38880bd3..d7f63e63cf6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserDocumentCompletedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserDocumentCompletedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserEncryptionLevel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserEncryptionLevel.cs index 63a95a1703c..c0373fdb2e2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserEncryptionLevel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserEncryptionLevel.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.AXEditMode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.AXEditMode.cs index e028daa9d6b..332bc20e34d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.AXEditMode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.AXEditMode.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.AXState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.AXState.cs index 7fdfbcf4474..2f9bec49c9a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.AXState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.AXState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.SelectionStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.SelectionStyle.cs index b83c6dcbe2f..427b71b370d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.SelectionStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.SelectionStyle.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.cs index bd0ccf38007..1cb05e1bddb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections.Specialized; using System.ComponentModel; @@ -37,9 +36,9 @@ internal static partial class WebBrowserHelper private const int HMperInch = 2540; // Special guids - internal static Guid windowsMediaPlayer_Clsid = new Guid("{22d6f312-b0f6-11d0-94ab-0080c74c7e95}"); - internal static Guid comctlImageCombo_Clsid = new Guid("{a98a24c0-b06f-3684-8c12-c52ae341e0bc}"); - internal static Guid maskEdit_Clsid = new Guid("{c932ba85-4374-101b-a56c-00aa003668dc}"); + internal static Guid windowsMediaPlayer_Clsid = new("{22d6f312-b0f6-11d0-94ab-0080c74c7e95}"); + internal static Guid comctlImageCombo_Clsid = new("{a98a24c0-b06f-3684-8c12-c52ae341e0bc}"); + internal static Guid maskEdit_Clsid = new("{c932ba85-4374-101b-a56c-00aa003668dc}"); // Window message to check if we have already sub-classed internal static readonly MessageId REGMSG_MSG = PInvoke.RegisterWindowMessage($"{Application.WindowMessagesVersion}_subclassCheck"); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatedEventArgs.cs index d04ade3730d..283586a60b1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatedEventHandler.cs index 9445d2db179..36b0f99339f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatingEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatingEventArgs.cs index c1faf6cebed..70680b258e4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatingEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatingEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatingEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatingEventHandler.cs index cbd17f4b841..98a242f28e2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatingEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserNavigatingEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserProgressChangedEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserProgressChangedEventArgs.cs index 77b1923e58f..ab0940a5f07 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserProgressChangedEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserProgressChangedEventArgs.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserProgressChangedEventHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserProgressChangedEventHandler.cs index e0049368145..2c674b5cc96 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserProgressChangedEventHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserProgressChangedEventHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserReadyState.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserReadyState.cs index 16bc3c84039..99162de50e3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserReadyState.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserReadyState.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using Windows.Win32.System.Ole; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserRefreshOption.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserRefreshOption.cs index 7b17ef9f8ac..51cab542a05 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserRefreshOption.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserRefreshOption.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserSiteBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserSiteBase.cs index 1a2196c168e..8a68e12caaa 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserSiteBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserSiteBase.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel.Design; using System.Drawing; @@ -409,8 +408,8 @@ private unsafe HRESULT OnActiveXRectChange(RECT* lprcPosRect) return HRESULT.E_INVALIDARG; } - var posRect = new RECT(0, 0, lprcPosRect->right - lprcPosRect->left, lprcPosRect->bottom - lprcPosRect->top); - var clipRect = WebBrowserHelper.GetClipRect(); + RECT posRect = new(0, 0, lprcPosRect->right - lprcPosRect->left, lprcPosRect->bottom - lprcPosRect->top); + RECT clipRect = WebBrowserHelper.GetClipRect(); Host.AXInPlaceObject!.SetObjectRects(&posRect, &clipRect); Host.MakeDirty(); return HRESULT.S_OK; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserUriTypeConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserUriTypeConverter.cs index edbd9f9a70d..66662a9122f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserUriTypeConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserUriTypeConverter.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Win32WindowExtensions.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Win32WindowExtensions.cs index deb6d0115c3..918c680edc0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Win32WindowExtensions.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Win32WindowExtensions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WinCategoryAttribute.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WinCategoryAttribute.cs index 6a4dcbebfea..a7aa1f132dd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WinCategoryAttribute.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WinCategoryAttribute.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WinFormsUtils.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WinFormsUtils.cs index acf37df3869..a7f07670528 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WinFormsUtils.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WinFormsUtils.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Drawing; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WindowSubclassHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WindowSubclassHandler.cs index cb52eb4bfa6..6f34e6cb225 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WindowSubclassHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WindowSubclassHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; using System.Runtime.ExceptionServices; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WindowsFormsSectionHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WindowsFormsSectionHandler.cs index 6f24b9ae3cf..5319012648f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WindowsFormsSectionHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WindowsFormsSectionHandler.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WindowsFormsSynchronizationContext.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WindowsFormsSynchronizationContext.cs index 43108fa4827..a4ef0520971 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WindowsFormsSynchronizationContext.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WindowsFormsSynchronizationContext.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/misc/CollectionHelper.cs b/src/System.Windows.Forms/src/misc/CollectionHelper.cs index f7308f21435..1bb67be7c61 100644 --- a/src/System.Windows.Forms/src/misc/CollectionHelper.cs +++ b/src/System.Windows.Forms/src/misc/CollectionHelper.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Collections.Generic; diff --git a/src/System.Windows.Forms/src/misc/CompatibleIComparer.cs b/src/System.Windows.Forms/src/misc/CompatibleIComparer.cs index f7217cc8fb2..5dec14035fe 100644 --- a/src/System.Windows.Forms/src/misc/CompatibleIComparer.cs +++ b/src/System.Windows.Forms/src/misc/CompatibleIComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Collections.Specialized; diff --git a/src/System.Windows.Forms/src/misc/CoreSwitches.cs b/src/System.Windows.Forms/src/misc/CoreSwitches.cs index 9d86cbe2f89..6563b9d9547 100644 --- a/src/System.Windows.Forms/src/misc/CoreSwitches.cs +++ b/src/System.Windows.Forms/src/misc/CoreSwitches.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.ComponentModel; diff --git a/src/System.Windows.Forms/src/misc/GDI/TextPaddingOptions.cs b/src/System.Windows.Forms/src/misc/GDI/TextPaddingOptions.cs index 43add3be175..85e6b17a55e 100644 --- a/src/System.Windows.Forms/src/misc/GDI/TextPaddingOptions.cs +++ b/src/System.Windows.Forms/src/misc/GDI/TextPaddingOptions.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Windows.Forms.Internal; diff --git a/src/System.Windows.Forms/src/misc/ImageListUtils.cs b/src/System.Windows.Forms/src/misc/ImageListUtils.cs index 4e28b28ad88..f21f9e589fc 100644 --- a/src/System.Windows.Forms/src/misc/ImageListUtils.cs +++ b/src/System.Windows.Forms/src/misc/ImageListUtils.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.ComponentModel; diff --git a/src/System.Windows.Forms/src/misc/InvariantComparer.cs b/src/System.Windows.Forms/src/misc/InvariantComparer.cs index a0b4c08d8bd..8108c65649c 100644 --- a/src/System.Windows.Forms/src/misc/InvariantComparer.cs +++ b/src/System.Windows.Forms/src/misc/InvariantComparer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; using System.Globalization; @@ -10,7 +9,7 @@ namespace System; internal class InvariantComparer : IComparer { private readonly CompareInfo m_compareInfo; - internal static readonly InvariantComparer Default = new InvariantComparer(); + internal static readonly InvariantComparer Default = new(); internal InvariantComparer() { diff --git a/src/System.Windows.Forms/src/misc/MultitargetUtil.cs b/src/System.Windows.Forms/src/misc/MultitargetUtil.cs index 441cbd439a0..510b9178bd9 100644 --- a/src/System.Windows.Forms/src/misc/MultitargetUtil.cs +++ b/src/System.Windows.Forms/src/misc/MultitargetUtil.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace System.Resources; diff --git a/src/System.Windows.Forms/src/misc/WeakHashtable.cs b/src/System.Windows.Forms/src/misc/WeakHashtable.cs index 75485ff7bc3..b895b03fe37 100644 --- a/src/System.Windows.Forms/src/misc/WeakHashtable.cs +++ b/src/System.Windows.Forms/src/misc/WeakHashtable.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Collections; diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/CommonControl1.cs b/src/System.Windows.Forms/tests/AccessibilityTests/CommonControl1.cs index 2761ab0fa02..e3a4138981d 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/CommonControl1.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/CommonControl1.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/CommonControl2.cs b/src/System.Windows.Forms/tests/AccessibilityTests/CommonControl2.cs index 8d02faabb26..c8a0cdd8eda 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/CommonControl2.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/CommonControl2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/ContainerControls.cs b/src/System.Windows.Forms/tests/AccessibilityTests/ContainerControls.cs index 3d1a9b74e44..66b8c7f6ef6 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/ContainerControls.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/ContainerControls.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/ContainerControls2.cs b/src/System.Windows.Forms/tests/AccessibilityTests/ContainerControls2.cs index 1555f1998e4..500d5f99976 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/ContainerControls2.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/ContainerControls2.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/CustomAccessiblePropertiesForm.cs b/src/System.Windows.Forms/tests/AccessibilityTests/CustomAccessiblePropertiesForm.cs index cf9cc525b4a..d70cdcc799b 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/CustomAccessiblePropertiesForm.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/CustomAccessiblePropertiesForm.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/DataBindingExample.cs b/src/System.Windows.Forms/tests/AccessibilityTests/DataBindingExample.cs index 8cd5ad3bc20..9eb2dd5a1fb 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/DataBindingExample.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/DataBindingExample.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Data; using System.Windows.Forms; @@ -9,8 +8,8 @@ namespace Accessibility_Core_App; public partial class DataBindingExample : Form { - private readonly List _studentA = new List(); - private readonly List _studentB = new List(); + private readonly List _studentA = new(); + private readonly List _studentB = new(); public DataBindingExample() { diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/DataControls.cs b/src/System.Windows.Forms/tests/AccessibilityTests/DataControls.cs index f16853ffc55..aec77759dc4 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/DataControls.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/DataControls.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Data; using System.Windows.Forms; diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/DialogControls.cs b/src/System.Windows.Forms/tests/AccessibilityTests/DialogControls.cs index ff3085af94e..7c46a47388c 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/DialogControls.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/DialogControls.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/Main.cs b/src/System.Windows.Forms/tests/AccessibilityTests/Main.cs index 84aaa7a6b57..6655cf4f2e1 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/Main.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/Main.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/MenuForm.cs b/src/System.Windows.Forms/tests/AccessibilityTests/MenuForm.cs index 9ccf28bff74..5b1b8b801df 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/MenuForm.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/MenuForm.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/Menu_Toolbars_controls.cs b/src/System.Windows.Forms/tests/AccessibilityTests/Menu_Toolbars_controls.cs index 5d14244f431..51543c0cfb0 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/Menu_Toolbars_controls.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/Menu_Toolbars_controls.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/PrintingControls.cs b/src/System.Windows.Forms/tests/AccessibilityTests/PrintingControls.cs index 83ebd1b0425..399a6f38002 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/PrintingControls.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/PrintingControls.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Drawing; using System.Windows.Forms; diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/RemainingControls.cs b/src/System.Windows.Forms/tests/AccessibilityTests/RemainingControls.cs index 732f203589e..e0b0c6b48ff 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/RemainingControls.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/RemainingControls.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/Student.cs b/src/System.Windows.Forms/tests/AccessibilityTests/Student.cs index 5867a720efb..1379e7ab848 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/Student.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/Student.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace Accessibility_Core_App; diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/TaskDialogTesting.cs b/src/System.Windows.Forms/tests/AccessibilityTests/TaskDialogTesting.cs index 501dc5c90d8..3e3773acaa3 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/TaskDialogTesting.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/TaskDialogTesting.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/ToolStripContainer.cs b/src/System.Windows.Forms/tests/AccessibilityTests/ToolStripContainer.cs index f94f4eb0eeb..f43e91ff7ad 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/ToolStripContainer.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/ToolStripContainer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.Windows.Forms; diff --git a/src/System.Windows.Forms/tests/AxHosts/AxHosts.Designer.cs b/src/System.Windows.Forms/tests/AxHosts/AxHosts.Designer.cs index 36b4a0d3926..f3937a76949 100644 --- a/src/System.Windows.Forms/tests/AxHosts/AxHosts.Designer.cs +++ b/src/System.Windows.Forms/tests/AxHosts/AxHosts.Designer.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace AxHosts; diff --git a/src/System.Windows.Forms/tests/AxHosts/AxHosts.cs b/src/System.Windows.Forms/tests/AxHosts/AxHosts.cs index 535af1d5980..fa2d3595374 100644 --- a/src/System.Windows.Forms/tests/AxHosts/AxHosts.cs +++ b/src/System.Windows.Forms/tests/AxHosts/AxHosts.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. using System.IO; diff --git a/src/System.Windows.Forms/tests/AxHosts/GlobalUsings.cs b/src/System.Windows.Forms/tests/AxHosts/GlobalUsings.cs index a090acf9c16..a9d638d7a43 100644 --- a/src/System.Windows.Forms/tests/AxHosts/GlobalUsings.cs +++ b/src/System.Windows.Forms/tests/AxHosts/GlobalUsings.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. global using System; global using System.Windows.Forms; diff --git a/src/System.Windows.Forms/tests/AxHosts/Program.cs b/src/System.Windows.Forms/tests/AxHosts/Program.cs index b75dff0d047..339c1ee1474 100644 --- a/src/System.Windows.Forms/tests/AxHosts/Program.cs +++ b/src/System.Windows.Forms/tests/AxHosts/Program.cs @@ -1,6 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. namespace AxHosts; diff --git a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.Designer.cs b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.Designer.cs index c9a92ea3c9a..fa20d617056 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.Designer.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.Designer.cs @@ -1,4 +1,4 @@ -namespace TestConsole; +namespace TestConsole; partial class MainForm { /// @@ -31,6 +31,7 @@ private void InitializeComponent() { this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage3 = new System.Windows.Forms.TabPage(); this.tabPage4 = new System.Windows.Forms.TabPage(); + this.tabPage5 = new System.Windows.Forms.TabPage(); this.propertyGrid = new System.Windows.Forms.PropertyGrid(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -79,6 +80,7 @@ private void InitializeComponent() { this.tabControl1.Controls.Add( this.tabPage2 ); this.tabControl1.Controls.Add( this.tabPage3 ); this.tabControl1.Controls.Add( this.tabPage4 ); + this.tabControl1.Controls.Add( this.tabPage5 ); this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl1.Location = new System.Drawing.Point( 0, 0 ); this.tabControl1.Name = "tabControl1"; @@ -126,6 +128,16 @@ private void InitializeComponent() { this.tabPage4.Text = "tabPage4"; this.tabPage4.UseVisualStyleBackColor = true; // + // tabPage5 + // + this.tabPage5.Location = new System.Drawing.Point(4, 25); + this.tabPage5.Name = "tabPage5"; + this.tabPage5.Padding = new System.Windows.Forms.Padding(3); + this.tabPage5.Size = new System.Drawing.Size(585, 473); + this.tabPage5.TabIndex = 3; + this.tabPage5.Text = "tabPage5"; + this.tabPage5.UseVisualStyleBackColor = true; + // // propertyGrid // this.propertyGrid.Dock = System.Windows.Forms.DockStyle.Fill; @@ -302,6 +314,7 @@ private void InitializeComponent() { private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.TabPage tabPage3; private System.Windows.Forms.TabPage tabPage4; +private System.Windows.Forms.TabPage tabPage5; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemTools; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemTabOrder; diff --git a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs index 270fdc74444..0f3ee6cad43 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs @@ -11,7 +11,7 @@ public partial class MainForm : Form { ISelectionService _selectionService; - private List _listOfDesignSurface = new List(); + private List _listOfDesignSurface = new(); public MainForm() { @@ -24,11 +24,13 @@ private void InitFormDesigner() CreateDesignSurface(2); CreateDesignSurface(3); CreateDesignSurface(4); + CreateDesignSurface(5); tabPage1.Text = "Use SnapLines"; tabPage2.Text = "Use Grid (Snap to the grid)"; tabPage3.Text = "Use Grid"; tabPage4.Text = "Align control by hand"; + tabPage5.Text = "TabControl and TableLayoutPanel"; //- enable the UndoEngines for (int i = 0; i < tabControl1.TabCount; i++) @@ -90,6 +92,9 @@ private void CreateDesignSurface(int n) case 4: surface.UseNoGuides(); break; + case 5: + surface.UseNoGuides(); + break; default: Console.WriteLine("Invalid selection"); break; @@ -161,21 +166,23 @@ private void CreateDesignSurface(int n) //- create some Controls at DesignTime TextBox t1 = surface.CreateControl(new Size(200, 20), new Point(10, 10)); Button b1 = surface.CreateControl