private void CropPictureBox_SizeChanged(object sender, EventArgs e) { CropPictureBox.Invalidate(); if (CropPictureBox.Image != null) { OnCropPictureBoxResize(); } }
/// <summary> /// イメージ上に四角を描画する /// </summary> /// <param name="startPoint"></param> /// <param name="endPoint"></param> private void DrawRectangleInCropPictureBox(Point startPoint, Point endPoint) { using (Pen pen = new Pen(Color.Red)) using (Graphics graphics = CropPictureBox.CreateGraphics()) { pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; CropPictureBox.Refresh(); graphics.DrawRectangle(pen, startPoint.X, startPoint.Y, Math.Abs(startPoint.X - endPoint.X), Math.Abs(startPoint.Y - endPoint.Y)); } }
private void CropPictureBox_MouseDown(object sender, MouseEventArgs e) { CropPictureBox.Invalidate(); _cropArea.X = e.X; _cropArea.Y = e.Y; _cropArea.Width = 0; _cropArea.Height = 0; _isMouseDown = true; }
private void CropPictureBox_MouseMove(object sender, MouseEventArgs e) { if (_isMouseDown) { _cropArea.Width = (e.X - _cropArea.X); _cropArea.Height = (e.Y - _cropArea.Y); if (_cropAreaBounds.Contains(_cropArea)) { CropPictureBox.Invalidate(); } } }