void miMakeList_Click(object sender, EventArgs e)
        {
            MethodDiagramViewer mv = this.Parent as MethodDiagramViewer;

            if (mv != null)
            {
                ISelectionService selectionService = (ISelectionService)this.GetService(typeof(ISelectionService));
                if (selectionService != null)
                {
                    ICollection ic = selectionService.GetSelectedComponents();
                    if (ic != null)
                    {
                        List <ActionViewer> avs = new List <ActionViewer>();
                        foreach (object v in ic)
                        {
                            ActionViewer av = v as ActionViewer;
                            if (av != null)
                            {
                                avs.Add(av);
                            }
                        }
                        if (avs.Count > 0)
                        {
                            mv.CreateActionList(avs);
                        }
                    }
                }
            }
        }
        protected override void OnImportAction()
        {
            base.OnImportAction();
            ISingleAction av = this.ActionObject as ISingleAction;

            if (av.ActionData != null)
            {
                ActionName  = av.ActionData.ActionName;
                Description = av.ActionData.Description;
                MethodDiagramViewer   mv = this.Parent as MethodDiagramViewer;
                List <ParameterValue> ps = av.ActionData.ParameterValues;
                if (ps != null && ps.Count > 0)
                {
                    foreach (ParameterValue p in ps)
                    {
                        if (p != null)
                        {
                            p.SetCustomMethod(mv.DesignerHolder.Method);
                        }
                    }
                }
            }
            else
            {
                DesignUtil.WriteToOutputWindowAndLog("Action data for {0} not found for [{1}]. You may delete the action from the method and re-create it.", av.ActionId, this.ActionName);
            }
        }
示例#3
0
        private void miSetProperty_Click(object sender, EventArgs e)
        {
            MenuItemDataProperty data = (MenuItemDataProperty)(((MenuItem)sender).Tag);
            MethodDiagramViewer  mv   = MethodViewer.GetCurrentViewer();
            ActionClass          act  = OnCreateSetPropertyAction(data);

            if (act != null)
            {
                if (!(this.ClassPointer is LocalVariable))
                {
                    if (MethodEditContext.IsWebPage)
                    {
                        if (!MethodEditContext.CheckAction(act, this.FindForm()))
                        {
                            return;
                        }
                    }
                }
                act.SetScopeMethod(_methodClass);
                int x = (mv.Width / 4 - 20) / 2;
                int y = (mv.Height / 4 - 20) / 2;
                if (x < 30)
                {
                    x = 30;
                }
                if (y < 30)
                {
                    y = 30;
                }
                mv.AddNewAction(act, new Point(x, y));
            }
        }
示例#4
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;
                }
            }
        }
        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());
                        }
                    }
                }
            }
        }
        public override bool LoadToDesigner(List <uint> usedBranches, MethodDiagramViewer designer)
        {
            if (usedBranches.Contains(this.BranchId))
            {
                return(false);
            }
            usedBranches.Add(this.BranchId);
            EventAction ea = AssignedActions;

            if (ea != null)
            {
                foreach (TaskID tid in ea.TaskIDList)
                {
                    HandlerMethodID hmid = tid as HandlerMethodID;
                    if (hmid != null)
                    {
                        if (hmid.HandlerMethod != null)
                        {
                        }
                    }
                    else
                    {
                        IAction a = tid.GetPublicAction(this.OwnerMethod.RootPointer);
                        if (a != null)
                        {
                        }
                    }
                }
            }
            return(designer.LoadAction(this));
        }
