private void buttonReplace_Click(object sender, EventArgs e) { if (_library == null) { return; } if (_library.FileName == null) { return; } if (PreviewListView.SelectedIndices.Count == 0) { return; } OpenFileDialog ofd = new OpenFileDialog(); ofd.ShowDialog(); if (ofd.FileName == "") { return; } Bitmap newBmp = new Bitmap(ofd.FileName); ImageList.Images.Clear(); _indexList.Clear(); _library.ReplaceImage(PreviewListView.SelectedIndices[0], newBmp, 0, 0); PreviewListView.VirtualListSize = _library.Images.Count; try { PreviewListView.RedrawItems(0, PreviewListView.Items.Count - 1, true); if (ViewMode == "Image") { ImageBox.Image = _library.Images[PreviewListView.SelectedIndices[0]].Image; } else { ImageBox.Image = _library.Images[PreviewListView.SelectedIndices[0]].MaskImage; } } catch (Exception) { return; } }
private void OpenCSharpV2Library() { if (CSharpV2ImageLibrary != null) { CSharpV2ImageLibrary.Close(); } cbAction.Properties.Items.AddRange(Enum.GetValues(typeof(Common.MirAction)).Cast <Common.MirAction>().ToList()); ImageList.Images.Clear(); PreviewListView.SelectedIndices.Clear(); PreviewListView.Items.Clear(); _indexList.Clear(); switch (openType) { case Common.OpenType.Open: CSharpV2ImageLibrary = new FileStructures.MLibraryV2(FilePath); break; case Common.OpenType.New: CSharpV2ImageLibrary = new FileStructures.MLibraryV2(FilePath); CSharpV2ImageLibrary.Save(); break; case Common.OpenType.None: default: MessageBox.Show("Invalid Open Type."); this.Dispose(); break; } this.Text = System.IO.Path.GetFileName(FilePath); PreviewListView.VirtualListSize = CSharpV2ImageLibrary.Images.Count; PreviewListView.RedrawItems(0, PreviewListView.Items.Count - 1, true); if (PreviewListView.Items.Count > 0) { PreviewListView.Items[0].Selected = true; } lbImageCount.Caption = string.Format("Images: {0}", CSharpV2ImageLibrary.Images.Count); GC.Collect(); }
private void OpenWTLLibrary() { if (WTLLibrary != null) { WTLLibrary = null; } ImageList.Images.Clear(); PreviewListView.SelectedIndices.Clear(); PreviewListView.Items.Clear(); _indexList.Clear(); switch (openType) { case Common.OpenType.Open: WTLLibrary = new FileStructures.WTLLibrary(FilePath); break; case Common.OpenType.New: WTLLibrary = new FileStructures.WTLLibrary(FilePath); // WemadeLibrary.Save(); break; case Common.OpenType.None: default: MessageBox.Show("Invalid Open Type."); this.Dispose(); break; } this.Text = System.IO.Path.GetFileName(FilePath); PreviewListView.VirtualListSize = WTLLibrary.Images.Length; PreviewListView.RedrawItems(0, PreviewListView.Items.Count - 1, true); if (PreviewListView.Items.Count > 0) { PreviewListView.Items[0].Selected = true; } lbImageCount.Caption = string.Format("Images: {0}", WTLLibrary.Images.Length); GC.Collect(); }
private void Form1_DragDrop(object sender, DragEventArgs e) { return; //Not added yet string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (Path.GetExtension(files[0]).ToUpper() == ".WIL" || Path.GetExtension(files[0]).ToUpper() == ".WZL" || Path.GetExtension(files[0]).ToUpper() == ".MIZ") { try { ParallelOptions options = new ParallelOptions { MaxDegreeOfParallelism = 8 }; Parallel.For(0, files.Length, options, i => { if (Path.GetExtension(files[i]).ToUpper() == ".WTL") { WTLLibrary WTLlib = new WTLLibrary(files[i]); WTLlib.ToMLibrary(); } else { WeMadeLibrary WILlib = new WeMadeLibrary(files[i]); WILlib.ToMLibrary(); } toolStripProgressBar.Value++; }); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } toolStripProgressBar.Value = 0; MessageBox.Show( string.Format("Successfully converted {0} {1}", (OpenWeMadeDialog.FileNames.Length).ToString(), (OpenWeMadeDialog.FileNames.Length > 1) ? "libraries" : "library")); } else if (Path.GetExtension(files[0]).ToUpper() == ".LIB") { ClearInterface(); ImageList.Images.Clear(); PreviewListView.Items.Clear(); _indexList.Clear(); if (_library != null) { _library.Close(); } //_library = new MLibraryV2(files[0]); //PreviewListView.VirtualListSize = _library.Images.Count; PreviewListView.RedrawItems(0, PreviewListView.Items.Count - 1, true); // Show .Lib path in application title. this.Text = files[0].ToString(); } else { return; } }
private void workerRemoveBlack_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) { if (e.Cancelled) { MessageBox.Show("Preview Cancelled"); } else if (e.Error != null) { } else { this.Text = System.IO.Path.GetFileName(FilePath); _indexList.Clear(); switch (libraryType) { case Common.LibraryType.None: break; case Common.LibraryType.CSharpLibraryV1: break; case Common.LibraryType.CSharpLibraryV2: PreviewListView.VirtualListSize = CSharpV2ImageLibrary.Images.Count; try { PreviewListView.RedrawItems(0, PreviewListView.Items.Count - 1, true); Preview.Image = CSharpV2ImageLibrary.Images[PreviewListView.SelectedIndices[0]].Image; } catch (Exception) { return; } break; case Common.LibraryType.WeMadeLibrary: PreviewListView.VirtualListSize = WemadeLibrary.Images.Length; try { PreviewListView.RedrawItems(0, PreviewListView.Items.Count - 1, true); Preview.Image = WemadeLibrary.Images[PreviewListView.SelectedIndices[0]].Image; } catch (Exception) { return; } break; case Common.LibraryType.WTLLibrary: PreviewListView.VirtualListSize = WTLLibrary.Images.Length; try { PreviewListView.RedrawItems(0, PreviewListView.Items.Count - 1, true); Preview.Image = WTLLibrary.Images[PreviewListView.SelectedIndices[0]].Image; } catch (Exception) { return; } break; default: break; } } GC.Collect(); }