功能完善
This commit is contained in:
24
NeuWPF/NeoUITest/App.xaml
Normal file
24
NeuWPF/NeoUITest/App.xaml
Normal file
@@ -0,0 +1,24 @@
|
||||
<Application
|
||||
StartupUri="MainWindow.xaml"
|
||||
x:Class="NeumUITest.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:enu="https://github.com/ShrlAlgo/LucentUI"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- <enu:ThemesDictionary Theme="Dark" /> -->
|
||||
<!-- <enu:ControlsDictionary /> -->
|
||||
<ResourceDictionary Source="pack://application:,,,/NeoUI;component/Themes/Light.xaml" />
|
||||
<!--<ResourceDictionary Source="pack://application:,,,/NeuWPF;component/Themes/Dark.xaml" />-->
|
||||
<ResourceDictionary Source="pack://application:,,,/NeoUI;component/Themes/Styles.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/NeumUITest;component/LocalResources.xaml" />
|
||||
|
||||
<!-- <ResourceDictionary Source="pack://application:,,,/LucentUI;component/Themes/Extra.xaml" /> -->
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
</ResourceDictionary>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
67
NeuWPF/NeoUITest/App.xaml.cs
Normal file
67
NeuWPF/NeoUITest/App.xaml.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
using NeoUI;
|
||||
|
||||
namespace NeumUITest
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
base.OnStartup(e);
|
||||
//Splash.ShowAsync("pack://application:,,,/NeumUITest;component/Resources/Images/ImageTest.png");
|
||||
//MainWindow = new MainWindow();
|
||||
//Splash.CloseOnLoaded(MainWindow);
|
||||
//MainWindow.Show();
|
||||
|
||||
}
|
||||
//protected override void OnStartup(StartupEventArgs e)
|
||||
//{
|
||||
// base.OnStartup(e);
|
||||
// // 在应用启动时,调用方法打印所有已加载的资源字典
|
||||
// Debug.WriteLine("==========================================================");
|
||||
// Debug.WriteLine(" Dumping All Loaded Application Resource Dictionaries... ");
|
||||
// Debug.WriteLine("==========================================================");
|
||||
// // 从最顶层的 Application.Resources 开始遍历
|
||||
// DumpResourceDictionaries(Application.Current.Resources, 0);
|
||||
// Debug.WriteLine("====================== End of Dump =======================");
|
||||
//}
|
||||
/// <summary>
|
||||
/// 递归打印资源字典及其合并的子字典。
|
||||
/// </summary>
|
||||
/// <param name="dictionary">要检查的资源字典。</param>
|
||||
/// <param name="indentationLevel">缩进级别,用于格式化输出。</param>
|
||||
private void DumpResourceDictionaries(ResourceDictionary dictionary, int indentationLevel)
|
||||
{
|
||||
// 创建缩进字符串,使输出更具可读性
|
||||
var indent = new string(' ', indentationLevel * 4);
|
||||
|
||||
// 打印当前字典的来源(Source URI)
|
||||
// App.xaml 中直接定义的根 ResourceDictionary 没有 Source,所以需要判断
|
||||
if (dictionary.Source != null)
|
||||
{
|
||||
Debug.WriteLine($"{indent}-> Source: {dictionary.Source}");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 这是根字典或一个内联定义的字典
|
||||
Debug.WriteLine($"{indent}[Root or Inline Dictionary]");
|
||||
}
|
||||
|
||||
// 递归遍历所有合并的字典
|
||||
foreach (var mergedDict in dictionary.MergedDictionaries)
|
||||
{
|
||||
DumpResourceDictionaries(mergedDict, indentationLevel + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
79
NeuWPF/NeoUITest/ControlTestWindow.xaml
Normal file
79
NeuWPF/NeoUITest/ControlTestWindow.xaml
Normal file
@@ -0,0 +1,79 @@
|
||||
<Window
|
||||
Height="600"
|
||||
Icon="/Resources/Images/ImageTest.png"
|
||||
Title="Custom Control Test"
|
||||
Width="800"
|
||||
d:Height="1200"
|
||||
d:SizeToContent="WidthAndHeight"
|
||||
mc:Ignorable="d"
|
||||
x:Class="LumeTest.ControlTestWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:neu="https://github.com/ShrlAlgo/NeuWPF"
|
||||
xmlns:sys="clr-namespace:System;assembly=netfx.force.conflicts"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- 主窗口背景色,这是拟态风格的基础 -->
|
||||
<Window.Resources>
|
||||
<!--<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/NeuWPFTest;component/ButtonStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>-->
|
||||
</Window.Resources>
|
||||
<!--<lu:WindowAssist.TitleBar>
|
||||
<Menu>
|
||||
<MenuItem Header="Help">
|
||||
<MenuItem Header="About" />
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</lu:WindowAssist.TitleBar>-->
|
||||
<Grid>
|
||||
<ScrollViewer
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Grid.Row="1">
|
||||
<neu:StackPanel Background="{DynamicResource BackgroundLayoutBrush}" Spacing="10">
|
||||
<neu:PropertyField
|
||||
Grid.Row="0"
|
||||
Margin="6,0"
|
||||
PropertyName="属性"
|
||||
PropertyValue="123" />
|
||||
<neu:PropertyField
|
||||
Grid.Row="1"
|
||||
Margin="6,0"
|
||||
PropertyName="属性x"
|
||||
PropertyValue="154" />
|
||||
<UniformGrid
|
||||
Grid.Row="6"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="20">
|
||||
<Button
|
||||
Content="Button"
|
||||
Style="{StaticResource NeuButtonStyle}"
|
||||
ToolTip="测试"
|
||||
ToolTipService.Placement="Left" />
|
||||
<Button
|
||||
Content="Button"
|
||||
Style="{StaticResource NeuButtonStyle}"
|
||||
ToolTip="测试"
|
||||
ToolTipService.Placement="Top" />
|
||||
<Button
|
||||
Content="Button"
|
||||
Style="{StaticResource NeuButtonStyle}"
|
||||
ToolTip="测试"
|
||||
ToolTipService.Placement="Right" />
|
||||
<Button
|
||||
Content="Button"
|
||||
Style="{StaticResource NeuButtonStyle}"
|
||||
ToolTip="测试"
|
||||
ToolTipService.InitialShowDelay="0"
|
||||
ToolTipService.Placement="Bottom" />
|
||||
<TextBox Style="{StaticResource NeuTextBox}" Text="TextBox" />
|
||||
|
||||
|
||||
</UniformGrid>
|
||||
</neu:StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Window>
|
||||
16
NeuWPF/NeoUITest/ControlTestWindow.xaml.cs
Normal file
16
NeuWPF/NeoUITest/ControlTestWindow.xaml.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
|
||||
namespace NeumUITest
|
||||
{
|
||||
/// <summary>
|
||||
/// ControlTestWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ControlTestWindow : Window
|
||||
{
|
||||
public ControlTestWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
63
NeuWPF/NeoUITest/DataModel/DataGridItem.cs
Normal file
63
NeuWPF/NeoUITest/DataModel/DataGridItem.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace NeumUITest.DataModel
|
||||
{
|
||||
public enum Gender
|
||||
{
|
||||
Male,
|
||||
Female,
|
||||
Other
|
||||
}
|
||||
public class DataGridItem
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
public int Age { get; set; }
|
||||
public bool Mark { get; set; }
|
||||
public Gender Gender { get; set; }
|
||||
}
|
||||
|
||||
public class DataGridDemo
|
||||
{
|
||||
public ObservableCollection<DataGridItem> DataCollection { get; set; } =
|
||||
[
|
||||
new DataGridItem
|
||||
{
|
||||
Id = 0,
|
||||
Name = "Symin",
|
||||
Age = 24,
|
||||
Mark = true,
|
||||
Gender = Gender.Other,
|
||||
},
|
||||
|
||||
new DataGridItem
|
||||
{
|
||||
Id = 1,
|
||||
Name = "Mike",
|
||||
Age = 23,
|
||||
Mark = false,
|
||||
Gender = Gender.Male,
|
||||
},
|
||||
|
||||
new DataGridItem
|
||||
{
|
||||
Id = 2,
|
||||
Name = "Alice",
|
||||
Age = 25,
|
||||
Mark = true,
|
||||
Gender = Gender.Female,
|
||||
},
|
||||
|
||||
new DataGridItem
|
||||
{
|
||||
Id = 3,
|
||||
Name = "Bob",
|
||||
Age = 18,
|
||||
Mark = true,
|
||||
Gender = Gender.Male,
|
||||
}
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
11
NeuWPF/NeoUITest/DataModel/TreeItemData.cs
Normal file
11
NeuWPF/NeoUITest/DataModel/TreeItemData.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NeumUITest.DataModel
|
||||
{
|
||||
public class TreeItemData
|
||||
{
|
||||
public string Content { get; set; } = "123";
|
||||
|
||||
public List<TreeItemData> Children { get; set; } = [];
|
||||
}
|
||||
}
|
||||
1208
NeuWPF/NeoUITest/MainWindow.xaml
Normal file
1208
NeuWPF/NeoUITest/MainWindow.xaml
Normal file
File diff suppressed because it is too large
Load Diff
383
NeuWPF/NeoUITest/MainWindow.xaml.cs
Normal file
383
NeuWPF/NeoUITest/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,383 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
using NeoUI.Appearance;
|
||||
using NeoUI.Controls;
|
||||
|
||||
namespace NeumUITest;
|
||||
|
||||
/// <summary>
|
||||
/// MainWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
[ObservableObject]
|
||||
public partial class MainWindow
|
||||
{
|
||||
public ObservableCollection<NodeViewModel> Nodes { get; set; }
|
||||
|
||||
// 用于绑定到MultiTreeView的SelectedItems
|
||||
// 使用ObservableCollection可以自动通知UI集合变化
|
||||
public ObservableCollection<object> SelectedNodes { get; set; }
|
||||
public MainWindow()
|
||||
{
|
||||
// 创建示例数据
|
||||
Nodes = new ObservableCollection<NodeViewModel>
|
||||
{
|
||||
new NodeViewModel
|
||||
{
|
||||
Name = "亚洲",
|
||||
Children =
|
||||
{
|
||||
new NodeViewModel { Name = "中国" },
|
||||
new NodeViewModel { Name = "日本" },
|
||||
new NodeViewModel { Name = "韩国" }
|
||||
}
|
||||
},
|
||||
new NodeViewModel
|
||||
{
|
||||
Name = "欧洲",
|
||||
Children =
|
||||
{
|
||||
new NodeViewModel { Name = "德国" },
|
||||
new NodeViewModel { Name = "法国" },
|
||||
}
|
||||
},
|
||||
new NodeViewModel { Name = "北美洲" }
|
||||
};
|
||||
|
||||
// 初始化选中的集合,并预选一个节点
|
||||
SelectedNodes = new ObservableCollection<object>();
|
||||
var chinaNode = Nodes[0].Children[0];
|
||||
SelectedNodes.Add(chinaNode); // 默认选中"中国"
|
||||
|
||||
DataContext = this;
|
||||
InitNode1Value();
|
||||
|
||||
InitializeComponent();
|
||||
Items =
|
||||
[
|
||||
new RadioItem { Label = "Apple", Value = "Apple" },
|
||||
new RadioItem { Label = "Pear", Value = "Pear" },
|
||||
new RadioItem { Label = "Orange", Value = "Orange" }];
|
||||
}
|
||||
public ObservableCollection<Staff> StaffList { get; set; } = [];
|
||||
private ObservableCollection<string> _allItems;
|
||||
private IEnumerable<string> _pagedItems;
|
||||
|
||||
[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;
|
||||
|
||||
public ObservableCollection<Area> SelectedObservableAreas { get; set; } = [];
|
||||
[ObservableProperty]
|
||||
public partial List<Area> SelectedListAreas { get; set; } = [];
|
||||
[ObservableProperty]
|
||||
private string password;
|
||||
|
||||
[ObservableProperty]
|
||||
private string input;
|
||||
[RelayCommand]
|
||||
private void AddArea()
|
||||
{
|
||||
|
||||
}
|
||||
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 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("加载失败,请检查您的网络连接。");
|
||||
}
|
||||
|
||||
private void ShowBasicModal_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bool? result = Modal.Confirm(this, "Basic Dialog", "This is a basic modal dialog.");
|
||||
if (result == true)
|
||||
{
|
||||
// 处理OK逻辑
|
||||
MessageBox.Show("User clicked OK!");
|
||||
}
|
||||
}
|
||||
|
||||
// 异步关闭用法
|
||||
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)
|
||||
{
|
||||
MessageBox.Show("Async task completed and user clicked OK!");
|
||||
}
|
||||
}
|
||||
|
||||
// 静态信息框
|
||||
private void ShowInfoModal_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Modal.Info(this, "Information", "This is an information dialog.");
|
||||
}
|
||||
|
||||
private void Icon_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IconsWindow iconsWindow = new IconsWindow
|
||||
{
|
||||
Owner = this,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner
|
||||
};
|
||||
iconsWindow.ShowDialog();
|
||||
|
||||
}
|
||||
|
||||
private void DarkTheme(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ThemeManager.SetThemeMode(ThemeMode.Dark);
|
||||
}
|
||||
|
||||
private void LightTheme(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ThemeManager.SetThemeMode(ThemeMode.Light);
|
||||
}
|
||||
|
||||
private void ColorPalette_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var palette = new ColorPaletteWindow
|
||||
{
|
||||
Owner = this,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner
|
||||
};
|
||||
palette.ShowDialog();
|
||||
}
|
||||
}
|
||||
public class ViewModelBase : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected void OnPropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
// 树节点的数据模型
|
||||
public class NodeViewModel : ViewModelBase
|
||||
{
|
||||
private string _name;
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set { _name = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
// 注意:这里不需要IsChecked属性,因为它由MultiTreeViewItem管理
|
||||
// 如果需要更复杂的逻辑(例如持久化选中状态),可以在这里添加
|
||||
|
||||
public ObservableCollection<NodeViewModel> Children { get; set; } = new ObservableCollection<NodeViewModel>();
|
||||
}
|
||||
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 = [];
|
||||
}
|
||||
33
NeuWPF/NeoUITest/NeoUITest.csproj
Normal file
33
NeuWPF/NeoUITest/NeoUITest.csproj
Normal file
@@ -0,0 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net462</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<UseWPF>true</UseWPF>
|
||||
<!-- <Version>1.1.1</Version>-->
|
||||
<!--<ApplicationIcon>Resources\Images\image.Png</ApplicationIcon>-->
|
||||
<!-- <PackageVersion>1.1.1</PackageVersion>-->
|
||||
<!-- <UseWindowsForms>true</UseWindowsForms>-->
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Resources\Images\image.png" />
|
||||
<None Remove="Resources\Images\ImageTest.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Resources\Images\image.png" />
|
||||
<Content Include="Resources\Images\ImageTest.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NeoUI\NeoUI.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
10
NeuWPF/NeoUITest/Properties/AssemblyInfo.cs
Normal file
10
NeuWPF/NeoUITest/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
BIN
NeuWPF/NeoUITest/Resources/Images/ImageTest.png
Normal file
BIN
NeuWPF/NeoUITest/Resources/Images/ImageTest.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
BIN
NeuWPF/NeoUITest/Resources/Images/image.png
Normal file
BIN
NeuWPF/NeoUITest/Resources/Images/image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 MiB |
BIN
NeuWPF/NeoUITest/Resources/Images/image.webp
Normal file
BIN
NeuWPF/NeoUITest/Resources/Images/image.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 318 KiB |
75
NeuWPF/NeoUITest/ViewModel.cs
Normal file
75
NeuWPF/NeoUITest/ViewModel.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NeumUITest
|
||||
{
|
||||
public class MainViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private readonly List<string> _fullDataSource; // 模拟的后端数据源
|
||||
|
||||
private IEnumerable<string> _pagedItems;
|
||||
|
||||
public IEnumerable<string> PagedItems
|
||||
{
|
||||
get => _pagedItems;
|
||||
private set
|
||||
{
|
||||
_pagedItems = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private int _currentPage = 1;
|
||||
|
||||
public int CurrentPage
|
||||
{
|
||||
get => _currentPage;
|
||||
set
|
||||
{
|
||||
_currentPage = value;
|
||||
OnPropertyChanged();
|
||||
UpdatePagedItems();
|
||||
}
|
||||
}
|
||||
|
||||
private int _pageSize = 10;
|
||||
|
||||
public int PageSize
|
||||
{
|
||||
get => _pageSize;
|
||||
set
|
||||
{
|
||||
_pageSize = value;
|
||||
OnPropertyChanged();
|
||||
UpdatePagedItems();
|
||||
}
|
||||
}
|
||||
|
||||
public long TotalItems { get; private set; }
|
||||
|
||||
public MainViewModel()
|
||||
{
|
||||
_fullDataSource = new List<string>(Enumerable.Range(1, 1052).Select(i => $"条目 {i}"));
|
||||
TotalItems = _fullDataSource.Count;
|
||||
OnPropertyChanged(nameof(TotalItems));
|
||||
|
||||
UpdatePagedItems(); // 加载第一页
|
||||
}
|
||||
|
||||
private void UpdatePagedItems()
|
||||
{
|
||||
var skip = (CurrentPage - 1) * PageSize;
|
||||
PagedItems = _fullDataSource.Skip(skip).Take(PageSize).ToList();
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user