public override void OnRender(Microsoft.SPOT.Presentation.Media.DrawingContext dc) { // Draw outline rectangle dc.DrawRectangle(_fillBrush, _linePen, 0, 0, COLUMN_WIDTH * COLUMNS, ROW_HEIGHT * ROWS); // Performance tunning - save all property calls to variables int blockCols = _universe.NextBlock.Columns; int blockRows = _universe.NextBlock.Rows; int offsetX = (Width - (blockCols * COLUMN_WIDTH) + 2) / 2; int offsetY = (Height - (blockRows * ROW_HEIGHT) + 2) / 2; // Draw block for (int row = 0; row < blockRows; row++) { for (int col = 0; col < blockCols; col++) { int brushType = _universe.NextBlock.GetCell(row, col) - 1; if (brushType >= 0) { dc.DrawRectangle(BlockBrushes.Instance.GetBrush(brushType), _blockPen, (col * COLUMN_WIDTH) + offsetX, (row * ROW_HEIGHT) + offsetY, COLUMN_WIDTH - 1, ROW_HEIGHT - 1); } } } base.OnRender(dc); }
public override void OnRender(DrawingContext dc) { if (_background != null) { dc.DrawRectangle(_background, null, 0, 0, _renderWidth, _renderHeight); } }
public override void OnRender(Microsoft.SPOT.Presentation.Media.DrawingContext dc) { if (_bitmap != null) { dc.DrawImage(_bitmap, 0, 0); } }
public override void OnRender(DrawingContext dc) { base.OnRender(dc); dc.DrawRectangle(new SolidColorBrush(Colors.Black), new Pen(Colors.Black), 0, 0, 50, 50); if (_direction == ArrowDirection.Down) { int Y, X; for (int i = 0; i <= 12; i++) { Y = 6 - i; X = 12 - i; dc.DrawLine(new Pen(Color.White), (this.Width / 2 - X), (this.Height / 2 - Y), (this.Width / 2 + X), (this.Height / 2 - Y)); } } else { int Y, X; for (int i = 0; i <= 12; i++) { Y = 17 - i; X = 12 - i; dc.DrawLine(new Pen(Color.White), (this.Width / 2 - X), Y, (this.Width / 2 + X), Y); } } }
public override void OnRender(DrawingContext dc) { // Update data on render scoreLabel.TextContent = _stats.Score.ToString(); levelLabel.TextContent = _stats.Level.ToString(); linesLabel.TextContent = _stats.LinesCompleted.ToString(); base.OnRender(dc); }
public override void OnRender(DrawingContext dc) { Bitmap bmp = _bitmap; if (bmp != null) { dc.DrawImage(_bitmap, 0, 0); } }
public override void OnRender(DrawingContext dc) { base.OnRender(dc); if (background != null) dc.Scale9Image(0, 0, ActualWidth, ActualHeight, background, 0, 0, 0, 0, opacity); if (border != null) dc.DrawRectangle(null, border, 0, 0, ActualWidth, ActualHeight); }
public override void OnRender(DrawingContext dc) { // Draw the bars for(int i=0; i < Value; i++) { dc.DrawRectangle(_fillBrush, _blockPen, (i*10)+10, 5, 5, 40); } base.OnRender(dc); }
public override void OnRender(DrawingContext dc) { base.OnRender(dc); if (IsSelected) { if (selectionBackgroundImage != null) dc.Scale9Image(0, 0, ActualWidth, ActualHeight, selectionBackgroundImage, 0, 0, 0, 0, opacity); } }
public override void OnRender(DrawingContext dc) { dc.DrawRectangle(_cyanBrush, _darkCyanPen, 0, 0, Width, Height); dc.DrawText(ref _name, _font, Color.Black, 0, 2, Width, Height - 2, TextAlignment.Center, TextTrimming.None); }
public override void OnRender(Microsoft.SPOT.Presentation.Media.DrawingContext dc) { // Saving performance create fill brush only once if (gradientBrush == null) { gradientBrush = new LinearGradientBrush(startColor, endColor, 0, this.Height / 2, 0, this.Height); } // Gradient fill dc.DrawRectangle(gradientBrush, null, 0, 0, this.Width, this.Height); // Left line separator dc.DrawRectangle(solidBrush, null, 0, 0, 2, this.Height); }
public override void OnRender(DrawingContext dc) { base.OnRender(dc); // draw crosshair if (idx < CalibrationManager.CalibrationPoints.Count) { int x = CalibrationManager.CalibrationPoints.ScreenX[idx]; int y = CalibrationManager.CalibrationPoints.ScreenY[idx]; dc.DrawLine(pen, x - 10, y, x - 2, y); dc.DrawLine(pen, x + 10, y, x + 2, y); dc.DrawLine(pen, x, y - 10, x, y - 2); dc.DrawLine(pen, x, y + 10, x, y + 2); } }
/// <summary> /// Overrides OnRender to do our own drawing. /// </summary> /// <param name="dc"></param> public override void OnRender(DrawingContext dc) { int x; int y; SolidColorBrush brush; Pen pen; Color color; Pen shade1; Pen shade2; // Check the pressed state and draw accordingly. if (_pressed) { brush = _pressedBackgroundBrush; pen = _pressedBorderPen; color = _pressedForeColor; shade1 = _darkShade; shade2 = _lightShade; } else { brush = _normalBackgroundBrush; pen = _borderPen; color = _foreColor; shade1 = _lightShade; shade2 = _darkShade; } GetLayoutOffset(out x, out y); // Draw the base rectangle of the button. dc.DrawRectangle(brush, pen, 1, 1, _width - 1, _height - 1); // Draw the caption. string caption = _caption; dc.DrawText(ref caption, _font, color, 0, _textMarginY, _width, _height, _alignment, _trimming); // Shade the outline of the rectangle for classic button look. dc.DrawLine(shade1, 1, 1, _width - 1, 1); dc.DrawLine(shade1, 1, 1, 1, _height - 1); dc.DrawLine(shade2, _width - 1, 1, _width - 1, _height - 1); dc.DrawLine(shade2, 1, _height - 1, _width - 1, _height - 1); }
public override void OnRender(DrawingContext dc) { dc.DrawRectangle(pressed ? brushPressed : brushUnpressed, null, 0, 0, ActualWidth, ActualHeight); //if (pressed) // dc.Bitmap.DrawRectangle(Color.Black, 0, 0, 0, ActualWidth, ActualHeight, 0, 0, ColorUtility.ColorFromRGB(128, 255, 0), 0, 0, ColorUtility.ColorFromRGB(128, 255, 0), ActualWidth, ActualHeight, 150); //else // dc.Bitmap.DrawRectangle(Color.Black, 0, 0, 0, ActualWidth, ActualHeight, 0, 0, Colors.Black, 0, 0, Colors.Black, ActualWidth, ActualHeight, 10); // border int corner = 2; int right = ActualWidth - 1; int bottom = ActualHeight - 1; dc.DrawLine(border, corner, 0, right - corner, 0); // top dc.DrawLine(border, corner, bottom, right - corner, bottom); // bottom dc.DrawLine(border, 0, corner, 0, bottom - corner); // left dc.DrawLine(border, right, corner, right, bottom - corner); // rigth dc.DrawLine(border, corner, 0, 0, corner); // upper-left dc.DrawLine(border, right - corner, 0, right, corner); // upper-right dc.DrawLine(border, 0, bottom - corner, corner, bottom); // bottom-left dc.DrawLine(border, right, bottom - corner, right - corner, bottom); // bottom-right // transparent corners ArrayList transparentPoints = new ArrayList(); transparentPoints.Add(new Point(0, 0)); transparentPoints.Add(new Point(1, 0)); transparentPoints.Add(new Point(0, 1)); transparentPoints.Add(new Point(right, 0)); transparentPoints.Add(new Point(right - 1, 0)); transparentPoints.Add(new Point(right, 1)); transparentPoints.Add(new Point(0, bottom)); transparentPoints.Add(new Point(1, bottom)); transparentPoints.Add(new Point(0, bottom - 1)); transparentPoints.Add(new Point(right, bottom)); transparentPoints.Add(new Point(right - 1, bottom)); transparentPoints.Add(new Point(right, bottom - 1)); foreach (Point p in transparentPoints) //dc.DrawRectangle(brushTransparent, null, p.X, p.Y, 1, 1); dc.Bitmap.DrawRectangle(Color.Black, 0, p.X, p.Y, 1, 1, 0, 0, Colors.Red, 0, 0, Colors.Red, 0, 0, 0); }
public override void OnRender(DrawingContext dc) { base.OnRender(dc); if (isSelected) { Pen pen = new Pen(Colors.DarkGray, 1); // top border dc.DrawLine(pen, 0, 0, ActualWidth - 1, 0); // left border dc.DrawLine(pen, 0, 0, 0, ActualHeight - 1); // right border dc.DrawLine(pen, ActualWidth - 1, 0, ActualWidth - 1, ActualHeight - 1); // bottom border dc.DrawLine(pen, 0, ActualHeight - 1, ActualWidth - 1, ActualHeight - 1); } }
public override void OnRender(DrawingContext dc) { // Performance tunning // storing properties to variables for faster reuse int fieldCols = gameUniverse.Field.Columns; int fieldRows = gameUniverse.Field.Rows; #region Draw Grid int final = fieldRows * ROW_HEIGHT; for(int col = 0; col <= fieldCols; col++) { int x = col * COLUMN_WIDTH; dc.DrawLine(gridPen, x, 0, x, final); } final = fieldCols * COLUMN_WIDTH; for (int row = 0; row <= fieldRows; row++) { int y = row * ROW_HEIGHT; dc.DrawLine(gridPen, 0, y, final, y); } #endregion #region Draw the game field for (int row = 0; row < fieldRows; row++) for (int col = 0; col < fieldCols; col++) { int brushType = gameUniverse.Field.GetCell(row, col) - 1; if (brushType >= 0) dc.DrawRectangle(BlockBrushes.Instance.GetBrush(brushType), blockPen, col * COLUMN_WIDTH + 1, row * ROW_HEIGHT + 1, COLUMN_WIDTH - 1, ROW_HEIGHT - 1); } #endregion #region Draw the current object // Performance tunning fieldCols = gameUniverse.CurrentBlock.Columns; fieldRows = gameUniverse.CurrentBlock.Rows; for (int row = 0; row < fieldRows; row++) for(int col = 0; col < fieldCols; col++) { int brushType = gameUniverse.CurrentBlock.GetCell(row, col) - 1; if (brushType >= 0) dc.DrawRectangle(BlockBrushes.Instance.GetBrush(brushType), blockPen, (col + gameUniverse.BlockX) * COLUMN_WIDTH + 1, (row + gameUniverse.BlockY) * ROW_HEIGHT + 1, COLUMN_WIDTH - 1, ROW_HEIGHT - 1); } #endregion #region Draw Game Over banner if (gameUniverse.Statistics.GameOver) { string gameOverStr = Resources.GetString(Resources.StringResources.GameOver); Font gameOverFont = Resources.GetFont(Resources.FontResources.Consolas23); int gameOverY = (this.Height - gameOverFont.Height) / 2; int gameOverHeight = gameOverFont.Height + 3; dc.DrawRectangle(new LinearGradientBrush(Colors.Gray, Colors.White, 0, 0, this.Width, gameOverFont.Height * 2), new Pen(Color.White), 2, gameOverY - 5, this.Width - 4, gameOverHeight + 5); dc.DrawText(ref gameOverStr, gameOverFont, Colors.Red, 0, gameOverY, this.Width, gameOverHeight, TextAlignment.Center, TextTrimming.WordEllipsis); } #endregion base.OnRender(dc); }
public override void OnRender(DrawingContext dc) { base.OnRender(dc); dc.DrawRectangle(new SolidColorBrush(Colors.White), new Pen(Colors.Gray), 0, 0, ActualWidth, ActualHeight); }
/// <summary> /// This is the standard RenderMessageHandler callback, posted via PostRender() /// and Resize(). This wraps RenderMessageHandlerCore and emits an ETW events /// to trace its execution. /// </summary> internal object RenderMessageHandler(object arg) { try { _isRendering = true; //_screen.Clear(); if (_invokeOnRenderCallbacks != null) { int callbackLoopCount = 0; int count = _invokeOnRenderCallbacks.Count; while (count > 0) { callbackLoopCount++; if (callbackLoopCount > 153) { throw new InvalidOperationException("infinite loop"); } InvokeOnRenderCallback[] callbacks = new InvokeOnRenderCallback[count]; _invokeOnRenderCallbacks.CopyTo(callbacks); _invokeOnRenderCallbacks.Clear(); for (int i = 0; i < count; i++) { callbacks[i].DoWork(); } count = _invokeOnRenderCallbacks.Count; } } DrawingContext dc = new DrawingContext(_screen); /* The dirty rectange MUST be read after the InvokeOnRender callbacks are * complete, as they can trigger layout changes or invalidate controls * which are expected to be redrawn. */ int x = _dirtyX0; int y = _dirtyY0; int w = _dirtyX1 - _dirtyX0; int h = _dirtyY1 - _dirtyY0; _dirtyX0 = _screenW; _dirtyY0 = _screenH; _dirtyX1 = _dirtyY1 = 0; try { if (w > 0 && h > 0) { // // This is the big Render! // // We've now updated layout and the updated scene will be // rendered. dc.PushClippingRectangle(x, y, w, h); _target.RenderRecursive(dc); dc.PopClippingRectangle(); } } finally { dc.Close(); if (w > 0 && h > 0) { _screen.Flush(x, y, w, h); } } } finally { _currentRenderOp = null; _isRendering = false; } return(null); }
public override void OnRender(DrawingContext dc) { base.OnRender(dc); _pBitmap = dc.Bitmap; _autoEvent.Set(); }
public override void OnRender(DrawingContext dc) { base.OnRender(dc); dc.DrawRectangle(null, new Pen(color), 0, 0, ActualWidth, ActualHeight); }
/// <summary> /// Renders the horizontal scroll bar. /// </summary> /// <param name="dc">The drawing context.</param> /// <param name="x">The X coordinate.</param> /// <param name="y">The Y coordinate.</param> /// <param name="scrollHeight">The height of the scroll bar.</param> protected void RenderHorizontalScrollBar(DrawingContext dc, int x, int y, int scrollHeight) { // Calculate and store the total width of the view. _horizontalScrollViewWidth = _width; _totalViewWidth = totalColumnWidth; // If there is no width, don't go any further. if (_totalViewWidth == 0) return; // Calculate and store the horizontal scroll information. _horizontalSliderWidth = (_horizontalScrollViewWidth * _horizontalScrollViewWidth) / _totalViewWidth; if (_horizontalSliderWidth > _width) _horizontalSliderWidth = _width; _horizontalSliderX = (_sx * _horizontalScrollViewWidth) / _totalViewWidth; // Draw the horizontal scrollbar background. int sy = y + _height - scrollHeight; dc.DrawRectangle(_lightBrush, _grayPen, x, sy, _horizontalScrollViewWidth, scrollHeight); // Draw the scrollbar thumb. dc.DrawRectangle(_grayBrush, _emptyPen, x + _horizontalSliderX, sy + 1, _horizontalSliderWidth, scrollHeight - 2); }
/// <summary> /// Handles the render event. /// </summary> /// <param name="dc"></param> public override void OnRender(DrawingContext dc) { // Loop through all the blocks except the animated block // and draw the associated bitmap. int i = 0; for (i = 0; i < 9; i++) { int x = (i % 3) * blockDimension; int y = (i / 3) * blockDimension; if (_animationTargetBlock != i) { DrawBlock(_blocks[i], x, y, dc); } } // Draw the animated block if there is one. if (_animationTargetBlock >= 0) { lock (_blockBitmap) { int x = (_animationTargetBlock % 3) * blockDimension; int y = (_animationTargetBlock / 3) * blockDimension; dc.DrawImage(_blockBitmap[8], x, y); if (_animationStep < 9 && activeAnimX != null && activeAnimY != null) { x += activeAnimX[_animationStep]; y += activeAnimY[_animationStep]; } DrawBlock(_blocks[_animationTargetBlock], x, y, dc); } } // Draw a rectangle box around the puzzle. dc.DrawLine(pen, 0, 0, 0, 239); dc.DrawLine(pen, 0, 0, 240, 0); dc.DrawLine(pen, 0, 239, 240, 239); dc.DrawLine(pen, 240, 0, 240, 239); }
/// <summary> /// Handles the render item event. This definition is here so we /// can call it from the OnRender method, but it is implemented in /// the derived class below. /// </summary> /// <param name="dc"></param> /// <param name="row"></param> /// <param name="column"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="width"></param> /// <param name="height"></param> protected virtual void OnRenderItem(DrawingContext dc, int row, int column, int x, int y, int width, int height) { }
/// <summary> /// Handle the render item event. /// </summary> /// <param name="dc"></param> /// <param name="row"></param> /// <param name="column"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="width"></param> /// <param name="height"></param> protected override void OnRenderItem(DrawingContext dc, int row, int column, int x, int y, int width, int height) { // The base class doesn't do anything, so don't bother calling // it. // Calculate the item so we know what color to use. int i = column + row * _column; // Draw a rectangle in that color at the correct location. dc.DrawRectangle(brushes[i], _pressedItem == i ? selectBorderPen : borderPen, x, y, width, height); }
private voiddelegate invalidate; // WORKAROUND private void Instance_PostRender(DrawingContext dc) { // The below workaround handles the issue that the OLED screen driver API cannot handle partial screen updates // WORKAROUND - when the clipping rectangle is not the full size, invalidate the whole window so we get called again with the full size int x, y, width, height; dc.GetClippingRectangle(out x, out y, out width, out height); if (x != 0 || y != 0 || width != dc.Width || height != dc.Height) { //Debug.Print("Paint rectangle: x " + x + " y " + y + " w " + width + " h " + height); if (invalidate == null) invalidate = new voiddelegate(WPFWindow.Invalidate); // WORKAROUND Program.BeginInvoke(invalidate, null); // WORKAROUND return; // WORKAROUND } Paint(dc.Bitmap); }
/// <summary> /// Handles the render event. /// </summary> /// <param name="dc"></param> public override void OnRender(DrawingContext dc) { base.OnRender(dc); // If the flag is set, draw a circle. if (drawCircle) { dc.DrawEllipse(brush, pen2, cx, cy, r, r); } }
/// <summary> /// Handles the render event. /// </summary> /// <param name="dc"></param> public override void OnRender(DrawingContext dc) { base.OnRender(dc); // If the flag is set, draw a circle. if (drawCircle) { dc.DrawEllipse(brush, pen, cx, cy, r, r); } // If we have some points, draw lines between them to make a // complete path. if (pointIndex > 1) { for (int i = 1; i < pointIndex; i++) { dc.DrawLine(pen2, Points[i - 1].x, Points[i - 1].y, Points[i].x, Points[i].y); } } }
/// <summary> /// Overrides the OnRender to do our own drawing. /// </summary> /// <param name="dc"></param> public override void OnRender(DrawingContext dc) { base.OnRender(dc); // Start at row 0, column 0. int i = 0; int j = 0; // Loop through all the rows. for (i = 0; i < _row; i++) { // Loop through all the columns. for (j = 0; j < _column; j++) { int x = j * _itemWidth + 2; int y = i * _itemHeight + 2; // Render the item. OnRenderItem(dc, i, j, x, y, _itemWidth, _itemHeight); } } }
/// <summary> /// /// </summary> /// <param name="i"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="dc"></param> private void DrawBlock(int i, int x, int y, DrawingContext dc) { dc.DrawImage(_blockBitmap[i], x, y); }
public override void OnRender(DrawingContext dc) { if (background != null) dc.DrawRectangle(background, null, 0, 0, ActualWidth, ActualHeight); if (foreground != null) { bool horizontal = orientation == Orientation.Horizontal; int w = horizontal ? ActualWidth * value / 100 : ActualWidth; int h = horizontal ? ActualHeight : ActualHeight * value / 100; dc.DrawRectangle(foreground, null, 0, 0, w, h); } }
public virtual void OnRender(DrawingContext dc) { }
/// <summary> /// Renders the vertical scroll bar. /// </summary> /// <param name="dc"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="scrollWidth"></param> /// <param name="itemHeight"></param> protected void RenderVerticalScrollBar(DrawingContext dc, int x, int y, int scrollWidth, int itemHeight) { try { // Calculate and store the total view height. _totalViewHeight = Items.Count * itemHeight; // If there is no height, don't go any further. if (_totalViewHeight == 0) return; // Calculate and store the vertical scroll information. _verticalScrollViewHeight = _height - scrollWidth - y; _verticalSliderHeight = (_verticalScrollViewHeight * _verticalScrollViewHeight) / _totalViewHeight; _verticalSliderY = (_sy * _verticalScrollViewHeight) / _totalViewHeight; // Draw the vertical scrollbar background. int sx = x + _width - scrollWidth; dc.DrawRectangle(_lightBrush, _grayPen, sx, y, scrollWidth, _verticalScrollViewHeight); // Draw the scrollbar thumb. if (_verticalSliderHeight < _height) { dc.DrawRectangle(_grayBrush, _emptyPen, sx + 1, y + 1 + _verticalSliderY, scrollWidth - 2, _verticalSliderHeight); } } catch (Exception ex) { Debug.Print(ex.ToString()); } }
public override void OnRender(DrawingContext dc) { int width = _renderWidth; int height = _renderHeight; // Border // dc.DrawRectangle(_borderBrush, null, 0, 0, width, height); // Background // if (_background != null) { dc.DrawRectangle(_background, null, _borderLeft, _borderTop, width - _borderLeft - _borderRight, height - _borderTop - _borderBottom); } }
protected internal virtual void RenderRecursive(DrawingContext dc) { Debug.Assert(this.IsMeasureValid && this.IsArrangeValid); dc.Translate(_offsetX, _offsetY); dc.PushClippingRectangle(0, 0, _renderWidth, _renderHeight); try { Debug.Assert(this.Visibility == Visibility.Visible); if (!dc.EmptyClipRect) { OnRender(dc); UIElementCollection children = _logicalChildren; if (children != null) { int n = children.Count; for (int i = 0; i < n; i++) { UIElement child = children[i]; if (child.IsRenderable()) { child.RenderRecursive(dc); } } } } } finally { dc.PopClippingRectangle(); dc.Translate(-_offsetX, -_offsetY); //------------------------------------------------------------------------------- // Reset the render flags. _flags &= ~(Flags.IsSubtreeDirtyForRender | Flags.IsDirtyForRender); } }