/// <summary> /// Draws the image. /// </summary> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Draw(LcdGdiPage page, Graphics graphics) { if (_image != null) { graphics.DrawImage(_image, AbsolutePosition.X, AbsolutePosition.Y, FinalSize.Width, FinalSize.Height); } }
/// <summary> /// Draws the rectangle. /// </summary> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Draw(LcdGdiPage page, Graphics graphics) { if (Pen != null) { graphics.DrawArc(Pen, AbsolutePosition.X, AbsolutePosition.Y, FinalSize.Width - 1.0f, FinalSize.Height - 1.0f, _startAngle, _sweepAngle); } }
/// <summary> /// Draws the image. /// </summary> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Draw(LcdGdiPage page, Graphics graphics) { if (_icon != null) { graphics.DrawIcon(_icon, new Rectangle((int)AbsolutePosition.X, (int)AbsolutePosition.Y, (int)FinalSize.Width, (int)FinalSize.Height)); } }
/// <summary> /// Draws the rectangle. /// </summary> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Draw(LcdGdiPage page, Graphics graphics) { if (Pen == null) { return; } graphics.DrawLine(Pen, StartPointForDrawing, EndPointForDrawing); }
/// <summary> /// Draws the text. /// </summary> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Draw(LcdGdiPage page, Graphics graphics) { if (String.IsNullOrEmpty(Text) || Brush == null || Font == null) { return; } graphics.TextContrast = _textContrast; graphics.TextRenderingHint = _textRenderingHint; graphics.DrawString(_text, _font, Brush, new RectangleF(AbsolutePosition, _boundSize), _stringFormat); }
/// <summary> /// Draws the rectangle. /// </summary> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Draw(LcdGdiPage page, Graphics graphics) { if (Brush != null) { graphics.FillRectangle(Brush, AbsolutePosition.X, AbsolutePosition.Y, FinalSize.Width - 1.0f, FinalSize.Height - 1.0f); } if (Pen != null) { graphics.DrawRectangle(Pen, AbsolutePosition.X, AbsolutePosition.Y, FinalSize.Width - 1.0f, FinalSize.Height - 1.0f); } }
/// <summary> /// Sets a clipping region that is the intersection of this object's clip, the child clip and the viewport. /// </summary> /// <param name="graphics">Graphics on which to set the clip.</param> private void SetClipForChild(Graphics graphics) { Region thisClip = graphics.Clip.Clone(); LcdGdiPage.PrepareGraphicsForChild(graphics, Child); Region childClip = graphics.Clip; thisClip.Intersect(childClip); thisClip.Intersect(new RectangleF(AbsolutePosition, Viewport)); graphics.Clip = thisClip; }
/// <summary> /// Draws the curve. /// </summary> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Draw(LcdGdiPage page, Graphics graphics) { PointF[] points = GetPoints(); if (Pen != null) { graphics.DrawBezier(Pen, AbsolutePosition.X + points[0].X, AbsolutePosition.Y + points[0].Y, AbsolutePosition.X + points[1].X, AbsolutePosition.Y + points[1].Y, AbsolutePosition.X + points[2].X, AbsolutePosition.Y + points[2].Y, AbsolutePosition.X + points[3].X, AbsolutePosition.Y + points[3].Y); } }
/// <summary> /// Draws this object. /// </summary> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Draw(LcdGdiPage page, Graphics graphics) { if (_child != null) { SetClipForChild(graphics); _child.Draw(page, graphics); if (_autoScrollX || _autoScrollY) { HasChanged = true; } } }
/// <summary> /// Draws the cardinal spline. /// </summary> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Draw(LcdGdiPage page, Graphics graphics) { PointF[] points = GetPoints(); for (int i = 0; i < points.Length; ++i) { PointF point = points[i]; point.X += AbsolutePosition.X; point.Y += AbsolutePosition.Y; points[i] = point; } if (_isClosed && Brush != null) graphics.FillClosedCurve(Brush, points, _fillMode, _tension); if (Pen != null) { if (_isClosed) graphics.DrawClosedCurve(Pen, points, _tension, _fillMode); else graphics.DrawCurve(Pen, points, _tension); } }
/// <summary> /// Draws the polygon. /// </summary> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Draw(LcdGdiPage page, Graphics graphics) { PointF[] points = GetPoints(); for (int i = 0; i < points.Length; ++i) { PointF point = points[i]; point.X += AbsolutePosition.X; point.Y += AbsolutePosition.Y; points[i] = point; } if (Brush != null) { graphics.FillPolygon(Brush, points, _fillMode); } if (Pen != null) { graphics.DrawPolygon(Pen, points); } }
/// <summary> /// Draws the progress bar. /// </summary> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Draw(LcdGdiPage page, Graphics graphics) { if (Brush != null) { graphics.FillRectangle(Brush, AbsolutePosition.X, AbsolutePosition.Y, FinalSize.Width - 1.0f, FinalSize.Height - 1.0f); } float penWidth; if (Pen != null) { graphics.DrawRectangle(Pen, AbsolutePosition.X, AbsolutePosition.Y, FinalSize.Width - 1.0f, FinalSize.Height - 1.0f); penWidth = Pen.Width; } else { penWidth = 0.0f; } if (_progressBrush != null) { int zeroBasedMaximum = _maximum - _minimum; int zeroBasedValue = _value - _minimum; float percent = zeroBasedMaximum == 0 ? 0.0f : zeroBasedValue / (float)zeroBasedMaximum; if (_isVertical) { float indicatorHeight = (FinalSize.Height - penWidth * 2) * percent; graphics.FillRectangle(_progressBrush, AbsolutePosition.X + penWidth, AbsolutePosition.Y + FinalSize.Height - penWidth - indicatorHeight, FinalSize.Width - penWidth * 2, indicatorHeight); } else { graphics.FillRectangle(_progressBrush, AbsolutePosition.X + penWidth, AbsolutePosition.Y + penWidth, (FinalSize.Width - penWidth * 2) * percent, FinalSize.Height - penWidth * 2); } } }
/// <summary> /// Updates the position of the object. /// </summary> /// <param name="elapsedTotalTime">Time elapsed since the device creation.</param> /// <param name="elapsedTimeSinceLastFrame">Time elapsed since last frame update.</param> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Update(TimeSpan elapsedTotalTime, TimeSpan elapsedTimeSinceLastFrame, LcdGdiPage page, Graphics graphics) { if (String.IsNullOrEmpty(Text) || Brush == null || Font == null) { FinalSize = SizeF.Empty; } else { graphics.TextContrast = _textContrast; graphics.TextRenderingHint = _textRenderingHint; _stringFormat.SetMeasurableCharacterRanges(new[] { new CharacterRange(0, _text.Length) }); _boundSize = Size == SizeF.Empty ? new SizeF(65536.0f, 65536.0f) : Size; if (HorizontalAlignment == LcdGdiHorizontalAlignment.Stretch) { _boundSize.Width = page.Bitmap.Width - Margin.Left - Margin.Right; } if (VerticalAlignment == LcdGdiVerticalAlignment.Stretch) { _boundSize.Height = page.Bitmap.Height - Margin.Top - Margin.Bottom; } Region[] regions = graphics.MeasureCharacterRanges(Text, Font, new RectangleF(PointF.Empty, _boundSize), _stringFormat); FinalSize = regions[0].GetBounds(graphics).Size; } CalcAbsolutePosition(page.Bitmap.Size, 1.0f); }
/// <summary> /// Updates the position of the object. /// </summary> /// <param name="elapsedTotalTime">Time elapsed since the device creation.</param> /// <param name="elapsedTimeSinceLastFrame">Time elapsed since last frame update.</param> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Update(TimeSpan elapsedTotalTime, TimeSpan elapsedTimeSinceLastFrame, LcdGdiPage page, Graphics graphics) { base.Update(elapsedTotalTime, elapsedTimeSinceLastFrame, page, graphics); if (_child != null) { SetClipForChild(graphics); _child.Update(elapsedTotalTime, elapsedTimeSinceLastFrame, page, graphics); _extent = new SizeF(_child.AbsolutePosition + _child.FinalSize); _maxScrollX = Math.Max(0.0f, _extent.Width - FinalSize.Width + 1.0f); _maxScrollY = Math.Max(0.0f, _extent.Height - FinalSize.Height + 1.0f); // Auto-scroll X if (_autoScrollXWasSet) { TimeSpan elapsedAutoScrollXTime = elapsedTotalTime - _autoScrollXStartTime; if (elapsedAutoScrollXTime <= _autoScrollXFixedStartTime) { _currentScrollX = 0.0f; } else if (_currentScrollX >= _maxScrollX) { if (_autoScrollXEndedTime == TimeSpan.Zero) { _autoScrollXEndedTime = elapsedTotalTime; } else if (elapsedTotalTime - _autoScrollXEndedTime >= _autoScrollXFixedEndTime) { _autoScrollXWasSet = false; _currentScrollX = 0.0f; } } else { _currentScrollX = (float)((elapsedAutoScrollXTime - _autoScrollXFixedStartTime).TotalSeconds * _autoScrollSpeedX); } } else { _autoScrollXWasSet = true; _autoScrollXStartTime = elapsedTotalTime; _autoScrollXEndedTime = TimeSpan.Zero; } // Auto-scroll Y if (_autoScrollYWasSet) { TimeSpan elapsedAutoScrollYTime = elapsedTotalTime - _autoScrollYStartTime; if (elapsedAutoScrollYTime <= _autoScrollYFixedStartTime) { _currentScrollY = 0.0f; } else if (_currentScrollY >= _maxScrollY) { if (_autoScrollYEndedTime == TimeSpan.Zero) { _autoScrollYEndedTime = elapsedTotalTime; } else if (elapsedTotalTime - _autoScrollYEndedTime >= _autoScrollYFixedEndTime) { _autoScrollYWasSet = false; _currentScrollY = 0.0f; } } else { _currentScrollY = (float)((elapsedAutoScrollYTime - _autoScrollYFixedStartTime).TotalSeconds * _autoScrollSpeedY); } } else { _autoScrollYWasSet = true; _autoScrollYStartTime = elapsedTotalTime; _autoScrollYEndedTime = TimeSpan.Zero; } _currentScrollX = Math.Min(_currentScrollX, _maxScrollX); _currentScrollY = Math.Min(_currentScrollY, _maxScrollY); _child.AbsolutePosition = new PointF( _child.AbsolutePosition.X + AbsolutePosition.X - _currentScrollX, _child.AbsolutePosition.Y + AbsolutePosition.Y - _currentScrollY); } else { _extent = SizeF.Empty; _maxScrollX = 0.0f; _maxScrollY = 0.0f; _currentScrollX = 0.0f; _currentScrollY = 0.0f; } }
/// <summary> /// Updates the position of the object. /// </summary> /// <param name="elapsedTotalTime">Time elapsed since the device creation.</param> /// <param name="elapsedTimeSinceLastFrame">Time elapsed since last frame update.</param> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Update(TimeSpan elapsedTotalTime, TimeSpan elapsedTimeSinceLastFrame, LcdGdiPage page, Graphics graphics) { if (Pen == null) { base.Update(elapsedTotalTime, elapsedTimeSinceLastFrame, page, graphics); return; } float finalWidth; if (HorizontalAlignment == LcdGdiHorizontalAlignment.Stretch) { finalWidth = page.Bitmap.Width - Margin.Left - Margin.Right; } else if (Size.Width == 0) { finalWidth = Pen.Width; } else { finalWidth = Math.Abs(Size.Width); } float finalHeight; if (VerticalAlignment == LcdGdiVerticalAlignment.Stretch) { finalHeight = page.Bitmap.Height - Margin.Top - Margin.Bottom; } else if (Size.Height == 0) { finalHeight = Pen.Width; } else { finalHeight = Math.Abs(Size.Height); } FinalSize = new SizeF(finalWidth, finalHeight); CalcAbsolutePosition(page.Bitmap.Size); }
/// <summary> /// Derived classes must override this method in order to draw the GDI object. /// </summary> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal abstract void Draw(LcdGdiPage page, Graphics graphics);
/// <summary> /// Derived classes must override this method in order to calculate the /// absolute position and final size of the object. This method is called only if /// <see cref="HasChanged"/> is <c>true</c>. /// </summary> /// <param name="elapsedTotalTime">Time elapsed since the device creation.</param> /// <param name="elapsedTimeSinceLastFrame">Time elapsed since last frame update.</param> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal virtual void Update(TimeSpan elapsedTotalTime, TimeSpan elapsedTimeSinceLastFrame, LcdGdiPage page, Graphics graphics) { FinalSize = new SizeF( HorizontalAlignment != LcdGdiHorizontalAlignment.Stretch ? Size.Width : page.Bitmap.Width - Margin.Left - Margin.Right, VerticalAlignment != LcdGdiVerticalAlignment.Stretch ? Size.Height : page.Bitmap.Height - Margin.Top - Margin.Bottom); CalcAbsolutePosition(page.Bitmap.Size); }
/// <summary> /// Updates the position of the object. /// </summary> /// <param name="elapsedTotalTime">Time elapsed since the device creation.</param> /// <param name="elapsedTimeSinceLastFrame">Time elapsed since last frame update.</param> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Update(TimeSpan elapsedTotalTime, TimeSpan elapsedTimeSinceLastFrame, LcdGdiPage page, Graphics graphics) { base.Update(elapsedTotalTime, elapsedTimeSinceLastFrame, page, graphics); if (_alignOnPixels) { AbsolutePosition = new PointF((float)Math.Truncate(AbsolutePosition.X), (float)Math.Truncate(AbsolutePosition.Y)); } }
/// <summary> /// Updates the position of the object. /// </summary> /// <param name="elapsedTotalTime">Time elapsed since the device creation.</param> /// <param name="elapsedTimeSinceLastFrame">Time elapsed since last frame update.</param> /// <param name="page">Page where this object will be drawn.</param> /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> protected internal override void Update(TimeSpan elapsedTotalTime, TimeSpan elapsedTimeSinceLastFrame, LcdGdiPage page, Graphics graphics) { FinalSize = Size; if (KeepAbsolute) { AbsolutePosition = new PointF(); } else { CalcAbsolutePosition(page.Bitmap.Size); } }