public void addImage(string imageName, string path) { bool exists = false; foreach (KeyValuePair <string, SourceImage> kvp in imageList) { if (kvp.Key.Equals(imageName) || kvp.Value.path.Equals(path)) { exists = true; } } if (exists != true) { sourceImageFactory.addImage(path, imageName); SourceImage newImage = new SourceImage(path, imageName); imageList.Add(imageName, newImage); } }
/// <summary> /// Creates a SourceImage based on the provided information, and adds it to the /// system. The SourceImageFactory is then called to add the SourceImage /// object to the reference file. /// /// If the image already exists, the image is not added to the system a second /// time. /// </summary> /// <param name="imageName">The full file name of the image to be added, including file extension.</param> /// <param name="path">The full path to the image to be added, including file name and file extension.</param> public void addImage(string imageName, string path) { bool exists = false; //check if the image exists foreach (KeyValuePair <string, SourceImage> kvp in imageList) { if (kvp.Key.Equals(imageName) || kvp.Value.path.Equals(path)) { exists = true; } } //if it doesn't exist if (exists != true) { //add a new image to the reference file sourceImageFactory.addImage(path, imageName); //add the image to the system SourceImage newImage = new SourceImage(path, imageName); imageList.Add(imageName, newImage); } }