private void InitializeComponents() { const int FORM_WIDTH = 400; const int FORM_HEIGHT = 400; propertyGrid = new PropertyGrid(); okButton = new Button(); cancelButton = new Button(); propertyGrid.SuspendLayout(); okButton.SuspendLayout(); cancelButton.SuspendLayout(); propertyGrid.Location = new Point(5, 5); propertyGrid.Size = new Size(FORM_WIDTH-20, FORM_HEIGHT-80); propertyGrid.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom; propertyGrid.ToolbarVisible = false; okButton.Location = new Point(FORM_WIDTH-75*2-40, FORM_HEIGHT-60); okButton.Size = new Size(75, 23); okButton.Text = "OK"; okButton.FlatStyle = FlatStyle.Flat; okButton.Anchor = AnchorStyles.Right | AnchorStyles.Bottom; okButton.Click += delegate { this.DialogResult = DialogResult.OK; this.Close(); }; cancelButton.Location = new Point(FORM_WIDTH-75-20, FORM_HEIGHT-60); cancelButton.Size = new Size(75, 23); cancelButton.Text = "Cancel"; cancelButton.FlatStyle = FlatStyle.Flat; cancelButton.Anchor = AnchorStyles.Right | AnchorStyles.Bottom; cancelButton.Click += delegate { this.DialogResult = DialogResult.Cancel; this.Close(); }; this.Size = new Size(FORM_WIDTH, FORM_HEIGHT); this.FormBorderStyle = FormBorderStyle.SizableToolWindow; this.Text = "Settings"; this.Controls.AddRange(new Control[]{ propertyGrid, okButton, cancelButton }); propertyGrid.ResumeLayout(false); okButton.ResumeLayout(false); cancelButton.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); }
private void InitializeComponents() { nameLabel = new Label(); pathLabel = new Label(); nameTextBox = new TextBox(); pathTextBox = new TextBox(); okButton = new Button(); cancelButton = new Button(); this.SuspendLayout(); nameLabel.SuspendLayout(); pathLabel.SuspendLayout(); nameTextBox.SuspendLayout(); pathTextBox.SuspendLayout(); okButton.SuspendLayout(); cancelButton.SuspendLayout(); nameLabel.Text = "Name"; nameLabel.AutoSize = true; nameLabel.Location = new Point(3, 3); pathLabel.Text = "Path"; pathLabel.AutoSize = true; pathLabel.Location = new Point(3, 30); nameTextBox.Size = new Size(250, 19); nameTextBox.Location = new Point(40, 2); nameTextBox.BorderStyle = BorderStyle.FixedSingle; pathTextBox.Size = new Size(250, 19); pathTextBox.Location = new Point(40, 29); pathTextBox.BorderStyle = BorderStyle.FixedSingle; okButton.Text = "OK"; okButton.Size = new Size(75, 23); okButton.Location = new Point((300-75)/2, 60); okButton.FlatStyle = FlatStyle.Flat; okButton.Click += delegate { this.DialogResult = DialogResult.OK; this.Close(); }; cancelButton.Text = "Cancel"; cancelButton.Size = new Size(75, 23); cancelButton.Location = new Point(215, 60); cancelButton.FlatStyle = FlatStyle.Flat; cancelButton.Click += delegate { this.DialogResult = DialogResult.Cancel; this.Close(); }; this.Size = new Size(300, 120); this.FormBorderStyle = FormBorderStyle.FixedSingle; this.Text = "Jump target"; this.Controls.AddRange(new Control[]{ nameLabel, pathLabel, nameTextBox, pathTextBox, okButton, cancelButton }); nameLabel.ResumeLayout(false); pathLabel.ResumeLayout(false); nameTextBox.ResumeLayout(false); pathTextBox.ResumeLayout(false); okButton.ResumeLayout(false); cancelButton.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); }
private void SetLinkedButtonsImage(Button localButton, Bitmap image) { localButton.SuspendLayout(); localButton.Image = image; localButton.ResumeLayout(); if(_chordFormButton != null) { _chordFormButton.SuspendLayout(); _chordFormButton.Image = image; _chordFormButton.ResumeLayout(); } }
public static Button MenuButton(IXsdPart part, ToolTip tooltip = null) { try { if (String.IsNullOrWhiteSpace(part.Name)) { throw new ArgumentNullException(); } var button = new Button(); button.SuspendLayout(); //button.AutoSize = true; button.BackColor = System.Drawing.Color.FromArgb(234, 234, 234); button.FlatAppearance.BorderSize = 0; button.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; button.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; button.FlatStyle = System.Windows.Forms.FlatStyle.Flat; button.Font = Methods.BaseFont; button.UseVisualStyleBackColor = false; button.Size = new System.Drawing.Size(152, 23); button.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0); button.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; button.Name = "b" + part.Name; button.Text = part.Name; button.Tag = part; if (tooltip != null) { tooltip.SetToolTip(button, part.Documentation); } button.Click += new System.EventHandler(Methods.MenuButton_Click); button.MouseEnter += new System.EventHandler(Methods.MenuButton_MouseEnter); button.MouseLeave += new System.EventHandler(Methods.MenuButton_MouseLeave); button.ResumeLayout(); return button; } catch (Exception ex) { return null; } }
private void DrawForegroundFromButton(PaintEventArgs pevent) { if (imageButton == null) { imageButton = new System.Windows.Forms.Button(); imageButton.Parent = new TransparentControl(); imageButton.SuspendLayout(); imageButton.BackColor = Color.Transparent; imageButton.FlatAppearance.BorderSize = 0; imageButton.FlatStyle = FlatStyle.Flat; } else { imageButton.SuspendLayout(); } imageButton.AutoEllipsis = AutoEllipsis; if (Enabled) { imageButton.ForeColor = ForeColor; } else { imageButton.ForeColor = Color.FromArgb((3 * ForeColor.R + _backColor.R) >> 2, (3 * ForeColor.G + _backColor.G) >> 2, (3 * ForeColor.B + _backColor.B) >> 2); } imageButton.Font = Font; imageButton.RightToLeft = RightToLeft; if (imageButton.Image != Image && imageButton.Image != null) { imageButton.Image.Dispose(); } if (Image != null) { imageButton.Image = Image; if (!Enabled) { Size size = Image.Size; float[][] newColorMatrix = new float[5][]; newColorMatrix[0] = new float[] { 0.2125f, 0.2125f, 0.2125f, 0f, 0f }; newColorMatrix[1] = new float[] { 0.2577f, 0.2577f, 0.2577f, 0f, 0f }; newColorMatrix[2] = new float[] { 0.0361f, 0.0361f, 0.0361f, 0f, 0f }; float[] arr = new float[5]; arr[3] = 1f; newColorMatrix[3] = arr; newColorMatrix[4] = new float[] { 0.38f, 0.38f, 0.38f, 0f, 1f }; System.Drawing.Imaging.ColorMatrix matrix = new System.Drawing.Imaging.ColorMatrix(newColorMatrix); System.Drawing.Imaging.ImageAttributes disabledImageAttr = new System.Drawing.Imaging.ImageAttributes(); disabledImageAttr.ClearColorKey(); disabledImageAttr.SetColorMatrix(matrix); imageButton.Image = new Bitmap(Image.Width, Image.Height); using (Graphics gr = Graphics.FromImage(imageButton.Image)) { gr.DrawImage(Image, new Rectangle(0, 0, size.Width, size.Height), 0, 0, size.Width, size.Height, GraphicsUnit.Pixel, disabledImageAttr); } } } imageButton.ImageAlign = ImageAlign; imageButton.ImageIndex = ImageIndex; imageButton.ImageKey = ImageKey; imageButton.ImageList = ImageList; imageButton.Padding = Padding; imageButton.Size = Size; imageButton.Text = Text; imageButton.TextAlign = TextAlign; imageButton.TextImageRelation = TextImageRelation; imageButton.UseCompatibleTextRendering = UseCompatibleTextRendering; imageButton.UseMnemonic = UseMnemonic; imageButton.ResumeLayout(); InvokePaint(imageButton, pevent); }
/// <summary> /// force means ignore any cache and require the user to enter a password /// </summary> /// <param name="prompt"></param> /// <param name="force"></param> /// <returns></returns> public static string Password(string prompt, bool requireEntry) { string passwordFileName; if (!string.IsNullOrWhiteSpace(prompt)) { if (ProcessFunctions.KeplerProcess != null) { passwordFileName = SwishFunctions.GeneratePasswordFileName(prompt, ProcessFunctions.KeplerProcess); passwordFileName = Path.Combine(Path.GetTempPath(), passwordFileName); if (!requireEntry && FileFunctions.FileExists(passwordFileName)) { string _encodedPassword = File.ReadAllText(passwordFileName); string _password = SwishFunctions.DecodePassword(_encodedPassword, ProcessFunctions.KeplerProcess); return _password; } } else { passwordFileName = string.Empty; } } else { prompt = "Please enter password"; passwordFileName = string.Empty; } string password; using (MaskedTextBox textBox = new MaskedTextBox()) using (Panel panel = new Panel()) using (Button buton = new Button()) using (Form form = new Form()) { textBox.SuspendLayout(); buton.SuspendLayout(); panel.SuspendLayout(); form.SuspendLayout(); textBox.UseSystemPasswordChar = true; textBox.Multiline = true; textBox.SelectionStart = 0; textBox.SelectionLength = 0; textBox.Size = new Size(300, textBox.Height); textBox.Dock = DockStyle.Top; textBox.Font = new Font(textBox.Font, FontStyle.Bold); textBox.TabIndex = 0; buton.Click += new EventHandler(buton_Click); buton.Dock = DockStyle.Left; buton.Text = "Ok"; buton.Size = new Size(75, 23); buton.TabIndex = 0; panel.Height = 23; panel.Controls.Add(buton); panel.Dock = DockStyle.Fill; panel.TabIndex = 1; form.ControlBox = false; form.Text = prompt; form.ClientSize = new Size(300, 43); form.Controls.Add(panel); form.Controls.Add(textBox); form.AcceptButton = buton; textBox.ResumeLayout(); buton.ResumeLayout(); panel.ResumeLayout(); form.ResumeLayout(); textBox.Focus(); form.ShowDialog(); password = textBox.Text; } if (string.IsNullOrWhiteSpace(password)) { return string.Empty; } if (string.IsNullOrWhiteSpace(passwordFileName)) { return password; } string encodedPassword = SwishFunctions.EncodePassword(password, ProcessFunctions.KeplerProcess); if (File.Exists(passwordFileName)) { FileFunctions.DeleteFile(passwordFileName, null); } File.WriteAllText(passwordFileName, encodedPassword); return password; }
public override Control MakeTallyRow(Control container, SubPop subPop) { Button tallyButton = new Button(); tallyButton.SuspendLayout(); tallyButton.Text = subPop.TDV.Species; tallyButton.Click += new EventHandler(base.OnSpeciesButtonClick); tallyButton.Tag = subPop; tallyButton.Parent = container; tallyButton.Dock = DockStyle.Top; tallyButton.ResumeLayout(false); return tallyButton; }