185 lines
5.2 KiB
C#
185 lines
5.2 KiB
C#
using System.Windows.Controls;
|
|
|
|
using WPFluent.Gallery.ControlsLookup;
|
|
using WPFluent.Gallery.Models;
|
|
using WPFluent.Gallery.Views.Pages;
|
|
|
|
namespace WPFluent.Gallery.ViewModels.Pages;
|
|
public class Grade
|
|
{
|
|
public string GradeLevel { get; set; }
|
|
|
|
public List<Student> Students { get; set; } = [];
|
|
|
|
}
|
|
public class Student
|
|
{
|
|
public int ID { get; set; }
|
|
public string Name { get; set; }
|
|
public string Class { get; set; }
|
|
}
|
|
|
|
public partial class BasicInputViewModel : ViewModel
|
|
{
|
|
[RelayCommand]
|
|
private async Task OnOpenCustomMessageBox(object sender)
|
|
{
|
|
var uiMessageBox = new WPFluent.Controls.MessageWindow
|
|
{
|
|
Title = "消息框",
|
|
Content =
|
|
"永远不会放弃你,永远不会让你失望 永远不会跑来跑去抛弃你 永远不会让你哭泣,永远不会说再见",
|
|
};
|
|
|
|
_ = await uiMessageBox.ShowDialogAsync();
|
|
}
|
|
[ObservableProperty]
|
|
private bool _isFlyoutOpen = false;
|
|
|
|
[RelayCommand]
|
|
private void FlyoutButtonClick(object sender)
|
|
{
|
|
if (!IsFlyoutOpen)
|
|
{
|
|
IsFlyoutOpen = true;
|
|
}
|
|
}
|
|
[RelayCommand]
|
|
private async void MsgAsync()
|
|
{
|
|
// Async methods
|
|
_ = await WPFluent.Controls.MessageBox.InformationAsync("这是一条信息消息");
|
|
_ = await WPFluent.Controls.MessageBox.WarningAsync("这是一个警告消息");
|
|
_ = await WPFluent.Controls.MessageBox.ErrorAsync("这是一个错误消息");
|
|
var result = await WPFluent.Controls.MessageBox.QuestionAsync("这是一个问题,请点击确定?");
|
|
}
|
|
[RelayCommand]
|
|
private void MsgSync()
|
|
{
|
|
_ = WPFluent.Controls.MessageBox.Information("这是一条信息消息");
|
|
_ = WPFluent.Controls.MessageBox.Warning("这是一个警告消息");
|
|
_ = WPFluent.Controls.MessageBox.Error("这是一个错误消息");
|
|
var result = WPFluent.Controls.MessageBox.Question("这是一个问题,请点击确定?");
|
|
}
|
|
[RelayCommand]
|
|
private void MsgPending()
|
|
{
|
|
using IPendingHandler pending = PendingBox.Show("做些事情", "标题", isShowCancel: true);
|
|
|
|
}
|
|
public BasicInputViewModel()
|
|
{
|
|
GenerateTreeViewItem();
|
|
}
|
|
[ObservableProperty]
|
|
private ICollection<NavigationCard> navigationCards = new ObservableCollection<NavigationCard>(
|
|
ControlPages
|
|
.FromNamespace(typeof(BasicInputPage).Namespace!)
|
|
.Select(x => new NavigationCard()
|
|
{
|
|
Name = x.Name,
|
|
Icon = x.Icon,
|
|
Description = x.Description,
|
|
PageType = x.PageType,
|
|
})
|
|
);
|
|
[RelayCommand]
|
|
private void ButtonClick(object sender)
|
|
{
|
|
if (sender is WPFluent.Controls.Button button)
|
|
{
|
|
switch (button.Appearance)
|
|
{
|
|
case ControlAppearance.Primary:
|
|
break;
|
|
case ControlAppearance.Accent:
|
|
break;
|
|
case ControlAppearance.Attention:
|
|
Toast.Information("I am information message");
|
|
break;
|
|
case ControlAppearance.Success:
|
|
Toast.Success("I am success message");
|
|
break;
|
|
case ControlAppearance.Caution:
|
|
Toast.Warning("I am warning message");
|
|
break;
|
|
case ControlAppearance.Critical:
|
|
Toast.Error("I am error message");
|
|
break;
|
|
case ControlAppearance.Transparent:
|
|
Toast.Show(owner: null!, "I am any message", new ToastConfig());
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
public ObservableCollection<Grade> Grades { get; set; } = [];
|
|
|
|
public ObservableCollection<Grade> SelectedItems { get; set; } = [];
|
|
|
|
public void GenerateTreeViewItem()
|
|
{
|
|
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);
|
|
}
|
|
[ObservableProperty]
|
|
private ObservableCollection<string> animals =
|
|
[
|
|
"Cat",
|
|
"Dog",
|
|
"Bear",
|
|
"Lion",
|
|
"Mouse",
|
|
"Horse",
|
|
"Rat",
|
|
"Elephant",
|
|
"Kangaroo",
|
|
"Lizard",
|
|
"Snake",
|
|
"Frog",
|
|
"Fish",
|
|
"Butterfly",
|
|
"Human",
|
|
"Cow",
|
|
"Bumble Bee"
|
|
];
|
|
|
|
#region ComboBox
|
|
|
|
[ObservableProperty]
|
|
private ObservableCollection<string> _comboBoxFontFamilies =
|
|
[
|
|
"Arial",
|
|
"Comic Sans MS",
|
|
"Segoe UI",
|
|
"Times New Roman",
|
|
];
|
|
|
|
[ObservableProperty]
|
|
private ObservableCollection<int> _comboBoxFontSizes =
|
|
[
|
|
8,
|
|
9,
|
|
10,
|
|
11,
|
|
12,
|
|
14,
|
|
16,
|
|
18,
|
|
20,
|
|
24,
|
|
28,
|
|
36,
|
|
48,
|
|
72,
|
|
];
|
|
|
|
#endregion
|
|
}
|