-
-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' of https://github.com/lepoco/wpfui into up…
…date/preview-14
- Loading branch information
Showing
24 changed files
with
788 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||
// Copyright (C) Leszek Pomianowski and WPF UI Contributors. | ||
// All Rights Reserved. | ||
|
||
using System.Windows.Media; | ||
|
||
namespace Wpf.Ui.Demo.Console.Models; | ||
|
||
public struct DataColor | ||
{ | ||
public Brush Color { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||
// Copyright (C) Leszek Pomianowski and WPF UI Contributors. | ||
// All Rights Reserved. | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Windows; | ||
|
||
public static class Program | ||
{ | ||
[STAThread] | ||
public static void Main(string[] args) | ||
{ | ||
if (Application.Current is null) | ||
Console.WriteLine($"Application.Current is null."); | ||
|
||
try | ||
{ | ||
new Wpf.Ui.Demo.Console.Views.SimpleView().ShowDialog(); | ||
new Wpf.Ui.Demo.Console.Views.MainView().ShowDialog(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex); | ||
Thread.Sleep(10000); | ||
throw; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||
// Copyright (C) Leszek Pomianowski and WPF UI Contributors. | ||
// All Rights Reserved. | ||
|
||
using System; | ||
using System.Linq; | ||
using System.Windows; | ||
using System.Windows.Media; | ||
using Wpf.Ui; | ||
using Wpf.Ui.Appearance; | ||
|
||
public static class ThemeUtils | ||
{ | ||
public static void ApplyTheme(this FrameworkElement frameworkElement) | ||
{ | ||
ApplicationThemeManager.Apply(frameworkElement); | ||
|
||
ThemeChangedEvent themeChanged = (sender, args) => | ||
{ | ||
ApplicationThemeManager.Apply(frameworkElement); | ||
if (frameworkElement is Window window) | ||
{ | ||
if (window != UiApplication.Current.MainWindow) | ||
WindowBackgroundManager.UpdateBackground(window, sender, Wpf.Ui.Controls.WindowBackdropType.None, true); | ||
} | ||
}; | ||
|
||
if (frameworkElement.IsLoaded) | ||
{ | ||
ApplicationThemeManager.Changed += themeChanged; | ||
} | ||
frameworkElement.Loaded += (s, e) => | ||
{ | ||
ApplicationThemeManager.Changed += themeChanged; | ||
}; | ||
frameworkElement.Unloaded += (s, e) => | ||
{ | ||
ApplicationThemeManager.Changed -= themeChanged; | ||
}; | ||
|
||
#if DEBUG | ||
if (frameworkElement is Window window) | ||
{ | ||
window.KeyDown += (s, e) => | ||
{ | ||
if (e.Key == System.Windows.Input.Key.T) | ||
{ | ||
ChangeTheme(); | ||
} | ||
|
||
if (e.Key == System.Windows.Input.Key.C) | ||
{ | ||
var rnd = new Random(); | ||
var randomColor = Color.FromRgb((byte)rnd.Next(256), (byte)rnd.Next(256), (byte)rnd.Next(256)); | ||
|
||
ApplicationAccentColorManager.Apply(randomColor, ApplicationThemeManager.GetAppTheme()); | ||
|
||
var current = ApplicationThemeManager.GetAppTheme(); | ||
var applicationTheme = ApplicationThemeManager.GetAppTheme() == ApplicationTheme.Light | ||
? ApplicationTheme.Dark | ||
: ApplicationTheme.Light; | ||
|
||
ApplicationThemeManager.Apply(applicationTheme, updateAccent: false); | ||
ApplicationThemeManager.Apply(current, updateAccent: false); | ||
} | ||
}; | ||
} | ||
#endif | ||
} | ||
|
||
public static void ChangeTheme() | ||
{ | ||
var applicationTheme = ApplicationThemeManager.GetAppTheme() == ApplicationTheme.Light | ||
? ApplicationTheme.Dark | ||
: ApplicationTheme.Light; | ||
|
||
ApplicationThemeManager.Apply(applicationTheme, updateAccent: false); | ||
} | ||
|
||
/// <summary> | ||
/// Applies Resources in the <paramref name="frameworkElement"/>. | ||
/// </summary> | ||
private static void Apply(FrameworkElement frameworkElement) | ||
{ | ||
if (frameworkElement is null) | ||
return; | ||
|
||
var resourcesRemove = frameworkElement.Resources.MergedDictionaries | ||
.Where(e => e.Source is not null) | ||
//.Where(e => e.Source.ToString().ToLower().Contains(Wpf.Ui.Appearance.ApplicationThemeManager.LibraryNamespace)) | ||
.Where(e => e.Source.ToString().ToLower().Contains("Wpf.Ui;")) | ||
.ToArray(); | ||
|
||
foreach (var resource in resourcesRemove) | ||
{ | ||
//System.Console.WriteLine( | ||
// $"INFO | {typeof(MainView)} Remove {resource.Source}", | ||
// "Wpf.Ui.Appearance" | ||
//); | ||
frameworkElement.Resources.MergedDictionaries.Remove(resource); | ||
} | ||
|
||
foreach (var resource in UiApplication.Current.Resources.MergedDictionaries) | ||
{ | ||
//System.Console.WriteLine( | ||
// $"INFO | {typeof(MainView)} Add {resource.Source}", | ||
// "Wpf.Ui.Appearance" | ||
//); | ||
frameworkElement.Resources.MergedDictionaries.Add(resource); | ||
} | ||
|
||
foreach (System.Collections.DictionaryEntry resource in UiApplication.Current.Resources) | ||
{ | ||
//System.Console.WriteLine( | ||
// $"INFO | {typeof(MainView)} Copy Resource {resource.Key} - {resource.Value}", | ||
// "Wpf.Ui.Appearance" | ||
//); | ||
frameworkElement.Resources[resource.Key] = resource.Value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<ui:FluentWindow x:Class="Wpf.Ui.Demo.Console.Views.MainView" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:Wpf.Ui.Demo.Console.Views" | ||
xmlns:pages="clr-namespace:Wpf.Ui.Demo.Console.Views.Pages" | ||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" | ||
Title="WPF UI - Console Demo" | ||
Width="1200" | ||
Height="654" | ||
d:DesignHeight="650" | ||
d:DesignWidth="900" | ||
ExtendsContentIntoTitleBar="True" | ||
WindowStartupLocation="CenterScreen" | ||
mc:Ignorable="d"> | ||
|
||
<ui:FluentWindow.InputBindings> | ||
<KeyBinding Key="F" | ||
Command="{Binding ElementName=AutoSuggestBox, Path=FocusCommand}" | ||
Modifiers="Control" /> | ||
</ui:FluentWindow.InputBindings> | ||
|
||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
<ui:NavigationView x:Name="RootNavigation" | ||
Grid.Row="1"> | ||
<ui:NavigationView.AutoSuggestBox> | ||
<ui:AutoSuggestBox x:Name="AutoSuggestBox" | ||
PlaceholderText="Search"> | ||
<ui:AutoSuggestBox.Icon> | ||
<ui:IconSourceElement> | ||
<ui:SymbolIconSource Symbol="Search24" /> | ||
</ui:IconSourceElement> | ||
</ui:AutoSuggestBox.Icon> | ||
</ui:AutoSuggestBox> | ||
</ui:NavigationView.AutoSuggestBox> | ||
<ui:NavigationView.Header> | ||
<ui:BreadcrumbBar Margin="42,32,0,0" | ||
FontSize="28" | ||
FontWeight="DemiBold" /> | ||
</ui:NavigationView.Header> | ||
<ui:NavigationView.MenuItems> | ||
<ui:NavigationViewItem Content="Dashboard" | ||
NavigationCacheMode="Enabled" | ||
TargetPageType="{x:Type pages:DashboardPage}"> | ||
<ui:NavigationViewItem.Icon> | ||
<ui:SymbolIcon Symbol="Home24" /> | ||
</ui:NavigationViewItem.Icon> | ||
</ui:NavigationViewItem> | ||
<ui:NavigationViewItem Content="Data" | ||
NavigationCacheMode="Enabled" | ||
TargetPageType="{x:Type pages:DataPage}"> | ||
<ui:NavigationViewItem.Icon> | ||
<ui:SymbolIcon Symbol="DataHistogram24" /> | ||
</ui:NavigationViewItem.Icon> | ||
</ui:NavigationViewItem> | ||
</ui:NavigationView.MenuItems> | ||
<ui:NavigationView.FooterMenuItems> | ||
<ui:NavigationViewItem Content="Settings" | ||
NavigationCacheMode="Enabled" | ||
TargetPageType="{x:Type pages:SettingsPage}"> | ||
<ui:NavigationViewItem.Icon> | ||
<ui:SymbolIcon Symbol="Settings24" /> | ||
</ui:NavigationViewItem.Icon> | ||
</ui:NavigationViewItem> | ||
</ui:NavigationView.FooterMenuItems> | ||
</ui:NavigationView> | ||
|
||
<ui:TitleBar Title="WPF UI - Console Demo" | ||
Grid.Row="0"/> | ||
</Grid> | ||
</ui:FluentWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||
// Copyright (C) Leszek Pomianowski and WPF UI Contributors. | ||
// All Rights Reserved. | ||
|
||
using System; | ||
using System.Linq; | ||
using System.Windows; | ||
using System.Windows.Media; | ||
using Wpf.Ui.Demo.Console.Views.Pages; | ||
|
||
namespace Wpf.Ui.Demo.Console.Views; | ||
public partial class MainView | ||
{ | ||
public MainView() | ||
{ | ||
DataContext = this; | ||
|
||
InitializeComponent(); | ||
|
||
Loaded += (_, _) => RootNavigation.Navigate(typeof(DashboardPage)); | ||
|
||
UiApplication.Current.MainWindow = this; | ||
|
||
this.ApplyTheme(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<Page | ||
x:Class="Wpf.Ui.Demo.Console.Views.Pages.DashboardPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:Wpf.Ui.Demo.Console.Views.Pages" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" | ||
Title="DashboardPage" | ||
d:DesignHeight="450" | ||
d:DesignWidth="800" | ||
ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}" | ||
ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}" | ||
Foreground="{DynamicResource TextFillColorPrimaryBrush}" | ||
ScrollViewer.CanContentScroll="False" | ||
mc:Ignorable="d"> | ||
|
||
<Grid Margin="42" VerticalAlignment="Top"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<ui:Button | ||
Grid.Column="0" | ||
Click="OnBaseButtonClick" | ||
Content="Click me!" | ||
Icon="{ui:SymbolIcon Fluent24}" /> | ||
<TextBlock | ||
x:Name="CounterTextBlock" | ||
Grid.Column="1" | ||
Margin="12,0,0,0" | ||
VerticalAlignment="Center" /> | ||
</Grid> | ||
</Page> |
Oops, something went wrong.