Example #1
0
 // data
 private void SAVEbutton_Click(object sender, EventArgs e)
 {
     if (setQTS == true)
     {
         //get file name
         CustomDialogBox saveAs = new CustomDialogBox("SAVE AS", "S A V E");
         if (saveAs.ShowDialog() == DialogResult.OK)
         {
             temp.Save(saveAs.fileName, ImageFormat.Png);
             CustomMessageBox msg = new CustomMessageBox("S-A-V-E-D");
             msg.Show();
             temp.Dispose();
         }
     }
     else if (setQTS == false && matrix.Count > 0 && links.Count > 0)
     {
         //get file name
         CustomDialogBox saveAs = new CustomDialogBox("SAVE AS", "S A V E");
         if (saveAs.ShowDialog() == DialogResult.OK)
         {
             DataManager.saveToCSV(saveAs.fileName, matrix, links);
             CustomMessageBox msg = new CustomMessageBox("S-A-V-E-D");
             msg.Show();
         }
     }
     else
     {
         CustomMessageBox msg = new CustomMessageBox("NOTHING TO SAVE");
         msg.Show();
     }
 }
Example #2
0
        private void OPENbutton_Click(object sender, EventArgs e)
        {
            CustomDialogBox saveAs = new CustomDialogBox("FILE NAME", "O P E N ");

            if (saveAs.ShowDialog() == DialogResult.OK)
            {
                refreshGraph(false);
                (matrix, links) = DataManager.importFromCSV(saveAs.fileName);
                //show imported
                putMatrix(matrix, 10);
                putMesh(links, 10);
                putMatrix(matrix, 5);
            }
        }
Example #3
0
        // QT
        private void QTbutton_Click(object sender, EventArgs e)
        {
            refreshGraph(false);
            try
            {
                rootNode = null;


                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png";
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    int             tolerance = 3; //default
                    CustomDialogBox tol       = new CustomDialogBox("tolerance", "E N G A G E");
                    if (tol.ShowDialog() == DialogResult.OK)
                    {
                        int.TryParse(tol.fileName, out tolerance);
                    }

                    // get path
                    var filePath = dialog.FileName;

                    //add picture
                    image = Image.FromFile(filePath);
                    graph.BackgroundImage = image;

                    //generate QT
                    rootNode = Engine.quadTreeGenerator(image, graph.Width, graph.Height, tolerance); //rectangle

                    //putSubdivision(rootNode,0);
                    Bitmap bmp = new Bitmap(image);

                    ///rect
                    Engine.onlyFigure(rootNode, bmp, false); //only fig
                    // Engine.deleteRedundant(rootNode, bmp);
                    putSubdivision(rootNode, 0, "pink");
                    graph.Refresh();
                }
            }
            catch (Exception ex)
            {
                CustomMessageBox msg = new CustomMessageBox(ex.ToString());
                msg.Show();
            }
        }
Example #4
0
        private void graph_MouseDown(object sender, MouseEventArgs e)
        {
            if (setQTP)
            {
                pointsQTP.Add(new PointModel(mouse_x, mouse_y));
                graph.Refresh();
            }
            if (setQTS)
            {
                image = Image.FromFile(imPath);
                graph.BackgroundImage = image;
                graph.Width           = image.Width;
                graph.Height          = image.Height;

                Bitmap          bmp       = new Bitmap(image);
                Color           pixColor  = bmp.GetPixel(e.X, e.Y);
                int             tolerance = 1; //default
                CustomDialogBox tol       = new CustomDialogBox("tolerance", "E N G A G E");
                if (tol.ShowDialog() == DialogResult.OK)
                {
                    int.TryParse(tol.fileName, out tolerance);
                }

                //rootNode = Engine.quadTreeGenerator_Seed(bmp, im.Width, im.Height, 2, pixColor); //rectangle
                //Engine.onlyFigure_Seed(rootNode, bmp, pixColor); //only fig



                rootNode_Triangle = Engine.quadTreeGenerator_Triangle_Seed(bmp, image.Width, image.Height, tolerance, pixColor); //triangle
                Engine.onlyFigure_Triangle_Seed(rootNode_Triangle, bmp, pixColor);                                               //only fig



                //putSubdivision(rootNode, 0, "red");
                putSubdivision_Triangle(rootNode_Triangle, 0, "pink");
                graph.DrawToBitmap(bmp, new Rectangle(0, 0, image.Width, image.Height));
                temp = bmp;
                //bmp.Dispose();
                graph.Refresh();
            }
        }