Esempio n. 1
0
        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(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);
        }
Esempio n. 3
0
 public override void OnRender(DrawingContext dc)
 {
     if (_background != null)
     {
         dc.DrawRectangle(_background, null, 0, 0, _renderWidth, _renderHeight);
     }
 }
Esempio n. 4
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);
                }
            }
        }
Esempio n. 5
0
        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)
 {
     dc.DrawRectangle(_cyanBrush, _darkCyanPen, 0, 0, Width, Height);
     dc.DrawText(ref _name,
                 _font,
                 Color.Black,
                 0,
                 2,
                 Width,
                 Height - 2,
                 TextAlignment.Center,
                 TextTrimming.None);
 }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
            /// <summary>
            /// Renders the items in the list view.
            /// </summary>
            /// <param name="dc"></param>
            /// <param name="x"></param>
            /// <param name="y"></param>
            /// <param name="headerHeight"></param>
            /// <param name="itemHeight"></param>
            protected virtual void RenderItems(DrawingContext dc, int x, int y,
                int headerHeight, int itemHeight)
            {

                // Create the brushes and pens for drawing the items.
                Brush[] brushes = new Brush[] { _emptyBrush, _lightCyanBrush, 
                    _grayBrush };
                Pen[] pens = new Pen[] { _emptyPen, _cyanPen };

                // Set the starting location for the first item.  Offset the 
                // location by _sx and _sy, which are the scroll positions.
                int cx = x + 6 - _sx;
                int cy = y + headerHeight + 2 - _sy;
                int j = 0;

                // Iterate through all the items.
                for (int ii = 0; ii < Items.Count; ii++)
                {
                    // Only draw the items that are visible.
                    if (cy >= _columnHeaderHeight)
                    {

                        // If the item is selected...
                        if (((ListViewItem)Items[ii]) == _selectedItem)
                        {
                            // Draw a rectangle alternately shaded and 
                            // transparent.
                            dc.DrawRectangle(brushes[2], pens[j & 1], x + 2, cy,
                            _width - 4, _itemHeight);
                        }
                        else
                        {
                            // Draw a rectangle alternately shaded and 
                            // transparent.
                            dc.DrawRectangle(brushes[j & 1], pens[j & 1], x + 2,
                                cy, _width - 4, _itemHeight);
                        }

                        // Set the starting location for the first column.
                        // Offset the location by _sx, which is the scroll 
                        // position.
                        cx = 4 - _sx;
                        int i = 0;
                        int newcx = 0;

                        // Iterate through the sub-items, which are columns.
                        for (int e = 0; e < ((ListViewItem)Items[ii]).SubItems.Count; e++)
                        {
                            // Calculate the x position of the next column.
                            newcx = cx + ((ListViewColumn)Columns[i]).Width;

                            // Draw only the items that will appear on the 
                            // screen.
                            if (newcx > 0)
                            {
                                dc.DrawText(((ListViewSubItem)((ListViewItem)Items[ii]).SubItems[e]).Text, _font, Color.Black,
                                    cx, cy + 2);
                            }

                            // Move to the next column.
                            cx = newcx;
                            i++;

                            // If the location is past the right side of the 
                            // screen, don't show any more columns.
                            if (cx > _width)
                                break;
                        }
                    }

                    // Increment to the next item.
                    cy += itemHeight;
                    j++;

                    // If the location is past the bottom of the screen, don't 
                    // show any more items.
                    if (cy > _height)
                        break;
                }
            }
Esempio n. 9
0
            /// <summary>
            /// Renders the column titles of the list view.
            /// </summary>
            /// <param name="dc"></param>
            /// <param name="x"></param>
            /// <param name="y"></param>
            /// <param name="headerHeight"></param>
            protected virtual void RenderColumns(DrawingContext dc, int x,
                int y, int headerHeight)
            {

                // Draw the header background.
                dc.DrawRectangle(_cyanBrush, _darkCyanPen, x, y + 2, _width,
                    headerHeight);

                // Iterate through the columns.
                int cx = 5 - _sx;
                for (int i = 0; i < Columns.Count; i++)
                {
                    // Draw the column text.
                    dc.DrawText(((ListViewColumn)Columns[i]).Name, _font, Color.Black, cx, y + 2);

                    // Increment by the column width.
                    cx += ((ListViewColumn)Columns[i]).Width;
                }

                // Store the total column width.
                totalColumnWidth = cx;
            }
Esempio n. 10
0
 public override void OnRender(DrawingContext dc)
 {
     //if (pressed)
     if (TouchCapture.Captured == this)
         dc.DrawRectangle(brushPressed, null, 0, 0, ActualWidth, ActualHeight);
 }
