Beispiel #1
0
        // The method which fires the Event
        protected void OnPixelColorChanged(object sender, ImageCanvasDataEventArgs e)
        {
            var target = PixelColorChanged;

            if (target != null)
            {
                target(this, e);
            }
        }
Beispiel #2
0
        void pictureBox_Canvas_MouseMove(object sender, MouseEventArgs e)
        {
            Point p = new Point((int)Math.Truncate(e.X / _zoomLevel), (int)Math.Truncate(e.Y / _zoomLevel));

            if ((_LocationFromCenter) && (normalImage != null))
            {
                this.label_MouseCoord.Text = "[x" + (p.X - Center.X).ToString("000") + " , y" + (p.Y - Center.Y).ToString("000") + "]";
            }
            else
            {
                this.label_MouseCoord.Text = "[x" + (p.X).ToString("000") + " , y" + (p.Y).ToString("000") + "]";
            }

            //Zoom via MouseWheel works only when the control has focus (which panels and pictureboxes usualy can't have). It only gets focus when CaptureFocusOnMouseOver is true
            if (_CaptureFocusOnMouseOver)
            {
                this.label_MouseCoord.Text += " Zoom=" + ZoomLevel.ToString();
            }


            this.label_Color.Visible = _ShowColorInfo;

            if (normalImage != null)
            {
                if ((p.X < normalImage.Width) && (p.Y < normalImage.Height))
                {
                    if (normalImage.PixelFormat != System.Drawing.Imaging.PixelFormat.Format8bppIndexed)
                    {
                        Bitmap tmp = (Bitmap)normalImage;
                        Color  c   = tmp.GetPixel(p.X, p.Y);
                        this.label_Color.Text = "RGB=[" + c.R.ToString("000") + "," + c.G.ToString("000") + "," + c.B.ToString("000") + "]";
                    }
                    else
                    {
                        int c = CConverter.GetPixel(p.X, p.Y, normalImage);
                        if (c != PaletteColorUnderMouse)
                        {
                            ImageCanvasDataEventArgs ne = new ImageCanvasDataEventArgs();
                            ne.Color = c;
                            PaletteColorUnderMouse = c;
                            OnPixelColorChanged(this, ne);
                        }
                        this.label_Color.Text = "Color=" + c;
                    }
                }
            }
        }