/// <summary>
 /// Sets a specified pixel to the specified color.
 /// </summary>
 /// <param name="color">The color to set the pixel to.</param>
 /// <param name="x">The X coordinate of the pixel.</param>
 /// <param name="y">The Y coordinate of the pixel.</param>
 public void SetPixel(Color color, uint x, uint y)
 {
     _display.SetPixel((int)x, (int)y, color);
     if (AutoRedraw)
     {
         Redraw();
     }
 }
                /// <summary>
                /// Displays the specified text.
                /// </summary>
                /// <param name="text">The text to display.</param>
                /// <param name="font">The font to use for the text display.</param>
                /// <param name="color">The color of the text.</param>
                /// <param name="x">The X coordinate to begin the text display.</param>
                /// <param name="y">The Y coordinate to begin the text display.</param>
                /// <remarks>
                /// This method displays text at the specified screen location.
                /// If the text is too long for the display, it will be clipped.
                /// </remarks>
                public void DisplayText(string text, Font font, Color color, uint x, uint y)
                {
                    _display.DrawText(text, font, color, (int)x, (int)y);

                    if (AutoRedraw)
                    {
                        Redraw();
                    }
                }
                /// <summary>
                /// Displays a line.
                /// </summary>
                /// <param name="color">The color of the line.</param>
                /// <param name="thickness">The thickness of the line.</param>
                /// <param name="x0">The X coordinate of the starting point of the line.</param>
                /// <param name="y0">The Y coordinate of the starting point of the line.</param>
                /// <param name="x1">The X coordinate of the ending point of the line.</param>
                /// <param name="y1">The Y coordinate of the ending point of the line.</param>
                public void DisplayLine(Color color, int thickness, int x0, int y0, int x1, int y1)
                {
                    _display.DrawLine(color, thickness, x0, y0, x1, y1);

                    if (AutoRedraw)
                    {
                        Redraw();
                    }
                }
                /// <summary>
                /// Displays an ellipse.
                /// </summary>
                /// <param name="outlineColor">The color of the ellipse outline.</param>
                /// <param name="x">The X coordinate of the center of the ellipse.</param>
                /// <param name="y">The Y coordinate of the center of the ellipse.</param>
                /// <param name="xRadius">The radius value for Y.</param>
                /// <param name="yRadius">The radius value for X.</param>
                public void DisplayEllipse(Color outlineColor, uint x, uint y, uint xRadius, uint yRadius)
                {
                    _display.DrawEllipse(outlineColor, (int)x, (int)y, (int)xRadius, (int)yRadius);

                    if (AutoRedraw)
                    {
                        Redraw();
                    }
                }
                /// <summary>
                /// Displays the specified text within the specified rectangular region.
                /// </summary>
                /// <param name="text">The text to display.</param>
                /// <param name="x">The X coordinate of the rectangular region.</param>
                /// <param name="y">The Y coordinate of the rectangular region.</param>
                /// <param name="width">The width of the rectangular region.</param>
                /// <param name="height">The height of the rectangular region.</param>
                /// <param name="color">The text color.</param>
                /// <param name="font">The text font.</param>
                /// <param name="textAlignment">A value from the <see cref="TextAlign"/> enumeration that specifies how to align the text within the rectangular region.</param>
                /// <param name="wordWrap">A value from the <see cref="WordWrap"/> enumeration that specifies how to wrap the text within the rectangular region.</param>
                /// <param name="trimming">A value from the <see cref="Trimming"/> enumeration that specifies how to trim excess text.</param>
                /// <param name="scaleTextToFit">A value from the <see cref="ScaleText"/> enumeration that specifies how the text should be scaled.</param>
                public void DisplayTextInRectangle(string text, uint x, uint y, uint width, uint height,
                                                   Color color, Font font, TextAlign textAlignment, WordWrap wordWrap, Trimming trimming, ScaleText scaleTextToFit)
                {
                    uint dtFlags = Bitmap.DT_None;

                    switch (textAlignment)
                    {
                    case TextAlign.Center:
                        dtFlags |= Bitmap.DT_AlignmentCenter;
                        break;

                    case TextAlign.Left:
                        dtFlags |= Bitmap.DT_AlignmentLeft;
                        break;

                    case TextAlign.Right:
                        dtFlags |= Bitmap.DT_AlignmentRight;
                        break;

                    default:
                        break;
                    }

                    switch (trimming)
                    {
                    case Trimming.CharacterEllipsis:
                        dtFlags |= Bitmap.DT_TrimmingCharacterEllipsis;
                        break;

                    case Trimming.WordEllipsis:
                        dtFlags |= Bitmap.DT_TrimmingWordEllipsis;
                        break;

                    default:
                        break;
                    }


                    if (wordWrap == WordWrap.Wrap)
                    {
                        dtFlags |= Bitmap.DT_WordWrap;
                    }

                    if (scaleTextToFit == ScaleText.None)
                    {
                        dtFlags |= Bitmap.DT_IgnoreHeight;
                    }

                    _display.DrawTextInRect(text, (int)x, (int)y, (int)width, (int)height, dtFlags, color, font);

                    if (AutoRedraw)
                    {
                        Redraw();
                    }
                }
                /// <summary>
                /// Displays a rectangle.
                /// </summary>
                /// <param name="outlineColor">The color for the outline of the rectangle.</param>
                /// <param name="thicknessOutline">The thickness of the outline.</param>
                /// <param name="x">The X coordinate for the top left corner of the rectangle.</param>
                /// <param name="y">The Y coordinate for the top left corner of the rectangle.</param>
                /// <param name="width">The width of the rectangle.</param>
                /// <param name="height">The height of the rectangle.</param>
                /// <param name="xCornerRadius">The X dimension corner radius, or zero for none.</param>
                /// <param name="yCornerRadius">The Y dimension corner radius, or zero for none.</param>
                /// <param name="colorGradientStart">The color to begin the background gradient.</param>
                /// <param name="xGradientStart">The X coordinate to begin the background gradient.</param>
                /// <param name="yGradientStart">The Y coordinate to begin the background gradient.</param>
                /// <param name="colorGradientEnd">The color to end the background gradient.</param>
                /// <param name="xGradientEnd">The X coordinate to end the background gradient.</param>
                /// <param name="yGradientEnd">The Y coordinate to end the background gradient.</param>
                /// <param name="opacity">The opacity of the rectangle, 0 (transparent)..256 (opaque).</param>
                public void DisplayRectangle(Color outlineColor, uint thicknessOutline, uint x, uint y, uint width, uint height,
                                             uint xCornerRadius, uint yCornerRadius, Color colorGradientStart, uint xGradientStart, uint yGradientStart,
                                             Color colorGradientEnd, uint xGradientEnd, uint yGradientEnd, ushort opacity)
                {
                    _display.DrawRectangle(outlineColor, (int)thicknessOutline, (int)x, (int)y, (int)width, (int)height, (int)xCornerRadius, (int)yCornerRadius,
                                           colorGradientStart, (int)xGradientStart, (int)yGradientStart, colorGradientEnd, (int)xGradientEnd, (int)yGradientEnd, opacity);

                    if (AutoRedraw)
                    {
                        Redraw();
                    }
                }
