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

October 2021 Quick Fix #184

Merged
merged 10 commits into from
Oct 19, 2021
1 change: 1 addition & 0 deletions CharacterMap/CharacterMap/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<ResourceDictionary>
<converters:ZoomBackgroundConverter x:Key="ZoomBackgroundConverter" />
<converters:CasingConverter x:Key="CasingConverter" />

<Style TargetType="FontIcon">
<Setter Property="FontFamily" Value="{ThemeResource SymbolThemeFontFamily}" />
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions CharacterMap/CharacterMap/CharacterMap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<AssemblyName>CharacterMap</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.22000.0</TargetPlatformVersion>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.20348.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<LangVersion>9.0</LangVersion>
Expand Down Expand Up @@ -220,7 +220,7 @@
<DependentUpon>UnhandledExceptionDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\UXSlider.cs" />
<Compile Include="Converters\ZoomBackgroundConverter.cs" />
<Compile Include="Converters\Converters.cs" />
<Compile Include="Core\AlphaKeyGroup.cs" />
<Compile Include="Core\AppSettings.cs" />
<Compile Include="Core\ExceptionHandlingSynchronizationContext.cs" />
Expand Down Expand Up @@ -403,6 +403,7 @@
<Content Include="Assets\FileAssociationTile.png" />
<None Include="Package.StoreAssociation.xml" />
<Content Include="Assets\ZBG.png" />
<Content Include="Assets\ZuneAssets\HoverOverlay.png" />
<Content Include="Properties\Default.rd.xml" />
<Content Include="Assets\SplashScreen.scale-200.png" />
<Content Include="Assets\Square150x150Logo.scale-200.png" />
Expand Down
2 changes: 1 addition & 1 deletion CharacterMap/CharacterMap/Controls/CharacterGridView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ void UpdateUnicode(GlyphAnnotation value)
{
if (_xamlDirect.GetXamlDirectObject(item.ContentTemplateRoot) is IXamlDirectObject root)
{
if (_xamlDirect.GetXamlDirectObjectProperty(root, XamlPropertyIndex.FrameworkElement_Tag) is Character c)
if (_xamlDirect.GetObjectProperty(root, XamlPropertyIndex.FrameworkElement_Tag) is Character c)
{
var childs = _xamlDirect.GetXamlDirectObjectProperty(root, XamlPropertyIndex.Panel_Children);
IXamlDirectObject tb = _xamlDirect.GetXamlDirectObjectFromCollectionAt(childs, 1);
Expand Down
40 changes: 39 additions & 1 deletion CharacterMap/CharacterMap/Controls/UXButton.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
using CharacterMap.Core;
using CharacterMap.Helpers;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace CharacterMap.Controls
{
[ObservableObject]
public partial class UXButtonTemplateSettings
{
[ObservableProperty]
string _effectiveLabel;

public void Update(string text, CharacterCasing casing)
{
EffectiveLabel = casing switch
{
CharacterCasing.Upper => text.ToUpper(),
CharacterCasing.Lower => text.ToLower(),
_ => text
};
}
}

public class UXButton : Button//, IThemeableControl
{
public bool IsHintVisible
Expand All @@ -32,6 +50,17 @@ public bool IsLabelVisible
((UXButton)d).UpdateLabel();
}));

public CharacterCasing LabelCasing
{
get { return (CharacterCasing)GetValue(LabelCasingProperty); }
set { SetValue(LabelCasingProperty, value); }
}

public static readonly DependencyProperty LabelCasingProperty =
DependencyProperty.Register(nameof(LabelCasing), typeof(CharacterCasing), typeof(UXButton), new PropertyMetadata(CharacterCasing.Normal, (d, e) =>
{
((UXButton)d).UpdateLabelText();
}));

public string Label
{
Expand All @@ -40,8 +69,12 @@ public string Label
}

public static readonly DependencyProperty LabelProperty =
DependencyProperty.Register(nameof(Label), typeof(string), typeof(UXButton), new PropertyMetadata(null));
DependencyProperty.Register(nameof(Label), typeof(string), typeof(UXButton), new PropertyMetadata(null, (d, e) =>
{
((UXButton)d).UpdateLabelText();
}));

public UXButtonTemplateSettings TemplateSettings { get; } = new UXButtonTemplateSettings();

bool _isTemplateApplied = false;

Expand Down Expand Up @@ -77,6 +110,11 @@ private void UpdateLabel(bool animate = true)
VisualStateManager.GoToState(this, IsLabelVisible ? "LabelVisible" : "LabelHidden", animate);
}

private void UpdateLabelText()
{
TemplateSettings.Update(Label, LabelCasing);
}

public void UpdateTheme()
{
//_themer.Update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Windows.UI.Xaml.Media;
using CharacterMap.Core;
using CharacterMap.Helpers;
using Windows.UI.Xaml.Controls;

namespace CharacterMap.Converters
{
Expand All @@ -23,6 +24,29 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
}
}

public class CasingConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if (parameter is CharacterCasing casing && value is string s)
{
return casing switch
{
CharacterCasing.Upper => s.ToUpper(),
CharacterCasing.Lower => s.ToLower(),
_ => s
};
}

return value;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}


