91 lines
3.1 KiB
C#
91 lines
3.1 KiB
C#
![]() |
using System.Windows;
|
|||
|
using System.Windows.Input;
|
|||
|
using DI_Electrical.Event;
|
|||
|
using DI_Electrical.Views.Dialog;
|
|||
|
using DI_Electrical.Views.Dialog.DialogSignalManagements;
|
|||
|
using DryIoc;
|
|||
|
using Newtonsoft.Json.Linq;
|
|||
|
using Prism.Events;
|
|||
|
using Prism.Ioc;
|
|||
|
using Prism.Mvvm;
|
|||
|
using Prism.Services.Dialogs;
|
|||
|
using Telerik.Windows.Controls;
|
|||
|
using DialogParameters = Prism.Services.Dialogs.DialogParameters;
|
|||
|
|
|||
|
namespace DI_Electrical.ViewModels
|
|||
|
{
|
|||
|
public class MainWindowViewModel : ViewModelBase
|
|||
|
{
|
|||
|
#region binding
|
|||
|
private string _ProjectName;
|
|||
|
/// <summary>
|
|||
|
///当前项目
|
|||
|
/// </summary>
|
|||
|
public string ProjectName
|
|||
|
{
|
|||
|
get { return _ProjectName; }
|
|||
|
set { _ProjectName = value; OnPropertyChanged(nameof(ProjectName)); }
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
/// <summary>
|
|||
|
/// 命令事件
|
|||
|
/// </summary>
|
|||
|
public ICommand Command_ShowDialogTest { get; set; }
|
|||
|
public ICommand Command_ShowDialogSignalManagement { get; set; }
|
|||
|
private readonly IDialogService _dialogService;
|
|||
|
private IEventAggregator _eventAggregator;
|
|||
|
public MainWindowViewModel(IDialogService dialogService , IEventAggregator eventAggregator)
|
|||
|
{
|
|||
|
Command_ShowDialogTest = new DelegateCommand(onShowDialogTest);
|
|||
|
Command_ShowDialogSignalManagement = new DelegateCommand(onShowDialogSignalManagement);
|
|||
|
_dialogService = dialogService;
|
|||
|
_eventAggregator= eventAggregator;
|
|||
|
_eventAggregator.GetEvent<loginEvent>().Subscribe(onEnterProjOK, ThreadOption.UIThread, true);
|
|||
|
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 选中项目
|
|||
|
/// </summary>
|
|||
|
/// <param name="obj"></param>
|
|||
|
private void onEnterProjOK(JToken obj)
|
|||
|
{
|
|||
|
ProjectName = GlobalObject.curProject?.ProjectName;
|
|||
|
}
|
|||
|
public void onShowDialogTest(object o)
|
|||
|
{
|
|||
|
IDialogParameters par = new DialogParameters();
|
|||
|
par.Add(GlobalObject.dialogPar.para1.ToString(), "abc你我他");
|
|||
|
_dialogService.ShowDialog(nameof(DialogTest), par, (result) =>
|
|||
|
{
|
|||
|
var res = result.Parameters.GetValue<string>(GlobalObject.dialogPar.para1.ToString());
|
|||
|
if (result.Result == ButtonResult.OK || result.Result == ButtonResult.Yes)
|
|||
|
{
|
|||
|
MessageBox.Show("窗体Yes关闭,返回:"+res);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
MessageBox.Show("窗体NO关闭,返回:" + res);
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
public void onShowDialogSignalManagement(object o)
|
|||
|
{
|
|||
|
IDialogParameters par = new DialogParameters();
|
|||
|
_dialogService.ShowDialog(nameof(DialogSignalManagement), par, (result) =>
|
|||
|
{
|
|||
|
var res = result.Parameters.GetValue<string>(GlobalObject.dialogPar.para1.ToString());
|
|||
|
if (result.Result == ButtonResult.OK || result.Result == ButtonResult.Yes)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|