Esempio n. 11
0
            /// <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);
            }
Esempio n. 12
0
 public override void OnRender(DrawingContext dc)
 {
     base.OnRender(dc);
     dc.DrawRectangle(new SolidColorBrush(Colors.White), new Pen(Colors.Gray), 0, 0, ActualWidth, ActualHeight);
 }
        public override void OnRender(DrawingContext dc)
        {
            base.OnRender(dc);

            dc.DrawRectangle(null, new Pen(color), 0, 0, ActualWidth, ActualHeight);
        }
Esempio n. 14
0
            /// <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);
            }
Esempio n. 15
0
 public override void OnRender(DrawingContext dc)
 {
     if (Bitmap != null)
         dc.DrawRectangle(brush, null, 0, 0, ActualWidth, ActualHeight);
 }
Esempio n. 16
0
        public override void OnRender(DrawingContext dc)
        {
            if (IsSelected)
                dc.DrawRectangle(selectedBrush, null, 0, 0, Width, Height);
            else
                dc.DrawRectangle(null, null, 0, 0, Width, Height);

            if (icon != null)
                dc.DrawImage(icon, iconOffset, iconOffset);
        }
Esempio n. 17
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);
        }
Esempio n. 18
0
        /// <summary>
        /// Overrides the base class OnRender method, to handle drawing.
        /// </summary>
        /// <param name="dc"></param>
        public override void OnRender(DrawingContext dc)
        {
            // Call the base class.
            base.OnRender(dc);

            // Create a solid black brush.
            SolidColorBrush brush =
                new SolidColorBrush(ColorUtility.ColorFromRGB(0, 0, 0));

            // Make the brush transparent.  Display only the outside edge, which 
            // uses the pen.
            brush.Opacity = 0;

            // Draw the border around the outside.
            dc.DrawRectangle(brush, new Pen(Color.Black), 0, 0, dc.Width,
                dc.Height);
        }
Esempio n. 19
0
 public override void OnRender(DrawingContext dc)
 {
     if (isCircle)
         dc.DrawEllipse(isActive ? activeBrush : inactiveBrush, border, ActualWidth / 2, ActualHeight / 2, (ActualWidth - 1) / 2, (ActualHeight - 1) / 2);
     else
         dc.DrawRectangle(isActive ? activeBrush : inactiveBrush, border, 0, 0, ActualWidth, ActualHeight);
 }
Esempio n. 20
0
        public override void OnRender(DrawingContext dc)
        {
            int r = Height / 2 - 1;

            // track
            int w = Width - 2 * r;
            dc.DrawRectangle(trackBrush, null, r, (Height - trackSize) / 2, w, trackSize);

            // thumb
            int x = (int)(r + (Width - 2 * r - 1) * value / 100);
            int y = r;
            dc.DrawEllipse(thumbBrush, null, x, y, r, r);

            ////Draw Slider
            //spriteBatch.Draw(GUIManager.skin, dstRectLeft, srcRectLeft, (hasHighlight ? highlightColor : BackColor));
            //spriteBatch.Draw(GUIManager.skin, dstRectMid, srcRectMid, BackColor);
            //spriteBatch.Draw(GUIManager.skin, dstRectRight, srcRectLeft, BackColor, 0f, Vector2.Zero, SpriteEffects.FlipHorizontally, 0f);

            ////Draw Slider Highlight
            //if (hasHighlight)
            //    spriteBatch.Draw(GUIManager.skin, dstRectMidHighlight, srcRectMid, highlightColor);

            ////Draw Thumb
            //spriteBatch.Draw(GUIManager.skin, dstRectThumb, srcRectThumb, BackColor);
        }
Esempio n. 21
0
            /// <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());
                }
            }
Esempio n. 22
0
 public override void OnRender(DrawingContext dc)
 {
     if (Orientation == Orientation.Horizontal)
     {
         barThickness = (ActualWidth - gap * (barCount - 1)) / barCount;
         int x = 0;
         for (int i = 1; i <= barCount; i++)
         {
             int val = ActualHeight * i / barCount;
             dc.DrawRectangle(
                 i <= activeBarCount ? foreground : background,
                 null,
                 x, ActualHeight - val,
                 barThickness, val);
             x += barThickness + gap;
         }
     }
     else
     {
         barThickness = (ActualHeight - gap * (barCount - 1)) / barCount;
         int y = ActualHeight - barThickness;
         for (int i = 1; i <= barCount; i++)
         {
             int val = ActualWidth * i / barCount;
             dc.DrawRectangle(
                 i <= activeBarCount ? foreground : background,
                 null,
                 ActualWidth - val, y,
                 val, barThickness);
             y -= barThickness + gap;
         }
     }
 }
