/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Form1_Load(object sender, EventArgs e) { mainBox = new PictureBoxIpl(); tabPage1.Controls.Add(mainBox); mainBox.Dock = DockStyle.Fill; mainDisplay.DoInvalid += delegate { mainBox.Invalidate(false); }; mainDisplay.StatusChange += delegate { ClearAndDraw(); }; //TODO , take as internal handler? ///mouse coordinate not match with image coordinate mainBox.MouseMove += MouseMoveHandler; mainBox.MouseClick += MouseClickHandler; mainBox.MouseDown += MouseDownHandler; mainBox.MouseUp += MouseUpHandler; mainBox.Paint += PaintEventHandler; btnNewLayer.Click += btnNewLayser_Click; btnLine.Click += btnTask_Click; btnSelect.Click += btnTask_Click; loadPicture(@"../../lenna.png"); __isLoaded = true; }
private void ClearAndDraw() { mainGraphics.Clear(Color.White); mainGraphics.DrawImage(mainGrayImage.ToBitmap(), new Point(0, 0)); mainDisplay.DataModel.DrawAllLayersObjects(mainGraphics); mainBox.Invalidate(false); }
public void RefreshIplImage(Mat img) { if (img == null || pictureBox.Image == null) { pictureBox.ImageIpl = img; imageID = img.Width + img.Height + img.Channels() + img.Type().Value; } else if (img.Width + img.Height + img.Channels() + img.Type().Value != imageID) { pictureBox.ImageIpl = img; imageID = img.Width + img.Height + img.Channels() + img.Type().Value; } else { BitmapConverter.ToBitmap(img, (Bitmap)pictureBox.Image); } pictureBox.Invalidate(); }