Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 56 additions & 33 deletions src/Certify.UI.Desktop/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,100 @@
x:Class="Certify.UI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:utils="clr-namespace:Certify.UI.Utils;assembly=Certify.UI.Shared"
StartupUri="pack://application:,,,/Certify.UI.Shared;component/Windows/MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Green.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Dark.Green.xaml" />

<ResourceDictionary Source="pack://application:,,,/ToastNotifications.Messages;component/Themes/Default.xaml" />
<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Themes/Fluent.xaml" />


</ResourceDictionary.MergedDictionaries>

<Color x:Key="SystemAccentColor">#FF78B83E</Color>
<Color x:Key="SystemAccentColorLight1">#FF8FC75A</Color>
<Color x:Key="SystemAccentColorLight2">#FFA8D27A</Color>
<Color x:Key="SystemAccentColorLight3">#FFDDEECD</Color>
<Color x:Key="SystemAccentColorDark1">#FF5EA02D</Color>
<Color x:Key="SystemAccentColorDark2">#FF467D1F</Color>
<Color x:Key="SystemAccentColorDark3">#FF315916</Color>
<SolidColorBrush x:Key="AccentFillColorDefaultBrush" Color="#FF78B83E" />
<SolidColorBrush x:Key="AccentFillColorSecondaryBrush" Color="#FF6EAA38" />
<SolidColorBrush x:Key="AccentFillColorTertiaryBrush" Color="#FFDDEECD" />
<SolidColorBrush x:Key="AccentFillColorDisabledBrush" Color="#6680B950" />
<SolidColorBrush x:Key="TextOnAccentFillColorPrimaryBrush" Color="#FFFFFFFF" />
<SolidColorBrush x:Key="ValidationErrorBrush" Color="#FFD32F2F" />
<SolidColorBrush x:Key="WindowTitleColorBrush" Color="#FF78B83E" />

<!-- Heading -->
<Style x:Key="Subheading" TargetType="TextBlock">
<Style
x:Key="Subheading"
BasedOn="{StaticResource {x:Type TextBlock}}"
TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="FontFamily" Value="Segoe UI Semibold" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Padding" Value="0,0,0,4" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
</Style>
<!-- Heading With Top Margin -->
<Style x:Key="SubheadingWithMargin" TargetType="TextBlock">
<Style
x:Key="SubheadingWithMargin"
BasedOn="{StaticResource {x:Type TextBlock}}"
TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="FontFamily" Value="Segoe UI Semibold" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Padding" Value="0,8,0,4" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
</Style>
<!-- Instruction Text -->

<Style x:Key="Instructions" TargetType="TextBlock">
<Style
x:Key="Instructions"
BasedOn="{StaticResource {x:Type TextBlock}}"
TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Padding" Value="0,6,0,6" />
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.SystemControlForegroundBaseMediumHigh}" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorSecondaryBrush}" />
<Setter Property="TextWrapping" Value="WrapWithOverflow" />

</Style>
<Style x:Key="Info" TargetType="TextBlock">
<Style
x:Key="Info"
BasedOn="{StaticResource {x:Type TextBlock}}"
TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Padding" Value="0,2,0,2" />
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.SystemControlForegroundBaseMediumHigh}" />

<Setter Property="Foreground" Value="{DynamicResource TextFillColorSecondaryBrush}" />
<Setter Property="TextWrapping" Value="WrapWithOverflow" />
</Style>

<!-- brush color overrides (tab items and disabled buttons) -->
<SolidColorBrush x:Key="MahApps.Brushes.Gray" Color="{DynamicResource MahApps.Colors.SystemChromeHigh}" />
<SolidColorBrush x:Key="MahApps.Brushes.Control.Disabled" Color="{DynamicResource MahApps.Colors.SystemAltLow}" />
<Style BasedOn="{StaticResource {x:Type Window}}" TargetType="Window">
<Setter Property="Background" Value="{DynamicResource LayerFillColorDefaultBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />

<Style TargetType="controls:NumericUpDown">
<Setter Property="BorderBrush" Value="{DynamicResource MahApps.Brushes.SystemControlForegroundBaseLow}" />
<Setter Property="TextOptions.TextFormattingMode" Value="Display" />
<Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
</Style>

<Style BasedOn="{StaticResource MahApps.Styles.ComboBox}" TargetType="ComboBox">
<Setter Property="BorderBrush" Value="{DynamicResource MahApps.Brushes.SystemControlForegroundBaseLow}" />
<Style BasedOn="{StaticResource {x:Type UserControl}}" TargetType="UserControl">
<Setter Property="Background" Value="{DynamicResource LayerFillColorDefaultBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
</Style>

