public void OpenFile(string filePath) { Reset(); bool errorsOccured = false; INode node = null; try { node = NodeFactory.Create(filePath); } catch { errorsOccured = true; } if (errorsOccured || !typeof(IBinaryFile).IsAssignableFrom(node.DataType)) { MessageBox.Show("File could not be opened.", "Miku Miku Model", MessageBoxButtons.OK, MessageBoxIcon.Error); node?.Dispose(); return; } node.Exported += OnNodeExported; var treeNode = new NodeAsTreeNode(node); { mNodeTreeView.Nodes.Add(treeNode); } treeNode.Expand(); mCurrentlyOpenFilePath = filePath; mSaveToolStripMenuItem.Enabled = true; mSaveAsToolStripMenuItem.Enabled = true; mCloseToolStripMenuItem.Enabled = true; SetTitle(Path.GetFileName(filePath)); }
public TextureSelectForm(INode textureSetNode) { InitializeComponent(); if (StyleSet.CurrentStyle != null) { StyleHelpers.ApplyStyle(this, StyleSet.CurrentStyle); } Icon = ResourceStore.LoadIcon("Icons/Application.ico"); var rootNode = new ReferenceNode(textureSetNode); var nodeAsTreeNode = new NodeAsTreeNode(rootNode); mNodeTreeView.Nodes.Add(nodeAsTreeNode); nodeAsTreeNode.Expand(); nodeAsTreeNode.Nodes[0].Expand(); }
public void OpenFile(string filePath) { Enabled = false; try { Reset(); #if DEBUG var node = NodeFactory.Create(filePath); #else INode node = null; string exceptionMessage = null; try { node = NodeFactory.Create(filePath); } catch (Exception exception) { exceptionMessage = exception.Message; } if (node != null && !typeof(IBinaryFile).IsAssignableFrom(node.DataType)) { exceptionMessage = "File type could not be determined."; } if (node == null || !string.IsNullOrEmpty(exceptionMessage)) { MessageBox.Show($"Failed to open {Path.GetFileName( filePath )}.\nReason: {exceptionMessage}", Program.Name, MessageBoxButtons.OK, MessageBoxIcon.Error); Enabled = true; return; } #endif SetSubscription(node); node.Exported += OnNodeExported; var treeNode = new NodeAsTreeNode(node); { mNodeTreeView.Nodes.Add(treeNode); } treeNode.Expand(); if (node is FarcArchiveNode && node.Nodes.Count > 0) { mNodeTreeView.SelectedNode = treeNode.Nodes[0] as NodeAsTreeNode; } mCurrentlyOpenFilePath = filePath; mSaveToolStripMenuItem.Enabled = true; mSaveAsToolStripMenuItem.Enabled = true; mCloseToolStripMenuItem.Enabled = true; SetTitle(); } finally { Enabled = true; } }