public override void RenderChildren(DrawingContext context) { int i = 0; int p = 0; foreach(Element child in this.Children) { bool isCalendarElement = child is CalendarElement; //if (!isCalendarElement && context.ItemsPerPage > 0 && i == 0 && p > 0 && p <= context.PageNumber) // Parent.StartNewPage(context); child.Render(context); if (!isCalendarElement) { context.CurrentTop += context.ItemHeight; i++; if (i == context.ItemsPerPage) { i = 0; p++; } } } }
public override RectangleF CalculateRectangle(DrawingContext context) { if (context == null) throw new ArgumentNullException("context"); return new RectangleF(context.Left, context.CurrentTop, context.Width, context.ItemHeight); }
public override RectangleF CalculateRectangle(DrawingContext context) { if (context == null) throw new ArgumentNullException("context"); bool isTopPortion = context.CurrentTop > context.Top; return new RectangleF(context.Left, isTopPortion ? context.CurrentTop : context.Top, context.Width, isTopPortion ? context.FreeHeight : context.Height); }
public RectangleF CalculateRectangleAndSetSize(DrawingContext context) { RectangleF rectangle = CalculateRectangle(context); this.Width = rectangle.Width; this.Height = rectangle.Height; return rectangle; }
public override void RenderChildren(DrawingContext context) { foreach (Element child in this.Children) { child.Render(context); context.CurrentTop += child.Height; context.FreeHeight -= child.Height; } }
public override RectangleF CalculateRectangle(DrawingContext context) { if (context == null) throw new ArgumentNullException("context"); if (context.HeaderItemHeight > 0) return new RectangleF(context.Left, context.CurrentTop, context.Width, CalculateHeight(context.HeaderItemHeight)); else return RectangleF.Empty; }
public override void RenderChildren(DrawingContext context) { float y = context.CurrentTop; foreach (Element child in this.Children) { child.Render(context); context.CurrentTop = y; } }
public override void StartNewPage(DrawingContext context) { foreach (Element child in this.Children) { if (child is HeadElement) { child.Render(context); context.CurrentTop += child.Height; } } }
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); }
public virtual RectangleF CalculateRectangle(DrawingContext context) { if (context == null) throw new ArgumentNullException("context"); GanttStyle style = this.Style as GanttStyle; float width = this.Width; if (width <= 0) width = style.Width; float height = this.Height; if (height <= 0) height = style.Height; return new RectangleF(context.Left, context.CurrentTop, width, height); }
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); }
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); } }
public override void RenderChildren(DrawingContext context) { if (context == null) throw new ArgumentNullException("context"); GanttStyle style = this.Style as GanttStyle; float y = context.CurrentTop; foreach (Element child in this.Children) { context.CurrentTop += style.BorderWidth; child.Render(context); context.CurrentTop += child.Height; } context.CurrentTop = y; context.Graphics.SetClip(_rectangle, CombineMode.Exclude); }
public override void RenderGanttElement(DrawingContext context, RectangleF rectangle, Brush backgroundBrush, Pen borderPen) { if (context == null) throw new ArgumentNullException("context"); GanttStyle style = this.Style as GanttStyle; if (backgroundBrush != null) context.Graphics.FillRectangle(backgroundBrush, rectangle); if (borderPen != null) { int n = this.Children.Count + 1; for (int i = 0; i < n; i++) { float y = rectangle.Top + i * (context.HeaderItemHeight + style.BorderWidth); context.Graphics.DrawLine(borderPen, rectangle.Left, y, rectangle.Right, y); } } _rectangle = rectangle; }
public override void RenderChildren(DrawingContext context) { foreach (Element child in this.Children) child.Render(context); }
public virtual void RenderGanttElement(DrawingContext context, RectangleF rectangle, Brush backgroundBrush, Pen borderPen) { if (context == null) throw new ArgumentNullException("context"); if (backgroundBrush != null) context.Graphics.FillRectangle(backgroundBrush, rectangle); rectangle.Width--; rectangle.Height--; if (borderPen != null) context.Graphics.DrawRectangle(borderPen, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); }
public override void RenderGanttElement(DrawingContext context, RectangleF rectangle, Brush backgroundBrush, Pen borderPen) { if (context == null) throw new ArgumentNullException("context"); float halfWidth = (rectangle.Width - 1) / 2; float halfHeight = (rectangle.Height - 1) / 2; float centerX = rectangle.Left + halfWidth; float centerY = rectangle.Top + halfHeight; GanttStyle style = this.Style as GanttStyle; PointF[] points = null; RectangleF ellipse = RectangleF.Empty; switch (style.ShapeStyle) { case ShapeStyle.Circle: case ShapeStyle.Ellipse: ellipse = rectangle; ellipse.Width--; ellipse.Height--; break; case ShapeStyle.LeftTriangle: points = new PointF[] { new PointF(rectangle.Right-1, rectangle.Top), new PointF(rectangle.Right-1, rectangle.Bottom-1), new PointF(rectangle.Left, centerY), }; break; case ShapeStyle.RightTriangle: points = new PointF[] { new PointF(rectangle.Left, rectangle.Top), new PointF(rectangle.Left, rectangle.Bottom-1), new PointF(rectangle.Right-1, centerY), }; break; case ShapeStyle.Rhombus: points = new PointF[] { new PointF(centerX, rectangle.Top), new PointF(rectangle.Right-1, centerY), new PointF(centerX, rectangle.Bottom-1), new PointF(rectangle.Left, centerY), }; break; case ShapeStyle.PentagonDown: points = new PointF[] { new PointF(rectangle.Left, rectangle.Top), new PointF(rectangle.Right-1, rectangle.Top), new PointF(rectangle.Right-1, centerY), new PointF(centerX, rectangle.Bottom-1), new PointF(rectangle.Left, centerY), }; break; case ShapeStyle.PentagonUp: points = new PointF[] { new PointF(centerX, rectangle.Top), new PointF(rectangle.Right-1, centerY), new PointF(rectangle.Right-1, rectangle.Bottom-1), new PointF(rectangle.Left, rectangle.Bottom-1), new PointF(rectangle.Left, centerY), }; break; case ShapeStyle.PentagonRight: points = new PointF[] { new PointF(rectangle.Right - 1, centerY), new PointF(centerX, rectangle.Bottom - 1), new PointF(rectangle.Left, rectangle.Bottom-1), new PointF(rectangle.Left, rectangle.Top), new PointF(centerX, rectangle.Top), }; break; case ShapeStyle.PentagonLeft: points = new PointF[] { new PointF(rectangle.Left, centerY), new PointF(centerX, rectangle.Top), new PointF(rectangle.Right - 1, rectangle.Top), new PointF(rectangle.Right - 1, rectangle.Bottom - 1), new PointF(centerX, rectangle.Bottom - 1), }; break; default: points = new PointF[] { new PointF(rectangle.Left, rectangle.Top), new PointF(rectangle.Right, rectangle.Top), new PointF(rectangle.Right, rectangle.Bottom), new PointF(rectangle.Left, rectangle.Bottom), }; break; } if (ellipse != RectangleF.Empty) { if (backgroundBrush != null) context.Graphics.FillEllipse(backgroundBrush, ellipse); if (borderPen != null) context.Graphics.DrawEllipse(borderPen, ellipse); } if (points != null) { if (backgroundBrush != null) context.Graphics.FillPolygon(backgroundBrush, points); if (borderPen != null) context.Graphics.DrawPolygon(borderPen, points); } }
public virtual void StartNewPage(DrawingContext context) { }
public override void RenderElement(DrawingContext context) { if (context == null) throw new ArgumentNullException("context"); GanttStyle style = this.Style as GanttStyle; this.Height = context.HeaderItemHeight; float visibleRight = context.Left + context.Width; int leftIndex = GetIndexByPoint(context.Left); int rightIndex = GetIndexByPoint(visibleRight); TimeSpan axisInterval = new TimeSpan(); for (int cellIndex = leftIndex; cellIndex <= rightIndex; cellIndex++) { TimeCell cell = GetCell(cellIndex); RectangleF rectangle = new RectangleF(cell.Left, context.CurrentTop, cell.Width, this.Height); if (rectangle.Left >= context.Left && rectangle.Right <= visibleRight) axisInterval += cell.Interval; else if (rectangle.Left < context.Left && rectangle.Right <= visibleRight) axisInterval += cell.GetTimeInterval(rectangle.Right - context.Left); else if (rectangle.Left >= context.Left && rectangle.Right > visibleRight) axisInterval += cell.GetTimeInterval(visibleRight - rectangle.Left); using (SolidBrush backgroundBrush = new SolidBrush(style.BackgroundColor)) { context.Graphics.FillRectangle(backgroundBrush, rectangle); } StringBuilder text = new StringBuilder(); switch (_titleType) { case TitleType.Start: text.Append(GetDateText(cell.StartDate, _format, context.Provider)); break; case TitleType.StartEnd: text.Append(GetDateText(cell.StartDate, _format, context.Provider)); text.Append(" - "); text.Append(GetDateText(cell.StartDate.AddTicks(cell.Interval.Ticks - 1), _format, context.Provider)); break; } if (text.Length > 0) { if (_scale == ScaleLevel.Week) { string weekNumber = string.Format(CultureInfo.InvariantCulture, " (#{0})", Iso8601WeekNumber.GetWeekNumber(cell.StartDate)); text.Append(weekNumber); } using (SolidBrush textBrush = new SolidBrush(style.ForegroundColor)) { // TODO: Load font style from style sheet. Font font = new Font("Arial", 8, FontStyle.Regular); StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; context.Graphics.DrawString(text.ToString(), font, textBrush, rectangle, stringFormat); } } rectangle.Width--; rectangle.Height--; using (Pen borderPen = new Pen(style.BorderColor, style.BorderWidth)) { context.Graphics.DrawLine(borderPen, rectangle.Left, rectangle.Top, rectangle.Left, rectangle.Bottom); } } context.EndDate = _viewStartDate + axisInterval; }
internal void SetEndDate(DrawingContext context) { float visibleRight = context.Left + context.Width; int leftIndex = GetIndexByPoint(context.Left); int rightIndex = GetIndexByPoint(visibleRight); TimeSpan axisInterval = new TimeSpan(); for (int cellIndex = leftIndex; cellIndex <= rightIndex; cellIndex++) { TimeCell cell = GetCell(cellIndex); RectangleF rectangle = new RectangleF(cell.Left, context.CurrentTop, cell.Width, this.Height); if (rectangle.Left >= context.Left && rectangle.Right <= visibleRight) axisInterval += cell.Interval; else if (rectangle.Left < context.Left && rectangle.Right <= visibleRight) axisInterval += cell.GetTimeInterval(rectangle.Right - context.Left); else if (rectangle.Left >= context.Left && rectangle.Right > visibleRight) axisInterval += cell.GetTimeInterval(visibleRight - rectangle.Left); } context.EndDate = _viewStartDate + axisInterval; }
public void RenderPortion(Point portionOffset, Size portionSize, int itemsPerPage, int pageNumber, ImageFormat format, Stream output) { using (Bitmap bitmap = new Bitmap(portionSize.Width, portionSize.Height)) { using (Graphics graphics = Graphics.FromImage(bitmap)) { float x = portionSize.Width * portionOffset.X; float y; if (portionOffset.Y < 0) // Render head y = 0; else y = portionSize.Height * portionOffset.Y + pageNumber * _itemHeight * itemsPerPage + _head.CalculateHeight(_headerItemHeight); using (Matrix matrix = new Matrix()) { matrix.Translate(-x, -y); graphics.Transform = matrix; } DrawingContext context = new DrawingContext(_startDate, x, y, portionSize.Width, portionSize.Height, itemsPerPage, pageNumber); context.Graphics = graphics; context.Provider = _provider; context.HeaderItemHeight = _headerItemHeight; context.ItemHeight = _itemHeight; _data.Render(context); } bitmap.Save(output, format); } }
public override void RenderGanttElement(DrawingContext context, RectangleF rectangle, Brush backgroundBrush, Pen borderPen) { if (context == null) throw new ArgumentNullException("context"); float height = rectangle.Height; // Make even size if ((height % 2) != 0) height++; float halfHeight = rectangle.Height / 2; GanttStyle style = this.Style as GanttStyle; PointF[] points = null; switch (style.ShapeStyle) { case ShapeStyle.Height50PercentUp: points = new PointF[] { new PointF(rectangle.Left, rectangle.Top), new PointF(rectangle.Right-1, rectangle.Top), new PointF(rectangle.Right-1, rectangle.Top + halfHeight), new PointF(rectangle.Left, rectangle.Top + halfHeight), }; break; case ShapeStyle.Height50PercentDown: points = new PointF[] { new PointF(rectangle.Left, rectangle.Bottom - halfHeight), new PointF(rectangle.Right-1, rectangle.Bottom - halfHeight), new PointF(rectangle.Right-1, rectangle.Bottom-1), new PointF(rectangle.Left, rectangle.Bottom-1), }; break; default: points = new PointF[] { new PointF(rectangle.Left, rectangle.Top), new PointF(rectangle.Right-1, rectangle.Top), new PointF(rectangle.Right-1, rectangle.Bottom-1), new PointF(rectangle.Left, rectangle.Bottom-1), }; break; } if (points != null) { if (backgroundBrush != null) context.Graphics.FillPolygon(backgroundBrush, points); if (borderPen != null) { if (style.ShapeStyle == ShapeStyle.Interval) { context.Graphics.DrawLine(borderPen, rectangle.Left, rectangle.Top, rectangle.Left, rectangle.Bottom - 1); context.Graphics.DrawLine(borderPen, rectangle.Right - 1, rectangle.Top, rectangle.Right - 1, rectangle.Bottom - 1); } else { context.Graphics.DrawPolygon(borderPen, points); } } } }
public void Render(DrawingContext context) { RenderElement(context); RenderChildren(context); }
public virtual void RenderChildren(DrawingContext context) { foreach (Element child in _children) child.Render(context); }
public override void RenderElement(DrawingContext context) { GanttStyle style = this.Style as GanttStyle; if (style.ShapeStyle != ShapeStyle.None) { _rectangle = CalculateRectangleAndSetSize(context); using (Brush backgroundBrush = CreateBackgroundBrush(style)) using (Pen borderPen = CreateBorderPen(style)) { RenderGanttElement(context, _rectangle, backgroundBrush, borderPen); } } }
public override void RenderGanttElement(DrawingContext context, RectangleF rectangle, Brush backgroundBrush, Pen borderPen) { if (context == null) { throw new ArgumentNullException("context"); } float halfWidth = (rectangle.Width - 1) / 2; float halfHeight = (rectangle.Height - 1) / 2; float centerX = rectangle.Left + halfWidth; float centerY = rectangle.Top + halfHeight; GanttStyle style = this.Style as GanttStyle; PointF[] points = null; RectangleF ellipse = RectangleF.Empty; switch (style.ShapeStyle) { case ShapeStyle.Circle: case ShapeStyle.Ellipse: ellipse = rectangle; ellipse.Width--; ellipse.Height--; break; case ShapeStyle.LeftTriangle: points = new PointF[] { new PointF(rectangle.Right - 1, rectangle.Top), new PointF(rectangle.Right - 1, rectangle.Bottom - 1), new PointF(rectangle.Left, centerY), }; break; case ShapeStyle.RightTriangle: points = new PointF[] { new PointF(rectangle.Left, rectangle.Top), new PointF(rectangle.Left, rectangle.Bottom - 1), new PointF(rectangle.Right - 1, centerY), }; break; case ShapeStyle.Rhombus: points = new PointF[] { new PointF(centerX, rectangle.Top), new PointF(rectangle.Right - 1, centerY), new PointF(centerX, rectangle.Bottom - 1), new PointF(rectangle.Left, centerY), }; break; case ShapeStyle.PentagonDown: points = new PointF[] { new PointF(rectangle.Left, rectangle.Top), new PointF(rectangle.Right - 1, rectangle.Top), new PointF(rectangle.Right - 1, centerY), new PointF(centerX, rectangle.Bottom - 1), new PointF(rectangle.Left, centerY), }; break; case ShapeStyle.PentagonUp: points = new PointF[] { new PointF(centerX, rectangle.Top), new PointF(rectangle.Right - 1, centerY), new PointF(rectangle.Right - 1, rectangle.Bottom - 1), new PointF(rectangle.Left, rectangle.Bottom - 1), new PointF(rectangle.Left, centerY), }; break; case ShapeStyle.PentagonRight: points = new PointF[] { new PointF(rectangle.Right - 1, centerY), new PointF(centerX, rectangle.Bottom - 1), new PointF(rectangle.Left, rectangle.Bottom - 1), new PointF(rectangle.Left, rectangle.Top), new PointF(centerX, rectangle.Top), }; break; case ShapeStyle.PentagonLeft: points = new PointF[] { new PointF(rectangle.Left, centerY), new PointF(centerX, rectangle.Top), new PointF(rectangle.Right - 1, rectangle.Top), new PointF(rectangle.Right - 1, rectangle.Bottom - 1), new PointF(centerX, rectangle.Bottom - 1), }; break; default: points = new PointF[] { new PointF(rectangle.Left, rectangle.Top), new PointF(rectangle.Right, rectangle.Top), new PointF(rectangle.Right, rectangle.Bottom), new PointF(rectangle.Left, rectangle.Bottom), }; break; } if (ellipse != RectangleF.Empty) { if (backgroundBrush != null) { context.Graphics.FillEllipse(backgroundBrush, ellipse); } if (borderPen != null) { context.Graphics.DrawEllipse(borderPen, ellipse); } } if (points != null) { if (backgroundBrush != null) { context.Graphics.FillPolygon(backgroundBrush, points); } if (borderPen != null) { context.Graphics.DrawPolygon(borderPen, points); } } }
public virtual void RenderElement(DrawingContext context) { }
public override void RenderGanttElement(DrawingContext context, RectangleF rectangle, Brush backgroundBrush, Pen borderPen) { if (context == null) throw new ArgumentNullException("context"); // Calculate arrow size GanttStyle style = this.Style as GanttStyle; _arrowSize = Math.Min(style.Width, style.Height); GanttElement originElement = _origin as GanttElement; GanttElement targetElement = _target as GanttElement; RectangleF origin = originElement.Rectangle; RectangleF target = targetElement.Rectangle; PointF originEnd = new PointF(origin.Right, Convert.ToSingle(Math.Ceiling(origin.Top - 1 + origin.Height / 2))); PointF targetStart = new PointF(targetElement.StartX, Convert.ToSingle(Math.Ceiling(target.Top - 1 + target.Height / 2))); PointF[] linePoints = null; PointF[] arrowPoints = null; bool riseY = target.Y > origin.Y; float doubleArrowSize = _arrowSize * 2; if (targetStart.X - originEnd.X > doubleArrowSize) { PointF pointer = new PointF(targetStart.X, riseY ? target.Top - 1 : target.Bottom); // Direct arrow: 3 points linePoints = new PointF[3] { originEnd, new PointF(pointer.X, originEnd.Y), new PointF(pointer.X, riseY ? pointer.Y - _arrowSize - 1 : pointer.Y + _arrowSize + 1) }; arrowPoints = CreateArrow(pointer, false, riseY); } else { PointF pointer = new PointF(target.Left - 1, targetStart.Y); // Back arrow: 6 points float intermediateY = riseY ? origin.Bottom + 1 : origin.Top - 2; linePoints = new PointF[6] { originEnd, new PointF(originEnd.X + doubleArrowSize, originEnd.Y), new PointF(originEnd.X + doubleArrowSize, intermediateY), new PointF(pointer.X - doubleArrowSize - 1, intermediateY), new PointF(pointer.X - doubleArrowSize - 1, pointer.Y), new PointF(pointer.X - _arrowSize - 1, pointer.Y) }; arrowPoints = CreateArrow(pointer, true, true); } if (linePoints != null) { if (borderPen != null) context.Graphics.DrawLines(borderPen, linePoints); } if (arrowPoints != null) { if (backgroundBrush != null) context.Graphics.FillPolygon(backgroundBrush, arrowPoints); if (borderPen != null) context.Graphics.DrawPolygon(borderPen, arrowPoints); } }
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)); }