diff --git a/src/Application/FormMain.cs b/src/Application/FormMain.cs index 3dfc4fab..bc696270 100644 --- a/src/Application/FormMain.cs +++ b/src/Application/FormMain.cs @@ -169,6 +169,7 @@ public FormMain(SettingsLocation location) this.ContextMenuStrip = this.contextMenu1; New(); + this.xsltViewer.Visible = false; if (!testing) { _ = AsyncSetup(); @@ -736,11 +737,13 @@ protected virtual void TabControlViews_Selected(object sender, NoBorderTabContro { this.helpProvider1.HelpNamespace = this._helpService.XsltHelp; this.CheckWebViewVersion(); + this.xsltViewer.Visible = true; this.DisplayXsltResults(); } else { this.helpProvider1.HelpNamespace = this._helpService.DefaultHelp; + this.xsltViewer.Visible = false; this.xsltViewer.OnClosed(); // good time to cleanup temp files. } } diff --git a/src/XmlNotepad/NodeTextView.cs b/src/XmlNotepad/NodeTextView.cs index 4b4a1f63..26752763 100644 --- a/src/XmlNotepad/NodeTextView.cs +++ b/src/XmlNotepad/NodeTextView.cs @@ -1127,6 +1127,7 @@ class AccessibleNodeTextViewNode : AccessibleObject private TreeNode _node; private NodeTextView _view; private AccessibleNodeTextView _acc; + private int _childCount = -1; public AccessibleNodeTextViewNode(AccessibleNodeTextView acc, TreeNode node) { @@ -1159,11 +1160,17 @@ public override string Description } public override void DoDefaultAction() { + _childCount = -1; _node.Toggle(); } public override int GetChildCount() { - return _node.Children.Count; + if (_childCount == -1) + { + // This can be VERY slow as it populates the children right here! + _childCount = _node.Children.Count; + } + return _childCount; } public override AccessibleObject GetChild(int index) { diff --git a/src/XmlNotepad/TreeView.cs b/src/XmlNotepad/TreeView.cs index 93f490cc..722b1f47 100644 --- a/src/XmlNotepad/TreeView.cs +++ b/src/XmlNotepad/TreeView.cs @@ -1685,9 +1685,10 @@ internal void DrawLabel2(Graphics g, Font f) internal static TreeNodeCollection GetChildren(TreeNode n) { - if (n.Children.Count > 0) + var children = n.Children; + if (children.Count > 0) { - return n.Children; + return children; } return null; } diff --git a/src/XmlNotepad/XmlTreeView.cs b/src/XmlNotepad/XmlTreeView.cs index 1b3465dd..ff2bdf51 100644 --- a/src/XmlNotepad/XmlTreeView.cs +++ b/src/XmlNotepad/XmlTreeView.cs @@ -1810,6 +1810,7 @@ public class XmlTreeNode : TreeNode, IXmlTreeNode private string _editLabel; private string _schemaAwareText; private Color _schemaAwareColor; + private TreeNodeCollection _lazyChildren; public XmlTreeNode(XmlTreeView view) { @@ -2062,7 +2063,11 @@ public override TreeNodeCollection Children { get { - return new XmlTreeNodeCollection(this); + if (this._lazyChildren == null) + { + this._lazyChildren = new XmlTreeNodeCollection(this); + } + return _lazyChildren; } } diff --git a/src/XmlNotepad/XsltViewer.cs b/src/XmlNotepad/XsltViewer.cs index 1f2eb3b5..5f422875 100644 --- a/src/XmlNotepad/XsltViewer.cs +++ b/src/XmlNotepad/XsltViewer.cs @@ -213,7 +213,7 @@ void OnModelChanged(ModelChangedEventArgs e) { this.SourceFileName.Text = _model.XsltFileName; } - if (e.ModelChangeType == ModelChangeType.Reloaded) + if (e.ModelChangeType == ModelChangeType.Reloaded && this.Visible) { this.delayedActions.StartDelayedAction("UpdateXslt", DisplayXsltResults, TimeSpan.FromSeconds(0.5)); }