Esempio n. 1
0
        protected override void OnDropDown(EventArgs e)
        {
            if (Items.Count <= 1)
            {
                Font selected = this.Font;

                this.BeginUpdate();

                Items.Clear();

                foreach (FontFamily ff in FontFamily.Families)
                {
                    foreach (FontStyle style in Enum.GetValues(typeof(FontStyle)))
                    {
                        if (ff.IsStyleAvailable(style))
                        {
                            Items.Add(new FontAndStyle(ff, style));
                        }
                    }
                }

                SelectedItem = new FontAndStyle(selected.FontFamily, selected.Style);

                this.EndUpdate();
            }

            base.OnDropDown(e);
        }
Esempio n. 2
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Graphics  grfx      = e.Graphics;
            Rectangle rectColor = new Rectangle(e.Bounds.Left, e.Bounds.Top, 2 * e.Bounds.Height, e.Bounds.Height);

            rectColor.Inflate(-1, -1);

            Rectangle rectText = new Rectangle(e.Bounds.Left + 2 * e.Bounds.Height,
                                               e.Bounds.Top,
                                               e.Bounds.Width - 2 * e.Bounds.Height,
                                               e.Bounds.Height);

            if (this.Enabled)
            {
                e.DrawBackground();
            }

            FontAndStyle item           = e.Index >= 0 ? (FontAndStyle)Items[e.Index] : FontAndStyle.Default;
            SolidBrush   foreColorBrush = new SolidBrush(e.ForeColor);

            Font font = new Font(item.Family, Font.Size, item.Style);

            grfx.DrawString("Abc", font, foreColorBrush, rectColor);
            grfx.DrawString(item.ToString(), Font, foreColorBrush, rectText);

            font.Dispose();
        }
Esempio n. 3
0
            public override bool Equals(object obj)
            {
                if (obj == null || !(obj is FontAndStyle))
                {
                    return(false);
                }
                FontAndStyle from = (FontAndStyle)obj;

                return(this.Family == from.Family && this.Style == from.Style);
            }
Esempio n. 4
0
        void SetDataSource(Font selected)
        {
            if (Items.Count > 1)
            {
                Items.Clear();
            }
            if (Items.Count == 0)
            {
                Items.Add(new FontAndStyle(selected.FontFamily, selected.Style));
            }
            else
            {
                Items[0] = new FontAndStyle(selected.FontFamily, selected.Style);
            }

            SelectedIndex = 0;
        }
Esempio n. 5
0
    protected override void OnDropDown(EventArgs e)
    {
      if (Items.Count <= 1)
      {
        Font selected = this.Font;

        this.BeginUpdate();

        Items.Clear();

        foreach (FontFamily ff in FontFamily.Families)
        {
          foreach (FontStyle style in Enum.GetValues(typeof(FontStyle)))
          {
            if (ff.IsStyleAvailable(style))
              Items.Add(new FontAndStyle(ff, style));
          }
        }

        SelectedItem = new FontAndStyle(selected.FontFamily, selected.Style);

        this.EndUpdate();
      }

      base.OnDropDown(e);
    }
Esempio n. 6
0
    void SetDataSource(Font selected)
    {
      if (Items.Count > 1)
        Items.Clear();
      if(Items.Count==0)
        Items.Add(new FontAndStyle(selected.FontFamily,selected.Style));
      else
        Items[0] = new FontAndStyle(selected.FontFamily,selected.Style);

      SelectedIndex = 0;
    }