Example #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            GraphicsState st = e.Graphics.Save();
            ActiveDrawing ei = PortOwner as ActiveDrawing;
            Point         p0 = ei.Center;
            Point         p1 = this.Center;
            double        a;

            if (p0.Y == p1.Y)
            {
                if (p1.X > p0.X)
                {
                    a = -Math.PI / 2.0;
                }
                else
                {
                    a = Math.PI / 2.0;
                }
            }
            else
            {
                a = -Math.Atan2((double)(p1.X - p0.X), ((double)(p1.Y - p0.Y)));
            }
            //move to the center of this port icon. (0,0) co-ordinates is at the left-top of the port icon.
            e.Graphics.TranslateTransform(this.Size.Width / 2, this.Size.Height / 2, System.Drawing.Drawing2D.MatrixOrder.Prepend);
            //rotate
            e.Graphics.RotateTransform((float)(a * 180.0 / Math.PI));
            //move to the left-top corner
            e.Graphics.TranslateTransform(-this.Size.Width / 2, -this.Size.Height / 2, System.Drawing.Drawing2D.MatrixOrder.Prepend);
            //do the drawing
            VplDrawing.DrawOutArrow(e.Graphics, _drawBrush, this.Size, enumPositionType.Bottom);
            //restore the transformations
            e.Graphics.Restore(st);
        }
Example #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            GraphicsState st = e.Graphics.Save();
            ActiveDrawing ei = PortOwner as ActiveDrawing;
            Point         p0 = ei.Center;
            Point         p1 = this.Center;
            double        a;

            if (p0.Y == p1.Y)
            {
                if (p1.X > p0.X)
                {
                    a = -Math.PI / 2.0;
                }
                else
                {
                    a = Math.PI / 2.0;
                }
            }
            else
            {
                a = -Math.Atan2((double)(p1.X - p0.X), ((double)(p1.Y - p0.Y)));
            }
            e.Graphics.TranslateTransform(this.Size.Width / 2, this.Size.Height / 2, System.Drawing.Drawing2D.MatrixOrder.Prepend);
            e.Graphics.RotateTransform((float)(a * 180.0 / Math.PI));
            e.Graphics.TranslateTransform(-this.Size.Width / 2, -this.Size.Height / 2, System.Drawing.Drawing2D.MatrixOrder.Prepend);
            VplDrawing.DrawInArrow(e.Graphics, _drawBrush, this.Size, enumPositionType.Bottom);
            e.Graphics.Restore(st);
        }
Example #3
0
 public void SaveIconLocations()
 {
     foreach (Control c in Controls)
     {
         ActiveDrawing ad = c as ActiveDrawing;
         if (ad != null)
         {
             ad.SaveLocation();
         }
         RelativeDrawing rd = c as RelativeDrawing;
         if (rd != null)
         {
             rd.SaveRelativePosition();
         }
     }
 }
        private void setupPorts(bool isNewAction)
        {
            if (isNewAction)
            {
                _act.InitializePorts(this);
            }
            PortCollection pc = _act.GetAllPorts();

            if (!isNewAction)
            {
                foreach (LinkLineNodePort p in pc)
                {
                    p.Owner = this;
                }
            }
            List <Control> ctrls = pc.GetAllControls(false);

            Control[] a = new Control[ctrls.Count];
            ctrls.CopyTo(a);
            Parent.Controls.AddRange(a);

            if (isNewAction)
            {
                OnInitNewPorts();
                Parent.Refresh();
            }
            else
            {
                for (int i = 0; i < a.Length; i++)
                {
                    ActiveDrawing ad = a[i] as ActiveDrawing;
                    if (ad != null)
                    {
                        ad.RestoreLocation();
                    }
                }
                OnInitExistingPorts();
            }
        }
Example #5
0
        public static EventPortOut CreateOutPort(TaskID a, EventIcon owner)
        {
            EventPortOut        po  = null;
            CustomMethodPointer cmp = null;
            HandlerMethodID     hid = a as HandlerMethodID;

            if (hid != null)
            {
                EventPortOutExecuteMethod em = new EventPortOutExecuteMethod(owner);
                em.SetMethod(hid.HandlerMethod);
                po = em;
            }
            else
            {
                if (a.Action == null)
                {
                }
                else
                {
                    IEventMapSource eir  = owner as IEventMapSource;
                    ClassPointer    root = eir.RootPointer;
                    ClassPointer    cpre = root.GetExternalExecuterClass(a.Action);
                    if (a.Action.IsStatic && cpre != null)
                    {
                        EventPortOutClassTypeAction pct = new EventPortOutClassTypeAction(owner);
                        pct.SetOwnerClassPointer(cpre);
                        po = pct;
                    }
                    else if (a.Action.ActionMethod != null)
                    {
                        DataTypePointer dtp = a.Action.ActionMethod.Owner as DataTypePointer;
                        if (dtp != null)
                        {
                            EventPortOutTypeAction pot = new EventPortOutTypeAction(owner);
                            pot.SetOwnerType(dtp.BaseClassType);
                            po = pot;
                        }
                        else
                        {
                            cmp = a.Action.ActionMethod as CustomMethodPointer;
                            if (cmp != null && cmp.Holder.DefinitionClassId == a.ClassId)
                            {
                                EventPortOutExecuteMethod em = new EventPortOutExecuteMethod(owner);
                                MethodClass mc = cmp.MethodPointed as MethodClass;
                                if (mc != null)
                                {
                                    em.SetMethod(mc);
                                }
                                po = em;
                            }
                            else
                            {
                                po = null;
                                SetterPointer sp = a.Action.ActionMethod as SetterPointer;
                                if (sp != null)
                                {
                                    CustomPropertyPointer cpp = sp.SetProperty as CustomPropertyPointer;
                                    if (cpp != null)
                                    {
                                        EventPortOutSetProperty posp = new EventPortOutSetProperty(owner);
                                        posp.SetProperty(cpp.Property);
                                        posp.PropertyId = cpp.MemberId;
                                        po = posp;
                                    }
                                }
                                if (po == null)
                                {
                                    EventPortOutExecuter pe = new EventPortOutExecuter(owner);
                                    pe.ActionExecuterId = a.Action.ExecuterMemberId;
                                    po = pe;
                                }
                            }
                        }
                    }
                    else
                    {
                        ActionAttachEvent aae = a.Action as ActionAttachEvent;
                        if (aae != null)
                        {
                            EventPortOutExecuter pe = new EventPortOutExecuter(owner);
                            pe.ActionExecuterId = a.Action.ExecuterMemberId;
                            po = pe;
                        }
                    }
                }
            }
            if (po != null)
            {
                po.AddAction(a);
                ActiveDrawing ei = owner as ActiveDrawing;
                double        x, y;
                ComponentIconEvent.CreateRandomPoint(ei.Width + ComponentIconEvent.PortSize, out x, out y);
                po.Location = new Point((int)(ei.Center.X + x), (int)(ei.Center.Y + y));
                po.SetLoaded();
                po.SaveLocation();
            }
            return(po);
        }