-
-
Notifications
You must be signed in to change notification settings - Fork 940
feat(controls): Add TitleBar CenterContent property
#1484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
93661a4
04f1c13
41e575d
821e785
ca36d66
6366d69
8005959
db3dd2a
bd437ae
4aa9aeb
cf04daf
4124f63
513d1a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -66,6 +66,16 @@ public partial class TitleBar : System.Windows.Controls.Control, IThemeControl | |||||
| new PropertyMetadata(null) | ||||||
| ); | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// Property for <see cref="CenterContent"/>. | ||||||
| /// </summary> | ||||||
| public static readonly DependencyProperty CenterContentProperty = DependencyProperty.Register( | ||||||
| nameof(CenterContent), | ||||||
| typeof(object), | ||||||
| typeof(TitleBar), | ||||||
| new PropertyMetadata(null) | ||||||
| ); | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// Property for <see cref="TrailingContent"/>. | ||||||
| /// </summary> | ||||||
|
|
@@ -233,6 +243,15 @@ public object? Header | |||||
| set => SetValue(HeaderProperty, value); | ||||||
| } | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// Gets or sets the content displayed in the center of the <see cref="TitleBar"/>. | ||||||
| /// </summary> | ||||||
| public object? CenterContent | ||||||
| { | ||||||
| get => GetValue(CenterContentProperty); | ||||||
| set => SetValue(CenterContentProperty, value); | ||||||
| } | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// Gets or sets the content displayed in right side of the <see cref="TitleBar"/>. | ||||||
| /// </summary> | ||||||
|
|
@@ -683,37 +702,23 @@ or PInvoke.WM_NCLBUTTONUP | |||||
| bool isMouseOverHeaderContent = false; | ||||||
| IntPtr htResult = (IntPtr)PInvoke.HTNOWHERE; | ||||||
|
|
||||||
| if (message == PInvoke.WM_NCHITTEST) | ||||||
| { | ||||||
| if (TrailingContent is UIElement || Header is UIElement) | ||||||
| { | ||||||
| UIElement? headerRightUiElement = TrailingContent as UIElement; | ||||||
|
|
||||||
| if (Header is UIElement headerLeftUIElement && headerLeftUIElement != _titleBlock) | ||||||
| { | ||||||
| isMouseOverHeaderContent = | ||||||
| headerLeftUIElement.IsMouseOverElement(lParam) | ||||||
| || (headerRightUiElement?.IsMouseOverElement(lParam) ?? false); | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| isMouseOverHeaderContent = headerRightUiElement?.IsMouseOverElement(lParam) ?? false; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| htResult = GetWindowBorderHitTestResult(hwnd, lParam); | ||||||
| } | ||||||
| if (message == PInvoke.WM_NCHITTEST) | ||||||
| { | ||||||
| if (TrailingContent is UIElement || Header is UIElement || CenterContent is UIElement) | ||||||
| { | ||||||
| UIElement? headerLeftUIElement = Header as UIElement; | ||||||
| UIElement? headerCenterUIElement = CenterContent as UIElement; | ||||||
| UIElement? headerRightUiElement = TrailingContent as UIElement; | ||||||
|
|
||||||
| var e = new HwndProcEventArgs(hwnd, msg, wParam, lParam, isMouseOverHeaderContent); | ||||||
| WndProcInvoked?.Invoke(this, e); | ||||||
| isMouseOverHeaderContent = (headerLeftUIElement is not null && headerLeftUIElement != _titleBlock && headerLeftUIElement.IsMouseOverElement(lParam)) | ||||||
| || (headerCenterUIElement?.IsMouseOverElement(lParam) ?? false) | ||||||
| || (headerRightUiElement?.IsMouseOverElement(lParam) ?? false); | ||||||
| } | ||||||
|
|
||||||
| if (e.ReturnValue != null) | ||||||
| { | ||||||
| handled = e.Handled; | ||||||
| return e.ReturnValue ?? IntPtr.Zero; | ||||||
| } | ||||||
| htResult = GetWindowBorderHitTestResult(hwnd, lParam); | ||||||
| } | ||||||
|
||||||
|
|
||||||
| switch (message) | ||||||
| switch (message) | ||||||
|
||||||
| switch (message) | |
| switch (message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Uh oh!
There was an error while loading. Please reload this page.