1 /*******************************************************************************
3 * Copyright (c) 2004-2005 Microsoft Corporation. All rights reserved.
5 * Description: The FindDialog class defines dialog UI for the find command
7 *******************************************************************************/
10 namespace Microsoft
.Samples
.WPFNotepad
14 using System
.Windows
.Controls
;
16 public partial class FindDialog
: Window
18 #region public Constructors
20 //------------------------------------------------------
22 // public Constructors
24 //------------------------------------------------------
28 InitializeComponent();
29 _findNext
.IsEnabled
= _replace
.IsEnabled
= _replaceAll
.IsEnabled
= !string.IsNullOrEmpty(_findWhat
.Text
);
32 #endregion public Constructors
35 #region public Properties
37 //------------------------------------------------------
41 //------------------------------------------------------
43 public string FindWhat
45 get { return _findWhat.Text; }
48 _findWhat
.Text
= value;
51 public string ReplaceWith
53 get { return _replaceWith.Text; }
56 _replaceWith
.Text
= value;
59 public bool? MatchCase { get { return _matchCase.IsChecked; }
}
60 public bool? SearchUp { get { return _findUp.IsChecked; }
}
62 public bool ShowReplace
{
63 get { return _replaceWith.Visibility == Visibility.Visible; }
69 toBe
= Visibility
.Visible
;
70 _directionGroupBox
.Visibility
= Visibility
.Collapsed
;
71 _findDown
.IsChecked
= true;
75 toBe
= Visibility
.Collapsed
;
76 _directionGroupBox
.Visibility
= Visibility
.Visible
;
78 _replaceLabel
.Visibility
= _replaceWith
.Visibility
= _replace
.Visibility
= _replaceAll
.Visibility
= toBe
;
82 #endregion public Properties
87 //------------------------------------------------------
91 //------------------------------------------------------
93 public event EventHandler FindNext
;
94 public event EventHandler Replace
;
95 public event EventHandler ReplaceAll
;
97 #endregion public Events
100 #region private Methods
102 //------------------------------------------------------
106 //------------------------------------------------------
108 void FindNextClicked(object sender
, RoutedEventArgs e
)
112 FindNext(this, EventArgs
.Empty
);
116 void ReplaceClicked(object sender
, RoutedEventArgs e
)
120 Replace(this, EventArgs
.Empty
);
124 void ReplaceAllClicked(object sender
, RoutedEventArgs e
)
126 if(ReplaceAll
!= null)
128 ReplaceAll(this, EventArgs
.Empty
);
132 void CancelClicked(object sender
, RoutedEventArgs e
)
137 void OnActivated(object sender
, EventArgs e
)
142 void FindTextChanged(object sender
, TextChangedEventArgs e
)
144 _findNext
.IsEnabled
= _replace
.IsEnabled
= _replaceAll
.IsEnabled
=!string.IsNullOrEmpty(_findWhat
.Text
);
147 #endregion private Methods