private void miEditCondition_Click(object sender, EventArgs e)
        {
            MethodDiagramViewer mv = this.DiagramViewer;

            if (mv != null)
            {
                dlgMathEditor  dlg  = new dlgMathEditor(this.Parent.RectangleToScreen(this.Bounds));
                AB_LoopActions loop = this.ActionObject as AB_LoopActions;
                loop.Condition.Project     = mv.Project;
                loop.Condition.ScopeMethod = mv.Method;
                dlg.MathExpression         = loop.Condition;
                dlg.SetScopeMethod(mv.Method);

                if (dlg.ShowDialog(this.FindForm()) == DialogResult.OK)
                {
                    loop.Condition = (MathNodeRoot)dlg.MathExpression;

                    mv.Changed = true;
                }
            }
        }
Exemple #2
0
 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();
                     }
                 }
             }
         }
     }
 }