Author: jpobst
Date: 2006-10-05 10:36:49 -0400 (Thu, 05 Oct 2006)
New Revision: 66290
Modified:
trunk/winforms/toolstrip20/ToolStripDemo.cs
Log:
2006-10-05 Jonathan Pobst <[EMAIL PROTECTED]>
* ToolStripDemo.cs: Add a ToolStripComboBox to the demo.
Modified: trunk/winforms/toolstrip20/ToolStripDemo.cs
===================================================================
--- trunk/winforms/toolstrip20/ToolStripDemo.cs 2006-10-05 14:31:16 UTC (rev
66289)
+++ trunk/winforms/toolstrip20/ToolStripDemo.cs 2006-10-05 14:36:49 UTC (rev
66290)
@@ -2,6 +2,7 @@
using System.Windows.Forms;
using System.Drawing;
using System.IO;
+using System.Drawing.Text;
namespace ToolStripDemo
{
@@ -10,13 +11,16 @@
[STAThread]
static void Main ()
{
+ Application.EnableVisualStyles ();
Application.Run (new ToolStripDemo ());
}
private ToolStrip ts;
- private RichTextBox rtb;
+ private TextBox rtb;
private string image_path;
-
+ private ToolStripComboBox tscb;
+ private ToolStripComboBox font_combo;
+
public ToolStripDemo()
{
this.Text = "ToolStrip Sample";
@@ -24,7 +28,8 @@
image_path = Path.Combine (Path.GetDirectoryName
(Application.ExecutablePath), "images");
- rtb = new RichTextBox ();
+ rtb = new TextBox ();
+ rtb.Multiline = true;
rtb.Dock = DockStyle.Fill;
this.Controls.Add (rtb);
@@ -65,15 +70,62 @@
ts.Items.Add (new ToolStripSeparator ());
- ToolStripLabel tsl = new ToolStripLabel("Button
Style:");
+ ToolStripLabel tsl = new ToolStripLabel ("Font:");
ts.Items.Add (tsl);
+ font_combo = new ToolStripComboBox ();
+ font_combo.DropDownStyle = ComboBoxStyle.DropDownList;
+ font_combo.AutoSize = false;
+ font_combo.Width = 150;
+ InstalledFontCollection ifc = new
InstalledFontCollection ();
+
+ foreach (FontFamily f in ifc.Families) {
+ if (f.IsStyleAvailable (FontStyle.Regular))
+ font_combo.Items.Add (f.Name);
+ }
+
+ font_combo.SelectedIndexChanged += new EventHandler
(font_combo_SelectedIndexChanged);
+ ts.Items.Add (font_combo);
+
+ tscb = new ToolStripComboBox ();
+ tscb.DropDownStyle = ComboBoxStyle.DropDownList;
+ tscb.Items.Add ("6");
+ tscb.Items.Add ("8");
+ tscb.Items.Add ("10");
+ tscb.Items.Add ("12");
+ tscb.Items.Add ("14");
+ tscb.Items.Add ("16");
+ tscb.Items.Add ("18");
+ tscb.SelectedIndexChanged += new EventHandler
(tscb_SelectedIndexChanged);
+ tscb.AutoSize = false;
+ tscb.Width = 45;
+
+ ts.Items.Add (tscb);
+
+ ToolStripLabel tsl2 = new ToolStripLabel("Button
Style:");
+ ts.Items.Add (tsl2);
+
Image image10 = Image.FromFile (Path.Combine
(image_path, "image-x-generic.png"));
ToolStripButton tb10 = new ToolStripButton ("Style",
image10, new EventHandler(Change_Style_Clicked));
tb10.DisplayStyle = ToolStripItemDisplayStyle.Image;
ts.Items.Add (tb10);
+
+ font_combo.SelectedIndex = font_combo.FindStringExact
(rtb.Font.Name);
+ tscb.SelectedIndex = tscb.FindStringExact
(rtb.Font.Size.ToString());
}
+ void font_combo_SelectedIndexChanged (object sender, EventArgs
e)
+ {
+ if (font_combo.SelectedIndex >= 0)
+ rtb.Font = new Font
((string)font_combo.SelectedItem, rtb.Font.Size);
+ }
+
+ void tscb_SelectedIndexChanged (object sender, EventArgs e)
+ {
+ if (tscb.SelectedIndex >= 0)
+ rtb.Font = new Font (rtb.Font.Name,
float.Parse(tscb.SelectedItem.ToString()));
+ }
+
public void New_Document_Clicked (object sender, EventArgs e)
{
rtb.Clear();
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches