private Document OpenDocument(DotaDataObject ddo) { Document doc = DocumentRegistry.GetDocumentFor(ddo); if (doc == null) { //If we don't have this document open, create it and add it to the registry doc = new DotaObjectDocument(ddo); DocumentRegistry.OpenDocument(ddo, doc); } return(doc); }
private void OpenTextEditor(DotaDataObject ddo) { Document doc = DocumentRegistry.GetDocumentFor(ddo); if (doc == null) { //If we don't have this document open, create it and add it to the registry doc = new DotaObjectDocument(ddo); DocumentRegistry.OpenDocument(ddo, doc); } (doc as DotaObjectDocument).OpenTextEditor(); }
private void treeView1_DoubleClick(object sender, EventArgs e) { TreeNode selectedNode = treeView1.SelectedNode; //The path of the file double clicked is stored in the treenode's tag string path = selectedNode.Tag as string; if (!CanOpenDocument(path)) { return; } TreeNode root = GetRootNode(selectedNode); bool FromVPK = root.Name == "vpk"; TextDocument document = DocumentRegistry.GetDocumentFor(path) as TextDocument; if (document == null) { document = new TextDocument(path, FromVPK); DocumentRegistry.OpenDocument(path, document); } document.OpenDefaultEditor(); }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode node = SelectedNode(); if (node == null) { return; } DotaDataObject ddo = node.Tag as DotaDataObject; if (ddo == null) { return; //It's a folder, we cant delete this. } if (ddo.ObjectInfo.ObjectClass == DotaDataObject.DataObjectInfo.ObjectDataClass.Default) { return; //Can't delete default objects } if (MessageBox.Show("Are you sure? This cannot be undone", "Delete Object", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { //Get the document for this and close the editors Document doc = DocumentRegistry.GetDocumentFor(ddo); if (doc != null) { doc.CloseAllEditors(false); } IList list = DotaData.FindListThatHasObject(ddo); list.Remove(ddo); //remove this node from the tree view node.Parent.Nodes.Remove(node); //And it's gone! } }