Example #7
0
                /// <summary>
                /// Displays a line.
                /// </summary>
                /// <param name="color">The color of the line.</param>
                /// <param name="thickness">The thickness of the line.</param>
                /// <param name="x0">The X coordinate of the starting point of the line.</param>
                /// <param name="y0">The Y coordinate of the starting point of the line.</param>
                /// <param name="x1">The X coordinate of the ending point of the line.</param>
                /// <param name="y1">The Y coordinate of the ending point of the line.</param>
                public void DisplayLine(Color color, int thickness, int x0, int y0, int x1, int y1)
                {
                    _screen.DrawLine(color, thickness, x0, y0, x1, y1);

                    if (_autoRedraw)
                    {
                        if (_redrawAll)
                        {
                            _displayModule.Paint(_screen, 0, 0, _width, _height);
                            _redrawAll = false;
                        }
                        else
                        {
                            int top = y0;
                            int left = x0;
                            int right = x1;
                            int bottom = y1;

                            if (y0 > y1) { top = y1; bottom = y0; }
                            if (x0 > x1) { left = x1; right = x0; }

                            if (thickness > 1)
                            {
                                top -= thickness;
                                left -= thickness;
                                right += thickness - 1; // This is what works in testing!
                                bottom += thickness;
                            }

                            if (top < 0) top = 0;
                            if (left < 0) left = 0;
                            if (right >= _width) right = _width - 1;
                            if (bottom >= _height) bottom = _height - 1;

                            _displayModule.Paint(_screen, left, top, right - left + 1, bottom - top + 1);
                        }
                    }
                }
 /// <summary>
 /// Displays a rectangle.
 /// </summary>
 /// <param name="outlineColor">The color for the outline of the rectangle.</param>
 /// <param name="thicknessOutline">The thickness of the outline.</param>
 /// <param name="fillColor">The color to fill the rectangle with.</param>
 /// <param name="x">The X coordinate for the top left corner of the rectangle.</param>
 /// <param name="y">The Y coordinate for the top left corner of the rectangle.</param>
 /// <param name="width">The width of the rectangle.</param>
 /// <param name="height">The height of the rectangle.</param>
 /// <param name="cornerRadius">The corner radius to be applied in both the X and Y dimensions.</param>
 /// <param name="opacity">The opacity of the rectangle, 0 (transparent)..256 (opaque).</param>
 public void DisplayRectangle(Color outlineColor, uint thicknessOutline, Color fillColor, uint x, uint y, uint width, uint height, uint cornerRadius, ushort opacity)
 {
     DisplayRectangle(outlineColor, thicknessOutline, x, y, width, height, cornerRadius, cornerRadius, fillColor, 0, 0, fillColor, 0, 0, opacity);
 }
 /// <summary>
 /// Displays a rectangle.
 /// </summary>
 /// <param name="outlineColor">The color for the outline of the rectangle.</param>
 /// <param name="thicknessOutline">The thickness of the outline.</param>
 /// <param name="fillColor">The color to fill the rectangle with.</param>
 /// <param name="x">The X coordinate for the top left corner of the rectangle.</param>
 /// <param name="y">The Y coordinate for the top left corner of the rectangle.</param>
 /// <param name="width">The width of the rectangle.</param>
 /// <param name="height">The height of the rectangle.</param>
 public void DisplayRectangle(Color outlineColor, uint thicknessOutline, Color fillColor, uint x, uint y, uint width, uint height)
 {
     DisplayRectangle(outlineColor, thicknessOutline, x, y, width, height, 0, 0, fillColor, 0, 0, fillColor, 0, 0, Bitmap.OpacityOpaque);
 }
