using System; using System.Drawing; using System.Globalization; using System.Windows.Forms; using System.Windows.Forms.VisualStyles; using System.Runtime.InteropServices; using System.Drawing.Drawing2D; public class MainForm : Form { public MainForm () { _okButton = new Button (); _okButton.FlatAppearance.BorderSize = 0; _okButton.FlatStyle = FlatStyle.Flat; _okButton.Location = new Point (60, 30); _okButton.Text = "OK"; Controls.Add (_okButton); _cancelButton = new Button (); _cancelButton.FlatAppearance.BorderSize = 0; _cancelButton.FlatStyle = FlatStyle.Flat; _cancelButton.Location = new Point (180, 30); _cancelButton.Text = "Cancel"; Controls.Add (_cancelButton); // // MainForm // ClientSize = new Size (300, 70); Location = new Point (250, 100); StartPosition = FormStartPosition.Manual; Text = "bug #82081"; Load += new EventHandler (MainForm_Load); } [STAThread] static void Main () { Application.Run (new MainForm ()); } void MainForm_Load (object sender, EventArgs e) { Size s = TextRenderer.MeasureText ("ABCDEFGHIJKLMNOPQRSTUVWXYZ", Font); Console.WriteLine ("Measure {0}, {1}", (((float)s.Width / (float)26) / 1.5f).ToString (), s.Height); Font f = Font; Console.WriteLine (f.ToString ()); LOGFONT l = new LOGFONT (); f.ToLogFont (l); Console.WriteLine ("{0}, {1}", l.lfWidth, l.lfHeight); Console.WriteLine (this.AutoScaleBaseSize.ToString ()); InstructionsForm instructionsForm = new InstructionsForm (); instructionsForm.Show (); } [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Auto)] class LOGFONT { public int lfHeight; public int lfWidth; public int lfEscapement; public int lfOrientation; public int lfWeight; public byte lfItalic; public byte lfUnderline; public byte lfStrikeOut; public byte lfCharSet; public byte lfOutPrecision; public byte lfClipPrecision; public byte lfQuality; public byte lfPitchAndFamily; [MarshalAs (UnmanagedType.ByValTStr, SizeConst = 32)] public string lfFaceName; } private Button _okButton; private Button _cancelButton; protected override void OnPaint (PaintEventArgs pevent) { base.OnPaint (pevent); LinearGradientBrush lgb = new LinearGradientBrush (new Rectangle (0, 1, Width, 19), Color.FromArgb (249,252,253), Color.FromArgb (211,219,233), LinearGradientMode.Vertical); pevent.Graphics.FillRectangle (lgb, new Rectangle (0,1,Width,19)); pevent.Graphics.DrawRectangle (new Pen (Color.FromArgb (158,182,206)), new Rectangle (0, 0, ClientSize.Width-1, 20)); } } public class InstructionsForm : Form { public InstructionsForm () { // // _tabControl // _tabControl = new TabControl (); _tabControl.Dock = DockStyle.Fill; Controls.Add (_tabControl); // // _bugDescriptionText1 // _bugDescriptionText1 = new TextBox (); _bugDescriptionText1.Dock = DockStyle.Fill; _bugDescriptionText1.Multiline = true; _bugDescriptionText1.Text = string.Format (CultureInfo.InvariantCulture, "Expected result on start-up:{0}{0}" + "1. The Cancel button is flat.{0}{0}" + "2. The Cancel button has no border.{0}{0}" + "3. The Cancel button highlights on mouseover.", Environment.NewLine); // // _tabPage1 // _tabPage1 = new TabPage (); _tabPage1.Text = "#1"; _tabPage1.Controls.Add (_bugDescriptionText1); _tabControl.Controls.Add (_tabPage1); // // _bugDescriptionText2 // _bugDescriptionText2 = new TextBox (); _bugDescriptionText2.Dock = DockStyle.Fill; _bugDescriptionText2.Multiline = true; _bugDescriptionText2.Text = string.Format (CultureInfo.InvariantCulture, "Steps to execute:{0}{0}" + "1. Click on the OK button.{0}{0}" + "2. Press Tab key.{0}{0}" + "Expected result:{0}{0}" + "1. Focus rectangle is drawn around the Cancel button.{0}{0}" + "2. The Cancel button highlights on mouseover.", Environment.NewLine); // // _tabPage2 // _tabPage2 = new TabPage (); _tabPage2.Text = "#2"; _tabPage2.Controls.Add (_bugDescriptionText2); _tabControl.Controls.Add (_tabPage2); // // InstructionsForm // ClientSize = new Size (360, 190); Location = new Point (600, 100); StartPosition = FormStartPosition.Manual; Text = "Instructions - bug #82081"; } private TextBox _bugDescriptionText1; private TextBox _bugDescriptionText2; private TabControl _tabControl; private TabPage _tabPage1; private TabPage _tabPage2; }