87 lines
3.0 KiB
C#
Raw Normal View History

2025-08-15 15:25:44 +08:00
using System.Windows;
using System.Windows.Input;
using DI_Electrical.Event;
using Newtonsoft.Json.Linq;
using Prism.Events;
using Prism.Services.Dialogs;
2025-09-04 18:28:02 +08:00
using SWS.Commons;
using SWS.WPF.Views;
2025-08-15 15:25:44 +08:00
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)
{
2025-09-04 18:28:02 +08:00
IDialogParameters par = new Prism.Services.Dialogs.DialogParameters();
2025-08-15 15:25:44 +08:00
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)
{
2025-09-04 18:28:02 +08:00
IDialogParameters par = new Prism.Services.Dialogs.DialogParameters();
2025-08-15 15:25:44 +08:00
_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
{
}
});
}
}
}