/// <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);
        }
        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);
                        }
                    }
                }
            }
        }
Esempio n. 3
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
            }
        }
Esempio n. 4
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
                {
                }
            }
        }
 public void InitializeInput()
 {
     //find out the Input data type
     if (_act != null)
     {
         if (_act.InPortList != null && _act.InPortList.Count > 0)
         {
             for (int i = 0; i < _act.InPortList.Count; i++)
             {
                 if (_act.InPortList[i].LinkedOutPort != null)
                 {
                     ActionViewer av = _act.InPortList[i].LinkedOutPort.Owner as ActionViewer;
                     if (av != null)
                     {
                         _act.InputName = av.ActionObject.OutputCodeName;
                         _act.InputType = av.ActionObject.OutputType;
                         _act.SetInputName(av.ActionObject.OutputCodeName, av.ActionObject.OutputType);
                         break;
                     }
                 }
             }
         }
     }
 }
Esempio n. 6
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;
            }
        }