1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using System.Collections.Generic;
6
using System.ComponentModel;
7
using System.Windows.Controls;
8
using System.Windows.Media;
10
namespace SearchAndReplace
12
abstract class SearchNode : INotifyPropertyChanged
16
public bool IsExpanded {
17
get { return isExpanded; }
19
if (isExpanded != value) {
21
OnPropertyChanged("IsExpanded");
26
IEnumerable<SearchNode> children;
28
public IEnumerable<SearchNode> Children {
29
get { return children; }
31
if (children != value) {
33
OnPropertyChanged("Children");
38
// Text usually is a TextBlock object, so we don't want too many of them floating in memory
39
// (remember, we have a SearchNode for each search result, even for those in the search history).
40
// We don't want to create a new TextBlock for each property access, either; so we'll cache them
41
// using a WeakReference.
43
WeakReference cachedText;
48
if (cachedText != null) {
49
text = cachedText.Target;
53
text = CreateText() ?? string.Empty;
54
cachedText = new WeakReference(text);
59
protected abstract object CreateText();
61
protected void InvalidateText()
64
OnPropertyChanged("Text");
67
public event PropertyChangedEventHandler PropertyChanged;
69
protected virtual void OnPropertyChanged(string propertyName)
71
if (PropertyChanged != null) {
72
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
76
public virtual void ActivateItem()