private void ImageListView_DoubleClick(object sender, EventArgs e) { if (imageListView.SelectedItems.Count == 1) { var item = imageListView.SelectedItems[0]; if (item.Tag is string path) { var node = folderTreeView.SelectedNode; var child = node.Nodes.Cast <TreeNode>().FirstOrDefault(n => n.Name == path); if (child != null) { folderTreeView.SelectedNode = child; } } else if (item.Tag is TextureInfo info) { var image = library.LoadTexture(info); new ImagePreviewForm(image, info.name).Show(); } } }
public static ContextMenuStrip FromImage(TextureLibrary library, TextureInfo info) { ContextMenuStrip menu = new ContextMenuStrip(); menu.Items.Add("&Replace with...", null, (sender, ev) => LoadTexture(library, info)); if (library.ImageChanges.Any(n => n.Key == info.name)) { menu.Items.Add("Discard changes", null, (sender, ev) => library.DiscardChange(info)); } menu.Items.Add(new ToolStripSeparator()); menu.Items.Add("&Copy", null, (sender, ev) => Clipboard.SetImage(library.LoadTexture(info))); menu.Items.Add("&Save as...", null, (sender, ev) => SaveTexture(info.name, library.LoadTexture(info))); return(menu); }
public object GetData(string format) { if (temporaryFiles == null) { temporaryFiles = new string[images.Length]; for (int n = 0; n < images.Length; n++) { var name = Path.ChangeExtension(Path.GetFileName(images[n].name), ".png"); var path = Path.Combine(Path.GetTempPath(), name); var image = library.LoadTexture(images[n]); image.Save(path, ImageFormat.Png); temporaryFiles[n] = path; } } return(temporaryFiles); }