private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof(vm.File): chunkList.UpdateList(); break; case nameof(vm.SelectedChunks): if (propertyWindow == null || propertyWindow.IsDisposed) { propertyWindow = new frmChunkProperties(vm); propertyWindow.Show(FormPanel, DockState.DockRight); } if (vm.SelectedChunks.Count > 0) { if (vm.SelectedChunks.First().data is CBitmapTexture xbm) { if (ImageViewer == null || ImageViewer.IsDisposed) { ImageViewer = new frmImagePreview(); ImageViewer.Show(FormPanel, DockState.Document); } ImageViewer.SetImage(vm.SelectedChunks.First()); } } break; } }
public frmImagePreview ShowImagePreview() { if (ImagePreview == null || ImagePreview.IsDisposed) { ImagePreview = new frmImagePreview(); ImagePreview.Show(dockPanel, DockState.Document); } ImagePreview.Activate(); return(ImagePreview); }
/// <summary> /// /// </summary> /// <param name="filename"></param> /// <param name="openrenderer"></param> public void PostLoadFile(string filename = "", bool openrenderer = false) { #region SetupFile // Backgroundwork Start Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); switch (Path.GetExtension(filename)) { case ".w2scene": case ".w2quest": case ".w2phase": { //this.flowDiagram = new frmChunkFlowDiagram(); //this.flowDiagram.OnOutput += MainController.LogString; //this.flowDiagram.File = this.File; //this.flowDiagram.DockAreas = DockAreas.Document; //this.flowDiagram.OnSelectChunk += this.frmCR2WDocument_OnSelectChunk; //this.flowDiagram.Show(this.FormPanel, DockState.Document); break; } case ".journal": { this.JournalEditor = new frmJournalEditor { File = this.File, DockAreas = DockAreas.Document }; this.JournalEditor.Show(this.FormPanel, DockState.Document); break; } case ".xbm": { this.ImageViewer = new frmImagePreview { DockAreas = DockAreas.Document }; this.ImageViewer.Show(this.FormPanel, DockState.Document); CR2WExportWrapper imagechunk = this.File?.Chunks?.FirstOrDefault(_ => _.data.REDType.Contains("CBitmapTexture")); this.ImageViewer.SetImage(imagechunk); break; } case ".redswf": { CR2WExportWrapper imagechunk = this.File?.Chunks?.FirstOrDefault(_ => _.data is CBitmapTexture); if (imagechunk != null) { this.ImageViewer = new frmImagePreview { DockAreas = DockAreas.Document }; this.ImageViewer.Show(this.FormPanel, DockState.Document); this.ImageViewer.SetImage(imagechunk); } break; } case ".w2mesh": { if (openrenderer) { try { // add all dependencies MockKernel.Get().Window.PauseMonitoring(); WccHelper.AddAllImports(filename, true, false); MockKernel.Get().Window.ResumeMonitoring(); this.RenderViewer = new Render.frmRender { LoadDocument = LoadDocumentAndGetFile, MeshFile = this.File, DockAreas = DockAreas.Document, renderHelper = new Render.RenderHelper(MainController.Get().ActiveMod, MainController.Get().Logger) }; this.RenderViewer.Show(this.FormPanel, DockState.Document); } catch (Exception ex) { MainController.LogString(ex.ToString(), Logtype.Error); } } break; } default: { break; } } var output = new StringBuilder(); if (this.File.UnknownTypes.Any()) { //ShowConsole(); //ShowOutput(); output.Append(this.FileName + ": contains " + this.File.UnknownTypes.Count + " unknown type(s):\n"); foreach (var unk in this.File.UnknownTypes) { output.Append("\"" + unk + "\", \n"); } output.Append("-------\n\n"); } var hasUnknownBytes = false; foreach (var t in this.File.Chunks.Where(t => t.unknownBytes?.Bytes != null && t.unknownBytes.Bytes.Length > 0)) { output.Append(t.REDName + " contains " + t.unknownBytes.Bytes.Length + " unknown bytes. \n"); hasUnknownBytes = true; } if (hasUnknownBytes) { output.Append("-------\n\n"); } //output.Append($"CR2WFile {filename} loaded in: {stopwatch.Elapsed}\n\n"); stopwatch.Stop(); MainController.LogString(output.ToString(), Logtype.Important); #endregion CR2WFile LoadDocumentAndGetFile(string path) { throw new NotImplementedException(); //foreach (var t in MockKernel.Get().GetMainViewModel().OpenDocuments.Where(_ => _.File is CR2WFile).Where(t => t.FileName == path)) // return t.File as CR2WFile; ////var activedoc = vm.OpenDocuments.FirstOrDefault(d => d.IsActivated); //var doc2 = LoadDocument(path) as frmCR2WDocument; ////activedoc.Activate(); //return doc2?.File; } }