//loads a pgm private void loadfile() { string f = ""; int n = 0; if (img != null) { if (cmd.getcmd("delete loaded image? [1]yes, [q]quit - ", ref n, 1)) { deleteimage(); } else { return; } } if (cmd.getfile("enter file name : ", ref f, ".pgm", 1)) { f = "images/" + f; img = new image(); if (img.load(f)) { t = new toolbox(img.getpixels(), img.getImageData().width, img.getImageData().totalpixels); } else { deleteimage(); } } }
private void button1_Click(object sender, EventArgs e) // This is the button click to save the file paths and load the image into the picture box { // Clear the info label label6.Text = ""; label6.ForeColor = Color.Blue; // Attempt to close eagleEye if it is opened if (eagleEyeRunning()) { eagleEye.Kill(); } // Assign map path by bringing up file dialog if (mapCleanup.getUserPath()) { mapPath = mapCleanup.getImagePath(); // check for pre-existing temp files - delete any if found RemoveTemporaryFiles(mapPath); // Reset the progress bar progressBar1.Visible = false; label1.Visible = false; // Disable the Save Button button3.Enabled = false; // if an image is loaded, remove it from GUI if (imageLoaded) { mapImage.Dispose(); } // set image mapImage = Image.FromFile(mapPath); pictureBox1.Image = mapImage; // Assign the directory path and load the trajectory and offset files dirPath = mapCleanup.getDir(); // Assign the paths for the offset and trajectory files offsetPath = mapCleanup.getOffset(); trajPath = mapCleanup.getTraj(); if (offsetPath == "" || trajPath == "") { label6.Text = "Error: Trajectory/Offset file(s) not found!\n"; label6.ForeColor = Color.Red; label6.Visible = true; } // If the paths for both the offset and trajectory files aren't found, do not generate Park and Dock coordinates if (offsetPath != "" && trajPath != "") { mapCleanup.generateParkandDock(); } // Generate a .pgm file string pgmPath = mapCleanup.generatePGM(); // Hide the generated .pgm file File.SetAttributes(pgmPath, FileAttributes.Hidden); // Make the store info headers visible label2.Visible = true; label3.Visible = true; // Get the store name and number string storeName = mapCleanup.getStoreInfo("name"); string storeNumber = mapCleanup.getStoreInfo("number"); // Populate the labels with the store name and the store number label4.Text = mapCleanup.getStoreInfo("name");; label5.Text = mapCleanup.getStoreInfo("number"); // Create data path as "[directory]\[storename][storenumber]data.csv" csvPath = mapCleanup.getDir() + "\\" + storeName + storeNumber + "data.csv"; // Load the image if (img.load(pgmPath)) { tBox = new toolbox(img.getpixels(), img.getImageData().width, img.getImageData().height, img.getImageData().totalpixels); } // Make the Clean Map button clickable button2.Enabled = true; // Clean Map Button // Make the progress bar and bar label visible to the user label1.Visible = true; progressBar1.Visible = true; progressBar1.Value = 0; progressBar1.Maximum = img.getImageData().totalpixels; // Allow Eagle Eye to be turned on button7.Enabled = true; // Display status message to user label6.Text = label6.Text + "Dirty map loaded."; if (label6.ForeColor != Color.Red) { label6.ForeColor = Color.Blue; } label6.Visible = true; } else { // Remove an image from the image box pictureBox1.Image = null; // Make Eagle Eye not executable button7.Enabled = false; // Display status message to user label6.Text = "Error: Dirty map not loaded."; label6.ForeColor = Color.Red; label6.Visible = true; } }