private void AddImage(string imageFileName) { try { Image img; if (!_loadedImages.TryGetValue(imageFileName, out img)) { img = Image.FromFile(imageFileName); _loadedImages.Add(imageFileName, img); } using (var inf = new ImageNameForm()) { if (_activeFolder != null) { inf.ImageNameChanged += ImageNameForm_ImageNameChanged; inf.ImageName = _activeFolder.GetFullName( Path.GetFileNameWithoutExtension(imageFileName)); } if (inf.ShowDialog() == DialogResult.OK) { if (_rootFolder == null) { _rootFolder = new ImagesFolder(); _rootFolder.ImageAddConflict += RootFolderImageAddConflict; _rootFolder.AddImage(inf.ImageName, img); AssignRootFolder(); } else { using (new TreeGridUpdater(_foldersTree)) _rootFolder.AddImage(inf.ImageName, img); } } } } catch (ArgumentException ex) { MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void RenameImage() { if (_imagesList.SelectedItems.Count != 1) { return; } var info = _activeFolder.GetImageInfo(_imagesList.SelectedItems[0].Name); using (var inf = new ImageNameForm()) { inf.ImageNameChanged += ImageNameForm_ImageNameChanged; inf.ImageName = info.FullName; if (inf.ShowDialog() == DialogResult.OK && info.FullName != inf.ImageName) { using (new TreeGridUpdater(_foldersTree)) _activeFolder.RenameImage(info.ShortName, inf.ImageName); } } }
private void RenameImage() { if (_imagesList.SelectedItems.Count != 1) return; var info = _activeFolder.GetImageInfo(_imagesList.SelectedItems[0].Name); using (var inf = new ImageNameForm()) { inf.ImageNameChanged += ImageNameForm_ImageNameChanged; inf.ImageName = info.FullName; if (inf.ShowDialog() == DialogResult.OK && info.FullName != inf.ImageName) using (new TreeGridUpdater(_foldersTree)) _activeFolder.RenameImage(info.ShortName, inf.ImageName); } }