<Style BasedOn="{StaticResource MahApps.Styles.TextBox}" TargetType="TextBox">
<Setter Property="BorderBrush" Value="{DynamicResource MahApps.Brushes.SystemControlForegroundBaseLow}" />
<Style BasedOn="{StaticResource {x:Type Label}}" TargetType="Label">
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
</Style>

<Style BasedOn="{StaticResource MahApps.Styles.Button}" TargetType="Button">
<Setter Property="FontSize" Value="12" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="BorderThickness" Value="1" />
<Style BasedOn="{StaticResource {x:Type ListView}}" TargetType="ListView">
<Setter Property="Background" Value="{DynamicResource CardBackgroundFillColorDefaultBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
</Style>

<Setter Property="BorderBrush" Value="{DynamicResource MahApps.Brushes.SystemControlForegroundBaseLow}" />
<Setter Property="controls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
<Setter Property="controls:ControlsHelper.CornerRadius" Value="0" />
<Style BasedOn="{StaticResource {x:Type ListViewItem}}" TargetType="ListViewItem">
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
</Style>

<!-- control templates -->
Expand Down
4 changes: 1 addition & 3 deletions src/Certify.UI.Shared/Certify.UI.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<UseWindowsForms>true</UseWindowsForms>
<!--assembly version specified here to allow WPF to load windows via startupUI without version dependency-->
<AssemblyVersion>6.0.0.*</AssemblyVersion>
<NoWarn>NU1701</NoWarn>
<NoWarn>$(NoWarn);NU1701;WPF0001</NoWarn>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand All @@ -25,12 +25,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="ControlzEx" Version="7.0.4" />
<PackageReference Include="Fody" Version="6.9.3" PrivateAssets="All" />
<PackageReference Include="FontAwesome.WPF" Version="4.7.0.9">
<NoWarn>NU1701</NoWarn>
</PackageReference>
<PackageReference Include="MahApps.Metro" Version="3.0.0-rc0529" />
<PackageReference Include="Markdig" Version="1.1.3" />
<PackageReference Include="Markdig.Wpf" Version="0.5.0.1" />
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
Expand Down
118 changes: 118 additions & 0 deletions src/Certify.UI.Shared/Controls/Fluent/NumberBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace Certify.UI.Controls.Fluent
{
public class NumberBox : TextBox
{
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register(nameof(Value), typeof(double?), typeof(NumberBox), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnValueChanged, CoerceValue));

public static readonly DependencyProperty MinimumProperty =
DependencyProperty.Register(nameof(Minimum), typeof(double), typeof(NumberBox), new PropertyMetadata(double.MinValue, OnLimitChanged));

public static readonly DependencyProperty MaximumProperty =
DependencyProperty.Register(nameof(Maximum), typeof(double), typeof(NumberBox), new PropertyMetadata(double.MaxValue, OnLimitChanged));

public static readonly DependencyProperty IntervalProperty =
DependencyProperty.Register(nameof(Interval), typeof(double), typeof(NumberBox), new PropertyMetadata(1d));

private bool _updatingText;

public NumberBox()
{
TextChanged += NumberBox_TextChanged;
PreviewKeyDown += NumberBox_PreviewKeyDown;
}

public event RoutedPropertyChangedEventHandler<double?> ValueChanged;

public double? Value
{
get => (double?)GetValue(ValueProperty);
set => SetValue(ValueProperty, value);
}

public double Minimum
{
get => (double)GetValue(MinimumProperty);
set => SetValue(MinimumProperty, value);
}

public double Maximum
{
get => (double)GetValue(MaximumProperty);
set => SetValue(MaximumProperty, value);
}

public double Interval
{
get => (double)GetValue(IntervalProperty);
set => SetValue(IntervalProperty, value);
}

private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is NumberBox numberBox)
{
numberBox.UpdateText();
numberBox.ValueChanged?.Invoke(numberBox, new RoutedPropertyChangedEventArgs<double?>((double?)e.OldValue, (double?)e.NewValue));
}
}

private static void OnLimitChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
d.CoerceValue(ValueProperty);
}

private static object CoerceValue(DependencyObject d, object baseValue)
{
if (d is NumberBox numberBox && baseValue is double value)
{
return numberBox.CoerceValueWithinBounds(value);
}

return baseValue;
}