示例#7
0
        private void miSetEvents_Click(object sender, EventArgs e)
        {
            MethodDiagramViewer   mv     = MethodViewer.GetCurrentViewer();
            ILimnorDesignerLoader loader = mv.Loader;
            DlgSelectEvent        dlg    = new DlgSelectEvent();

            dlg.LoadData(_menuData);
            DialogResult ret = dlg.ShowDialog(this.FindForm());

            if (dlg.FrequentlyUsedMethodsChanged)
            {
                _menuData.RemoveMenuCollection();
                loader.DesignPane.ResetContextMenu();
            }
            if (ret == DialogResult.OK)
            {
                IEvent ei = dlg.ReturnEventInfo;
                if (ei != null)
                {
                    EventPointer ep = ei as EventPointer;
                    if (ep == null)
                    {
                        EventClass ec = ei as EventClass;
                        if (ec != null)
                        {
                            EventClass ec2 = (EventClass)ec.Clone();
                            ec2.SetHolder(this.ClassPointer);
                            CustomEventPointer cep = new CustomEventPointer(ec2, this.ClassPointer);
                            ei = cep;
                        }
                    }
                    assignAction(ei);
                }
            }
        }
        /// <summary>
        /// check dragged components are within their parent
        /// </summary>
        /// <param name="g">represent the Form</param>
        /// <param name="e"></param>
        /// <returns></returns>
        private bool candrop(Glyph g, System.Windows.Forms.DragEventArgs e)
        {
            bool bRet = false;

            if (ComponentsDraged != null && ComponentsDraged.Count > 0)
            {
                System.Windows.Forms.Design.Behavior.ControlBodyGlyph cbg = g as System.Windows.Forms.Design.Behavior.ControlBodyGlyph;
                if (cbg != null)
                {
                    MethodDiagramViewer mv = cbg.RelatedComponent as MethodDiagramViewer;
                    if (mv != null)
                    {
                        bRet = true;
                        IEnumerator ie = ComponentsDraged.GetEnumerator();
                        while (ie.MoveNext())
                        {
                            ActionViewer v = ie.Current as ActionViewer;
                            if (v != null)
                            {
                                if (mv.GUID != v.ParentGuid)
                                {
                                    bRet = false;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            if (!bRet)
            {
                e.Effect = System.Windows.Forms.DragDropEffects.None;
            }
            return(bRet);
        }
示例#9
0
 private void assignAction(IEvent ep)
 {
     if (ep != null)
     {
         MethodDiagramViewer mv = MethodViewer.GetCurrentViewer();
         mv.AddAssignActionsAction(ep);
     }
 }
        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;
                }
            }
        }
示例#11
0
        private void miAssignEvent_Click(object sender, EventArgs e)
        {
            MenuItemDataEvent   data = (MenuItemDataEvent)(((MenuItem)sender).Tag);
            MethodDiagramViewer mv   = MethodViewer.GetCurrentViewer();
            IEvent ep = data.CreateEventPointer(data.Owner);

            if (ep != null)
            {
                assignAction(ep);
            }
        }
        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);
            }
        }
 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;
 }
        protected override void OnEditAction()
        {
            MethodDiagramViewer mv = this.DiagramViewer;

            if (mv != null)
            {
                LimnorProject           project = mv.Project;
                AB_DecisionTableActions av      = this.ActionObject as AB_DecisionTableActions;
                //string name = av.Name;
                DlgDecisionTable dlg = new DlgDecisionTable();
                dlg.LoadData(av.DecisionTable, mv.Method, project, mv.DesignerHolder);
                if (dlg.ShowDialog(this.FindForm()) == DialogResult.OK)
                {
                    av.DecisionTable = dlg.Result;
                    mv.Changed       = true;
                }
            }
        }
