/// <summary> /// 添加或删除时间节点 /// </summary> /// <param name="str"></param> private void AddOrDeleteTimePoint(String str) { if (str.Equals("Add")) { GetNumberDialog dialog = new GetNumberDialog(StaticConstant.mw, "TheFrameOfTheNewNodeColon", false, model.LiTime, false); if (dialog.ShowDialog() == true) { int[] x = new int[100]; for (int j = 0; j < 100; j++) { x[j] = 0; } InsertTimePoint(dialog.OneNumber, x); } } else if (str.Equals("AddStart")) { //如果已经有该时间点,报错 if (model.LiTime.Contains(0)) { new MessageDialog(StaticConstant.mw, "TheFrameHasATimeNode").ShowDialog(); } else { int[] x = new int[100]; for (int i = 0; i < 100; i++) { x[i] = 0; } InsertTimePoint(0, x); } } else if (str.Equals("Delete")) { if (model.LiTime.Count == 0) { return; } OkOrCancelDialog oocd = new OkOrCancelDialog(StaticConstant.mw, "WhetherToDeleteTheTimeNode"); if (oocd.ShowDialog() == true) { model.NowData.Remove(model.LiTime[model.NowTimePoint - 1]); model.LiTime.RemoveAt(model.NowTimePoint - 1); if (model.LiTime.Count == 0) { model.NowTimePoint = 0; } else { if (model.NowTimePoint == 1) { model.NowTimePoint = 1; } else { model.NowTimePoint--; } } model.AllTimePoint -= 1; List <int> li = model.LiTime; model.LiTime = li; } } else { String strTime = str.Trim(); if (strTime.Trim().Equals("")) { return; } int time = 0; try { if (strTime.Contains("+")) { //当前时间 + time = int.Parse(strTime) + int.Parse(str.Substring(1)); } else if (strTime.Contains("-")) { //当前时间 - time = int.Parse(strTime) - int.Parse(str.Substring(1)); } else { //当前时间 time = int.Parse(strTime); } if (time < 0) { new MessageDialog(StaticConstant.mw, "TheInputFormatIsIncorrect").ShowDialog(); return; } } catch { new MessageDialog(StaticConstant.mw, "TheInputFormatIsIncorrect").ShowDialog(); return; } //如果已经有该时间点,报错 if (model.LiTime.Contains(time)) { new MessageDialog(StaticConstant.mw, "TheFrameHasATimeNode").ShowDialog(); } else { int[] x = new int[100]; for (int i = 0; i < 100; i++) { x[i] = 0; } InsertTimePoint(time, x); } } }