Skip to content

Commit

Permalink
Update simple demo [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
pomianowski committed Jun 11, 2022
1 parent b8db424 commit 24a3d10
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 62 deletions.
2 changes: 1 addition & 1 deletion src/Wpf.Ui.SimpleDemo/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ui:Resources Theme="Dark" />
<ui:Resources Theme="Light" />
</Application.Resources>
</Application>
29 changes: 17 additions & 12 deletions src/Wpf.Ui.SimpleDemo/DashboardPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,23 @@
</StackPanel>
</ui:CardAction>

<ui:CardAction Margin="0,12,0,0" Icon="Fluent24">
<StackPanel>
<TextBlock
Margin="0,0,0,4"
FontWeight="Medium"
Text="Action card" />
<TextBlock
FontSize="11"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
Text="Click it and nothing will happen!" />
</StackPanel>
</ui:CardAction>
<ui:CardControl
Title="Task bar state"
Margin="0,8,0,0"
Icon="TasksApp24"
Subtitle="Selected desired state of the task bar">
<ComboBox
x:Name="TaskbarStateComboBox"
MinWidth="120"
SelectedIndex="0"
SelectionChanged="TaskbarStateComboBox_OnSelectionChanged">
<ComboBoxItem Content="None" />
<ComboBoxItem Content="Normal" />
<ComboBoxItem Content="Error" />
<ComboBoxItem Content="Pause" />
<ComboBoxItem Content="Indeterminate" />
</ComboBox>
</ui:CardControl>

<ui:Button
Margin="0,12,0,0"
Expand Down
78 changes: 56 additions & 22 deletions src/Wpf.Ui.SimpleDemo/DashboardPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Wpf.Ui.SimpleDemo
using System.Windows.Controls;

namespace Wpf.Ui.SimpleDemo;

/// <summary>
/// Interaction logic for DashboardPage.xaml
/// </summary>
public partial class DashboardPage : Page
{
/// <summary>
/// Interaction logic for DashboardPage.xaml
/// </summary>
public partial class DashboardPage : Page
public DashboardPage()
{
public DashboardPage()
InitializeComponent();
}

private void TaskbarStateComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (sender is not ComboBox comboBox)
return;

var parentWindow = System.Windows.Window.GetWindow(this);

if (parentWindow == null)
return;

var selectedIndex = comboBox.SelectedIndex;

switch (selectedIndex)
{
InitializeComponent();
case 1:
Wpf.Ui.TaskBar.TaskBarProgress.SetValue(
parentWindow,
Wpf.Ui.TaskBar.TaskBarProgressState.Normal,
80);
break;

case 2:
Wpf.Ui.TaskBar.TaskBarProgress.SetValue(
parentWindow,
Wpf.Ui.TaskBar.TaskBarProgressState.Error,
80);
break;

case 3:
Wpf.Ui.TaskBar.TaskBarProgress.SetValue(
parentWindow,
Wpf.Ui.TaskBar.TaskBarProgressState.Paused,
80);
break;

case 4:
Wpf.Ui.TaskBar.TaskBarProgress.SetValue(
parentWindow,
Wpf.Ui.TaskBar.TaskBarProgressState.Indeterminate,
80);
break;

default:
Wpf.Ui.TaskBar.TaskBarProgress.SetState(parentWindow, Wpf.Ui.TaskBar.TaskBarProgressState.None);
break;
}
}
}
8 changes: 4 additions & 4 deletions src/Wpf.Ui.SimpleDemo/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.

using System.Windows;

namespace Wpf.Ui.SimpleDemo;

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();

Wpf.Ui.Appearance.Theme.ApplyDarkThemeToWindow(this);
Wpf.Ui.Appearance.Accent.ApplySystemAccent();

// Wpf.Ui.Appearance.Theme.ApplyDarkThemeToWindow(this);
// Wpf.Ui.Appearance.Background.Apply(this, Wpf.Ui.Appearance.BackgroundType.Mica);
}
}
23 changes: 8 additions & 15 deletions src/Wpf.Ui/Appearance/Accent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.

using System;
using System.Windows;
using System.Windows.Media;
using Wpf.Ui.Extensions;
Expand Down Expand Up @@ -105,20 +104,6 @@ public static Color TertiaryAccent
/// </summary>
public static Brush TertiaryAccentBrush => new SolidColorBrush(TertiaryAccent);

/// <summary>
/// Obsolete alternative for <see cref="Apply"/>. Will be removed in the future.
/// </summary>
[Obsolete]
public static void Change(Color systemAccent, ThemeType themeType = ThemeType.Light,
bool systemGlassColor = false) => Apply(systemAccent, themeType, systemGlassColor);

/// <summary>
/// Obsolete alternative for <see cref="Apply"/>. Will be removed in the future.
/// </summary>
[Obsolete]
public static void Change(Color systemAccent, Color primaryAccent,
Color secondaryAccent, Color tertiaryAccent) => Apply(systemAccent, primaryAccent, secondaryAccent, tertiaryAccent);

/// <summary>
/// Changes the color accents of the application based on the color entered.
/// </summary>
Expand Down Expand Up @@ -170,6 +155,14 @@ public static void Apply(Color systemAccent, Color primaryAccent,
UpdateColorResources(systemAccent, primaryAccent, secondaryAccent, tertiaryAccent);
}

/// <summary>
/// Applies system accent color to the application.
/// </summary>
public static void ApplySystemAccent()
{
Apply(GetColorizationColor(), Theme.GetAppTheme());
}

/// <summary>
/// Gets current Desktop Window Manager colorization color.
/// <para>It should be the color defined in the system Personalization.</para>
Expand Down
8 changes: 0 additions & 8 deletions src/Wpf.Ui/Appearance/Theme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ public static class Theme
/// <returns><see langword="true"/> if system uses high contrast theme.</returns>
public static bool IsSystemHighContrast() => SystemTheme.HighContrast;

/// <summary>
/// Obsolete alternative for <see cref="Apply"/>. Will be removed in the future.
/// </summary>
[Obsolete]
public static void Set(ThemeType themeType, BackgroundType backgroundEffect = BackgroundType.Mica,
bool updateAccent = true, bool forceBackground = false) =>
Apply(themeType, backgroundEffect, updateAccent, forceBackground);

/// <summary>
/// Changes the current application theme.
/// </summary>
Expand Down

0 comments on commit 24a3d10

Please sign in to comment.