예제 #1
0
        /// <summary>
        /// Creates a new button
        /// </summary>
        /// <param name="name">Name of the button</param>
        /// <param name="text">Content text of the button</param>
        /// <param name="font">Font to render the content text</param>
        /// <param name="x">X position relative to it's parent</param>
        /// <param name="y">Y position relative to it's parent</param>
        /// <param name="showFocusRect">true if the focus rectangle should be visible; false if not</param>
        /// <remarks>
        /// The <see cref="Control.Width"/> and <see cref="Control.Height"/> are calculated automatically to fit the content text.
        /// </remarks>
        public Button(string name, string text, Font font, int x, int y, bool showFocusRect = true) :
            base(name, x, y)
        {
            DefaultColors();

            _text = text;
            _font = font;
            if (!showFocusRect)
            {
                _renderStyle &= ~ButtonRenderStyles.ShowFocusRectangle;
            }
            _state = PressState.Normal;
            SetPadding(new Thickness(11, 6, 11, 7));

            if (!MeasureControl())
            {
                Invalidate();
            }

            /*// Size button
             * size sz = FontManager.ComputeExtentEx(_font, _text);
             * // ReSharper disable DoNotCallOverridableMethodsInConstructor
             * Width = sz.Width + 22;
             * Height = sz.Height + 13;
             * // ReSharper restore DoNotCallOverridableMethodsInConstructor*/
        }
예제 #2
0
        /// <summary>
        /// Creates a new button
        /// </summary>
        /// <param name="name">Name of the button</param>
        /// <param name="text">Content text of the button</param>
        /// <param name="font">Font to render the content text</param>
        /// <param name="x">X position relative to it's parent</param>
        /// <param name="y">Y position relative to it's parent</param>
        /// <param name="width">Width of the button in pixel</param>
        /// <param name="height">Height of the button in pixel</param>
        /// <param name="showFocusRect">true if the focus rectangle should be visible; false if not</param>
        public Button(string name, string text, Font font, int x, int y, int width, int height, bool showFocusRect = true) :
            base(name, x, y, width, height)
        {
            DefaultColors();

            _text = text;
            _font = font;

            if (!showFocusRect)
            {
                _renderStyle &= ~ButtonRenderStyles.ShowFocusRectangle;
            }
            _state = PressState.Normal;

            SetPadding(new Thickness(11, 6, 11, 7));
        }