Пример #1
0
        private void ReadLabelsTXT()
        {
            string txtLabelFile = Form1.labeledFoldername + @"\labels\" + Path.GetFileNameWithoutExtension(unlabeledfiles[currentImageIndex]) + ".txt";

            if (File.Exists(txtLabelFile))
            {
                string[] txtLabelFileLines = File.ReadAllLines(txtLabelFile);

                foreach (var line in txtLabelFileLines)
                {
                    ResizableRectangle tempResizableRectangle = new ResizableRectangle(line);
                    tempResizableRectangle.sizeNodeRect = sizeNodeRect;
                    displayedResizableRectangleList.Add(tempResizableRectangle);
                    tempResizableRectangle.SetPictureBox(pictureBoxS);
                    tempResizableRectangle.currentObjectClass = currentObjectClassList.Find(objectToFind => objectToFind.className == tempResizableRectangle.className);

                    //create new Object Class if not yet available
                    if (tempResizableRectangle.currentObjectClass == null)
                    {
                        addannewButton();
                        Console.WriteLine(currentObjectClassList.Last().className);
                        currentObjectClassList.Last().className = tempResizableRectangle.className;
                        Console.WriteLine(currentObjectClassList.Last().className);
                        tempResizableRectangle.currentObjectClass = currentObjectClassList.Last();
                        currentObjectClassList.Last().textBox.Text = tempResizableRectangle.className;
                    }
                }
            }
        }
Пример #2
0
        bool isAnyWindowSelected = false;   //if true: an existing window will be resized; if false: a new window will be created


        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (pictureBox1.Image == null)
            {
                return;
            }

            // all existing boxes are checked if any handle node is selected
            isAnyWindowSelected = false;
            foreach (ResizableRectangle item in displayedResizableRectangleList)
            {
                if (item.nodeSelected != ResizableRectangle.PosSizableRect.None)
                {
                    isAnyWindowSelected            = true;
                    selectedResizableRectangle     = item;
                    toolStripTextBoxTruncated.Text = selectedResizableRectangle.truncated.ToString();
                }
            }

            //mouse down coordinates are remembered
            draw = true;
            mouseDownCoordinates.X = e.X;
            mouseDownCoordinates.Y = e.Y;

            // if no box is selected, a new one is created
            if (!isAnyWindowSelected)
            {
                CurrentObjectClass selectedObjectClass = currentObjectClassList.Find(objectToFind => objectToFind.radioButton.Checked == true);

                currentResizableRectangle                    = new ResizableRectangle(new Rectangle(e.X, e.Y, 0, 0));
                currentResizableRectangle.className          = selectedObjectClass.className;
                currentResizableRectangle.boxColor           = selectedObjectClass.color;
                currentResizableRectangle.currentObjectClass = selectedObjectClass;
                currentResizableRectangle.sizeNodeRect       = sizeNodeRect;
                currentResizableRectangle.SetPictureBox(this.pictureBox1);

                selectedResizableRectangle     = currentResizableRectangle;
                toolStripTextBoxTruncated.Text = selectedResizableRectangle.truncated.ToString();

                // makes sure that this mouseButton-Event is executed last, after all ResizableRectangles are checked for selected nodes
                pictureBox1.MouseDown -= new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
                pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
            }
        }