Esempio n. 1
0
            protected override void OnPaint(PaintEventArgs e)
            {
                base.OnPaint(e);

                if (IsHovering)
                {
                    e.Canvas.Clear(glyph == TitleBarButtonGlyph.Close ? Theme.FormCloseHighlightColor : Theme.HighlightColor);
                }

                var glyph_bounds = glyph == TitleBarButtonGlyph.Minimize ?
                                   DrawingExtensions.CenterRectangle(DisplayRectangle, e.LogicalToDeviceUnits(new Size(BUTTON_PADDING, 1))) :
                                   DrawingExtensions.CenterSquare(DisplayRectangle, e.LogicalToDeviceUnits(BUTTON_PADDING));

                switch (glyph)
                {
                case TitleBarButtonGlyph.Close:
                    ControlPaint.DrawCloseGlyph(e, glyph_bounds);
                    break;

                case TitleBarButtonGlyph.Minimize:
                    ControlPaint.DrawMinimizeGlyph(e, glyph_bounds);
                    break;

                case TitleBarButtonGlyph.Maximize:
                    ControlPaint.DrawMaximizeGlyph(e, glyph_bounds);
                    break;
                }
            }
Esempio n. 2
0
        /// <inheritdoc/>
        protected override void Render(FormTitleBar control, PaintEventArgs e)
        {
            // Form icon
            if (control.Image != null)
            {
                var icon_glyph_bounds = DrawingExtensions.CenterSquare(GetIconBounds(control), e.LogicalToDeviceUnits(FORM_ICON_SIZE));

                e.Canvas.DrawBitmap(control.Image, icon_glyph_bounds);
            }

            // Form text
            e.Canvas.DrawText(control.Text.Trim(), Theme.UIFont, e.LogicalToDeviceUnits(Theme.FontSize), GetTitleBounds(control), Theme.LightTextColor, ContentAlignment.MiddleCenter);

            // Minimize button
            if (control.AllowMinimize)
            {
                var minimize_button_bounds = GetMinimizeButtonBounds(control);

                if (control.HoverElement == FormTitleBar.FormTitleBarElement.Minimize)
                {
                    e.Canvas.FillRectangle(minimize_button_bounds, Theme.HighlightColor);
                }

                var min_glyph_bounds = DrawingExtensions.CenterRectangle(minimize_button_bounds, e.LogicalToDeviceUnits(new Size(BUTTON_PADDING, 1)));
                ControlPaint.DrawMinimizeGlyph(e, min_glyph_bounds);
            }

            // Maximize button
            if (control.AllowMaximize)
            {
                var maximize_button_bounds = GetMaximizeButtonBounds(control);

                if (control.HoverElement == FormTitleBar.FormTitleBarElement.Maximize)
                {
                    e.Canvas.FillRectangle(maximize_button_bounds, Theme.HighlightColor);
                }

                var max_glyph_bounds = DrawingExtensions.CenterSquare(maximize_button_bounds, e.LogicalToDeviceUnits(BUTTON_PADDING));
                ControlPaint.DrawMaximizeGlyph(e, max_glyph_bounds);
            }

            // Close button
            var close_button_bounds = GetCloseButtonBounds(control);

            if (control.HoverElement == FormTitleBar.FormTitleBarElement.Close)
            {
                e.Canvas.FillRectangle(close_button_bounds, Theme.FormCloseHighlightColor);
            }

            var close_glyph_bounds = DrawingExtensions.CenterSquare(close_button_bounds, e.LogicalToDeviceUnits(BUTTON_PADDING));

            ControlPaint.DrawCloseGlyph(e, close_glyph_bounds);
        }