Esempio n. 1
0
            /// <summary>
            /// Constructs a Button with the specified caption and font, and 
            /// default size.
            /// </summary>
            /// <param name="caption"></param>
            /// <param name="font"></param>
            public Button(string caption, Font font)
            {
                _caption = caption;
                _font = font;
                HorizontalAlignment = HorizontalAlignment.Left;
                VerticalAlignment = VerticalAlignment.Bottom;

                int textWidth;
                int textHeight;
                _font.ComputeExtent(_caption, out textWidth, out textHeight);

                _width = textWidth + _textMarginX * 2;
                _height = textHeight + _textMarginY * 2;
            }
Esempio n. 2
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);
                        }
                    }
                }