Example #10
0
                /// <summary>
                /// Displays the specified text within the specified rectangular region.
                /// </summary>
                /// <param name="text">The text to display.</param>
                /// <param name="x">The X coordinate of the rectangular region.</param>
                /// <param name="y">The Y coordinate of the rectangular region.</param>
                /// <param name="width">The width of the rectangular region.</param>
                /// <param name="height">The height of the rectangular region.</param>
                /// <param name="color">The text color.</param>
                /// <param name="font">The text font.</param>
                /// <param name="textAlignment">A value from the <see cref="TextAlign"/> enumeration that specifies how to align the text within the rectangular region.</param>
                /// <param name="wordWrap">A value from the <see cref="WordWrap"/> enumeration that specifies how to wrap the text within the rectangular region.</param>
                /// <param name="trimming">A value from the <see cref="Trimming"/> enumeration that specifies how to trim excess text.</param>
                /// <param name="scaleTextToFit">A value from the <see cref="ScaleText"/> enumeration that specifies how the text should be scaled.</param>
                public void DisplayTextInRectangle(string text, int x, int y, int width, int height,
                    Color color, Font font, TextAlign textAlignment, WordWrap wordWrap, Trimming trimming, ScaleText scaleTextToFit)
                {
                    uint dtFlags = Bitmap.DT_None;

                    switch (textAlignment)
                    {
                        case TextAlign.Center:
                            dtFlags |= Bitmap.DT_AlignmentCenter;
                            break;
                        case TextAlign.Left:
                            dtFlags |= Bitmap.DT_AlignmentLeft;
                            break;
                        case TextAlign.Right:
                            dtFlags |= Bitmap.DT_AlignmentRight;
                            break;
                        default:
                            break;
                    }

                    switch (trimming)
                    {
                        case Trimming.CharacterEllipsis:
                            dtFlags |= Bitmap.DT_TrimmingCharacterEllipsis;
                            break;
                        case Trimming.WordEllipsis:
                            dtFlags |= Bitmap.DT_TrimmingWordEllipsis;
                            break;
                        default:
                            break;
                    }


                    if (wordWrap == WordWrap.Wrap)
                        dtFlags |= Bitmap.DT_WordWrap;

                    if (scaleTextToFit == ScaleText.None)
                        dtFlags |= Bitmap.DT_IgnoreHeight;

                    _screen.DrawTextInRect(text, x, y, width, height, dtFlags, color, font);

                    if (_autoRedraw)
                    {
                        if (_redrawAll)
                        {
                            _displayModule.Paint(_screen, 0, 0, _width, _height);
                            _redrawAll = false;
                        }
                        else
                        {
                            int right, bottom;
                            font.ComputeTextInRect(text, out right, out bottom, 0, 0, width, height, dtFlags);

                            right += x;
                            bottom += y;

                            if (right >= _width) right = _width - 1;
                            if (bottom >= _height) bottom = _height - 1;

                            if (x < 0) x = 0;
                            if (y < 0) y = 0;

                            if (right >= 0 && bottom >= 0 && x < _width && y < _height)
                                _displayModule.Paint(_screen, x, y, right - x + 1, bottom - y + 1);
                        }
                    }
                }
