void UpdateDirectory() { dirTextBox.Text = curDir; listView.Clear(); foreach (var directory in GetDirectories(curDir).Select(d => d.Split('\\').Last())) { listView.Items.Add(new ListViewItem() { Tag = new Tuple <string, object>("dir", directory), Text = directory, ImageIndex = 0 }); } foreach (var file in GetFiles(curDir)) { if (!iconCache.ContainsKey(file.directory + "\\" + file.name)) { iconList.Images.Add(GFFile.LoadFromBytes(cnt.GetFileBytes(file.directory + "\\" + file.name)).GetBitmap()); iconCache.Add(file.directory + "\\" + file.name, iconList.Images.Count - 1); } listView.Items.Add(new ListViewItem() { Tag = new Tuple <string, object>("file", file), Text = file.name, ImageIndex = iconCache[file.directory + "\\" + file.name] }); } }
private void saveFileMenuStripBtn_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count == 0) { return; } var item = listView.SelectedItems[0]; var tag = (Tuple <string, object>)item.Tag; if (tag.Item1 != "file") { return; } var file = (CNTFile.FileStruct)tag.Item2; SaveFileDialog dialog = new SaveFileDialog() { Filter = "Bitmap|*.bmp" }; dialog.FileOk += (o, args) => GFFile.LoadFromBytes(cnt.GetFileBytes(file.directory + "\\" + file.name)).GetBitmap().Save(dialog.FileName); dialog.ShowDialog(); }
private void modifyToolStripMenuItem_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count == 0) { return; } var item = listView.SelectedItems[0]; var tag = (Tuple <string, object>)item.Tag; if (tag.Item1 != "file") { return; } var file = (CNTFile.FileStruct)tag.Item2; string bitmapName = tempFolder + "\\" + file.name + ".bmp"; GFFile.LoadFromBytes(cnt.GetFileBytes(file.directory + "\\" + file.name)).GetBitmap().Save(bitmapName); Process.Start("explorer.exe", $"/select, \"{bitmapName}\""); if (watchedFiles.ContainsKey(bitmapName)) { return; } watchedFiles.Add(bitmapName, file); }
public GFView(byte[] gfData) { InitializeComponent(); gfFile = GFFile.LoadFromBytes(gfData); }