From 3c2c903b292d25e60f9dfb6c933da6e464fa687d Mon Sep 17 00:00:00 2001 From: Klaus Loeffelmann Date: Tue, 30 Jul 2024 18:20:15 -0700 Subject: [PATCH] Convert Window control methods into bindable properties. --- .../src/NativeMethods.txt | 1 + .../src/PublicAPI.Unshipped.txt | 30 +- .../src/Resources/SR.resx | 24 ++ .../src/Resources/xlf/SR.cs.xlf | 40 +++ .../src/Resources/xlf/SR.de.xlf | 40 +++ .../src/Resources/xlf/SR.es.xlf | 40 +++ .../src/Resources/xlf/SR.fr.xlf | 40 +++ .../src/Resources/xlf/SR.it.xlf | 40 +++ .../src/Resources/xlf/SR.ja.xlf | 40 +++ .../src/Resources/xlf/SR.ko.xlf | 40 +++ .../src/Resources/xlf/SR.pl.xlf | 40 +++ .../src/Resources/xlf/SR.pt-BR.xlf | 40 +++ .../src/Resources/xlf/SR.ru.xlf | 40 +++ .../src/Resources/xlf/SR.tr.xlf | 40 +++ .../src/Resources/xlf/SR.zh-Hans.xlf | 40 +++ .../src/Resources/xlf/SR.zh-Hant.xlf | 40 +++ .../src/System/Windows/Forms/Form.cs | 309 ++++++++++++++---- .../Windows/Forms/FormCornerPreference.cs | 33 ++ 18 files changed, 850 insertions(+), 67 deletions(-) create mode 100644 src/System.Windows.Forms/src/System/Windows/Forms/FormCornerPreference.cs diff --git a/src/System.Windows.Forms.Primitives/src/NativeMethods.txt b/src/System.Windows.Forms.Primitives/src/NativeMethods.txt index 0c70a732181..fadc15139e8 100644 --- a/src/System.Windows.Forms.Primitives/src/NativeMethods.txt +++ b/src/System.Windows.Forms.Primitives/src/NativeMethods.txt @@ -108,6 +108,7 @@ DSH_FLAGS DTM_* DTN_* DTS_* +DwmGetWindowAttribute DwmSetWindowAttribute DWM_WINDOW_CORNER_PREFERENCE DuplicateHandle diff --git a/src/System.Windows.Forms/src/PublicAPI.Unshipped.txt b/src/System.Windows.Forms/src/PublicAPI.Unshipped.txt index f69fcbca1ec..1be282acf39 100644 --- a/src/System.Windows.Forms/src/PublicAPI.Unshipped.txt +++ b/src/System.Windows.Forms/src/PublicAPI.Unshipped.txt @@ -4,6 +4,23 @@ static System.Windows.Forms.Application.SetColorMode(System.Windows.Forms.System static System.Windows.Forms.Application.SystemColorMode.get -> System.Windows.Forms.SystemColorMode static System.Windows.Forms.Control.ControlSystemColors.Current.get -> System.Windows.Forms.Control.ControlSystemColors! static System.Windows.Forms.Control.ControlSystemColors.GetAdaptedDarkModeColorFromKnownColor(System.Drawing.KnownColor knownColor, bool darkMode) -> System.Drawing.Color +System.Windows.Forms.Form.FormBorderColor.get -> System.Drawing.Color +System.Windows.Forms.Form.FormBorderColor.set -> void +System.Windows.Forms.Form.FormBorderColorChanged -> System.EventHandler? +System.Windows.Forms.Form.FormCaptionBackColor.get -> System.Drawing.Color +System.Windows.Forms.Form.FormCaptionBackColor.set -> void +System.Windows.Forms.Form.FormCaptionBackColorChanged -> System.EventHandler? +System.Windows.Forms.Form.FormCaptionTextColor.get -> System.Drawing.Color +System.Windows.Forms.Form.FormCaptionTextColor.set -> void +System.Windows.Forms.Form.FormCaptionTextColorChanged -> System.EventHandler? +System.Windows.Forms.Form.FormCornerPreference.get -> System.Windows.Forms.FormCornerPreference +System.Windows.Forms.Form.FormCornerPreference.set -> void +System.Windows.Forms.Form.FormCornerPreferenceChanged -> System.EventHandler? +System.Windows.Forms.FormCornerPreference +System.Windows.Forms.FormCornerPreference.Default = 0 -> System.Windows.Forms.FormCornerPreference +System.Windows.Forms.FormCornerPreference.DoNotRound = 1 -> System.Windows.Forms.FormCornerPreference +System.Windows.Forms.FormCornerPreference.Round = 2 -> System.Windows.Forms.FormCornerPreference +System.Windows.Forms.FormCornerPreference.RoundSmall = 3 -> System.Windows.Forms.FormCornerPreference System.Windows.Forms.SystemColorMode System.Windows.Forms.SystemColorMode.Classic = 0 -> System.Windows.Forms.SystemColorMode System.Windows.Forms.SystemColorMode.Dark = 2 -> System.Windows.Forms.SystemColorMode @@ -21,15 +38,6 @@ System.Windows.Forms.Control.DebuggerBreakCounters.get -> System.Collections.Gen System.Windows.Forms.Control.DebuggerBreakCounters.set -> void System.Windows.Forms.Control.VisualStylesMode.get -> System.Windows.Forms.VisualStylesMode System.Windows.Forms.Control.VisualStylesMode.set -> void -System.Windows.Forms.Form.SetWindowBorderColor(System.Drawing.Color color) -> void -System.Windows.Forms.Form.SetWindowCaptionColor(System.Drawing.Color color) -> void -System.Windows.Forms.Form.SetWindowCaptionTextColor(System.Drawing.Color color) -> void -System.Windows.Forms.Form.SetWindowCornerPreference(System.Windows.Forms.Form.WindowCornerPreference cornerPreference) -> void -System.Windows.Forms.Form.WindowCornerPreference -System.Windows.Forms.Form.WindowCornerPreference.Default = 0 -> System.Windows.Forms.Form.WindowCornerPreference -System.Windows.Forms.Form.WindowCornerPreference.DoNotRound = 1 -> System.Windows.Forms.Form.WindowCornerPreference -System.Windows.Forms.Form.WindowCornerPreference.Round = 2 -> System.Windows.Forms.Form.WindowCornerPreference -System.Windows.Forms.Form.WindowCornerPreference.RoundSmall = 3 -> System.Windows.Forms.Form.WindowCornerPreference System.Windows.Forms.VisualStylesMode System.Windows.Forms.VisualStylesMode.Classic = 0 -> System.Windows.Forms.VisualStylesMode System.Windows.Forms.VisualStylesMode.Disabled = 1 -> System.Windows.Forms.VisualStylesMode @@ -72,3 +80,7 @@ System.Windows.Forms.Control.ControlSystemColors.ScrollBar.get -> System.Drawing System.Windows.Forms.Control.ControlSystemColors.Window.get -> System.Drawing.Color System.Windows.Forms.Control.ControlSystemColors.WindowFrame.get -> System.Drawing.Color System.Windows.Forms.Control.ControlSystemColors.WindowText.get -> System.Drawing.Color +virtual System.Windows.Forms.Form.OnFormBorderColorChanged(System.EventArgs! e) -> void +virtual System.Windows.Forms.Form.OnFormCaptionBackColorChanged(System.EventArgs! e) -> void +virtual System.Windows.Forms.Form.OnFormCaptionTextColorChanged(System.EventArgs! e) -> void +virtual System.Windows.Forms.Form.OnFormCornerPreferenceChanged(System.EventArgs! e) -> void diff --git a/src/System.Windows.Forms/src/Resources/SR.resx b/src/System.Windows.Forms/src/Resources/SR.resx index 17baf149eb9..c77410bbcb4 100644 --- a/src/System.Windows.Forms/src/Resources/SR.resx +++ b/src/System.Windows.Forms/src/Resources/SR.resx @@ -6991,4 +6991,28 @@ Stack trace where the illegal operation occurred was: Dark mode cannot be activated, either because of an activated High-Contrast mode or because the underlying OS does not support it. + + Occurs whenever the FormBorderColor property is changed. + + + Occurs whenever the FormCaptionBackColor property is changed. + + + Occurs whenever the FormCaptionTextColor property is changed. + + + Occurs whenever the FormCornerPreference property is changed. + + + The rounding style of the Form's border. + + + The color of the Form's border. + + + The back color of the Form's caption (title bar). + + + The color of the Form's text caption (title bar text). + \ 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 13eba07f568..f360657edf5 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf @@ -5320,6 +5320,16 @@ Chcete jej nahradit? Aktuální pozice posuvníku automatického posouvání. + + Occurs whenever the FormBorderColor property is changed. + Occurs whenever the FormBorderColor property is changed. + + + + The color of the Form's border. + The color of the Form's border. + + Indicates the appearance and behavior of the border and title bar of the form. Určuje vzhled a chování ohraničení a záhlaví formuláře. @@ -5330,11 +5340,41 @@ Chcete jej nahradit? Stornovací tlačítko formuláře. Je-li tato vlastnost nastavena, dojde k aktivaci tohoto tlačítka vždy, když uživatel stiskne klávesu Esc. + + Occurs whenever the FormCaptionBackColor property is changed. + Occurs whenever the FormCaptionBackColor property is changed. + + + + The back color of the Form's caption (title bar). + The back color of the Form's caption (title bar). + + + + Occurs whenever the FormCaptionTextColor property is changed. + Occurs whenever the FormCaptionTextColor property is changed. + + + + The color of the Form's text caption (title bar text). + The color of the Form's text caption (title bar text). + + Determines whether a form has a Control/System menu box. Určuje, zda má formulář systémovou a řídicí nabídku. + + Occurs whenever the FormCornerPreference property is changed. + Occurs whenever the FormCornerPreference property is changed. + + + + The rounding style of the Form's border. + The rounding style of the Form's border. + + The bounds of this form in desktop coordinates. Okraje tohoto formuláře v souřadnicích plochy. 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 8d3c4697f0f..994bc8b6993 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf @@ -5320,6 +5320,16 @@ Möchten Sie sie ersetzen? Die aktuelle Position der automatischen Schiebeleiste. + + Occurs whenever the FormBorderColor property is changed. + Occurs whenever the FormBorderColor property is changed. + + + + The color of the Form's border. + The color of the Form's border. + + Indicates the appearance and behavior of the border and title bar of the form. Gibt die Darstellung und das Verhalten des Rahmens und der Titelleiste des Formulars an. @@ -5330,11 +5340,41 @@ Möchten Sie sie ersetzen? Die Schaltfläche "Abbrechen" des Formulars. Wenn diese Eigenschaft festgelegt ist, wird auf die Schaltfläche "geklickt", wenn der Benutzer die ESC-Taste drückt. + + Occurs whenever the FormCaptionBackColor property is changed. + Occurs whenever the FormCaptionBackColor property is changed. + + + + The back color of the Form's caption (title bar). + The back color of the Form's caption (title bar). + + + + Occurs whenever the FormCaptionTextColor property is changed. + Occurs whenever the FormCaptionTextColor property is changed. + + + + The color of the Form's text caption (title bar text). + The color of the Form's text caption (title bar text). + + Determines whether a form has a Control/System menu box. Bestimmt, ob ein Formular ein Steuerelement/System-Menüfeld hat. + + Occurs whenever the FormCornerPreference property is changed. + Occurs whenever the FormCornerPreference property is changed. + + + + The rounding style of the Form's border. + The rounding style of the Form's border. + + The bounds of this form in desktop coordinates. Die Begrenzungen dieses Formulars in Desktopkoordinaten. 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 6d976f123eb..37bcf28cc97 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf @@ -5320,6 +5320,16 @@ Do you want to replace it? Posición actual de la barra de desplazamiento automático. + + Occurs whenever the FormBorderColor property is changed. + Occurs whenever the FormBorderColor property is changed. + + + + The color of the Form's border. + The color of the Form's border. + + Indicates the appearance and behavior of the border and title bar of the form. Indica la apariencia y el comportamiento del borde y de la barra de título del formulario. @@ -5330,11 +5340,41 @@ Do you want to replace it? Botón Cancelar del formulario. Si esta propiedad está establecida, se 'hace clic' en el botón cuando el usuario presiona la tecla 'ESC'. + + Occurs whenever the FormCaptionBackColor property is changed. + Occurs whenever the FormCaptionBackColor property is changed. + + + + The back color of the Form's caption (title bar). + The back color of the Form's caption (title bar). + + + + Occurs whenever the FormCaptionTextColor property is changed. + Occurs whenever the FormCaptionTextColor property is changed. + + + + The color of the Form's text caption (title bar text). + The color of the Form's text caption (title bar text). + + Determines whether a form has a Control/System menu box. Determina si el formulario tiene un cuadro de menú Control o Sistema. + + Occurs whenever the FormCornerPreference property is changed. + Occurs whenever the FormCornerPreference property is changed. + + + + The rounding style of the Form's border. + The rounding style of the Form's border. + + The bounds of this form in desktop coordinates. Límites de este formulario en coordenadas del escritorio. 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 aa077a0e786..8f66ddb098d 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf @@ -5320,6 +5320,16 @@ Voulez-vous le remplacer ? La position actuelle de la barre de défilement automatique. + + Occurs whenever the FormBorderColor property is changed. + Occurs whenever the FormBorderColor property is changed. + + + + The color of the Form's border. + The color of the Form's border. + + Indicates the appearance and behavior of the border and title bar of the form. Indique l'apparence et le comportement de la bordure et de la barre de titre du formulaire. @@ -5330,11 +5340,41 @@ Voulez-vous le remplacer ? Le bouton d'annulation de ce formulaire. Si cette propriété est définie, le bouton est "cliqué" lorsque l'utilisateur appuie sur la touche "ÉCHAP". + + Occurs whenever the FormCaptionBackColor property is changed. + Occurs whenever the FormCaptionBackColor property is changed. + + + + The back color of the Form's caption (title bar). + The back color of the Form's caption (title bar). + + + + Occurs whenever the FormCaptionTextColor property is changed. + Occurs whenever the FormCaptionTextColor property is changed. + + + + The color of the Form's text caption (title bar text). + The color of the Form's text caption (title bar text). + + Determines whether a form has a Control/System menu box. Détermine si un formulaire a un menu Système. + + Occurs whenever the FormCornerPreference property is changed. + Occurs whenever the FormCornerPreference property is changed. + + + + The rounding style of the Form's border. + The rounding style of the Form's border. + + The bounds of this form in desktop coordinates. Les limites de ce formulaire en coordonnées du bureau. 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 8d8678c8e27..2b94b17ba43 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf @@ -5320,6 +5320,16 @@ Sostituirlo? La posizione corrente della barra di scorrimento automatico. + + Occurs whenever the FormBorderColor property is changed. + Occurs whenever the FormBorderColor property is changed. + + + + The color of the Form's border. + The color of the Form's border. + + Indicates the appearance and behavior of the border and title bar of the form. Indica l'aspetto e il comportamento del bordo e della barra del titolo del form. @@ -5330,11 +5340,41 @@ Sostituirlo? Il pulsante di annullamento del form. Se la proprietà viene impostata, il pulsante verrà scelto ogni volta che l'utente premerà ESC. + + Occurs whenever the FormCaptionBackColor property is changed. + Occurs whenever the FormCaptionBackColor property is changed. + + + + The back color of the Form's caption (title bar). + The back color of the Form's caption (title bar). + + + + Occurs whenever the FormCaptionTextColor property is changed. + Occurs whenever the FormCaptionTextColor property is changed. + + + + The color of the Form's text caption (title bar text). + The color of the Form's text caption (title bar text). + + Determines whether a form has a Control/System menu box. Determina se un form dispone di una casella del menu di sistema/controllo. + + Occurs whenever the FormCornerPreference property is changed. + Occurs whenever the FormCornerPreference property is changed. + + + + The rounding style of the Form's border. + The rounding style of the Form's border. + + The bounds of this form in desktop coordinates. I limiti di questo form in coordinate desktop. 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 9fe7c9754fb..fb693843362 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf @@ -5320,6 +5320,16 @@ Do you want to replace it? 自動スクロール機能のスクロール バーの現在の位置です。 + + Occurs whenever the FormBorderColor property is changed. + Occurs whenever the FormBorderColor property is changed. + + + + The color of the Form's border. + The color of the Form's border. + + Indicates the appearance and behavior of the border and title bar of the form. フォームの境界線およびタイトル バーの、外観および動作を示します。 @@ -5330,11 +5340,41 @@ Do you want to replace it? フォームの [キャンセル] ボタンです。このプロパティを設定すると、ユーザーが Esc キーを押すたびに、ボタンがクリックされます。 + + Occurs whenever the FormCaptionBackColor property is changed. + Occurs whenever the FormCaptionBackColor property is changed. + + + + The back color of the Form's caption (title bar). + The back color of the Form's caption (title bar). + + + + Occurs whenever the FormCaptionTextColor property is changed. + Occurs whenever the FormCaptionTextColor property is changed. + + + + The color of the Form's text caption (title bar text). + The color of the Form's text caption (title bar text). + + Determines whether a form has a Control/System menu box. フォームにコントロール/システム メニュー ボックスを加えるかどうかを決定します。 + + Occurs whenever the FormCornerPreference property is changed. + Occurs whenever the FormCornerPreference property is changed. + + + + The rounding style of the Form's border. + The rounding style of the Form's border. + + The bounds of this form in desktop coordinates. デスクトップ座標でのこのフォームの境界線です。 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 f75dcaaaa6b..3c50714afbc 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf @@ -5320,6 +5320,16 @@ Do you want to replace it? 자동으로 스크롤되는 스크롤 막대의 현재 위치입니다. + + Occurs whenever the FormBorderColor property is changed. + Occurs whenever the FormBorderColor property is changed. + + + + The color of the Form's border. + The color of the Form's border. + + Indicates the appearance and behavior of the border and title bar of the form. 폼의 테두리 및 제목 표시줄의 모양과 동작을 나타냅니다. @@ -5330,11 +5340,41 @@ Do you want to replace it? 폼의 취소 단추입니다. 이 속성을 설정하면 <Esc> 키를 누를 때마다 단추가 '클릭'됩니다. + + Occurs whenever the FormCaptionBackColor property is changed. + Occurs whenever the FormCaptionBackColor property is changed. + + + + The back color of the Form's caption (title bar). + The back color of the Form's caption (title bar). + + + + Occurs whenever the FormCaptionTextColor property is changed. + Occurs whenever the FormCaptionTextColor property is changed. + + + + The color of the Form's text caption (title bar text). + The color of the Form's text caption (title bar text). + + Determines whether a form has a Control/System menu box. 폼에 컨트롤/시스템 메뉴 상자를 포함할지 여부를 결정합니다. + + Occurs whenever the FormCornerPreference property is changed. + Occurs whenever the FormCornerPreference property is changed. + + + + The rounding style of the Form's border. + The rounding style of the Form's border. + + The bounds of this form in desktop coordinates. 데스크톱 좌표로 표시한 이 폼의 범위입니다. 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 ad82fb94aae..0ebe632b23e 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf @@ -5320,6 +5320,16 @@ Czy chcesz go zamienić? Bieżąca pozycja paska przewijania automatycznego. + + Occurs whenever the FormBorderColor property is changed. + Occurs whenever the FormBorderColor property is changed. + + + + The color of the Form's border. + The color of the Form's border. + + Indicates the appearance and behavior of the border and title bar of the form. Wskazuje wygląd i zachowanie obramowania i paska tytułu formularza. @@ -5330,11 +5340,41 @@ Czy chcesz go zamienić? Przycisk anulowania formularza. Gdy ta właściwość jest ustawiona, to przycisk jest „kliknięty” przy każdym naciśnięciu klawisza ESC. + + Occurs whenever the FormCaptionBackColor property is changed. + Occurs whenever the FormCaptionBackColor property is changed. + + + + The back color of the Form's caption (title bar). + The back color of the Form's caption (title bar). + + + + Occurs whenever the FormCaptionTextColor property is changed. + Occurs whenever the FormCaptionTextColor property is changed. + + + + The color of the Form's text caption (title bar text). + The color of the Form's text caption (title bar text). + + Determines whether a form has a Control/System menu box. Określa, czy w formularzu znajduje się pole menu systemowego/sterowania. + + Occurs whenever the FormCornerPreference property is changed. + Occurs whenever the FormCornerPreference property is changed. + + + + The rounding style of the Form's border. + The rounding style of the Form's border. + + The bounds of this form in desktop coordinates. Granice formularza we współrzędnych pulpitu. 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 7ffc891ac25..cbab581dbfb 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 @@ -5320,6 +5320,16 @@ Deseja substituí-lo? A posição atual da barra de rolagem automática. + + Occurs whenever the FormBorderColor property is changed. + Occurs whenever the FormBorderColor property is changed. + + + + The color of the Form's border. + The color of the Form's border. + + Indicates the appearance and behavior of the border and title bar of the form. Indica a aparência e o comportamento da borda e da barra de títulos do formulário. @@ -5330,11 +5340,41 @@ Deseja substituí-lo? O botão para cancelar do formulário. Se esta propriedade estiver definida, o botão será 'clicado' sempre que o usuário pressionar a tecla 'ESC'. + + Occurs whenever the FormCaptionBackColor property is changed. + Occurs whenever the FormCaptionBackColor property is changed. + + + + The back color of the Form's caption (title bar). + The back color of the Form's caption (title bar). + + + + Occurs whenever the FormCaptionTextColor property is changed. + Occurs whenever the FormCaptionTextColor property is changed. + + + + The color of the Form's text caption (title bar text). + The color of the Form's text caption (title bar text). + + Determines whether a form has a Control/System menu box. Determina se um formulário tem uma caixa de menu Controle/Sistema. + + Occurs whenever the FormCornerPreference property is changed. + Occurs whenever the FormCornerPreference property is changed. + + + + The rounding style of the Form's border. + The rounding style of the Form's border. + + The bounds of this form in desktop coordinates. Os limites deste formulário nas coordenadas da área de trabalho. 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 f314cc968d9..3d30102e4f7 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf @@ -5321,6 +5321,16 @@ Do you want to replace it? Текущее положение автоматической полосы прокрутки. + + Occurs whenever the FormBorderColor property is changed. + Occurs whenever the FormBorderColor property is changed. + + + + The color of the Form's border. + The color of the Form's border. + + Indicates the appearance and behavior of the border and title bar of the form. Определяет внешний вид и поведение границы и строки заголовка данной формы. @@ -5331,11 +5341,41 @@ Do you want to replace it? Кнопка отмены для данной формы. Если это свойство задано, можно сделать нажатие клавиши ESC эквивалентным нажатию этой кнопки. + + Occurs whenever the FormCaptionBackColor property is changed. + Occurs whenever the FormCaptionBackColor property is changed. + + + + The back color of the Form's caption (title bar). + The back color of the Form's caption (title bar). + + + + Occurs whenever the FormCaptionTextColor property is changed. + Occurs whenever the FormCaptionTextColor property is changed. + + + + The color of the Form's text caption (title bar text). + The color of the Form's text caption (title bar text). + + Determines whether a form has a Control/System menu box. Определяет, содержит ли форма значок меню окна/системного меню. + + Occurs whenever the FormCornerPreference property is changed. + Occurs whenever the FormCornerPreference property is changed. + + + + The rounding style of the Form's border. + The rounding style of the Form's border. + + The bounds of this form in desktop coordinates. Привязки данной формы в координатах рабочего стола. 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 fcd82b97dc4..008238d8a8a 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf @@ -5320,6 +5320,16 @@ Bunu değiştirmek istiyor musunuz? Otomatik kayan kaydırma çubuğunun geçerli konumu. + + Occurs whenever the FormBorderColor property is changed. + Occurs whenever the FormBorderColor property is changed. + + + + The color of the Form's border. + The color of the Form's border. + + Indicates the appearance and behavior of the border and title bar of the form. Formun kenarlığının ve başlık çubuğunun görünümünü ve davranışını gösterir. @@ -5330,11 +5340,41 @@ Bunu değiştirmek istiyor musunuz? Formun iptal düğmesi. Bu özellik ayarlıysa, kullanıcı 'ESC' tuşuna her bastığında düğme 'tıklatılır'. + + Occurs whenever the FormCaptionBackColor property is changed. + Occurs whenever the FormCaptionBackColor property is changed. + + + + The back color of the Form's caption (title bar). + The back color of the Form's caption (title bar). + + + + Occurs whenever the FormCaptionTextColor property is changed. + Occurs whenever the FormCaptionTextColor property is changed. + + + + The color of the Form's text caption (title bar text). + The color of the Form's text caption (title bar text). + + Determines whether a form has a Control/System menu box. Formun Denetim/Sistem menüsü kutusu olup olmadığını belirler. + + Occurs whenever the FormCornerPreference property is changed. + Occurs whenever the FormCornerPreference property is changed. + + + + The rounding style of the Form's border. + The rounding style of the Form's border. + + The bounds of this form in desktop coordinates. Bu formun sınırları (masaüstü koordinatlarında). 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 312bf9fbb7b..9cd2f57b0ab 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 @@ -5320,6 +5320,16 @@ Do you want to replace it? 自动滚动的滚动条的当前位置。 + + Occurs whenever the FormBorderColor property is changed. + Occurs whenever the FormBorderColor property is changed. + + + + The color of the Form's border. + The color of the Form's border. + + Indicates the appearance and behavior of the border and title bar of the form. 指示窗体的边框和标题栏的外观和行为。 @@ -5330,11 +5340,41 @@ Do you want to replace it? 窗体的“取消”按钮。如果设置该属性,每次用户按“Esc”键都相当于“单击”了该按钮。 + + Occurs whenever the FormCaptionBackColor property is changed. + Occurs whenever the FormCaptionBackColor property is changed. + + + + The back color of the Form's caption (title bar). + The back color of the Form's caption (title bar). + + + + Occurs whenever the FormCaptionTextColor property is changed. + Occurs whenever the FormCaptionTextColor property is changed. + + + + The color of the Form's text caption (title bar text). + The color of the Form's text caption (title bar text). + + Determines whether a form has a Control/System menu box. 确定窗体是否有“控件/系统”菜单框。 + + Occurs whenever the FormCornerPreference property is changed. + Occurs whenever the FormCornerPreference property is changed. + + + + The rounding style of the Form's border. + The rounding style of the Form's border. + + The bounds of this form in desktop coordinates. 此窗体在桌面坐标中的边界。 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 428947db7a2..d53317ee08a 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 @@ -5320,6 +5320,16 @@ Do you want to replace it? 自動捲動捲軸目前的位置。 + + Occurs whenever the FormBorderColor property is changed. + Occurs whenever the FormBorderColor property is changed. + + + + The color of the Form's border. + The color of the Form's border. + + Indicates the appearance and behavior of the border and title bar of the form. 表示表單框線和標題列的外觀和行為。 @@ -5330,11 +5340,41 @@ Do you want to replace it? 表單的取消按鈕。如果設定此屬性,當使用者按下 'ESC' 鍵時就代表「已按下」該按鈕。 + + Occurs whenever the FormCaptionBackColor property is changed. + Occurs whenever the FormCaptionBackColor property is changed. + + + + The back color of the Form's caption (title bar). + The back color of the Form's caption (title bar). + + + + Occurs whenever the FormCaptionTextColor property is changed. + Occurs whenever the FormCaptionTextColor property is changed. + + + + The color of the Form's text caption (title bar text). + The color of the Form's text caption (title bar text). + + Determines whether a form has a Control/System menu box. 決定表單是否有系統控制功能表方塊。 + + Occurs whenever the FormCornerPreference property is changed. + Occurs whenever the FormCornerPreference property is changed. + + + + The rounding style of the Form's border. + The rounding style of the Form's border. + + The bounds of this form in desktop coordinates. 此表單在桌面座標中的界限。 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 4507a4d9361..e46ae1d4d5d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs @@ -47,6 +47,10 @@ public partial class Form : ContainerControl private static readonly object s_resizeEndEvent = new(); private static readonly object s_rightToLeftLayoutChangedEvent = new(); private static readonly object s_dpiChangedEvent = new(); + private static readonly object s_formBorderColorChanged = new(); + private static readonly object s_formCaptionBackColorChanged = new(); + private static readonly object s_formCaptionTextColorChanged = new(); + private static readonly object s_formCornerPreferenceChanged = new(); // // The following flags should be used with formState[..] not formStateEx[..] @@ -131,6 +135,11 @@ public partial class Form : ContainerControl private static readonly int s_propOpacity = PropertyStore.CreateKey(); private static readonly int s_propTransparencyKey = PropertyStore.CreateKey(); + private static readonly int s_propFormBorderColor = PropertyStore.CreateKey(); + private static readonly int s_propFormCaptionBackColor = PropertyStore.CreateKey(); + + private static readonly int s_propFormCaptionTextColor = PropertyStore.CreateKey(); + private static readonly int s_propFormCornerPreference = PropertyStore.CreateKey(); // Form per instance members // Note: Do not add anything to this list unless absolutely necessary. @@ -161,14 +170,6 @@ public partial class Form : ContainerControl private bool _processingDpiChanged; private bool _inRecreateHandle; - public enum WindowCornerPreference - { - Default = DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_DEFAULT, - DoNotRound = DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_DONOTROUND, - Round = DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUND, - RoundSmall = DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUNDSMALL - } - /// /// Initializes a new instance of the class. /// @@ -2342,30 +2343,67 @@ protected override void SetVisibleCore(bool value) } /// - /// Sets the rounding style of the corners of this Form. + /// Sets or gets the rounding style of the corners using the enum. /// - /// - /// A value of the enum - /// which determines the corner rounding style. - /// - public void SetWindowCornerPreference(WindowCornerPreference cornerPreference) + [DefaultValue(FormCornerPreference.Default)] + [SRCategory(nameof(SR.CatWindowStyle))] + [SRDescription(nameof(SR.FormCornerPreferenceDescr))] + public FormCornerPreference FormCornerPreference { - SetWindowCornerPreferenceInternal(cornerPreference); + get + { + if (Properties.ContainsInteger(s_propFormCornerPreference)) + { + return (FormCornerPreference)Properties.GetInteger(s_propFormCornerPreference); + } + + return FormCornerPreference.Default; + } + set + { + if (value == FormCornerPreference) + { + return; + } + + if (value == FormCornerPreference.Default) + { + Properties.RemoveObject(s_propFormCornerPreference); + } + else + { + Properties.SetInteger(s_propFormCornerPreference, (int)value); + } + + if (IsHandleCreated) + { + SetFormCornerPreferenceInternal(value); + } + + OnFormCornerPreferenceChanged(EventArgs.Empty); + } } - private unsafe void SetWindowCornerPreferenceInternal(WindowCornerPreference cornerPreference) + /// + /// Raises the event when the + /// property changes. + /// + protected virtual void OnFormCornerPreferenceChanged(EventArgs e) { - if (!IsHandleCreated) + if (Events[s_formCornerPreferenceChanged] is EventHandler eventHandler) { - return; + eventHandler(this, e); } + } + private unsafe void SetFormCornerPreferenceInternal(FormCornerPreference cornerPreference) + { DWM_WINDOW_CORNER_PREFERENCE dwmCornerPreference = cornerPreference switch { - WindowCornerPreference.Default => DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_DEFAULT, - WindowCornerPreference.DoNotRound => DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_DONOTROUND, - WindowCornerPreference.Round => DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUND, - WindowCornerPreference.RoundSmall => DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUNDSMALL, + FormCornerPreference.Default => DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_DEFAULT, + FormCornerPreference.DoNotRound => DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_DONOTROUND, + FormCornerPreference.Round => DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUND, + FormCornerPreference.RoundSmall => DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUNDSMALL, _ => throw new ArgumentOutOfRangeException(nameof(cornerPreference)) }; @@ -2377,76 +2415,187 @@ private unsafe void SetWindowCornerPreferenceInternal(WindowCornerPreference cor } /// - /// Sets the color of the border of this Form. + /// Sets or gets the Form's border color. /// - /// The border color. - public void SetWindowBorderColor(Color color) + [SRCategory(nameof(SR.CatWindowStyle))] + [SRDescription(nameof(SR.FormBorderColorDescr))] + [DefaultValue(typeof(Color), "Empty")] + public Color FormBorderColor { - SetWindowBorderColorInternal(color); + get + { + if (Properties.ContainsObject(s_propFormBorderColor)) + { + return Properties.GetColor(s_propFormBorderColor); + } + else + { + if (!IsHandleCreated || IsAncestorSiteInDesignMode) + { + return Color.Empty; + } + + return GetFormAttributeColorInternal(DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR); + } + } + set + { + if (value == FormBorderColor) + { + return; + } + + if (!IsHandleCreated) + { + Properties.SetColor(s_propFormBorderColor, value); + return; + } + + Properties.SetColor(s_propFormBorderColor, value); + SetFormAttributeColorInternal(DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR, value); + OnFormBorderColorChanged(EventArgs.Empty); + } } - private unsafe void SetWindowBorderColorInternal(Color color) + /// + /// Raises the event when the property changes. + /// + protected virtual void OnFormBorderColorChanged(EventArgs e) { - if (!IsHandleCreated) + if (Events[s_formBorderColorChanged] is EventHandler eventHandler) { - return; + eventHandler(this, e); } + } - COLORREF colorRef = color; + /// + /// Sets or gets the Form's title bar back color. + /// + [SRCategory(nameof(SR.CatWindowStyle))] + [SRDescription(nameof(SR.FormCaptionBackColorDescr))] + [DefaultValue(typeof(Color), "Empty")] + public Color FormCaptionBackColor + { + get + { + if (Properties.ContainsObject(s_propFormCaptionBackColor)) + { + return Properties.GetColor(s_propFormCaptionBackColor); + } + else + { + if (!IsHandleCreated || IsAncestorSiteInDesignMode) + { + return Color.Empty; + } - PInvoke.DwmSetWindowAttribute( - HWND, - DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR, - &colorRef, - (uint)sizeof(COLORREF)); + return GetFormAttributeColorInternal(DWMWINDOWATTRIBUTE.DWMWA_CAPTION_COLOR); + } + } + set + { + if (value == FormCaptionBackColor) + { + return; + } + + if (!IsHandleCreated) + { + Properties.SetColor(s_propFormCaptionBackColor, value); + return; + } + + Properties.SetColor(s_propFormCaptionBackColor, value); + SetFormAttributeColorInternal(DWMWINDOWATTRIBUTE.DWMWA_CAPTION_COLOR, value); + OnFormCaptionBackColorChanged(EventArgs.Empty); + } } /// - /// Sets the color of the title bar of this Form containing the caption and control buttons. + /// Raises the event when the property changes. /// - /// The title bar color. - public void SetWindowCaptionColor(Color color) + protected virtual void OnFormCaptionBackColorChanged(EventArgs e) { - SetWindowCaptionColorInternal(color); + if (Events[s_formCaptionBackColorChanged] is EventHandler eventHandler) + { + eventHandler(this, e); + } } - private unsafe void SetWindowCaptionColorInternal(Color color) + /// + /// Sets or gets the Form's title bar back color. + /// + [SRCategory(nameof(SR.CatWindowStyle))] + [SRDescription(nameof(SR.FormCaptionTextColorDescr))] + [DefaultValue(typeof(Color), "Empty")] + public Color FormCaptionTextColor { - if (!IsHandleCreated) + get { - return; + if (Properties.ContainsObject(s_propFormCaptionTextColor)) + { + return Properties.GetColor(s_propFormCaptionTextColor); + } + else + { + if (!IsHandleCreated || IsAncestorSiteInDesignMode) + { + return Color.Empty; + } + + return GetFormAttributeColorInternal(DWMWINDOWATTRIBUTE.DWMWA_TEXT_COLOR); + } } + set + { + if (value == FormCaptionTextColor) + { + return; + } - COLORREF colorRef = color; + if (!IsHandleCreated) + { + Properties.SetColor(s_propFormCaptionTextColor, value); + return; + } - PInvoke.DwmSetWindowAttribute( - HWND, - DWMWINDOWATTRIBUTE.DWMWA_CAPTION_COLOR, - &colorRef, - (uint)sizeof(COLORREF)); + Properties.SetColor(s_propFormCaptionTextColor, value); + SetFormAttributeColorInternal(DWMWINDOWATTRIBUTE.DWMWA_TEXT_COLOR, value); + OnFormCaptionTextColorChanged(EventArgs.Empty); + } } /// - /// Sets the color of the text in the title bar of this Form. + /// Raises the event when the property changes. /// - /// The text color of the title bar. - public void SetWindowCaptionTextColor(Color color) + protected virtual void OnFormCaptionTextColorChanged(EventArgs e) { - SetWindowCaptionTextColorInternal(color); + if (Events[s_formCaptionBackColorChanged] is EventHandler eventHandler) + { + eventHandler(this, e); + } } - private unsafe void SetWindowCaptionTextColorInternal(Color color) + private unsafe Color GetFormAttributeColorInternal(DWMWINDOWATTRIBUTE dmwWindowAttribute) { - if (!IsHandleCreated) - { - return; - } + COLORREF colorRef; + + PInvoke.DwmSetWindowAttribute( + HWND, + dmwWindowAttribute, + &colorRef, + (uint)sizeof(COLORREF)); + + return colorRef; + } + private unsafe void SetFormAttributeColorInternal(DWMWINDOWATTRIBUTE dmwWindowAttribute, Color color) + { COLORREF colorRef = color; PInvoke.DwmSetWindowAttribute( HWND, - DWMWINDOWATTRIBUTE.DWMWA_TEXT_COLOR, + dmwWindowAttribute, &colorRef, (uint)sizeof(COLORREF)); } @@ -2582,6 +2731,50 @@ public event FormClosingEventHandler? FormClosing remove => Events.RemoveHandler(s_formClosingEvent, value); } + /// + /// Occurs when the property has changed. + /// + [SRCategory(nameof(SR.CatAppearance))] + [SRDescription(nameof(SR.FormBorderColorChangedDescr))] + public event EventHandler? FormBorderColorChanged + { + add => Events.AddHandler(s_formBorderColorChanged, value); + remove => Events.RemoveHandler(s_formBorderColorChanged, value); + } + + /// + /// Occurs when the property has changed. + /// + [SRCategory(nameof(SR.CatAppearance))] + [SRDescription(nameof(SR.FormCaptionBackColorChangedDescr))] + public event EventHandler? FormCaptionBackColorChanged + { + add => Events.AddHandler(s_formCaptionBackColorChanged, value); + remove => Events.RemoveHandler(s_formCaptionBackColorChanged, value); + } + + /// + /// Occurs when the property has changed. + /// + [SRCategory(nameof(SR.CatAppearance))] + [SRDescription(nameof(SR.FormCaptionTextColorChangedDescr))] + public event EventHandler? FormCaptionTextColorChanged + { + add => Events.AddHandler(s_formCaptionTextColorChanged, value); + remove => Events.RemoveHandler(s_formCaptionTextColorChanged, value); + } + + /// + /// Occurs when the property has changed. + /// + [SRCategory(nameof(SR.CatAppearance))] + [SRDescription(nameof(SR.FormCornerPreferenceChangedDescr))] + public event EventHandler? FormCornerPreferenceChanged + { + add => Events.AddHandler(s_formCornerPreferenceChanged, value); + remove => Events.RemoveHandler(s_formCornerPreferenceChanged, value); + } + /// /// Occurs when the form is closed. /// diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FormCornerPreference.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FormCornerPreference.cs new file mode 100644 index 00000000000..77edb3be1c2 --- /dev/null +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FormCornerPreference.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 Windows.Win32.Graphics.Dwm; + +namespace System.Windows.Forms; + +/// +/// Specifies the corner preference for a which can be +/// set using the property. +/// +public enum FormCornerPreference +{ + /// + /// The default corner preference. + /// + Default = DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_DEFAULT, + + /// + /// Do not round the corners of the form window. + /// + DoNotRound = DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_DONOTROUND, + + /// + /// Round the corners of the form window. + /// + Round = DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUND, + + /// + /// Round the corners of the form window with a small radius. + /// + RoundSmall = DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUNDSMALL +}