Exemplo n.º 1
0
        private void OnSectionsListBoxDrawItem(object sender, DrawItemEventArgs e)
        {
            SettingsDialogSection section = this.sectionsListBox.Items[e.Index] as SettingsDialogSection;
            int x = UIUtil.ScaleWidth(4);

            using (IDrawingContext context = DrawingContextUtil.FromGraphics(e.Graphics, e.Bounds, false, FactorySource.PerThread))
            {
                HighlightState disabled;
                context.Clear(new ColorRgba128Float?(this.BackColor));
                if (e.State.HasFlag(DrawItemState.Disabled) || e.State.HasFlag(DrawItemState.Grayed))
                {
                    disabled = HighlightState.Disabled;
                }
                else if (e.State.HasFlag(DrawItemState.Selected))
                {
                    disabled = HighlightState.Checked;
                }
                else if (e.State.HasFlag(DrawItemState.HotLight) || (e.Index == this.hotTrackIndex))
                {
                    disabled = HighlightState.Hover;
                }
                else
                {
                    disabled = HighlightState.Default;
                }
                RectInt32 bounds = e.Bounds.ToRectInt32();
                bounds.Inflate(-1, -1);
                this.selectionHighlightRenderer.HighlightState = disabled;
                this.selectionHighlightRenderer.RenderBackground(context, bounds);
                SizeInt32 num4 = UIUtil.ScaleSize(section.DeviceIcon.PixelSize);
                RectInt32 num5 = new RectInt32(x, e.Bounds.Top + ((e.Bounds.Height - num4.Height) / 2), num4.Width, num4.Height);
                context.DrawBitmap(section.DeviceIcon, new RectDouble?(num5), 1.0, BitmapInterpolationMode.Linear, null);
                HotkeyRenderMode hotkeyRenderMode       = !e.State.HasFlag(DrawItemState.NoAccelerator) ? HotkeyRenderMode.Show : HotkeyRenderMode.Hide;
                TextLayout       resourceSource         = UIText.CreateLayout(context, section.DisplayName, e.Font, null, hotkeyRenderMode, 65535.0, 65535.0);
                ITextLayout      cachedOrCreateResource = context.GetCachedOrCreateResource <ITextLayout>(resourceSource);
                int   num6 = num5.Right + x;
                float num7 = e.Bounds.Top + ((e.Bounds.Height - cachedOrCreateResource.Metrics.Height) / 2f);
                context.DrawTextLayout((double)num6, (double)num7, resourceSource, this.selectionHighlightRenderer.EmbeddedTextBrush, DrawTextOptions.None);
                if (!e.State.HasFlag(DrawItemState.NoFocusRect))
                {
                    context.DrawFocusRectangle(e.Bounds.ToRectFloat());
                }
            }
        }