Beispiel #1
0
        private void DrawPseudostate(TNode state, D2dGraphics g, bool outline)
        {
            RectangleF bounds       = state.Bounds;
            D2dEllipse ellipse      = (D2dEllipse)bounds;
            D2dEllipse innerEllipse = ellipse;

            innerEllipse.RadiusX = 4;
            innerEllipse.RadiusY = 4;
            PointF c = ellipse.Center;

            g.FillEllipse(ellipse, m_theme.FillBrush);

            switch (state.Type)
            {
            case StateType.Start:
                g.FillEllipse(innerEllipse, m_theme.TextBrush);
                break;

            case StateType.Final:
                g.DrawEllipse(ellipse, m_theme.OutlineBrush, 3.0f);
                g.FillEllipse(innerEllipse, m_theme.TextBrush);
                break;

            case StateType.ShallowHistory:
                g.DrawText("H", m_centerText, bounds, m_theme.TextBrush);
                break;

            case StateType.DeepHistory:
                g.DrawText("H*", m_centerText, bounds, m_theme.TextBrush);
                break;

            case StateType.Conditional:
                g.DrawText("C", m_centerText, bounds, m_theme.TextBrush);
                break;
            }

            if (outline && state.Type != StateType.Final)
            {
                g.DrawEllipse(ellipse, m_theme.OutlineBrush);
            }
        }
Beispiel #2
0
        private void Draw(TNode node, D2dGraphics g)
        {
            RectangleF             boundRect = node.Bounds;
            D2dEllipse             bounds    = (D2dEllipse)boundRect;
            D2dLinearGradientBrush brush
                = m_theme.FillGradientBrush;

            brush.StartPoint = boundRect.Location;
            brush.EndPoint   = new PointF(boundRect.Right, boundRect.Bottom);
            g.FillEllipse(bounds, brush);
            g.DrawEllipse(bounds, m_theme.OutlineBrush);
            g.DrawText(node.TitleText, m_theme.TextFormat, boundRect, m_theme.TextBrush);
        }
        private void DrawGhost(TNode state, D2dGraphics g)
        {
            RectangleF bounds = state.Bounds;

            if (state.Type != StateType.Normal)
            {
                g.FillEllipse((D2dEllipse)bounds, m_theme.GhostBrush);
            }
            else
            {
                m_stateRect.Rect = bounds;
                g.FillRoundedRectangle(m_stateRect, m_theme.GhostBrush);
            }
        }
Beispiel #4
0
            private void PaintD2d(object sender, EventArgs e)
            {
                if (!IsContextValid())
                {
                    return;
                }
                var control       = (D2dAdaptableControl)AdaptedControl;
                var sourceControl = m_birdEyeView.m_sourceControl;

                var srcXformAdapter = sourceControl.Cast <ITransformAdapter>();

                D2dGraphics g        = control.D2dGraphics;
                Matrix3x2F  invXform = g.Transform;
                float       scaleX   = invXform.M11;

                invXform.Invert();

                Point cpt = control.PointToClient(Control.MousePosition);
                var   gpt = Matrix3x2F.TransformPoint(invXform, cpt);

                // transform client rect of source control to graph space.
                var srcInvXform = Matrix3x2F.Invert(srcXformAdapter.Transform);
                var grect       = Matrix3x2F.Transform(srcInvXform, sourceControl.ClientRectangle);

                float strokeWidth = m_dragging || (grect.Contains(gpt) && control.Focused)
                    ? 3.0f / scaleX : 1.5f / scaleX;

                g.DrawRectangle(grect, Color.Yellow, strokeWidth);

                Point srcCpt = sourceControl.PointToClient(Control.MousePosition);
                var   srcGpt = Matrix3x2F.TransformPoint(srcInvXform, srcCpt);

                if (sourceControl.Focused && grect.Contains(srcGpt) &&
                    !control.ClientRectangle.Contains(cpt))
                {
                    float      cursorSize = 7.0f / scaleX;
                    RectangleF cursorRect = new RectangleF(srcGpt.X - cursorSize / 2, srcGpt.Y - cursorSize / 2,
                                                           cursorSize, cursorSize);
                    g.FillEllipse(cursorRect, Color.Yellow);
                }
            }
Beispiel #5
0
 private void DrawGhost(TNode node, D2dGraphics g)
 {
     g.FillEllipse((D2dEllipse)node.Bounds, m_theme.GhostBrush);
 }
        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;
                //    }
                //}
            }
        }