示例#1
0
        /// <summary>
        /// Paints the transition.
        /// </summary>
        /// <param name="graphics"><see cref="Graphics"/> instance for painting.</param>
        public void Paint(Graphics graphics)
        {
            // paint background
            StateView.DrawingTools.SolidBrush.Color = ColorSettings.StateTransition;
            graphics.FillRectangle(StateView.DrawingTools.SolidBrush, Bounds);

            // paint border
            StateView.DrawingTools.Pen.Color = ColorSettings.ForState(StateView.SelectState, StateView.StartingState);
            graphics.DrawRectangle(StateView.DrawingTools.Pen, Bounds);

            // paint event text
            StateView.DrawingTools.SolidBrush.Color = ColorSettings.StateTransitionText;
            graphics.DrawString(Transition.Event != null ? Transition.Event.Name : String.Empty, StateView.DrawingTools.Font, StateView.DrawingTools.SolidBrush, textLocation);

            // paint transition
            if (Transition.StateTo != null)
            {
                StateView stateToView = StateView.ScreenControl.FindStateViewForState(Transition.StateTo);

                if (stateToView != null)
                {
                    PointF startingPoint, afterStartingPoint, afterStartingPointBezier;
                    PointF endingPoint, beforeEndingPointBezier;

                    float bezierWidthGap     = 80;
                    float afterStartWidthGap = 40;

                    // right side of the transition
                    if ((stateToView.Location.X + stateToView.Bounds.Width / 2f) - (Location.X + Bounds.Width / 2f) >= 0)
                    {
                        startingPoint            = new PointF(Location.X + Bounds.Width, Location.Y + Bounds.Height / 2f);
                        afterStartingPoint       = new PointF(startingPoint.X + afterStartWidthGap, startingPoint.Y);
                        afterStartingPointBezier = new PointF(startingPoint.X + bezierWidthGap, startingPoint.Y);
                    }
                    // left side of the transition
                    else
                    {
                        startingPoint            = new PointF(Location.X, Location.Y + Bounds.Height / 2f);
                        afterStartingPoint       = new PointF(startingPoint.X - afterStartWidthGap, startingPoint.Y);
                        afterStartingPointBezier = new PointF(startingPoint.X - bezierWidthGap, startingPoint.Y);
                    }

                    // left side of the state
                    if (Math.Abs(stateToView.Location.X - afterStartingPoint.X) < Math.Abs(stateToView.Location.X + stateToView.Bounds.Width - afterStartingPoint.X))
                    {
                        endingPoint             = new PointF(stateToView.Location.X, stateToView.Location.Y + stateToView.TitleHeight / 2f);
                        beforeEndingPointBezier = new PointF(endingPoint.X - bezierWidthGap, endingPoint.Y);
                    }
                    // right side of the state
                    else
                    {
                        endingPoint             = new PointF(stateToView.Location.X + stateToView.Bounds.Width, stateToView.Location.Y + stateToView.TitleHeight / 2f);
                        beforeEndingPointBezier = new PointF(endingPoint.X + bezierWidthGap, endingPoint.Y);
                    }

                    graphics.DrawBezier(StateView.DrawingTools.LinePen, startingPoint, afterStartingPointBezier, beforeEndingPointBezier, endingPoint);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Paints the state.
        /// </summary>
        /// <param name="graphics"><see cref="Graphics"/> instance for painting.</param>
        public void Paint(Graphics graphics)
        {
            // paint background
            DrawingTools.SolidBrush.Color = ColorSettings.ForState(SelectState, StartingState);
            graphics.FillRectangle(DrawingTools.SolidBrush, Bounds);

            // paint border
            DrawingTools.Pen.Color = ColorSettings.ForState(SelectState, StartingState);
            graphics.DrawRectangle(DrawingTools.Pen, Bounds);

            // paint name text
            DrawingTools.SolidBrush.Color = ColorSettings.StateText;
            graphics.DrawString(Name, DrawingTools.BoldFont, DrawingTools.SolidBrush, nameLocation);

            // paint transitions
            for (int i = 0; i < transitions.Count; ++i)
            {
                transitions[i].Paint(graphics);
            }
        }