|
|
@ -1,4 +1,5 @@
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Google.Protobuf.WellKnownTypes;
|
|
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Prism.Commands;
|
|
|
|
using Prism.Commands;
|
|
|
|
using Prism.Ioc;
|
|
|
|
using Prism.Ioc;
|
|
|
|
using Prism.Mvvm;
|
|
|
|
using Prism.Mvvm;
|
|
|
@ -56,13 +57,17 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
set {
|
|
|
|
set {
|
|
|
|
if (value >= 0)
|
|
|
|
if (value >= 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string file = Path.Combine(_workareasModelArray.workarea[value].filepath, "workarea.json");
|
|
|
|
try
|
|
|
|
if (!File.Exists(file))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
JsonParser.WriteSystemConfigFile(file, WareaModel);
|
|
|
|
var area = _workareasModelArray.workarea[value];
|
|
|
|
}
|
|
|
|
string file = Path.Combine(area.filepath, Path.GetFileName(area.filepath) + ".json");
|
|
|
|
string json = File.ReadAllText(file);
|
|
|
|
string json = File.ReadAllText(file);
|
|
|
|
WareaModel = JsonConvert.DeserializeObject<WorkareaModel>(json);
|
|
|
|
WareaModel = JsonConvert.DeserializeObject<WorkareaModel>(json);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MessageBox.Show("当前工区目录配置文件不存在," + ex.Message);
|
|
|
|
|
|
|
|
}
|
|
|
|
_workareasModelArray.selectIndex = value;
|
|
|
|
_workareasModelArray.selectIndex = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetProperty(ref _wareaSelectedIndex, value);
|
|
|
|
SetProperty(ref _wareaSelectedIndex, value);
|
|
|
@ -92,6 +97,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
{
|
|
|
|
{
|
|
|
|
apmStationFile = string.Empty;
|
|
|
|
apmStationFile = string.Empty;
|
|
|
|
apmttime2dFile = string.Empty;
|
|
|
|
apmttime2dFile = string.Empty;
|
|
|
|
|
|
|
|
// WareaModel.apmModel = ;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
public DelegateCommand AddItemCommand => new(() =>
|
|
|
|
public DelegateCommand AddItemCommand => new(() =>
|
|
|
@ -106,17 +112,38 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
if (result != null && result.Result == ButtonResult.OK)
|
|
|
|
if (result != null && result.Result == ButtonResult.OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var area = result.Parameters.GetValue<Workareas>("param1");
|
|
|
|
var area = result.Parameters.GetValue<Workareas>("param1");
|
|
|
|
WareaModel.savepath = area.filepath;
|
|
|
|
var file = _workareasModelArray.workarea.Where(f => f.workareaname == area.workareaname).FirstOrDefault();
|
|
|
|
var file = _workareasModelArray.workarea.Where(f => f.filepath == area.filepath).FirstOrDefault();
|
|
|
|
|
|
|
|
if (file == null)
|
|
|
|
if (file == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_workareasModelArray.workarea.Add(area);
|
|
|
|
_workareasModelArray.workarea.Add(area);
|
|
|
|
WorkareaNameSource.Add(area.workareaname);
|
|
|
|
WorkareaNameSource.Add(area.workareaname);
|
|
|
|
|
|
|
|
WareaSelectedIndex= WorkareaNameSource.Count()-1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//更新当前工区目录
|
|
|
|
|
|
|
|
file.filepath = area.filepath;
|
|
|
|
|
|
|
|
WareaSelectedIndex = _workareasModelArray.selectIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DelegateCommand DeleteItemCommand => new(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (MessageBox.Show($"删除{WareaModel.workareaname}工区所有文件?", "提示", MessageBoxButton.OKCancel,
|
|
|
|
|
|
|
|
MessageBoxImage.Exclamation) == MessageBoxResult.OK)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (Directory.Exists(WareaModel.savepath))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Directory.Delete(WareaModel.savepath, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var area= _workareasModelArray.workarea.Where(a => a.workareaname == WareaModel.workareaname).FirstOrDefault();
|
|
|
|
|
|
|
|
WorkareaNameSource.Remove(WareaModel.workareaname);
|
|
|
|
|
|
|
|
_workareasModelArray.workarea.Remove(area);
|
|
|
|
|
|
|
|
WareaSelectedIndex =0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
public DelegateCommand<object> SelectFileCommand => new((obj) =>
|
|
|
|
public DelegateCommand<object> SelectFileCommand => new((obj) =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string para = obj.ToString();
|
|
|
|
string para = obj.ToString();
|
|
|
@ -183,7 +210,6 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
if (MessageBox.Show("确认修改?", "参数设置", MessageBoxButton.OKCancel,
|
|
|
|
if (MessageBox.Show("确认修改?", "参数设置", MessageBoxButton.OKCancel,
|
|
|
|
MessageBoxImage.Exclamation) == MessageBoxResult.OK)
|
|
|
|
MessageBoxImage.Exclamation) == MessageBoxResult.OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
//1 Workarea配置更新,选择的索引
|
|
|
|
//1 Workarea配置更新,选择的索引
|
|
|
|
JsonParser.WriteSystemConfigFile(Path.Combine(JsonParser.workareaPath, "Workareas.json"), _workareasModelArray);
|
|
|
|
JsonParser.WriteSystemConfigFile(Path.Combine(JsonParser.workareaPath, "Workareas.json"), _workareasModelArray);
|
|
|
|
_wareaModel.apmModel.channels = new List<StationChannelsModel>
|
|
|
|
_wareaModel.apmModel.channels = new List<StationChannelsModel>
|
|
|
@ -197,8 +223,8 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
JsonParser.WriteSystemConfigFile(Path.Combine(_wareaModel.savepath, "Workarea.json"), _wareaModel);
|
|
|
|
JsonParser.WriteSystemConfigFile(Path.Combine(_wareaModel.savepath, "Workarea.json"), _wareaModel);
|
|
|
|
string wareaJson = JsonConvert.SerializeObject(_wareaModel);
|
|
|
|
|
|
|
|
var curWorkarea = JsonConvert.DeserializeObject<WorkareaModel>(wareaJson);
|
|
|
|
var curWorkarea = JsonParser.DeepCopy<WorkareaModel>(_wareaModel);
|
|
|
|
if (!string.IsNullOrEmpty(apmStationFile))
|
|
|
|
if (!string.IsNullOrEmpty(apmStationFile))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string destFileName = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.station));
|
|
|
|
string destFileName = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.station));
|
|
|
|