private void Add()
{
try
{
if (this.SystemModelViewModel.ConstructedSystemModeList.Count == 0)
{
MessageBox.Show("请先添加系统模式!", "警告", System.Windows.MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
if (this.SystemModelViewModel.ConstructedSystemModeList.Count > 0 && this.SystemModelViewModel.CurrentConstructedSystemModel == null)
{
MessageBox.Show("请选择一个系统模式!", "警告", System.Windows.MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
WorkingmModeSelectViewModel selectViewModel = new WorkingmModeSelectViewModel(this);
this.GetService<IEnvironment>().GetService<WorkBenchViewModel>().ShowChildDialog(selectViewModel);
if (selectViewModel.DialogResult != true)
return;
List<Model.Project.WorkingMode> wmList = new List<Model.Project.WorkingMode>();
selectViewModel.SaveLastSelectedWM(selectViewModel.ModuleSN);
if (selectViewModel.WmDic.Count == 0)
{
foreach (var wm in selectViewModel.WorkingModeList.Where(p => p.IsSelected))
{
wmList.Add(wm.WorkingModeItem);
}
}
else
{
foreach (var keyvalue in selectViewModel.WmDic)
{
foreach (var wm in keyvalue.Value)
{
wmList.Add(wm.WorkingModeItem);
}
}
}
foreach (var wm in wmList)
{
if (!this.WorkingModeList.Contains(wm))
this.WorkingModeList.Add(wm);
}
_isNewState = true;
}
catch (Exception ex)
{
MessageBox.Show("新增的时候出错!", "警告", System.Windows.MessageBoxButton.OK, MessageBoxImage.Warning);
}
}