12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using System;
- using System.Windows.Forms;
- using System.Drawing;
- using System.ComponentModel;
- using FastReport.Utils;
- namespace FastReport.Controls
- {
- internal class ToolStripFontSizeComboBox : ToolStripComboBox
- {
- private float fontSize;
- private bool updating;
- public event EventHandler SizeSelected;
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public float FontSize
- {
- get
- {
- fontSize = Converter.StringToFloat(Text, true);
- UpdateText();
- return fontSize;
- }
- set
- {
- fontSize = value;
- UpdateText();
- }
- }
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public new System.Windows.Forms.ComboBox.ObjectCollection Items
- {
- get { return base.Items; }
- }
- private void ComboBox_DrawItem(object sender, DrawItemEventArgs e)
- {
- e.DrawBackground();
- ComboBox.DrawImageAndText(e, null, Items[e.Index].ToString());
- }
- private void UpdateText()
- {
- updating = true;
- // mono fix
- ComboBox.SelectedIndex = 1;
- Text = Converter.DecreasePrecision(fontSize, 2).ToString();
- updating = false;
- }
- private void OnSizeSelected()
- {
- if (updating)
- return;
- if (SizeSelected != null)
- SizeSelected(this, EventArgs.Empty);
- }
- protected override void OnKeyDown(KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- OnSizeSelected();
- }
- protected override void OnSelectedIndexChanged(EventArgs e)
- {
- OnSizeSelected();
- }
- public ToolStripFontSizeComboBox()
- {
- ComboBox.DrawMode = DrawMode.OwnerDrawFixed;
- ComboBox.ItemHeight = 15;
- ComboBox.DrawItem += ComboBox_DrawItem;
- Size = new Size(50, 25);
- Items.AddRange(new string[] {
- "5", "6", "7", "8", "9", "10", "11", "12", "14", "16", "18", "20",
- "22", "24", "26", "28", "36", "48", "72"});
- }
- }
- }
|