private void loadToolStripMenuItem_Click(object sender, EventArgs e) { for (int i = 0; i < comparisons.Count; i++) { deleteFiles(i); } comparisons.Clear(); OpenFileDialog open = new OpenFileDialog(); if (open.ShowDialog() == DialogResult.OK) { StreamReader reader = new StreamReader(open.FileName); while (!reader.EndOfStream) { nodes.Comparison comp = new nodes.Comparison(); comp.image1 = new nodes.Image(); comp.image2 = new nodes.Image(); comp.name = reader.ReadLine(); comp.image1.path = reader.ReadLine(); comp.image1.name = reader.ReadLine(); comp.image2.path = reader.ReadLine(); comp.image2.name = reader.ReadLine(); comparisons.Add(comp); if (!File.Exists(comp.image1.path) || !File.Exists(comp.image2.path)) { MessageBox.Show("At least one of the previously saved images no longer exists at previously desgnated location.", "Issue"); windows.Comparison comparison = new windows.Comparison(comparisons.Count - 1, comp.image1.path, comp.image2.path); if (comparison.ShowDialog() != DialogResult.OK) { comparisons.RemoveAt(comparisons.Count - 1); } else { generate_data(comparisons.Count - 1); } } else { generate_data(comparisons.Count - 1); } } reader.Close(); treeView1_Update(); } }
// private void editToolStripMenuItem_Click(object sender, EventArgs e) { //If there are no comparisons if (comparisons.Count == 0) { //Alert user to issue MessageBox.Show("EDIT ERROR: No Comparisons to Edit.", "ERROR"); } //Else if no comparison is selected else if (treeView1.SelectedNode == null) { //Alert user to issue MessageBox.Show("EDIT ERROR: No Comparison Selected to Edit.", "Error"); } //Else the comparisons list contains comparisons and the //user has selected a comparison from list else { int index = 0; //Stores index of user selected index //If selected node is root if (treeView1.SelectedNode.Level == 0) { //Assign index of root node to variable index index = treeView1.SelectedNode.Index; } //Else node is a subnode else { //Assign index of parent node to variable to index index = treeView1.SelectedNode.Parent.Index; } //Create new instance of windows Comparison Dialog windows.Comparison comparison = new windows.Comparison(index); //Assign new title to comparison dialog comparison.Text = "Edit Comparison"; //If comparison returns ok exit if (comparison.ShowDialog() == DialogResult.OK) { //Update treeview1 treeView1_Update(); } } }
/////////////////////////////////// // createToolStripMenuItem_Click // // Type: // Event Handler // // Arguments: // sender : object // e : EventArgs // // Return: // void /////////////////////////////////// private void createToolStripMenuItem_Click(object sender, EventArgs e) { //Create new instance of windows.Comparison Dialog windows.Comparison comparison = new windows.Comparison(); //If comparison dialog exits with status ok if (comparison.ShowDialog() == DialogResult.OK) { //Update treeview1 treeView1_Update(); //Take index of last element in comparisons list int index = comparisons.Count - 1; //generate data files for final comparison generate_data(index); // pictureBox3.ImageLocation = comparisons[index].name + ".bmp"; } }