Example #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);
                }
            }
        }
Example #2
0
        /// <inheritdoc />
        public override void Paint(Graphics graphics)
        {
            // paint node background
            DrawingTools.SolidBrush.Color = ColorSettings.ForNodeBackground(Node.NodeData.Type);
            graphics.FillRectangle(DrawingTools.SolidBrush, Bounds);

            // paint node border
            DrawingTools.Pen.Color = ColorSettings.ForNode(Node.NodeData.Type, SelectState);
            graphics.DrawRectangle(DrawingTools.Pen, Bounds);

            // paint name background
            DrawingTools.SolidBrush.Color = ColorSettings.ForNode(Node.NodeData.Type, SelectState);
            graphics.FillRectangle(DrawingTools.SolidBrush, nameRectangle);

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

            // paint in sockets
            foreach (NodeSocketView socket in inSockets)
            {
                socket.Paint(graphics);
            }

            // paint out sockets
            foreach (NodeSocketView socket in outSockets)
            {
                socket.Paint(graphics);
            }

            // paint variable sockets
            foreach (NodeSocketView socket in variableSockets)
            {
                if (socket.Visible)
                {
                    socket.Paint(graphics);
                }
            }

            // paint comment text
            if (!String.IsNullOrEmpty(Node.Comment))
            {
                DrawingTools.SolidBrush.Color = ColorSettings.CommentText;
                graphics.DrawString(Node.Comment, DrawingTools.Font, DrawingTools.SolidBrush, commentLocation);
            }
        }
Example #3
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);
            }
        }
        /// <inheritdoc />
        public override void Paint(Graphics graphics)
        {
            // paint variable socket
            if (this.SelectState == Scripting.SelectState.Default)
            {
                DrawingTools.SolidBrush.Color = ColorSettings.ForVariable(VariableNodeSocket.VariableType);
            }
            else if (this.SelectState == Scripting.SelectState.Hover)
            {
                DrawingTools.SolidBrush.Color = ColorSettings.Hover;
            }

            if (Type == NodeSocketType.VariableIn)
            {
                // variable in = rectangle
                graphics.FillRectangle(DrawingTools.SolidBrush, Bounds);
            }
            else
            {
                // variable out = triangle
                PointF[] triangle = new PointF[3];
                triangle[0] = new PointF(Bounds.X, Bounds.Y);
                triangle[1] = new PointF(Bounds.X + Bounds.Width, Bounds.Y);
                triangle[2] = new PointF(Bounds.X + Bounds.Width / 2f, Bounds.Y + Bounds.Height);
                graphics.FillPolygon(DrawingTools.SolidBrush, triangle);
            }

            // paint name text
            DrawingTools.SolidBrush.Color = ColorSettings.NodeSocketText;
            graphics.DrawString(Name, DrawingTools.Font, DrawingTools.SolidBrush, textLocation);

            // paint default value text
            if (VariableNodeSocket.Type == NodeSocketType.VariableIn && VariableNodeSocket.Connections.Count == 0 && !VariableNodeSocket.NodeSocketData.CanBeEmpty)
            {
                DrawingTools.SolidBrush.Color = ColorSettings.NodeVariableSocketValueText;
                graphics.DrawString(VariableNodeSocket.Value.ToString(), DrawingTools.Font, DrawingTools.SolidBrush, valueTextRectangle, valueTextFormat);
            }
        }