更新客户端渲染,更新了壳

This commit is contained in:
QWQLwToo
2026-07-06 23:05:40 +08:00
parent e7dd87bf7e
commit 31d778710b
1311 changed files with 172662 additions and 1582 deletions
@@ -0,0 +1,10 @@
// 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.
global using System;
global using System.Collections.ObjectModel;
global using System.Threading;
global using System.Windows;
global using System.Windows.Media;
@@ -0,0 +1,11 @@
// 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.
namespace Wpf.Ui.Demo.Console.Models;
public struct DataColor
{
public Brush Color { get; set; }
}
@@ -0,0 +1,33 @@
// 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.Diagnostics;
public static class Program
{
[STAThread]
public static void Main(string[] args)
{
Debug.WriteLine("Args: " + string.Join(", ", 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;
}
}
}
@@ -0,0 +1,90 @@
// 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 Wpf.Ui.Appearance;
namespace Wpf.Ui.Demo.Console.Utilities;
public static class ThemeUtilities
{
public static void ApplyTheme(this FrameworkElement frameworkElement)
{
ApplicationThemeManager.Apply(frameworkElement);
void themeChanged(ApplicationTheme sender, Color args)
{
ApplicationThemeManager.Apply(frameworkElement);
if (frameworkElement is Window window)
{
if (window != UiApplication.Current.MainWindow)
{
WindowBackgroundManager.UpdateBackground(
window,
sender,
Wpf.Ui.Controls.WindowBackdropType.None
);
}
}
}
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());
ApplicationTheme current = ApplicationThemeManager.GetAppTheme();
ApplicationTheme applicationTheme =
ApplicationThemeManager.GetAppTheme() == ApplicationTheme.Light
? ApplicationTheme.Dark
: ApplicationTheme.Light;
ApplicationThemeManager.Apply(applicationTheme, updateAccent: false);
ApplicationThemeManager.Apply(current, updateAccent: false);
}
};
}
#endif
}
public static void ChangeTheme()
{
ApplicationTheme applicationTheme =
ApplicationThemeManager.GetAppTheme() == ApplicationTheme.Light
? ApplicationTheme.Dark
: ApplicationTheme.Light;
ApplicationThemeManager.Apply(applicationTheme, updateAccent: false);
}
}
@@ -0,0 +1,78 @@
<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:local="clr-namespace:Wpf.Ui.Demo.Console.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
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>
@@ -0,0 +1,25 @@
// 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 Wpf.Ui.Demo.Console.Utilities;
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();
}
}
@@ -0,0 +1,31 @@
<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>
@@ -0,0 +1,34 @@
// 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 Wpf.Ui.Demo.Console.Utilities;
namespace Wpf.Ui.Demo.Console.Views.Pages;
/// <summary>
/// Interaction logic for DashboardPage.xaml
/// </summary>
public partial class DashboardPage
{
private int _counter = 0;
public DashboardPage()
{
DataContext = this;
InitializeComponent();
CounterTextBlock.SetCurrentValue(System.Windows.Controls.TextBlock.TextProperty, _counter.ToString());
this.ApplyTheme();
}
private void OnBaseButtonClick(object sender, RoutedEventArgs e)
{
CounterTextBlock.SetCurrentValue(
System.Windows.Controls.TextBlock.TextProperty,
(++_counter).ToString()
);
}
}
@@ -0,0 +1,43 @@
<Page
x:Class="Wpf.Ui.Demo.Console.Views.Pages.DataPage"
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:models="clr-namespace:Wpf.Ui.Demo.Console.Models"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
Title="DataPage"
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">
<ui:VirtualizingItemsControl
x:Name="ColorsItemsControl"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
VirtualizingPanel.CacheLengthUnit="Item"
>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type models:DataColor}">
<ui:Button
Width="80"
Height="80"
Margin="2"
Padding="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Appearance="Secondary"
Background="{Binding Color, Mode=OneWay}"
FontSize="25"
Icon="Fluent24"
/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ui:VirtualizingItemsControl>
</Grid>
</Page>
@@ -0,0 +1,49 @@
// 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 Wpf.Ui.Demo.Console.Models;
using Wpf.Ui.Demo.Console.Utilities;
namespace Wpf.Ui.Demo.Console.Views.Pages;
/// <summary>
/// Interaction logic for DataView.xaml
/// </summary>
public partial class DataPage
{
public ObservableCollection<DataColor> ColorsCollection = [];
public DataPage()
{
InitializeData();
InitializeComponent();
ColorsItemsControl.ItemsSource = ColorsCollection;
this.ApplyTheme();
}
private void InitializeData()
{
var random = new Random();
for (int i = 0; i < 8192; i++)
{
ColorsCollection.Add(
new DataColor
{
Color = new SolidColorBrush(
Color.FromArgb(
(byte)200,
(byte)random.Next(0, 250),
(byte)random.Next(0, 250),
(byte)random.Next(0, 250)
)
),
}
);
}
}
}
@@ -0,0 +1,38 @@
<Page
x:Class="Wpf.Ui.Demo.Console.Views.Pages.SettingsPage"
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="SettingsPage"
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"
>
<StackPanel Margin="42">
<TextBlock FontSize="20" FontWeight="Medium" Text="Personalization" />
<TextBlock Margin="0,12,0,0" Text="Theme" />
<RadioButton
x:Name="LightThemeRadioButton"
Margin="0,12,0,0"
Checked="OnLightThemeRadioButtonChecked"
Content="Light"
GroupName="themeSelect"
/>
<RadioButton
x:Name="DarkThemeRadioButton"
Margin="0,8,0,0"
Checked="OnDarkThemeRadioButtonChecked"
Content="Dark"
GroupName="themeSelect"
/>
<TextBlock Margin="0,24,0,0" FontSize="20" FontWeight="Medium" Text="About WPF UI - Simple Demo" />
<TextBlock x:Name="AppVersionTextBlock" Margin="0,12,0,0" />
</StackPanel>
</Page>
@@ -0,0 +1,49 @@
// 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 Wpf.Ui.Appearance;
using Wpf.Ui.Demo.Console.Utilities;
namespace Wpf.Ui.Demo.Console.Views.Pages;
/// <summary>
/// Interaction logic for SettingsPage.xaml
/// </summary>
public partial class SettingsPage
{
public SettingsPage()
{
InitializeComponent();
AppVersionTextBlock.Text = $"WPF UI - Simple Demo - {GetAssemblyVersion()}";
if (Appearance.ApplicationThemeManager.GetAppTheme() == ApplicationTheme.Dark)
{
DarkThemeRadioButton.IsChecked = true;
}
else
{
LightThemeRadioButton.IsChecked = true;
}
this.ApplyTheme();
}
private void OnLightThemeRadioButtonChecked(object sender, RoutedEventArgs e)
{
Appearance.ApplicationThemeManager.Apply(ApplicationTheme.Light);
}
private void OnDarkThemeRadioButtonChecked(object sender, RoutedEventArgs e)
{
Appearance.ApplicationThemeManager.Apply(ApplicationTheme.Dark);
}
private string GetAssemblyVersion()
{
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString()
?? string.Empty;
}
}
@@ -0,0 +1,25 @@
<ui:FluentWindow
x:Class="Wpf.Ui.Demo.Console.Views.SimpleView"
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"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
Width="64"
Height="64"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
ExtendsContentIntoTitleBar="True"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d"
>
<StackPanel>
<ui:TitleBar Title="Simple View" CanMaximize="False" ShowMaximize="False" ShowMinimize="False" />
<StackPanel Margin="8">
<ui:CardAction Click="CardAction_Click">
Change Theme
</ui:CardAction
>
</StackPanel>
</StackPanel>
</ui:FluentWindow>
@@ -0,0 +1,22 @@
// 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 Wpf.Ui.Demo.Console.Utilities;
namespace Wpf.Ui.Demo.Console.Views;
public partial class SimpleView
{
public SimpleView()
{
InitializeComponent();
this.ApplyTheme();
}
private void CardAction_Click(object sender, RoutedEventArgs e)
{
ThemeUtilities.ChangeTheme();
}
}
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
<UseWPF>true</UseWPF>
<ApplicationIcon>wpfui.ico</ApplicationIcon>
<NoWarn>$(NoWarn);SA1601</NoWarn>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<None Remove="wpfui.ico" />
</ItemGroup>
<ItemGroup>
<Content Include="wpfui.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Wpf.Ui\Wpf.Ui.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="MainView.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
</ItemGroup>
</Project>
Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB