Ejemplo n.º 1
0
 public Rectangle(IGraphElementHost host)
     : base(host)
 {
     Position = new PointF(0, 0);
     Size     = new SizeF(40, 20);
     PPath.AddRectangle(Position.X, Position.Y, Size.Width, Size.Height);
 }
Ejemplo n.º 2
0
 public Dot(IGraphElementHost host)
     : base(host)
 {
     DotSize     = 1;
     PNode.Brush = null;
     PPath.AddRectangle(Position.X, Position.Y, DotSize, DotSize);
 }
            public void UpdateRectangle()
            {
                // create a new bounds that contains both the press and current
                // drag point.
                RectangleFx r = RectangleFx.Empty;

                r = PUtil.AddPointToRect(r, pressPoint);
                r = PUtil.AddPointToRect(r, dragPoint);

                // Set the rectangles bounds.
                rectangle.PathReference.Reset();
                rectangle.AddRectangle(r.X, r.Y, r.Width, r.Height);
            }
        /// <summary>
        /// Update the marquee bounds based on the given event data.
        /// </summary>
        /// <param name="e">A PInputEventArgs that contains the event data.</param>
        protected virtual void UpdateMarquee(PInputEventArgs e)
        {
            RectangleF r = RectangleF.Empty;

            if (marqueeParent is PCamera)
            {
                r = PUtil.AddPointToRect(r, canvasPressPt);
                r = PUtil.AddPointToRect(r, e.CanvasPosition);
            }
            else
            {
                r = PUtil.AddPointToRect(r, presspt);
                r = PUtil.AddPointToRect(r, e.Position);
            }

            r = marquee.GlobalToLocal(r);
            marquee.Reset();
            SetSafeMarqueePen(r.Width, r.Height);
            marquee.AddRectangle(r.X, r.Y, r.Width, r.Height);

            r = RectangleF.Empty;
            r = PUtil.AddPointToRect(r, presspt);
            r = PUtil.AddPointToRect(r, e.Position);

            allItems.Clear();
            PNodeFilter filter = CreateNodeFilter(r);

            foreach (PNode parent in selectableParents)
            {
                PNodeList items;
                if (parent is PCamera)
                {
                    items = new PNodeList();
                    PCamera cameraParent = (PCamera)parent;
                    for (int i = 0; i < cameraParent.LayerCount; i++)
                    {
                        cameraParent.GetLayer(i).GetAllNodes(filter, items);
                    }
                }
                else
                {
                    items = parent.GetAllNodes(filter, null);
                }

                foreach (PNode node in items)
                {
                    allItems.Add(node, true);
                }
            }
        }
Ejemplo n.º 5
0
        public WEvent(WwiseBank.Event hircEvent, float x, float y, WwiseGraphEditor grapheditor)
            : base(hircEvent, grapheditor)
        {
            outlinePen = new Pen(EventColor);
            const string s      = "Event";
            float        starty = 0;
            float        w      = 15;
            float        midW   = 0;

            varLinkBox = new PPath();
            GetLinks();
            foreach (var varLink in Varlinks)
            {
                string d  = string.Join(",", varLink.Links.Select(l => $"#{l}"));
                SText  t2 = new SText(d + "\n" + varLink.Desc)
                {
                    X        = w,
                    Y        = 0,
                    Pickable = false
                };
                w += t2.Width + 20;
                varLink.node.TranslateBy(t2.X + t2.Width / 2, t2.Y + t2.Height);
                t2.AddChild(varLink.node);
                varLinkBox.AddChild(t2);
            }
            if (Varlinks.Count != 0)
            {
                varLinkBox.AddRectangle(0, 0, w, varLinkBox[0].Height);
            }
            varLinkBox.Pickable = false;
            varLinkBox.Pen      = outlinePen;
            varLinkBox.Brush    = nodeBrush;
            outLinkBox          = new PPath();
            for (int i = 0; i < Outlinks.Count; i++)
            {
                string linkDesc = Outlinks[i].Desc;
                if (OutputNumbers && Outlinks[i].Links.Any())
                {
                    linkDesc += $": {string.Join(",", Outlinks[i].Links.Select(l => $"#{l}"))}";
                }
                SText t2 = new SText(linkDesc);
                if (t2.Width + 10 > midW)
                {
                    midW = t2.Width + 10;
                }
                //t2.TextAlignment = StringAlignment.Far;
                //t2.ConstrainWidthToTextWidth = false;
                t2.X        = 0 - t2.Width;
                t2.Y        = starty + 3;
                starty     += t2.Height + 6;
                t2.Pickable = false;
                Outlinks[i].node.TranslateBy(0, t2.Y + t2.Height / 2);
                t2.AddChild(Outlinks[i].node);
                outLinkBox.AddChild(t2);
            }
            outLinkBox.AddPolygon(new[] { new PointF(0, 0), new PointF(0, starty), new PointF(-0.5f * midW, starty + 30), new PointF(0 - midW, starty), new PointF(0 - midW, 0), new PointF(midW / -2, -30) });
            outLinkBox.Pickable = false;
            outLinkBox.Pen      = outlinePen;
            outLinkBox.Brush    = nodeBrush;
            float tW = GetTitleBox(s, w);

            if (tW > w)
            {
                if (midW > tW)
                {
                    w = midW;
                    titleBox.Width = w;
                }
                else
                {
                    w = tW;
                }
                varLinkBox.Width = w;
            }
            float h = titleBox.Height + 1;

            outLinkBox.TranslateBy(titleBox.Width / 2 + midW / 2, h + 30);
            h += outLinkBox.Height + 1;
            varLinkBox.TranslateBy(0, h);
            h     += varLinkBox.Height;
            bounds = new RectangleF(0, 0, w, h);
            AddChild(titleBox);
            AddChild(varLinkBox);
            AddChild(outLinkBox);
            SetOffset(x, y);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Overridden.  When the lens is resized this method gives us a chance to layout the
 /// lens's camera child appropriately.
 /// </summary>
 public override void LayoutChildren()
 {
     dragBar.Reset();
     dragBar.AddRectangle((float)X, (float)Y, (float)Width, (float)LENS_DRAGBAR_HEIGHT);
     camera.SetBounds(X, Y + LENS_DRAGBAR_HEIGHT, Width, Height - LENS_DRAGBAR_HEIGHT);
 }