private void OnFileWatcherChanged(object sender, FileSystemEventArgs e) { string FileName = e.FullPath; Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType); var Result = MessageBox.Show("Texture has been modifed in external program! Would you like to apply the edits?", "Texture Editor", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); if (Result == DialogResult.Yes) { bool DecodeTextureBack = false; if (ActiveTexture.Platform.OutputFormat != FormatToChange) { ActiveTexture.Platform.OutputFormat = FormatToChange; DecodeTextureBack = true; } if (FileName.EndsWith(".dds")) { DDS dds = new DDS(FileName); if (dds.Platform.OutputFormat != ActiveTexture.Platform.OutputFormat) { DecodeTextureBack = true; } SaveAndApplyImage(dds.GetBitmap(), DecodeTextureBack); } else { SaveAndApplyImage(new Bitmap(FileName), DecodeTextureBack); } } else { FileWatcher.Filter = ""; FileWatcher.EnableRaisingEvents = false; } FileWatcher.Filter = ""; FileWatcher.EnableRaisingEvents = false; }
public void EditChannel(STChannelType ChannelType) { var Image = imageEditor.BaseImage; if (Image != null) { OpenFileDialog ofd = new OpenFileDialog(); ofd.FileName = Text; ofd.Filter = "Supported Formats|*.dds; *.png;*.tga;*.jpg;*.tiff|" + "Microsoft DDS |*.dds|" + "Portable Network Graphics |*.png|" + "Joint Photographic Experts Group |*.jpg|" + "Bitmap Image |*.bmp|" + "Tagged Image File Format |*.tiff|" + "All files(*.*)|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { Bitmap ImportedImage = null; string ext = Utils.GetExtension(ofd.FileName); if (ext == ".dds") { DDS dds = new DDS(ofd.FileName); ImportedImage = dds.GetBitmap(); } else if (ext == ".tga") { ImportedImage = Paloma.TargaImage.LoadTargaImage(ofd.FileName); } else { ImportedImage = new Bitmap(ofd.FileName); } Bitmap newImage = BitmapExtension.ReplaceChannel(Image, ImportedImage, ChannelType); imageEditor.SaveAndApplyImage(newImage, true, ext == ".dds"); } } }