//Rê chuột private void DrawSpace_MouseMove(object sender, MouseEventArgs e) { //hiện tọa độ toaDoX.Text = "" + e.Location.X; toaDoY.Text = "" + e.Location.Y; //vẽ if (curMode == drawMode.Pencil || curMode == drawMode.Brush) { if (mouseDown == true) { if (e.Button == MouseButtons.Left) { curPoint = e.Location; msPaint.DrawLine(mPen, startPoint, curPoint); startPoint = curPoint; DrawSpace.BackgroundImage = (Bitmap)bm.Clone(); } } } else { if (mouseDown == true) { curPoint = new Point(e.Location.X, e.Location.Y); DrawSpace.Refresh(); } } }
private void loadImage() { if (Reticule != null) { Reticule.Dispose(); } while (true) { try { Bitmap tempBMP = new Bitmap("ret.bmp"); Reticule = new Bitmap(tempBMP); tempBMP.Dispose(); this.Size = Reticule.Size; DrawSpace.Size = Reticule.Size; this.TransparencyKey = Reticule.GetPixel(0, 0); this.BackColor = this.TransparencyKey; DrawSpace.Image = Reticule; DrawSpace.Refresh(); return; } catch (System.IO.FileNotFoundException) { if (MessageBox.Show("Reticule File Not Found, press OK to retry, Cancel to quit", "Error Loading File", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel) { System.Environment.Exit(0); } } catch (System.ArgumentException) { if (MessageBox.Show("Reticule File Not Found, press OK to retry, Cancel to quit", "Error Loading File", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel) { System.Environment.Exit(0); } } } }