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 575a64a0fbb..6f6477cc7cc 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 @@ -23,27 +23,27 @@ internal static partial class UiaCore public interface IRawElementProviderFragment : IRawElementProviderSimple { /// - /// Request to return the element in the specified direction + /// Returns the element in the specified . /// - /// Indicates the direction in which to navigate - /// Returns the element in the specified direction + /// Indicates the direction in which to navigate. + /// The element in the specified direction, if it exists. [return: MarshalAs(UnmanagedType.IUnknown)] object? /*IRawElementProviderFragment*/ Navigate(NavigateDirection direction); /// - /// Gets the runtime ID of an element. This should be unique - /// among elements on a desktop. + /// Gets the runtime ID of an element. This should be unique among elements on a desktop. /// /// - /// Proxy implementations should return null for the top-level proxy which - /// corresponds to the HWND; and should return an array which starts - /// with AutomationInteropProvider.AppendRuntimeId, followed by values - /// which are then unique within that proxy's HWNDs. + /// + /// Proxy implementations should return null for the top-level proxy which corresponds to the HWND; + /// and should return an array which starts with AutomationInteropProvider.AppendRuntimeId", followed by + /// values which are then unique within that proxy's HWNDs. + /// /// int[]? GetRuntimeId(); /// - /// Return a bounding rectangle of this element + /// Return a bounding rectangle of this element. /// UiaRect BoundingRectangle { get; } @@ -59,10 +59,12 @@ public interface IRawElementProviderFragment : IRawElementProviderSimple /// /// Request that focus is set to this item. + /// + /// /// The UIAutomation framework will ensure that the UI hosting this fragment is already /// focused before calling this method, so this method should only update its internal /// focus state; it should not attempt to give its own HWND the focus, for example. - /// + /// void SetFocus(); /// 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 3197dc8820d..3f826d687ee 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 @@ -36,10 +36,10 @@ public interface IRawElementProviderSimple object? GetPatternProvider(UIA patternId); /// - /// Request value of specified property from an element. + /// Returns the value of the specified from the element. /// /// Identifier indicating the property to return - /// Returns a ValInfo indicating whether the element supports this property, or has no value for it. + /// Returns the requested value if supported or null if it is not. object? GetPropertyValue(UIA propertyId); // Only native impl roots need to return something for this, diff --git a/src/System.Windows.Forms/src/Resources/SR.resx b/src/System.Windows.Forms/src/Resources/SR.resx index 9b77e2c1ccc..121fd6f60f9 100644 --- a/src/System.Windows.Forms/src/Resources/SR.resx +++ b/src/System.Windows.Forms/src/Resources/SR.resx @@ -1,5 +1,64 @@  + @@ -53,10 +112,10 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=42.42.42.42, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=42.42.42.42, Culture=neutral, PublicKeyToken=b77a5c561934e089 Displays the 'About' box for this component @@ -4361,7 +4420,7 @@ Stack trace where the illegal operation occurred was: Indicates whether the panel should have a border. - + Description @@ -4802,7 +4861,7 @@ Stack trace where the illegal operation occurred was: {0} Properties Window - + {0} Description @@ -6779,4 +6838,4 @@ Stack trace where the illegal operation occurred was: Border color to use on the top edge of the StatusStrip. - + \ No newline at end of file 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 50bb395e54a..6e7d085af02 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf @@ -7346,11 +7346,6 @@ Trasování zásobníku, kde došlo k neplatné operaci: Formulář {0} se pokusil nastavit jako svého vlastníka nevhodný formulář. Formuláře nemohou vlastnit samy sebe ani své vlastníky. - - Description - Popis - - Property value is not valid. Hodnota vlastnosti není platná. @@ -8176,11 +8171,6 @@ Trasování zásobníku, kde došlo k neplatné operaci: Barva popředí neaktivního textu v oblasti mřížky - - {0} Description - Popis pro {0} - - Browse... Procházet... @@ -8221,6 +8211,16 @@ Trasování zásobníku, kde došlo k neplatné operaci: Barva popředí podokna popisu. + + {0} Description + {0} Description + + + + Description + Description + + Sets whether to show the description pane. Určuje, zda bude zobrazeno podokno popisu. 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 84f53e18a93..9e3f42dc278 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf @@ -7346,11 +7346,6 @@ Stapelüberwachung, in der der unzulässige Vorgang auftrat: Das Formular {0} hat versucht, ein ungültiges Formular als Besitzer festzulegen. Formulare können nicht sich selbst oder ihre Besitzer besitzen. - - Description - Beschreibung - - Property value is not valid. Ungültiger Eigenschaftswert. @@ -8176,11 +8171,6 @@ Stapelüberwachung, in der der unzulässige Vorgang auftrat: Die Vordergrundfarbe für gesperrten Text im Rasterbereich. - - {0} Description - {0}-Beschreibung - - Browse... Durchsuchen... @@ -8221,6 +8211,16 @@ Stapelüberwachung, in der der unzulässige Vorgang auftrat: Die Vordergrundfarbe des Beschreibungsbereichs. + + {0} Description + {0} Description + + + + Description + Description + + Sets whether to show the description pane. Legt fest, ob der Beschreibungsbereich angezeigt wird. 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 ff335011d93..c1b25bce79c 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf @@ -7346,11 +7346,6 @@ El seguimiento de la pila donde tuvo lugar la operación no válida fue: El formulario {0} intentó establecer como propietario un formulario no válido. Los formularios no pueden poseer a sus propietarios ni a sí mismos. - - Description - Descripción - - Property value is not valid. El valor de la propiedad no es válido. @@ -8176,11 +8171,6 @@ El seguimiento de la pila donde tuvo lugar la operación no válida fue: Color de primer plano del texto deshabilitado en el área de la cuadrícula. - - {0} Description - Descripción de {0} - - Browse... Examinar... @@ -8221,6 +8211,16 @@ El seguimiento de la pila donde tuvo lugar la operación no válida fue: Color de primer plano del panel de descripciones. + + {0} Description + {0} Description + + + + Description + Description + + Sets whether to show the description pane. Establece si se va a mostrar o no el panel de descripciones. 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 1a745c8595b..65143841277 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf @@ -7346,11 +7346,6 @@ Cette opération non conforme s'est produite sur la trace de la pile : Le formulaire {0} a essayé de définir un formulaire inéligible comme son propriétaire. Les formulaires ne peuvent pas s'appartenir ou appartenir à leurs propriétaires. - - Description - Description - - Property value is not valid. Valeur de propriété non valide. @@ -8176,11 +8171,6 @@ Cette opération non conforme s'est produite sur la trace de la pile : Couleur de premier plan du texte désactivé de la grille. - - {0} Description - Description de {0} - - Browse... Parcourir... @@ -8221,6 +8211,16 @@ Cette opération non conforme s'est produite sur la trace de la pile : La couleur de premier plan du volet Description. + + {0} Description + {0} Description + + + + Description + Description + + Sets whether to show the description pane. Définit si le volet Description s'affiche. 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 6a9d5e31e4a..0757da29423 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf @@ -7346,11 +7346,6 @@ Traccia dello stack da cui si è verificata l'operazione non valida: Tentativo del form {0} di impostare come proprio proprietario un form non adatto. I form non possono essere proprietari di se stessi né dei propri proprietari. - - Description - Descrizione - - Property value is not valid. Valore della proprietà non valido. @@ -8176,11 +8171,6 @@ Traccia dello stack da cui si è verificata l'operazione non valida: Colore di primo piano del testo disabilitato nell'area della griglia. - - {0} Description - Descrizione di {0} - - Browse... Sfoglia... @@ -8221,6 +8211,16 @@ Traccia dello stack da cui si è verificata l'operazione non valida: Colore di primo piano del riquadro Descrizione. + + {0} Description + {0} Description + + + + Description + Description + + Sets whether to show the description pane. Indica se visualizzare il riquadro Descrizione. 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 49bdb6dd9a9..9174bfbac5c 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf @@ -7346,11 +7346,6 @@ Stack trace where the illegal operation occurred was: フォーム {0} はそれ自体のオーナーとして適切でないフォームを設定しようとしました。フォームがフォームを所有したり、そのオーナーを所有したりすることはできません。 - - Description - 説明 - - Property value is not valid. プロパティの値が無効です。 @@ -8176,11 +8171,6 @@ Stack trace where the illegal operation occurred was: グリッド領域内の無効な文字の前景色。 - - {0} Description - {0} 説明 - - Browse... 参照... @@ -8221,6 +8211,16 @@ Stack trace where the illegal operation occurred was: 説明ペインの前景色です。 + + {0} Description + {0} Description + + + + Description + Description + + Sets whether to show the description pane. 説明ペインを表示するかどうかを設定します。 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 ad589ad205d..ad931596175 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf @@ -7346,11 +7346,6 @@ Stack trace where the illegal operation occurred was: {0} 폼이 자격이 없는 폼을 소유자로 설정하려고 했습니다. 폼은 자신 또는 자신의 소유자를 소유할 수 없습니다. - - Description - 설명 - - Property value is not valid. 속성 값이 잘못되었습니다. @@ -8176,11 +8171,6 @@ Stack trace where the illegal operation occurred was: 표 영역에 있는 비활성 텍스트의 전경색입니다. - - {0} Description - {0} 설명 - - Browse... 찾아보기... @@ -8221,6 +8211,16 @@ Stack trace where the illegal operation occurred was: 설명 창의 전경색입니다. + + {0} Description + {0} Description + + + + Description + Description + + Sets whether to show the description pane. 설명 창을 표시할지 여부를 설정합니다. 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 23a3dfd2572..480a5fca7d4 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf @@ -7346,11 +7346,6 @@ Stos śledzenia, w którym wystąpiła zabroniona operacja: Formularz {0} podjął próbę ustawienia nieodpowiedniego formularza jako właściciela. Formularze nie mogą być swoimi własnymi właścicielami ani właścicielami swoich właścicieli. - - Description - Opis - - Property value is not valid. Wartość właściwości nie jest prawidłowa. @@ -8176,11 +8171,6 @@ Stos śledzenia, w którym wystąpiła zabroniona operacja: Kolor pierwszego obszaru wyłączonego tekstu w obszarze siatki. - - {0} Description - {0} — opis - - Browse... Przeglądaj... @@ -8221,6 +8211,16 @@ Stos śledzenia, w którym wystąpiła zabroniona operacja: Kolor pierwszego planu okienka opisu. + + {0} Description + {0} Description + + + + Description + Description + + Sets whether to show the description pane. Określa, czy pokazywać okienko opisu. 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 39113feed01..d24d448cde0 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 @@ -7346,11 +7346,6 @@ Rastreamento de pilha em que a operação ilegal ocorreu: O formulário {0} tentou definir um formulário inadequado como proprietário. Formulários não podem possuir a si próprios ou seus proprietários. - - Description - Descrição - - Property value is not valid. Valor de propriedade inválido. @@ -8176,11 +8171,6 @@ Rastreamento de pilha em que a operação ilegal ocorreu: A cor do primeiro plano do texto desabilitado na área da grade. - - {0} Description - Descrição de {0} - - Browse... Procurar... @@ -8221,6 +8211,16 @@ Rastreamento de pilha em que a operação ilegal ocorreu: A cor de primeiro plano do painel de descrição. + + {0} Description + {0} Description + + + + Description + Description + + Sets whether to show the description pane. Define se o painel de descrição deve ser mostrado. 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 1bec5845534..8c8d8fc0017 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf @@ -7347,11 +7347,6 @@ Stack trace where the illegal operation occurred was: Форма {0} пыталась установить в качестве своего владельца недействительную форму. Формы не могут быть владельцами самих себя или своих владельцев. - - Description - Описание - - Property value is not valid. Недопустимое значение свойства. @@ -8177,11 +8172,6 @@ Stack trace where the illegal operation occurred was: Цвет переднего плана отключенного текста в области таблицы. - - {0} Description - {0}: описание - - Browse... Обзор… @@ -8222,6 +8212,16 @@ Stack trace where the illegal operation occurred was: Цвет переднего плана панели описания. + + {0} Description + {0} Description + + + + Description + Description + + Sets whether to show the description pane. Устанавливает, должна ли отображаться панель описания. 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 66a0f26b7db..6ab4f5dd602 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf @@ -7346,11 +7346,6 @@ Geçersiz işlemin gerçekleştiği yığın izi: {0} formu, geçersiz bir formu sahip olarak ayarlamaya çalıştı. Formlar kendilerinin veya sahiplerinin sahibi olamaz. - - Description - Açıklama - - Property value is not valid. Özellik değeri geçerli değil. @@ -8176,11 +8171,6 @@ Geçersiz işlemin gerçekleştiği yığın izi: Kılavuz alanındaki devre dışı metnin ön plan rengi. - - {0} Description - {0} Açıklaması - - Browse... Gözat... @@ -8221,6 +8211,16 @@ Geçersiz işlemin gerçekleştiği yığın izi: Açıklama bölmesinin ön plan rengi. + + {0} Description + {0} Description + + + + Description + Description + + Sets whether to show the description pane. Açıklama bölmesinin gösterilip gösterilmeyeceğini ayarlar. 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 dd4d755d5f4..da4ce995ee3 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 @@ -7346,11 +7346,6 @@ Stack trace where the illegal operation occurred was: 窗体 {0} 尝试将不符合要求的窗体设置为它的所有者。窗体不能拥有自身或其所有者。 - - Description - 描述 - - Property value is not valid. 属性值无效。 @@ -8176,11 +8171,6 @@ Stack trace where the illegal operation occurred was: 网格区域中的禁用文本的前景色。 - - {0} Description - {0} 说明 - - Browse... 浏览... @@ -8221,6 +8211,16 @@ Stack trace where the illegal operation occurred was: 说明窗格的前景色。 + + {0} Description + {0} Description + + + + Description + Description + + Sets whether to show the description pane. 设置是否显示说明窗格。 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 9deb197e851..75837a6b815 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 @@ -7346,11 +7346,6 @@ Stack trace where the illegal operation occurred was: 表單 {0} 嘗試將不合資格的表單設為擁有人。表單不能擁有本身或其擁有人。 - - Description - 描述 - - Property value is not valid. 無效的屬性值。 @@ -8176,11 +8171,6 @@ Stack trace where the illegal operation occurred was: 方格區域中停用文字的前景色彩。 - - {0} Description - {0} 描述 - - Browse... 瀏覽... @@ -8221,6 +8211,16 @@ Stack trace where the illegal operation occurred was: 描述窗格的前景色彩。 + + {0} Description + {0} Description + + + + Description + Description + + Sets whether to show the description pane. 設定是否顯示描述窗格。 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 08d0c331c7e..886635f87dd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleObject.cs @@ -357,6 +357,11 @@ internal virtual int ProviderOptions internal virtual UiaCore.IRawElementProviderSimple? HostRawElementProvider => null; + /// + /// Returns the value of the specified from the element. + /// + /// Identifier indicating the property to return + /// Returns the requested value if supported or null if it is not. internal virtual object? GetPropertyValue(UiaCore.UIA propertyID) => propertyID switch { @@ -419,6 +424,11 @@ private bool IsInvokePatternAvailable internal virtual int GetChildId() => NativeMethods.CHILDID_SELF; + /// + /// Returns the element in the specified . + /// + /// Indicates the direction in which to navigate. + /// Returns the element in the specified direction if it exists. internal virtual UiaCore.IRawElementProviderFragment? FragmentNavigate(UiaCore.NavigateDirection direction) => null; internal virtual UiaCore.IRawElementProviderSimple[]? GetEmbeddedFragmentRoots() => null; 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 49753cdcc01..2338f3ccc4a 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 @@ -9,14 +9,51 @@ namespace System.Windows.Forms.ComponentModel.Com2Interop { + /// + /// Allows Visual Studio to communicate internally with the PropertyGrid control. + /// public interface IComPropertyBrowser { + /// + /// Closes andy open drop-down controls on the control. + /// void DropDownDone(); + + /// + /// Gets a value indicating whether the control is currently setting one of the + /// properties of its selected object. + /// bool InPropertySet { get; } + + /// + /// Occurs when the control is browsing a COM object and the user renames the object. + /// event ComponentRenameEventHandler ComComponentNameChanged; + + /// + /// Commits all pending changes to the control. + /// + /// + /// if the successfully commits changes; otherwise, + /// . + /// bool EnsurePendingChangesCommitted(); + + /// + /// Activates the control when the user chooses Properties for a control in Design view. + /// void HandleF4(); + + /// + /// Loads user states from the registry into the control. + /// + /// The registry key that contains the user states. void LoadState(RegistryKey key); + + /// + /// Saves user states from the control to the registry. + /// + /// The registry key that contains the user states. void SaveState(RegistryKey key); } } 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 c615bb6235f..608f3870aa5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs @@ -13417,13 +13417,7 @@ void IArrangedElement.SetBounds(Rectangle bounds, BoundsSpecified specified) /// Indicates whether or not the control supports UIA Providers via /// IRawElementProviderFragment/IRawElementProviderFragmentRoot interfaces /// - internal virtual bool SupportsUiaProviders - { - get - { - return false; - } - } + internal virtual bool SupportsUiaProviders => false; /// /// Explicit support of DropTarget 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 8d24fb0f731..2eddbd95d44 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 @@ -158,7 +158,7 @@ internal AccessibleObject GetChildFragment(int index) { if (index == 0) { - return _owningPropertyGrid.HotCommandsAccessibleObject; + return _owningPropertyGrid.CommandsPaneAccessibleObject; } index--; @@ -168,7 +168,7 @@ internal AccessibleObject GetChildFragment(int index) { if (index == 0) { - return _owningPropertyGrid.HelpAccessibleObject; + return _owningPropertyGrid.HelpPaneAccessibleObject; } } 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 new file mode 100644 index 00000000000..133542be3a0 --- /dev/null +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.RegistryStateNames.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation 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 PropertyGrid + { + private static class RegistryStateNames + { + public const string AlphabeticalSort = "PbrsAlpha"; + public const string HelpVisible = "PbrsShowDesc"; + public const string CommandsVisible = "PbrsShowCommands"; + public const string CommentSizeRatio = "PbrsDescHeightRatio"; + public const string CommandSizeRatio = "PbrsHotCommandHeightRatio"; + } + } +} 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 0d2a0a58077..16c36a31276 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.cs @@ -26,10 +26,10 @@ namespace System.Windows.Forms [SRDescription(nameof(SR.DescriptionPropertyGrid))] public partial class PropertyGrid : ContainerControl, IComPropertyBrowser, Ole32.IPropertyNotifySink { - private readonly DocComment _docComment; - private int _docCommentSizeRatio = -1; - private int _hotCommandsSizeRatio = -1; - private readonly HotCommands _hotCommands; + private readonly HelpPane _helpPane; + private int _helpPaneSizeRatio = -1; + private int _commandsPaneSizeRatio = -1; + private readonly CommandsPane _commandsPane; private readonly ToolStrip _toolStrip; private bool _helpVisible = true; @@ -220,25 +220,25 @@ public PropertyGrid() // Always add the property tab here. AddTab(DefaultTabType, PropertyTabScope.Static); - _docComment = new(this); - _docComment.SuspendLayout(); - _docComment.TabStop = false; - _docComment.Dock = DockStyle.None; - _docComment.BackColor = SystemColors.Control; - _docComment.ForeColor = SystemColors.ControlText; - _docComment.MouseMove += OnChildMouseMove; - _docComment.MouseDown += OnChildMouseDown; - - _hotCommands = new HotCommands(this); - _hotCommands.SuspendLayout(); - _hotCommands.TabIndex = 3; - _hotCommands.Dock = DockStyle.None; + _helpPane = new(this); + _helpPane.SuspendLayout(); + _helpPane.TabStop = false; + _helpPane.Dock = DockStyle.None; + _helpPane.BackColor = SystemColors.Control; + _helpPane.ForeColor = SystemColors.ControlText; + _helpPane.MouseMove += OnChildMouseMove; + _helpPane.MouseDown += OnChildMouseDown; + + _commandsPane = new CommandsPane(this); + _commandsPane.SuspendLayout(); + _commandsPane.TabIndex = 3; + _commandsPane.Dock = DockStyle.None; SetHotCommandColors(); - _hotCommands.Visible = false; - _hotCommands.MouseMove += OnChildMouseMove; - _hotCommands.MouseDown += OnChildMouseDown; + _commandsPane.Visible = false; + _commandsPane.MouseMove += OnChildMouseMove; + _commandsPane.MouseDown += OnChildMouseDown; - Controls.AddRange(new Control[] { _docComment, _hotCommands, _gridView, _toolStrip }); + Controls.AddRange(new Control[] { _helpPane, _commandsPane, _gridView, _toolStrip }); SetActiveControl(_gridView); _toolStrip.ResumeLayout(performLayout: false); // SetupToolbar should perform the layout @@ -252,8 +252,8 @@ public PropertyGrid() } finally { - _docComment?.ResumeLayout(performLayout: false); - _hotCommands?.ResumeLayout(performLayout: false); + _helpPane?.ResumeLayout(performLayout: false); + _commandsPane?.ResumeLayout(performLayout: false); ResumeLayout(performLayout: true); } @@ -414,7 +414,7 @@ public AttributeCollection BrowsableAttributes [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Advanced)] [SRDescription(nameof(SR.PropertyGridCanShowCommandsDesc))] - public virtual bool CanShowCommands => _hotCommands.WouldBeVisible; + public virtual bool CanShowCommands => _commandsPane.WouldBeVisible; /// /// The text used color for category headings. The background color is determined by the LineColor property. @@ -442,11 +442,11 @@ public Color CategoryForeColor [SRDescription(nameof(SR.PropertyGridCommandsBackColorDesc))] public Color CommandsBackColor { - get => _hotCommands.BackColor; + get => _commandsPane.BackColor; set { - _hotCommands.BackColor = value; - _hotCommands.Label.BackColor = value; + _commandsPane.BackColor = value; + _commandsPane.Label.BackColor = value; } } @@ -457,11 +457,11 @@ public Color CommandsBackColor [SRDescription(nameof(SR.PropertyGridCommandsForeColorDesc))] public Color CommandsForeColor { - get => _hotCommands.ForeColor; + get => _commandsPane.ForeColor; set { - _hotCommands.ForeColor = value; - _hotCommands.Label.ForeColor = value; + _commandsPane.ForeColor = value; + _commandsPane.Label.ForeColor = value; } } @@ -472,8 +472,8 @@ public Color CommandsForeColor [SRDescription(nameof(SR.PropertyGridCommandsLinkColorDesc))] public Color CommandsLinkColor { - get => _hotCommands.Label.LinkColor; - set => _hotCommands.Label.LinkColor = value; + get => _commandsPane.Label.LinkColor; + set => _commandsPane.Label.LinkColor = value; } /// @@ -483,8 +483,8 @@ public Color CommandsLinkColor [SRDescription(nameof(SR.PropertyGridCommandsActiveLinkColorDesc))] public Color CommandsActiveLinkColor { - get => _hotCommands.Label.ActiveLinkColor; - set => _hotCommands.Label.ActiveLinkColor = value; + get => _commandsPane.Label.ActiveLinkColor; + set => _commandsPane.Label.ActiveLinkColor = value; } /// @@ -494,8 +494,8 @@ public Color CommandsActiveLinkColor [SRDescription(nameof(SR.PropertyGridCommandsDisabledLinkColorDesc))] public Color CommandsDisabledLinkColor { - get => _hotCommands.Label.DisabledLinkColor; - set => _hotCommands.Label.DisabledLinkColor = value; + get => _commandsPane.Label.DisabledLinkColor; + set => _commandsPane.Label.DisabledLinkColor = value; } /// @@ -506,8 +506,8 @@ public Color CommandsDisabledLinkColor [DefaultValue(typeof(Color), "ControlDark")] public Color CommandsBorderColor { - get => _hotCommands.BorderColor; - set => _hotCommands.BorderColor = value; + get => _commandsPane.BorderColor; + set => _commandsPane.BorderColor = value; } /// @@ -515,7 +515,7 @@ public Color CommandsBorderColor /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Advanced)] - public virtual bool CommandsVisible => _hotCommands.Visible; + public virtual bool CommandsVisible => _commandsPane.Visible; /// /// Returns true if the commands pane will be shown for objects @@ -526,30 +526,29 @@ public Color CommandsBorderColor [SRDescription(nameof(SR.PropertyGridCommandsVisibleIfAvailable))] public virtual bool CommandsVisibleIfAvailable { - get => _hotCommands.AllowVisible; + get => _commandsPane.AllowVisible; set { - bool hotcommandsVisible = _hotCommands.Visible; - _hotCommands.AllowVisible = value; + bool hotcommandsVisible = _commandsPane.Visible; + _commandsPane.AllowVisible = value; - if (hotcommandsVisible != _hotCommands.Visible) + if (hotcommandsVisible != _commandsPane.Visible) { OnLayoutInternal(dividerOnly: false); - _hotCommands.Invalidate(); + _commandsPane.Invalidate(); } } } /// - /// Returns a default location for showing the context menu. This - /// location is the center of the active property label in the grid, and - /// is used useful to position the context menu when the menu is invoked + /// Returns a default location for showing the context menu. This location is the center of the active + /// property label in the grid, and is used useful to position the context menu when the menu is invoked /// via the keyboard. /// [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Advanced)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public Point ContextMenuDefaultLocation => GetPropertyGridView().ContextMenuDefaultLocation; + public Point ContextMenuDefaultLocation => _gridView.ContextMenuDefaultLocation; /// /// Collection of child controls. @@ -632,7 +631,7 @@ private bool FreezePainting /// /// Gets the help control accessibility object. /// - internal AccessibleObject HelpAccessibleObject => _docComment.AccessibilityObject; + internal AccessibleObject HelpPaneAccessibleObject => _helpPane.AccessibilityObject; /// /// The background color for the help region. @@ -642,8 +641,8 @@ private bool FreezePainting [DefaultValue(typeof(Color), "Control")] public Color HelpBackColor { - get => _docComment.BackColor; - set => _docComment.BackColor = value; + get => _helpPane.BackColor; + set => _helpPane.BackColor = value; } /// @@ -654,20 +653,20 @@ public Color HelpBackColor [DefaultValue(typeof(Color), "ControlText")] public Color HelpForeColor { - get => _docComment.ForeColor; - set => _docComment.ForeColor = value; + get => _helpPane.ForeColor; + set => _helpPane.ForeColor = value; } /// - /// The border color for the help region + /// The border color for the help region. /// [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridHelpBorderColorDesc))] [DefaultValue(typeof(Color), "ControlDark")] public Color HelpBorderColor { - get => _docComment.BorderColor; - set => _docComment.BorderColor = value; + get => _helpPane.BorderColor; + set => _helpPane.BorderColor = value; } /// @@ -684,17 +683,17 @@ public virtual bool HelpVisible { _helpVisible = value; - _docComment.Visible = value; + _helpPane.Visible = value; OnLayoutInternal(dividerOnly: false); Invalidate(); - _docComment.Invalidate(); + _helpPane.Invalidate(); } } /// /// Gets the hot commands control accessible object. /// - internal AccessibleObject HotCommandsAccessibleObject => _hotCommands.AccessibilityObject; + internal AccessibleObject CommandsPaneAccessibleObject => _commandsPane.AccessibilityObject; /// /// Gets the main entry accessible object. @@ -798,8 +797,6 @@ public bool CanShowVisualStyleGlyphs } } - bool IComPropertyBrowser.InPropertySet => GetPropertyGridView().InPropertySet; - [SRCategory(nameof(SR.CatAppearance))] [SRDescription(nameof(SR.PropertyGridLineColorDesc))] [DefaultValue(typeof(Color), "InactiveBorder")] @@ -1088,7 +1085,7 @@ public object[] SelectedObjects } ShowEventsButton(showEvents && _currentObjects.Length > 0); - DisplayHotCommands(); + DisplayCommandsPane(); EnablePropPageButton(_currentObjects.Length == 1 ? _currentObjects[0] : null); OnSelectedObjectsChanged(EventArgs.Empty); } @@ -1734,9 +1731,9 @@ private ToolStripButton CreatePushButton(string toolTipText, int imageIndex, Eve return button; } - private void DisplayHotCommands() + private void DisplayCommandsPane() { - bool hotCommandsDisplayed = _hotCommands.Visible; + bool commandsPaneDisplayed = _commandsPane.Visible; IComponent component = null; DesignerVerb[] verbs = null; @@ -1785,14 +1782,14 @@ private void DisplayHotCommands() { if (verbs is not null && verbs.Length > 0) { - _hotCommands.SetVerbs(component, verbs); + _commandsPane.SetVerbs(component, verbs); } else { - _hotCommands.SetVerbs(null, null); + _commandsPane.SetVerbs(null, null); } - if (hotCommandsDisplayed != _hotCommands.Visible) + if (commandsPaneDisplayed != _commandsPane.Visible) { OnLayoutInternal(dividerOnly: false); } @@ -1884,25 +1881,25 @@ private SnappableControl DividerInside(int y) { int useGrid = -1; - if (_hotCommands.Visible) + if (_commandsPane.Visible) { - Point location = _hotCommands.Location; + Point location = _commandsPane.Location; if (y >= (location.Y - s_cyDivider) && y <= (location.Y + 1)) { - return _hotCommands; + return _commandsPane; } useGrid = 0; } - if (_docComment.Visible) + if (_helpPane.Visible) { - Point location = _docComment.Location; + Point location = _helpPane.Location; if (y >= (location.Y - s_cyDivider) && y <= (location.Y + 1)) { - return _docComment; + return _helpPane; } if (useGrid == -1) @@ -1922,9 +1919,9 @@ private SnappableControl DividerInside(int y) switch (useGrid) { case 0: - return _hotCommands; + return _commandsPane; case 1: - return _docComment; + return _helpPane; } } } @@ -1935,9 +1932,9 @@ private SnappableControl DividerInside(int y) private int DividerLimitHigh(SnappableControl target) { int high = _gridView.Location.Y + MinGridHeight; - if (target == _docComment && _hotCommands.Visible) + if (target == _helpPane && _commandsPane.Visible) { - high += _hotCommands.Size.Height + 2; + high += _commandsPane.Size.Height + 2; } return high; @@ -1974,8 +1971,6 @@ private static void DrawXorBar(Control ctlDrawTo, Rectangle rcFrame) } } - void IComPropertyBrowser.DropDownDone() => GetPropertyGridView().CloseDropDown(); - private bool EnablePropPageButton(object obj) { if (obj is null) @@ -2115,8 +2110,8 @@ private void AddLargeImage(Bitmap originalBitmap) bool IComPropertyBrowser.EnsurePendingChangesCommitted() { - // The commits sometimes cause transactions to open - // and close, which will cause refreshes, which we want to ignore. + // The commits sometimes cause transactions to open and close, which will cause refreshes, + // which we want to ignore. try { @@ -2126,7 +2121,7 @@ bool IComPropertyBrowser.EnsurePendingChangesCommitted() _designerHost.TransactionClosed -= OnTransactionClosed; } - return GetPropertyGridView().EnsurePendingChangesCommitted(); + return _gridView.EnsurePendingChangesCommitted(); } finally { @@ -2258,14 +2253,14 @@ internal Control GetElementFromPoint(Point point) return _gridView; } - if (HotCommandsAccessibleObject.Bounds.Contains(point)) + if (CommandsPaneAccessibleObject.Bounds.Contains(point)) { - return _hotCommands; + return _commandsPane; } - if (HelpAccessibleObject.Bounds.Contains(point)) + if (HelpPaneAccessibleObject.Bounds.Contains(point)) { - return _docComment; + return _helpPane; } return null; @@ -2293,7 +2288,11 @@ internal GridEntryCollection GetCurrentEntries() return _currentEntries; } - private PropertyGridView GetPropertyGridView() => _gridView; + internal bool HavePropertyEntriesChanged() => GetFlag(Flags.PropertiesChanged); + + bool IComPropertyBrowser.InPropertySet => _gridView.InPropertySet; + + void IComPropertyBrowser.DropDownDone() => _gridView.CloseDropDown(); void IComPropertyBrowser.HandleF4() { @@ -2310,11 +2309,23 @@ void IComPropertyBrowser.HandleF4() _gridView.Focus(); } - internal bool HavePropEntriesChanged() => GetFlag(Flags.PropertiesChanged); + void IComPropertyBrowser.SaveState(RegistryKey key) + { + if (key is null) + { + return; + } - void IComPropertyBrowser.LoadState(RegistryKey optRoot) + key.SetValue(RegistryStateNames.AlphabeticalSort, PropertySort == PropertySort.Alphabetical ? "1" : "0"); + key.SetValue(RegistryStateNames.HelpVisible, HelpVisible ? "1" : "0"); + key.SetValue(RegistryStateNames.CommandsVisible, CommandsVisibleIfAvailable ? "1" : "0"); + key.SetValue(RegistryStateNames.CommentSizeRatio, _helpPaneSizeRatio.ToString(CultureInfo.InvariantCulture)); + key.SetValue(RegistryStateNames.CommandSizeRatio, _commandsPaneSizeRatio.ToString(CultureInfo.InvariantCulture)); + } + + void IComPropertyBrowser.LoadState(RegistryKey key) { - if (optRoot is null) + if (key is null) { // Apply the same defaults from above. PropertySort = PropertySort.Categorized | PropertySort.Alphabetical; @@ -2323,43 +2334,38 @@ void IComPropertyBrowser.LoadState(RegistryKey optRoot) } else { - object value = optRoot.GetValue("PbrsAlpha", "0"); + object value = key.GetValue(RegistryStateNames.AlphabeticalSort, "0"); - if (value is not null && value.ToString().Equals("1")) - { - PropertySort = PropertySort.Alphabetical; - } - else - { - PropertySort = PropertySort.Categorized | PropertySort.Alphabetical; - } + PropertySort = value is not null && value.ToString().Equals("1") + ? PropertySort.Alphabetical + : PropertySort.Categorized | PropertySort.Alphabetical; - value = optRoot.GetValue("PbrsShowDesc", "1"); - HelpVisible = (value is not null && value.ToString().Equals("1")); + value = key.GetValue(RegistryStateNames.HelpVisible, "1"); + HelpVisible = value is not null && value.ToString().Equals("1"); - value = optRoot.GetValue("PbrsShowCommands", "0"); - CommandsVisibleIfAvailable = (value is not null && value.ToString().Equals("1")); - - value = optRoot.GetValue("PbrsDescHeightRatio", "-1"); + value = key.GetValue(RegistryStateNames.CommandsVisible, "0"); + CommandsVisibleIfAvailable = value is not null && value.ToString().Equals("1"); bool update = false; + + value = key.GetValue(RegistryStateNames.CommentSizeRatio, "-1"); if (value is string descriptionString) { int ratio = int.Parse(descriptionString, CultureInfo.InvariantCulture); if (ratio > 0) { - _docCommentSizeRatio = ratio; + _helpPaneSizeRatio = ratio; update = true; } } - value = optRoot.GetValue("PbrsHotCommandHeightRatio", "-1"); + value = key.GetValue(RegistryStateNames.CommandSizeRatio, "-1"); if (value is string commandString) { int ratio = int.Parse(commandString, CultureInfo.InvariantCulture); if (ratio > 0) { - _docCommentSizeRatio = ratio; + _commandsPaneSizeRatio = ratio; update = true; } } @@ -2624,8 +2630,8 @@ private void OnLayoutInternal(bool dividerOnly) SetupToolbar(true); } - // No toolbar or doc comment or commands, just fill the whole thing with the grid - if (!_toolStrip.Visible && !_docComment.Visible && !_hotCommands.Visible) + // No toolbar or help or commands visible, just fill the whole thing with the grid. + if (!_toolStrip.Visible && !_helpPane.Visible && !_commandsPane.Visible) { _gridView.Location = new Point(0, 0); _gridView.Size = Size; @@ -2659,102 +2665,102 @@ private void OnLayoutInternal(bool dividerOnly) int height; // If we're just moving the divider, set the requested heights. - int dcRequestedHeight = 0; - int hcRequestedHeight = 0; - int dcOptHeight = 0; - int hcOptHeight = 0; + int helpRequestedHeight = 0; + int commandsRequestedHeight = 0; + int helpOptimalHeight = 0; + int commandsOptimalHeight = 0; if (dividerOnly) { - dcRequestedHeight = _docComment.Visible ? _docComment.Size.Height : 0; - hcRequestedHeight = _hotCommands.Visible ? _hotCommands.Size.Height : 0; + helpRequestedHeight = _helpPane.Visible ? _helpPane.Size.Height : 0; + commandsRequestedHeight = _commandsPane.Visible ? _commandsPane.Size.Height : 0; } else { - if (_docComment.Visible) + if (_helpPane.Visible) { - dcOptHeight = _docComment.GetOptimalHeight(Size.Width - s_cyDivider); - if (_docComment.UserSized) + helpOptimalHeight = _helpPane.GetOptimalHeight(Size.Width - s_cyDivider); + if (_helpPane.UserSized) { - dcRequestedHeight = _docComment.Size.Height; + helpRequestedHeight = _helpPane.Size.Height; } - else if (_docCommentSizeRatio != -1) + else if (_helpPaneSizeRatio != -1) { - dcRequestedHeight = (Height * _docCommentSizeRatio) / 100; + helpRequestedHeight = (Height * _helpPaneSizeRatio) / 100; } else { - dcRequestedHeight = dcOptHeight; + helpRequestedHeight = helpOptimalHeight; } } - if (_hotCommands.Visible) + if (_commandsPane.Visible) { - hcOptHeight = _hotCommands.GetOptimalHeight(Size.Width - s_cyDivider); - if (_hotCommands.UserSized) + commandsOptimalHeight = _commandsPane.GetOptimalHeight(Size.Width - s_cyDivider); + if (_commandsPane.UserSized) { - hcRequestedHeight = _hotCommands.Size.Height; + commandsRequestedHeight = _commandsPane.Size.Height; } - else if (_hotCommandsSizeRatio != -1) + else if (_commandsPaneSizeRatio != -1) { - hcRequestedHeight = (Height * _hotCommandsSizeRatio) / 100; + commandsRequestedHeight = (Height * _commandsPaneSizeRatio) / 100; } else { - hcRequestedHeight = hcOptHeight; + commandsRequestedHeight = commandsOptimalHeight; } } } // Place the help comment window. - if (dcRequestedHeight > 0) + if (helpRequestedHeight > 0) { maxSpace -= s_cyDivider; - if (hcRequestedHeight == 0 || (dcRequestedHeight + hcRequestedHeight) < maxSpace) + if (commandsRequestedHeight == 0 || (helpRequestedHeight + commandsRequestedHeight) < maxSpace) { // Full size. - height = Math.Min(dcRequestedHeight, maxSpace); + height = Math.Min(helpRequestedHeight, maxSpace); } - else if (hcRequestedHeight > 0 && hcRequestedHeight < maxSpace) + else if (commandsRequestedHeight > 0 && commandsRequestedHeight < maxSpace) { // Give most of the space to the hot commands. - height = maxSpace - hcRequestedHeight; + height = maxSpace - commandsRequestedHeight; } else { // Split the difference. - height = Math.Min(dcRequestedHeight, maxSpace / 2 - 1); + height = Math.Min(helpRequestedHeight, maxSpace / 2 - 1); } height = Math.Max(height, s_cyDivider * 2); - _docComment.SetBounds(0, endSize - height, Size.Width, height); + _helpPane.SetBounds(0, endSize - height, Size.Width, height); // If we've modified the height to less than the optimal, clear the userSized item. - if (height <= dcOptHeight && height < dcRequestedHeight) + if (height <= helpOptimalHeight && height < helpRequestedHeight) { - _docComment.UserSized = false; + _helpPane.UserSized = false; } - else if (_docCommentSizeRatio != -1 || _docComment.UserSized) + else if (_helpPaneSizeRatio != -1 || _helpPane.UserSized) { - _docCommentSizeRatio = (_docComment.Height * 100) / Height; + _helpPaneSizeRatio = (_helpPane.Height * 100) / Height; } - _docComment.Invalidate(); - endSize = _docComment.Location.Y - s_cyDivider; + _helpPane.Invalidate(); + endSize = _helpPane.Location.Y - s_cyDivider; maxSpace -= height; } // Place the hot commands. - if (hcRequestedHeight > 0) + if (commandsRequestedHeight > 0) { maxSpace -= s_cyDivider; - if (maxSpace > hcRequestedHeight) + if (maxSpace > commandsRequestedHeight) { // Full size. - height = Math.Min(hcRequestedHeight, maxSpace); + height = Math.Min(commandsRequestedHeight, maxSpace); } else { @@ -2765,18 +2771,18 @@ private void OnLayoutInternal(bool dividerOnly) height = Math.Max(height, s_cyDivider * 2); // If we've modified the height, clear the userSized item. - if (height <= hcOptHeight && height < hcRequestedHeight) + if (height <= commandsOptimalHeight && height < commandsRequestedHeight) { - _hotCommands.UserSized = false; + _commandsPane.UserSized = false; } - else if (_hotCommandsSizeRatio != -1 || _hotCommands.UserSized) + else if (_commandsPaneSizeRatio != -1 || _commandsPane.UserSized) { - _hotCommandsSizeRatio = (_hotCommands.Height * 100) / Height; + _commandsPaneSizeRatio = (_commandsPane.Height * 100) / Height; } - _hotCommands.SetBounds(0, endSize - height, Size.Width, height); - _hotCommands.Invalidate(); - endSize = _hotCommands.Location.Y - s_cyDivider; + _commandsPane.SetBounds(0, endSize - height, Size.Width, height); + _commandsPane.Invalidate(); + endSize = _commandsPane.Location.Y - s_cyDivider; } _gridView.Size = new Size(Size.Width, endSize - _gridView.Location.Y); @@ -2915,22 +2921,22 @@ protected override void OnPaint(PaintEventArgs pevent) int yLast = psheetLoc.Y + _gridView.Size.Height; - // Fill above hotcommands. - if (_hotCommands.Visible) + // Fill above the commands pane. + if (_commandsPane.Visible) { pevent.Graphics.FillRectangle( backgroundBrush, - new Rectangle(0, yLast, width, _hotCommands.Location.Y - yLast)); - yLast += _hotCommands.Size.Height; + new Rectangle(0, yLast, width, _commandsPane.Location.Y - yLast)); + yLast += _commandsPane.Size.Height; } - // Fill above doc comment. - if (_docComment.Visible) + // Fill above the help pane. + if (_helpPane.Visible) { pevent.Graphics.FillRectangle( backgroundBrush, - new Rectangle(0, yLast, width, _docComment.Location.Y - yLast)); - yLast += _docComment.Size.Height; + new Rectangle(0, yLast, width, _helpPane.Location.Y - yLast)); + yLast += _helpPane.Size.Height; } // Anything that might be left. @@ -3246,7 +3252,7 @@ protected override bool ProcessDialogKey(Keys keyData) if (keyData.HasFlag(Keys.Shift)) { // This is backward - if (_hotCommands.Visible && _hotCommands.ContainsFocus) + if (_commandsPane.Visible && _commandsPane.ContainsFocus) { _gridView.ReverseFocus(); } @@ -3278,9 +3284,9 @@ protected override bool ProcessDialogKey(Keys keyData) else { // Otherwise, we're processing a message from elsewhere so we select our bottom item. - if (_hotCommands.Visible) + if (_commandsPane.Visible) { - _hotCommands.FocusLabel(); + _commandsPane.FocusLabel(); } else if (_mainEntry is not null) { @@ -3320,9 +3326,9 @@ protected override bool ProcessDialogKey(Keys keyData) } else if (_gridView.FocusInside) { - if (_hotCommands.Visible) + if (_commandsPane.Visible) { - _hotCommands.FocusLabel(); + _commandsPane.FocusLabel(); return true; } else @@ -3330,7 +3336,7 @@ protected override bool ProcessDialogKey(Keys keyData) passToParent = true; } } - else if (_hotCommands.ContainsFocus) + else if (_commandsPane.ContainsFocus) { passToParent = true; } @@ -3400,7 +3406,7 @@ private void Refresh(bool clearCached) RefreshProperties(clearCached); _gridView.Refresh(); - DisplayHotCommands(); + DisplayCommandsPane(); } finally { @@ -3694,23 +3700,25 @@ internal void RemoveTab(Type tabType) // The following Reset methods are used via reflection. - private void ResetCommandsBackColor() => _hotCommands.ResetBackColor(); + private void ResetCommandsBackColor() => _commandsPane.ResetBackColor(); - private void ResetCommandsForeColor() => _hotCommands.ResetForeColor(); + private void ResetCommandsForeColor() => _commandsPane.ResetForeColor(); - private void ResetCommandsLinkColor() => _hotCommands.Label.ResetLinkColor(); + private void ResetCommandsLinkColor() => _commandsPane.Label.ResetLinkColor(); - private void ResetCommandsActiveLinkColor() => _hotCommands.Label.ResetActiveLinkColor(); + private void ResetCommandsActiveLinkColor() => _commandsPane.Label.ResetActiveLinkColor(); - private void ResetCommandsDisabledLinkColor() => _hotCommands.Label.ResetDisabledLinkColor(); + private void ResetCommandsDisabledLinkColor() => _commandsPane.Label.ResetDisabledLinkColor(); - private void ResetHelpBackColor() => _docComment.ResetBackColor(); + private void ResetHelpBackColor() => _helpPane.ResetBackColor(); - private void ResetHelpForeColor() => _docComment.ResetBackColor(); + private void ResetHelpForeColor() => _helpPane.ResetBackColor(); - // This method is intended for use in replacing a specific selected root object with - // another object of the same exact type. Scenario: An immutable root object being - // replaced with a new instance because one of its properties was changed by the user. + /// + /// This method is intended for use in replacing a specific selected root object with another object of the + /// same exact type. Scenario: An immutable root object being replaced with a new instance because one of its + /// properties was changed by the user. + /// internal void ReplaceSelectedObject(object oldObject, object newObject) { Debug.Assert(oldObject is not null && newObject is not null && oldObject.GetType() == newObject.GetType()); @@ -3726,39 +3734,21 @@ internal void ReplaceSelectedObject(object oldObject, object newObject) } } - public void ResetSelectedProperty() => GetPropertyGridView().Reset(); + public void ResetSelectedProperty() => _gridView.Reset(); private void SaveTabSelection() { if (_designerHost is not null) { - if (_designerSelections is null) - { - _designerSelections = new Hashtable(); - } - + _designerSelections ??= new Hashtable(); _designerSelections[_designerHost.GetHashCode()] = _selectedViewTab; } } - void IComPropertyBrowser.SaveState(RegistryKey optRoot) - { - if (optRoot is null) - { - return; - } - - optRoot.SetValue("PbrsAlpha", (PropertySort == PropertySort.Alphabetical ? "1" : "0")); - optRoot.SetValue("PbrsShowDesc", (HelpVisible ? "1" : "0")); - optRoot.SetValue("PbrsShowCommands", (CommandsVisibleIfAvailable ? "1" : "0")); - optRoot.SetValue("PbrsDescHeightRatio", _docCommentSizeRatio.ToString(CultureInfo.InvariantCulture)); - optRoot.SetValue("PbrsHotCommandHeightRatio", _hotCommandsSizeRatio.ToString(CultureInfo.InvariantCulture)); - } - private void SetHotCommandColors() - => _hotCommands.SetColors(SystemColors.Control, SystemColors.ControlText, Color.Empty, Color.Empty, Color.Empty, Color.Empty); + => _commandsPane.SetColors(SystemColors.Control, SystemColors.ControlText, Color.Empty, Color.Empty, Color.Empty, Color.Empty); - internal void SetStatusBox(string title, string description) => _docComment.SetComment(title, description); + internal void SetStatusBox(string title, string description) => _helpPane.SetDescription(title, description); private void SelectViewTabButton(ToolStripButton button, bool updateSelection) { @@ -4116,15 +4106,15 @@ protected void ShowEventsButton(bool value) // "Should" methods are used by the designer via reflection. - private bool ShouldSerializeCommandsBackColor() => _hotCommands.ShouldSerializeBackColor(); + private bool ShouldSerializeCommandsBackColor() => _commandsPane.ShouldSerializeBackColor(); - private bool ShouldSerializeCommandsForeColor() => _hotCommands.ShouldSerializeForeColor(); + private bool ShouldSerializeCommandsForeColor() => _commandsPane.ShouldSerializeForeColor(); - private bool ShouldSerializeCommandsLinkColor() => _hotCommands.Label.ShouldSerializeLinkColor(); + private bool ShouldSerializeCommandsLinkColor() => _commandsPane.Label.ShouldSerializeLinkColor(); - private bool ShouldSerializeCommandsActiveLinkColor() => _hotCommands.Label.ShouldSerializeActiveLinkColor(); + private bool ShouldSerializeCommandsActiveLinkColor() => _commandsPane.Label.ShouldSerializeActiveLinkColor(); - private bool ShouldSerializeCommandsDisabledLinkColor() => _hotCommands.Label.ShouldSerializeDisabledLinkColor(); + private bool ShouldSerializeCommandsDisabledLinkColor() => _commandsPane.Label.ShouldSerializeDisabledLinkColor(); /// /// Sinks the property notify events on all the COM objects we are currently browsing. @@ -4300,7 +4290,7 @@ public bool UseCompatibleTextRendering set { UseCompatibleTextRenderingInt = value; - _docComment.UpdateTextRenderingEngine(); + _helpPane.UpdateTextRenderingEngine(); _gridView.Invalidate(); } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HotCommands.HotCommandsAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CommandsPane.CommandsPaneAccessibleObject.cs similarity index 58% rename from src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HotCommands.HotCommandsAccessibleObject.cs rename to src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CommandsPane.CommandsPaneAccessibleObject.cs index 698a399a2c5..aff685ee871 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HotCommands.HotCommandsAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CommandsPane.CommandsPaneAccessibleObject.cs @@ -6,30 +6,26 @@ namespace System.Windows.Forms.PropertyGridInternal { - internal partial class HotCommands + internal partial class CommandsPane { /// - /// Represents the hot commands control accessible object. + /// Represents the accessible object. /// - internal class HotCommandsAccessibleObject : Control.ControlAccessibleObject + internal class CommandsPaneAccessibleObject : ControlAccessibleObject { private readonly PropertyGrid _parentPropertyGrid; /// - /// Initializes new instance of DocCommentAccessibleObject. + /// Initializes new instance of . /// - /// The owning HotCommands control. - /// The parent PropertyGrid control. - public HotCommandsAccessibleObject(HotCommands owningHotCommands, PropertyGrid parentPropertyGrid) : base(owningHotCommands) + /// The owning control. + /// The parent control. + public CommandsPaneAccessibleObject(CommandsPane owningCommandsPane, PropertyGrid parentPropertyGrid) : base(owningCommandsPane) { _parentPropertyGrid = parentPropertyGrid; } - /// - /// Request to return the element in the specified direction. - /// - /// Indicates the direction in which to navigate. - /// Returns the element in the specified direction. + /// internal override UiaCore.IRawElementProviderFragment? FragmentNavigate(UiaCore.NavigateDirection direction) { if (_parentPropertyGrid.AccessibilityObject is PropertyGrid.PropertyGridAccessibleObject propertyGridAccessibleObject) @@ -44,11 +40,7 @@ public HotCommandsAccessibleObject(HotCommands owningHotCommands, PropertyGrid p return base.FragmentNavigate(direction); } - /// - /// Request value of specified property from an element. - /// - /// Identifier indicating the property to return - /// Returns a ValInfo indicating whether the element supports this property, or has no value for it. + /// internal override object? GetPropertyValue(UiaCore.UIA propertyID) => propertyID switch { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HotCommands.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CommandsPane.cs similarity index 92% rename from src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HotCommands.cs rename to src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CommandsPane.cs index f47b58207ab..8db52b10dbf 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HotCommands.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/CommandsPane.cs @@ -10,7 +10,15 @@ namespace System.Windows.Forms.PropertyGridInternal { - internal partial class HotCommands : PropertyGrid.SnappableControl + /// + /// The commands pane optionally shown at the bottom of the . + /// + /// + /// + /// controls the visibility of this control. + /// + /// + internal partial class CommandsPane : PropertyGrid.SnappableControl { private object _component; private DesignerVerb[] _verbs; @@ -18,7 +26,7 @@ internal partial class HotCommands : PropertyGrid.SnappableControl private bool _allowVisible = true; private int _optimalHeight = -1; - internal HotCommands(PropertyGrid owner) : base(owner) + internal CommandsPane(PropertyGrid owner) : base(owner) { Text = "Command Pane"; } @@ -41,7 +49,7 @@ public virtual bool AllowVisible /// /// The accessibility object for this control. protected override AccessibleObject CreateAccessibilityInstance() - => new HotCommandsAccessibleObject(this, OwnerPropertyGrid); + => new CommandsPaneAccessibleObject(this, OwnerPropertyGrid); public override Rectangle DisplayRectangle { @@ -96,10 +104,7 @@ public override int GetOptimalHeight(int width) public override int SnapHeightRequest(int request) => request; - /// - /// Indicates whether or not the control supports UIA Providers via - /// IRawElementProviderFragment/IRawElementProviderFragmentRoot interfaces. - /// + /// internal override bool SupportsUiaProviders => true; private void LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DocComment.DocCommentAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HelpPane.HelpPaneAccessibleObject.cs similarity index 55% rename from src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DocComment.DocCommentAccessibleObject.cs rename to src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HelpPane.HelpPaneAccessibleObject.cs index 70ac75fb8ab..9e25ba4874f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DocComment.DocCommentAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HelpPane.HelpPaneAccessibleObject.cs @@ -6,30 +6,26 @@ namespace System.Windows.Forms.PropertyGridInternal { - internal partial class DocComment + internal partial class HelpPane { /// - /// Represents the DocComment control accessible object. + /// Represents the accessible object. /// - internal class DocCommentAccessibleObject : Control.ControlAccessibleObject + internal class HelpPaneAccessibleObject : ControlAccessibleObject { private readonly PropertyGrid _parentPropertyGrid; /// - /// Initializes new instance of DocCommentAccessibleObject. + /// Initializes new instance of the . /// - /// The owning DocComment control. - /// The parent PropertyGrid control. - public DocCommentAccessibleObject(DocComment owningDocComment, PropertyGrid parentPropertyGrid) : base(owningDocComment) + /// The owning control. + /// The parent control. + public HelpPaneAccessibleObject(HelpPane owningHelpPane, PropertyGrid parentPropertyGrid) : base(owningHelpPane) { _parentPropertyGrid = parentPropertyGrid; } - /// - /// Request to return the element in the specified direction. - /// - /// Indicates the direction in which to navigate. - /// Returns the element in the specified direction. + /// internal override UiaCore.IRawElementProviderFragment? FragmentNavigate(UiaCore.NavigateDirection direction) { if (_parentPropertyGrid.AccessibilityObject is PropertyGrid.PropertyGridAccessibleObject propertyGridAccessibleObject) @@ -44,11 +40,7 @@ public DocCommentAccessibleObject(DocComment owningDocComment, PropertyGrid pare return base.FragmentNavigate(direction); } - /// - /// Request value of specified property from an element. - /// - /// Identifier indicating the property to return - /// Returns a ValInfo indicating whether the element supports this property, or has no value for it. + /// internal override object? GetPropertyValue(UiaCore.UIA propertyID) => propertyID switch { @@ -58,7 +50,7 @@ public DocCommentAccessibleObject(DocComment owningDocComment, PropertyGrid pare }; public override string Name => Owner?.AccessibleName - ?? string.Format(SR.PropertyGridDocCommentAccessibleNameTemplate, _parentPropertyGrid?.AccessibilityObject.Name); + ?? string.Format(SR.PropertyGridHelpPaneAccessibleNameTemplate, _parentPropertyGrid?.AccessibilityObject.Name); } } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DocComment.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HelpPane.cs similarity index 58% rename from src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DocComment.cs rename to src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HelpPane.cs index a3985e655f7..59d7837ce62 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DocComment.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/HelpPane.cs @@ -8,10 +8,18 @@ namespace System.Windows.Forms.PropertyGridInternal { - internal partial class DocComment : PropertyGrid.SnappableControl + /// + /// The help (description) pane optionally shown at the bottom of the . + /// + /// + /// + /// controls the visibility of this control. + /// + /// + internal partial class HelpPane : PropertyGrid.SnappableControl { - private readonly Label _labelTitle; - private readonly Label _labelDescription; + private readonly Label _titleLabel; + private readonly Label _descriptionLabel; private string _fullDescription; private int _lineHeight; @@ -22,21 +30,20 @@ internal partial class DocComment : PropertyGrid.SnappableControl protected const int DefaultHeight = 59; protected const int MinimumLines = 2; - private int _cydef = DefaultHeight; - private int _cBorder = BorderSize; + private int _borderSize = BorderSize; - private Rectangle _rect = Rectangle.Empty; + private Rectangle _lastClientRectangle = Rectangle.Empty; - internal DocComment(PropertyGrid owner) : base(owner) + internal HelpPane(PropertyGrid owner) : base(owner) { SuspendLayout(); - _labelTitle = new() + _titleLabel = new() { UseMnemonic = false, Cursor = Cursors.Default }; - _labelDescription = new() + _descriptionLabel = new() { AutoEllipsis = true, Cursor = Cursors.Default @@ -44,17 +51,20 @@ internal DocComment(PropertyGrid owner) : base(owner) UpdateTextRenderingEngine(); - Controls.Add(_labelTitle); - Controls.Add(_labelDescription); + Controls.Add(_titleLabel); + Controls.Add(_descriptionLabel); + + int defaultHeight = DefaultHeight; + if (DpiHelper.IsScalingRequirementMet) { - _cBorder = LogicalToDeviceUnits(BorderSize); - _cydef = LogicalToDeviceUnits(DefaultHeight); + _borderSize = LogicalToDeviceUnits(BorderSize); + defaultHeight = LogicalToDeviceUnits(DefaultHeight); } - Size = new(DefaultWidth, _cydef); + Size = new(DefaultWidth, defaultHeight); - Text = SR.PBRSDocCommentPaneTitle; + Text = SR.PropertyGridHelpPaneTitle; SetStyle(ControlStyles.Selectable, false); ResumeLayout(false); } @@ -78,7 +88,7 @@ public override int GetOptimalHeight(int width) UpdateUIWithFont(); // Compute optimal label height as one line only. - int height = _labelTitle.Size.Height; + int height = _titleLabel.Size.Height; // Do this to avoid getting parented to the Parking window. if (OwnerPropertyGrid.IsHandleCreated && !IsHandleCreated) @@ -88,10 +98,9 @@ public override int GetOptimalHeight(int width) // Compute optimal text height. bool isScalingRequirementMet = DpiHelper.IsScalingRequirementMet; - Graphics g = _labelDescription.CreateGraphicsInternal(); - SizeF sizef = PropertyGrid.MeasureTextHelper.MeasureText(OwnerPropertyGrid, g, _labelTitle.Text, Font, width); + using Graphics g = _descriptionLabel.CreateGraphicsInternal(); + SizeF sizef = PropertyGrid.MeasureTextHelper.MeasureText(OwnerPropertyGrid, g, _titleLabel.Text, Font, width); Size size = Size.Ceiling(sizef); - g.Dispose(); int padding = isScalingRequirementMet ? LogicalToDeviceUnits(2) : 2; height += (size.Height * 2) + padding; return Math.Max(height + 2 * padding, isScalingRequirementMet ? LogicalToDeviceUnits(DefaultHeight) : DefaultHeight); @@ -111,19 +120,22 @@ protected override void OnFontChanged(EventArgs e) protected override void OnLayout(LayoutEventArgs e) { UpdateUIWithFont(); - SetChildLabelsBounds(); - _labelDescription.Text = _fullDescription; - _labelDescription.AccessibleName = _fullDescription; // Don't crop the description for accessibility clients + SetLabelBounds(); + _descriptionLabel.Text = _fullDescription; + _descriptionLabel.AccessibleName = _fullDescription; // Don't crop the description for accessibility clients base.OnLayout(e); } protected override void OnResize(EventArgs e) { - Rectangle newRect = ClientRectangle; - if (!_rect.IsEmpty && newRect.Width > _rect.Width) + Rectangle currentClientRectangle = ClientRectangle; + if (!_lastClientRectangle.IsEmpty && currentClientRectangle.Width > _lastClientRectangle.Width) { - Rectangle rectInvalidate = new(_rect.Width - 1, 0, newRect.Width - _rect.Width + 1, _rect.Height); - Invalidate(rectInvalidate); + Invalidate(new Rectangle( + _lastClientRectangle.Width - 1, + 0, + currentClientRectangle.Width - _lastClientRectangle.Width + 1, + _lastClientRectangle.Height)); } if (DpiHelper.IsScalingRequirementMet) @@ -132,39 +144,35 @@ protected override void OnResize(EventArgs e) _lineHeight = Font.Height + LogicalToDeviceUnits(2); if (oldLineHeight != _lineHeight) { - _labelTitle.Location = new(_cBorder, _cBorder); - _labelDescription.Location = new(_cBorder, _cBorder + _lineHeight); + _titleLabel.Location = new(_borderSize, _borderSize); + _descriptionLabel.Location = new(_borderSize, _borderSize + _lineHeight); - // Labels were explicitly set bounds. resize of parent is not rescaling labels. - SetChildLabelsBounds(); + SetLabelBounds(); } } - _rect = newRect; + _lastClientRectangle = currentClientRectangle; base.OnResize(e); } - /// - /// Setting child label bounds - /// - private void SetChildLabelsBounds() + private void SetLabelBounds() { Size size = ClientSize; // If the client size is 0, setting this to a negative number will force an extra layout. - size.Width = Math.Max(0, size.Width - 2 * _cBorder); - size.Height = Math.Max(0, size.Height - 2 * _cBorder); + size.Width = Math.Max(0, size.Width - 2 * _borderSize); + size.Height = Math.Max(0, size.Height - 2 * _borderSize); - _labelTitle.SetBounds( - _labelTitle.Top, - _labelTitle.Left, + _titleLabel.SetBounds( + _titleLabel.Top, + _titleLabel.Left, size.Width, Math.Min(_lineHeight, size.Height), BoundsSpecified.Size); - _labelDescription.SetBounds( - _labelDescription.Top, - _labelDescription.Left, + _descriptionLabel.SetBounds( + _descriptionLabel.Top, + _descriptionLabel.Left, size.Width, Math.Max(0, size.Height - _lineHeight - (DpiHelper.IsScalingRequirementMet ? LogicalToDeviceUnits(1) : 1)), BoundsSpecified.Size); @@ -176,33 +184,30 @@ protected override void OnHandleCreated(EventArgs e) UpdateUIWithFont(); } - /// - /// Rescales constants when DPI of the window has changed. - /// - /// Old DPI. - /// New DPI. + /// protected override void RescaleConstantsForDpi(int deviceDpiOld, int deviceDpiNew) { base.RescaleConstantsForDpi(deviceDpiOld, deviceDpiNew); if (DpiHelper.IsScalingRequirementMet) { - _cBorder = LogicalToDeviceUnits(BorderSize); - _cydef = LogicalToDeviceUnits(DefaultHeight); + _borderSize = LogicalToDeviceUnits(BorderSize); } } - public virtual void SetComment(string title, string description) + public virtual void SetDescription(string title, string description) { - if (_labelDescription.Text != title) + if (_descriptionLabel.Text != title) { - _labelTitle.Text = title; + _titleLabel.Text = title; } if (description != _fullDescription) { _fullDescription = description; - _labelDescription.Text = _fullDescription; - _labelDescription.AccessibleName = _fullDescription; // Don't crop the description for accessibility clients + _descriptionLabel.Text = _fullDescription; + + // Don't crop the description for accessibility clients. + _descriptionLabel.AccessibleName = _fullDescription; } } @@ -213,40 +218,34 @@ public override int SnapHeightRequest(int newHeight) return 1 + lines * _lineHeight; } - /// - /// Constructs the new instance of the accessibility object for this control. - /// - /// The accessibility object for this control. - protected override AccessibleObject CreateAccessibilityInstance() => new DocCommentAccessibleObject(this, OwnerPropertyGrid); + /// + protected override AccessibleObject CreateAccessibilityInstance() => new HelpPaneAccessibleObject(this, OwnerPropertyGrid); - /// - /// Indicates whether or not the control supports UIA Providers via - /// IRawElementProviderFragment/IRawElementProviderFragmentRoot interfaces. - /// + /// internal override bool SupportsUiaProviders => true; internal void UpdateTextRenderingEngine() { - _labelTitle.UseCompatibleTextRendering = OwnerPropertyGrid.UseCompatibleTextRendering; - _labelDescription.UseCompatibleTextRendering = OwnerPropertyGrid.UseCompatibleTextRendering; + _titleLabel.UseCompatibleTextRendering = OwnerPropertyGrid.UseCompatibleTextRendering; + _descriptionLabel.UseCompatibleTextRendering = OwnerPropertyGrid.UseCompatibleTextRendering; } private void UpdateUIWithFont() { if (IsHandleCreated && _needUpdateUIWithFont) { - // Some fonts throw because Bold is not a valid option for them. Fail gracefully. + // Some fonts throw because Bold is not a valid option for them. Fail gracefully. try { - _labelTitle.Font = new(Font, FontStyle.Bold); + _titleLabel.Font = new(Font, FontStyle.Bold); } catch (Exception e) when (!ClientUtils.IsCriticalException(e)) { } _lineHeight = Font.Height + 2; - _labelTitle.Location = new(_cBorder, _cBorder); - _labelDescription.Location = new(_cBorder, _cBorder + _lineHeight); + _titleLabel.Location = new(_borderSize, _borderSize); + _descriptionLabel.Location = new(_borderSize, _borderSize + _lineHeight); _needUpdateUIWithFont = false; PerformLayout(); 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 315f2240310..a642e741725 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 @@ -4181,7 +4181,7 @@ private void Refresh(bool fullRefresh, int startRow, int endRow) startRow = 0; } - if (fullRefresh || OwnerGrid.HavePropEntriesChanged()) + if (fullRefresh || OwnerGrid.HavePropertyEntriesChanged()) { if (HasEntries && !InPropertySet && !CommitEditTextBox()) { diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/CommandsPane.CommandsPaneAccessibleObjectTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/CommandsPane.CommandsPaneAccessibleObjectTests.cs new file mode 100644 index 00000000000..6f180f07e5a --- /dev/null +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/CommandsPane.CommandsPaneAccessibleObjectTests.cs @@ -0,0 +1,60 @@ +// Licensed to the .NET Foundation under one or more agreements. +// 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 Interop; + +namespace System.Windows.Forms.PropertyGridInternal.Tests +{ + public class CommandsPane_CommandsPaneAccessibleObjectTests : IClassFixture + { + [WinFormsFact] + public void CommandsPaneAccessibleObject_Ctor_Default() + { + using PropertyGrid propertyGrid = new PropertyGrid(); + using CommandsPane commandsPane = new CommandsPane(propertyGrid); + CommandsPane.CommandsPaneAccessibleObject accessibleObject = + new CommandsPane.CommandsPaneAccessibleObject(commandsPane, propertyGrid); + + Assert.Equal(commandsPane, accessibleObject.Owner); + Assert.False(propertyGrid.IsHandleCreated); + Assert.False(commandsPane.IsHandleCreated); + } + + [WinFormsFact] + public void CommandsPaneAccessibleObject_ControlType_IsPane_IfAccessibleRoleIsDefault() + { + using PropertyGrid propertyGrid = new PropertyGrid(); + using CommandsPane commandsPane = new CommandsPane(propertyGrid); + // AccessibleRole is not set = Default + + object actual = commandsPane.AccessibilityObject.GetPropertyValue(UiaCore.UIA.ControlTypePropertyId); + + Assert.Equal(UiaCore.UIA.PaneControlTypeId, actual); + Assert.False(propertyGrid.IsHandleCreated); + Assert.False(commandsPane.IsHandleCreated); + } + + [WinFormsTheory] + [InlineData(true, AccessibleRole.Client)] + [InlineData(false, AccessibleRole.None)] + public void CommandsPaneAccessibleObject_Role_IsExpected_ByDefault(bool createControl, AccessibleRole expectedRole) + { + using PropertyGrid propertyGrid = new PropertyGrid(); + using CommandsPane commandsPane = new CommandsPane(propertyGrid); + // AccessibleRole is not set = Default + + if (createControl) + { + commandsPane.CreateControl(); + } + + AccessibleRole actual = commandsPane.AccessibilityObject.Role; + + Assert.Equal(expectedRole, actual); + Assert.False(propertyGrid.IsHandleCreated); + Assert.Equal(createControl, commandsPane.IsHandleCreated); + } + } +} diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/DocComment.DocCommentAccessibleObjectTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/DocComment.DocCommentAccessibleObjectTests.cs deleted file mode 100644 index 6d2f2607ecf..00000000000 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/DocComment.DocCommentAccessibleObjectTests.cs +++ /dev/null @@ -1,60 +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 Xunit; -using static Interop; - -namespace System.Windows.Forms.PropertyGridInternal.Tests -{ - public class DocComment_DocCommentAccessibleObjectTests : IClassFixture - { - [WinFormsFact] - public void DocCommentAccessibleObject_Ctor_Default() - { - using PropertyGrid propertyGrid = new PropertyGrid(); - using DocComment docComment = new DocComment(propertyGrid); - DocComment.DocCommentAccessibleObject accessibleObject = - new DocComment.DocCommentAccessibleObject(docComment, propertyGrid); - - Assert.Equal(docComment, accessibleObject.Owner); - Assert.False(propertyGrid.IsHandleCreated); - Assert.False(docComment.IsHandleCreated); - } - - [WinFormsFact] - public void DocCommentAccessibleObject_ControlType_IsPane_IfAccessibleRoleIsDefault() - { - using PropertyGrid propertyGrid = new PropertyGrid(); - using DocComment docComment = new DocComment(propertyGrid); - // AccessibleRole is not set = Default - - object actual = docComment.AccessibilityObject.GetPropertyValue(UiaCore.UIA.ControlTypePropertyId); - - Assert.Equal(UiaCore.UIA.PaneControlTypeId, actual); - Assert.False(propertyGrid.IsHandleCreated); - Assert.False(docComment.IsHandleCreated); - } - - [WinFormsTheory] - [InlineData(true, AccessibleRole.Client)] - [InlineData(false, AccessibleRole.None)] - public void DocCommentAccessibleObject_Role_IsExpected_ByDefault(bool createControl, AccessibleRole expectedRole) - { - using PropertyGrid propertyGrid = new PropertyGrid(); - using DocComment docComment = new DocComment(propertyGrid); - // AccessibleRole is not set = Default - - if (createControl) - { - docComment.CreateControl(); - } - - AccessibleRole actual = docComment.AccessibilityObject.Role; - - Assert.Equal(expectedRole, actual); - Assert.False(propertyGrid.IsHandleCreated); - Assert.Equal(createControl, docComment.IsHandleCreated); - } - } -} diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/HelpPane.HelpPaneAccessibleObjectTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/HelpPane.HelpPaneAccessibleObjectTests.cs new file mode 100644 index 00000000000..21e66bc083f --- /dev/null +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/HelpPane.HelpPaneAccessibleObjectTests.cs @@ -0,0 +1,60 @@ +// Licensed to the .NET Foundation under one or more agreements. +// 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 Interop; + +namespace System.Windows.Forms.PropertyGridInternal.Tests +{ + public class HelpPane_HelpPaneAccessibleObjectTests : IClassFixture + { + [WinFormsFact] + public void HelpPaneAccessibleObject_Ctor_Default() + { + using PropertyGrid propertyGrid = new PropertyGrid(); + using HelpPane helpPane = new HelpPane(propertyGrid); + HelpPane.HelpPaneAccessibleObject accessibleObject = + new HelpPane.HelpPaneAccessibleObject(helpPane, propertyGrid); + + Assert.Equal(helpPane, accessibleObject.Owner); + Assert.False(propertyGrid.IsHandleCreated); + Assert.False(helpPane.IsHandleCreated); + } + + [WinFormsFact] + public void HelpPaneAccessibleObject_ControlType_IsPane_IfAccessibleRoleIsDefault() + { + using PropertyGrid propertyGrid = new PropertyGrid(); + using HelpPane helpPane = new HelpPane(propertyGrid); + // AccessibleRole is not set = Default + + object actual = helpPane.AccessibilityObject.GetPropertyValue(UiaCore.UIA.ControlTypePropertyId); + + Assert.Equal(UiaCore.UIA.PaneControlTypeId, actual); + Assert.False(propertyGrid.IsHandleCreated); + Assert.False(helpPane.IsHandleCreated); + } + + [WinFormsTheory] + [InlineData(true, AccessibleRole.Client)] + [InlineData(false, AccessibleRole.None)] + public void HelpPaneAccessibleObject_Role_IsExpected_ByDefault(bool createControl, AccessibleRole expectedRole) + { + using PropertyGrid propertyGrid = new PropertyGrid(); + using HelpPane helpPane = new HelpPane(propertyGrid); + // AccessibleRole is not set = Default + + if (createControl) + { + helpPane.CreateControl(); + } + + AccessibleRole actual = helpPane.AccessibilityObject.Role; + + Assert.Equal(expectedRole, actual); + Assert.False(propertyGrid.IsHandleCreated); + Assert.Equal(createControl, helpPane.IsHandleCreated); + } + } +} diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/HotCommands.HotCommandsAccessibleObjectTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/HotCommands.HotCommandsAccessibleObjectTests.cs deleted file mode 100644 index 87cb8d2e7d8..00000000000 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/HotCommands.HotCommandsAccessibleObjectTests.cs +++ /dev/null @@ -1,60 +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 Xunit; -using static Interop; - -namespace System.Windows.Forms.PropertyGridInternal.Tests -{ - public class HotCommands_HotCommandsAccessibleObjectTests : IClassFixture - { - [WinFormsFact] - public void HotCommandsAccessibleObject_Ctor_Default() - { - using PropertyGrid propertyGrid = new PropertyGrid(); - using HotCommands hotCommands = new HotCommands(propertyGrid); - HotCommands.HotCommandsAccessibleObject accessibleObject = - new HotCommands.HotCommandsAccessibleObject(hotCommands, propertyGrid); - - Assert.Equal(hotCommands, accessibleObject.Owner); - Assert.False(propertyGrid.IsHandleCreated); - Assert.False(hotCommands.IsHandleCreated); - } - - [WinFormsFact] - public void HotCommandsAccessibleObject_ControlType_IsPane_IfAccessibleRoleIsDefault() - { - using PropertyGrid propertyGrid = new PropertyGrid(); - using HotCommands hotCommands = new HotCommands(propertyGrid); - // AccessibleRole is not set = Default - - object actual = hotCommands.AccessibilityObject.GetPropertyValue(UiaCore.UIA.ControlTypePropertyId); - - Assert.Equal(UiaCore.UIA.PaneControlTypeId, actual); - Assert.False(propertyGrid.IsHandleCreated); - Assert.False(hotCommands.IsHandleCreated); - } - - [WinFormsTheory] - [InlineData(true, AccessibleRole.Client)] - [InlineData(false, AccessibleRole.None)] - public void HotCommandsAccessibleObject_Role_IsExpected_ByDefault(bool createControl, AccessibleRole expectedRole) - { - using PropertyGrid propertyGrid = new PropertyGrid(); - using HotCommands hotCommands = new HotCommands(propertyGrid); - // AccessibleRole is not set = Default - - if (createControl) - { - hotCommands.CreateControl(); - } - - AccessibleRole actual = hotCommands.AccessibilityObject.Role; - - Assert.Equal(expectedRole, actual); - Assert.False(propertyGrid.IsHandleCreated); - Assert.Equal(createControl, hotCommands.IsHandleCreated); - } - } -}