protected override void OnEditAction() { MethodDiagramViewer mv = this.DiagramViewer; if (mv != null) { AB_ActionList av = this.ActionObject as AB_ActionList; ActionList aList = av.Actions; DlgActionList dlg = new DlgActionList(); dlg.LoadData(aList, mv.Method, mv.Project, mv.DesignerHolder); Form f = this.FindForm(); #if DEBUG MathNode.Trace("Showing dialog"); #endif if (dlg.ShowDialog(f) == DialogResult.OK) { av.Actions = dlg.Result; mv.Changed = true; foreach (ActionItem a in aList) { if (a.Action != null && a.Action.Changed) { if (!mv.ChangedActions.ContainsKey(a.ActionId)) { mv.ChangedActions.Add(a.ActionId, a.Action); } } } } else { foreach (ActionItem a in aList) { if (a.Action != null && a.Action.Changed) { a.Action.ReloadFromXmlNode(); } } } } }
private void edit(int idx) { if (dataGridView1.CurrentCell != null && dataGridView1.CurrentCell.RowIndex >= 0 && dataGridView1.CurrentCell.RowIndex < _dataTable.Rows.Count) { if (idx == 0) { Rectangle rc = dataGridView1.GetCellDisplayRectangle(dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentCell.RowIndex, true); MathNodeRoot r = _dataTable.Rows[dataGridView1.CurrentCell.RowIndex][0] as MathNodeRoot; r.ScopeMethod = _method; r.Project = _prj; dlgMathEditor dlg = new dlgMathEditor(this.Parent.RectangleToScreen(rc)); dlg.MathExpression = r; dlg.SetScopeMethod(_method); if (dlg.ShowDialog(this.FindForm()) == DialogResult.OK) { r = (MathNodeRoot)dlg.MathExpression; _dataTable.Rows[dataGridView1.CurrentCell.RowIndex][0] = r; } } else { ActionList aList = _dataTable.Rows[dataGridView1.CurrentCell.RowIndex][1] as ActionList; ILimnorDesignPane pane = _prj.GetTypedData <ILimnorDesignPane>(_method.ClassId); if (aList == null || aList.Count == 0) { List <IAction> actList = DesignUtil.SelectAction(pane.Loader, null, null, true, _method, _method.CurrentActionsHolder, this.FindForm()); if (actList != null && actList.Count > 0) { aList = new ActionList(); aList.Name = "Actions"; // actList[0].ToString(); foreach (IAction act in actList) { aList.Add(new ActionItem(act)); } _dataTable.Rows[dataGridView1.CurrentCell.RowIndex][1] = aList; } else { return; } } IMethodDialog imd = this.FindForm() as IMethodDialog; MethodDesignerHolder v = null; if (imd != null) { v = imd.GetEditor(); } DlgActionList dlg = new DlgActionList(); dlg.LoadData(aList, _method, _prj, v); if (dlg.ShowDialog(this.FindForm()) == DialogResult.OK) { aList = dlg.Result; _dataTable.Rows[dataGridView1.CurrentCell.RowIndex][1] = aList; if (v != null) { MethodDiagramViewer mv = v.GetCurrentViewer(); foreach (ActionItem a in aList) { if (a.Action != null && a.Action.Changed) { if (!mv.ChangedActions.ContainsKey(a.ActionId)) { mv.ChangedActions.Add(a.ActionId, a.Action); } } } } } else { foreach (ActionItem a in aList) { if (a.Action != null && a.Action.Changed) { a.Action.ReloadFromXmlNode(); } } } } } }