Skip to content

Commit

Permalink
Miscellaneous fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinnara committed Dec 2, 2019
1 parent 5d1f169 commit 8c6399e
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 87 deletions.
10 changes: 5 additions & 5 deletions ModernWpf.Controls/ContentDialog/ContentDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -632,11 +632,11 @@ public override void OnApplyTemplate()
}

#if DEBUG
if (GetTemplateChild(DialogShowingStatesGroup) is VisualStateGroup dialogShowingStates)
{
dialogShowingStates.CurrentStateChanging += DialogShowingStates_CurrentStateChanging;
dialogShowingStates.CurrentStateChanged += DialogShowingStates_CurrentStateChanged;
}
//if (GetTemplateChild(DialogShowingStatesGroup) is VisualStateGroup dialogShowingStates)
//{
// dialogShowingStates.CurrentStateChanging += DialogShowingStates_CurrentStateChanging;
// dialogShowingStates.CurrentStateChanged += DialogShowingStates_CurrentStateChanged;
//}
#endif
UpdateVisualStates(false);
}
Expand Down
1 change: 0 additions & 1 deletion ModernWpf.Controls/ToggleSwitch/ToggleSwitch.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
xmlns:local="clr-namespace:ModernWpf.Controls"
xmlns:sys="clr-namespace:System;assembly=mscorlib">

<Thickness x:Key="ToggleSwitchTopHeaderMargin">0,0,0,0</Thickness>
<GridLength x:Key="ToggleSwitchPreContentMargin">6</GridLength>
<GridLength x:Key="ToggleSwitchPostContentMargin">6</GridLength>

Expand Down
12 changes: 4 additions & 8 deletions ModernWpf.SampleApp/ControlPages/ComboBoxPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
ItemsSource="{Binding Fonts}"
DisplayMemberPath="Item1"
SelectedValuePath="Item2"
SelectedIndex="2"
ui:ControlHelper.Header="Font"
Width="200"
Loaded="Combo2_Loaded" />
Width="200" />
<TextBlock
x:Name="Control2Output"
Text="You can set the font used for this text."
Expand All @@ -72,13 +72,9 @@
x:Name="Combo3"
IsEditable="True"
ItemsSource="{Binding FontSizes}"
SelectedIndex="2"
ui:ControlHelper.Header="Font Size"
Width="200"
Loaded="Combo3_Loaded">
<ComboBox.Resources>
<PopupAnimation x:Key="{x:Static SystemParameters.ComboBoxPopupAnimationKey}">None</PopupAnimation>
</ComboBox.Resources>
</ComboBox>
Width="200" />
<TextBlock
x:Name="Control3Output"
Text="You can set the font size used for this text."
Expand Down
10 changes: 0 additions & 10 deletions ModernWpf.SampleApp/ControlPages/ComboBoxPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,5 @@ private void ColorComboBox_SelectionChanged(object sender, SelectionChangedEvent
}
Control1Output.Fill = new SolidColorBrush(color);
}

private void Combo2_Loaded(object sender, RoutedEventArgs e)
{
Combo2.SelectedIndex = 2;
}

private void Combo3_Loaded(object sender, RoutedEventArgs e)
{
Combo3.SelectedIndex = 2;
}
}
}
4 changes: 2 additions & 2 deletions ModernWpf.SampleApp/ControlPages/ListBoxPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
ItemsSource="{Binding Fonts}"
DisplayMemberPath="Item1"
SelectedValuePath="Item2"
Height="164"
Loaded="ListBox2_Loaded" />
SelectedIndex="2"
Height="164" />
<TextBlock
x:Name="Control2Output"
Text="You can set the font used for this text."
Expand Down
5 changes: 0 additions & 5 deletions ModernWpf.SampleApp/ControlPages/ListBoxPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,5 @@ public ListBoxPage()
InitializeComponent();
DataContext = this;
}

private void ListBox2_Loaded(object sender, RoutedEventArgs e)
{
ListBox2.SelectedIndex = 2;
}
}
}
5 changes: 1 addition & 4 deletions ModernWpf.SampleApp/ControlPages/TestContentDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
SecondaryButtonClick="OnSecondaryButtonClick"
CloseButtonClick="OnCloseButtonClick"
Closed="OnClosed">
<ui:SimpleStackPanel
Spacing="12"
Margin="0,0,0,24">
<ui:SimpleStackPanel Spacing="12">
<TextBox
ui:ControlHelper.Header="Title"
Text="{Binding ElementName=dialog, Path=Title, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
Expand Down Expand Up @@ -56,6 +54,5 @@
Margin="0,8,0,0"
Visibility="Collapsed" />
</StackPanel>

</ui:SimpleStackPanel>
</ui:ContentDialog>
84 changes: 42 additions & 42 deletions ModernWpf/Styles/TextBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,48 +37,48 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<ControlTemplate.Resources>
<Style x:Key="DeleteButtonStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border
x:Name="ButtonLayoutGrid"
BorderBrush="{DynamicResource TextControlButtonBorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{DynamicResource TextControlButtonBackground}"
CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}">
<TextBlock
x:Name="GlyphElement"
Foreground="{DynamicResource TextControlButtonForeground}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
FontStyle="Normal"
FontSize="12"
Text="&#xE10A;"
FontFamily="{DynamicResource SymbolThemeFontFamily}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="ButtonLayoutGrid" Value="{DynamicResource TextControlButtonBackgroundPointerOver}" />
<Setter Property="BorderBrush" TargetName="ButtonLayoutGrid" Value="{DynamicResource TextControlButtonBorderBrushPointerOver}" />
<Setter Property="Foreground" TargetName="GlyphElement" Value="{DynamicResource TextControlButtonForegroundPointerOver}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" TargetName="ButtonLayoutGrid" Value="{DynamicResource TextControlButtonBackgroundPressed}" />
<Setter Property="BorderBrush" TargetName="ButtonLayoutGrid" Value="{DynamicResource TextControlButtonBorderBrushPressed}" />
<Setter Property="Foreground" TargetName="GlyphElement" Value="{DynamicResource TextControlButtonForegroundPressed}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" TargetName="ButtonLayoutGrid" Value="0" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ControlTemplate.Resources>
<Grid SnapsToDevicePixels="True">
<Grid.Resources>
<Style x:Name="DeleteButtonStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border
x:Name="ButtonLayoutGrid"
BorderBrush="{DynamicResource TextControlButtonBorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{DynamicResource TextControlButtonBackground}"
CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}">
<TextBlock
x:Name="GlyphElement"
Foreground="{DynamicResource TextControlButtonForeground}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
FontStyle="Normal"
FontSize="12"
Text="&#xE10A;"
FontFamily="{DynamicResource SymbolThemeFontFamily}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="ButtonLayoutGrid" Value="{DynamicResource TextControlButtonBackgroundPointerOver}" />
<Setter Property="BorderBrush" TargetName="ButtonLayoutGrid" Value="{DynamicResource TextControlButtonBorderBrushPointerOver}" />
<Setter Property="Foreground" TargetName="GlyphElement" Value="{DynamicResource TextControlButtonForegroundPointerOver}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" TargetName="ButtonLayoutGrid" Value="{DynamicResource TextControlButtonBackgroundPressed}" />
<Setter Property="BorderBrush" TargetName="ButtonLayoutGrid" Value="{DynamicResource TextControlButtonBorderBrushPressed}" />
<Setter Property="Foreground" TargetName="GlyphElement" Value="{DynamicResource TextControlButtonForegroundPressed}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" TargetName="ButtonLayoutGrid" Value="0" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ButtonStates">
<VisualState x:Name="ButtonVisible">
Expand Down Expand Up @@ -162,7 +162,7 @@
Grid.Row="1"
Grid.Column="1"
Focusable="False"
Style="{DynamicResource DeleteButtonStyle}"
Style="{StaticResource DeleteButtonStyle}"
BorderThickness="{TemplateBinding BorderThickness}"
primitives:ControlHelper.CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius, Converter={StaticResource RightCornerRadiusFilterConverter}}"
Padding="{DynamicResource HelperButtonThemePadding}"
Expand Down
2 changes: 2 additions & 0 deletions ModernWpf/ThemeResources/Dark.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@
<Thickness x:Key="ContentDialogButton2HostMargin">0,0,0,0</Thickness>
<Thickness x:Key="ContentDialogContentMargin">0,0,0,0</Thickness>
<Thickness x:Key="ContentDialogContentScrollViewerMargin">0,0,0,0</Thickness>
<Thickness x:Key="ContentDialogCommandSpaceMargin">0,24,0,0</Thickness>
<Thickness x:Key="ContentDialogTitleMargin">0,0,0,12</Thickness>
<Thickness x:Key="ContentDialogPadding">24,18,24,24</Thickness>
<m:StaticResource x:Key="ContentDialogForeground" ResourceKey="SystemControlPageTextBaseHighBrush" />
Expand Down Expand Up @@ -628,6 +629,7 @@
<m:StaticResource x:Key="FlyoutBorderThemeBrush" ResourceKey="SystemControlForegroundChromeHighBrush" />

