功能完善
This commit is contained in:
@@ -1,140 +0,0 @@
|
||||
<Application
|
||||
x:Class="NeuWPFTest.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:enu="https://github.com/ShrlAlgo/LucentUI"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- <enu:ThemesDictionary Theme="Dark" /> -->
|
||||
<!-- <enu:ControlsDictionary /> -->
|
||||
<ResourceDictionary Source="pack://application:,,,/NeuWPF;component/Themes/Light.xaml" />
|
||||
<!--<ResourceDictionary Source="pack://application:,,,/NeuWPF;component/Themes/Dark.xaml" />-->
|
||||
<ResourceDictionary Source="pack://application:,,,/NeuWPF;component/Themes/Styles.xaml" />
|
||||
|
||||
<!-- <ResourceDictionary Source="pack://application:,,,/LucentUI;component/Themes/Extra.xaml" /> -->
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<!-- 定义拟态风格的颜色 -->
|
||||
<Color x:Key="NeumorphismBaseColor">#e0e5ec</Color>
|
||||
<Color x:Key="NeumorphismDarkShadowColor">#a3b1c6</Color>
|
||||
<Color x:Key="NeumorphismLightShadowColor">#ffffff</Color>
|
||||
|
||||
<SolidColorBrush x:Key="NeumorphismBaseBrush" Color="{StaticResource NeumorphismBaseColor}"/>
|
||||
|
||||
<Style x:Key="NeumorphicButtonLocal" TargetType="Button">
|
||||
<Setter Property="Foreground" Value="#707070"/>
|
||||
<Setter Property="Background" Value="{StaticResource NeumorphismBaseBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="RenderTransformOrigin" Value="0.5, 0.5"/>
|
||||
<Setter Property="RenderTransform">
|
||||
<Setter.Value>
|
||||
<ScaleTransform ScaleX="1" ScaleY="1"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Grid>
|
||||
<Border x:Name="ShadowContainer" Background="{StaticResource NeumorphismBaseBrush}" CornerRadius="20">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect ShadowDepth="5" Direction="315" Color="{StaticResource NeumorphismDarkShadowColor}" Opacity="0.5" BlurRadius="10"/>
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
|
||||
<Border x:Name="LightContainer" Background="{StaticResource NeumorphismBaseBrush}" CornerRadius="20">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect ShadowDepth="-5" Direction="135" Color="{StaticResource NeumorphismLightShadowColor}" Opacity="1" BlurRadius="10"/>
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
|
||||
<Border x:Name="MainBorder" Background="{TemplateBinding Background}" CornerRadius="10">
|
||||
<Border x:Name="PressedEffectBorder" CornerRadius="10" Opacity="0">
|
||||
<Border.Background>
|
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
|
||||
<GradientStop Color="{StaticResource NeumorphismDarkShadowColor}" Offset="0.1"/>
|
||||
<GradientStop Color="Transparent" Offset="0.5"/>
|
||||
<GradientStop Color="{StaticResource NeumorphismLightShadowColor}" Offset="0.9"/>
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
</Border>
|
||||
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding Content}"/>
|
||||
</Grid>
|
||||
|
||||
<!-- 将所有Triggers移到ControlTemplate内部 -->
|
||||
<ControlTemplate.Triggers>
|
||||
<!-- 按下状态的静态Trigger -->
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="ShadowContainer" Property="Opacity" Value="0"/>
|
||||
<Setter TargetName="LightContainer" Property="Opacity" Value="0"/>
|
||||
<Setter TargetName="PressedEffectBorder" Property="Opacity" Value="1"/>
|
||||
</Trigger>
|
||||
|
||||
<!-- 动画 EventTriggers -->
|
||||
<EventTrigger RoutedEvent="MouseEnter">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<!-- 在这里,TargetName可以正常工作 -->
|
||||
<DoubleAnimation Storyboard.TargetName="ShadowContainer" Storyboard.TargetProperty="Effect.ShadowDepth" To="8" Duration="0:0:0.2"/>
|
||||
<DoubleAnimation Storyboard.TargetName="LightContainer" Storyboard.TargetProperty="Effect.ShadowDepth" To="-8" Duration="0:0:0.2"/>
|
||||
<DoubleAnimation Storyboard.TargetName="ShadowContainer" Storyboard.TargetProperty="Effect.BlurRadius" To="15" Duration="0:0:0.2"/>
|
||||
<DoubleAnimation Storyboard.TargetName="LightContainer" Storyboard.TargetProperty="Effect.BlurRadius" To="15" Duration="0:0:0.2"/>
|
||||
|
||||
<!-- 没有TargetName,默认作用于应用模板的控件(Button) -->
|
||||
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" To="1.05" Duration="0:0:0.2"/>
|
||||
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" To="1.05" Duration="0:0:0.2"/>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
|
||||
<EventTrigger RoutedEvent="MouseLeave">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetName="ShadowContainer" Storyboard.TargetProperty="Effect.ShadowDepth" To="5" Duration="0:0:0.2"/>
|
||||
<DoubleAnimation Storyboard.TargetName="LightContainer" Storyboard.TargetProperty="Effect.ShadowDepth" To="-5" Duration="0:0:0.2"/>
|
||||
<DoubleAnimation Storyboard.TargetName="ShadowContainer" Storyboard.TargetProperty="Effect.BlurRadius" To="10" Duration="0:0:0.2"/>
|
||||
<DoubleAnimation Storyboard.TargetName="LightContainer" Storyboard.TargetProperty="Effect.BlurRadius" To="10" Duration="0:0:0.2"/>
|
||||
|
||||
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" To="1" Duration="0:0:0.2"/>
|
||||
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" To="1" Duration="0:0:0.2"/>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
|
||||
<EventTrigger RoutedEvent="PreviewMouseDown">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" To="0.95" Duration="0:0:0.1"/>
|
||||
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" To="0.95" Duration="0:0:0.1"/>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
|
||||
<EventTrigger RoutedEvent="PreviewMouseUp">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" To="1.05" Duration="0:0:0.5">
|
||||
<DoubleAnimation.EasingFunction>
|
||||
<ElasticEase EasingMode="EaseOut" Oscillations="2" Springiness="4"/>
|
||||
</DoubleAnimation.EasingFunction>
|
||||
</DoubleAnimation>
|
||||
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" To="1.05" Duration="0:0:0.5">
|
||||
<DoubleAnimation.EasingFunction>
|
||||
<ElasticEase EasingMode="EaseOut" Oscillations="2" Springiness="4"/>
|
||||
</DoubleAnimation.EasingFunction>
|
||||
</DoubleAnimation>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -1,68 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
using NeuWPF;
|
||||
using NeuWPF.Controls;
|
||||
|
||||
namespace NeuWPFTest
|
||||
{
|
||||
/// <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:,,,/NeuWPFTest;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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
<Window
|
||||
Height="600"
|
||||
Icon="/Resources/Images/SyminUI.png"
|
||||
Title="Custom Control Test"
|
||||
Width="800"
|
||||
d:Height="1200"
|
||||
d:SizeToContent="WidthAndHeight"
|
||||
mc:Ignorable="d"
|
||||
x:Class="NeuWPFTest.ControlTestWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:lu="https://github.com/ShrlAlgo/NeuWPF"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
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">
|
||||
<lu:StackPanel Background="{DynamicResource BackgroundLayoutBrush}" Spacing="10">
|
||||
<lu:PropertyField
|
||||
Grid.Row="0"
|
||||
Margin="6,0"
|
||||
PropertyName="属性"
|
||||
PropertyValue="123" />
|
||||
<lu:PropertyField
|
||||
Grid.Row="1"
|
||||
Margin="6,0"
|
||||
PropertyName="属性x"
|
||||
PropertyValue="154" />
|
||||
|
||||
|
||||
<TreeView Grid.Row="3" x:Name="OldTreeView">
|
||||
<TreeView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding ItemName}" />
|
||||
</DataTemplate>
|
||||
</TreeView.ItemTemplate>
|
||||
</TreeView>
|
||||
|
||||
<TreeViewItem Grid.Row="4" Header="TreeItem" />
|
||||
<ItemsControl Grid.Row="5" x:Name="testItemsControl" />
|
||||
<lu:StackPanel
|
||||
Grid.Row="6"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="20"
|
||||
Spacing="100">
|
||||
<Button
|
||||
Content="Button"
|
||||
Height="100"
|
||||
Style="{StaticResource NeuMorphicButtonStyle}"
|
||||
Width="200" />
|
||||
</lu:StackPanel>
|
||||
</lu:StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,50 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
|
||||
namespace NeuWPFTest
|
||||
{
|
||||
/// <summary>
|
||||
/// ControlTestWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ControlTestWindow : Window
|
||||
{
|
||||
public ControlTestWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
SetViewData();
|
||||
SetItemsData();
|
||||
}
|
||||
private void SetViewData()
|
||||
{
|
||||
var i1 = new TreeData("1111");
|
||||
i1.Children = new List<TreeData>
|
||||
{
|
||||
new TreeData("AAA"),
|
||||
new TreeData("BBB")
|
||||
};
|
||||
List<TreeData> datalist = new()
|
||||
{
|
||||
i1,
|
||||
new TreeData("2222"),
|
||||
new TreeData("3333")
|
||||
};
|
||||
|
||||
//myTreeView.ItemsSource = datalist;
|
||||
OldTreeView.ItemsSource = datalist;
|
||||
}
|
||||
|
||||
private void SetItemsData()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
public class TreeData
|
||||
{
|
||||
public TreeData(string name)
|
||||
{
|
||||
ItemName = name;
|
||||
}
|
||||
public string ItemName { get; set; }
|
||||
public List<TreeData> Children { get; set; } = new List<TreeData>();
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace NeuWPFTest.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,
|
||||
}
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NeuWPFTest.DataModel
|
||||
{
|
||||
public class TreeItemData
|
||||
{
|
||||
public string Content { get; set; } = "123";
|
||||
|
||||
public List<TreeItemData> Children { get; set; } = [];
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,288 +0,0 @@
|
||||
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 NeuWPF.Appearance;
|
||||
using NeuWPF.Controls;
|
||||
|
||||
namespace NeuWPFTest;
|
||||
|
||||
/// <summary>
|
||||
/// MainWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
[ObservableObject]
|
||||
public partial class MainWindow
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
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;
|
||||
|
||||
[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("加载失败,请检查您的网络连接。");
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
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 = [];
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
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)
|
||||
)]
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.7 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 318 KiB |
@@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace NeuWPFTest;
|
||||
public class SizeConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
// 确保我们得到了两个double值 (ActualWidth, ActualHeight)
|
||||
if (values != null && values.Length == 2 && values[0] is double && values[1] is double)
|
||||
{
|
||||
double width = (double)values[0];
|
||||
double height = (double)values[1];
|
||||
// 返回着色器所需的 Size 对象
|
||||
return new Size(width, height);
|
||||
}
|
||||
return new Size(0, 0);
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
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 NeuWPFTest
|
||||
{
|
||||
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