88 lines
3.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Windows;
using System.Windows.Input;
using DI_Electrical.Event;
using Newtonsoft.Json.Linq;
using Prism.Events;
using Prism.Services.Dialogs;
using SWS.Commons;
using SWS.WPF.Views;
using Telerik.Windows.Controls;
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 Prism.Services.Dialogs.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 Prism.Services.Dialogs.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
{
}
});
}
}
}