added SSCLI 1.0
[windows-sources.git] / sdk / samples / WPFSamples / WPFNotepad / csharp / finddialog.xaml.cs
blob34b9abddc8de58111f02f304f814c248f5db9dfe
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
12 using System;
13 using System.Windows;
14 using System.Windows.Controls;
16 public partial class FindDialog : Window
18 #region public Constructors
20 //------------------------------------------------------
22 // public Constructors
24 //------------------------------------------------------
26 public FindDialog()
28 InitializeComponent();
29 _findNext.IsEnabled = _replace.IsEnabled = _replaceAll.IsEnabled = !string.IsNullOrEmpty(_findWhat.Text);
32 #endregion public Constructors
35 #region public Properties
37 //------------------------------------------------------
39 // public Properties
41 //------------------------------------------------------
43 public string FindWhat
45 get { return _findWhat.Text; }
46 set
48 _findWhat.Text = value;
51 public string ReplaceWith
53 get { return _replaceWith.Text; }
54 set
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; }
64 set
66 Visibility toBe;
67 if (value)
69 toBe = Visibility.Visible;
70 _directionGroupBox.Visibility = Visibility.Collapsed;
71 _findDown.IsChecked = true;
73 else
75 toBe = Visibility.Collapsed;
76 _directionGroupBox.Visibility = Visibility.Visible;
78 _replaceLabel.Visibility = _replaceWith.Visibility = _replace.Visibility = _replaceAll.Visibility = toBe;
82 #endregion public Properties
85 #region public Events
87 //------------------------------------------------------
89 // public Events
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 //------------------------------------------------------
104 // private Methods
106 //------------------------------------------------------
108 void FindNextClicked(object sender, RoutedEventArgs e)
110 if(FindNext != null)
112 FindNext(this, EventArgs.Empty);
116 void ReplaceClicked(object sender, RoutedEventArgs e)
118 if(Replace != null)
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)
134 Close();
137 void OnActivated(object sender, EventArgs e)
139 _findWhat.Focus();
142 void FindTextChanged(object sender, TextChangedEventArgs e)
144 _findNext.IsEnabled = _replace.IsEnabled = _replaceAll.IsEnabled =!string.IsNullOrEmpty(_findWhat.Text);
147 #endregion private Methods