private void NumberBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (_updatingText)
{
return;
}

if (double.TryParse(Text, NumberStyles.Float, CultureInfo.CurrentCulture, out var value))
{
Value = value;
}
}

private void NumberBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key != Key.Up && e.Key != Key.Down)
{
return;
}

var currentValue = Value ?? (Minimum != double.MinValue ? Minimum : 0);
Value = currentValue + (e.Key == Key.Up ? Interval : -Interval);
e.Handled = true;
}

private double CoerceValueWithinBounds(double value)
{
return Math.Max(Minimum, Math.Min(Maximum, value));
}

private void UpdateText()
{
_updatingText = true;
Text = Value?.ToString(CultureInfo.CurrentCulture) ?? string.Empty;
_updatingText = false;
}
}
}
16 changes: 7 additions & 9 deletions src/Certify.UI.Shared/Controls/GettingStarted.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
x:Class="Certify.UI.Controls.GettingStarted"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Custom="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:local="clr-namespace:Certify.UI.Controls"
Expand All @@ -27,13 +26,13 @@
Margin="0,0,0,0"
FontFamily="Segoe UI"
FontSize="30"
Foreground="{DynamicResource MahApps.Brushes.Gray1}"
Foreground="{DynamicResource TextOnAccentFillColorPrimaryBrush}"
TextWrapping="Wrap"><Run FontWeight="Bold" Text="Certify" /><Run Text=" the web" /></TextBlock>
<TextBlock
Margin="0,0,0,8"
FontFamily="Segoe UI"
FontSize="16"
Foreground="{DynamicResource MahApps.Brushes.Gray1}"
Foreground="{DynamicResource TextOnAccentFillColorPrimaryBrush}"
Text="Certify Certificate Manager"
TextWrapping="Wrap" />
<TextBlock Style="{StaticResource Instructions}" TextWrapping="Wrap">
Expand All @@ -47,7 +46,6 @@
<GroupBox
x:Name="CommunityEdition"
Margin="0,16,0,0"
Custom:HeaderedControlHelper.HeaderBackground="{StaticResource ErrorColorBrush}"
BorderThickness="0"
Header="License Not Activated"
Visibility="{Binding IsLicenseUpgradeRecommended, Converter={StaticResource ResourceKey=BooleanToVisibilityConverter}}">
Expand All @@ -72,7 +70,7 @@
VerticalAlignment="Top"
FontSize="12"
FontWeight="Bold"
Foreground="{StaticResource MahApps.Brushes.IdealForeground}"
Foreground="{DynamicResource TextOnAccentFillColorPrimaryBrush}"
Text="Your license key has expired. Some features will be reduced or unavailable. Please Sign In to https://certifytheweb.com and renew your license key, then re-open the app."
TextWrapping="Wrap" />

Expand Down Expand Up @@ -119,7 +117,7 @@
Margin="0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Foreground="#FF6BB039"
Foreground="{DynamicResource AccentFillColorDefaultBrush}"
Icon="PlayCircle" />
<TextBlock Margin="8,0,0,0" HorizontalAlignment="Left"><Run Text="Quick Start Guide" /></TextBlock>
</StackPanel>
Expand Down Expand Up @@ -153,7 +151,7 @@
HorizontalAlignment="Left"
VerticalAlignment="Top"
FontSize="12"
Foreground="{StaticResource MahApps.Brushes.IdealForeground}"
Foreground="{DynamicResource TextOnAccentFillColorPrimaryBrush}"
Text="{Binding SystemDiagnosticError}"
TextWrapping="Wrap" />

Expand Down Expand Up @@ -280,7 +278,7 @@
Margin="0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Foreground="#FF6BB039"
Foreground="{DynamicResource AccentFillColorDefaultBrush}"
Icon="PlusCircle" />
<TextBlock Margin="8,0,0,0" HorizontalAlignment="Center"><Run Text="{x:Static res:SR.GettingStarted_AddToDashboard}" /></TextBlock>
</StackPanel>
Expand All @@ -298,7 +296,7 @@
Margin="0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Foreground="#FF6BB039"
Foreground="{DynamicResource AccentFillColorDefaultBrush}"
Icon="Leaf" />
<TextBlock Margin="8,0,0,0" HorizontalAlignment="Center"><Run Text="{x:Static res:SR.GettingStarted_ViewDashboard}" /></TextBlock>
</StackPanel>
Expand Down
Loading