public DialogNewProject() { //////////////////////////// // Define the design data // //////////////////////////// // Main Window Size thisSize = new Size(500, 300); Size thisPadding = this.Padding.Size; // custom-sized elements Rectangle rectLabelInformation = new Rectangle( 0, 0, thisSize.Width - (this.Padding.Left + this.Padding.Right), 100); // standard-sized elements Point pointTextBoxWidth = new Point(225, 120); Point pointTextBoxHeight = new Point(225, 150); Point pointLabelWidth = new Point(175, 120); Point pointLabelHeight = new Point(175, 150); Point pointButtonConfirm = new Point(150, 220); Point pointButtonCancel = new Point(250, 220); // Text data string stringTitle = "New Project"; string stringTextBoxEmpty = "Type Here"; string stringConfirm = "Confirm"; string stringCancel = "Cancel"; string stringLabelInformation = "Enter the size of the new project in pixels."; string stringLabelWidth = "Width:"; string stringLabelHeight = "Height:"; string stringErrorInvalidInputTitle = "Invalid Input"; string stringErrorInvalidInput = "Error creating new project:"; string stringErrorInvalidInputWidth = "\n - Width must be greater than 0\n and only contain characters 0~9"; string stringErrorInvalidInputHeight = "\n - Height must be greater than 0\n and only contain characters 0~9"; ///////////////////////////// // Set the form values // ///////////////////////////// this.ShowInTaskbar = false; this.Text = stringTitle; this.Width = thisSize.Width; this.Height = thisSize.Height; this.StartPosition = FormStartPosition.CenterParent; this.FormBorderStyle = FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.AutoSizeMode = AutoSizeMode.GrowAndShrink; this.AutoSize = true; //////////////////////////// // Apply data to controls // //////////////////////////// // Number input for width m_textBoxWidth = new TextBoxMarked(stringTextBoxEmpty); m_textBoxWidth.Top = thisPadding.Height + pointTextBoxWidth.Y; m_textBoxWidth.Left = thisPadding.Width + pointTextBoxWidth.X; // Number input for height m_textBoxHeight = new TextBoxMarked(stringTextBoxEmpty); m_textBoxHeight.Top = thisPadding.Height + pointTextBoxHeight.Y; m_textBoxHeight.Left = thisPadding.Width + pointTextBoxHeight.X; // Informational text m_labelInformation = new SkinnedLabel(); m_labelInformation.Top = thisPadding.Height + rectLabelInformation.Y; m_labelInformation.Left = thisPadding.Width + rectLabelInformation.X; m_labelInformation.Width = rectLabelInformation.Width; m_labelInformation.Height = rectLabelInformation.Height; m_labelInformation.Text = stringLabelInformation; // Label for width input box m_labelWidth = new SkinnedLabel(); m_labelWidth.Top = thisPadding.Height + pointLabelWidth.Y; m_labelWidth.Left = thisPadding.Width + pointLabelWidth.X; m_labelWidth.Text = stringLabelWidth; // Label for height input box m_labelHeight = new SkinnedLabel(); m_labelHeight.Top = thisPadding.Height + pointLabelHeight.Y; m_labelHeight.Left = thisPadding.Width + pointLabelHeight.X; m_labelHeight.Text = stringLabelHeight; // Confirm button m_buttonConfirm = new SkinnedButton(); m_buttonConfirm.Top = thisPadding.Height + pointButtonConfirm.Y; m_buttonConfirm.Left = thisPadding.Width + pointButtonConfirm.X; m_buttonConfirm.Text = stringConfirm; m_buttonConfirm.Click += (vvv, bbb) => { bool validWidth = false; bool validHeight = false; if (int.TryParse(m_textBoxWidth.Text, out m_width)) { if (m_width > 0) { validWidth = true; } } if (int.TryParse(m_textBoxHeight.Text, out m_height)) { if (m_height > 0) { validHeight = true; } } if (validWidth == true && validHeight == true) { this.DialogResult = DialogResult.OK; this.Close(); } else { string message = stringErrorInvalidInput; if (validWidth == false) { message += stringErrorInvalidInputWidth; } if (validHeight == false) { message += stringErrorInvalidInputHeight; } DialogMessage error = new DialogMessage(stringErrorInvalidInputTitle, message); error.ShowDialog(); } }; // Cancel Button m_buttonCancel = new SkinnedButton(); m_buttonCancel.Top = thisPadding.Height + pointButtonCancel.Y; m_buttonCancel.Left = thisPadding.Width + pointButtonCancel.X; m_buttonCancel.Text = stringCancel; m_buttonCancel.Click += (vvv, bbb) => { this.DialogResult = DialogResult.No; this.Close(); }; ////////////////////////////////// // Add the controls to the form // ////////////////////////////////// this.Controls.Add(m_labelInformation); this.Controls.Add(m_textBoxWidth); this.Controls.Add(m_textBoxHeight); this.Controls.Add(m_labelWidth); this.Controls.Add(m_labelHeight); this.Controls.Add(m_buttonConfirm); this.Controls.Add(m_buttonCancel); } // END public DialogNewProject()
public DialogNewLayer() { //////////////////////////// // Define the design data // //////////////////////////// // Main Window Size thisSize = new Size(10, 20); Size thisPadding = this.Padding.Size; // custom-sized elements Rectangle rectLabelInformation = new Rectangle( 0, 0, 160, 150); // standard-sized elements Point pointLabelName = new Point(10, 155); Point pointLabelWidth = new Point(10, 180); Point pointLabelHeight = new Point(10, 205); Point pointTextBoxName = new Point(70, 155); Point pointTextBoxWidth = new Point(70, 180); Point pointTextBoxHeight = new Point(70, 205); Point pointButtonConfirm = new Point(80, 300); Point pointButtonCancel = new Point(0, 300); // Text data string stringTitle = "Add Layer"; string stringLabelInformation = "Create a new layer."; string stringLabelName = "Name:"; string stringLabelWidth = "Width:"; string stringLabelHeight = "Height:"; string stringTextBoxEmpty = "Type Here..."; string stringConfirm = "Confirm"; string stringCancel = "Cancel"; string stringErrorInvalidInputTitle = "Invalid Input"; string stringErrorInvalidInput = "Error creating new layer:"; string stringErrorInvalidInputName = "\n - Name is not valid <-- THIS SHOULD NOT APPEAR"; string stringErrorInvalidInputWidth = "\n - Width must be greater than 0\n and only contain characters 0~9"; string stringErrorInvalidInputHeight = "\n - Height must be greater than 0\n and only contain characters 0~9"; //////////////////////////////////////// // create controls and apply the data // //////////////////////////////////////// // Main Window this.ShowInTaskbar = false; this.Text = stringTitle; this.Width = thisSize.Width; this.Height = thisSize.Height; this.StartPosition = FormStartPosition.CenterParent; this.FormBorderStyle = FormBorderStyle.FixedToolWindow; this.ShowInTaskbar = false; this.MaximizeBox = false; this.MinimizeBox = false; this.AutoSizeMode = AutoSizeMode.GrowAndShrink; this.AutoSize = true; // Text input for name m_textBoxName = new TextBoxMarked(stringTextBoxEmpty); m_textBoxName.Top = thisPadding.Height + pointTextBoxName.Y; m_textBoxName.Left = thisPadding.Width + pointTextBoxName.X; // Number input for width m_textBoxWidth = new TextBoxMarked(stringTextBoxEmpty); m_textBoxWidth.Top = thisPadding.Height + pointTextBoxWidth.Y; m_textBoxWidth.Left = thisPadding.Width + pointTextBoxWidth.X; // Number input for height m_textBoxHeight = new TextBoxMarked(stringTextBoxEmpty); m_textBoxHeight.Top = thisPadding.Height + pointTextBoxHeight.Y; m_textBoxHeight.Left = thisPadding.Width + pointTextBoxHeight.X; // Informational text m_labelInformation = new SkinnedLabel(); m_labelInformation.Top = thisPadding.Height + rectLabelInformation.Y; m_labelInformation.Left = thisPadding.Width + rectLabelInformation.X; m_labelInformation.Width = rectLabelInformation.Width; m_labelInformation.Height = rectLabelInformation.Height; m_labelInformation.Text = stringLabelInformation; // Label for name input m_labelName = new SkinnedLabel(); m_labelName.Top = thisPadding.Height + pointLabelName.Y; m_labelName.Left = thisPadding.Width + pointLabelName.X; m_labelName.Text = stringLabelName; m_labelName.Padding = new Padding(2); // Label for width input box m_labelWidth = new SkinnedLabel(); m_labelWidth.Top = thisPadding.Height + pointLabelWidth.Y; m_labelWidth.Left = thisPadding.Width + pointLabelWidth.X; m_labelWidth.Text = stringLabelWidth; m_labelWidth.Padding = new Padding(2); // Label for height input box m_labelHeight = new SkinnedLabel(); m_labelHeight.Top = thisPadding.Height + pointLabelHeight.Y; m_labelHeight.Left = thisPadding.Width + pointLabelHeight.X; m_labelHeight.Text = stringLabelHeight; m_labelHeight.Padding = new Padding(2); // Confirm button m_buttonConfirm = new SkinnedButton(); m_buttonConfirm.Top = thisPadding.Height + pointButtonConfirm.Y; m_buttonConfirm.Left = thisPadding.Width + pointButtonConfirm.X; m_buttonConfirm.Text = stringConfirm; m_buttonConfirm.Click += (vvv, bbb) => { bool validName = false; bool validWidth = false; bool validHeight = false; if (m_textBoxName.Text != null) { m_name = m_textBoxName.Text; validName = true; } if (int.TryParse(m_textBoxWidth.Text, out m_width)) { if (m_width > 0) { validWidth = true; } } if (int.TryParse(m_textBoxHeight.Text, out m_height)) { if (m_height > 0) { validHeight = true; } } if (validName == true && validWidth == true && validHeight == true) { this.DialogResult = DialogResult.OK; this.Close(); } else { string message = stringErrorInvalidInput; if (validName == false) { message += stringErrorInvalidInputName; } if (validWidth == false) { message += stringErrorInvalidInputWidth; } if (validHeight == false) { message += stringErrorInvalidInputHeight; } DialogMessage error = new DialogMessage(stringErrorInvalidInputTitle, message); error.ShowDialog(); } }; // Cancel Button m_buttonCancel = new SkinnedButton(); m_buttonCancel.Top = thisPadding.Height + pointButtonCancel.Y; m_buttonCancel.Left = thisPadding.Width + pointButtonCancel.X; m_buttonCancel.Text = stringCancel; m_buttonCancel.Click += (vvv, bbb) => { this.DialogResult = DialogResult.No; this.Close(); }; ////////////////////////////////// // Add the controls to the form // ////////////////////////////////// this.Controls.Add(m_labelInformation); this.Controls.Add(m_labelName); this.Controls.Add(m_textBoxName); this.Controls.Add(m_labelWidth); this.Controls.Add(m_textBoxWidth); this.Controls.Add(m_labelHeight); this.Controls.Add(m_textBoxHeight); this.Controls.Add(m_buttonCancel); this.Controls.Add(m_buttonConfirm); }
public DialogTestSkin() { this.Size = new Size(400, 310); label = new SkinnedLabel(); menuStrip = new SkinnedMenuStrip(); menuStripItem1 = new SkinnedToolStripItem(); menuStripItem2 = new SkinnedToolStripItem(); menuStripItemItem1 = new SkinnedToolStripItem(); menuStripItemItem2 = new SkinnedToolStripItem(); menuStripItemItem3 = new SkinnedToolStripItem(); menuStripItemItemItem1 = new SkinnedToolStripItem(); menuStripItemItemItem2 = new SkinnedToolStripItem(); menuStripItemItemItem3 = new SkinnedToolStripItem(); panel = new SkinnedPanel(); textBox = new SkinnedTextBox(); textBoxMarked = new TextBoxMarked("Type Text..."); textBoxNumberMarked = new TextBoxMarked("Type Number..."); button = new SkinnedButton(); button2 = new SkinnedButton(); layerList = new LayerList(150, 200); // set values label.Location = new Point(20, 30); menuStrip.Location = new Point(0, 0); panel.Location = new Point(200, 30); textBox.Location = new Point(50, 10); textBoxMarked.Location = new Point(50, 35); textBoxNumberMarked.Location = new Point(50, 60); button.Location = new Point(50, 100); button2.Location = new Point(50, 140); layerList.Location = new Point(20, 60); layerList.LayerItemQuickAdd += (s, e) => { LayerList list = s as LayerList; list.AddItem(null); }; layerList.LayerItemAdd += (s, e) => { string str = textBox.Text; layerList.AddItem(str); }; layerList.LayerItemRemove += (s, e) => { int i = layerList.m_selectedItem; if (i >= 0) { layerList.removeItem(i, e); } else { Console.Write("\nClick this to delete the selected layer."); } }; button.MouseUp += (s, e) => { Console.Write("\nThis button does nothing."); }; button2.MouseUp += (s, e) => { Console.Write("\npoke."); }; layerList.LayerItemsChanged += (s, e) => { int selected = layerList.m_selectedItem; if (selected < 0) { return; } label.Text = selected.ToString(); }; // add controls menuStripItemItem1.DropDownItems.Add(menuStripItemItemItem1); menuStripItemItem1.DropDownItems.Add(menuStripItemItemItem2); menuStripItemItem1.DropDownItems.Add(menuStripItemItemItem3); menuStripItem1.DropDownItems.Add(menuStripItemItem1); menuStripItem1.DropDownItems.Add(menuStripItemItem2); menuStripItem1.DropDownItems.Add(menuStripItemItem3); menuStrip.Items.Add(menuStripItem1); menuStrip.Items.Add(menuStripItem2); panel.Controls.Add(textBox); panel.Controls.Add(textBoxMarked); panel.Controls.Add(textBoxNumberMarked); panel.Controls.Add(button); panel.Controls.Add(button2); this.Controls.Add(label); this.Controls.Add(panel); this.Controls.Add(layerList); this.Controls.Add(menuStrip); }