Пример #1
0
            /// <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);
                    }
                }
            }
Пример #2
0
            /// <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);
                }
            }
Пример #3
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);
 }
Пример #4
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);
        }
        /// <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
        }
Пример #6
0
            public override void OnRender(DrawingContext dc)
            {
                if (_pushClippingRectangle)
                {
                    try
                    {
                        dc.PushClippingRectangle(x0, y0, xDimension, yDimension);
                    }
                    catch (ArgumentException ex)
                    {
                        Log.Comment("Caught " + ex.Message + " when Pushing a clipping rectangle at (" + x0 + ", " + y0 + ")" +
                            " and Width = " + xDimension + " Height = " + yDimension);
                        _argumentException = true;
                    }
                }
                if (_popClippingRectangle)
                {
                    dc.PopClippingRectangle();
                }
                if (_getClippingRectangle)
                {
                    dc.GetClippingRectangle(out x1, out y1, out wd, out ht);
                }
                if (_drawLine)
                {
                    dc.DrawLine(_pen, x0, y0, x1, y1);
                }
                if (_drawRectangle)
                {
                    try
                    {
                        dc.DrawRectangle(_brush, _pen, r, s, xDimension, yDimension);
                    }
                    catch (ArgumentException ex)
                    {
                        Log.Comment("Caught " + ex.Message + " when drawing a Rectangle at (" + r + ", " + s + ")" +
                            " Width = " + xDimension + " Height = " + yDimension);
                        _argumentException = true;
                    }
                }
                if (_drawEllipse)
                {
                    dc.DrawEllipse(_brush, _pen, r, s, xDimension, yDimension);
                }
                if (_drawPolygon)
                {
                    dc.DrawPolygon(_brush, _pen, pts);
                }
                if (_clear)
                {
                    dc.Clear();
                }
                if (_setPixel)
                {
                    dc.SetPixel(_color, r, s);
                }
                if (_drawImage)
                {
                    try
                    {
                        dc.DrawImage(bmp1, r, s);
                    }
                    catch (NullReferenceException ex)
                    {
                        Log.Comment("Caught " + ex.Message + " when drawing a null Image");
                        _nullReferenceException = true;
                    }
                }
                if (_drawCroppedImage)
                {
                    try
                    {
                        dc.DrawImage(bmp1, r, s, x0, y0, xDimension, yDimension);
                    }                   
                    catch (ArgumentException ex)
                    {
                        Log.Comment("Caught " + ex.Message + " when drawing an Image at (" + r + ", " + s + ")" +
                            "from a source Image at(" + x0 + ", " + y0 + ") Width = " + xDimension + " Height = " + yDimension);
                        _argumentException = true;
                    }
                    catch (NullReferenceException ex)
                    {
                        Log.Comment("Caught " + ex.Message + " when drawing a null Image");
                        _nullReferenceException = true;
                    }
                }
                if (_translate)
                {
                    dc.Translate(r, s);
                }
                if (_blendImage)
                {
                    dc.BlendImage(bmp2, x0, y0, x1, y1, xDimension, yDimension, _opacity);
                }
                if (_drawText)
                {
                    _textFits = dc.DrawText(ref _str, _font, _color, r, s, xDimension, yDimension, _alignment, _trimming);
                }
                base.OnRender(dc);
                _pBitmap = dc.Bitmap;

                Master_Media.autoEvent.Set();
            }