示例#1
0
        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);
        }
示例#2
0
        private void buttonToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String newCtrl = getNextCtrlName("button");

            addCtrl(newCtrl);
            ControlMoverOrResizer.Init(Controls[newCtrl]);
        }
示例#3
0
 private void resetToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(controlsInfoStr))
     {
         ControlMoverOrResizer.SetSizeAndPositionOfControlsFromString(this, controlsInfoStr);
         resetControls();
     }
 }
示例#4
0
        private void resetControls()
        {
            editToolStripMenuItem.Enabled = true;
            Text = formTitle;
            addNewToolStripMenuItem.Enabled = false;
            Invalidate();
            menuStrip1.BackColor = Color.Transparent;

            ControlMoverOrResizer.Stop( );
        }
示例#5
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            controlsInfoStr = ControlMoverOrResizer.GetSizeAndPositionOfControlsToString(this);

            ctrls.Controls1     = controlsInfoStr;
            ctrls.BeingModified = false;
            db.SaveChanges();

            resetControls();
        }
示例#6
0
        // 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);
        }