CPF/CPF.Toolkit.Demo/MainViewModel.cs

58 lines
1.4 KiB
C#
Raw Normal View History

using CPF.Controls;
using System;
2023-11-22 17:30:26 +08:00
using System.Collections.Generic;
2023-11-23 09:57:32 +08:00
using System.Diagnostics;
2023-11-22 17:30:26 +08:00
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPF.Toolkit.Demo
{
internal class MainViewModel : ViewModelBase
{
bool isClose = false;
public void Test()
{
if (this.Dialog.Ask("确定要关闭吗") == "确定")
{
this.isClose = true;
this.Close();
}
}
2023-11-22 17:30:26 +08:00
protected override void OnClose(ClosingEventArgs e)
{
e.Cancel = !this.isClose;
base.OnClose(e);
}
2023-11-22 23:55:50 +08:00
public async void LoadingTest()
{
2023-11-23 13:38:29 +08:00
await this.ShowLoading(async () =>
2023-11-23 09:57:32 +08:00
{
await Task.Delay(1000);
Debug.WriteLine(1);
await Task.Delay(1000);
Debug.WriteLine(2);
await Task.Delay(1000);
Debug.WriteLine(3);
});
//await this.ShowLoading(Task.Delay(3000));
2023-11-22 23:55:50 +08:00
this.Dialog.Sucess("test");
//var result = await this.ShowLoading(async () =>
//{
// await Task.Delay(5000);
// return "test";
//});
//this.Dialog.Sucess(result);
}
2023-11-23 13:38:29 +08:00
2023-11-23 15:20:43 +08:00
public async Task AsyncClick()
2023-11-23 13:38:29 +08:00
{
2023-11-23 15:20:43 +08:00
await Task.Delay(3000);
2023-11-23 13:38:29 +08:00
this.Dialog.Alert("test");
2023-11-23 15:20:43 +08:00
}
2023-11-22 17:30:26 +08:00
}
}