public class LowerConverter : IValueConverter
{
Expand Down
16 changes: 12 additions & 4 deletions CharacterMap/CharacterMap/Core/Localizer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CharacterMap.Helpers;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Markup;

namespace CharacterMap.Core
Expand All @@ -8,14 +9,21 @@ public class Localizer : MarkupExtension
{
public string Key { get; set; }

public bool Lowercase { get; set; }
public CharacterCasing Casing { get; set; } = CharacterCasing.Normal;

protected override object ProvideValue()
{
if (Lowercase)
return Localization.Get(Key).ToLower();
string text = Localization.Get(Key);

return Localization.Get(Key);
if (Casing != CharacterCasing.Normal)
text = Casing switch
{
CharacterCasing.Upper => text.ToUpper(),
CharacterCasing.Lower => text.ToLower(),
_ => text
};

return text;
}
}
}
21 changes: 13 additions & 8 deletions CharacterMap/CharacterMap/Helpers/FlyoutHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,11 @@ static void DeleteMenuFlyoutItem_Click(object sender, RoutedEventArgs e)
var newCollection = new MenuFlyoutItem
{
Text = Localization.Get("NewCollectionItem/Text"),
Icon = new FontIcon { Glyph = "\uE109" }
};
Icon = new FontIcon { Glyph = "\uE109" },
DataContext = font
};
newCollection.Click += CreateCollection_Click;

if (newColl.Items != null)
{
newColl.Items.Add(newCollection);
Expand All @@ -241,7 +243,8 @@ static void DeleteMenuFlyoutItem_Click(object sender, RoutedEventArgs e)
var symb = new MenuFlyoutItem
{
Text = Localization.Get("OptionSymbolFonts/Text"),
IsEnabled = !_collections.SymbolCollection.Fonts.Contains(font.Name)
IsEnabled = !_collections.SymbolCollection.Fonts.Contains(font.Name),
DataContext = font
};
symb.Click += AddToSymbolFonts_Click;
newColl.Items.Add(symb);
Expand Down Expand Up @@ -306,7 +309,8 @@ static void DeleteMenuFlyoutItem_Click(object sender, RoutedEventArgs e)
{
Text = Localization.Get("RemoveFromCollectionItem/Text"),
Icon = new FontIcon { Glyph = "\uE108" },
Tag = font
Tag = font,
DataContext = font
};
removeItem.Click += RemoveFrom_Click;
menu.Items.Add(removeItem);
Expand All @@ -321,7 +325,7 @@ static void DeleteMenuFlyoutItem_Click(object sender, RoutedEventArgs e)
{
Text = Localization.Get("BtnPrint/Content"),
Icon = new FontIcon { Glyph = "\uE749" }
}.AddKeyboardAccelerator(VirtualKey.P, VirtualKeyModifiers.Control);
}.AddKeyboardAccelerator(VirtualKey.P, VirtualKeyModifiers.Control);

item.Click += Print_Click;
menu.Items.Insert(standalone ? 2 : 3, item);
Expand All @@ -339,7 +343,8 @@ static void DeleteMenuFlyoutItem_Click(object sender, RoutedEventArgs e)
{
Text = Localization.Get("RemoveFontFlyout/Text"),
Icon = new FontIcon { Glyph = "\uE107" },
Tag = font
Tag = font,
DataContext = font
};