Esempio n. 23
0
            /// <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>
        /// Override the OnRender to enable manually drawing the scroll bars.
        /// </summary>
        /// <param name="dc"></param>
        public override void OnRender(DrawingContext dc)
        {
            base.OnRender(dc);

            // Make a brush and pen for drawing scroll bars.
            SolidColorBrush brush =
                new SolidColorBrush(ColorUtility.ColorFromRGB(224, 224, 224));
            SolidColorBrush sliderBrush =
                new SolidColorBrush(ColorUtility.ColorFromRGB(64, 64, 64));
            Pen pen = new Pen(ColorUtility.ColorFromRGB(64, 64, 64));

            // Draw the horizontal scroll bar.
            int hOffset = (int)(_viewer.HorizontalOffset * _hScrollRatio);
            dc.DrawRectangle(brush, pen, 0, Height - _hScrollHeight, _hScrollWidth,
                _hScrollHeight);
            dc.DrawRectangle(sliderBrush, pen,
                (int)(_viewer.HorizontalOffset * _hScrollRatio),
                Height - _hScrollHeight, _vScrollWidth, _hScrollHeight);

            // Draw the vertical scroll bar.
            int vOffset = (int)(_viewer.VerticalOffset * _vScrollRatio);
            dc.DrawRectangle(brush, pen, Width - _vScrollWidth, 0, _vScrollWidth,
                _vScrollHeight);
            dc.DrawRectangle(sliderBrush, pen, Width - _vScrollWidth, vOffset,
                _vScrollWidth, _hScrollHeight);
        }
Esempio n. 25
0
        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);
            }
        }
Esempio n. 26
0
 public override void OnRender(DrawingContext dc)
 {
     if (background != null || border != null)
         dc.DrawRectangle(background, border, 0, 0, ActualWidth, ActualHeight);
 }
        /// <summary>
        /// Override the OnRender and draw using the DrawingContext that is passed 
        /// in.
        /// </summary>
        /// <param name="dc"></param>
        public override void OnRender(DrawingContext dc)
        {
            // Paint the background.
            dc.DrawRectangle(
                new SolidColorBrush(ColorUtility.ColorFromRGB(128, 0, 255)),
                new Pen(ColorUtility.ColorFromRGB(128, 0, 255)),
                0, 0, Width, Height);

            // Draw some circles.
            for (int i = 0; i < 3; i++)
                dc.DrawEllipse(
                    new SolidColorBrush(ColorUtility.ColorFromRGB((byte)(64 * i),
                        128, 128)),
                    new Pen(ColorUtility.ColorFromRGB(255, (byte)(64 * i), 255)),
                    Width / 5, Height / 5, i * (Width / 10 - (i * 2)),
                    i * (Height / 10 - (i * 2)));

            // Draw some lines.
            for (int i = 0; i < 20; i++)
                dc.DrawLine(new Pen(ColorUtility.ColorFromRGB((byte)(16 * i),
                    (byte)(16 * (20 - i)), (byte)(16 * (2 * i)))),
#if MF_FRAMEWORK_VERSION_V3_0
                Microsoft.SPOT.Math.Random(Width / 2) + Width / 3,
                Microsoft.SPOT.Math.Random(Height / 3) + Height / 3,
                Microsoft.SPOT.Math.Random(Width / 4) + Width / 2,
                Microsoft.SPOT.Math.Random(Height / 4) + Height / 2);
#else
 _random.Next(Width / 2) + Width / 3,
                    _random.Next(Height / 3) + Height / 3,
                    _random.Next(Width / 4) + Width / 2,
                    _random.Next(Height / 4) + Height / 2);
#endif

            // Draw a rectangle.
            dc.DrawRectangle(new SolidColorBrush(ColorUtility.ColorFromRGB(
                255, 0, 0)),
                new Pen(ColorUtility.ColorFromRGB(0, 0, 255)), Width - 40, 0, 30,
                100);

            // Draw a polyline.
            int[] points = { 10, 230, 30, 210, 0, 180, 30, 130, 50, 130, 80, 180, 
                           50, 210, 70, 230 };
            if (Width > Height)
                for (int i = 1; i < points.Length; i += 2)
                    points[i] -= 20;
            dc.DrawPolygon(new SolidColorBrush(ColorUtility.ColorFromRGB(
                32, 0, 128)),
                new Pen(ColorUtility.ColorFromRGB(0, 0, 0)), points);

            // Draw some text.
            dc.DrawText(Resources.GetString(
                Resources.StringResources.DrawTextSample),
                Resources.GetFont(Resources.FontResources.NinaBFont),
                ColorUtility.ColorFromRGB(255, 255, 255),
#if MF_FRAMEWORK_VERSION_V3_0
            Microsoft.SPOT.Math.Random(Width / 4), Height - 20);