示例#15
0
        private void createNewAction(MenuItemDataMethod data)
        {
            ILimnorDesignPane dp  = Designer.Project.GetTypedData <ILimnorDesignPane>(Designer.ObjectMap.ClassId);
            IAction           act = OnCreateAction(data, dp);

            if (act != null)
            {
                if (!(this.ClassPointer is LocalVariable))
                {
                    if (MethodEditContext.IsWebPage)
                    {
                        if (!MethodEditContext.CheckAction(act, this.FindForm()))
                        {
                            return;
                        }
                    }
                }
                MethodDiagramViewer mv = MethodViewer.GetCurrentViewer();
                act.ScopeMethod  = _methodClass;
                act.ActionHolder = MethodViewer.ActionsHolder;
                double x0, y0;
                ComponentIconEvent.CreateRandomPoint((double)((mv.Width - 20) / 2), out x0, out y0);
                if (x0 < 0)
                {
                    x0 = 10;
                }
                if (y0 < 0)
                {
                    y0 = 10;
                }
                ActionViewer av = MethodViewer.AddNewAction(act, new Point((mv.Width - 20) / 2 + (int)x0, (mv.Height - 20) / 2 + (int)y0));
                if (av.Parent == null)
                {
#if DEBUG
                    MessageBox.Show("Adding action viewer failed (1)");
#endif
                    mv.Controls.Add(av);
                }
                else
                {
                }
            }
        }
        protected override void OnReplaceAction()
        {
            MethodDiagramViewer mv = this.Parent as MethodDiagramViewer;

            if (mv != null)
            {
                ISingleAction  av             = this.ActionObject as ISingleAction;
                List <IAction> actReplaceList = DesignUtil.SelectAction(mv.DesignerHolder.Loader, av.ActionData, null, false, mv.DesignerHolder.Method, mv.ActionsHolder, this.FindForm());
                if (actReplaceList != null && actReplaceList.Count > 0)
                {
                    av.ActionId   = new TaskID(actReplaceList[0].WholeActionId);
                    av.ActionData = actReplaceList[0];
                    IMethodDiagram p = this.Parent as IMethodDiagram;
                    if (p != null)
                    {
                        p.OnActionNameChanged(av.ActionData.ActionName, av.ActionId.WholeTaskId);
                    }
                }
            }
        }
        void miSelectConstructor_Click(object sender, EventArgs e)
        {
            MethodDiagramViewer mv = this.Parent as MethodDiagramViewer;

            if (mv != null)
            {
                AB_Constructor           av  = this.ActionObject as AB_Constructor;
                IConstructor             cp  = av.ActionData.ActionMethod as IConstructor;
                LocalVariable            lv  = cp.Owner as LocalVariable;
                dlgConstructorParameters dlg = new dlgConstructorParameters();
                dlg.SetMethod(mv.DesignerHolder.Method);
                dlg.LoadData(lv);
                dlg.LocateConstructor(cp);
                if (dlg.ShowDialog(this.FindForm()) == DialogResult.OK)
                {
                    cp.CopyFrom(dlg.Ret);
                    mv.Changed = true;
                }
            }
        }
        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 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;
                }
            }
        }
        public void ImportAction(ActionBranch item, bool isNewAction)
        {
            bLoading  = true;
            this._act = item;
            Point pos = new Point(item.Location.X < 0 ? 0 : item.Location.X, item.Location.Y < 0 ? 0 : item.Location.Y);

            this.Location    = pos;
            this.Size        = item.Size;
            this.Description = item.Description;
            this.TextFont    = item.TextFont;
            this.TextColor   = item.TextColor;
            OnImportAction();
            bLoading = false;
            setupPorts(isNewAction);
            CreateImage();
            MethodDiagramViewer dv = this.Parent as MethodDiagramViewer;

            if (dv != null)
            {
                _parentGuid = dv.GUID;
            }
        }
示例#21
0
        void miNewInstance_Click(object sender, EventArgs e)
        {
            MethodDiagramViewer mv = MethodViewer.GetCurrentViewer();

            if (mv != null)
            {
                MemberComponentId     lv  = this.ClassPointer as MemberComponentId;
                ActionAssignComponent act = new ActionAssignComponent(MethodViewer.Method.RootPointer);
                act.ActionOwner = lv;
                act.ActionId    = (UInt32)(Guid.NewGuid().GetHashCode());
                act.ActionName  = MethodViewer.RootClass.CreateNewActionName("Create" + lv.ObjectType.Name);
                Point p = mv.PointToClient(System.Windows.Forms.Cursor.Position);
                if (p.X < 0)
                {
                    p.X = 10;
                }
                if (p.Y < 0)
                {
                    p.Y = 10;
                }
                act.ValidateParameterValues();
                mv.AddNewAction(act, p);
            }
        }
        protected override void OnEditAction()
        {
            MethodDiagramViewer mv = this.DiagramViewer;

            if (mv != null)
            {
                ILimnorDesignerLoader loader = mv.DesignerHolder.Designer as ILimnorDesignerLoader;
                ISingleAction         av     = this.ActionObject as ISingleAction;
                string name = av.ActionData.ActionName;
                FormProgress.HideProgress();
                if (av.ActionData.Edit(loader.Writer, mv.Method, this.FindForm(), false))
                {
                    if (name != av.ActionData.ActionName)
                    {
                        IMethodDiagram p = this.Parent as IMethodDiagram;
                        if (p != null)
                        {
                            p.OnActionNameChanged(av.ActionData.ActionName, av.ActionId.WholeTaskId);
                        }
                    }
                    mv.Changed = true;
                }
            }
        }
示例#23
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();
                     }
                 }
             }
         }
     }
 }
 /// <summary>
 /// sub-editor
 /// </summary>
 /// <param name="designer"></param>
 /// <param name="designerType"></param>
 /// <param name="rcStart"></param>
 /// <param name="parentEditor"></param>
 public DlgMethod(ILimnorDesigner designer, Type designerType, Rectangle rcStart, MethodDiagramViewer parentEditor, UInt32 scopeId)
     : base(/*rcStart*/)
 {
     setMembers(designer, designerType, parentEditor, scopeId);
 }