Exemple #1
0
        private void envoieListe(List <PositionZone> lst)
        {
            if (OnUpdatePositionZones == null)
            {
                return;
            }
            List <PositionZone> tmp = new List <PositionZone>();

            foreach (PositionZone p in lst)
            {
                PositionZone pp = p;
                pp.A.X = (int)(pp.A.X * ratioCmParPixel[0]);
                pp.A.Y = (int)(pp.A.Y * ratioCmParPixel[1]);

                pp.B.X = (int)(pp.B.X * ratioCmParPixel[0]);
                pp.B.Y = (int)(pp.B.Y * ratioCmParPixel[1]);

                pp.C.X = (int)(pp.C.X * ratioCmParPixel[0]);
                pp.C.Y = (int)(pp.C.Y * ratioCmParPixel[1]);

                pp.D.X = (int)(pp.D.X * ratioCmParPixel[0]);
                pp.D.Y = (int)(pp.D.Y * ratioCmParPixel[1]);
                tmp.Add(pp);
            }
            UpdatePositionZonesEventArgs a = new UpdatePositionZonesEventArgs(tmp);

            OnUpdatePositionZones(this, a);
        }
Exemple #2
0
        // Calcul le centre d'un rectangle de dépose
        static public PositionElement CentreRectangle(PositionZone Zone)
        {
            int             X = (Zone.A.X + Zone.C.X) / 2;
            int             Y = (Zone.A.Y + Zone.C.Y) / 2;
            PositionElement p = new PositionElement(X, Y);

            return(p);
        }
Exemple #3
0
        public void ClicImage(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                ImageReel_MouseDown(sender, e);
            }
            else if (e.Button == MouseButtons.Left)
            {
                col = new int[] { (int)e.X, (int)e.Y };
            }
            else if (e.Button == MouseButtons.Middle)
            {
                if (LstZone.Count > 0 && LstZone[LstZone.Count - 1].ID == -1)
                {
                    int   w_i = ((PictureBox)sender).Image.Width;
                    int   h_i = ((PictureBox)sender).Image.Height;
                    int   w_c = ((PictureBox)sender).Width;
                    int   h_c = ((PictureBox)sender).Height;
                    float ord = ((float)w_i * (float)((float)e.X / (float)w_c));
                    float abs = ((float)h_i * (float)((float)e.Y / (float)h_c));

                    PositionZone zn = LstZone[LstZone.Count - 1];
                    if (zn.A.X == 0 && zn.A.Y == 0)
                    {
                        zn.A.X = (int)ord;
                        zn.A.Y = (int)abs;
                    }
                    else if (zn.B.X == 0 && zn.B.Y == 0)
                    {
                        zn.B.X = (int)ord;
                        zn.B.Y = (int)abs;
                    }
                    else if (zn.C.X == 0 && zn.C.Y == 0)
                    {
                        zn.C.X = (int)ord;
                        zn.C.Y = (int)abs;
                    }
                    else
                    {
                        zn.D.X = (int)ord;
                        zn.D.Y = (int)abs;
                        zn.ID  = LstZone.Count - 1;
                    }
                    LstZone[LstZone.Count - 1] = zn;
                    if (LstZone[LstZone.Count - 1].ID > -1)
                    {
                        envoieListe(LstZone);
                    }
                }
            }
        }
Exemple #4
0
        public void addcouleur(Bitmap bm)
        {
            if (LstZone.Count == 0 || LstZone[LstZone.Count - 1].ID != -1 && col != null)
            {
                int   w_i = bm.Width;
                int   h_i = bm.Height;
                int   w_c = imgReel.Width;
                int   h_c = imgReel.Height;
                float ord = ((float)w_i * (float)((float)this.col[0] / (float)w_c));
                float abs = ((float)h_i * (float)((float)this.col[1] / (float)h_c));
                this.col = null;
                int R = 0, G = 0, B = 0, A = 0;
                int count = 0;
                // Moyenne des pixels
                for (int i = (int)(ord - 1); i < (int)(ord + 1); i++)
                {
                    for (int j = (int)(abs - 1); j < (int)(abs + 1); j++)
                    {
                        count++;
                        Color c = bm.GetPixel(i, j);
                        R += c.R;
                        G += c.G;
                        B += c.B;
                        A += c.A;
                    }
                }
                RGB tmp  = new RGB(((byte)(R / count)), ((byte)(G / count)), ((byte)(B / count)), ((byte)(A / count)));
                HSL colo = HSL.FromRGB(tmp);
                Logger.GlobalLogger.debug("Couleur ajoutée : " + tmp.ToString() + " HLS : " + colo.Hue + " " + colo.Luminance + " " + colo.Saturation);

                HSLFiltering Filter = new HSLFiltering();
                Filter.Hue        = new IntRange((colo.Hue + 340) % 360, (colo.Hue + 20) % 360);
                Filter.Saturation = new Range(0.6f, 1f);
                Filter.Luminance  = new Range(0.1f, 1f);
                LstHslFiltering.Add(Filter);
                PositionZone ZoneTmp = new PositionZone();
                ZoneTmp.ID = -1;
                LstZone.Add(ZoneTmp);
                MessageBox.Show("Ajouter une zone de dépose avec le click milieu");
            }
        }
Exemple #5
0
 public void setPosition(PositionZone pos)
 {
     _position = pos;
 }
Exemple #6
0
 public Zone(int id, PositionZone pos)
 {
     this._id = id;
     setPosition(pos);
 }