This commit is contained in:
ShrlAlgo
2025-07-11 09:20:23 +08:00
parent c7b104f44f
commit 4d35cadb56
840 changed files with 102347 additions and 11595 deletions

View File

@@ -4,28 +4,207 @@
// All Rights Reserved.
using System.Windows.Controls;
using WPFluent.Gallery.ControlsLookup;
using WPFluent.Gallery.Models;
using WPFluent.Gallery.Views.Pages.Collections;
namespace WPFluent.Gallery.ViewModels.Pages.Collections;
namespace WPFluent.Gallery.ViewModels.Pages;
public partial class CollectionsViewModel : ViewModel
{
[ObservableProperty]
private ICollection<NavigationCard> _navigationCards = new ObservableCollection<NavigationCard>(
ControlPages
.FromNamespace(typeof(CollectionsPage).Namespace!)
.Select(x => new NavigationCard()
{
Name = x.Name,
Icon = x.Icon,
Description = x.Description,
PageType = x.PageType,
})
);
private TreeModelCollection<TreeTestModel> treeTestModel = CreateTestModel();
public static TreeModelCollection<TreeTestModel> CreateTestModel()
{
return new TreeModelCollection<TreeTestModel>()
{
Children = new(
[
new()
{
Column1 = "Test 1",
Column2 = "Test 1",
Column3 = "Test 1",
Children = new(
[
new()
{
Column1 = "Test 1.1",
Column2 = "Test 1.1",
Column3 = "Test 1.1",
Children = new(
[
new()
{
Column1 = "Test 1.2",
Column2 = "Test 1.2",
Column3 = "Test 1.2",
},
]),
},
]),
},
new()
{
Column1 = "Test 2",
Column2 = "Test 2",
Column3 = "Test 2",
}
]),
};
}
[ObservableProperty]
private ObservableCollection<Product> _productsCollection = GenerateProducts();
private ObservableCollection<Staff> staffList = [];
public CollectionsViewModel()
{
InitNode1Value();
}
private 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 ICollection<NavigationCard> _navigationCards = new ObservableCollection<NavigationCard>(
// ControlPages
// .FromNamespace(typeof(CollectionsPage).Namespace!)
// .Select(x => new NavigationCard()
// {
// Name = x.Name,
// Icon = x.Icon,
// Description = x.Description,
// PageType = x.PageType,
// })
//);
public static ObservableCollection<Grade> GenerateTreeViewItem()
{
ObservableCollection<Grade> grades = [];
Grade item = new() { GradeLevel = "一年级" };
item.Students.Add(new() { Name = "学生11" });
item.Students.Add(new() { Name = "学生12" });
item.Students.Add(new() { Name = "学生13" });
Grade item1 = new() { GradeLevel = "二年级" };
item1.Students.Add(new() { Name = "学生21" });
item1.Students.Add(new() { Name = "学生22" });
grades.Add(item);
grades.Add(item1);
return grades;
}
public ObservableCollection<Grade> SelectedItems { get; set; } = [];
public ObservableCollection<Grade> Grades { get; set; } = GenerateTreeViewItem();
[ObservableProperty]
private ObservableCollection<Product> productsCollection = GenerateProducts();
private static ObservableCollection<Product> GenerateProducts()
{
@@ -58,7 +237,7 @@ public partial class CollectionsViewModel : ViewModel
return products;
}
[ObservableProperty]
private ObservableCollection<string> _listBoxItems =
private ObservableCollection<string> listBoxItems =
[
"Arial",
"Comic Sans MS",
@@ -69,23 +248,8 @@ public partial class CollectionsViewModel : ViewModel
#region ListView
private int _listViewSelectionModeComboBoxSelectedIndex = 0;
public int ListViewSelectionModeComboBoxSelectedIndex
{
get => _listViewSelectionModeComboBoxSelectedIndex;
set
{
_ = SetProperty(ref _listViewSelectionModeComboBoxSelectedIndex, value);
UpdateListViewSelectionMode(value);
}
}
[ObservableProperty]
private SelectionMode _listViewSelectionMode = SelectionMode.Single;
[ObservableProperty]
private ObservableCollection<Person> _basicListViewItems = GeneratePersons();
private ObservableCollection<Person> basicListViewItems = GeneratePersons();
private static ObservableCollection<Person> GeneratePersons()
{
@@ -149,16 +313,47 @@ public partial class CollectionsViewModel : ViewModel
return persons;
}
private void UpdateListViewSelectionMode(int selectionModeIndex)
{
ListViewSelectionMode = selectionModeIndex switch
{
1 => SelectionMode.Multiple,
2 => SelectionMode.Extended,
_ => SelectionMode.Single,
};
}
#endregion
}
[ObservableObject]
public partial class TreeTestModel : TreeModelObject<TreeTestModel>
{
[ObservableProperty]
private string? column1;
[ObservableProperty]
private string? column2;
[ObservableProperty]
private string? column3;
[ObservableProperty]
private bool isChecked = false;
}
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 = [];
}