Click here to Skip to main content
15,897,032 members
Articles / Programming Languages / C#

Moveable Resizable Objects

Rate me:
Please Sign up or sign in to vote.
4.98/5 (59 votes)
9 Oct 2009CPOL198 min read 125.9K   8.7K   178  
Here is a description of an extremely powerful mechanism that makes screen objects moveable and resizable.
namespace Test_MoveGraphLibrary
{
    partial class Form_Calculator
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System .ComponentModel .IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose (bool disposing)
        {
            if (disposing && (components != null))
            {
                components .Dispose ();
            }
            base .Dispose (disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent ()
        {
            this .menuStrip1 = new System .Windows .Forms .MenuStrip ();
            this .miEdit = new System .Windows .Forms .ToolStripMenuItem ();
            this .miView = new System .Windows .Forms .ToolStripMenuItem ();
            this .miDefaultView = new System .Windows .Forms .ToolStripMenuItem ();
            this .miHelp = new System .Windows .Forms .ToolStripMenuItem ();
            this .buttonC = new System .Windows .Forms .Button ();
            this .buttonCE = new System .Windows .Forms .Button ();
            this .buttonBackspace = new System .Windows .Forms .Button ();
            this .buttonEqual = new System .Windows .Forms .Button ();
            this .buttonOpposite = new System .Windows .Forms .Button ();
            this .buttonPercent = new System .Windows .Forms .Button ();
            this .buttonSqrt = new System .Windows .Forms .Button ();
            this .buttonPlus = new System .Windows .Forms .Button ();
            this .buttonMinus = new System .Windows .Forms .Button ();
            this .buttonMultiply = new System .Windows .Forms .Button ();
            this .buttonDivide = new System .Windows .Forms .Button ();
            this .buttonDot = new System .Windows .Forms .Button ();
            this .buttonPlusMinus = new System .Windows .Forms .Button ();
            this .button_9 = new System .Windows .Forms .Button ();
            this .button_8 = new System .Windows .Forms .Button ();
            this .button_7 = new System .Windows .Forms .Button ();
            this .button_6 = new System .Windows .Forms .Button ();
            this .button_5 = new System .Windows .Forms .Button ();
            this .button_4 = new System .Windows .Forms .Button ();
            this .button_3 = new System .Windows .Forms .Button ();
            this .button_2 = new System .Windows .Forms .Button ();
            this .button_1 = new System .Windows .Forms .Button ();
            this .button_0 = new System .Windows .Forms .Button ();
            this .buttonMPlus = new System .Windows .Forms .Button ();
            this .buttonMS = new System .Windows .Forms .Button ();
            this .buttonMR = new System .Windows .Forms .Button ();
            this .buttonMC = new System .Windows .Forms .Button ();
            this .panelM = new System .Windows .Forms .Panel ();
            this .textboxValue = new System .Windows .Forms .TextBox ();
            this .menuStrip1 .SuspendLayout ();
            this .SuspendLayout ();
            // 
            // menuStrip1
            // 
            this .menuStrip1 .Items .AddRange (new System .Windows .Forms .ToolStripItem [] {
            this.miEdit,
            this.miView,
            this.miHelp});
            this .menuStrip1 .Location = new System .Drawing .Point (0, 0);
            this .menuStrip1 .Name = "menuStrip1";
            this .menuStrip1 .Size = new System .Drawing .Size (353, 26);
            this .menuStrip1 .TabIndex = 1;
            this .menuStrip1 .Text = "menuStrip1";
            // 
            // miEdit
            // 
            this .miEdit .Name = "miEdit";
            this .miEdit .Size = new System .Drawing .Size (43, 22);
            this .miEdit .Text = "&Edit";
            // 
            // miView
            // 
            this .miView .DropDownItems .AddRange (new System .Windows .Forms .ToolStripItem [] {
            this.miDefaultView});
            this .miView .Name = "miView";
            this .miView .Size = new System .Drawing .Size (49, 22);
            this .miView .Text = "&View";
            // 
            // miDefaultView
            // 
            this .miDefaultView .Name = "miDefaultView";
            this .miDefaultView .Size = new System .Drawing .Size (152, 22);
            this .miDefaultView .Text = "Default";
            this .miDefaultView .Click += new System .EventHandler (this .Click_miDefaultView);
            // 
            // miHelp
            // 
            this .miHelp .Name = "miHelp";
            this .miHelp .Size = new System .Drawing .Size (48, 22);
            this .miHelp .Text = "&Help";
            this .miHelp .Click += new System .EventHandler (this .Click_miHelp);
            // 
            // buttonC
            // 
            this .buttonC .ForeColor = System .Drawing .Color .Red;
            this .buttonC .Location = new System .Drawing .Point (267, 80);
            this .buttonC .Name = "buttonC";
            this .buttonC .Size = new System .Drawing .Size (75, 36);
            this .buttonC .TabIndex = 58;
            this .buttonC .Text = "C";
            this .buttonC .UseVisualStyleBackColor = true;
            this .buttonC .Click += new System .EventHandler (this .Click_buttonC);
            // 
            // buttonCE
            // 
            this .buttonCE .ForeColor = System .Drawing .Color .Red;
            this .buttonCE .Location = new System .Drawing .Point (186, 80);
            this .buttonCE .Name = "buttonCE";
            this .buttonCE .Size = new System .Drawing .Size (75, 36);
            this .buttonCE .TabIndex = 57;
            this .buttonCE .Text = "CE";
            this .buttonCE .UseVisualStyleBackColor = true;
            this .buttonCE .Click += new System .EventHandler (this .Click_buttonCE);
            // 
            // buttonBackspace
            // 
            this .buttonBackspace .ForeColor = System .Drawing .Color .Red;
            this .buttonBackspace .Location = new System .Drawing .Point (78, 80);
            this .buttonBackspace .Name = "buttonBackspace";
            this .buttonBackspace .Size = new System .Drawing .Size (102, 36);
            this .buttonBackspace .TabIndex = 56;
            this .buttonBackspace .Text = "Backspace";
            this .buttonBackspace .UseVisualStyleBackColor = true;
            this .buttonBackspace .Click += new System .EventHandler (this .Click_buttonBackspace);
            // 
            // buttonEqual
            // 
            this .buttonEqual .ForeColor = System .Drawing .Color .Red;
            this .buttonEqual .Location = new System .Drawing .Point (294, 265);
            this .buttonEqual .Name = "buttonEqual";
            this .buttonEqual .Size = new System .Drawing .Size (48, 36);
            this .buttonEqual .TabIndex = 55;
            this .buttonEqual .Text = "=";
            this .buttonEqual .UseVisualStyleBackColor = true;
            this .buttonEqual .Click += new System .EventHandler (this .Click_buttonEqual);
            // 
            // buttonOpposite
            // 
            this .buttonOpposite .ForeColor = System .Drawing .Color .Blue;
            this .buttonOpposite .Location = new System .Drawing .Point (294, 223);
            this .buttonOpposite .Name = "buttonOpposite";
            this .buttonOpposite .Size = new System .Drawing .Size (48, 36);
            this .buttonOpposite .TabIndex = 54;
            this .buttonOpposite .Text = "1 / x";
            this .buttonOpposite .UseVisualStyleBackColor = true;
            // 
            // buttonPercent
            // 
            this .buttonPercent .ForeColor = System .Drawing .Color .Blue;
            this .buttonPercent .Location = new System .Drawing .Point (294, 181);
            this .buttonPercent .Name = "buttonPercent";
            this .buttonPercent .Size = new System .Drawing .Size (48, 36);
            this .buttonPercent .TabIndex = 53;
            this .buttonPercent .Text = "%";
            this .buttonPercent .UseVisualStyleBackColor = true;
            // 
            // buttonSqrt
            // 
            this .buttonSqrt .ForeColor = System .Drawing .Color .Blue;
            this .buttonSqrt .Location = new System .Drawing .Point (294, 139);
            this .buttonSqrt .Name = "buttonSqrt";
            this .buttonSqrt .Size = new System .Drawing .Size (48, 36);
            this .buttonSqrt .TabIndex = 52;
            this .buttonSqrt .Text = "Sqrt";
            this .buttonSqrt .UseVisualStyleBackColor = true;
            // 
            // buttonPlus
            // 
            this .buttonPlus .ForeColor = System .Drawing .Color .Red;
            this .buttonPlus .Location = new System .Drawing .Point (240, 265);
            this .buttonPlus .Name = "buttonPlus";
            this .buttonPlus .Size = new System .Drawing .Size (48, 36);
            this .buttonPlus .TabIndex = 51;
            this .buttonPlus .Text = "+";
            this .buttonPlus .UseVisualStyleBackColor = true;
            this .buttonPlus .Click += new System .EventHandler (this .Click_operation);
            // 
            // buttonMinus
            // 
            this .buttonMinus .ForeColor = System .Drawing .Color .Red;
            this .buttonMinus .Location = new System .Drawing .Point (240, 223);
            this .buttonMinus .Name = "buttonMinus";
            this .buttonMinus .Size = new System .Drawing .Size (48, 36);
            this .buttonMinus .TabIndex = 50;
            this .buttonMinus .Text = "-";
            this .buttonMinus .UseVisualStyleBackColor = true;
            this .buttonMinus .Click += new System .EventHandler (this .Click_operation);
            // 
            // buttonMultiply
            // 
            this .buttonMultiply .ForeColor = System .Drawing .Color .Red;
            this .buttonMultiply .Location = new System .Drawing .Point (240, 181);
            this .buttonMultiply .Name = "buttonMultiply";
            this .buttonMultiply .Size = new System .Drawing .Size (48, 36);
            this .buttonMultiply .TabIndex = 49;
            this .buttonMultiply .Text = "*";
            this .buttonMultiply .UseVisualStyleBackColor = true;
            this .buttonMultiply .Click += new System .EventHandler (this .Click_operation);
            // 
            // buttonDivide
            // 
            this .buttonDivide .ForeColor = System .Drawing .Color .Red;
            this .buttonDivide .Location = new System .Drawing .Point (240, 139);
            this .buttonDivide .Name = "buttonDivide";
            this .buttonDivide .Size = new System .Drawing .Size (48, 36);
            this .buttonDivide .TabIndex = 48;
            this .buttonDivide .Text = "/";
            this .buttonDivide .UseVisualStyleBackColor = true;
            this .buttonDivide .Click += new System .EventHandler (this .Click_operation);
            // 
            // buttonDot
            // 
            this .buttonDot .Font = new System .Drawing .Font ("Microsoft Sans Serif", 7.8F, System .Drawing .FontStyle .Bold, System .Drawing .GraphicsUnit .Point, ((byte) (0)));
            this .buttonDot .ForeColor = System .Drawing .Color .Blue;
            this .buttonDot .Location = new System .Drawing .Point (186, 265);
            this .buttonDot .Name = "buttonDot";
            this .buttonDot .Size = new System .Drawing .Size (48, 36);
            this .buttonDot .TabIndex = 47;
            this .buttonDot .Text = ".";
            this .buttonDot .UseVisualStyleBackColor = true;
            this .buttonDot .Click += new System .EventHandler (this .Click_buttonDot);
            // 
            // buttonPlusMinus
            // 
            this .buttonPlusMinus .ForeColor = System .Drawing .Color .Blue;
            this .buttonPlusMinus .Location = new System .Drawing .Point (132, 265);
            this .buttonPlusMinus .Name = "buttonPlusMinus";
            this .buttonPlusMinus .Size = new System .Drawing .Size (48, 36);
            this .buttonPlusMinus .TabIndex = 46;
            this .buttonPlusMinus .Text = "+ / -";
            this .buttonPlusMinus .UseVisualStyleBackColor = true;
            // 
            // button_9
            // 
            this .button_9 .ForeColor = System .Drawing .Color .Blue;
            this .button_9 .Location = new System .Drawing .Point (186, 139);
            this .button_9 .Name = "button_9";
            this .button_9 .Size = new System .Drawing .Size (48, 36);
            this .button_9 .TabIndex = 45;
            this .button_9 .Text = "9";
            this .button_9 .UseVisualStyleBackColor = true;
            this .button_9 .Click += new System .EventHandler (this .Click_number);
            // 
            // button_8
            // 
            this .button_8 .ForeColor = System .Drawing .Color .Blue;
            this .button_8 .Location = new System .Drawing .Point (132, 139);
            this .button_8 .Name = "button_8";
            this .button_8 .Size = new System .Drawing .Size (48, 36);
            this .button_8 .TabIndex = 44;
            this .button_8 .Text = "8";
            this .button_8 .UseVisualStyleBackColor = true;
            this .button_8 .Click += new System .EventHandler (this .Click_number);
            // 
            // button_7
            // 
            this .button_7 .ForeColor = System .Drawing .Color .Blue;
            this .button_7 .Location = new System .Drawing .Point (78, 139);
            this .button_7 .Name = "button_7";
            this .button_7 .Size = new System .Drawing .Size (48, 36);
            this .button_7 .TabIndex = 43;
            this .button_7 .Text = "7";
            this .button_7 .UseVisualStyleBackColor = true;
            this .button_7 .Click += new System .EventHandler (this .Click_number);
            // 
            // button_6
            // 
            this .button_6 .ForeColor = System .Drawing .Color .Blue;
            this .button_6 .Location = new System .Drawing .Point (186, 181);
            this .button_6 .Name = "button_6";
            this .button_6 .Size = new System .Drawing .Size (48, 36);
            this .button_6 .TabIndex = 42;
            this .button_6 .Text = "6";
            this .button_6 .UseVisualStyleBackColor = true;
            this .button_6 .Click += new System .EventHandler (this .Click_number);
            // 
            // button_5
            // 
            this .button_5 .ForeColor = System .Drawing .Color .Blue;
            this .button_5 .Location = new System .Drawing .Point (132, 181);
            this .button_5 .Name = "button_5";
            this .button_5 .Size = new System .Drawing .Size (48, 36);
            this .button_5 .TabIndex = 41;
            this .button_5 .Text = "5";
            this .button_5 .UseVisualStyleBackColor = true;
            this .button_5 .Click += new System .EventHandler (this .Click_number);
            // 
            // button_4
            // 
            this .button_4 .ForeColor = System .Drawing .Color .Blue;
            this .button_4 .Location = new System .Drawing .Point (78, 181);
            this .button_4 .Name = "button_4";
            this .button_4 .Size = new System .Drawing .Size (48, 36);
            this .button_4 .TabIndex = 40;
            this .button_4 .Text = "4";
            this .button_4 .UseVisualStyleBackColor = true;
            this .button_4 .Click += new System .EventHandler (this .Click_number);
            // 
            // button_3
            // 
            this .button_3 .ForeColor = System .Drawing .Color .Blue;
            this .button_3 .Location = new System .Drawing .Point (186, 223);
            this .button_3 .Name = "button_3";
            this .button_3 .Size = new System .Drawing .Size (48, 36);
            this .button_3 .TabIndex = 39;
            this .button_3 .Text = "3";
            this .button_3 .UseVisualStyleBackColor = true;
            this .button_3 .Click += new System .EventHandler (this .Click_number);
            // 
            // button_2
            // 
            this .button_2 .ForeColor = System .Drawing .Color .Blue;
            this .button_2 .Location = new System .Drawing .Point (132, 223);
            this .button_2 .Name = "button_2";
            this .button_2 .Size = new System .Drawing .Size (48, 36);
            this .button_2 .TabIndex = 38;
            this .button_2 .Text = "2";
            this .button_2 .UseVisualStyleBackColor = true;
            this .button_2 .Click += new System .EventHandler (this .Click_number);
            // 
            // button_1
            // 
            this .button_1 .ForeColor = System .Drawing .Color .Blue;
            this .button_1 .Location = new System .Drawing .Point (78, 223);
            this .button_1 .Name = "button_1";
            this .button_1 .Size = new System .Drawing .Size (48, 36);
            this .button_1 .TabIndex = 37;
            this .button_1 .Text = "1";
            this .button_1 .UseVisualStyleBackColor = true;
            this .button_1 .Click += new System .EventHandler (this .Click_number);
            // 
            // button_0
            // 
            this .button_0 .ForeColor = System .Drawing .Color .Blue;
            this .button_0 .Location = new System .Drawing .Point (78, 265);
            this .button_0 .Name = "button_0";
            this .button_0 .Size = new System .Drawing .Size (48, 36);
            this .button_0 .TabIndex = 36;
            this .button_0 .Text = "0";
            this .button_0 .UseVisualStyleBackColor = true;
            this .button_0 .Click += new System .EventHandler (this .Click_number);
            // 
            // buttonMPlus
            // 
            this .buttonMPlus .ForeColor = System .Drawing .Color .Red;
            this .buttonMPlus .Location = new System .Drawing .Point (13, 265);
            this .buttonMPlus .Name = "buttonMPlus";
            this .buttonMPlus .Size = new System .Drawing .Size (48, 36);
            this .buttonMPlus .TabIndex = 35;
            this .buttonMPlus .Text = "M+";
            this .buttonMPlus .UseVisualStyleBackColor = true;
            // 
            // buttonMS
            // 
            this .buttonMS .ForeColor = System .Drawing .Color .Red;
            this .buttonMS .Location = new System .Drawing .Point (13, 223);
            this .buttonMS .Name = "buttonMS";
            this .buttonMS .Size = new System .Drawing .Size (48, 36);
            this .buttonMS .TabIndex = 34;
            this .buttonMS .Text = "MS";
            this .buttonMS .UseVisualStyleBackColor = true;
            // 
            // buttonMR
            // 
            this .buttonMR .ForeColor = System .Drawing .Color .Red;
            this .buttonMR .Location = new System .Drawing .Point (13, 181);
            this .buttonMR .Name = "buttonMR";
            this .buttonMR .Size = new System .Drawing .Size (48, 36);
            this .buttonMR .TabIndex = 33;
            this .buttonMR .Text = "MR";
            this .buttonMR .UseVisualStyleBackColor = true;
            // 
            // buttonMC
            // 
            this .buttonMC .ForeColor = System .Drawing .Color .Red;
            this .buttonMC .Location = new System .Drawing .Point (13, 139);
            this .buttonMC .Name = "buttonMC";
            this .buttonMC .Size = new System .Drawing .Size (48, 36);
            this .buttonMC .TabIndex = 32;
            this .buttonMC .Text = "MC";
            this .buttonMC .UseVisualStyleBackColor = true;
            // 
            // panelM
            // 
            this .panelM .BorderStyle = System .Windows .Forms .BorderStyle .Fixed3D;
            this .panelM .Location = new System .Drawing .Point (13, 80);
            this .panelM .Name = "panelM";
            this .panelM .Size = new System .Drawing .Size (36, 36);
            this .panelM .TabIndex = 31;
            // 
            // textboxValue
            // 
            this .textboxValue .Location = new System .Drawing .Point (15, 41);
            this .textboxValue .Name = "textboxValue";
            this .textboxValue .Size = new System .Drawing .Size (329, 22);
            this .textboxValue .TabIndex = 30;
            this .textboxValue .TextAlign = System .Windows .Forms .HorizontalAlignment .Right;
            // 
            // Form_Calculator
            // 
            this .AutoScaleDimensions = new System .Drawing .SizeF (8F, 16F);
            this .AutoScaleMode = System .Windows .Forms .AutoScaleMode .Font;
            this .ClientSize = new System .Drawing .Size (353, 316);
            this .Controls .Add (this .buttonC);
            this .Controls .Add (this .buttonCE);
            this .Controls .Add (this .buttonBackspace);
            this .Controls .Add (this .buttonEqual);
            this .Controls .Add (this .buttonOpposite);
            this .Controls .Add (this .buttonPercent);
            this .Controls .Add (this .buttonSqrt);
            this .Controls .Add (this .buttonPlus);
            this .Controls .Add (this .buttonMinus);
            this .Controls .Add (this .buttonMultiply);
            this .Controls .Add (this .buttonDivide);
            this .Controls .Add (this .buttonDot);
            this .Controls .Add (this .buttonPlusMinus);
            this .Controls .Add (this .button_9);
            this .Controls .Add (this .button_8);
            this .Controls .Add (this .button_7);
            this .Controls .Add (this .button_6);
            this .Controls .Add (this .button_5);
            this .Controls .Add (this .button_4);
            this .Controls .Add (this .button_3);
            this .Controls .Add (this .button_2);
            this .Controls .Add (this .button_1);
            this .Controls .Add (this .button_0);
            this .Controls .Add (this .buttonMPlus);
            this .Controls .Add (this .buttonMS);
            this .Controls .Add (this .buttonMR);
            this .Controls .Add (this .buttonMC);
            this .Controls .Add (this .panelM);
            this .Controls .Add (this .textboxValue);
            this .Controls .Add (this .menuStrip1);
            this .DoubleBuffered = true;
            this .MaximizeBox = false;
            this .MinimizeBox = false;
            this .Name = "Form_Calculator";
            this .Text = "Primitive Calculator";
            this .MouseUp += new System .Windows .Forms .MouseEventHandler (this .OnMouseUp);
            this .MouseDown += new System .Windows .Forms .MouseEventHandler (this .OnMouseDown);
            this .FormClosing += new System .Windows .Forms .FormClosingEventHandler (this .OnFormClosing);
            this .MouseMove += new System .Windows .Forms .MouseEventHandler (this .OnMouseMove);
            this .menuStrip1 .ResumeLayout (false);
            this .menuStrip1 .PerformLayout ();
            this .ResumeLayout (false);
            this .PerformLayout ();

        }

        #endregion

        private System .Windows .Forms .MenuStrip menuStrip1;
        private System .Windows .Forms .ToolStripMenuItem miEdit;
        private System .Windows .Forms .ToolStripMenuItem miView;
        private System .Windows .Forms .ToolStripMenuItem miDefaultView;
        private System .Windows .Forms .ToolStripMenuItem miHelp;
        private System .Windows .Forms .Button buttonC;
        private System .Windows .Forms .Button buttonCE;
        private System .Windows .Forms .Button buttonBackspace;
        private System .Windows .Forms .Button buttonEqual;
        private System .Windows .Forms .Button buttonOpposite;
        private System .Windows .Forms .Button buttonPercent;
        private System .Windows .Forms .Button buttonSqrt;
        private System .Windows .Forms .Button buttonPlus;
        private System .Windows .Forms .Button buttonMinus;
        private System .Windows .Forms .Button buttonMultiply;
        private System .Windows .Forms .Button buttonDivide;
        private System .Windows .Forms .Button buttonDot;
        private System .Windows .Forms .Button buttonPlusMinus;
        private System .Windows .Forms .Button button_9;
        private System .Windows .Forms .Button button_8;
        private System .Windows .Forms .Button button_7;
        private System .Windows .Forms .Button button_6;
        private System .Windows .Forms .Button button_5;
        private System .Windows .Forms .Button button_4;
        private System .Windows .Forms .Button button_3;
        private System .Windows .Forms .Button button_2;
        private System .Windows .Forms .Button button_1;
        private System .Windows .Forms .Button button_0;
        private System .Windows .Forms .Button buttonMPlus;
        private System .Windows .Forms .Button buttonMS;
        private System .Windows .Forms .Button buttonMR;
        private System .Windows .Forms .Button buttonMC;
        private System .Windows .Forms .Panel panelM;
        private System .Windows .Forms .TextBox textboxValue;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions