Exemple #1
0
        public override RectangleF CalculateRectangle(DrawingContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            GanttStyle style = this.Style as GanttStyle;

            float height = style.Height;
            float x = context.DateToPixel(_start);
            float x2 = context.DateToPixel(_finish);
            float width = x2 - x;
            float y = context.CurrentTop + (context.ItemHeight - height) / 2;

            return new RectangleF(x, y, width, height);
        }
Exemple #2
0
        public override RectangleF CalculateRectangle(DrawingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            GanttStyle style = this.Style as GanttStyle;

            float height = style.Height;
            float x      = context.DateToPixel(_start);
            float x2     = context.DateToPixel(_finish);
            float width  = x2 - x;
            float y      = context.CurrentTop + (context.ItemHeight - height) / 2;

            return(new RectangleF(x, y, width, height));
        }
Exemple #3
0
        private TimeCell GetCell(int index)
        {
            DateTime startDate = GetCellStartDate(index);
            TimeSpan interval  = this.Interval;
            float    width     = this.Width;
            float    x         = DrawingContext.DateToPixel(startDate, _viewStartDate, interval, width);

            return(new TimeCell(index, startDate, interval, x, width, this));
        }
Exemple #4
0
        public override RectangleF CalculateRectangle(DrawingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            GanttStyle style = this.Style as GanttStyle;

            _startX = context.DateToPixel(_value);
            float x = _startX;

            float width  = style.Width;
            float height = style.Height;

            // Make odd size
            if ((width % 2) == 0)
            {
                width--;
            }
            if ((height % 2) == 0)
            {
                height--;
            }

            float minSize = Math.Min(style.Width, style.Height);

            switch (style.ShapeStyle)
            {
            case ShapeStyle.Circle:
                width = height = minSize;
                x    -= (width - 1) / 2;
                break;

            case ShapeStyle.LeftTriangle:
                height = minSize;
                width  = (minSize + 1) / 2;
                x     += 1 - width;
                break;

            case ShapeStyle.RightTriangle:
                height = minSize;
                width  = (minSize + 1) / 2;
                break;

            default:
                x -= (width - 1) / 2;
                break;
            }

            float y = context.CurrentTop + (context.ItemHeight - height) / 2;

            return(new RectangleF(x, y, width, height));
        }
Exemple #5
0
        public int GetPortionX(DateTime date, int portionWidth)
        {
            DrawingContext context = new DrawingContext(_startDate, 0, 0, portionWidth, 0, 0, 0);

            CalculateAxesWidth();
            _axes[_axes.Count - 1].SetEndDate(context);

            float x = context.DateToPixel(date);

            return(Convert.ToInt32(Math.Floor(x / portionWidth)));
        }
Exemple #6
0
        public override void RenderElement(DrawingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            DateTime leftDate     = context.PixelToDate(context.Left).Date;
            DateTime rightDate    = context.PixelToDate(context.Left + context.Width).Date;
            bool     isTopPortion = context.CurrentTop > context.Top;
            float    top          = isTopPortion ? context.CurrentTop : context.Top;
            float    width        = context.TimeSpanToPixel(new TimeSpan(1, 0, 0, 0));
            float    height       = isTopPortion ? context.FreeHeight : context.Height;

            DateTime currentDate = leftDate;

            while (currentDate <= rightDate)
            {
                bool render = false;

                if (_dayOfWeek != null)
                {
                    if (currentDate.DayOfWeek == _dayOfWeek.Value)
                    {
                        render = true;
                    }
                }

                if (_date != null)
                {
                    if (currentDate == _date.Value)
                    {
                        render = true;
                    }
                }

                if (render)
                {
                    GanttStyle style     = this.Style as GanttStyle;
                    RectangleF rectangle = new RectangleF(context.DateToPixel(currentDate), top, width, height);

                    using (Brush backgroundBrush = CreateBackgroundBrush(style))
                        using (Pen borderPen = CreateBorderPen(style))
                        {
                            RenderGanttElement(context, rectangle, backgroundBrush, borderPen);
                        }
                }

                currentDate = currentDate.AddDays(1);
            }
        }
Exemple #7
0
        public override RectangleF CalculateRectangle(DrawingContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            GanttStyle style = this.Style as GanttStyle;

            _startX = context.DateToPixel(_value);
            float x = _startX;

            float width = style.Width;
            float height = style.Height;

            // Make odd size
            if ((width % 2) == 0)
                width--;
            if ((height % 2) == 0)
                height--;

            float minSize = Math.Min(style.Width, style.Height);

            switch (style.ShapeStyle)
            {
                case ShapeStyle.Circle:
                    width = height = minSize;
                    x -= (width - 1) / 2;
                    break;
                case ShapeStyle.LeftTriangle:
                    height = minSize;
                    width = (minSize + 1) / 2;
                    x += 1 - width;
                    break;
                case ShapeStyle.RightTriangle:
                    height = minSize;
                    width = (minSize + 1) / 2;
                    break;
                default:
                    x -= (width - 1) / 2;
                    break;
            }

            float y = context.CurrentTop + (context.ItemHeight - height) / 2;

            return new RectangleF(x, y, width, height);
        }
Exemple #8
0
        public override void RenderElement(DrawingContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            DateTime leftDate = context.PixelToDate(context.Left).Date;
            DateTime rightDate = context.PixelToDate(context.Left + context.Width).Date;
            bool isTopPortion = context.CurrentTop > context.Top;
            float top = isTopPortion ? context.CurrentTop : context.Top;
            float width = context.TimeSpanToPixel(new TimeSpan(1, 0, 0, 0));
            float height = isTopPortion ? context.FreeHeight : context.Height;

            DateTime currentDate = leftDate;
            while (currentDate <= rightDate)
            {
                bool render = false;

                if (_dayOfWeek != null)
                {
                    if (currentDate.DayOfWeek == _dayOfWeek.Value)
                        render = true;
                }

                if (_date != null)
                {
                    if (currentDate == _date.Value)
                        render = true;
                }

                if (render)
                {
                    GanttStyle style = this.Style as GanttStyle;
                    RectangleF rectangle = new RectangleF(context.DateToPixel(currentDate), top, width, height);

                    using (Brush backgroundBrush = CreateBackgroundBrush(style))
                    using (Pen borderPen = CreateBorderPen(style))
                    {
                        RenderGanttElement(context, rectangle, backgroundBrush, borderPen);
                    }
                }

                currentDate = currentDate.AddDays(1);
            }
        }
Exemple #9
0
        public int GetPortionX(DateTime date, int portionWidth)
        {
            DrawingContext context = new DrawingContext(_startDate, 0, 0, portionWidth, 0, 0, 0);

            CalculateAxesWidth();
            _axes[_axes.Count - 1].SetEndDate(context);

            float x = context.DateToPixel(date);
            return Convert.ToInt32(Math.Floor(x / portionWidth));
        }