Пример #1
0
        // Constructor
        public joystickControl()
        {
            this.Size = new Size(200, 200);

            mainSplitter.Dock             = DockStyle.Fill;
            mainSplitter.Orientation      = Orientation.Horizontal;
            mainSplitter.Panel2.BackColor = Color.DarkGray;
            mainSplitter.Panel2MinSize    = 17;
            mainSplitter.SplitterDistance = 100;
            mainSplitter.SplitterWidth    = 1;
            mainSplitter.FixedPanel       = FixedPanel.Panel2;

            mainPanel.Dock      = DockStyle.Fill;
            mainPanel.BackColor = bgColor;

            labelSplitter.Dock             = DockStyle.Fill;
            labelSplitter.SplitterWidth    = 1;
            labelSplitter.Panel1.BackColor = Color.FromArgb(150, 150, 150);

            label_x.Font          = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label_x.Dock          = DockStyle.Fill;
            label_x.Minimum       = -1;
            label_x.Maximum       = 1;
            label_x.DecimalPlaces = 2;
            label_x.Increment     = 0.01m;
            label_x.ContextMenu   = new ContextMenu();

            label_y.Font          = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label_y.Dock          = DockStyle.Fill;
            label_y.Minimum       = -1;
            label_y.Maximum       = 1;
            label_y.DecimalPlaces = 2;
            label_y.Increment     = 0.01m;
            label_y.ContextMenu   = new ContextMenu();

            this.Controls.Add(mainSplitter);
            mainSplitter.Panel1.Controls.Add(mainPanel);
            mainSplitter.Panel2.Controls.Add(labelSplitter);
            labelSplitter.Panel1.Controls.Add(label_x);
            labelSplitter.Panel2.Controls.Add(label_y);
            labelSplitter.SplitterDistance = this.Width / 2;

            // Add events
            mainPanel.MouseDown  += new System.Windows.Forms.MouseEventHandler(move_MouseDown);
            mainPanel.MouseUp    += new System.Windows.Forms.MouseEventHandler(move_MouseUp);
            mainPanel.MouseMove  += new System.Windows.Forms.MouseEventHandler(move_MouseMove);
            this.mainPanel.Paint += new System.Windows.Forms.PaintEventHandler(OnPaint);
            label_x.MouseDown    += new System.Windows.Forms.MouseEventHandler(xSpinnerMouseDown);
            label_x.ValueChanged += new System.EventHandler(xSpinnerValueChanged);
            label_x.Enter        += new System.EventHandler(spinnerEnter);
            spinnerEvent         += new spinnerHandler(spinnerFocus);
            label_y.MouseDown    += new System.Windows.Forms.MouseEventHandler(ySpinnerMouseDown);
            label_y.ValueChanged += new System.EventHandler(ySpinnerValueChanged);
            label_y.Enter        += new System.EventHandler(spinnerEnter);
            joystickEvent        += new joystickHandler(joystickValueChanged);
        }
Пример #2
0
        // Constructor
        public joystickControl()
        {
            this.Size = new Size(200, 200);

            mainSplitter.Dock = DockStyle.Fill;
            mainSplitter.Orientation = Orientation.Horizontal;
            mainSplitter.Panel2.BackColor = Color.DarkGray;
            mainSplitter.Panel2MinSize = 17;
            mainSplitter.SplitterDistance = 100;
            mainSplitter.SplitterWidth = 1;
            mainSplitter.FixedPanel = FixedPanel.Panel2;

            mainPanel.Dock = DockStyle.Fill;
            mainPanel.BackColor = bgColor;

            labelSplitter.Dock = DockStyle.Fill;
            labelSplitter.SplitterWidth = 1;
            labelSplitter.Panel1.BackColor = Color.FromArgb(150,150,150);

            label_x.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label_x.Dock = DockStyle.Fill;
            label_x.Minimum = -1;
            label_x.Maximum = 1;
            label_x.DecimalPlaces = 2;
            label_x.Increment = 0.01m;
            label_x.ContextMenu = new ContextMenu();

            label_y.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));   
            label_y.Dock = DockStyle.Fill;
            label_y.Minimum = -1;
            label_y.Maximum = 1;
            label_y.DecimalPlaces = 2;
            label_y.Increment = 0.01m;
            label_y.ContextMenu = new ContextMenu();

            this.Controls.Add(mainSplitter);
            mainSplitter.Panel1.Controls.Add(mainPanel);
            mainSplitter.Panel2.Controls.Add(labelSplitter);
            labelSplitter.Panel1.Controls.Add(label_x);
            labelSplitter.Panel2.Controls.Add(label_y);
            labelSplitter.SplitterDistance = this.Width / 2;

            // Add events
            mainPanel.MouseDown += new System.Windows.Forms.MouseEventHandler(move_MouseDown);
            mainPanel.MouseUp += new System.Windows.Forms.MouseEventHandler(move_MouseUp);
            mainPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(move_MouseMove);
            this.mainPanel.Paint += new System.Windows.Forms.PaintEventHandler(OnPaint);
            label_x.MouseDown += new System.Windows.Forms.MouseEventHandler(xSpinnerMouseDown);
            label_x.ValueChanged += new System.EventHandler(xSpinnerValueChanged);
            label_x.Enter += new System.EventHandler(spinnerEnter);
            spinnerEvent += new spinnerHandler(spinnerFocus);
            label_y.MouseDown += new System.Windows.Forms.MouseEventHandler(ySpinnerMouseDown);
            label_y.ValueChanged += new System.EventHandler(ySpinnerValueChanged);
            label_y.Enter += new System.EventHandler(spinnerEnter);
            joystickEvent += new joystickHandler(joystickValueChanged);
        }