79 lines
1.8 KiB
C#
79 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UIStandard.Common;
|
|
using Prism.Commands;
|
|
using Prism.Regions;
|
|
using Prism.Mvvm;
|
|
using Prism.Events;
|
|
using Prism.Services.Dialogs;
|
|
|
|
namespace UIStandard.Start.ViewModels
|
|
{
|
|
public class MainViewModel : BindableBase
|
|
{
|
|
|
|
#region Show Loading
|
|
private int _viewBlur;
|
|
|
|
public int ViewBlur
|
|
{
|
|
get { return _viewBlur; }
|
|
set { SetProperty(ref _viewBlur, value); }
|
|
}
|
|
|
|
private bool _showLoading;
|
|
|
|
public bool ShowLoading
|
|
{
|
|
get { return _showLoading; }
|
|
set
|
|
{
|
|
SetProperty(ref _showLoading, value, () =>
|
|
{
|
|
ViewBlur = value ? 5 : 0;
|
|
});
|
|
}
|
|
}
|
|
|
|
private string _loadingTip;
|
|
|
|
public string LoadingTip
|
|
{
|
|
get { return _loadingTip; }
|
|
set { SetProperty(ref _loadingTip, value); }
|
|
}
|
|
#endregion
|
|
|
|
|
|
IRegionManager _regionManager;
|
|
|
|
public MainViewModel(IDialogService dialogService,
|
|
IRegionManager regionManager,
|
|
IEventAggregator eventAggregator)
|
|
{
|
|
_regionManager = regionManager;
|
|
|
|
//打开登录弹窗
|
|
dialogService.ShowDialog("SocketLoginView", result =>
|
|
{
|
|
if (result.Result != ButtonResult.OK)
|
|
{
|
|
System.Environment.Exit(0);
|
|
}
|
|
});
|
|
|
|
|
|
eventAggregator.GetEvent<LoadingEvent>()
|
|
.Subscribe(tip =>
|
|
{
|
|
//显示或隐藏Loading动画
|
|
ShowLoading = !ShowLoading;
|
|
this.LoadingTip = tip;
|
|
});
|
|
}
|
|
}
|
|
}
|