Example #1
0
        private void d2dControl_DrawingD2d(object sender, EventArgs e)
        {
            // if we're dragging, or could drag and no one else is dragging...
            if (Dragging() ||
                (DragPossible() && !AdaptedControl.Capture))
            {
                var         d2dControl = this.AdaptedControl as D2dAdaptableControl;
                D2dGraphics gfx        = d2dControl.D2dGraphics;

                Rectangle frameRect = GetItemBounds();
                if (!frameRect.IsEmpty)
                {
                    Matrix transform = m_transformAdapter.Transform;
                    frameRect = GdiUtil.Transform(transform, frameRect);
                    frameRect.Inflate(-HandleSize, -HandleSize);
                    gfx.Transform = Matrix3x2F.Identity;
                    gfx.FillRectangle(GetHandleRect(frameRect, Direction.TopLeft), Color.Gray);
                    gfx.FillRectangle(GetHandleRect(frameRect, Direction.Top), Color.Gray);
                    gfx.FillRectangle(GetHandleRect(frameRect, Direction.TopRight), Color.Gray);
                    gfx.FillRectangle(GetHandleRect(frameRect, Direction.Right), Color.Gray);
                    gfx.FillRectangle(GetHandleRect(frameRect, Direction.BottomRight), Color.Gray);
                    gfx.FillRectangle(GetHandleRect(frameRect, Direction.Bottom), Color.Gray);
                    gfx.FillRectangle(GetHandleRect(frameRect, Direction.BottomLeft), Color.Gray);
                    gfx.FillRectangle(GetHandleRect(frameRect, Direction.Left), Color.Gray);
                    gfx.Transform = transform;
                }
            }
        }
        private void control_DrawingD2d(object sender, EventArgs e)
        {
            if (Selector.IsSelecting)
            {
                var         d2dControl = (D2dAdaptableControl)sender;
                D2dGraphics g          = d2dControl.D2dGraphics;

                // Replace transform and anti-aliasing setting.
                Matrix3x2F xform = d2dControl.D2dGraphics.Transform;
                d2dControl.D2dGraphics.Transform = Matrix3x2F.Identity;
                D2dAntialiasMode oldAA = d2dControl.D2dGraphics.AntialiasMode;
                d2dControl.D2dGraphics.AntialiasMode = D2dAntialiasMode.Aliased;

                // Draw the selection rectangle.
                Rectangle rect = MakeSelectionRect(
                    ClientToCanvas(Selector.CurrentPoint), ClientToCanvas(Selector.FirstPoint));
                rect.Intersect(AdaptedControl.ClientRectangle);
                var rectF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height);
                g.DrawRectangle(rectF, SelectionBorderColor, 1.0f, null);
                g.FillRectangle(rectF, SelectionFillColor);

                // Restore D2dGraphics settings.
                d2dControl.D2dGraphics.Transform     = xform;
                d2dControl.D2dGraphics.AntialiasMode = oldAA;
            }
        }
Example #3
0
        private void Draw(TNode state, D2dGraphics g, bool outline)
        {
            RectangleF bounds = state.Bounds;

            if (state.Type != StateType.Normal)
            {
                DrawPseudostate(state, g, outline);
            }
            else
            {
                float scaleX     = g.Transform.M11; // assume no rotation.
                float radInPixel = scaleX * CornerRadius;

                IComplexState <TNode, TEdge> complexState = state as IComplexState <TNode, TEdge>;

                StateIndicators indicators = state.Indicators;
                if ((indicators & StateIndicators.Active) != 0)
                {
                    if (radInPixel > MinRadiusInPixel)
                    {
                        D2dEllipse ellipse = new D2dEllipse();
                        ellipse.RadiusX = CornerRadius;
                        ellipse.RadiusY = CornerRadius;
                        ellipse.Center  = bounds.Location;
                        g.FillEllipse(ellipse, Color.SpringGreen);
                    }
                }


                if (radInPixel > MinRadiusInPixel)
                {
                    m_stateRect.Rect = bounds;
                    D2dLinearGradientBrush gradbrush = m_theme.FillGradientBrush;
                    gradbrush.StartPoint = bounds.Location;
                    gradbrush.EndPoint   = new PointF(bounds.Right, bounds.Bottom);

                    g.FillRoundedRectangle(m_stateRect, gradbrush);
                    if (outline)
                    {
                        g.DrawRoundedRectangle(m_stateRect, m_theme.OutlineBrush);
                    }
                }
                else
                {
                    g.FillRectangle(bounds, m_theme.FillBrush);
                    if (outline)
                    {
                        g.DrawRectangle(bounds, m_theme.OutlineBrush);
                    }
                }
                g.DrawLine(bounds.Left, bounds.Top + m_fontHeight + Margin,
                           bounds.Right, bounds.Top + m_fontHeight + Margin, m_theme.OutlineBrush);

                if ((scaleX * m_fontHeight) > MinFontHeightInPixel)
                {
                    g.DrawText(complexState.TitleText, m_theme.TextFormat,
                               new PointF(bounds.X + CornerRadius, bounds.Y + Margin), m_theme.TextBrush);
                }



                //RectangleF textBounds = new RectangleF(
                //    (float)(bounds.Left + 4),
                //    (float)(bounds.Top + m_fontHeight + 2),
                //    (float)(bounds.Width - 5),
                //    (float)(bounds.Height - m_fontHeight - 4));

                //g.DrawString(complexState.Text, m_theme.Font, m_theme.TextBrush, textBounds, s_stateTextFormat);

                //IList<int> partitionWidths = complexState.PartitionSizes;
                //if (partitionWidths.Count > 0)
                //{
                //    // draw AND-state dividers
                //    int lastDivider = bounds.Left;
                //    foreach (int width in partitionWidths)
                //    {
                //        g.DrawLine(
                //            m_dividerPen,
                //            lastDivider, bounds.Y + m_fontHeight + Margin,
                //            lastDivider, bounds.Y + bounds.Height);

                //        lastDivider += width;
                //    }
                //}
            }
        }