Skip to content
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

Add FontSize markup extension #613

Closed
wants to merge 9 commits into from
8 changes: 8 additions & 0 deletions src/Orc.Theming.Example/ViewModels/Tools/FontSizeViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Orc.Theming.Example.ViewModels
{
using Catel.MVVM;

public class FontSizeViewModel : ViewModelBase
{
}
}
2 changes: 2 additions & 0 deletions src/Orc.Theming.Example/Views/ControlPaddingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
xmlns:system="clr-namespace:System;assembly=System.Runtime"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">

<StackPanel Orientation="Vertical">
<orccontrols:WatermarkTextBox Watermark="WatermarkTextBox"/>
<TextBox Text="TextBox"/>
<ComboBox Text="Combobox" IsEditable="True"/>
<orccontrols:FilterBox Text="FilterBox"/>
<orccontrols:DateTimePicker Value="{x:Static system:DateTime.Now}"/>
</StackPanel>

</catel:UserControl>
9 changes: 6 additions & 3 deletions src/Orc.Theming.Example/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@

<StackPanel Grid.Row="0"
Orientation="Horizontal">
<orctheming:BaseColorSchemeSwitcherView />
<StackPanel>
<orctheming:AccentColorSwitcherView />
<orctheming:FontSizeSwitcherView />
<orctheming:BaseColorSchemeSwitcherView />
</StackPanel>

<orctheming:BaseColorSchemeSwitcherWithIconView />
<orctheming:AccentColorSwitcherView />
<orctheming:FontSizeSwitcherView />
</StackPanel>

<TabControl x:Name="TabControl" Grid.Row="1">
Expand Down
8 changes: 4 additions & 4 deletions src/Orc.Theming.Example/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ private void LoadTabItems()
});

var viewsToAdd = (from viewType in GetType().Assembly.GetTypesEx()
where typeof(UserControl).IsAssignableFromEx(viewType) &&
viewType != typeof(ControlsView)
orderby viewType.Name
select viewType);
where typeof(UserControl).IsAssignableFromEx(viewType) &&
viewType != typeof(ControlsView)
orderby viewType.Name
select viewType);

