//Search private void SearchBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { EmbFile.UpdateTextureFilter(); } }
private void EmbContextMenu_Paste_Click(object sender, RoutedEventArgs e) { try { List <EmbEntry> copiedTextures = (List <EmbEntry>)Clipboard.GetData(ClipboardDataTypes.EmbTexture); if (copiedTextures != null) { foreach (var texture in copiedTextures) { if (EmbFile.Entry.Count >= EMB_File.MAX_EFFECT_TEXTURES) { MessageBox.Show("The maximum amount of textures has been reached. Cannot add anymore.", "Duplicate", MessageBoxButton.OK, MessageBoxImage.Warning); return; } var newTexture = texture.Clone(); newTexture.Name = EmbFile.GetUnusedName(newTexture.Name); EmbFile.Add(newTexture); RefreshTextureCount(); } if (copiedTextures.Count > 0) { listBox_Textures.SelectedItem = EmbFile.Entry[EmbFile.Entry.Count - 1]; listBox_Textures.ScrollIntoView(EmbFile.Entry[EmbFile.Entry.Count - 1]); } } } catch (Exception ex) { parent.SaveExceptionLog(ex.ToString()); MessageBox.Show(String.Format("An error occured.\n\nDetails: {0}\n\nA log containing more details about the error was saved at \"{1}\".", ex.Message, GeneralInfo.ERROR_LOG_PATH), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void EmbContextMenu_Paste_Click(object sender, RoutedEventArgs e) { try { List <EmbEntry> copiedTextures = (List <EmbEntry>)Clipboard.GetData(ClipboardDataTypes.EmbTexture); if (copiedTextures != null) { List <IUndoRedo> undos = new List <IUndoRedo>(); foreach (var texture in copiedTextures) { if (EmbFile.Entry.Count >= EMB_File.MAX_EFFECT_TEXTURES) { MessageBox.Show("The maximum amount of textures has been reached. Cannot add anymore.", "Duplicate", MessageBoxButton.OK, MessageBoxImage.Warning); return; } var newTexture = texture.Clone(); newTexture.Name = EmbFile.GetUnusedName(newTexture.Name); EmbFile.Add(newTexture); RefreshTextureCount(); undos.Add(new UndoableListAdd <EmbEntry>(EmbFile.Entry, newTexture)); } if (copiedTextures.Count > 0) { listBox_Textures.SelectedItem = EmbFile.Entry[EmbFile.Entry.Count - 1]; listBox_Textures.ScrollIntoView(EmbFile.Entry[EmbFile.Entry.Count - 1]); undos.Add(new UndoActionDelegate(this, nameof(RefreshTextureCount), true)); UndoManager.Instance.AddUndo(new CompositeUndo(undos, "Texture Paste")); } } } catch (Exception ex) { parent.SaveExceptionLog(ex.ToString()); MessageBox.Show(String.Format("An error occured.\n\nDetails: {0}\n\nA log containing more details about the error was saved at \"{1}\".", ex.Message, SettingsManager.Instance.GetErrorLogPath()), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void ClearSearch_Click(object sender, RoutedEventArgs e) { EmbFile.TextureSearchFilter = string.Empty; EmbFile.UpdateTextureFilter(); }
private void Search_Click(object sender, RoutedEventArgs e) { EmbFile.UpdateTextureFilter(); }
//EMB Options private void EmbOptions_AddTexture_Click(object sender, RoutedEventArgs e) { List <IUndoRedo> undos = new List <IUndoRedo>(); //Validation if (EmbFile.Entry.Count >= EMB_File.MAX_EFFECT_TEXTURES) { MessageBox.Show(String.Format("The maximum allowed amount of textures has been reached. Cannot add anymore.", EMB_File.MAX_EFFECT_TEXTURES), "Error", MessageBoxButton.OK, MessageBoxImage.Stop); return; } //Add file OpenFileDialog openFile = new OpenFileDialog(); openFile.Title = "Add texture(s)..."; openFile.Filter = "DDS texture files | *.dds"; openFile.Multiselect = true; openFile.ShowDialog(this); int renameCount = 0; int added = 0; foreach (var file in openFile.FileNames) { if (File.Exists(file) && !String.IsNullOrWhiteSpace(file)) { if (System.IO.Path.GetExtension(file) != ".dds") { MessageBox.Show(String.Format("{0} is not a supported format.", System.IO.Path.GetExtension(file)), "Invalid Format", MessageBoxButton.OK, MessageBoxImage.Error); return; } byte[] bytes = File.ReadAllBytes(file); string fileName = System.IO.Path.GetFileName(file); EmbEntry newEntry = new EmbEntry(); newEntry.Data = bytes.ToList(); newEntry.Name = EmbFile.GetUnusedName(fileName); newEntry.LoadDds(); //Validat the emb again, so we dont go over the limit if (EmbFile.Entry.Count >= EMB_File.MAX_EFFECT_TEXTURES && IsForContainer) { MessageBox.Show(String.Format("The maximum allowed amount of textures has been reached. Cannot add anymore.\n\n{1} of the selected textures were added before the limit was reached.", EMB_File.MAX_EFFECT_TEXTURES, added), "Error", MessageBoxButton.OK, MessageBoxImage.Stop); return; } //Add the emb undos.Add(new UndoableListAdd <EmbEntry>(EmbFile.Entry, newEntry)); EmbFile.Entry.Add(newEntry); added++; if (newEntry.Name != fileName) { renameCount++; } } } undos.Add(new UndoActionDelegate(this, nameof(RefreshTextureCount), true)); RefreshTextureCount(); if (added > 0) { UndoManager.Instance.AddUndo(new CompositeUndo(undos, added > 1 ? "Add Textures" : "Add Texture")); } if (renameCount > 0) { MessageBox.Show(String.Format("{0} texture(s) were renamed during the add process because textures already existed in the EMB with the same name.", renameCount), "Add Texture", MessageBoxButton.OK, MessageBoxImage.Information); } }