Example #1
0
            /// <summary>
            /// Draw the edge on the specified surface.
            /// </summary>
            /// <param name="surface">Surface to draw on.</param>
            internal void Draw(DrawingSurface2D surface)
            {
                var previous = Spline[0];
                int width    = this.Style == Style.Bold ? 3 : 1;
                Pen pen      = new Pen(this.Color);

                pen.Width = width;
                for (int i = 1; i < Spline.Count; i++)
                {
                    Point2D point = Spline[i];
                    if (i == Spline.Count - 1)
                    {
                        // adjust for arrow size at the end of the edge.
                        const double absoluteArrowSize = 0.15;
                        double       dx  = point.X - previous.X;
                        double       dy  = point.Y - previous.Y;
                        double       len = Math.Sqrt(dx * dx + dy * dy);
                        double       adx = absoluteArrowSize * dx / len;
                        double       ady = absoluteArrowSize * dy / len;

                        point = new Point2D(point.X + adx, point.Y + ady);
                        //pen.EndCap = LineCap.ArrowAnchor;
                        AdjustableArrowCap cap = new AdjustableArrowCap(4, 6);
                        pen.CustomEndCap = cap;
                    }
                    surface.DrawLine(pen, previous, point, false);
                    previous = point;
                }
            }
Example #2
0
            /// <summary>
            /// Draw the edge on the specified surface.
            /// </summary>
            /// <param name="surface">Surface to draw on.</param>
            internal void Draw(DrawingSurface2D surface)
            {
                var previous = Spline[0];
                int width = this.Style == Style.Bold ? 3 : 1;
                Pen pen = new Pen(this.Color);
                pen.Width = width;
                for (int i = 1; i < Spline.Count; i++)
                {
                    Point2D point = Spline[i];
                    if (i == Spline.Count - 1)
                    {
                        // adjust for arrow size at the end of the edge.
                        const double absoluteArrowSize = 0.15;
                        double dx = point.X - previous.X;
                        double dy = point.Y - previous.Y;
                        double len = Math.Sqrt(dx * dx + dy * dy);
                        double adx = absoluteArrowSize * dx / len;
                        double ady = absoluteArrowSize * dy / len;

                        point = new Point2D(point.X + adx, point.Y + ady);
                        //pen.EndCap = LineCap.ArrowAnchor;
                        AdjustableArrowCap cap = new AdjustableArrowCap(4, 6);
                        pen.CustomEndCap = cap;
                    }
                    surface.DrawLine(pen, previous, point, false);
                    previous = point;
                }
            }
Example #3
0
        /// <summary>
        /// Draw the plan.
        /// </summary>
        /// <param name="drawingSurface2D">Surface where the plan is to be drawn.</param>
        /// <param name="colorToUse">Function deciding the color to use for each vertex.</param>
        public void Draw(DrawingSurface2D drawingSurface2D, Func<ExecutedVertexInstance, Color> colorToUse)
        {
            foreach (var vertex in this.vertices)
            {
                DateTime start = vertex.Start;
                string machine = vertex.Machine;
                if (string.IsNullOrEmpty(machine) || start == DateTime.MinValue)
                    continue;

                TimeSpan runningTime = vertex.RunningTime;
                // This can happen if there is nothing known about this vertex at the point when the schedule is drawn.
                if (runningTime == TimeSpan.MinValue)
                    continue;

                DateTime end = start + runningTime;
                int index = this.utilization.SortedIndex(machine);
                double y = spacing * index;
                double left = (start - this.startTime).TotalSeconds;
                double right = (end - this.startTime).TotalSeconds;
                Color color = colorToUse(vertex);
                Pen pen = new Pen(color, 2);

                drawingSurface2D.DrawLine(pen, new Point2D(left, y), new Point2D(right, y), false);
            }
        }