foreach (var viewToAdd in viewsToAdd)
{
Expand Down
130 changes: 130 additions & 0 deletions src/Orc.Theming.Example/Views/Tools/FontSizeView.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<catel:UserControl x:Class="Orc.Theming.Example.Views.FontSizeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:catel="http://schemas.catelproject.com"
xmlns:ribbon="clr-namespace:Orc.Theming.Example"
xmlns:orctheming="http://schemas.wildgums.com/orc/theming"
xmlns:orccontrols="http://schemas.wildgums.com/orc/controls">

<orccontrols:StackGrid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<Label Content="Default font size"
Grid.ColumnSpan="2"
HorizontalAlignment="Center" />

<GroupBox Header="No subscriptions (not responsive)">
<StackPanel Orientation="Horizontal">
<GroupBox Header="Scaling">
<StackPanel Orientation="Vertical"
HorizontalAlignment="Left">
<Label Content="This is 0.6"
FontSize="{orctheming:FontSize Scale=0.6}" />
<Label Content="This is 0.8"
FontSize="{orctheming:FontSize Scale=0.8}" />
<Label Content="This is 1.0"
FontSize="{orctheming:FontSize Scale=1.0}" />
<Label Content="This is 1.2"
FontSize="{orctheming:FontSize Scale=1.2}" />
<Label Content="This is 1.4"
FontSize="{orctheming:FontSize Scale=1.4}" />
</StackPanel>
</GroupBox>

<GroupBox Header="Delta">
<StackPanel Orientation="Vertical"
HorizontalAlignment="Left">
<Label Content="This is -4"
FontSize="{orctheming:FontSize Delta=-4}" />
<Label Content="This is -2"
FontSize="{orctheming:FontSize Delta=-2}" />
<Label Content="This is 0"
FontSize="{orctheming:FontSize Delta=0}" />
<Label Content="This is +2"
FontSize="{orctheming:FontSize Delta=2}" />
<Label Content="This is +4"
FontSize="{orctheming:FontSize Delta=4}" />
</StackPanel>
</GroupBox>

<GroupBox Header="Absolute">
<StackPanel Orientation="Vertical"
HorizontalAlignment="Left">
<Label Content="This is 10"
FontSize="{orctheming:FontSize Absolute=10}" />
<Label Content="This is 12"
FontSize="{orctheming:FontSize Absolute=12}" />
<Label Content="This is 14"
FontSize="{orctheming:FontSize Absolute=14}" />
<Label Content="This is 16"
FontSize="{orctheming:FontSize Absolute=16}" />
<Label Content="This is 18"
FontSize="{orctheming:FontSize Absolute=18}" />
</StackPanel>
</GroupBox>
</StackPanel>
</GroupBox>

<GroupBox Header="Subscriptions (responsive)">
<StackPanel Orientation="Horizontal">
<GroupBox Header="Scaling">
<StackPanel Orientation="Vertical"
HorizontalAlignment="Left">
<Label Content="This is 0.6"
FontSize="{orctheming:FontSize Scale=0.6, SubscribeToEvents=True}" />
<Label Content="This is 0.8"
FontSize="{orctheming:FontSize Scale=0.8, SubscribeToEvents=True}" />
<Label Content="This is 1.0"
FontSize="{orctheming:FontSize Scale=1.0, SubscribeToEvents=True}" />
<Label Content="This is 1.2"
FontSize="{orctheming:FontSize Scale=1.2, SubscribeToEvents=True}" />
<Label Content="This is 1.4"
FontSize="{orctheming:FontSize Scale=1.4, SubscribeToEvents=True}" />
</StackPanel>
</GroupBox>

<GroupBox Header="Delta">
<StackPanel Orientation="Vertical"
HorizontalAlignment="Left">
<Label Content="This is -4"
FontSize="{orctheming:FontSize Delta=-4, SubscribeToEvents=True}" />
<Label Content="This is -2"
FontSize="{orctheming:FontSize Delta=-2, SubscribeToEvents=True}" />
<Label Content="This is 0"
FontSize="{orctheming:FontSize Delta=0, SubscribeToEvents=True}" />
<Label Content="This is +2"
FontSize="{orctheming:FontSize Delta=2, SubscribeToEvents=True}" />
<Label Content="This is +4"
FontSize="{orctheming:FontSize Delta=4, SubscribeToEvents=True}" />
</StackPanel>
</GroupBox>

<GroupBox Header="Absolute">
<StackPanel Orientation="Vertical"
HorizontalAlignment="Left">
<Label Content="This is 10"
FontSize="{orctheming:FontSize Absolute=10, SubscribeToEvents=True}" />
<Label Content="This is 12"
FontSize="{orctheming:FontSize Absolute=12, SubscribeToEvents=True}" />
<Label Content="This is 14"
FontSize="{orctheming:FontSize Absolute=14, SubscribeToEvents=True}" />
<Label Content="This is 16"
FontSize="{orctheming:FontSize Absolute=16, SubscribeToEvents=True}" />
<Label Content="This is 18"
FontSize="{orctheming:FontSize Absolute=18, SubscribeToEvents=True}" />
</StackPanel>
</GroupBox>
</StackPanel>
</GroupBox>

</orccontrols:StackGrid>

</catel:UserControl>
9 changes: 9 additions & 0 deletions src/Orc.Theming.Example/Views/Tools/FontSizeView.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Orc.Theming.Example.Views;

public partial class FontSizeView
{
public FontSizeView()
{
InitializeComponent();
}
}
2 changes: 1 addition & 1 deletion src/Orc.Theming.Example/Views/Wpf/ToggleButtonView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Content="&#8800;"
FontSize="28"/>
FontSize="{orctheming:FontSize Absolute=28}"/>
</StackPanel>

</catel:UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,31 @@ namespace Orc.Theming
public double Width { get; set; }
protected override object ProvideDynamicValue(System.IServiceProvider? serviceProvider) { }
}
public class FontSize : Catel.Windows.Markup.UpdatableMarkupExtension
{
public FontSize() { }
[System.Windows.Markup.ConstructorArgument("delta")]
public double? Absolute { get; set; }
[System.Windows.Markup.ConstructorArgument("delta")]
public double? Delta { get; set; }
[System.Windows.Markup.ConstructorArgument("mode")]
public Orc.Theming.FontSizeMode Mode { get; set; }
[System.Windows.Markup.ConstructorArgument("scale")]
public double? Scale { get; set; }
[System.Windows.Markup.ConstructorArgument("subscribeToEvents")]
public bool SubscribeToEvents { get; set; }
protected override void OnTargetObjectLoaded() { }
protected override void OnTargetObjectUnloaded() { }
protected override object? ProvideDynamicValue(System.IServiceProvider? serviceProvider) { }
}
public enum FontSizeMode
{
Default = 1,
TextBlockMetadata = 1,
Service = 2,
Parent = 3,
Resource = 4,
}
public class FontSizeService : Orc.Theming.IFontSizeService
{
public FontSizeService() { }
Expand Down
Loading
Loading