예제 #1
0
        private void DrawGroupPinNodeFakeEdge(ICircuitGroupPin <TElement> grpPin, PointF grpPinPos, bool inputSide, DiagramDrawingStyle style, D2dGraphics g)
        {
            ElementTypeInfo info = GetElementTypeInfo(grpPin.InternalElement, g);

            if (inputSide)
            {
                PointF op = grpPinPos;
                float  x1 = op.X + CircuitGroupPinInfo.FloatingPinBoxWidth;
                float  y1 = op.Y + CircuitGroupPinInfo.FloatingPinBoxHeight / 2;

                Point ip = grpPin.InternalElement.Bounds.Location;
                float x2 = ip.X;
                float y2 = ip.Y + GetPinOffset(grpPin.InternalElement, grpPin.InternalPinIndex, true);

                DrawWire(g, m_fakeInputLinkPen, x1, y1, x2, y2, 1.0f, m_VirtualLinkStrokeStyle);
            }
            else
            {
                Point op = grpPin.InternalElement.Bounds.Location;
                float x1 = op.X + info.Size.Width;
                float y1 = op.Y + GetPinOffset(grpPin.InternalElement, grpPin.InternalPinIndex, false);

                PointF ip = grpPinPos;
                float  x2 = ip.X;
                float  y2 = ip.Y + CircuitGroupPinInfo.FloatingPinBoxHeight / 2;
                DrawWire(g, m_fakeOutputLinkPen, x1, y1, x2, y2, 1.0f, m_VirtualLinkStrokeStyle);
            }
        }
예제 #2
0
        /// <summary>
        /// Gets the bounding rectangle of a circuit element in local space, which is the same as
        /// world space except for sub-circuits</summary>
        /// <param name="pin">floating group pin to get the bounds for</param>
        /// <param name="inputSide">true if the pin is on the left side?</param>
        /// <param name="g">Graphics object</param>
        /// <returns>Rectangle completely bounding the node</returns>
        public virtual RectangleF GetBounds(ICircuitGroupPin <TElement> pin, bool inputSide, D2dGraphics g)
        {
            var p      = GetGroupPinLocation(pin, inputSide);
            var result = new RectangleF(p.X, p.Y, CircuitGroupPinInfo.FloatingPinBoxWidth, CircuitGroupPinInfo.FloatingPinBoxHeight);

            return(result);
        }
예제 #3
0
 private PointF GetGroupPinLocation(ICircuitGroupPin <TElement> grpPin, bool inputSide)
 {
     if (inputSide)
     {
         return(new PointF(VisibleWorldBounds.X + CircuitGroupPinInfo.FloatingPinBoxWidth + Theme.PinMargin, grpPin.Bounds.Location.Y));
     }
     else
     {
         return(new PointF(VisibleWorldBounds.X + VisibleWorldBounds.Width - Theme.PinMargin - 2 * CircuitGroupPinInfo.FloatingPinBoxWidth - 16, grpPin.Bounds.Location.Y));
     }
 }
예제 #4
0
        private RectangleF GetThumbtackRect(ICircuitGroupPin <TElement> grpPin, bool inputSide)
        {
            PointF p = GetGroupPinLocation(grpPin, inputSide);

            int xOffset = inputSide ? CircuitGroupPinInfo.FloatingPinBoxWidth : -D2dUtil.ThumbtackSize;

            if (grpPin.Info.Pinned)
            {
                return(new RectangleF(p.X + xOffset, p.Y, D2dUtil.ThumbtackSize, D2dUtil.ThumbtackSize));
            }

            return(new RectangleF(p.X + xOffset, p.Y + Theme.PinSize / 2.0f, D2dUtil.ThumbtackSize, D2dUtil.ThumbtackSize));
        }
예제 #5
0
        private RectangleF GetVisibilityCheckRect(ICircuitGroupPin <TElement> grpPin, bool inputSide)
        {
            RectangleF pinRect, eyeRect;
            PointF     p     = GetGroupPinLocation(grpPin, inputSide);
            float      width = CircuitGroupPinInfo.FloatingPinBoxWidth - Theme.PinSize - 3;

            if (inputSide)
            {
                pinRect = new RectangleF(p.X + CircuitGroupPinInfo.FloatingPinBoxWidth - Theme.PinSize,
                                         grpPin.Bounds.Location.Y + Theme.PinMargin + Theme.PinOffset,
                                         Theme.PinSize, Theme.PinSize);

                eyeRect = new RectangleF(p.X - 2 - width, pinRect.Y, width, pinRect.Height);
            }
            else
            {
                pinRect = new RectangleF(p.X + 1, grpPin.Bounds.Location.Y + Theme.PinMargin + Theme.PinOffset,
                                         Theme.PinSize, Theme.PinSize);
                eyeRect = new RectangleF(p.X + CircuitGroupPinInfo.FloatingPinBoxWidth + 2, pinRect.Y, width, pinRect.Height);
            }
            return(eyeRect);
        }
