Exemple #1
0
        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            if (!s.IsPathsEmpty() && !s.cd.IsEmpty())
            {
                if (p == null)
                {
                    MessageBox.Show("Please select a class to label");
                }
                else
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        if (!s.isDrawing)
                        {
                            s.isDrawing = true;
                            s.StartPos.SetCoords(e.Location.X, e.Location.Y);
                            s.EndPos.SetCoords(e.Location.X, e.Location.Y);
                        }

                        else
                        {
                            s.isDrawing = false;
                            s.EndPos.SetCoords(e.Location.X, e.Location.Y);
                            MyRectangle rect = s.GetRectangle();
                            if (rect.Width > 0 && rect.Height > 0)
                            {
                                s.AddPair(rect, p.Color);
                            }
                            pictureBox1.Invalidate();
                        }
                    }
                }
            }
        }
Exemple #2
0
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            if (!s.IsBBoxesEmpty() && s.ImageBoxes[s.currentPic].GetCount() > 0)
            {
                s.DrawAll(e.Graphics);
            }
            else if (!s.IsPathsEmpty())
            {
                if (s.CrosshairsEnabled)
                {
                    s.DrawLines(e.Graphics);
                }
            }
            if (s.isDrawing)
            {
                MyRectangle mr = s.GetRectangle();
                Color       c  = Color.FromArgb(127, p.Color.R, p.Color.G, p.Color.B);
                Brush       b  = new SolidBrush(c);
                Rectangle   r  = new Rectangle(mr.X, mr.Y, mr.Width, mr.Height);

                e.Graphics.DrawRectangle(p, r);
                e.Graphics.FillRectangle(b, r);
                b.Dispose();
            }
            if (!s.IsPathsEmpty())
            {
                toolStripStatusLabel2.Text = string.Format("Name: {0}, Objects: {1} ", Path.GetFileName(s.PicturePaths[s.currentPic]), s.ImageBoxes[s.currentPic].GetCount());
            }
        }
Exemple #3
0
        /// <summary>
        /// Returns the last Rectangle
        /// </summary>
        /// <returns>Serializable Rectangle</returns>
        public MyRectangle Pop()
        {
            MyRectangle mr = DrawnRectangles[DrawnRectangles.Count - 1];

            DrawnRectangles.RemoveAt(DrawnRectangles.Count - 1);
            return(mr);
        }
Exemple #4
0
        /// <summary>
        /// Performs undo action for the given picture
        /// </summary>
        public void Undo()
        {
            if (UndoList[currentPic].DrawnRectangles.Count != 0)
            {
                MyRectangle r = UndoList[currentPic].Pop();


                ImageBoxes[currentPic].Remove(r);
            }
        }
Exemple #5
0
        public MyRectangle GetRectangle()
        {
            int         x    = Math.Min(StartPos.X, EndPos.X);
            int         y    = Math.Min(StartPos.Y, EndPos.Y);
            int         w    = Math.Abs(StartPos.X - EndPos.X);
            int         h    = Math.Abs(StartPos.Y - EndPos.Y);
            MyRectangle rect = new MyRectangle(x, y, w, h);


            return(rect);
        }
Exemple #6
0
 public void AddPair(MyRectangle r, Color c)
 {
     ImageBoxes[currentPic].Add(r, c);
     UndoList[currentPic].Push(r);
 }
Exemple #7
0
 public void Remove(MyRectangle r)
 {
     BBoxes.Remove(r);
 }
Exemple #8
0
 public void Add(MyRectangle r, Color c)
 {
     BBoxes[r] = c.ToArgb();
 }
Exemple #9
0
 /// <summary>
 /// Adds Rectangle on the stack
 /// </summary>
 /// <param name="r">Serializable Rectange</param>
 public void Push(MyRectangle r)
 {
     DrawnRectangles.Add(r);
 }