Skip to content

Commit

Permalink
Added ProgressBar ControlTemplate to also support using non-Metro pro…
Browse files Browse the repository at this point in the history
…gressbars via ProgressStyleKey
  • Loading branch information
Dirkster99 committed Dec 15, 2018
1 parent 4595732 commit 6f2358c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
17 changes: 15 additions & 2 deletions source/Components/MLib/Controls/ProgressBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@
xmlns:reskeys="clr-namespace:MLib.Themes"
>

<!-- Colors the standard ProgressBar which can be used whenever the Infinite Metro Style is not wanted -->
<Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type reskeys:ResourceKeys},
ResourceId=ProgressStyleKey}"
TargetType="ProgressBar"
>
<Setter Property="Foreground" Value="{DynamicResource {x:Static reskeys:ResourceKeys.ControlAccentBrushKey}}" />
<Setter Property="Background" Value="{DynamicResource {x:Static reskeys:ResourceKeys.ProgressBackgroundBrushKey}}" />
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static reskeys:ResourceKeys.ControlInputBorderKey}}"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>

<!-- Source: First Floor Modern UI -->
<Style x:Key="MetroProgressBar" TargetType="ProgressBar">
<Style x:Key="MetroProgressBar" TargetType="ProgressBar"
BasedOn="{StaticResource {x:Type ProgressBar}}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static reskeys:ResourceKeys.ControlAccentBrushKey}}" />
<Setter Property="Background" Value="{DynamicResource {x:Static reskeys:ResourceKeys.ProgressBackgroundBrushKey}}" />
<Setter Property="BorderThickness"
Expand Down Expand Up @@ -141,6 +153,7 @@

</Style>

<Style BasedOn="{StaticResource MetroProgressBar}" TargetType="ProgressBar" />
<Style x:Key="{x:Type ProgressBar}"
BasedOn="{StaticResource MetroProgressBar}" TargetType="ProgressBar" />

</ResourceDictionary>
4 changes: 2 additions & 2 deletions source/Components/MLib/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.7.0")]
[assembly: AssemblyFileVersion("1.0.7.0")]
[assembly: AssemblyVersion("1.0.8.0")]
[assembly: AssemblyFileVersion("1.0.8.0")]
13 changes: 12 additions & 1 deletion source/Components/MLib/Themes/ResourceKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -665,5 +665,16 @@ public static class ResourceKeys
/// </summary>
public static readonly ComponentResourceKey ToolBarTrayBackground = new ComponentResourceKey(typeof(ResourceKeys), "ToolBarTrayBackground");
#endregion Toolbar Colors
}

#region ProgressBar
/// <summary>
/// MLib has 2 ways of enabling Metro ProgressBars (Infinit ProgressBar with 4 dots sliding through)
/// A MetroProgressBar control lives in <see cref="MLib.Controls.Metro.MetroProgressBar"/>
/// and the other one is activated by default.
///
/// A non-metro progress bar with a moving rectangle only can be activated with this style key.
/// </summary>
public static readonly ComponentResourceKey ProgressStyleKey = new ComponentResourceKey(typeof(ResourceKeys), "ProgressStyleKey");
#endregion ProgressBar
}
}

0 comments on commit 6f2358c

Please sign in to comment.