2025-08-12 23:08:54 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Windows;
|
2025-07-31 20:12:24 +08:00
|
|
|
|
using System.Windows.Controls;
|
2025-08-12 23:08:54 +08:00
|
|
|
|
|
|
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
|
|
|
2025-07-31 20:12:24 +08:00
|
|
|
|
using NeuWPF.Appearance;
|
2025-08-12 23:08:54 +08:00
|
|
|
|
using NeuWPF.Controls;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NeuWPFTest;
|
2025-07-31 20:12:24 +08:00
|
|
|
|
|
2025-08-12 23:08:54 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// MainWindow.xaml 的交互逻辑
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[ObservableObject]
|
|
|
|
|
|
public partial class MainWindow
|
2025-07-31 20:12:24 +08:00
|
|
|
|
{
|
2025-08-12 23:08:54 +08:00
|
|
|
|
public MainWindow()
|
2025-07-31 20:12:24 +08:00
|
|
|
|
{
|
2025-08-12 23:08:54 +08:00
|
|
|
|
DataContext = this;
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
InitNode1Value();
|
|
|
|
|
|
Items =
|
|
|
|
|
|
[
|
|
|
|
|
|
new RadioItem { Label = "Apple", Value = "Apple" },
|
|
|
|
|
|
new RadioItem { Label = "Pear", Value = "Pear" },
|
|
|
|
|
|
new RadioItem { Label = "Orange", Value = "Orange" }];
|
|
|
|
|
|
}
|
|
|
|
|
|
public ObservableCollection<Staff> StaffList = [];
|
|
|
|
|
|
private ObservableCollection<string> _allItems;
|
|
|
|
|
|
private IEnumerable<string> _pagedItems;
|
2025-07-31 20:12:24 +08:00
|
|
|
|
|
2025-08-12 23:08:54 +08:00
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
private Staff staff;
|
|
|
|
|
|
public void InitNode1Value()
|
|
|
|
|
|
{
|
|
|
|
|
|
Staff staff = new Staff() { Name = "Alice", Age = 30, Sex = "Male", Duty = "Manager", IsExpanded = true };
|
|
|
|
|
|
Staff staff2 = new Staff() { Name = "Alice1", Age = 21, Sex = "Male", Duty = "Normal", IsExpanded = true };
|
|
|
|
|
|
Staff staff3 = new Staff() { Name = "Alice11", Age = 21, Sex = "Male", Duty = "Normal" };
|
|
|
|
|
|
staff2.StaffList.Add(staff3);
|
|
|
|
|
|
staff3 = new Staff() { Name = "Alice22", Age = 21, Sex = "Female", Duty = "Normal" };
|
|
|
|
|
|
staff2.StaffList.Add(staff3);
|
|
|
|
|
|
staff.StaffList.Add(staff2);
|
|
|
|
|
|
staff2 = new Staff() { Name = "Alice2", Age = 22, Sex = "Female", Duty = "Normal" };
|
|
|
|
|
|
staff.StaffList.Add(staff2);
|
|
|
|
|
|
staff2 = new Staff() { Name = "Alice3", Age = 23, Sex = "Female", Duty = "Normal" };
|
|
|
|
|
|
staff.StaffList.Add(staff2);
|
|
|
|
|
|
StaffList.Add(staff);
|
|
|
|
|
|
|
|
|
|
|
|
staff = new Staff() { Name = "Bob", Age = 31, Sex = "Male", Duty = "CEO" };
|
|
|
|
|
|
staff2 = new Staff() { Name = "Bob1", Age = 24, Sex = "Female", Duty = "Normal" };
|
|
|
|
|
|
staff.StaffList.Add(staff2);
|
|
|
|
|
|
staff2 = new Staff() { Name = "Bob2", Age = 25, Sex = "Female", Duty = "Normal" };
|
|
|
|
|
|
staff.StaffList.Add(staff2);
|
|
|
|
|
|
staff2 = new Staff() { Name = "Bob3", Age = 26, Sex = "Male", Duty = "Normal" };
|
|
|
|
|
|
staff.StaffList.Add(staff2);
|
|
|
|
|
|
StaffList.Add(staff);
|
|
|
|
|
|
|
|
|
|
|
|
staff = new Staff() { Name = "Cyber", Age = 32, Sex = "Female", Duty = "Leader" };
|
|
|
|
|
|
staff2 = new Staff() { Name = "Cyber1", Age = 27, Sex = "Female", Duty = "Normal" };
|
|
|
|
|
|
staff.StaffList.Add(staff2);
|
|
|
|
|
|
staff2 = new Staff() { Name = "Cyber2", Age = 28, Sex = "Female", Duty = "Normal" };
|
|
|
|
|
|
staff.StaffList.Add(staff2);
|
|
|
|
|
|
StaffList.Add(staff);
|
|
|
|
|
|
}
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
|
|
|
|
|
|
private Area area;
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
private List<Area> seletedAreas=new List<Area>();
|
|
|
|
|
|
|
|
|
|
|
|
[RelayCommand]
|
|
|
|
|
|
private void AddArea(Area area)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public Area[] Areas
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
} =
|
|
|
|
|
|
{
|
|
|
|
|
|
new Area(0, "北海道"),
|
|
|
|
|
|
new Area(1, "青森県"),
|
|
|
|
|
|
new Area(2, "岩手県"),
|
|
|
|
|
|
new Area(3, "宮城県"),
|
|
|
|
|
|
new Area(4, "秋田県"),
|
|
|
|
|
|
new Area(5, "山形県"),
|
|
|
|
|
|
new Area(6, "福島県"),
|
|
|
|
|
|
new Area(7, "茨城県"),
|
|
|
|
|
|
new Area(8, "栃木県"),
|
|
|
|
|
|
new Area(9, "群馬県"),
|
|
|
|
|
|
new Area(10, "埼玉県"),
|
|
|
|
|
|
new Area(11, "千葉県"),
|
|
|
|
|
|
new Area(12, "東京都"),
|
|
|
|
|
|
new Area(13, "神奈川県"),
|
|
|
|
|
|
new Area(14, "新潟県"),
|
|
|
|
|
|
new Area(15, "富山県"),
|
|
|
|
|
|
new Area(16, "石川県"),
|
|
|
|
|
|
new Area(17, "福井県"),
|
|
|
|
|
|
new Area(18, "山梨県"),
|
|
|
|
|
|
new Area(19, "長野県"),
|
|
|
|
|
|
new Area(20, "岐阜県"),
|
|
|
|
|
|
new Area(21, "静岡県"),
|
|
|
|
|
|
new Area(22, "愛知県"),
|
|
|
|
|
|
new Area(23, "三重県"),
|
|
|
|
|
|
new Area(24, "滋賀県"),
|
|
|
|
|
|
new Area(25, "京都府"),
|
|
|
|
|
|
new Area(26, "大阪府"),
|
|
|
|
|
|
new Area(27, "兵庫県"),
|
|
|
|
|
|
new Area(28, "奈良県"),
|
|
|
|
|
|
new Area(29, "和歌山県"),
|
|
|
|
|
|
new Area(30, "鳥取県"),
|
|
|
|
|
|
new Area(31, "島根県"),
|
|
|
|
|
|
new Area(32, "岡山県"),
|
|
|
|
|
|
new Area(33, "広島県"),
|
|
|
|
|
|
new Area(34, "山口県"),
|
|
|
|
|
|
new Area(35, "徳島県"),
|
|
|
|
|
|
new Area(36, "香川県"),
|
|
|
|
|
|
new Area(37, "愛媛県"),
|
|
|
|
|
|
new Area(38, "高知県"),
|
|
|
|
|
|
new Area(39, "福岡県"),
|
|
|
|
|
|
new Area(40, "佐賀県"),
|
|
|
|
|
|
new Area(41, "長崎県"),
|
|
|
|
|
|
new Area(42, "熊本県"),
|
|
|
|
|
|
new Area(43, "大分県"),
|
|
|
|
|
|
new Area(44, "宮崎県"),
|
|
|
|
|
|
new Area(45, "鹿児島県"),
|
|
|
|
|
|
new Area(46, "沖縄県")
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
public IEnumerable<RadioItem> Items { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public struct RadioItem
|
|
|
|
|
|
{
|
|
|
|
|
|
public string Label;
|
|
|
|
|
|
|
|
|
|
|
|
public string Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_loaded)
|
|
|
|
|
|
return;
|
|
|
|
|
|
TextMessage.Text = "选项变化" + e.OriginalSource;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool _loaded = false;
|
|
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e) { _loaded = true; }
|
|
|
|
|
|
|
|
|
|
|
|
private void Switch_OnClick(object sender, RoutedEventArgs e) { ThemeManager.SwitchThemeMode(); }
|
|
|
|
|
|
|
|
|
|
|
|
private void Test_OnClick(object sender, RoutedEventArgs e) { new ControlTestWindow().Show(); }
|
|
|
|
|
|
private void WindowNeu_OnClick(object sender, RoutedEventArgs e) { new NeuWindowTest().Show(); }
|
|
|
|
|
|
|
|
|
|
|
|
private void Breadcrumb_Navigate(object sender, RoutedPropertyChangedEventArgs<string> e)
|
|
|
|
|
|
{ MessageBox.Show(e.NewValue); }
|
|
|
|
|
|
|
|
|
|
|
|
private void LeftTopButton_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
NotificationManager.Show(
|
|
|
|
|
|
"发生错误",
|
|
|
|
|
|
"无法连接到服务器,请检查您的网络连接。",
|
|
|
|
|
|
NotificationType.Error,
|
|
|
|
|
|
NotificationPlacement.TopLeft,
|
|
|
|
|
|
durationSeconds: 5); // 自定义持续时间
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RightTopButton_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
NotificationManager.Show("操作成功", "您的设置已保存,并已成功应用到系统中。", NotificationType.Success);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void LeftBottomButton_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
NotificationManager.Show(
|
|
|
|
|
|
"警告",
|
|
|
|
|
|
"您的磁盘空间即将用尽,请及时清理文件。",
|
|
|
|
|
|
NotificationType.Warning,
|
|
|
|
|
|
NotificationPlacement.BottomLeft);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RightBottomButton_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
NotificationManager.Show(
|
|
|
|
|
|
"系统提示",
|
|
|
|
|
|
"这是一条普通的信息提示,用于通知用户。",
|
|
|
|
|
|
NotificationType.Info,
|
|
|
|
|
|
NotificationPlacement.BottomRight);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Info_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Toast.Screen.ShowInfo("这是一条桌面通知,显示在屏幕右下角。");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Success_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Toast.For(this).ShowSuccess("操作成功!已在当前窗口内显示。");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Warning_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Toast.Screen.ShowWarning("您的订阅即将过期,请及时续订。");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Error_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Toast.For(this).ShowError("加载失败,请检查您的网络连接。");
|
|
|
|
|
|
}
|
2025-07-31 20:12:24 +08:00
|
|
|
|
|
2025-08-12 23:08:54 +08:00
|
|
|
|
private void ShowBasicModal_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool? result = Modal.Confirm(this, "Basic Dialog", "This is a basic modal dialog.");
|
|
|
|
|
|
if (result == true)
|
2025-07-31 20:12:24 +08:00
|
|
|
|
{
|
2025-08-12 23:08:54 +08:00
|
|
|
|
// 处理OK逻辑
|
|
|
|
|
|
MessageBox.Show("User clicked OK!");
|
2025-07-31 20:12:24 +08:00
|
|
|
|
}
|
2025-08-12 23:08:54 +08:00
|
|
|
|
}
|
2025-07-31 20:12:24 +08:00
|
|
|
|
|
2025-08-12 23:08:54 +08:00
|
|
|
|
// 异步关闭用法
|
|
|
|
|
|
private async void ShowAsyncModal_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool? result = Modal.Confirm(this,
|
|
|
|
|
|
"Async Dialog",
|
|
|
|
|
|
"This dialog will close after a 2-second task.",
|
|
|
|
|
|
async () => {
|
|
|
|
|
|
// 模拟一个耗时操作
|
|
|
|
|
|
await Task.Delay(2000);
|
|
|
|
|
|
// 返回true表示操作成功,可以关闭对话框
|
|
|
|
|
|
// 返回false则对话框会保持打开状态
|
|
|
|
|
|
return true;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (result == true)
|
2025-07-31 20:12:24 +08:00
|
|
|
|
{
|
2025-08-12 23:08:54 +08:00
|
|
|
|
MessageBox.Show("Async task completed and user clicked OK!");
|
2025-07-31 20:12:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-08-12 23:08:54 +08:00
|
|
|
|
|
|
|
|
|
|
// 静态信息框
|
|
|
|
|
|
private void ShowInfoModal_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Modal.Info(this, "Information", "This is an information dialog.");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public record Area(int Id, string Name)
|
|
|
|
|
|
{
|
|
|
|
|
|
public int Id { get; } = Id;
|
|
|
|
|
|
|
|
|
|
|
|
public string Name { get; } = Name;
|
|
|
|
|
|
|
|
|
|
|
|
public override string ToString() => Name;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class Staff : ObservableObject
|
|
|
|
|
|
{
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
private string name = null!;
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
private int age;
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
private string sex = null!;
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
private string duty = null!;
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
private bool isChecked = true;
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
private bool isSelected = false;
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
private bool isExpanded = false;
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
private ObservableCollection<Staff> staffList = [];
|
2025-07-31 20:12:24 +08:00
|
|
|
|
}
|