예제 #6
0
        /// <summary>
        /// Draws floating group pin</summary>
        /// <param name="grpPin">Group pin</param>
        /// <param name="inputSide">True for input pin, false for output pin</param>
        /// <param name="style">DiagramDrawingStyle</param>
        /// <param name="g">Graphics object</param>
        public void DrawFloatingGroupPin(ICircuitGroupPin <TElement> grpPin, bool inputSide, DiagramDrawingStyle style, D2dGraphics g)
        {
            SizeF  pinNameSize = g.MeasureText(grpPin.Name, Theme.TextFormat);
            PointF p;

            if (inputSide)
            {
                p = GetGroupPinLocation(grpPin, true);

                RectangleF pinRect = new RectangleF(p.X + CircuitGroupPinInfo.FloatingPinBoxWidth - Theme.PinSize,
                                                    grpPin.Bounds.Location.Y + Theme.PinMargin + Theme.PinOffset,
                                                    Theme.PinSize, Theme.PinSize);
                // draw output pin for input floating pins
                g.DrawRectangle(pinRect, m_subGraphPinPen);
                if (grpPin.Info.Pinned)
                {
                    D2dUtil.DrawPin((int)(p.X + CircuitGroupPinInfo.FloatingPinBoxWidth), (int)p.Y, true, true, m_pinBrush, g);
                }
                else
                {
                    D2dUtil.DrawPin((int)(p.X + CircuitGroupPinInfo.FloatingPinBoxWidth), (int)p.Y + Theme.PinSize / 2, false, true, m_pinBrush, g);
                }

                RectangleF bounds    = new RectangleF(p.X, p.Y, CircuitGroupPinInfo.FloatingPinBoxWidth, CircuitGroupPinInfo.FloatingPinBoxHeight);
                RectangleF alignRect = new RectangleF(
                    bounds.Left, bounds.Bottom + Theme.PinMargin, pinNameSize.Width, Theme.RowSpacing);
                var textAlignment = Theme.TextFormat.TextAlignment;
                Theme.TextFormat.TextAlignment = D2dTextAlignment.Leading;
                g.DrawText(grpPin.Name, Theme.TextFormat, alignRect.Location, Theme.TextBrush);
                Theme.TextFormat.TextAlignment = textAlignment;
            }
            else
            {
                // assume vertical scroll bar width = 16
                p = GetGroupPinLocation(grpPin, false);

                RectangleF pinRect = new RectangleF(p.X + 1, grpPin.Bounds.Location.Y + Theme.PinMargin + Theme.PinOffset,
                                                    Theme.PinSize, Theme.PinSize);
                // draw input pin for output floating pins
                g.DrawRectangle(pinRect, m_subGraphPinPen);
                // draw pin icon
                if (grpPin.Info.Pinned)
                {
                    D2dUtil.DrawPin((int)p.X, (int)p.Y, true, false, m_pinBrush, g);
                }
                else
                {
                    D2dUtil.DrawPin((int)p.X, (int)p.Y + Theme.PinSize / 2, false, false, m_pinBrush, g);
                }

                // draw label
                RectangleF bounds     = new RectangleF(p.X, p.Y, CircuitGroupPinInfo.FloatingPinBoxWidth, CircuitGroupPinInfo.FloatingPinBoxHeight);
                RectangleF alignRectF = new RectangleF(bounds.Right - pinNameSize.Width, bounds.Bottom + Theme.PinMargin,
                                                       pinNameSize.Width, Theme.RowSpacing);

                var textAlignment = Theme.TextFormat.TextAlignment;
                Theme.TextFormat.TextAlignment = D2dTextAlignment.Trailing;
                g.DrawText(grpPin.Name, Theme.TextFormat, alignRectF, Theme.TextBrush);
                Theme.TextFormat.TextAlignment = textAlignment;
            }

            // draw the fake pin node itself
            float savedStrokeWidth = Theme.StrokeWidth;

            Theme.StrokeWidth = 2.0f;
            if (style == DiagramDrawingStyle.Normal)
            {
                g.DrawRectangle(new RectangleF(p.X, p.Y, CircuitGroupPinInfo.FloatingPinBoxWidth, CircuitGroupPinInfo.FloatingPinBoxHeight), m_subGraphPinNodePen);
            }
            else
            {
                g.DrawRectangle(new RectangleF(p.X, p.Y, CircuitGroupPinInfo.FloatingPinBoxWidth, CircuitGroupPinInfo.FloatingPinBoxHeight), Theme.HotBrush);
            }
            Theme.StrokeWidth = savedStrokeWidth;


            if (!grpPin.Info.ExternalConnected)
            {
                RectangleF eyeRect = GetVisibilityCheckRect(grpPin, inputSide);
                g.DrawEyeIcon(eyeRect, grpPin.Info.Visible ? m_visiblePinBrush : m_hiddrenPinBrush, 1.0f);
            }

            // draw fake edge that connects group pin fake node
            DrawGroupPinNodeFakeEdge(grpPin, p, inputSide, style, g);
        }