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

            if (mv != null)
            {
                AB_AssignActions eaAct = this.ActionObject as AB_AssignActions;
                if (eaAct != null)
                {
                    MethodDesignerHolder holder = mv.DesignerHolder;
                    if (holder != null)
                    {
                        EventHandlerMethod m = eaAct.GetHandlerMethod();
                        if (m == null)
                        {
                            MessageBox.Show(mv.FindForm(), "Action data for event handler method not found. You may delete the action and re-create the action.", "Edit action", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        else
                        {
                            m.Edit(eaAct.BranchId, this.Bounds, holder.Loader, this.FindForm());
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void mi_useAs(object sender, EventArgs e)
        {
            MenuItem mi = sender as MenuItem;

            if (mi != null)
            {
                ComponentIconLocal cil = mi.Tag as ComponentIconLocal;
                if (cil != null)
                {
                    MethodDesignerHolder mh = null;
                    Control c = this.Parent;
                    while (c != null)
                    {
                        mh = c as MethodDesignerHolder;
                        if (mh != null)
                        {
                            break;
                        }
                        c = c.Parent;
                    }
                    if (mh != null)
                    {
                        ParameterClassSubMethod pc = this.ClassPointer as ParameterClassSubMethod;
                        mh.LoadNewCastAs(pc, cil.LocalPointer);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void miEditActions_Click(object sender, EventArgs e)
        {
            MethodDiagramViewer mv = this.DiagramViewer;

            if (mv != null)
            {
                AB_ForLoop           loop   = this.ActionObject as AB_ForLoop;
                MethodDesignerHolder holder = mv.DesignerHolder;
                MethodClass          mc     = loop.Method;
                DlgMethod            dlg    = mc.CreateSubMethodEditor(typeof(ActionGroupDesignerHolder), this.Parent.RectangleToScreen(this.Bounds), mv, loop.BranchId);

                try
                {
                    mc.SubMethod.Push(loop);
                    dlg.LoadActions(loop);
                    if (dlg.ShowDialog(this.FindForm()) == DialogResult.OK)
                    {
                        UpdateAction(dlg.ActionResult);
                        mv.Changed = true;
                    }
                }
                catch (Exception err)
                {
                    MathNode.Log(this.FindForm(), err);
                }
                finally
                {
                    mc.SubMethod.Pop();
                    mc.CurrentSubEditor = null;
                }
            }
        }
Ejemplo n.º 4
0
        void miNewInstance_Click(object sender, EventArgs e)
        {
            MethodDesignerHolder mv = MethodViewer;

            if (mv != null)
            {
                LocalVariable        lv  = this.ClassPointer as LocalVariable;
                ActionAssignInstance act = mv.CreateSetValueAction(lv);
                //
                Point p = mv.PointToClient(System.Windows.Forms.Cursor.Position);
                if (p.X < 0 || p.X > (mv.Width / 2))
                {
                    p.X = 10;
                }
                if (p.Y < 0 || p.Y > (mv.Height / 2))
                {
                    p.Y = 10;
                }
                ActionViewer av = mv.AddNewAction(act, p);
#if DEBUG
                if (av != null)
                {
                    if (!av.Visible)
                    {
                        MessageBox.Show("Action Viewer not visible");
                    }
                }
#endif
            }
        }
Ejemplo n.º 5
0
        void p_ValueChanged(object sender, EventArgs e)
        {
            MethodDesignerHolder mh = MethodViewer;

            if (mh != null)
            {
                mh.Changed = true;
            }
        }
        protected override void OnEditAction()
        {
            MethodDiagramViewer mv = this.DiagramViewer;

            if (mv != null)
            {
                AB_Squential av = this.ActionObject as AB_Squential;

                MethodDesignerHolder holder = mv.DesignerHolder;
                MethodClass          mc     = av.Method;
                DlgMethod            dlg    = mc.CreateSubMethodEditor(typeof(ActionGroupDesignerHolder), this.Parent.RectangleToScreen(this.Bounds), mv, av.BranchId);
                SubMethodInfoPointer smi    = null;
                try
                {
                    ISingleAction sa = av as ISingleAction;
                    if (sa != null)
                    {
                        smi = sa.ActionData.ActionMethod as SubMethodInfoPointer;
                        if (smi != null)
                        {
                            AB_SubMethodAction smb = this.ActionObject as AB_SubMethodAction;
                            smi.CreateParameters(smb);
                            av.Method.SubMethod.Push(smi);
                        }
                    }
                    //
                    dlg.LoadActions(av);
                    if (_caller == null)
                    {
                        _caller = this.FindForm();
                    }
                    if (dlg.ShowDialog(_caller) == DialogResult.OK)
                    {
                        AB_SubMethodAction abs = this.ActionObject as AB_SubMethodAction;
                        abs.CopyActionsFrom(dlg.ActionResult, dlg.ComponentIcons);
                        mv.Changed = true;
                    }
                }
                catch (Exception err)
                {
                    MathNode.Log(this.FindForm(), err);
                }
                finally
                {
                    if (smi != null)
                    {
                        if (av.Method.SubMethod.Count > 0)
                        {
                            av.Method.SubMethod.Pop();
                        }
                    }
                    mc.CurrentSubEditor = null;
                }
            }
        }
        private void miEditActions_Click(object sender, EventArgs e)
        {
            MethodDiagramViewer mv = this.DiagramViewer;

            if (mv != null)
            {
                AB_Group             group  = this.ActionObject as AB_Group;
                MethodDesignerHolder holder = mv.DesignerHolder;
                holder.OpenActionGroup(group);
            }
        }
        public void LoadData(ActionList actions, MethodClass method, LimnorProject project, MethodDesignerHolder view)
        {
            _viewer   = view;
            _actions  = actions;
            _method   = method;
            _project  = project;
            _loaded   = false;
            this.Text = string.Format("Actions - {0}", actions.Name);
#if DEBUG
            MathNode.Trace("End of DlgActionList.LoadData");
#endif
        }
 private void setMembers(ILimnorDesigner designer, Type designerType, MethodDiagramViewer parentEditor, UInt32 scopeId)
 {
     _designer = designer;
     InitializeComponent();
     holder      = (MethodDesignerHolder)(Activator.CreateInstance(designerType, _designer, scopeId));
     holder.Dock = DockStyle.Fill;
     holder.SetForSubMethod(parentEditor);
     if (parentEditor != null)
     {
         parentEditor.Method.CurrentSubEditor = holder;
     }
     this.Controls.Add(holder);
     this.Load += DlgMethod_Load;
 }
Ejemplo n.º 10
0
 public void SetMethodViewer(MethodDesignerHolder viewer)
 {
     _viewer = viewer;
 }
 public void LoadData(MethodDesignerHolder methodHolder, string initName)
 {
     _holder       = methodHolder;
     textBox1.Text = initName;
 }
Ejemplo n.º 12
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();
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 13
0
        void miDelete_Click(object sender, EventArgs e)
        {
            LocalVariable  lv   = this.ClassPointer as LocalVariable;
            List <IAction> acts = lv.RootPointer.GetRelatedActions(lv.MemberId);
            bool           bOK  = (acts.Count == 0);

            if (bOK)
            {
                MethodDesignerHolder mdh = MethodViewer;
                if (mdh != null)
                {
                    BranchList bl = mdh.ActionList;
                    if (bl != null)
                    {
                        Dictionary <UInt32, IAction> actions = new Dictionary <uint, IAction>();
                        bl.GetActionsUseLocalVariable(lv.MemberId, actions);
                        if (actions.Count > 0)
                        {
                            foreach (KeyValuePair <UInt32, IAction> kv in actions)
                            {
                                acts.Add(kv.Value);
                            }
                            bOK = false;
                        }
                    }
                }
            }
            if (!bOK)
            {
                List <ObjectTextID> objs = new List <ObjectTextID>();
                foreach (IAction a in acts)
                {
                    objs.Add(new ObjectTextID("Action", "", a.Display));
                }
                dlgObjectUsage dlg = new dlgObjectUsage();
                dlg.LoadData("There are actions using this object. These actions must be removed before this object can be removed.", "Remove object", objs);
                //currently no OK will be returned
                bOK = (dlg.ShowDialog(this.FindForm()) == DialogResult.OK);
                if (bOK)
                {
                    IList <MethodDiagramViewer> l = MethodViewer.GetViewer();
                    foreach (MethodDiagramViewer mv in l)
                    {
                        //remove local/constructor actions belong to it
                        List <IComponent> avList = new List <IComponent>();
                        for (int i = 0; i < mv.Controls.Count; i++)
                        {
                            ActionViewer av = mv.Controls[i] as ActionViewer;
                            if (av != null)
                            {
                                foreach (IAction a in acts)
                                {
                                    if (av.ActionObject.ContainsActionId(a.ActionId))
                                    {
                                        avList.Add(av);
                                    }
                                }
                            }
                        }
                        if (avList.Count > 0)
                        {
                            mv.DeleteComponents(avList.ToArray());
                        }
                    }
                }
            }
            if (bOK)
            {
                MethodViewer.RemoveLocalVariable(this);
                RemoveLabel();
                Control p = this.Parent;
                if (p != null)
                {
                    p.Controls.Remove(this);
                }
                MethodViewer.Changed = true;
            }
        }
Ejemplo n.º 14
0
 public MethodNameCreation(MethodDesignerHolder holder)
 {
     _holder = holder;
 }
 public void LoadData(DecisionTable data, MethodClass method, LimnorProject project, MethodDesignerHolder view)
 {
     _viewer         = view;
     this.ClientSize = data.ControlSize;
     decisionTableControl1.LoadData(data, method, project);
 }