大量更新

This commit is contained in:
GG Z
2025-12-23 21:35:54 +08:00
parent cd4733ee01
commit ceccab9abb
211 changed files with 9439 additions and 6578 deletions

View File

@@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -40,7 +41,28 @@ public partial class MainWindow
public partial TreeNodeItem SelectedItem { get; set; }
[ObservableProperty]
public partial Area Area { get; set; }
public partial Area AutoArea { get; set; }
private Area? _area;
public Area? Area
{
get => _area;
set
{
Debug.WriteLine($"VM.Area setter: incoming = {value?.Name ?? "null"}");
//if (value == null)
//{
// // 打印调用栈,帮助定位是谁把它设为 null只在收到 null 时打印以减少噪音)
// var st = new System.Diagnostics.StackTrace(true);
// Debug.WriteLine("StackTrace for setting Area = null:");
// Debug.WriteLine(st.ToString());
//}
_area = value;
OnPropertyChanged();
}
}
[ObservableProperty]
public partial List<Area> SelectedListAreas { get; set; } = [];
@@ -57,23 +79,24 @@ public partial class MainWindow
[RelayCommand]
private void AddArea()
{
StringBuilder sb = new StringBuilder();
var dictionary = Application.Current.Resources;
foreach (var res in dictionary.MergedDictionaries)
{
foreach (DictionaryEntry item in res)
{
//sb.AppendLine($"{item.Key} = {item.Value}");
if (item.Key.ToString() == "TextPrimaryBrush")
{
MessageBox.Show($"TextPrimaryBrush:{item.Value}");
}
if (item.Key.ToString() == "TextPrimaryBrush")
{
MessageBox.Show($"TextSecondaryBrush:{item.Value}");
}
}
}
MessageBox.Show($"多选1{SelectedListAreas.Count}\n多选2{SelectedObservableAreas.Count}\n单选{Area?.Name}");
//StringBuilder sb = new StringBuilder();
//var dictionary = Application.Current.Resources;
//foreach (var res in dictionary.MergedDictionaries)
//{
// foreach (DictionaryEntry item in res)
// {
// //sb.AppendLine($"{item.Key} = {item.Value}");
// if (item.Key.ToString() == "TextPrimaryBrush")
// {
// MessageBox.Show($"TextPrimaryBrush:{item.Value}");
// }
// if (item.Key.ToString() == "TextPrimaryBrush")
// {
// MessageBox.Show($"TextSecondaryBrush:{item.Value}");
// }
// }
//}
//输出到桌面
//System.IO.File.WriteAllText(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "resources.txt"), sb.ToString());
}
@@ -208,12 +231,9 @@ public partial class MainWindow
MessageBox.Show(message);
}
private void ToggleDetails(PersonItem product)
private static void ToggleDetails(PersonItem? product)
{
if (product != null)
{
product.IsDetailsVisible = !product.IsDetailsVisible;
}
product?.IsDetailsVisible = !product.IsDetailsVisible;
}
#endregion
@@ -252,24 +272,24 @@ public partial class MainWindow
#region
private void LeftTopButton_Click(object sender, RoutedEventArgs e)
{
NotificationManager.Show("发生错误", "无法连接到服务器,请检查您的网络连接。",
Notification.Show("发生错误", "无法连接到服务器,请检查您的网络连接。",
NotificationType.Error, NotificationPlacement.TopLeft, durationSeconds: 5);
}
private void RightTopButton_Click(object sender, RoutedEventArgs e)
{
NotificationManager.Show("操作成功", "您的设置已保存,并已成功应用到系统中。", NotificationType.Success);
Notification.Show("操作成功", "您的设置已保存,并已成功应用到系统中。", NotificationType.Success);
}
private void LeftBottomButton_Click(object sender, RoutedEventArgs e)
{
NotificationManager.Show("警告", "您的磁盘空间即将用尽,请及时清理文件。",
Notification.Show("警告", "您的磁盘空间即将用尽,请及时清理文件。",
NotificationType.Warning, NotificationPlacement.BottomLeft);
}
private void RightBottomButton_Click(object sender, RoutedEventArgs e)
{
NotificationManager.Show("系统提示", "这是一条普通的信息提示,用于通知用户。",
Notification.Show("系统提示", "这是一条普通的信息提示,用于通知用户。",
NotificationType.Info, NotificationPlacement.BottomRight);
}
#endregion
@@ -341,10 +361,18 @@ public partial class MainWindow
private async void ThemeToggle_OnCheckedChanged(object sender, RoutedEventArgs e)
{
if (sender is not ToggleButton tb) return;
try
{
if (sender is not ToggleButton) return;
var targetMode = tb.IsChecked == true ? ThemeMode.Dark : ThemeMode.Light;
await ThemeManager.ApplyThemeAsync(targetMode, animationDurationMs: 800);
//var targetMode = tb.IsChecked == true ? ThemeMode.Dark : ThemeMode.Light;
//await ThemeManager.ApplyThemeAsync(targetMode, animationDurationMs: 800);
await ThemeManager.SwitchThemeModeAnimatedAsync(800);
}
catch (Exception exception)
{
Console.WriteLine(exception);
}
}
private void ColorPalette_OnClick(object sender, RoutedEventArgs e)
@@ -384,35 +412,34 @@ public partial class MainWindow
public partial class TreeNodeItem : ObservableObject
{
[ObservableProperty]
private string name = string.Empty;
public partial string Name { get; set; } = string.Empty;
[ObservableProperty]
private int age;
public partial int Age { get; set; }
[ObservableProperty]
private string sex = string.Empty;
public partial string Sex { get; set; } = string.Empty;
[ObservableProperty]
private string duty = string.Empty;
public partial string Duty { get; set; } = string.Empty;
[ObservableProperty]
private string status = string.Empty;
public partial string Status { get; set; } = string.Empty;
[ObservableProperty]
private string owner = string.Empty;
public partial string Owner { get; set; } = string.Empty;
[ObservableProperty]
private bool isDetailsVisible = false;
public partial bool IsDetailsVisible { get; set; } = false;
[ObservableProperty]
private bool isChecked = true;
public partial bool IsChecked { get; set; } = true;
[ObservableProperty]
private bool isSelected = false;
public partial bool IsSelected { get; set; } = false;
[ObservableProperty]
private bool isExpanded = false;
public partial bool IsExpanded { get; set; } = false;
public ObservableCollection<TreeNodeItem> Children { get; set; } = new();
public TreeNodeItem() { }
@@ -442,13 +469,13 @@ public partial class TreeNodeItem : ObservableObject
public partial class PersonItem : ObservableObject
{
[ObservableProperty]
private string name = string.Empty;
public partial string Name { get; set; } = string.Empty;
[ObservableProperty]
private int age;
public partial int Age { get; set; }
[ObservableProperty]
private bool isDetailsVisible = false;
public partial bool IsDetailsVisible { get; set; } = false;
public PersonItem() { }
@@ -461,14 +488,18 @@ public partial class PersonItem : ObservableObject
public class Area
{
public Area()
{
}
public Area(int Id, string Name)
{
this.Id = Id;
this.Name = Name;
}
public int Id { get; }
public string Name { get; }
public int Id { get; set; }
public string Name { get; set; }
public override string ToString() => Name;
}