From 4d9f1f2fbe2222e257a4b12cdf2dd4a8487bce75 Mon Sep 17 00:00:00 2001 From: JohnnyBravo75 Date: Wed, 30 Jul 2014 22:01:03 +0200 Subject: [PATCH] Current changes, to be in sync --- SharpDevelop.userprefs | 16 ++ .../Project/CSharpBinding.csproj | 5 - .../OutlinePad/CSharpOutlineContentHost.xaml | 2 +- .../OutlinePad/ExtensionMethods.cs | 51 ++++ .../XamlOutlineContentHost.xaml | 4 +- .../OutlinePad/XamlOutlineContentHost.xaml.cs | 263 ++++++++++++++++++ .../{ => OutlinePad}/XamlOutlineNode.cs | 22 +- .../XamlBinding/XamlBinding.csproj | 14 +- .../XamlOutlineContentHost.xaml.cs | 134 --------- .../Project/FormsDesigner.csproj | 1 - .../ICSharpCode.Reporting.csproj | 1 - 11 files changed, 361 insertions(+), 152 deletions(-) create mode 100644 SharpDevelop.userprefs create mode 100644 src/AddIns/BackendBindings/XamlBinding/XamlBinding/OutlinePad/ExtensionMethods.cs rename src/AddIns/BackendBindings/XamlBinding/XamlBinding/{ => OutlinePad}/XamlOutlineContentHost.xaml (75%) create mode 100644 src/AddIns/BackendBindings/XamlBinding/XamlBinding/OutlinePad/XamlOutlineContentHost.xaml.cs rename src/AddIns/BackendBindings/XamlBinding/XamlBinding/{ => OutlinePad}/XamlOutlineNode.cs (83%) delete mode 100644 src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlOutlineContentHost.xaml.cs diff --git a/SharpDevelop.userprefs b/SharpDevelop.userprefs new file mode 100644 index 0000000000..80bb0c2385 --- /dev/null +++ b/SharpDevelop.userprefs @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj index 00a094c92b..663ee85d07 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj @@ -256,11 +256,6 @@ ICSharpCode.SharpDevelop.Widgets False - - {8035765F-D51F-4A0C-A746-2FD100E19419} - ICSharpCode.SharpDevelop.Widgets - False - {9E951B9F-6AC2-4537-9D0B-0AE7C026D5A1} FormsDesigner diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineContentHost.xaml b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineContentHost.xaml index bda20483ed..b8fa41b195 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineContentHost.xaml +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OutlinePad/CSharpOutlineContentHost.xaml @@ -9,5 +9,5 @@ AllowDropOrder="True" MouseDoubleClick="TreeViewMouseDoubleClick" MouseLeftButtonUp="TreeView_MouseLeftButtonUp" - /> + /> \ No newline at end of file diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/OutlinePad/ExtensionMethods.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/OutlinePad/ExtensionMethods.cs new file mode 100644 index 0000000000..a8fdd936d5 --- /dev/null +++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/OutlinePad/ExtensionMethods.cs @@ -0,0 +1,51 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using ICSharpCode.NRefactory; + +namespace ICSharpCode.XamlBinding +{ + /// + /// Description of TextLocationExtensions. + /// + static class TextLocationExtensions { + + public static bool IsInfinite(this TextLocation location) { + return location == null || location.Line == int.MaxValue || location.Column == int.MaxValue; + } + + public static bool IsValid(this TextLocation location) { + if (location.IsEmpty) + return false; + if (location.IsInfinite()) + return false; + return true; + } + + public static bool IsInside(this TextLocation location, TextLocation startLocation, TextLocation endLocation) { + if (location.IsEmpty) + return false; + + return location.Line >= startLocation.Line && + (location.Line <= endLocation.Line || endLocation.Line == -1) && + (location.Line != startLocation.Line || location.Column >= startLocation.Column) && + (location.Line != endLocation.Line || location.Column <= endLocation.Column); + } + } +} diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlOutlineContentHost.xaml b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/OutlinePad/XamlOutlineContentHost.xaml similarity index 75% rename from src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlOutlineContentHost.xaml rename to src/AddIns/BackendBindings/XamlBinding/XamlBinding/OutlinePad/XamlOutlineContentHost.xaml index 55d8591cd9..3a1d4b93b8 100644 --- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlOutlineContentHost.xaml +++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/OutlinePad/XamlOutlineContentHost.xaml @@ -7,5 +7,7 @@ x:Name="treeView" AllowDrop="True" AllowDropOrder="True" - MouseDoubleClick="TreeViewMouseDoubleClick" /> + MouseDoubleClick="TreeViewMouseDoubleClick" + MouseLeftButtonUp="TreeView_MouseLeftButtonUp" + /> \ No newline at end of file diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/OutlinePad/XamlOutlineContentHost.xaml.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/OutlinePad/XamlOutlineContentHost.xaml.cs new file mode 100644 index 0000000000..019358d61d --- /dev/null +++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/OutlinePad/XamlOutlineContentHost.xaml.cs @@ -0,0 +1,263 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.IO; +using System.Linq; +using System.Windows.Controls; +using System.Windows.Forms; +using System.Windows.Input; +using System.Windows.Threading; +using ICSharpCode.Core; +using ICSharpCode.NRefactory.Xml; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Editor; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Parser; +using ICSharpCode.NRefactory; + + +namespace ICSharpCode.XamlBinding +{ + /// + /// Interaction logic for XamlOutlineContentHost.xaml + /// + public partial class XamlOutlineContentHost : DockPanel, IOutlineContentHost, IDisposable + { + ITextEditor editor; + DispatcherTimer updateTreeTimer = new DispatcherTimer(); + const double updateDelayMilliseconds = 500; + DispatcherTimer scrollToNodeTimer = new DispatcherTimer(); + const double scrollDelayMilliseconds = 200; + AXmlDocument document; + TextLocation? lastCaretLocation; + XamlOutlineNode selectedNode = null; + const bool optionSelectActiveTreeNode = true; + const bool optionSelectRange = false; + + public XamlOutlineContentHost(ITextEditor editor) + { + this.editor = editor; + this.editor.Caret.LocationChanged += CaretLocationChanged; + + InitializeComponent(); + + SD.ParserService.ParseInformationUpdated += ParseInfoUpdated; + + this.updateTreeTimer.Interval = TimeSpan.FromMilliseconds(updateDelayMilliseconds); + this.updateTreeTimer.Tick += this.UpdateTreeTimer_Tick; + + this.scrollToNodeTimer.Interval = TimeSpan.FromMilliseconds(scrollDelayMilliseconds); + this.scrollToNodeTimer.Tick += this.ScrollToNodeTimer_Tick; + } + + void ParseInfoUpdated(object sender, ParseInformationEventArgs e) + { + if (this.editor == null || !FileUtility.IsEqualFileName(this.editor.FileName, e.FileName)) + return; + + var parseInfo = e.NewParseInformation as XamlFullParseInformation; + if (parseInfo != null && parseInfo.Document != null) { + this.updateTreeTimer.Stop(); + this.document = parseInfo.Document; + this.updateTreeTimer.Start(); + } + } + + void CaretLocationChanged(object sender, EventArgs e) + { + SelectActiveTreeNode(); + } + + void SelectActiveTreeNode() { + if (!optionSelectActiveTreeNode) + return; + // prevent unnecessary looping, when both CaretLocationChanged and ParseUpdateChanged are fired. + if (this.lastCaretLocation.HasValue && this.lastCaretLocation == this.editor.Caret.Location) + return; + + this.lastCaretLocation = this.editor.Caret.Location; + selectedNode = null; + FindNodeFromLocation(this.editor.Caret.Location, treeView.Root as XamlOutlineNode); + if (selectedNode != null && treeView.SelectedItem != selectedNode) { + treeView.SelectedItem = selectedNode; + if (!scrollToNodeTimer.IsEnabled) { + scrollToNodeTimer.Start(); + } + } + } + + bool IsRangeInside(TextLocation outerStartLocation, TextLocation outerEndLocation, + TextLocation innerStartLocation, TextLocation innerEndLocation) { + if (outerStartLocation.IsEmpty || outerStartLocation.IsInfinite() || + outerEndLocation.IsEmpty || outerEndLocation.IsInfinite() || + innerStartLocation.IsEmpty || innerStartLocation.IsInfinite() || + innerEndLocation.IsEmpty || innerEndLocation.IsInfinite()) + return false; + + const int virtualLineLength = 200; + var outerRange = (outerEndLocation.Line - outerStartLocation.Line) * virtualLineLength - outerStartLocation.Column + outerEndLocation.Column; + var innerRange = (innerEndLocation.Line - innerStartLocation.Line) * virtualLineLength - innerStartLocation.Column + innerEndLocation.Column; + return innerRange < outerRange; + } + + void FindNodeFromLocation(TextLocation location, XamlOutlineNode node) { + if (node == null) + return; + if (node.StartMarker.IsDeleted || node.EndMarker.IsDeleted) + return; + + if (location.IsInside(node.StartMarker.Location, node.EndMarker.Location) + && (selectedNode == null || IsRangeInside(selectedNode.StartLocation, selectedNode.EndLocation, + node.StartLocation, node.EndLocation))) { + selectedNode = node; + } + + foreach(var child in node.Children) { + FindNodeFromLocation(location, child as XamlOutlineNode); + } + } + + void UpdateTreeTimer_Tick(Object sender, EventArgs args) { + this.updateTreeTimer.Stop(); + this.UpdateTree(this.document); + this.SelectActiveTreeNode(); + } + + void ScrollToNodeTimer_Tick(Object sender, EventArgs args) { + this.scrollToNodeTimer.Stop(); + if (selectedNode != null) { + treeView.ScrollIntoView(selectedNode); + } + } + + void UpdateTree(AXmlDocument root) + { + if (treeView.Root == null) { + treeView.Root = new XamlOutlineNode { + ElementName = "Document Root", + Name = Path.GetFileName(editor.FileName), + Editor = editor + }; + } + + UpdateNode(treeView.Root as XamlOutlineNode, root); + } + + void UpdateNode(XamlOutlineNode node, AXmlObject dataNode) + { + if (dataNode == null || node == null) + return; + int textLength = Math.Max(editor.Document.TextLength - 1,0); + if (dataNode is AXmlElement) { + var item = (AXmlElement)dataNode; + node.Name = item.GetAttributeValue("Name") ?? item.GetAttributeValue(XamlConst.XamlNamespace, "Name"); + node.ElementName = item.Name; + } + node.StartMarker = editor.Document.CreateAnchor(Utils.MinMax(dataNode.StartOffset, 0, textLength)); + node.EndMarker = editor.Document.CreateAnchor(Utils.MinMax(dataNode.EndOffset, 0, textLength)); + node.StartLocation = new TextLocation(node.StartMarker.Line, node.StartMarker.Column); + node.EndLocation = new TextLocation(node.EndMarker.Line, node.EndMarker.Column); + + var dataChildren = dataNode.Children.OfType().ToList(); + + int childrenCount = node.Children.Count; + int dataCount = dataChildren.Count; + + for (int i = 0; i < Math.Max(childrenCount, dataCount); 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(AXmlElement item) + { + XamlOutlineNode node = new XamlOutlineNode { + Name = item.GetAttributeValue("Name") ?? item.GetAttributeValue(XamlConst.XamlNamespace, "Name"), + ElementName = item.Name, + StartMarker = 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)), + Editor = editor, + XmlNodeItem = item + }; + + node.StartLocation = new TextLocation(node.StartMarker.Line, node.StartMarker.Column); + node.EndLocation = new TextLocation(node.EndMarker.Line, node.EndMarker.Column); + node.IsExpanded = true; + + foreach (var child in item.Children.OfType()) + node.Children.Add(BuildNode(child)); + + return node; + } + + void TreeView_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + var node = treeView.SelectedItem as XamlOutlineNode; + if (node == null) + return; + + if (optionSelectRange) + editor.Select(node.StartMarker.Offset, node.EndMarker.Offset - node.StartMarker.Offset); + FileService.JumpToFilePosition(this.editor.FileName, node.StartMarker.Line, node.StartMarker.Column); + } + + void TreeViewMouseDoubleClick(object sender, MouseButtonEventArgs e) + { +// XamlOutlineNode node = treeView.SelectedItem as XamlOutlineNode; +// if (node == null) return; +// editor.Select(node.StartMarker.Offset, node.EndMarker.Offset - node.StartMarker.Offset); + } + + public object OutlineContent { + get { return this; } + } + + public void Dispose() { + SD.ParserService.ParseInformationUpdated -= ParseInfoUpdated; + + if (this.editor != null) { + if (this.editor.Caret != null) + this.editor.Caret.LocationChanged -= CaretLocationChanged; + this.editor = null; + } + + this.document = null; + this.lastCaretLocation = null; + this.selectedNode = null; + + if (this.updateTreeTimer != null) { + this.updateTreeTimer.Stop(); + this.updateTreeTimer.Tick -= this.UpdateTreeTimer_Tick; + this.updateTreeTimer = null; + } + + if (this.scrollToNodeTimer != null) { + this.scrollToNodeTimer.Stop(); + this.scrollToNodeTimer.Tick -= this.ScrollToNodeTimer_Tick; + this.scrollToNodeTimer = null; + } + } + } +} diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlOutlineNode.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/OutlinePad/XamlOutlineNode.cs similarity index 83% rename from src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlOutlineNode.cs rename to src/AddIns/BackendBindings/XamlBinding/XamlBinding/OutlinePad/XamlOutlineNode.cs index 495b3a533e..2224a8bf3c 100644 --- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlOutlineNode.cs +++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/OutlinePad/XamlOutlineNode.cs @@ -24,6 +24,8 @@ using ICSharpCode.NRefactory.Editor; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.TreeView; +using ICSharpCode.NRefactory.Xml; +using ICSharpCode.NRefactory; namespace ICSharpCode.XamlBinding { @@ -47,13 +49,20 @@ namespace ICSharpCode.XamlBinding } } - public ITextAnchor Marker { get; set; } + public override object ToolTip { + get { return this.GetSourceText(); } + } + + public ITextAnchor StartMarker { get; set; } public ITextAnchor EndMarker { get; set; } public ITextEditor Editor { get; set; } + public AXmlElement XmlNodeItem { get; set; } + public TextLocation StartLocation { get; set; } + public TextLocation EndLocation { get; set; } public string GetMarkupText() { - return Editor.Document.GetText(Marker.Offset, EndMarker.Offset - Marker.Offset); + return Editor.Document.GetText(StartMarker.Offset, EndMarker.Offset - StartMarker.Offset); } protected override IDataObject GetDataObject(SharpTreeNode[] nodes) @@ -96,6 +105,13 @@ namespace ICSharpCode.XamlBinding // } // } + public string GetSourceText() { + if (StartMarker.IsDeleted || EndMarker.IsDeleted) + return string.Empty; + + return Editor.Document.GetText(StartMarker.Offset, EndMarker.Offset - StartMarker.Offset); + } + public override bool CanDelete(SharpTreeNode[] nodes) { return nodes.OfType().All(n => n.Parent != null); @@ -115,7 +131,7 @@ namespace ICSharpCode.XamlBinding void DeleteCore() { - Editor.Document.Remove(Marker.Offset, EndMarker.Offset - Marker.Offset); + Editor.Document.Remove(StartMarker.Offset, EndMarker.Offset - StartMarker.Offset); } public override object Text { diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlBinding.csproj b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlBinding.csproj index b42dc3f77d..6d36e9c995 100644 --- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlBinding.csproj +++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlBinding.csproj @@ -66,6 +66,12 @@ + + + XamlOutlineContentHost.xaml + Code + + @@ -109,11 +115,6 @@ - - XamlOutlineContentHost.xaml - Code - - {53DCA265-3C3C-42F9-B647-F72BA678122B} @@ -172,10 +173,11 @@ + - + \ No newline at end of file diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlOutlineContentHost.xaml.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlOutlineContentHost.xaml.cs deleted file mode 100644 index dc8fb4c0b3..0000000000 --- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlOutlineContentHost.xaml.cs +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this -// software and associated documentation files (the "Software"), to deal in the Software -// without restriction, including without limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -// to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -using System; -using System.IO; -using System.Linq; -using System.Windows.Controls; -using System.Windows.Input; - -using ICSharpCode.Core; -using ICSharpCode.NRefactory.Xml; -using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Editor; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.SharpDevelop.Parser; - -namespace ICSharpCode.XamlBinding -{ - /// - /// Interaction logic for XamlOutlineContentHost.xaml - /// - public partial class XamlOutlineContentHost : DockPanel, IOutlineContentHost, IDisposable - { - ITextEditor editor; - - public XamlOutlineContentHost(ITextEditor editor) - { - this.editor = editor; - - InitializeComponent(); - - SD.ParserService.ParseInformationUpdated += ParseInfoUpdated; - } - - void ParseInfoUpdated(object sender, ParseInformationEventArgs e) - { - if (this.editor == null || !FileUtility.IsEqualFileName(this.editor.FileName, e.FileName)) - return; - - var parseInfo = e.NewParseInformation as XamlFullParseInformation; - if (parseInfo != null && parseInfo.Document != null) - UpdateTree(parseInfo.Document); - } - - void UpdateTree(AXmlDocument root) - { - if (treeView.Root == null) { - treeView.Root = new XamlOutlineNode { - ElementName = "Document Root", - Name = Path.GetFileName(editor.FileName), - Editor = editor - }; - } - - UpdateNode(treeView.Root as XamlOutlineNode, root); - } - - void UpdateNode(XamlOutlineNode node, AXmlObject dataNode) - { - if (dataNode == null || node == null) - return; - if (dataNode is AXmlElement) { - var item = (AXmlElement)dataNode; - node.Name = item.GetAttributeValue("Name") ?? item.GetAttributeValue(XamlConst.XamlNamespace, "Name"); - node.ElementName = item.Name; - } - 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)); - - var dataChildren = dataNode.Children.OfType().ToList(); - - int childrenCount = node.Children.Count; - int dataCount = dataChildren.Count; - - for (int i = 0; i < Math.Max(childrenCount, dataCount); 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(AXmlElement item) - { - XamlOutlineNode node = new XamlOutlineNode { - Name = item.GetAttributeValue("Name") ?? item.GetAttributeValue(XamlConst.XamlNamespace, "Name"), - ElementName = item.Name, - 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)), - Editor = editor - }; - - foreach (var child in item.Children.OfType()) - node.Children.Add(BuildNode(child)); - - return node; - } - - void TreeViewMouseDoubleClick(object sender, MouseButtonEventArgs e) - { - XamlOutlineNode node = treeView.SelectedItem as XamlOutlineNode; - if (node == null) return; - editor.Select(node.Marker.Offset, node.EndMarker.Offset - node.Marker.Offset); - } - - public object OutlineContent { - get { return this; } - } - - public void Dispose() - { - SD.ParserService.ParseInformationUpdated -= ParseInfoUpdated; - } - } -} diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj b/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj index 366aa3a811..1b41ab422d 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj @@ -54,7 +54,6 @@ - diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj index 707962a862..0ec76d2f32 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj @@ -198,7 +198,6 @@ -