// Remove this main menu from its owning form. internal void RemoveFromForm() { // Cause the form to reposition its controls // now that the client area has changed ownerForm.PerformLayout(); ownerForm = null; }
public static string AskForPassword() { Form dialog = new Form(); dialog.FormBorderStyle = FormBorderStyle.FixedDialog; System.Windows.Forms.Label label1; MarkJohansen.Forms.MSJTextBox msjTextBox1; MarkJohansen.Forms.MSJButton msjButton1; label1 = new System.Windows.Forms.Label(); msjTextBox1 = new MarkJohansen.Forms.MSJTextBox(); msjButton1 = new MarkJohansen.Forms.MSJButton(); dialog.SuspendLayout(); // // label1 // label1.AutoSize = true; label1.Location = new System.Drawing.Point(2, 8); label1.Name = "label1"; label1.Size = new System.Drawing.Size(160, 13); label1.TabIndex = 0; label1.Text = "Please enter your DM password."; // // msjTextBox1 // msjTextBox1.Location = new System.Drawing.Point(5, 25); msjTextBox1.Name = "msjTextBox1"; msjTextBox1.Size = new System.Drawing.Size(285, 20); msjTextBox1.TabIndex = 1; // // msjButton1 // msjButton1.Location = new System.Drawing.Point(5, 51); msjButton1.Name = "msjButton1"; msjButton1.Size = new System.Drawing.Size(285, 28); msjButton1.TabIndex = 2; msjButton1.Text = "OK"; msjButton1.Click += (sender, e) => { dialog.Close(); }; msjButton1.UseVisualStyleBackColor = true; // // Form1 // dialog.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); dialog.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; dialog.ClientSize = new System.Drawing.Size(292, 84); dialog.Controls.Add(msjButton1); dialog.Controls.Add(msjTextBox1); dialog.Controls.Add(label1); dialog.Name = "Form1"; dialog.Text = "Form1"; dialog.ResumeLayout(false); dialog.PerformLayout(); dialog.ShowDialog(); return msjTextBox1.Text; }
// Add this main menu to a form. internal void AddToForm(Form form) { ownerForm = form; if (!ownerForm.IsHandleCreated) { return; } // Cause the form to reposition its controls // now that the client area has changed form.PerformLayout(); }
public static string InputBox(string Prompt = "", string Title = "", string DefaultResponse = "") { var textBox = new TextBox(); textBox.Location = new Point(12, 84); textBox.Size = new Size(329, 19); textBox.Text = DefaultResponse; var okButton = new Button(); okButton.DialogResult = DialogResult.OK; okButton.Location = new Point(266, 9); okButton.Size = new Size(75, 23); okButton.Text = "OK"; okButton.UseVisualStyleBackColor = true; var cancelButton = new Button(); cancelButton.DialogResult = DialogResult.Cancel; cancelButton.Location = new Point(266, 38); cancelButton.Size = new Size(75, 23); cancelButton.Text = "キャンセル"; cancelButton.UseVisualStyleBackColor = true; var label = new Label(); label.AutoSize = true; label.Location = new Point(12, 9); label.Size = new Size(0, 12); label.Text = Prompt; var form = new Form(); form.SuspendLayout(); form.AcceptButton = okButton; form.CancelButton = cancelButton; form.AutoScaleDimensions = new SizeF(6F, 12F); form.AutoScaleMode = AutoScaleMode.Font; form.ClientSize = new Size(353, 120); form.ControlBox = false; form.Controls.Add(textBox); form.Controls.Add(okButton); form.Controls.Add(cancelButton); form.Controls.Add(label); form.FormBorderStyle = FormBorderStyle.FixedDialog; form.ShowInTaskbar = false; form.StartPosition = FormStartPosition.CenterParent; form.ResumeLayout(false); form.PerformLayout(); form.Text = Title; if (form.ShowDialog() == DialogResult.OK) return textBox.Text; else return null; }
public LabelManager(Form p, int m) { maxNumItems = m; items = new List<ResultItem>(0); labels = new Label[maxNumItems]; p.SuspendLayout(); for (int i = 0; i < maxNumItems; i++) { labels[i] = new Label(); labels[i].AutoEllipsis = true; labels[i].BackColor = Color.White; labels[i].Font = new Font("Microsoft Sans Serif", 18F, FontStyle.Regular, GraphicsUnit.Point, 0); labels[i].Location = new Point(100, 110 + (i * 50)); labels[i].Size = new Size(1050, 30); labels[i].TextAlign = ContentAlignment.MiddleCenter; p.Controls.Add(labels[i]); } p.ResumeLayout(); p.PerformLayout(); }
public static int NumericInputBox(string Prompt = "", string Title = "", int DefaultResponse = 0, int MinValue = 0, int MaxValue = 100) { var nud = new NumericUpDown(); nud.Location = new Point(12, 84); nud.Size = new Size(100, 19); nud.Minimum = MinValue; nud.Maximum = MaxValue; nud.Value = DefaultResponse; var okButton = new Button(); okButton.DialogResult = DialogResult.OK; okButton.Location = new Point(266, 9); okButton.Size = new Size(75, 23); okButton.Text = "OK"; okButton.UseVisualStyleBackColor = true; var cancelButton = new Button(); cancelButton.DialogResult = DialogResult.Cancel; cancelButton.Location = new Point(266, 38); cancelButton.Size = new Size(75, 23); cancelButton.Text = "キャンセル"; cancelButton.UseVisualStyleBackColor = true; var label = new Label(); label.AutoSize = true; label.Location = new Point(12, 9); label.Size = new Size(0, 12); label.Text = Prompt; var form = new Form(); form.SuspendLayout(); form.AcceptButton = okButton; form.CancelButton = cancelButton; form.AutoScaleDimensions = new SizeF(6F, 12F); form.AutoScaleMode = AutoScaleMode.Font; form.ClientSize = new Size(353, 120); form.ControlBox = false; form.Controls.Add(nud); form.Controls.Add(okButton); form.Controls.Add(cancelButton); form.Controls.Add(label); form.FormBorderStyle = FormBorderStyle.FixedDialog; form.ShowInTaskbar = false; form.StartPosition = FormStartPosition.CenterParent; form.ResumeLayout(false); form.PerformLayout(); form.Text = Title; if (form.ShowDialog() == DialogResult.OK) return (int)nud.Value; else return 0; }
public void TestPublicMethods () { // Public Methods that force Handle creation: // - CreateGraphics () // - GetChildAtPoint () // - Invoke, BeginInvoke throws InvalidOperationException if Handle has not been created // - PointToClient () // - PointToScreen () // - RectangleToClient () // - RectangleToScreen () // - Select () // - Show (IWin32Window) // Notes: // - CreateControl does NOT force Handle creation! Form c = new Form (); c.BringToFront (); Assert.IsFalse (c.IsHandleCreated, "A1"); c.Contains (new Form ()); Assert.IsFalse (c.IsHandleCreated, "A2"); c.CreateControl (); Assert.IsFalse (c.IsHandleCreated, "A3"); c = new Form (); Graphics g = c.CreateGraphics (); g.Dispose (); Assert.IsTrue (c.IsHandleCreated, "A4"); c.Dispose (); c = new Form (); c.Dispose (); Assert.IsFalse (c.IsHandleCreated, "A5"); c = new Form (); // This is weird, it causes a form to appear that won't go away until you move the mouse over it, // but it doesn't create a handle?? //DragDropEffects d = c.DoDragDrop ("yo", DragDropEffects.None); //Assert.IsFalse (c.IsHandleCreated, "A6"); //Assert.AreEqual (DragDropEffects.None, d, "A6b"); //Bitmap b = new Bitmap (100, 100); //c.DrawToBitmap (b, new Rectangle (0, 0, 100, 100)); //Assert.IsFalse (c.IsHandleCreated, "A7"); //b.Dispose (); c.FindForm (); Assert.IsFalse (c.IsHandleCreated, "A8"); c.Focus (); Assert.IsFalse (c.IsHandleCreated, "A9"); c.GetChildAtPoint (new Point (10, 10)); Assert.IsTrue (c.IsHandleCreated, "A10"); c.Dispose (); c = new Form (); c.GetContainerControl (); Assert.IsFalse (c.IsHandleCreated, "A11"); c.Dispose (); c = new Form (); c.GetNextControl (new Control (), true); Assert.IsFalse (c.IsHandleCreated, "A12"); c.GetPreferredSize (Size.Empty); Assert.IsFalse (c.IsHandleCreated, "A13"); c.Hide (); Assert.IsFalse (c.IsHandleCreated, "A14"); c.Invalidate (); Assert.IsFalse (c.IsHandleCreated, "A15"); //c.Invoke (new InvokeDelegate (InvokeMethod)); //Assert.IsFalse (c.IsHandleCreated, "A16"); c.PerformLayout (); Assert.IsFalse (c.IsHandleCreated, "A17"); c.PointToClient (new Point (100, 100)); Assert.IsTrue (c.IsHandleCreated, "A18"); c.Dispose (); c = new Form (); c.PointToScreen (new Point (100, 100)); Assert.IsTrue (c.IsHandleCreated, "A19"); c.Dispose (); c = new Form (); //c.PreProcessControlMessage ??? //c.PreProcessMessage ??? c.RectangleToClient (new Rectangle (0, 0, 100, 100)); Assert.IsTrue (c.IsHandleCreated, "A20"); c.Dispose (); c = new Form (); c.RectangleToScreen (new Rectangle (0, 0, 100, 100)); Assert.IsTrue (c.IsHandleCreated, "A21"); c.Dispose (); c = new Form (); c.Refresh (); Assert.IsFalse (c.IsHandleCreated, "A22"); c.ResetBackColor (); Assert.IsFalse (c.IsHandleCreated, "A23"); c.ResetBindings (); Assert.IsFalse (c.IsHandleCreated, "A24"); c.ResetCursor (); Assert.IsFalse (c.IsHandleCreated, "A25"); c.ResetFont (); Assert.IsFalse (c.IsHandleCreated, "A26"); c.ResetForeColor (); Assert.IsFalse (c.IsHandleCreated, "A27"); c.ResetImeMode (); Assert.IsFalse (c.IsHandleCreated, "A28"); c.ResetRightToLeft (); Assert.IsFalse (c.IsHandleCreated, "A29"); c.ResetText (); Assert.IsFalse (c.IsHandleCreated, "A30"); c.SuspendLayout (); Assert.IsFalse (c.IsHandleCreated, "A31"); c.ResumeLayout (); Assert.IsFalse (c.IsHandleCreated, "A32"); c.Scale (new SizeF (1.5f, 1.5f)); Assert.IsFalse (c.IsHandleCreated, "A33"); c.Select (); Assert.IsTrue (c.IsHandleCreated, "A34"); c.Dispose (); c = new Form (); c.SelectNextControl (new Control (), true, true, true, true); Assert.IsFalse (c.IsHandleCreated, "A35"); c.SetBounds (0, 0, 100, 100); Assert.IsFalse (c.IsHandleCreated, "A36"); c.Update (); Assert.IsFalse (c.IsHandleCreated, "A37"); // Form c.Activate (); Assert.IsFalse (c.IsHandleCreated, "F1"); c.AddOwnedForm (new Form ()); Assert.IsFalse (c.IsHandleCreated, "F2"); c.Close (); Assert.IsFalse (c.IsHandleCreated, "F3"); c.Hide (); Assert.IsFalse (c.IsHandleCreated, "F4"); c.LayoutMdi (MdiLayout.Cascade); Assert.IsFalse (c.IsHandleCreated, "F5"); #if !MONO c.PerformAutoScale (); Assert.IsFalse (c.IsHandleCreated, "F6"); #endif c.PerformLayout (); Assert.IsFalse (c.IsHandleCreated, "F7"); c.AddOwnedForm (new Form ()); c.RemoveOwnedForm (c.OwnedForms [c.OwnedForms.Length - 1]); Assert.IsFalse (c.IsHandleCreated, "F8"); c.ScrollControlIntoView (null); Assert.IsFalse (c.IsHandleCreated, "F9"); c.SetAutoScrollMargin (7, 13); Assert.IsFalse (c.IsHandleCreated, "F10"); c.SetDesktopBounds (-1, -1, 144, 169); Assert.IsFalse (c.IsHandleCreated, "F11"); c.SetDesktopLocation (7, 13); Assert.IsFalse (c.IsHandleCreated, "F12"); c = new Form (); c.Show (null); Assert.IsTrue (c.IsHandleCreated, "F13"); c.Close (); c = new Form (); //c.ShowDialog () c.ToString (); Assert.IsFalse (c.IsHandleCreated, "F14"); c.Validate (); Assert.IsFalse (c.IsHandleCreated, "F15"); #if !MONO c.ValidateChildren (); Assert.IsFalse (c.IsHandleCreated, "F16"); #endif c.Close (); }
private void helpButton_Click(object sender, EventArgs e) { Form legend = new Form(); legend.Icon = BIDSHelper.Resources.Common.BIDSHelper; legend.Text = "Measure Group Health Check: Legend"; legend.MaximizeBox = false; legend.MinimizeBox = false; TextBox text = new TextBox(); text.Location = new System.Drawing.Point(2, 2); text.Size = new System.Drawing.Size(500, 380); text.Multiline = true; StringBuilder sb = new StringBuilder(); sb.AppendLine("Columns:"); sb.AppendLine("Measure - The measure name"); sb.AppendLine("Aggregate - The aggregate function for that measure"); sb.AppendLine("Total - The aggregated value across all rows"); sb.AppendLine("Min - The minimum value from a single row"); sb.AppendLine("Max - The maximum value from a single row"); sb.AppendLine("Decimals? - Are there any values that have decimals? More than 4 decimals?"); sb.AppendLine("DSV - The datatype for the column in the data source view"); sb.AppendLine("Current - The current measure datatype"); sb.AppendLine("New - The recommended new measure datatype"); sb.AppendLine(); sb.AppendLine("Datatypes:"); foreach (MeasureGroupHealthCheckPlugin.MeasureDataTypeOption dataType in MeasureGroupHealthCheckPlugin.dataTypeOptions) { sb.Append(dataType.dataType.ToString()).Append("/").Append(dataType.type.Name); sb.Append(" (").Append(dataType.displayMin).Append(" to ").Append(dataType.displayMax).Append(") ").AppendLine(dataType.limitations); } text.Text = sb.ToString(); text.ReadOnly = true; text.Select(0, 0); text.BorderStyle = BorderStyle.None; text.PerformLayout(); legend.Controls.Add(text); legend.Width = text.Width + 4; legend.Height = text.Height + 4; legend.MinimumSize = legend.Size; legend.MaximumSize = legend.Size; legend.SizeGripStyle = SizeGripStyle.Hide; legend.ShowInTaskbar = false; legend.StartPosition = FormStartPosition.CenterParent; legend.FormBorderStyle = FormBorderStyle.Fixed3D; legend.PerformLayout(); legend.ShowDialog(); legend.Dispose(); }
public void Bug81936 () { Form f = new Form (); f.ShowInTaskbar = false; TableLayoutPanel tableLayoutPanel1; Label button2; Label button4; tableLayoutPanel1 = new TableLayoutPanel (); button2 = new Label (); button4 = new Label (); button2.Text = "Test1"; button4.Text = "Test2"; button2.Anchor = AnchorStyles.Left; button4.Anchor = AnchorStyles.Left; button2.Height = 14; button4.Height = 14; tableLayoutPanel1.SuspendLayout (); f.SuspendLayout (); tableLayoutPanel1.ColumnCount = 1; tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ()); tableLayoutPanel1.Controls.Add (button2, 0, 0); tableLayoutPanel1.Controls.Add (button4, 0, 1); tableLayoutPanel1.Location = new Point (0, 0); tableLayoutPanel1.RowCount = 2; tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Absolute, 28F)); tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Absolute, 28F)); tableLayoutPanel1.Size = new Size (292, 56); f.ClientSize = new Size (292, 312); f.Controls.Add (tableLayoutPanel1); f.Name = "Form1"; f.Text = "Form1"; tableLayoutPanel1.ResumeLayout (false); tableLayoutPanel1.PerformLayout (); f.ResumeLayout (false); f.PerformLayout (); f.Show (); Assert.AreEqual (new Rectangle (3, 7, 100, 14), button2.Bounds, "A1"); Assert.AreEqual (new Rectangle (3, 35, 100, 14), button4.Bounds, "A2"); f.Dispose (); }
public void AutoSizeTest () { ControlAutoSizeTester c = new ControlAutoSizeTester (new Size (23, 17), AutoSizeMode.GrowAndShrink); Form f = new Form(); f.Size = new Size (200, 200); c.Parent = f; f.Show(); Size s = new Size (42, 42); c.Size = s; Point l = new Point (10, 10); c.Location = l; //Check wether normal size setting is OK Assert.AreEqual (s, c.Size, "#S1"); //Check wether size remains without GetPreferredSize implemented even when AutoSize turned on. c.AutoSize = true; f.PerformLayout(); Assert.AreEqual (s, c.Size, "#S2"); //Simulate a Control implementing GetPreferredSize c.UseCustomPrefSize = true; f.PerformLayout(); //Check wether size shrinks to preferred size Assert.AreEqual (c.CustomPrefSize, c.Size, "#S3"); //Check wether Location stays constant Assert.AreEqual (l, c.Location, "#L1"); //Check wether Dock is respected c.Dock = DockStyle.Bottom; Assert.AreEqual (f.ClientSize.Width, c.Width, "#D1"); //Check wether size shrinks to preferred size again c.Dock = DockStyle.None; Assert.AreEqual (c.CustomPrefSize, c.Size, "#S4"); //Check wether Anchor is respected for adjusting Locatioon c.Anchor = AnchorStyles.Bottom; f.Height += 50; Assert.AreEqual (l.Y + 50, c.Top, "#A1"); //Check wether size is still OK Assert.AreEqual (c.CustomPrefSize, c.Size, "#S5"); //just tidy up c.Anchor = AnchorStyles.Top | AnchorStyles.Left; c.Location = l; //Check wether shrinking to zero is possible c.CustomPrefSize = new Size (0, 0); f.PerformLayout(); Assert.AreEqual (c.CustomPrefSize, c.Size, "#S6"); //Check wether MinimumSize is honored c.MinimumSize = new Size (10, 12); c.CustomPrefSize = new Size (5, 5); f.PerformLayout(); Assert.AreEqual (c.MinimumSize, c.Size, "#S7"); c.MinimumSize = new Size (0, 0); //Check wether MaximumSize is honored c.MaximumSize = new Size (100, 120); c.CustomPrefSize = new Size (500, 500); f.PerformLayout(); Assert.AreEqual (c.MaximumSize, c.Size, "#S8"); //Check wether shrinking does not happen when GrowOnly c.AutoSize = false; s = new Size (23, 23); c.Size = s; c.CustomPrefSize = new Size (5, 5); c.AutoSizeMode = AutoSizeMode.GrowOnly; c.AutoSize = true; f.PerformLayout(); Assert.AreEqual (s, c.Size, "#S9"); f.Close (); }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form form = new Form(); FlowLayoutPanel flowLayoutPanelTop; RadioButton radioButtonText; RadioButton radioButtonNumber; ComboBox comboBox; Panel panelFill; TextBox textBoxInput; TextBox textBoxOutput; StatusStrip statusStrip; ToolStripStatusLabel statusLabel; // 布局 { flowLayoutPanelTop = new FlowLayoutPanel(); radioButtonText = new RadioButton(); radioButtonNumber = new RadioButton(); comboBox = new ComboBox(); panelFill = new Panel(); textBoxInput = new TextBox(); textBoxOutput = new TextBox(); statusStrip = new StatusStrip(); statusLabel = new ToolStripStatusLabel(); flowLayoutPanelTop.SuspendLayout(); panelFill.SuspendLayout(); statusStrip.SuspendLayout(); form.SuspendLayout(); // // flowLayoutPanel1 // flowLayoutPanelTop.Controls.Add(radioButtonText); flowLayoutPanelTop.Controls.Add(radioButtonNumber); flowLayoutPanelTop.Controls.Add(comboBox); flowLayoutPanelTop.Dock = DockStyle.Top; flowLayoutPanelTop.Location = new Point(0, 0); flowLayoutPanelTop.Name = "flowLayoutPanel1"; flowLayoutPanelTop.Size = new Size(363, 30); flowLayoutPanelTop.TabIndex = 0; // // radioButton1 // radioButtonText.AutoSize = true; radioButtonText.Location = new Point(3, 3); radioButtonText.Name = "radioButton1"; radioButtonText.Size = new Size(47, 16); radioButtonText.TabIndex = 0; radioButtonText.TabStop = true; radioButtonText.Text = "文本"; radioButtonText.UseVisualStyleBackColor = true; // // radioButton2 // radioButtonNumber.AutoSize = true; radioButtonNumber.Location = new Point(56, 3); radioButtonNumber.Name = "radioButton2"; radioButtonNumber.Size = new Size(47, 16); radioButtonNumber.TabIndex = 0; radioButtonNumber.TabStop = true; radioButtonNumber.Text = "数字"; radioButtonNumber.UseVisualStyleBackColor = true; // // comboBox1 // comboBox.FormattingEnabled = true; comboBox.Location = new Point(109, 3); comboBox.Name = "comboBox1"; comboBox.Size = new Size(121, 20); comboBox.TabIndex = 1; comboBox.AutoCompleteSource = AutoCompleteSource.ListItems; comboBox.AutoCompleteMode = AutoCompleteMode.Suggest; // // panel1 // panelFill.Controls.Add(textBoxOutput); panelFill.Controls.Add(textBoxInput); panelFill.Dock = DockStyle.Fill; panelFill.Location = new Point(0, 30); panelFill.Name = "panel1"; panelFill.Size = new Size(363, 230); panelFill.TabIndex = 1; // // textBox1 // textBoxInput.Dock = DockStyle.Top; textBoxInput.Location = new Point(0, 0); textBoxInput.Multiline = true; textBoxInput.Name = "textBox1"; textBoxInput.Size = new Size(363, 74); textBoxInput.TabIndex = 0; // // textBox2 // textBoxOutput.Dock = DockStyle.Bottom; textBoxOutput.Location = new Point(0, 80); textBoxOutput.Multiline = true; textBoxOutput.Name = "textBox2"; textBoxOutput.ReadOnly = true; textBoxOutput.Size = new Size(363, 150); textBoxOutput.TabIndex = 1; // // statusStrip1 // statusStrip.Items.AddRange(new ToolStripItem[] {statusLabel}); statusStrip.Location = new Point(0, 238); statusStrip.Name = "statusStrip1"; statusStrip.Size = new Size(363, 22); statusStrip.TabIndex = 2; statusStrip.Text = "statusStrip1"; // // toolStripStatusLabel1 // statusLabel.Name = "toolStripStatusLabel1"; statusLabel.Size = new Size(29, 17); statusLabel.Spring = true; statusLabel.TextAlign = ContentAlignment.MiddleLeft; // // Form1 // form.AutoScaleDimensions = new SizeF(6F, 12F); form.AutoScaleMode = AutoScaleMode.Font; form.ClientSize = new Size(363, 260); form.Controls.Add(statusStrip); form.Controls.Add(panelFill); form.Controls.Add(flowLayoutPanelTop); form.Name = "Form1"; form.Text = "二进制打印"; form.StartPosition = FormStartPosition.CenterScreen; form.ImeMode = ImeMode.On; flowLayoutPanelTop.ResumeLayout(false); flowLayoutPanelTop.PerformLayout(); panelFill.ResumeLayout(false); panelFill.PerformLayout(); statusStrip.ResumeLayout(false); statusStrip.PerformLayout(); form.ResumeLayout(false); form.PerformLayout(); } radioButtonText.Click += (o, e) => { textBoxInput.Text = ""; textBoxOutput.Text = ""; var commonUse = new List<string>(); commonUse.Add(Encoding.Unicode.WebName); commonUse.Add(Encoding.UTF8.WebName); commonUse.Add(Encoding.Default.WebName); commonUse.Add(Encoding.UTF7.WebName); commonUse.Add(Encoding.UTF32.WebName); var fullList = Encoding.GetEncodings().Select(i=>i.GetEncoding().WebName); comboBox.DataSource = commonUse.Concat(fullList.Except(commonUse)).ToArray(); }; radioButtonNumber.Click += (o, e) => { textBoxInput.Text = ""; textBoxOutput.Text = ""; comboBox.DataSource = new string[] { "unsigned oct", "signed oct", "hex", }; }; radioButtonText.PerformClick(); Func<byte[], string> formatBytes = bytes => { if (bytes == null || bytes.Length == 0) return string.Empty; var buf = new StringBuilder(); foreach (byte b in bytes) buf.AppendFormat("{0:x2} ", b); buf.Remove(buf.Length - 1, 1); return buf.ToString(); }; EventHandler intput2output = (o, e) => { textBoxOutput.Text = string.Empty; if (string.IsNullOrEmpty(textBoxInput.Text)) return; if (radioButtonText.Checked) { try { Encoding encoding = Encoding.GetEncoding(comboBox.Text); textBoxOutput.Text = formatBytes(encoding.GetBytes(textBoxInput.Text)); } catch (Exception _e) { statusLabel.Text = _e.Message.Replace("\r\n", "\t"); } } else { try { if (comboBox.Text == "hex") { uint i = uint.Parse(textBoxInput.Text, System.Globalization.NumberStyles.HexNumber); textBoxOutput.Text = formatBytes(ToByteArray(i)); } else if (comboBox.Text == "signed oct") { int i = int.Parse(textBoxInput.Text); textBoxOutput.Text = formatBytes(ToByteArray(i)); } else if (comboBox.Text == "unsigned oct") { uint i = uint.Parse(textBoxInput.Text); textBoxOutput.Text = formatBytes(ToByteArray(i)); } else { statusLabel.Text = "未知的格式。"; } } catch (Exception _e) { statusLabel.Text = _e.Message.Replace("\r\n", "\t"); } } }; textBoxInput.TextChanged += intput2output; comboBox.SelectedValueChanged += intput2output; textBoxOutput.DoubleClick += (o, e) => { if (string.IsNullOrEmpty(textBoxOutput.Text)) return; textBoxOutput.SelectAll(); textBoxOutput.Copy(); statusLabel.Text = "复制到剪贴板。"; }; Timer timerCleanStatus = new Timer(); timerCleanStatus.Interval = 3000; timerCleanStatus.Tick += (o, e) => { statusLabel.Text = ""; }; timerCleanStatus.Start(); Application.Run(form); }
/// <summary> /// executed in a separate thread - uses spare CPU cycles /// </summary> protected void InitGUI() { // Control.CheckForIllegalCrossThreadCalls = false; // create consoles for output/input // output console is one of the first things to create JQuantForms.ConsoleOut consoleOut = new JQuantForms.ConsoleOut(); consoleOut.Dock = DockStyle.Fill; this.consoleOut = consoleOut; consoleIn = new JQuantForms.ConsoleIn(new JQuantForms.ConsoleIn.ProcessCommandDelegate(this.ConsoleInCommandHalder)); consoleIn.Dock = DockStyle.Fill; // Create layout tlp = new TableLayoutPanel(); tlp.Dock = DockStyle.Fill; tlp.ColumnCount = 1; tlp.RowCount = 2; tlp.RowStyles.Add(new System.Windows.Forms.RowStyle (System.Windows.Forms.SizeType.Percent, 80F)); tlp.RowStyles.Add(new System.Windows.Forms.RowStyle (System.Windows.Forms.SizeType.Absolute, 28F)); // add consoles tlp.Controls.Add(consoleOut, 0, 0); tlp.Controls.Add(consoleIn, 0, 1); // i have no idea what this thing does // tlp.ResumeLayout(false); // tlp.PerformLayout(); // create main form mainForm = new Form(); mainForm.Size = new System.Drawing.Size(600, 400); mainForm.SuspendLayout(); // add layout to the main form mainForm.Controls.Add(tlp); mainForm.ResumeLayout(false); mainForm.PerformLayout(); mainForm.Show(); Application.Run(mainForm); }
// Overridden by DXWindow protected virtual void createMenuBar(Form parent) { menuBar = new MenuStrip(); parent.SuspendLayout(); parent.Controls.Add(menuBar); parent.MainMenuStrip = menuBar; parent.ResumeLayout(false); parent.PerformLayout(); }
/* * Popup a webbrowser-window with the Oyatel Connect prompt. * */ public void loginPopup() { _access_token = ""; popup = new Form(); canClosePopup = false; WebBrowser webBrowser = new WebBrowser(); popup.SuspendLayout(); webBrowser.Location = new System.Drawing.Point(0, 0); webBrowser.MinimumSize = new System.Drawing.Size(20, 20); webBrowser.Name = "webBrowser"; webBrowser.Size = new System.Drawing.Size(880, 550); popup.Width = 900; popup.Height = 570; popup.Text = "Oyatel Connect"; popup.Visible = true; popup.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); popup.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; popup.ClientSize = new System.Drawing.Size(880, 550); popup.Controls.Add(webBrowser); popup.Name = "Oyatel.Connect"; popup.Text = "Oyatel Connect"; popup.ResumeLayout(false); popup.PerformLayout(); webBrowser.Visible = true; webBrowser.Navigated += new WebBrowserNavigatedEventHandler(navigated_event); webBrowser.ProgressChanged += new WebBrowserProgressChangedEventHandler(ProgressChanged); webBrowser.Navigate("https://oauth.oyatel.com/oauth/authorize?client_id=" + client_id + "&response_type=token&redirect_uri=" + redirect_uri, false); }
static DialogResult ShowUI(string title, string promptText, string value, bool password = false) { Form form = new Form(); Label label = new Label(); TextBox textBox = new TextBox(); if (password) textBox.UseSystemPasswordChar = true; MyButton buttonOk = new MyButton(); MyButton buttonCancel = new MyButton(); //System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainV2)); //form.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); // Suspend form layout. form.SuspendLayout(); const int yMargin = 10; // // label // var y = 20; label.AutoSize = true; label.Location = new Point(9, y); label.Size = new Size(372, 13); label.Text = promptText; label.MaximumSize = new Size(372, 0); // // textBox // textBox.Size = new Size(372, 20); textBox.Text = value; textBox.TextChanged += textBox_TextChanged; // // buttonOk // buttonOk.Size = new Size(75, 23); buttonOk.Text = "OK"; buttonOk.DialogResult = DialogResult.OK; // // buttonCancel // buttonCancel.Size = new Size(75, 23); buttonCancel.Text = "Cancel"; buttonCancel.DialogResult = DialogResult.Cancel; // // form // form.TopMost = true; form.TopLevel = true; form.Text = title; form.ClientSize = new Size(396, 107); form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel }); form.FormBorderStyle = FormBorderStyle.FixedSingle; form.StartPosition = FormStartPosition.CenterScreen; form.MinimizeBox = false; form.MaximizeBox = false; form.AcceptButton = buttonOk; form.CancelButton = buttonCancel; // Resume form layout form.ResumeLayout(false); form.PerformLayout(); // Adjust the location of textBox, buttonOk, buttonCancel based on the content of the label. y = y + label.Height + yMargin; textBox.Location = new Point(12, y); y = y + textBox.Height + yMargin; buttonOk.Location = new Point(228, y); buttonCancel.Location = new Point(309, y); // Increase the size of the form. form.ClientSize = new Size(396, y + buttonOk.Height + yMargin); if (ApplyTheme != null) ApplyTheme(form); Console.WriteLine("Input Box " + System.Threading.Thread.CurrentThread.Name); Application.DoEvents(); form.ShowDialog(); Console.WriteLine("Input Box 2 " + System.Threading.Thread.CurrentThread.Name); DialogResult dialogResult = form.DialogResult; if (dialogResult == DialogResult.OK) { value = textBox.Text; InputBox.value = value; } form.Dispose(); TextChanged = null; form = null; return dialogResult; }
public void ResumeLayoutEffects () { Form f = new Form (); f.ShowInTaskbar = false; f.ClientSize = new Size (300, 300); Button button1 = new Button (); f.Controls.Add (button1); button1.Anchor = AnchorStyles.Right | AnchorStyles.Bottom; button1.Location = new Point (f.ClientSize.Width - button1.Width, f.ClientSize.Height - button1.Height); f.Show (); Assert.AreEqual (new Point (225, 277), button1.Location, "A1"); f.SuspendLayout (); f.Height += 10; f.ResumeLayout (false); f.PerformLayout (); Assert.AreEqual (new Point (225, 277), button1.Location, "A2"); f.SuspendLayout (); f.Height += 10; f.ResumeLayout (); Assert.AreEqual (new Point (225, 287), button1.Location, "A3"); f.Dispose (); }
public void AnchoredAutoSizedControls_SizeInCorrectDirection () { Form f = new Form (); f.ClientSize = new Size (300, 300); f.ShowInTaskbar = false; Panel p1 = new Panel (); p1.Bounds = new Rectangle (150, 150, 0, 0); p1.Anchor = AnchorStyles.Top | AnchorStyles.Left; p1.AutoSize = true; f.Controls.Add (p1); Panel p2 = new Panel (); p2.Bounds = new Rectangle (150, 150, 0, 0); p2.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; p2.AutoSize = true; f.Controls.Add (p2); Panel p3 = new Panel (); p3.Bounds = new Rectangle (150, 150, 0, 0); p3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right; p3.AutoSize = true; f.Controls.Add (p3); Panel p4 = new Panel (); p4.Bounds = new Rectangle (150, 150, 0, 0); p4.Anchor = AnchorStyles.None; p4.AutoSize = true; f.Controls.Add (p4); f.Show (); // cause the panels to grow p1.Controls.Add (new TextBox ()); p2.Controls.Add (new TextBox ()); p3.Controls.Add (new TextBox ()); p4.Controls.Add (new TextBox ()); f.PerformLayout (); Assert.AreEqual (150, p1.Top, "1"); Assert.AreEqual (150, p1.Left, "2"); Assert.AreEqual (150, p2.Bottom, "3"); Assert.AreEqual (150, p2.Right, "4"); Assert.AreEqual (150, p3.Top, "5"); Assert.AreEqual (150, p3.Left, "6"); Assert.AreEqual (150, p4.Top, "7"); Assert.AreEqual (150, p4.Left, "8"); f.Dispose (); }
public void CategoryEdit(int chosen_category) { #region edit_category_form formEditCategory = new Form(); formEditCategory.Name = "FormEditCategory"; formEditCategory.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; formEditCategory.Text = "Редагувати категорію"; formEditCategory.TopMost = true; formEditCategory.ResumeLayout(false); formEditCategory.PerformLayout(); formEditCategory.AutoScaleDimensions = new SizeF(6F, 13F); formEditCategory.AutoScaleMode = AutoScaleMode.Font; formEditCategory.ClientSize = new Size(384, 284); textBoxEditCategName = new TextBox(); textBoxCategPK = new TextBox(); richTextBoxEditCategInfo = new RichTextBox(); Label label1 = new Label(); Label label2 = new Label(); Label label3 = new Label(); Button buttonAcceptEdit = new Button(); Button buttonCancelEdit = new Button(); // // textBoxEditCategName // textBoxEditCategName.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); textBoxEditCategName.Location = new System.Drawing.Point(165, 52); textBoxEditCategName.Name = "textBoxEditCategName"; textBoxEditCategName.Size = new System.Drawing.Size(206, 26); textBoxEditCategName.TabIndex = 0; // // richTextBoxEditCategInfo // richTextBoxEditCategInfo.Location = new System.Drawing.Point(165, 93); richTextBoxEditCategInfo.Name = "richTextBoxEditCategInfo"; richTextBoxEditCategInfo.Size = new System.Drawing.Size(206, 112); richTextBoxEditCategInfo.TabIndex = 1; richTextBoxEditCategInfo.Text = ""; // // label1 // label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; label1.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); label1.Location = new System.Drawing.Point(12, 52); label1.Name = "label1"; label1.Size = new System.Drawing.Size(135, 29); label1.TabIndex = 2; label1.Text = "Назва категорії:"; label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // label2 // label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; label2.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); label2.Location = new System.Drawing.Point(12, 93); label2.Name = "label2"; label2.Size = new System.Drawing.Size(135, 55); label2.TabIndex = 3; label2.Text = "Інформація про категорію:"; label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // label3 // label3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; label3.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); label3.Location = new System.Drawing.Point(12, 9); label3.Name = "label3"; label3.Size = new System.Drawing.Size(135, 29); label3.TabIndex = 4; label3.Text = "Номер категорії:"; label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // textBoxCategPK // textBoxCategPK.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); textBoxCategPK.Location = new System.Drawing.Point(166, 9); textBoxCategPK.Name = "textBoxCategPK"; textBoxCategPK.ReadOnly = true; textBoxCategPK.Size = new System.Drawing.Size(206, 26); textBoxCategPK.TabIndex = 5; // // buttonAcceptEdit // buttonAcceptEdit.Font = new System.Drawing.Font("Times New Roman", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); buttonAcceptEdit.Location = new System.Drawing.Point(44, 229); buttonAcceptEdit.Name = "buttonAcceptEdit"; buttonAcceptEdit.Size = new System.Drawing.Size(145, 43); buttonAcceptEdit.TabIndex = 6; buttonAcceptEdit.Text = "Затвердити зміни та закрити вікно"; buttonAcceptEdit.UseVisualStyleBackColor = true; buttonAcceptEdit.Click += new System.EventHandler(buttonAcceptEdit_Click); // // buttonCancelEdit // buttonCancelEdit.Font = new System.Drawing.Font("Times New Roman", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); buttonCancelEdit.Location = new System.Drawing.Point(195, 229); buttonCancelEdit.Name = "buttonCancelEdit"; buttonCancelEdit.Size = new System.Drawing.Size(144, 43); buttonCancelEdit.TabIndex = 7; buttonCancelEdit.Text = "Відмінити та закрити вікно"; buttonCancelEdit.UseVisualStyleBackColor = true; buttonCancelEdit.Click += new System.EventHandler(buttonCancelEdit_Click); // // FormEditCategory // formEditCategory.Controls.Add(buttonCancelEdit); formEditCategory.Controls.Add(buttonAcceptEdit); formEditCategory.Controls.Add(textBoxCategPK); formEditCategory.Controls.Add(label3); formEditCategory.Controls.Add(label2); formEditCategory.Controls.Add(label1); formEditCategory.Controls.Add(richTextBoxEditCategInfo); formEditCategory.Controls.Add(textBoxEditCategName); formEditCategory.Show(); #endregion string strCategName, strCategInfo = "1"; textBoxCategPK.Text = Convert.ToString(chosen_category); CategoryShowOneInfo(chosen_category, out strCategName, out strCategInfo); textBoxEditCategName.Text = strCategName; richTextBoxEditCategInfo.Text = strCategInfo; }
public void Bug81843 () { Form f = new Form (); f.ShowInTaskbar = false; TableLayoutPanel tableLayoutPanel1; Button button2; TextBox textBox1; Button button4; tableLayoutPanel1 = new TableLayoutPanel (); button2 = new Button (); button4 = new Button (); textBox1 = new TextBox (); tableLayoutPanel1.SuspendLayout (); f.SuspendLayout (); tableLayoutPanel1.AutoSize = true; tableLayoutPanel1.ColumnCount = 3; tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ()); tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ()); tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ()); tableLayoutPanel1.Controls.Add (button2, 0, 1); tableLayoutPanel1.Controls.Add (button4, 2, 1); tableLayoutPanel1.Controls.Add (textBox1, 1, 0); tableLayoutPanel1.Location = new Point (0, 0); tableLayoutPanel1.RowCount = 2; tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Percent, 50F)); tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Percent, 50F)); tableLayoutPanel1.Size = new Size (292, 287); button2.Size = new Size (75, 23); button4.Size = new Size (75, 23); textBox1.Dock = DockStyle.Fill; textBox1.Location = new Point (84, 3); textBox1.Multiline = true; textBox1.Size = new Size (94, 137); f.ClientSize = new Size (292, 312); f.Controls.Add (tableLayoutPanel1); f.Name = "Form1"; f.Text = "Form1"; tableLayoutPanel1.ResumeLayout (false); tableLayoutPanel1.PerformLayout (); f.ResumeLayout (false); f.PerformLayout (); f.Show (); Assert.AreEqual (new Rectangle (3, 146, 75, 23), button2.Bounds, "A1"); Assert.AreEqual (new Rectangle (184, 146, 75, 23), button4.Bounds, "A2"); Assert.AreEqual (new Rectangle (84, 3, 94, 137), textBox1.Bounds, "A3"); f.Dispose (); }
public ProjectMenuStrip( ApplicationForm applicationForm, System.Windows.Forms.Form form, System.Windows.Forms.MenuStrip menuStrip, string sProjectFileExtension ) { m_form = form; m_sProjectFileExtension = sProjectFileExtension; m_ApplicationForm = applicationForm; this.menuStrip1 = menuStrip; m_form.ResumeLayout(true); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.quitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); // // menuStrip1 // this.menuStrip1.Items.Insert(0, this.fileToolStripMenuItem); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(963, 24); this.menuStrip1.TabIndex = 2; this.menuStrip1.Text = "menuStrip1"; // // fileToolStripMenuItem // this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.newToolStripMenuItem, this.openToolStripMenuItem, this.saveToolStripMenuItem, this.quitToolStripMenuItem}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); this.fileToolStripMenuItem.Text = "&File"; // // newToolStripMenuItem // this.newToolStripMenuItem.Name = "newToolStripMenuItem"; this.newToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.newToolStripMenuItem.Text = "&new"; this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click); // // openToolStripMenuItem // this.openToolStripMenuItem.Name = "openToolStripMenuItem"; this.openToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.openToolStripMenuItem.Text = "&open"; this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click); // // saveToolStripMenuItem // this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; this.saveToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.saveToolStripMenuItem.Text = "&save"; this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); // // quitToolStripMenuItem // this.quitToolStripMenuItem.Name = "quitToolStripMenuItem"; this.quitToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.quitToolStripMenuItem.Text = "&quit"; this.quitToolStripMenuItem.Click += new System.EventHandler(this.quitToolStripMenuItem_Click); m_form.Controls.Add(this.menuStrip1); m_form.MainMenuStrip = this.menuStrip1; this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); m_form.ResumeLayout(false); m_form.PerformLayout(); this.menuStrip1.Show(); }