Example #11
0
 /// <summary>
 /// Displays a rectangle.
 /// </summary>
 /// <param name="outlineColor">The color for the outline of the rectangle.</param>
 /// <param name="thicknessOutline">The thickness of the outline.</param>
 /// <param name="fillColor">The color to fill the rectangle with.</param>
 /// <param name="x">The X coordinate for the top left corner of the rectangle.</param>
 /// <param name="y">The Y coordinate for the top left corner of the rectangle.</param>
 /// <param name="width">The width of the rectangle.</param>
 /// <param name="height">The height of the rectangle.</param>
 /// <param name="opacity">The opacity of the rectangle, 0 (transparent)..256 (opaque).</param>
 public void DisplayRectangle(Color outlineColor, int thicknessOutline, Color fillColor, int x, int y, int width, int height, ushort opacity)
 {
     DisplayRectangle(outlineColor, thicknessOutline, x, y, width, height, 0, 0, fillColor, 0, 0, fillColor, 0, 0, opacity);
 }
Example #12
0
                /// <summary>
                /// Displays an ellipse.
                /// </summary>
                /// <param name="outlineColor">The color of the ellipse outline.</param>
                /// <param name="x">The X coordinate of the center of the ellipse.</param>
                /// <param name="y">The Y coordinate of the center of the ellipse.</param>
                /// <param name="xRadius">The radius value for Y.</param>
                /// <param name="yRadius">The radius value for X.</param>
                public void DisplayEllipse(Color outlineColor, uint x, uint y, uint xRadius, uint yRadius)
                {
                    _display.DrawEllipse(outlineColor, (int)x, (int)y, (int)xRadius, (int)yRadius);

                    if (AutoRedraw) Redraw();
                }
Example #13
0
 /// <summary>
 /// Displays the specified text within the specified rectangular region.
 /// </summary>
 /// <param name="text">The text to display.</param>
 /// <param name="x">The X coordinate of the rectangular region.</param>
 /// <param name="y">The Y coordinate of the rectangular region.</param>
 /// <param name="width">The width of the rectangular region.</param>
 /// <param name="height">The height of the rectangular region.</param>
 /// <param name="color">The text color.</param>
 /// <param name="font">The text font.</param>
 /// <param name="textAlignment">A value from the <see cref="TextAlign"/> enumeration that specifies how to align the text within the rectangular region.</param>
 public void DisplayTextInRectangle(string text, uint x, uint y, uint width, uint height, Color color, Font font, TextAlign textAlignment)
 {
     DisplayTextInRectangle(text, x, y, width, height, color, font, textAlignment, WordWrap.None, Trimming.WordEllipsis, ScaleText.None);
 }
Example #14
0
                internal SimpleGraphicsInterface(DisplayModule displayModule)
                {
                    _displayModule = displayModule;
                    _backgroundColor = Color.Black;
                    _autoRedraw = true;

                    _screen = _displayModule._drawingContext.Bitmap;
                    _width = _screen.Width;
                    _height = _screen.Height;

                    Clear();
                }
Example #15
0
                /// <summary>
                /// Sets a specified pixel to the specified color.
                /// </summary>
                /// <param name="color">The color to set the pixel to.</param>
                /// <param name="x">The X coordinate of the pixel.</param>
                /// <param name="y">The Y coordinate of the pixel.</param>
                public void SetPixel(Color color, int x, int y)
                {
                    _screen.SetPixel(x, y, color);

                    if (_autoRedraw)
                    {
                        if (_redrawAll)
                        {
                            _displayModule.Paint(_screen, 0, 0, _width, _height);
                            _redrawAll = false;
                        }
                        else
                        {
                            if (x >= 0 && x < _width && y >= 0 && y < _height)
                                _displayModule.Paint(_screen, x, y, 1, 1);
                        }
                    }
                }
Example #16
0
 /// <summary>
 /// Displays an ellipse.
 /// </summary>
 /// <param name="outlineColor">The color of the ellipse outline.</param>
 /// <param name="thicknessOutline">The thickness of the outline.</param>
 /// <param name="fillColor">The color of the ellipse fill.</param>
 /// <param name="x">The X coordinate of the center of the ellipse.</param>
 /// <param name="y">The Y coordinate of the center of the ellipse.</param>
 /// <param name="xRadius">The radius value for Y.</param>
 /// <param name="yRadius">The radius value for X.</param>
 /// <param name="opacity">The opacity of the ellipse, 0 (transparent)..256 (opaque).</param>
 public void DisplayEllipse(Color outlineColor, int thicknessOutline, Color fillColor, int x, int y, int xRadius, int yRadius, ushort opacity)
 {
     DisplayEllipse(outlineColor, thicknessOutline, x, y, xRadius, yRadius, fillColor, 0, 0, fillColor, 0, 0, opacity);
 }
Example #17
0
 /// <summary>
 /// Displays an ellipse.
 /// </summary>
 /// <param name="outlineColor">The color of the ellipse outline.</param>
 /// <param name="thicknessOutline">The thickness of the outline.</param>
 /// <param name="fillColor">The color of the ellipse fill.</param>
 /// <param name="x">The X coordinate of the center of the ellipse.</param>
 /// <param name="y">The Y coordinate of the center of the ellipse.</param>
 /// <param name="xRadius">The radius value for Y.</param>
 /// <param name="yRadius">The radius value for X.</param>
 public void DisplayEllipse(Color outlineColor, int thicknessOutline, Color fillColor, int x, int y, int xRadius, int yRadius)
 {
     DisplayEllipse(outlineColor, thicknessOutline, x, y, xRadius, yRadius, fillColor, 0, 0, fillColor, 0, 0, Bitmap.OpacityOpaque);
 }
Example #18
0
                /// <summary>
                /// Displays an ellipse.
                /// </summary>
                /// <param name="outlineColor">The color of the ellipse outline.</param>
                /// <param name="thicknessOutline">The thickness of the outline.</param>
                /// <param name="x">The X coordinate of the center of the ellipse.</param>
                /// <param name="y">The Y coordinate of the center of the ellipse.</param>
                /// <param name="xRadius">The radius value for Y.</param>
                /// <param name="yRadius">The radius value for X.</param>
                /// <param name="colorGradientStart">The color to begin the background gradient.</param>
                /// <param name="xGradientStart">The X coordinate to begin the background gradient.</param>
                /// <param name="yGradientStart">The Y coordinate to begin the background gradient.</param>
                /// <param name="colorGradientEnd">The color to end the background gradient.</param>
                /// <param name="xGradientEnd">The X coordinate to end the background gradient.</param>
                /// <param name="yGradientEnd">The Y coordinate to end the background gradient.</param>
                /// <param name="opacity">The opacity of the ellipse, 0 (transparent)..256 (opaque).</param>
                public void DisplayEllipse(Color outlineColor, int thicknessOutline, int x, int y, int xRadius, int yRadius,
                            Color colorGradientStart, int xGradientStart, int yGradientStart,
                            Color colorGradientEnd, int xGradientEnd, int yGradientEnd, ushort opacity)
                {
                    _screen.DrawEllipse(outlineColor, thicknessOutline, x, y, xRadius, yRadius,
                        colorGradientStart, xGradientStart, yGradientStart, colorGradientEnd, xGradientEnd, yGradientEnd, opacity);

                    if (_autoRedraw)
                    {
                        if (_redrawAll)
                        {
                            _displayModule.Paint(_screen, 0, 0, _width, _height);
                            _redrawAll = false;
                        }
                        else
                        {
                            int left = x - xRadius;
                            int top = y - yRadius;
                            int right = x + xRadius;
                            int bottom = y + yRadius;

                            if (thicknessOutline > 1)
                            {
                                left -= thicknessOutline;
                                top -= thicknessOutline;
                                right += thicknessOutline - 1;
                                bottom += thicknessOutline;
                            }

                            if (left < 0) left = 0;
                            if (top < 0) top = 0;
                            if (right >= _width) right = _width - 1;
                            if (bottom >= _height) bottom = _height - 1;

                            if (right >= 0 && bottom >= 0 && left < _width && top < _height)
                                _displayModule.Paint(_screen, left, top, right - left + 1, bottom - top + 1);
                        }
                    }
                }
Example #19
0
                /// <summary>
                /// Displays the specified text.
                /// </summary>
                /// <param name="text">The text to display.</param>
                /// <param name="font">The font to use for the text display.</param>
                /// <param name="color">The color of the text.</param>
                /// <param name="x">The X coordinate to begin the text display.</param>
                /// <param name="y">The Y coordinate to begin the text display.</param>
                /// <remarks>
                /// This method displays text at the specified screen location. 
                /// If the text is too long for the display, it will be clipped.
                /// </remarks>
                public void DisplayText(string text, Font font, Color color, uint x, uint y)
                {
                    _display.DrawText(text, font, color, (int)x, (int)y);

                    if (AutoRedraw) Redraw();
                }
Example #20
0
 /// <summary>
 /// Displays a rectangle.
 /// </summary>
 /// <param name="outlineColor">The color for the outline of the rectangle.</param>
 /// <param name="thicknessOutline">The thickness of the outline.</param>
 /// <param name="fillColor">The color to fill the rectangle with.</param>
 /// <param name="x">The X coordinate for the top left corner of the rectangle.</param>
 /// <param name="y">The Y coordinate for the top left corner of the rectangle.</param>
 /// <param name="width">The width of the rectangle.</param>
 /// <param name="height">The height of the rectangle.</param>
 public void DisplayRectangle(Color outlineColor, uint thicknessOutline, Color fillColor, uint x, uint y, uint width, uint height)
 {
     DisplayRectangle(outlineColor, thicknessOutline, x, y, width, height, 0, 0, fillColor, 0, 0, fillColor, 0, 0, Bitmap.OpacityOpaque);
 }
Example #21
0
                /// <summary>
                /// Displays the specified text within the specified rectangular region.
                /// </summary>
                /// <param name="text">The text to display.</param>
                /// <param name="x">The X coordinate of the rectangular region.</param>
                /// <param name="y">The Y coordinate of the rectangular region.</param>
                /// <param name="width">The width of the rectangular region.</param>
                /// <param name="height">The height of the rectangular region.</param>
                /// <param name="color">The text color.</param>
                /// <param name="font">The text font.</param>
                /// <param name="textAlignment">A value from the <see cref="TextAlign"/> enumeration that specifies how to align the text within the rectangular region.</param>
                /// <param name="wordWrap">A value from the <see cref="WordWrap"/> enumeration that specifies how to wrap the text within the rectangular region.</param>
                /// <param name="trimming">A value from the <see cref="Trimming"/> enumeration that specifies how to trim excess text.</param>
                /// <param name="scaleTextToFit">A value from the <see cref="ScaleText"/> enumeration that specifies how the text should be scaled.</param>
                public void DisplayTextInRectangle(string text, uint x, uint y, uint width, uint height,
                    Color color, Font font, TextAlign textAlignment, WordWrap wordWrap, Trimming trimming, ScaleText scaleTextToFit)
                {
                    uint dtFlags = Bitmap.DT_None;

                    switch (textAlignment)
                    {
                        case TextAlign.Center:
                            dtFlags |= Bitmap.DT_AlignmentCenter;
                            break;
                        case TextAlign.Left:
                            dtFlags |= Bitmap.DT_AlignmentLeft;
                            break;
                        case TextAlign.Right:
                            dtFlags |= Bitmap.DT_AlignmentRight;
                            break;
                        default:
                            break;
                    }

                    switch (trimming)
                    {
                        case Trimming.CharacterEllipsis:
                            dtFlags |= Bitmap.DT_TrimmingCharacterEllipsis;
                            break;
                        case Trimming.WordEllipsis:
                            dtFlags |= Bitmap.DT_TrimmingWordEllipsis;
                            break;
                        default:
                            break;
                    }


                    if (wordWrap == WordWrap.Wrap)
                        dtFlags |= Bitmap.DT_WordWrap;

                    if (scaleTextToFit == ScaleText.None)
                        dtFlags |= Bitmap.DT_IgnoreHeight;

                    _display.DrawTextInRect(text, (int)x, (int)y, (int)width, (int)height, dtFlags, color, font);

                    if (AutoRedraw) Redraw();
                }
Example #22
0
                /// <summary>
                /// Displays a line.
                /// </summary>
                /// <param name="color">The color of the line.</param>
                /// <param name="thickness">The thickness of the line.</param>
                /// <param name="x0">The X coordinate of the starting point of the line.</param>
                /// <param name="y0">The Y coordinate of the starting point of the line.</param>
                /// <param name="x1">The X coordinate of the ending point of the line.</param>
                /// <param name="y1">The Y coordinate of the ending point of the line.</param>
                public void DisplayLine(Color color, int thickness, int x0, int y0, int x1, int y1)
                {
                    _display.DrawLine(color, thickness, x0, y0, x1, y1);

                    if (AutoRedraw) Redraw();
                }
Example #23
0
 /// <summary>
 /// Displays the specified text within the specified rectangular region.
 /// </summary>
 /// <param name="text">The text to display.</param>
 /// <param name="x">The X coordinate of the rectangular region.</param>
 /// <param name="y">The Y coordinate of the rectangular region.</param>
 /// <param name="width">The width of the rectangular region.</param>
 /// <param name="height">The height of the rectangular region.</param>
 /// <param name="color">The text color.</param>
 /// <param name="font">The text font.</param>
 public void DisplayTextInRectangle(string text, uint x, uint y, uint width, uint height, Color color, Font font)
 {
     DisplayTextInRectangle(text, x, y, width, height, color, font, TextAlign.Left);
 }
Example #24
0
                /// <summary>
                /// Displays the specified text.
                /// </summary>
                /// <param name="text">The text to display.</param>
                /// <param name="font">The font to use for the text display.</param>
                /// <param name="color">The color of the text.</param>
                /// <param name="x">The X coordinate to begin the text display.</param>
                /// <param name="y">The Y coordinate to begin the text display.</param>
                /// <remarks>
                /// This method displays text at the specified screen location. 
                /// If the text is too long for the display, it will be clipped.
                /// </remarks>
                public void DisplayText(string text, Font font, Color color, int x, int y)
                {
                    _screen.DrawText(text, font, color, x, y);

                    if (_autoRedraw)
                    {
                        if (_redrawAll)
                        {
                            _displayModule.Paint(_screen, 0, 0, _width, _height);
                            _redrawAll = false;
                        }
                        else
                        {
                            int right, bottom;
                            font.ComputeExtent(text, out right, out bottom);

                            right += x;
                            bottom += y;

                            if (right >= _width) right = _width - 1;
                            if (bottom >= _height) bottom = _height - 1;

                            if (x < 0) x = 0;
                            if (y < 0) y = 0;

                            if (right >= 0 && bottom >= 0 && x < _width && y < _height)
                                _displayModule.Paint(_screen, x, y, right - x + 1, bottom - y + 1);
                        }
                    }
                }
Example #25
0
                /// <summary>
                /// Displays a rectangle.
                /// </summary>
                /// <param name="outlineColor">The color for the outline of the rectangle.</param>
                /// <param name="thicknessOutline">The thickness of the outline.</param>
                /// <param name="x">The X coordinate for the top left corner of the rectangle.</param>
                /// <param name="y">The Y coordinate for the top left corner of the rectangle.</param>
                /// <param name="width">The width of the rectangle.</param>
                /// <param name="height">The height of the rectangle.</param>
                /// <param name="xCornerRadius">The X dimension corner radius, or zero for none.</param>
                /// <param name="yCornerRadius">The Y dimension corner radius, or zero for none.</param>
                /// <param name="colorGradientStart">The color to begin the background gradient.</param>
                /// <param name="xGradientStart">The X coordinate to begin the background gradient.</param>
                /// <param name="yGradientStart">The Y coordinate to begin the background gradient.</param>
                /// <param name="colorGradientEnd">The color to end the background gradient.</param>
                /// <param name="xGradientEnd">The X coordinate to end the background gradient.</param>
                /// <param name="yGradientEnd">The Y coordinate to end the background gradient.</param>
                /// <param name="opacity">The opacity of the rectangle, 0 (transparent)..256 (opaque).</param>
                public void DisplayRectangle(Color outlineColor, uint thicknessOutline, uint x, uint y, uint width, uint height,
                    uint xCornerRadius, uint yCornerRadius, Color colorGradientStart, uint xGradientStart, uint yGradientStart,
                    Color colorGradientEnd, uint xGradientEnd, uint yGradientEnd, ushort opacity)
                {
                    _display.DrawRectangle(outlineColor, (int)thicknessOutline, (int)x, (int)y, (int)width, (int)height, (int)xCornerRadius, (int)yCornerRadius,
                        colorGradientStart, (int)xGradientStart, (int)yGradientStart, colorGradientEnd, (int)xGradientEnd, (int)yGradientEnd, opacity);

                    if (AutoRedraw) Redraw();
                }
 /// <summary>
 /// Displays the specified text within the specified rectangular region.
 /// </summary>
 /// <param name="text">The text to display.</param>
 /// <param name="x">The X coordinate of the rectangular region.</param>
 /// <param name="y">The Y coordinate of the rectangular region.</param>
 /// <param name="width">The width of the rectangular region.</param>
 /// <param name="height">The height of the rectangular region.</param>
 /// <param name="color">The text color.</param>
 /// <param name="font">The text font.</param>
 /// <param name="textAlignment">A value from the <see cref="TextAlign"/> enumeration that specifies how to align the text within the rectangular region.</param>
 public void DisplayTextInRectangle(string text, uint x, uint y, uint width, uint height, Color color, Font font, TextAlign textAlignment)
 {
     DisplayTextInRectangle(text, x, y, width, height, color, font, textAlignment, WordWrap.None, Trimming.WordEllipsis, ScaleText.None);
 }
Example #27
0
 /// <summary>
 /// Displays a rectangle.
 /// </summary>
 /// <param name="outlineColor">The color for the outline of the rectangle.</param>
 /// <param name="thicknessOutline">The thickness of the outline.</param>
 /// <param name="fillColor">The color to fill the rectangle with.</param>
 /// <param name="x">The X coordinate for the top left corner of the rectangle.</param>
 /// <param name="y">The Y coordinate for the top left corner of the rectangle.</param>
 /// <param name="width">The width of the rectangle.</param>
 /// <param name="height">The height of the rectangle.</param>
 /// <param name="cornerRadius">The corner radius to be applied in both the X and Y dimensions.</param>
 /// <param name="opacity">The opacity of the rectangle, 0 (transparent)..256 (opaque).</param>
 public void DisplayRectangle(Color outlineColor, uint thicknessOutline, Color fillColor, uint x, uint y, uint width, uint height, uint cornerRadius, ushort opacity)
 {
     DisplayRectangle(outlineColor, thicknessOutline, x, y, width, height, cornerRadius, cornerRadius, fillColor, 0, 0, fillColor, 0, 0, opacity);
 }
 /// <summary>
 /// Displays the specified text within the specified rectangular region.
 /// </summary>
 /// <param name="text">The text to display.</param>
 /// <param name="x">The X coordinate of the rectangular region.</param>
 /// <param name="y">The Y coordinate of the rectangular region.</param>
 /// <param name="width">The width of the rectangular region.</param>
 /// <param name="height">The height of the rectangular region.</param>
 /// <param name="color">The text color.</param>
 /// <param name="font">The text font.</param>
 public void DisplayTextInRectangle(string text, uint x, uint y, uint width, uint height, Color color, Font font)
 {
     DisplayTextInRectangle(text, x, y, width, height, color, font, TextAlign.Left);
 }
Example #29
0
 /// <summary>
 /// Sets a specified pixel to the specified color.
 /// </summary>
 /// <param name="color">The color to set the pixel to.</param>
 /// <param name="x">The X coordinate of the pixel.</param>
 /// <param name="y">The Y coordinate of the pixel.</param>
 public void SetPixel(Color color, uint x, uint y)
 {
     _display.SetPixel((int)x, (int)y, color);
     if (AutoRedraw) Redraw();
 }
Example #30
0
                /// <summary>
                /// Displays a rectangle.
                /// </summary>
                /// <param name="outlineColor">The color for the outline of the rectangle.</param>
                /// <param name="thicknessOutline">The thickness of the outline.</param>
                /// <param name="x">The X coordinate for the top left corner of the rectangle.</param>
                /// <param name="y">The Y coordinate for the top left corner of the rectangle.</param>
                /// <param name="width">The width of the rectangle.</param>
                /// <param name="height">The height of the rectangle.</param>
                /// <param name="xCornerRadius">The X dimension corner radius, or zero for none.</param>
                /// <param name="yCornerRadius">The Y dimension corner radius, or zero for none.</param>
                /// <param name="colorGradientStart">The color to begin the background gradient.</param>
                /// <param name="xGradientStart">The X coordinate to begin the background gradient.</param>
                /// <param name="yGradientStart">The Y coordinate to begin the background gradient.</param>
                /// <param name="colorGradientEnd">The color to end the background gradient.</param>
                /// <param name="xGradientEnd">The X coordinate to end the background gradient.</param>
                /// <param name="yGradientEnd">The Y coordinate to end the background gradient.</param>
                /// <param name="opacity">The opacity of the rectangle, 0 (transparent)..256 (opaque).</param>
                public void DisplayRectangle(Color outlineColor, int thicknessOutline, int x, int y, int width, int height,
                    int xCornerRadius, int yCornerRadius, Color colorGradientStart, int xGradientStart, int yGradientStart,
                    Color colorGradientEnd, int xGradientEnd, int yGradientEnd, ushort opacity)
                {
                    _screen.DrawRectangle(outlineColor, thicknessOutline, x, y, width, height, xCornerRadius, yCornerRadius,
                        colorGradientStart, xGradientStart, yGradientStart, colorGradientEnd, xGradientEnd, yGradientEnd, opacity);

                    if (_autoRedraw)
                    {
                        if (_redrawAll)
                        {
                            _displayModule.Paint(_screen, 0, 0, _width, _height);
                            _redrawAll = false;
                        }
                        else
                        {
                            int right = x + width - 1;
                            int bottom = y + height - 1;

                            if (thicknessOutline > 1)
                            {
                                int offset = thicknessOutline / 2;
                                x -= offset;
                                y -= offset;
                                right += offset;
                                bottom += offset;
                            }

                            if (right >= _width) right = _width - 1;
                            if (bottom >= _height) bottom = _height - 1;

                            if (x < 0) x = 0;
                            if (y < 0) y = 0;

                            if (right >= 0 && bottom >= 0 && x < _width && y < _height)
                                _displayModule.Paint(_screen, x, y, right - x + 1, bottom - y + 1);
                        }
                    }
                }