private void Main_MouseMove(object sender, MouseEventArgs e) { if (this.m_IsPickingChromaColor) { Cursor.Current = Cursors.Cross; this.pictureBoxChromaColor.Image.Dispose(); this.pictureBoxChromaColor.Image = this.CreateSwatch(0x15, 0x15, this.GetColorFromImage(this.pictureBox.Image, e.X, e.Y)); } if ((e.Button == MouseButtons.Left) && !this.m_IsPickingChromaColor) { if (!this.m_IsFramelessMode) { if (this.m_IsRubberBandBoxBeingDragged) { DoubleBufferedPictureBox box = sender as DoubleBufferedPictureBox; this.DrawRubberBandBox(sender, e.Location); } } else if (this.m_IsFormBeingDragged) { int x = (base.Location.X - this.m_LastLocation.X) + e.X; base.Location = new Point(x, (base.Location.Y - this.m_LastLocation.Y) + e.Y); base.Update(); } } }
public void DrawRubberBandBox(object sender, Point location) { DoubleBufferedPictureBox box = sender as DoubleBufferedPictureBox; box.Refresh(); using (Graphics graphics = box.CreateGraphics()) { Rectangle rect = GetRectangle(this.m_MouseDownPoint, location); graphics.DrawRectangle(Pens.Red, rect); this.m_LastLocation = location; } }
private void Main_MouseDown(object sender, MouseEventArgs e) { if ((e.Button == MouseButtons.Left) && !this.m_IsPickingChromaColor) { if (this.m_IsFramelessMode || this.m_IsSnipped) { this.m_IsFormBeingDragged = true; this.m_LastLocation = e.Location; } else { this.m_IsRubberBandBoxBeingDragged = true; DoubleBufferedPictureBox box = sender as DoubleBufferedPictureBox; this.m_MouseDownPoint = e.Location; } } }
private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.comboWindows = new System.Windows.Forms.ComboBox(); this.timer = new System.Windows.Forms.Timer(this.components); this.pictureBoxChromaColor = new DisembodiedHeads.DoubleBufferedPictureBox(this.components); this.pictureBox = new DisembodiedHeads.DoubleBufferedPictureBox(this.components); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxChromaColor)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); this.SuspendLayout(); // // comboWindows // this.comboWindows.FormattingEnabled = true; this.comboWindows.Location = new System.Drawing.Point(0, 0); this.comboWindows.Name = "comboWindows"; this.comboWindows.Size = new System.Drawing.Size(766, 21); this.comboWindows.TabIndex = 1; this.comboWindows.SelectedValueChanged += new System.EventHandler(this.comboWindows_SelectedValueChanged); // // timer // this.timer.Interval = 1; this.timer.Tick += new System.EventHandler(this.timer_Tick); // // pictureBoxChromaColor // this.pictureBoxChromaColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.pictureBoxChromaColor.Location = new System.Drawing.Point(773, 0); this.pictureBoxChromaColor.Name = "pictureBoxChromaColor"; this.pictureBoxChromaColor.Size = new System.Drawing.Size(21, 21); this.pictureBoxChromaColor.TabIndex = 3; this.pictureBoxChromaColor.TabStop = false; this.pictureBoxChromaColor.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBoxChromaColor_MouseUp); // // pictureBox // this.pictureBox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBox.Location = new System.Drawing.Point(0, 0); this.pictureBox.Name = "pictureBox"; this.pictureBox.Size = new System.Drawing.Size(800, 450); this.pictureBox.TabIndex = 2; this.pictureBox.TabStop = false; this.pictureBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Main_MouseDown); this.pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Main_MouseMove); this.pictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Main_MouseUp); // // Main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.ClientSize = new System.Drawing.Size(800, 450); this.Controls.Add(this.pictureBoxChromaColor); this.Controls.Add(this.comboWindows); this.Controls.Add(this.pictureBox); this.Name = "Main"; this.Text = "Disembodied Heads"; ((System.ComponentModel.ISupportInitialize)(this.pictureBoxChromaColor)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); this.ResumeLayout(false); }