/// <summary> /// Loads character resources from another application whose /// data formats are supported by this one. /// </summary> /// <param name="path"></param> public void LoadCharacterResourcesInterop(String path) { Boolean hasState = true; using (CharaBlocker cb = new CharaBlocker(this)) { // Load Resources and reflect them on UI Interop.CharaxDirHelper interopHelper = new Interop.CharaxDirHelper(path); using (MemoryStream tmp = new MemoryStream()) { interopHelper.GenerateDescriptor(tmp); tmp.Position = 0; resourceManager = CharacterResourceManager.FromXML(tmp); } // Set up bitmap loader with root at path dir resourceManager.FileSystemProxy = new DefaultFileSystemProxy(Path.GetDirectoryName(path)); ReloadResourceManager(); ResetSelection(); UpdateColorProcessorList(); cmbColorProcessors.SelectedIndex = 0; // If there is a saved state, restore it as well // Here we usa a FileSystemProxy because we have no idea whether // the state is stored on a file or a package Stream state = resourceManager.FileSystemProxy.GetSavedStateStream(); if (state != null) { LoadCharacterFromStream(state, false); state.Dispose(); } else { ResetSelection(); resourceManager.Processors.Clear(); UpdateColorProcessorList(); hasState = false; } // Reflect color processors on the UI UpdateColorProcessorList(); // Reload Chara Set List ReloadPropertyListView((CharaSetGroup)cmbCharaProp.SelectedItem); // Generate Layer Adjustment values foreach (CharaSetGroup csg in resourceManager) { if (!csg.Multiselect) continue; GenerateLayerAdjustments(csg); } // Maintain CharaBlocker instance cb.DummyMethod(); } miTools.Enabled = false; if (!hasState) UpdateCharacterPreviewAsync(); DebugHelper.DebugPrint("Successfully loaded Legacy: {0}", resourceManager.Name); }
private void Menu_AddLegacyParts(object sender, EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() != System.Windows.Forms.DialogResult.Cancel) { Interop.CharaxDirHelper helper = new Interop.CharaxDirHelper(fbd.SelectedPath, resourceManager); CharacterResourceManager patchmgr; using (MemoryStream ms = new MemoryStream()) { helper.GenerateDescriptor(ms); ms.Position = 0; patchmgr = CharacterResourceManager.FromXML(ms); } patchmgr.FileSystemProxy = new DefaultFileSystemProxy(fbd.SelectedPath); resourceManager.Merge(patchmgr); ReloadResourceManager(); } }