-
-
Notifications
You must be signed in to change notification settings - Fork 780
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
Added new icon element (and markup) - DrawingBrushIcon. New constants for NavigationLeftCompact #1061
base: main
Are you sure you want to change the base?
Added new icon element (and markup) - DrawingBrushIcon. New constants for NavigationLeftCompact #1061
Changes from 7 commits
abf17e6
d86b0c5
9281c43
7d1a0f2
df9ee46
5aa126e
4cb69eb
e90f5f0
c59d8f6
ef1f7eb
3e2d042
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 | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,70 @@ | ||||||||
// This Source Code Form is subject to the terms of the MIT License. | ||||||||
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||||||||
// Copyright (C) Leszek Pomianowski and WPF UI Contributors. | ||||||||
// All Rights Reserved. | ||||||||
|
||||||||
Check warning on line 5 in src/Wpf.Ui/Controls/IconElement/DrawingBrushIcon.cs GitHub Actions / build
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
using System.Windows.Controls; | ||||||||
|
||||||||
namespace Wpf.Ui.Controls; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
public class DrawingBrushIcon : IconElement | ||||||||
Check warning on line 10 in src/Wpf.Ui/Controls/IconElement/DrawingBrushIcon.cs GitHub Actions / build
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing docs for the public API |
||||||||
{ | ||||||||
public DrawingBrush Icon | ||||||||
{ | ||||||||
get { return (DrawingBrush)GetValue(IconProperty); } | ||||||||
set { SetValue(IconProperty, value); } | ||||||||
} | ||||||||
|
||||||||
public static readonly DependencyProperty IconProperty = | ||||||||
DependencyProperty.Register("Icon", typeof(DrawingBrush), typeof(DrawingBrushIcon), new PropertyMetadata(default(DrawingBrush), OnIconChanged)); | ||||||||
|
||||||||
private static void OnIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | ||||||||
{ | ||||||||
var self = (DrawingBrushIcon)d; | ||||||||
if (self.Border is null) | ||||||||
return; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing brackets according to the .editorconfig |
||||||||
|
||||||||
self.Border.Background = e.NewValue as DrawingBrush; | ||||||||
} | ||||||||
|
||||||||
public double Size | ||||||||
{ | ||||||||
get { return (double)GetValue(SizeProperty); } | ||||||||
set { SetValue(SizeProperty, value); } | ||||||||
} | ||||||||
|
||||||||
// Using a DependencyProperty as the backing store for IconSize. This enables animation, styling, binding, etc... | ||||||||
public static readonly DependencyProperty SizeProperty = | ||||||||
DependencyProperty.Register("Size", typeof(double), typeof(DrawingBrushIcon), new PropertyMetadata(16.0, OnIconSizeChanged)); | ||||||||
|
||||||||
private static void OnIconSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | ||||||||
{ | ||||||||
var self = (DrawingBrushIcon)d; | ||||||||
if (self.Border is null) | ||||||||
return; | ||||||||
|
||||||||
if (double.TryParse(e.NewValue?.ToString(), out double dblValue)) | ||||||||
{ | ||||||||
self.Border.Width = dblValue; | ||||||||
self.Border.Height = dblValue; | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
protected Border? Border; | ||||||||
|
||||||||
protected override UIElement InitializeChildren() | ||||||||
{ | ||||||||
Border = new Border() | ||||||||
{ | ||||||||
HorizontalAlignment = HorizontalAlignment.Stretch, | ||||||||
Background = Icon, | ||||||||
Width = Size, | ||||||||
Height = Size | ||||||||
}; | ||||||||
|
||||||||
Viewbox viewbox = new Viewbox(); | ||||||||
viewbox.Child = Border; | ||||||||
|
||||||||
return viewbox; | ||||||||
} | ||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,24 @@ | |
xmlns:converters="clr-namespace:Wpf.Ui.Converters" | ||
xmlns:system="clr-namespace:System;assembly=mscorlib"> | ||
|
||
<!--#region navigation leftConstants --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dont use regions |
||
<!--<system:Double x:Key="PaneToggleButtonHeight">40</system:Double> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove if not needed |
||
<system:Double x:Key="PaneToggleButtonWidth">40</system:Double>--> | ||
<system:Double x:Key="NavigationViewLeftIconSize">12</system:Double> | ||
<system:Double x:Key="NavigationViewItemActiveRectangleHeight">16</system:Double> | ||
<system:Double x:Key="PaneLeftButtonHeight">40</system:Double> | ||
<system:Double x:Key="PaneLeftButtonWidth">40</system:Double> | ||
<!--#endregion navigation leftConstants --> | ||
|
||
<system:Double x:Key="NavigationViewFluentIconSize">24</system:Double> | ||
<system:Double x:Key="PaneToggleButtonHeight">40</system:Double> | ||
<system:Double x:Key="PaneToggleButtonWidth">40</system:Double> | ||
<system:Double x:Key="PaneFluentButtonHeight">60</system:Double> | ||
<system:Double x:Key="PaneFluentButtonWidth">60</system:Double> | ||
<system:Double x:Key="NavigationViewItemChevronSize">12</system:Double> | ||
<Thickness x:Key="PaneToggleButtonThickness">1,1,1,1</Thickness> | ||
|
||
|
||
|
||
<converters:BackButtonVisibilityToVisibilityConverter x:Key="BackButtonVisibilityToVisibilityConverter" /> | ||
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||
// Copyright (C) Leszek Pomianowski and WPF UI Contributors. | ||
// All Rights Reserved. | ||
|
||
using System.Windows.Markup; | ||
using Wpf.Ui.Controls; | ||
|
||
namespace Wpf.Ui.Markup; | ||
|
||
[ContentProperty(nameof(Icon))] | ||
[MarkupExtensionReturnType(typeof(DrawingBrushIcon))] | ||
public class DrawingBrushIconExtension : MarkupExtension | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Formatting |
||
public DrawingBrushIconExtension(DrawingBrush icon) | ||
{ | ||
Icon = icon; | ||
} | ||
public DrawingBrushIconExtension(DrawingBrush icon, double size) | ||
Check warning on line 19 in src/Wpf.Ui/Markup/DrawingBrushIconExtension.cs GitHub Actions / build
|
||
: this(icon) | ||
{ | ||
Size = size; | ||
} | ||
|
||
[ConstructorArgument("icon")] | ||
public DrawingBrush Icon { get; set; } | ||
|
||
[ConstructorArgument("Size")] | ||
Check warning on line 28 in src/Wpf.Ui/Markup/DrawingBrushIconExtension.cs GitHub Actions / build
|
||
public double Size { get; set; } = 16; | ||
|
||
public override object ProvideValue(IServiceProvider serviceProvider) | ||
{ | ||
var drawingBrushIcon = new DrawingBrushIcon { Icon = Icon, Size = Size }; | ||
|
||
return drawingBrushIcon; | ||
} | ||
} |
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.
Formatting