Browse Source

XamlOutlineContentHost now recreates outline tree only if the ParseInformation has been updated and not every 2 seconds

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5648 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 15 years ago
parent
commit
d11184a05c
  1. 7
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlLanguageBinding.cs
  2. 16
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlOutlineContentHost.xaml.cs

7
src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlLanguageBinding.cs

@ -21,6 +21,7 @@ namespace ICSharpCode.XamlBinding @@ -21,6 +21,7 @@ namespace ICSharpCode.XamlBinding
{
XamlColorizer colorizer;
TextView textView;
XamlOutlineContentHost contentHost;
public override void Attach(ITextEditor editor)
{
@ -38,7 +39,8 @@ namespace ICSharpCode.XamlBinding @@ -38,7 +39,8 @@ namespace ICSharpCode.XamlBinding
// attach the colorizer
textView.LineTransformers.Add(colorizer);
// add the XamlOutlineContentHost, which manages the tree view
textView.Services.AddService(typeof(IOutlineContentHost), new XamlOutlineContentHost(editor));
contentHost = new XamlOutlineContentHost(editor);
textView.Services.AddService(typeof(IOutlineContentHost), contentHost);
}
// add ILanguageBinding
textView.Services.AddService(typeof(XamlLanguageBinding), this);
@ -50,12 +52,13 @@ namespace ICSharpCode.XamlBinding @@ -50,12 +52,13 @@ namespace ICSharpCode.XamlBinding
base.Detach();
// if we added something before
if (textView != null && colorizer != null) {
if (textView != null && colorizer != null && contentHost != null) {
// remove and dispose everything we added
textView.LineTransformers.Remove(colorizer);
textView.Services.RemoveService(typeof(IOutlineContentHost));
textView.Services.RemoveService(typeof(XamlLanguageBinding));
colorizer.Dispose();
contentHost.Dispose();
}
}
}

16
src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlOutlineContentHost.xaml.cs

@ -20,10 +20,9 @@ namespace ICSharpCode.XamlBinding @@ -20,10 +20,9 @@ namespace ICSharpCode.XamlBinding
/// <summary>
/// Interaction logic for XamlOutlineContentHost.xaml
/// </summary>
public partial class XamlOutlineContentHost : DockPanel, IOutlineContentHost
public partial class XamlOutlineContentHost : DockPanel, IOutlineContentHost, IDisposable
{
ITextEditor editor;
DispatcherTimer timer;
public XamlOutlineContentHost(ITextEditor editor)
{
@ -31,14 +30,10 @@ namespace ICSharpCode.XamlBinding @@ -31,14 +30,10 @@ namespace ICSharpCode.XamlBinding
InitializeComponent();
this.timer = new DispatcherTimer(DispatcherPriority.Background, this.Dispatcher);
this.timer.Tick += new EventHandler(XamlOutlineContentHostTick);
this.timer.Interval = new TimeSpan(0, 0, 2);
this.timer.Start();
ParserService.ParseInformationUpdated += ParseInfoUpdated;
}
void XamlOutlineContentHostTick(object sender, EventArgs e)
void ParseInfoUpdated(object sender, EventArgs e)
{
if (this.editor == null || string.IsNullOrEmpty(this.editor.FileName))
return;
@ -114,5 +109,10 @@ namespace ICSharpCode.XamlBinding @@ -114,5 +109,10 @@ namespace ICSharpCode.XamlBinding
return this;
}
}
public void Dispose()
{
ParserService.ParseInformationUpdated -= ParseInfoUpdated;
}
}
}
Loading…
Cancel
Save