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

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,18 @@
// 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.Mvvm.ViewModels;
public partial class DashboardViewModel : ViewModel
{
[ObservableProperty]
private int _counter = 0;
[RelayCommand]
private void OnCounterIncrement()
{
Counter++;
}
}
@@ -0,0 +1,50 @@
// 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;
using Wpf.Ui.Demo.Mvvm.Models;
namespace Wpf.Ui.Demo.Mvvm.ViewModels;
public partial class DataViewModel : ViewModel
{
private bool _isInitialized = false;
[ObservableProperty]
private List<DataColor> _colors = [];
public override void OnNavigatedTo()
{
if (!_isInitialized)
{
InitializeViewModel();
}
}
private void InitializeViewModel()
{
var random = new Random();
Colors.Clear();
for (int i = 0; i < 8192; i++)
{
Colors.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)
)
),
}
);
}
_isInitialized = true;
}
}
@@ -0,0 +1,74 @@
// 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.Collections.ObjectModel;
using Wpf.Ui.Controls;
namespace Wpf.Ui.Demo.Mvvm.ViewModels;
public partial class MainWindowViewModel : ViewModel
{
private bool _isInitialized = false;
[ObservableProperty]
private string _applicationTitle = string.Empty;
[ObservableProperty]
private ObservableCollection<object> _navigationItems = [];
[ObservableProperty]
private ObservableCollection<object> _navigationFooter = [];
[ObservableProperty]
private ObservableCollection<MenuItem> _trayMenuItems = [];
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Style",
"IDE0060:Remove unused parameter",
Justification = "Demo"
)]
public MainWindowViewModel(INavigationService navigationService)
{
if (!_isInitialized)
{
InitializeViewModel();
}
}
private void InitializeViewModel()
{
ApplicationTitle = "WPF UI - MVVM Demo";
NavigationItems =
[
new NavigationViewItem()
{
Content = "Home",
Icon = new SymbolIcon { Symbol = SymbolRegular.Home24 },
TargetPageType = typeof(Views.Pages.DashboardPage),
},
new NavigationViewItem()
{
Content = "Data",
Icon = new SymbolIcon { Symbol = SymbolRegular.DataHistogram24 },
TargetPageType = typeof(Views.Pages.DataPage),
},
];
NavigationFooter =
[
new NavigationViewItem()
{
Content = "Settings",
Icon = new SymbolIcon { Symbol = SymbolRegular.Settings24 },
TargetPageType = typeof(Views.Pages.SettingsPage),
},
];
TrayMenuItems = [new() { Header = "Home", Tag = "tray_home" }];
_isInitialized = true;
}
}
@@ -0,0 +1,71 @@
// 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.Mvvm.ViewModels;
public partial class SettingsViewModel : ViewModel
{
private bool _isInitialized = false;
[ObservableProperty]
private string _appVersion = string.Empty;
[ObservableProperty]
private Wpf.Ui.Appearance.ApplicationTheme _currentApplicationTheme = Wpf.Ui
.Appearance
.ApplicationTheme
.Unknown;
public override void OnNavigatedTo()
{
if (!_isInitialized)
{
InitializeViewModel();
}
}
private void InitializeViewModel()
{
CurrentApplicationTheme = Wpf.Ui.Appearance.ApplicationThemeManager.GetAppTheme();
AppVersion = $"Wpf.Ui.Demo.Mvvm - {GetAssemblyVersion()}";
_isInitialized = true;
}
private static string GetAssemblyVersion()
{
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString()
?? string.Empty;
}
[RelayCommand]
private void OnChangeTheme(string parameter)
{
switch (parameter)
{
case "theme_light":
if (CurrentApplicationTheme == Wpf.Ui.Appearance.ApplicationTheme.Light)
{
break;
}
Wpf.Ui.Appearance.ApplicationThemeManager.Apply(Wpf.Ui.Appearance.ApplicationTheme.Light);
CurrentApplicationTheme = Wpf.Ui.Appearance.ApplicationTheme.Light;
break;
default:
if (CurrentApplicationTheme == Wpf.Ui.Appearance.ApplicationTheme.Dark)
{
break;
}
Wpf.Ui.Appearance.ApplicationThemeManager.Apply(Wpf.Ui.Appearance.ApplicationTheme.Dark);
CurrentApplicationTheme = Wpf.Ui.Appearance.ApplicationTheme.Dark;
break;
}
}
}
@@ -0,0 +1,39 @@
// 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.Abstractions.Controls;
namespace Wpf.Ui.Demo.Mvvm.ViewModels;
public abstract class ViewModel : ObservableObject, INavigationAware
{
/// <inheritdoc />
public virtual Task OnNavigatedToAsync()
{
OnNavigatedTo();
return Task.CompletedTask;
}
/// <summary>
/// Handles the event that is fired after the component is navigated to.
/// </summary>
// ReSharper disable once MemberCanBeProtected.Global
public virtual void OnNavigatedTo() { }
/// <inheritdoc />
public virtual Task OnNavigatedFromAsync()
{
OnNavigatedFrom();
return Task.CompletedTask;
}
/// <summary>
/// Handles the event that is fired before the component is navigated from.
/// </summary>
// ReSharper disable once MemberCanBeProtected.Global
public virtual void OnNavigatedFrom() { }
}