203 lines
5.8 KiB
C#
203 lines
5.8 KiB
C#
using CapMachine.Core;
|
|
using CapMachine.Wpf.Models;
|
|
using CapMachine.Wpf.Models.PPCalc;
|
|
using CapMachine.Wpf.Services;
|
|
using Prism.Commands;
|
|
using Prism.Services.Dialogs;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Win32;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Forms;
|
|
using NPOI.HPSF;
|
|
|
|
namespace CapMachine.Wpf.ViewModels
|
|
{
|
|
public class DialogSuperHeatCoolConfigViewModel : DialogViewModel
|
|
{
|
|
public DialogSuperHeatCoolConfigViewModel(PPCService pPCService)
|
|
{
|
|
Title = "过热度/过冷度设置";
|
|
PPCService = pPCService;
|
|
|
|
SuperHeatCoolConfig = PPCService.SuperHeatCoolConfig;
|
|
|
|
CryogenComboBoxList = new List<ComboBoxModel>()
|
|
{
|
|
new ComboBoxModel(){Key="0",Text="R134a" },
|
|
new ComboBoxModel(){Key="1",Text="R1234yf" },
|
|
};
|
|
}
|
|
|
|
private List<ComboBoxModel> _CryogenComboBoxList;
|
|
/// <summary>
|
|
/// 制冷剂下拉框列表
|
|
/// </summary>
|
|
public List<ComboBoxModel> CryogenComboBoxList
|
|
{
|
|
get { return _CryogenComboBoxList; }
|
|
set { _CryogenComboBoxList = value; RaisePropertyChanged(); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 当前的过热度和过冷度的配置
|
|
/// </summary>
|
|
public SuperHeatCoolConfigModel SuperHeatCoolConfig { get; set; }
|
|
|
|
|
|
private DelegateCommand _OpenSuperHeatCoolPathCmd;
|
|
/// <summary>
|
|
/// 打开过热度和过冷度的文件指令
|
|
/// </summary>
|
|
public DelegateCommand OpenSuperHeatCoolPathCmd
|
|
{
|
|
set
|
|
{
|
|
_OpenSuperHeatCoolPathCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (_OpenSuperHeatCoolPathCmd == null)
|
|
{
|
|
_OpenSuperHeatCoolPathCmd = new DelegateCommand(() => OpenSuperHeatCoolPathCmdMethod());
|
|
}
|
|
return _OpenSuperHeatCoolPathCmd;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 打开过热度和过冷度的文件文件信息
|
|
/// </summary>
|
|
private void OpenSuperHeatCoolPathCmdMethod()
|
|
{
|
|
//DbcFilePath
|
|
try
|
|
{
|
|
var TargetFilePath = GetFilePath();
|
|
if (!string.IsNullOrEmpty(TargetFilePath))
|
|
{
|
|
SuperHeatCoolConfig.FluidsPath = TargetFilePath;
|
|
}
|
|
//System.Diagnostics.Process.Start(fileName);//打开指定路径下的文件
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
System.Windows.MessageBox.Show("可能未选择文件路径", "提示", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Hand);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取保存文件的路径
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string GetFilePath()
|
|
{
|
|
using (var folderBrowserDialog = new FolderBrowserDialog())
|
|
{
|
|
folderBrowserDialog.Description = "请选择一个文件夹";
|
|
folderBrowserDialog.ShowNewFolderButton = true;
|
|
|
|
if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
{
|
|
string selectedPath = folderBrowserDialog.SelectedPath;
|
|
// 处理选中的文件夹路径
|
|
return selectedPath;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private string name;
|
|
/// <summary>
|
|
/// 名称
|
|
/// </summary>
|
|
public string Name
|
|
{
|
|
get { return name; }
|
|
set { name = value; RaisePropertyChanged(); }
|
|
}
|
|
|
|
|
|
private DelegateCommand saveCmd;
|
|
/// <summary>
|
|
/// 保存命令
|
|
/// </summary>
|
|
public DelegateCommand SaveCmd
|
|
{
|
|
set
|
|
{
|
|
saveCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (saveCmd == null)
|
|
{
|
|
saveCmd = new DelegateCommand(() => SaveCmdMethod());
|
|
}
|
|
return saveCmd;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存命令方法
|
|
/// </summary>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
private void SaveCmdMethod()
|
|
{
|
|
DialogParameters pars = new DialogParameters
|
|
{
|
|
{ "Name", Name }
|
|
};
|
|
|
|
RaiseRequestClose(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK, pars));
|
|
}
|
|
|
|
private DelegateCommand cancelCmd;
|
|
/// <summary>
|
|
/// 保存命令
|
|
/// </summary>
|
|
public DelegateCommand CancelCmd
|
|
{
|
|
set
|
|
{
|
|
cancelCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (cancelCmd == null)
|
|
{
|
|
cancelCmd = new DelegateCommand(() => CancelCmdMethod());
|
|
}
|
|
return cancelCmd;
|
|
}
|
|
}
|
|
|
|
public PPCService PPCService { get; }
|
|
|
|
|
|
/// <summary>
|
|
/// 取消命令方法
|
|
/// </summary>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
private void CancelCmdMethod()
|
|
{
|
|
RaiseRequestClose(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 窗口打开时的传递的参数
|
|
/// </summary>
|
|
/// <param name="parameters"></param>
|
|
public override void OnDialogOpened(IDialogParameters parameters)
|
|
{
|
|
//Name = parameters.GetValue<string>("Name");
|
|
}
|
|
}
|
|
}
|