private void editToolStripMenuItem_Click(object sender, EventArgs e) { menuStrip1.BackColor = Color.LightGreen; if (ctrls != null) { ctrls.BeingModified = true; db.SaveChanges(); } this.Text += " - Editing"; editToolStripMenuItem.Enabled = false; addNewToolStripMenuItem.Enabled = true; if (!string.IsNullOrWhiteSpace(controlsInfoStr)) { ControlMoverOrResizer.SetSizeAndPositionOfControlsFromString(this, controlsInfoStr); } foreach (Control ctrl in Controls) { if (ctrl.GetType() == typeof(TextBox) || ctrl.GetType() == typeof(Button)) { ControlMoverOrResizer.Init(ctrl); } } controlsInfoStr = ControlMoverOrResizer.GetSizeAndPositionOfControlsToString(this); }
private void buttonToolStripMenuItem_Click(object sender, EventArgs e) { String newCtrl = getNextCtrlName("button"); addCtrl(newCtrl); ControlMoverOrResizer.Init(Controls[newCtrl]); }
private void resetToolStripMenuItem_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(controlsInfoStr)) { ControlMoverOrResizer.SetSizeAndPositionOfControlsFromString(this, controlsInfoStr); resetControls(); } }
private void resetControls() { editToolStripMenuItem.Enabled = true; Text = formTitle; addNewToolStripMenuItem.Enabled = false; Invalidate(); menuStrip1.BackColor = Color.Transparent; ControlMoverOrResizer.Stop( ); }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { controlsInfoStr = ControlMoverOrResizer.GetSizeAndPositionOfControlsToString(this); ctrls.Controls1 = controlsInfoStr; ctrls.BeingModified = false; db.SaveChanges(); resetControls(); }
// adding controls t othe form. TextBox and Button ctrls are avaialble private void addCtrl(String ctrlName, int posX = 100, int posY = 100, int width = 175, int height = 30) { dynamic ctrl = null; if (ctrlName.ToLower().StartsWith("textbox")) { ctrl = new TextBox(); ctrl.Multiline = true; } if (ctrlName.ToLower().StartsWith("button")) { ctrl = new Button(); } ctrl.Name = ctrlName; ctrl.Location = new Point(posX, posY); ctrl.Size = new Size(width, height); ctrl.Text = ctrl.Name; Controls.Add(ctrl); controlsInfoStr = ControlMoverOrResizer.GetSizeAndPositionOfControlsToString(this); }