/// <summary>
        /// Renders a MenuItem.
        /// </summary>
        protected virtual void RenderItem(MenuDropDown control, MenuItem item, PaintEventArgs e)
        {
            // Background
            var background_color = item.Hovered || item.IsDropDownOpened ? Theme.ItemHighlightColor : Theme.LightTextColor;

            e.Canvas.FillRectangle(item.Bounds, background_color);

            // Image
            if (item.Image != null)
            {
                var image_size   = e.LogicalToDeviceUnits(16);
                var image_bounds = DrawingExtensions.CenterSquare(item.Bounds, image_size);
                var image_rect   = new Rectangle(item.Bounds.Left + e.LogicalToDeviceUnits(6), image_bounds.Top, image_size, image_size);
                e.Canvas.DrawBitmap(item.Image, image_rect, !item.Enabled);
            }

            // Text
            var font_color = item.Enabled ? Theme.PrimaryTextColor : Theme.DisabledTextColor;
            var font_size  = e.LogicalToDeviceUnits(Theme.FontSize);
            var bounds     = item.Bounds;

            bounds.X += e.LogicalToDeviceUnits(28);
            e.Canvas.DrawText(item.Text, Theme.UIFont, font_size, bounds, font_color, ContentAlignment.MiddleLeft);

            // Dropdown Arrow
            if (item.HasItems)
            {
                var arrow_bounds = DrawingExtensions.CenterSquare(item.Bounds, 16);
                var arrow_area   = new Rectangle(item.Bounds.Right - e.LogicalToDeviceUnits(16) - 4, arrow_bounds.Top, 16, 16);
                ControlPaint.DrawArrowGlyph(e, arrow_area, font_color, ArrowDirection.Right);
            }
        }
Esempio n. 2
0
        /// <inheritdoc/>
        protected override void Render(ComboBox control, PaintEventArgs e)
        {
            var text_area = GetTextArea(control, e);
            var unit_3    = e.LogicalToDeviceUnits(3);

            if (control.Selected && control.ShowFocusCues)
            {
                var focus_bounds = new Rectangle(text_area.Left - unit_3, text_area.Top, text_area.Width + unit_3, text_area.Height);
                e.Canvas.DrawFocusRectangle(focus_bounds, unit_3);
            }

            // Draw the text of the selected item
            if (control.Items.SelectedItem != null)
            {
                e.Canvas.DrawText(control.Items.SelectedItem.ToString() !, text_area, control, ContentAlignment.MiddleLeft, maxLines: 1);
            }

            // Draw the drop down glyph
            var button_bounds = GetDropDownButtonArea(control, e);

            ControlPaint.DrawArrowGlyph(e, button_bounds, control.Enabled ? Theme.PrimaryTextColor : Theme.DisabledTextColor, ArrowDirection.Down);
        }
Esempio n. 3
0
        /// <summary>
        /// Renders a TreeViewItem.
        /// </summary>
        protected virtual void RenderItem(TreeView control, TreeViewItem item, PaintEventArgs e)
        {
            var is_selected      = item == control.SelectedItem;
            var background_color = is_selected ? Theme.ItemHighlightColor : Theme.LightNeutralGray;
            var foreground_color = control.Enabled ? Theme.PrimaryTextColor : Theme.DisabledTextColor;

            e.Canvas.FillRectangle(item.Bounds, background_color);

            if (is_selected && control.Focused && control.ShowFocusCues)
            {
                e.Canvas.DrawFocusRectangle(item.Bounds, e.LogicalToDeviceUnits(1));
            }

            if (control.ShowDropdownGlyph == true)
            {
                var glyph_bounds = GetGlyphBounds(control, item);

                if (GetShouldDrawDropdownGlyph(control, item))
                {
                    ControlPaint.DrawArrowGlyph(e, glyph_bounds, foreground_color, item.Expanded ? ArrowDirection.Down : ArrowDirection.Right);
                }
            }

            if (control.ShowItemImages == true && item.Image != null)
            {
                var image_bounds = GetImageBounds(control, item, e);

                e.Canvas.DrawBitmap(item.Image !, image_bounds, !control.Enabled);
            }

            if (string.IsNullOrWhiteSpace(item.Text))
            {
                return;
            }

            var text_bounds = GetTextBounds(control, item, e);

            e.Canvas.DrawText(item.Text.Trim(), Theme.UIFont, e.LogicalToDeviceUnits(Theme.FontSize), text_bounds, foreground_color, ContentAlignment.MiddleLeft, maxLines: 1);
        }
Esempio n. 4
0
        /// <inheritdoc/>
        protected override void Render(ScrollBar control, PaintEventArgs e)
        {
            var top_arrow_area = GetDecrementArrowBounds(control);

            top_arrow_area.Width  -= 1;
            top_arrow_area.Height -= 1;

            var bottom_arrow_area = GetIncrementArrowBounds(control);

            bottom_arrow_area.Width  -= 1;
            bottom_arrow_area.Height -= 1;

            // Top Arrow
            e.Canvas.FillRectangle(top_arrow_area, SKColors.White);
            e.Canvas.DrawRectangle(top_arrow_area, Theme.BorderGray);
            ControlPaint.DrawArrowGlyph(e, top_arrow_area, Theme.BorderGray, GetDecrementArrowDirection(control));

            // Bottom Arrow
            e.Canvas.FillRectangle(bottom_arrow_area, SKColors.White);
            e.Canvas.DrawRectangle(bottom_arrow_area, Theme.BorderGray);
            ControlPaint.DrawArrowGlyph(e, bottom_arrow_area, Theme.BorderGray, GetIncrementArrowDirection(control));

            if (!control.Enabled)
            {
                return;
            }

            // Grip
            var thumb_bounds = GetThumbDragBounds(control);

            if (thumb_bounds.Width > 0 && thumb_bounds.Height > 0)
            {
                e.Canvas.FillRectangle(thumb_bounds, SKColors.White);
                e.Canvas.DrawRectangle(thumb_bounds, Theme.BorderGray);
            }
        }