public bool OpenFile(string fileName) { bool result = true; // if fileName is null, then this is a reload bool reload = false; if (string.IsNullOrEmpty(fileName)) { reload = true; fileName = docPkg.FilePath; } // close current file if any CloseFile(); // open the package docPkg = new DocumentPackage(); if (!docPkg.Open(fileName)) { result = false; } else { // update the tree RefreshTree(); // reload any open view if (reload) { ReloadAllViews(); IsModified = false; } } return result; }
public void CloseFile() { // clear the tree view treeView.Nodes.Clear(); // clear history history.Clear(); curHistory = null; // update command state this.buttonBack.Enabled = false; this.buttonForward.Enabled = false; this.buttonHistory.Enabled = true; // close the document if (docPkg == null) return; docPkg.Close(); docPkg = null; }