示例#1
0
        /// <summary>
        /// Defines brush to draw stop element.
        /// </summary>
        /// <param name="stop">Stop.</param>
        /// <param name="context">Drawing context.</param>
        /// <returns></returns>
        private static Brush _GetFillBrush(StopInfo stopInfo, GanttItemElementDrawingContext context)
        {
            Debug.Assert(context != null);

            // Define selected color.
            if (context.DrawSelected)
            {
                return(GanttControlHelper.GetSelectedBrush());
            }

            // Define location color.
            if (stopInfo.Stop.StopType == StopType.Location)
            {
                return(GanttControlHelper.GetLocationBrush());
            }

            // Define Break color.
            if (stopInfo.Stop.StopType == StopType.Lunch)
            {
                return(GanttControlHelper.GetBreakBrush());
            }

            // Define locked color.
            if (stopInfo.Stop.IsLocked || (stopInfo.Route != null && stopInfo.Route.IsLocked))
            {
                return(GanttControlHelper.GetLockedBrush(stopInfo.Route.Color));
            }

            // If stop is Order, not locked, not selected and not dragged over - return normal fill color.
            return(GanttControlHelper.GetFillBrush(stopInfo.Route.Color));
        }
示例#2
0
        /// <summary>
        /// Draws transparent element with container's width in default. If element is dragged over highlights Time windows of dregged order.
        /// </summary>
        /// <param name="context">Drawing context.</param>
        public void Draw(GanttItemElementDrawingContext context)
        {
            Rect elementSize = new Rect(context.DrawingArea.X, context.DrawingArea.Top, context.DrawingArea.Width, context.DrawingArea.Height);

            SolidColorBrush fillBrush = new SolidColorBrush(Colors.Transparent);
            Pen             drawPen   = GanttControlHelper.GetPen();

            // Draw element.
            context.DrawingContext.DrawRectangle(fillBrush, drawPen, elementSize);

            // Draw dragged over element.
            if (context.DrawDraggedOver)
            {
                Debug.Assert(ParentGanttItem.Tag != null);

                Brush draggedOverBrush = GanttControlHelper.GetEmptyElementDragOverFillBrush(((Route)ParentGanttItem.Tag).Color);
                Pen   pen = new Pen(fillBrush, 0);
                pen.Freeze();

                // Define collection of highlighted rectangles.
                Collection <Rect> highlightedRects = _GetHighlightedRects(context);

                if (highlightedRects == null)
                {
                    return;
                }

                // Draw dragged over areas.
                foreach (Rect rect in highlightedRects)
                {
                    context.DrawingContext.DrawRoundedRectangle(draggedOverBrush, pen, rect, ROUND_RADIUS, ROUND_RADIUS);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Defines brush to draw drivetime element.
        /// </summary>
        /// <param name="context">Drawing context.</param>
        /// <returns></returns>
        private Brush _GetFillBrush(GanttItemElementDrawingContext context)
        {
            Debug.Assert(_stop != null);
            Debug.Assert(_route != null);
            Debug.Assert(context != null);

            // Define selected color.
            if (context.DrawSelected)
            {
                return(GanttControlHelper.GetSelectedBrush());
            }

            // Define dragged over color.
            if (context.DrawDraggedOver)
            {
                return(GanttControlHelper.GetDragOverBrush());
            }

            // Define locked color.
            if (_stop.IsLocked || _route.IsLocked)
            {
                return(GanttControlHelper.GetLockedBrush(_route.Color));
            }

            // If stop is Order, not locked, not selected and not dragged over - return normal fill color.
            return(GanttControlHelper.GetFillBrush(_route.Color));
        }
示例#4
0
        /// <summary>
        /// Draws internal gradient effect.
        /// </summary>
        /// <param name="context">Drawing context.</param>
        private static void _DrawGradientEffect(GanttItemElementDrawingContext context)
        {
            Rect  elementRect   = _GetGradientRect(context);
            Brush gradientBrush = GanttControlHelper.GetGradientEffectBrush();
            Pen   drawPen       = GanttControlHelper.GetPen();

            context.DrawingContext.DrawRoundedRectangle(gradientBrush, drawPen, elementRect, ROUND_RADIUS, ROUND_RADIUS);
        }
示例#5
0
        /// <summary>
        /// Draws gantt item element.
        /// </summary>
        /// <param name="fillBrush">Filling brush.</param>
        /// <param name="context">Context.</param>
        private static void _DrawRectangle(Brush fillBrush, GanttItemElementDrawingContext context)
        {
            // Draw shadow effect.
            _DrawShadowEffect(context);

            Rect elementRect = _GetElementRect(context);
            Pen  drawPen     = GanttControlHelper.GetPen();

            // Draw rectangle.
            context.DrawingContext.DrawRoundedRectangle(fillBrush, drawPen, elementRect, ROUND_RADIUS, ROUND_RADIUS);

            // Draw top gradient effect.
            _DrawGradientEffect(context);
        }
示例#6
0
        public void Draw(GanttItemElementDrawingContext context)
        {
            Debug.Assert(_stop != null);
            Debug.Assert(_route != null);

            // Define element size.
            double yPos        = context.DrawingArea.Top + context.DrawingArea.Height / HEIGHT_INDEX;
            double height      = context.DrawingArea.Height / HEIGHT_INDEX;
            Rect   elementSize = new Rect(context.DrawingArea.X, yPos, context.DrawingArea.Width, height);

            Brush fillBrush = _GetFillBrush(context);
            Pen   drawPen   = GanttControlHelper.GetPen();

            // Draw element.
            context.DrawingContext.DrawRoundedRectangle(fillBrush, drawPen, elementSize, ROUND_RADIUS, ROUND_RADIUS);
        }
示例#7
0
        /// <summary>
        /// Draws stop.
        /// </summary>
        /// <param name="stopInfo">Information about stop. Used for optimizing performance.</param>
        /// <param name="context">DrawingContext.</param>
        /// <remarks>
        /// Getting some relation properties (like Route, AssociatedObject) from stop takes some time
        /// due to the data layer implementation specifics. To improve perofmrance on rendering of
        /// large amount of stops use this method passing cached value of stop's properties.
        /// </remarks>
        public static void DrawStop(StopInfo stopInfo, GanttItemElementDrawingContext context)
        {
            Debug.Assert(stopInfo.Stop != null);
            Debug.Assert(stopInfo.Route != null);
            Debug.Assert(context != null);

            Brush fillBrush = _GetFillBrush(stopInfo, context);

            // Draw element.
            _DrawRectangle(fillBrush, context);

            // Draw violated icon.
            if (stopInfo.Stop.IsViolated)
            {
                Rect elementRect      = _GetElementRect(context);
                Rect violatedIconRect = new Rect(elementRect.Left + GAP_SIZE, elementRect.Top + GAP_SIZE, ICON_SIZE, ICON_SIZE);

                violatedIconRect.Width = (violatedIconRect.Width > elementRect.Width) ? elementRect.Width : violatedIconRect.Width;

                ImageBrush brush = GanttControlHelper.GetViolatedBrush();
                context.DrawingContext.DrawImage(brush.ImageSource, violatedIconRect);
            }
        }