|
|
@ -2,10 +2,13 @@ |
|
|
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
|
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System; |
|
|
|
|
|
|
|
using System.IO; |
|
|
|
|
|
|
|
using System.Linq; |
|
|
|
using System.Windows.Controls; |
|
|
|
using System.Windows.Controls; |
|
|
|
using System.Windows.Input; |
|
|
|
using System.Windows.Input; |
|
|
|
|
|
|
|
|
|
|
|
using ICSharpCode.Core; |
|
|
|
using ICSharpCode.Core; |
|
|
|
|
|
|
|
using ICSharpCode.NRefactory.Xml; |
|
|
|
using ICSharpCode.SharpDevelop; |
|
|
|
using ICSharpCode.SharpDevelop; |
|
|
|
using ICSharpCode.SharpDevelop.Editor; |
|
|
|
using ICSharpCode.SharpDevelop.Editor; |
|
|
|
using ICSharpCode.SharpDevelop.Gui; |
|
|
|
using ICSharpCode.SharpDevelop.Gui; |
|
|
@ -34,56 +37,64 @@ namespace ICSharpCode.XamlBinding |
|
|
|
if (this.editor == null || !FileUtility.IsEqualFileName(this.editor.FileName, e.FileName)) |
|
|
|
if (this.editor == null || !FileUtility.IsEqualFileName(this.editor.FileName, e.FileName)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
#warning Reimplement XAML outline
|
|
|
|
var parseInfo = e.NewParseInformation as XamlFullParseInformation; |
|
|
|
// var cu = e.NewSyntaxTree as XamlSyntaxTree;
|
|
|
|
if (parseInfo != null && parseInfo.Document != null) |
|
|
|
//
|
|
|
|
UpdateTree(parseInfo.Document); |
|
|
|
// if (cu != null && cu.TreeRootNode != null)
|
|
|
|
|
|
|
|
// UpdateTree(cu.TreeRootNode);
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UpdateTree(NodeWrapper root) |
|
|
|
void UpdateTree(AXmlDocument root) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (this.treeView.Root == null) |
|
|
|
if (treeView.Root == null) { |
|
|
|
this.treeView.Root = BuildNode(root); |
|
|
|
treeView.Root = new XamlOutlineNode { |
|
|
|
else |
|
|
|
ElementName = "Document Root", |
|
|
|
UpdateNode(this.treeView.Root as XamlOutlineNode, root); |
|
|
|
Name = Path.GetFileName(editor.FileName), |
|
|
|
|
|
|
|
Editor = editor |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UpdateNode(treeView.Root as XamlOutlineNode, root); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UpdateNode(XamlOutlineNode node, NodeWrapper dataNode) |
|
|
|
void UpdateNode(XamlOutlineNode node, AXmlObject dataNode) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (dataNode != null && node != null) { |
|
|
|
if (dataNode == null || node == null) |
|
|
|
node.Name = dataNode.Name; |
|
|
|
return; |
|
|
|
node.ElementName = dataNode.ElementName; |
|
|
|
if (dataNode is AXmlElement) { |
|
|
|
node.Marker = editor.Document.CreateAnchor(Utils.MinMax(dataNode.StartOffset, 0, editor.Document.TextLength)); |
|
|
|
var item = (AXmlElement)dataNode; |
|
|
|
node.EndMarker = editor.Document.CreateAnchor(Utils.MinMax(dataNode.EndOffset, 0, editor.Document.TextLength)); |
|
|
|
node.Name = item.GetAttributeValue("Name") ?? item.GetAttributeValue(XamlConst.XamlNamespace, "Name"); |
|
|
|
|
|
|
|
node.ElementName = item.Name; |
|
|
|
int childrenCount = node.Children.Count; |
|
|
|
} |
|
|
|
int dataCount = dataNode.Children.Count; |
|
|
|
node.Marker = editor.Document.CreateAnchor(Utils.MinMax(dataNode.StartOffset, 0, editor.Document.TextLength)); |
|
|
|
|
|
|
|
node.EndMarker = editor.Document.CreateAnchor(Utils.MinMax(dataNode.EndOffset, 0, editor.Document.TextLength)); |
|
|
|
for (int i = 0; i < Math.Max(childrenCount, dataCount); i++) { |
|
|
|
|
|
|
|
if (i >= childrenCount) { |
|
|
|
var dataChildren = dataNode.Children.OfType<AXmlElement>().ToList(); |
|
|
|
node.Children.Add(BuildNode(dataNode.Children[i])); |
|
|
|
|
|
|
|
} else if (i >= dataCount) { |
|
|
|
int childrenCount = node.Children.Count; |
|
|
|
while (node.Children.Count > dataCount) |
|
|
|
int dataCount = dataChildren.Count; |
|
|
|
node.Children.RemoveAt(dataCount); |
|
|
|
|
|
|
|
} else { |
|
|
|
for (int i = 0; i < Math.Max(childrenCount, dataCount); i++) { |
|
|
|
UpdateNode(node.Children[i] as XamlOutlineNode, dataNode.Children[i]); |
|
|
|
if (i >= childrenCount) { |
|
|
|
} |
|
|
|
node.Children.Add(BuildNode(dataChildren[i])); |
|
|
|
|
|
|
|
} else if (i >= dataCount) { |
|
|
|
|
|
|
|
while (node.Children.Count > dataCount) |
|
|
|
|
|
|
|
node.Children.RemoveAt(dataCount); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
UpdateNode(node.Children[i] as XamlOutlineNode, dataChildren[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
XamlOutlineNode BuildNode(NodeWrapper item) |
|
|
|
XamlOutlineNode BuildNode(AXmlElement item) |
|
|
|
{ |
|
|
|
{ |
|
|
|
XamlOutlineNode node = new XamlOutlineNode() { |
|
|
|
XamlOutlineNode node = new XamlOutlineNode { |
|
|
|
Name = item.Name, |
|
|
|
Name = item.GetAttributeValue("Name") ?? item.GetAttributeValue(XamlConst.XamlNamespace, "Name"), |
|
|
|
ElementName = item.ElementName, |
|
|
|
ElementName = item.Name, |
|
|
|
Marker = editor.Document.CreateAnchor(Utils.MinMax(item.StartOffset, 0, editor.Document.TextLength - 1)), |
|
|
|
Marker = editor.Document.CreateAnchor(Utils.MinMax(item.StartOffset, 0, editor.Document.TextLength - 1)), |
|
|
|
EndMarker = editor.Document.CreateAnchor(Utils.MinMax(item.EndOffset, 0, editor.Document.TextLength - 1)), |
|
|
|
EndMarker = editor.Document.CreateAnchor(Utils.MinMax(item.EndOffset, 0, editor.Document.TextLength - 1)), |
|
|
|
Editor = editor |
|
|
|
Editor = editor |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
foreach (var child in item.Children) |
|
|
|
foreach (var child in item.Children.OfType<AXmlElement>()) |
|
|
|
node.Children.Add(BuildNode(child)); |
|
|
|
node.Children.Add(BuildNode(child)); |
|
|
|
|
|
|
|
|
|
|
|
return node; |
|
|
|
return node; |
|
|
@ -96,9 +107,7 @@ namespace ICSharpCode.XamlBinding |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public object OutlineContent { |
|
|
|
public object OutlineContent { |
|
|
|
get { |
|
|
|
get { return this; } |
|
|
|
return this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
public void Dispose() |
|
|
|