Пример #1
0
        private void lbxPanes_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lbxPanes.SelectedItem == null)
            {
                return;
            }
            PreferencePaneListItem item = (PreferencePaneListItem)lbxPanes.SelectedItem;

            // Screen size change to accomodate initial IM feature thx to Elmo Clarity 20/12/2010

            if (item.Name.ToLower(CultureInfo.CurrentCulture) == "text")
            {
                this.Height = 460;
            }
            else
            {
                this.Height = 390;
            }

            SelectPreferencePane(item.Name);
        }
Пример #2
0
        private void lbxPanes_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();

            if (e.Index < 0)
            {
                return;
            }

            PreferencePaneListItem itemToDraw = (PreferencePaneListItem)lbxPanes.Items[e.Index];
            Brush textBrush = null;
            Font  textFont  = null;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                textBrush = new SolidBrush(Color.FromKnownColor(KnownColor.HighlightText));
                textFont  = new Font(e.Font, FontStyle.Bold);
            }
            else
            {
                textBrush = new SolidBrush(Color.FromKnownColor(KnownColor.ControlText));
                textFont  = new Font(e.Font, FontStyle.Regular);
            }

            SizeF stringSize = e.Graphics.MeasureString(itemToDraw.Name, textFont);
            float stringX    = e.Bounds.Left + 4 + itemToDraw.Icon.Width;
            float stringY    = e.Bounds.Top + 2 + ((itemToDraw.Icon.Height / 2) - (stringSize.Height / 2));

            e.Graphics.DrawImage(itemToDraw.Icon, e.Bounds.Left + 2, e.Bounds.Top + 2);
            e.Graphics.DrawString(itemToDraw.Name, textFont, textBrush, stringX, stringY);

            e.DrawFocusRectangle();

            textFont.Dispose();
            textBrush.Dispose();
            textFont  = null;
            textBrush = null;
        }