#else
 _random.Next(Width / 4), Height - 20);
#endif
        }
Esempio n. 28
0
            /// <summary>
            /// Renders the list view.
            /// </summary>
            /// <param name="dc">The drawing context of the list view.</param>
            public override void OnRender(DrawingContext dc)
            {
                int x;
                int y;

                // Get the x and y offsets.
                GetLayoutOffset(out x, out y);

                // Draw a border around the list view.
                dc.DrawRectangle(_emptyBrush, _borderPen, x, y, _width, _height);

                // Render the buttons.
                RenderButtons(dc, x, y);

                // Render the columns.
                cy1 = _columnHeaderHeight - 20;
                cy2 = _columnHeaderHeight;
                RenderColumns(dc, x, y + cy1, 20);

                // Render all the items.
                RenderItems(dc, x, y, _columnHeaderHeight, _itemHeight);

                // Render the vertical scroll bar.
                RenderVerticalScrollBar(dc, x, y + _columnHeaderHeight,
                    _scrollbarDimension, _itemHeight);

                // Calculate the positions of the different areas of the screen.
                cy3 = _height - _scrollbarDimension;
                cx1 = (_width - _scrollbarDimension) / 5;
                cx2 = cx1 * 2;
                cx3 = cx1 * 3;
                cx4 = cx1 * 4;
                cx5 = _width - _scrollbarDimension;

                // Render the horizontal scroll bar.
                RenderHorizontalScrollBar(dc, x, y, _scrollbarDimension);
            }
Esempio n. 29
0
        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);
        }
Esempio n. 30
0
            /// <summary>
            /// Renders the buttons.
            /// </summary>
            /// <param name="dc">The drawing context.</param>
            /// <param name="x">The width of a button.</param>
            /// <param name="y">The height of a button.</param>
            protected virtual void RenderButtons(DrawingContext dc, int x,
                int y)
            {

                // Calculate the width of a single button.
                int buttonWidth = _width / 5;

                // Render the New File button.
                dc.DrawRectangle(_cyanBrush, _darkCyanPen, x, y, buttonWidth,
                    20);
                string sNewFile = "New File";
                dc.DrawText(ref sNewFile, _font, Color.Black, x, y + 2,
                    buttonWidth, 16, TextAlignment.Center,
                    TextTrimming.None);

                // Render the New Directory button.
                dc.DrawRectangle(_cyanBrush, _darkCyanPen, x + buttonWidth, y,
                    buttonWidth, 20);
                string sNewDir = "New Dir";
                dc.DrawText(ref sNewDir, _font, Color.Black, x + buttonWidth,
                    y + 2, buttonWidth, 16,
                    TextAlignment.Center, TextTrimming.None);

                // Render the Move button.
                dc.DrawRectangle(_cyanBrush, _darkCyanPen, x + (buttonWidth * 2),
                    y, buttonWidth, 20);
                string sMove = "Move";
                dc.DrawText(ref sMove, _font, Color.Black, x + (buttonWidth * 2),
                    y + 2, buttonWidth, 16,
                    TextAlignment.Center, TextTrimming.None);

                // Render the Delete button.
                dc.DrawRectangle(_cyanBrush, _darkCyanPen, x + (buttonWidth * 3),
                    y, buttonWidth, 20);
                string sDelete = "Delete";
                dc.DrawText(ref sDelete, _font, Color.Black,
                    x + (buttonWidth * 3), y + 2, buttonWidth, 16,
                    TextAlignment.Center, TextTrimming.None);

                // Render the Format button.
                dc.DrawRectangle(_cyanBrush, _darkCyanPen, x + (buttonWidth * 4),
                    y, buttonWidth, 20);
                string sFormat = "Format";
                dc.DrawText(ref sFormat, _font,
                    Color.Black, x + (buttonWidth * 4), y + 2, buttonWidth, 16,
                    TextAlignment.Center, TextTrimming.None);
            }
Esempio n. 31
0
        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);
            }
        }
Esempio n. 32
0
 public override void OnRender(DrawingContext dc)
 {
     if (!Utils.StringIsNullOrEmpty(activeBitmapID))
     {
         ImageBrush brush = (ImageBrush)brushes[activeBitmapID];
         if (brush != null && brush.BitmapSource != null)
             dc.DrawRectangle(brush, null, 0, 0, ActualWidth, ActualHeight);
     }
 }