if (showAdvanced)
Expand All @@ -355,7 +360,7 @@ static void DeleteMenuFlyoutItem_Click(object sender, RoutedEventArgs e)
{
Text = Localization.Get("CompareFontsButton/Text"),
Icon = new FontIcon { Glyph = "\uE1D3" }
}.AddKeyboardAccelerator(VirtualKey.K, VirtualKeyModifiers.Control);
}.AddKeyboardAccelerator(VirtualKey.K, VirtualKeyModifiers.Control);

qq.Click += (s, e) =>
{
Expand All @@ -372,7 +377,7 @@ static void DeleteMenuFlyoutItem_Click(object sender, RoutedEventArgs e)
{
Text = Localization.Get("AddToQuickCompare/Text"),
Icon = new FontIcon { Glyph = "\uE109" }
}.AddKeyboardAccelerator(VirtualKey.Q, VirtualKeyModifiers.Control);
}.AddKeyboardAccelerator(VirtualKey.Q, VirtualKeyModifiers.Control);

item.Click += (s, e) =>
{
Expand Down
4 changes: 2 additions & 2 deletions CharacterMap/CharacterMap/Helpers/TitleBarHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal static string GetTitle()
return ApplicationView.GetForCurrentView().Title;
}

internal static void SetTitleBar(FrameworkElement e)
internal static void SetTitleBar(UIElement e)
{
SetDefaultTitleBar(Window.Current.Content, e);

Expand All @@ -61,7 +61,7 @@ internal static void RestoreDefaultTitleBar()
if (GetDefaultTitleBar(Window.Current.Content) is XamlTitleBar bar)
bar.IsDragTarget = true;

Window.Current.SetTitleBar(GetDefaultTitleBar(Window.Current.Content));
SetTitleBar(GetDefaultTitleBar(Window.Current.Content));
}
}
}
68 changes: 68 additions & 0 deletions CharacterMap/CharacterMap/Styles/Button.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,74 @@
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

<Style x:Key="ChromelessButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{ThemeResource ButtonForeground}" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
<Setter Property="FocusVisualMargin" Value="-3" />
<Setter Property="UseSystemFocusVisuals" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<ContentPresenter
x:Name="ContentPresenter"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw"
Background="{TemplateBinding Background}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<Storyboard>
<PointerUpThemeAnimation Storyboard.TargetName="ContentPresenter" />
</Storyboard>
</VisualState>

<VisualState x:Name="PointerOver">
<Storyboard>
<PointerUpThemeAnimation Storyboard.TargetName="ContentPresenter" />
</Storyboard>
</VisualState>

<VisualState x:Name="Pressed">
<Storyboard>
<PointerDownThemeAnimation Storyboard.TargetName="ContentPresenter" />
</Storyboard>
</VisualState>

<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Target="ContentPresenter.Opacity" Value="0.5" />
</VisualState.Setters>
<Storyboard>
<PointerUpThemeAnimation Storyboard.TargetName="ContentPresenter" />
</Storyboard>
</VisualState>

</VisualStateGroup>

</VisualStateManager.VisualStateGroups>
</ContentPresenter>

</ControlTemplate>
</Setter.Value>
</Setter>
</Style>



<Style x:Key="IconButton" BasedOn="{StaticResource ButtonRevealStyle}" TargetType="Button">
<Setter Property="Background" Value="{ThemeResource ListViewItemRevealBackground}" />
Expand Down
7 changes: 1 addition & 6 deletions CharacterMap/CharacterMap/Styles/ItemTemplates.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,7 @@
<Grid
ColumnSpacing="12"
Padding="12 4"
Background="Transparent"
PointerPressed="Grid_PointerPressed">
<Grid.ContextFlyout>
<!-- Menu content created dynamically -->
<MenuFlyout MenuFlyoutPresenterStyle="{StaticResource DefaultFlyoutStyle}" Opening="FontContextFlyout_Opening" />
</Grid.ContextFlyout>
Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
Expand Down
Loading