public PictureSetting(string guid, Bitmap bitmap, ICutPicture iCutPicture, string filePath) { InitializeComponent(); this.bitmap = bitmap; this._filePath = filePath; panelBack.Width = bitmap.Width; panelBack.Height = bitmap.Height; picBitmap.Image = bitmap; picBitmap.Size = new Size(bitmap.Width, bitmap.Height); picBitmap.Left = 0; picBitmap.Top = 0; //设置选中区域的最大和最小 picWidth.Maximum = bitmap.Width; picHeight.Maximum = bitmap.Height > 100 ? 100 : bitmap.Height; picWidth.Value = 32; picHeight.Value = 32; //设置控件可移动 SetItemEvent(btnSize); SetBtn(); btnSize.Left = 0; btnSize.Top = 0; btnSize.Width = 32; btnSize.Height = 32; this._iCutPicture = iCutPicture; this._guid = guid; var newBitmap = ImageTool.GetCutPic(bitmap, btnSize.Left, btnSize.Top, btnSize.Width, btnSize.Height); _iCutPicture?.GetCutPicture(guid, new PictureSettingParameter() { Bitmap = newBitmap, UserControl = this }); }
private void btnSize_MouseMove(object sender, MouseEventArgs e) { if (_mouseDown) { var newBitmap = ImageTool.GetCutPic(bitmap, btnSize.Left, btnSize.Top, btnSize.Width, btnSize.Height); _iCutPicture?.GetCutPicture(_guid, new PictureSettingParameter() { Bitmap = newBitmap, UserControl = this }); } }
private void picHeight_ValueChanged(object sender, EventArgs e) { try { btnSize.Height = (int)picHeight.Value; var newBitmap = ImageTool.GetCutPic(bitmap, btnSize.Left, btnSize.Top, btnSize.Width, btnSize.Height); _iCutPicture?.GetCutPicture(_guid, new PictureSettingParameter() { Bitmap = newBitmap, UserControl = this }); } catch (Exception ex) { MessageBox.Show(ex.Message); } }