<!-- Resources for HyperlinkButton -->
<Thickness x:Key="HyperlinkButtonBorderThemeThickness">0</Thickness>
<m:StaticResource x:Key="HyperlinkButtonForeground" ResourceKey="SystemControlHyperlinkTextBrush" />
<m:StaticResource x:Key="HyperlinkButtonForegroundPointerOver" ResourceKey="SystemControlPageTextBaseMediumBrush" />
<m:StaticResource x:Key="HyperlinkButtonForegroundPressed" ResourceKey="SystemControlHighlightBaseMediumLowBrush" />
Expand Down
2 changes: 2 additions & 0 deletions ModernWpf/ThemeResources/HighContrast.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@
<Thickness x:Key="ContentDialogButton2HostMargin">0,0,0,0</Thickness>
<Thickness x:Key="ContentDialogContentMargin">0,0,0,0</Thickness>
<Thickness x:Key="ContentDialogContentScrollViewerMargin">0,0,0,0</Thickness>
<Thickness x:Key="ContentDialogCommandSpaceMargin">0,24,0,0</Thickness>
<Thickness x:Key="ContentDialogTitleMargin">0,0,0,12</Thickness>
<Thickness x:Key="ContentDialogPadding">24,18,24,24</Thickness>
<m:StaticResource x:Key="ContentDialogForeground" ResourceKey="SystemControlPageTextBaseHighBrush" />
Expand Down Expand Up @@ -628,6 +629,7 @@
<m:StaticResource x:Key="FlyoutBorderThemeBrush" ResourceKey="SystemControlTransientBorderBrush" />

<!-- Resources for HyperlinkButton -->
<Thickness x:Key="HyperlinkButtonBorderThemeThickness">0</Thickness>
<m:StaticResource x:Key="HyperlinkButtonForeground" ResourceKey="SystemControlHyperlinkTextBrush" />
<m:StaticResource x:Key="HyperlinkButtonForegroundPointerOver" ResourceKey="SystemControlPageTextBaseMediumBrush" />
<m:StaticResource x:Key="HyperlinkButtonForegroundPressed" ResourceKey="SystemControlHighlightBaseMediumLowBrush" />
Expand Down
2 changes: 2 additions & 0 deletions ModernWpf/ThemeResources/Light.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@
<Thickness x:Key="ContentDialogButton2HostMargin">0,0,0,0</Thickness>
<Thickness x:Key="ContentDialogContentMargin">0,0,0,0</Thickness>
<Thickness x:Key="ContentDialogContentScrollViewerMargin">0,0,0,0</Thickness>
<Thickness x:Key="ContentDialogCommandSpaceMargin">0,24,0,0</Thickness>
<Thickness x:Key="ContentDialogTitleMargin">0,0,0,12</Thickness>
<Thickness x:Key="ContentDialogPadding">24,18,24,24</Thickness>
<m:StaticResource x:Key="ContentDialogForeground" ResourceKey="SystemControlPageTextBaseHighBrush" />
Expand Down Expand Up @@ -628,6 +629,7 @@
<m:StaticResource x:Key="FlyoutBorderThemeBrush" ResourceKey="SystemControlForegroundChromeHighBrush" />

<!-- Resources for HyperlinkButton -->
<Thickness x:Key="HyperlinkButtonBorderThemeThickness">0</Thickness>
<m:StaticResource x:Key="HyperlinkButtonForeground" ResourceKey="SystemControlHyperlinkTextBrush" />
<m:StaticResource x:Key="HyperlinkButtonForegroundPointerOver" ResourceKey="SystemControlPageTextBaseMediumBrush" />
<m:StaticResource x:Key="HyperlinkButtonForegroundPressed" ResourceKey="SystemControlHighlightBaseMediumLowBrush" />
Expand Down
33 changes: 24 additions & 9 deletions ModernWpf/Transitions/Transitions/Transition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,35 @@ public class Transition : ITransition
/// </summary>
private Storyboard _storyboard;

private ClockState _currentState = ClockState.Stopped;

/// <summary>
/// The property that identifies the
/// <see cref="T:System.Windows.Media.Animation.Storyboard"/>
/// for the
/// <see cref="T:System.Windows.UIElement"/>.
/// </summary>
protected internal Storyboard Storyboard
{
protected internal Storyboard Storyboard
{
get { return _storyboard; }
set
{
if(value != _storyboard)
if (value != _storyboard)
{
if (_storyboard != null)
{
_storyboard.Completed -= OnCompleted;
}
_storyboard.CurrentStateInvalidated -= OnCurrentStateInvalidated;
_storyboard.Completed -= OnCompleted;
}

_storyboard = value;

_currentState = ClockState.Stopped;

if (_storyboard != null)
{
_storyboard.CurrentStateInvalidated += OnCurrentStateInvalidated;
_storyboard.Completed += OnCompleted;
}
}
}
}
}
Expand Down Expand Up @@ -121,7 +126,7 @@ public Transition(UIElement element, Storyboard storyboard)
/// </summary>
public virtual void Begin()
{
Save();
Save();
Storyboard.Begin(ElementAsFE, true);
}

Expand Down Expand Up @@ -216,6 +221,12 @@ private void Save()
}
}

private void OnCurrentStateInvalidated(object sender, EventArgs e)
{
var clock = (Clock)sender;
_currentState = clock.CurrentState;
}

/// <summary>
/// Mirrors <see cref="E:System.Windows.Media.Animation.Storyboard.Completed"/>.
/// </summary>
Expand Down Expand Up @@ -257,7 +268,11 @@ public void SkipToFill()
/// </summary>
public void Stop()
{
Storyboard.Stop(ElementAsFE);
if (_currentState != ClockState.Stopped)
{
Storyboard.Stop(ElementAsFE);
}

Restore();
}
}
Expand Down
3 changes: 2 additions & 1 deletion ModernWpf/XamlControlsResources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
<sys:Double x:Key="ControlContentThemeFontSize">14</sys:Double>
<sys:Double x:Key="ContentControlFontSize">14</sys:Double>
<sys:Double x:Key="TextControlThemeMinHeight">32</sys:Double>
<Thickness x:Key="TextControlThemePadding">10,5,6,6</Thickness>
<sys:Double x:Key="TitleBarHeight">32</sys:Double>
<Thickness x:Key="TextControlThemePadding">10,5,6,6</Thickness>
<Thickness x:Key="ToggleSwitchTopHeaderMargin">0,0,0,0</Thickness>

<Style x:Key="EmptyFocusVisual">
<Setter Property="primitives:FocusVisualHelper.IsSystemFocusVisual" Value="True" />
Expand Down

0 comments on commit 8c6399e

Please sign in to comment.