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

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

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