private void ContextMenu_HueAdjustment_Click(object sender, RoutedEventArgs e) { #if !DEBUG try #endif { var material = dataGrid.SelectedItem as Material; if (material != null) { RecolorAll recolor = new RecolorAll(material, this); if (recolor.Initialize()) { recolor.ShowDialog(); } } } #if !DEBUG 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); } #endif }
private void EmbContextMenu_Replace_Click(object sender, RoutedEventArgs e) { try { var texture = listBox_Textures.SelectedItem as EmbEntry; if (texture != null) { OpenFileDialog openFile = new OpenFileDialog(); openFile.Title = "Replace texture..."; openFile.Filter = "DDS texture files | *.dds"; openFile.Multiselect = false; openFile.ShowDialog(this); if (File.Exists(openFile.FileName) && !String.IsNullOrWhiteSpace(openFile.FileName)) { List <IUndoRedo> undos = new List <IUndoRedo>(); byte[] bytes = File.ReadAllBytes(openFile.FileName); string name = System.IO.Path.GetFileName(openFile.FileName); if (name != texture.Name) { string newName = container.File3_Ref.GetUnusedName(name); undos.Add(new UndoableProperty <EmbEntry>(nameof(texture.Name), texture, texture.Name, newName)); texture.Name = newName; } var newData = bytes.ToList(); undos.Add(new UndoableProperty <EmbEntry>(nameof(texture.Data), texture, texture.Data, newData)); texture.Data = newData; if (texture.Name != name) { MessageBox.Show(String.Format("The new texture was automatically renamed because \"{0}\" was already used.", name), "Rename", MessageBoxButton.OK, MessageBoxImage.Information); } UndoManager.Instance.AddUndo(new CompositeUndo(undos, "Replace Texture")); } } } 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); } }