~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnterTextBox.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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)
 
3
 
 
4
using System;
 
5
using System.Collections.Generic;
 
6
using System.Linq;
 
7
using System.Text;
 
8
using System.Windows.Controls;
 
9
using System.Windows.Input;
 
10
using System.Windows.Data;
 
11
using System.Windows;
 
12
 
 
13
namespace ICSharpCode.WpfDesign.Designer.Controls
 
14
{
 
15
        public class EnterTextBox : TextBox
 
16
        {
 
17
                protected override void OnKeyDown(KeyEventArgs e)
 
18
                {
 
19
                        if (e.Key == Key.Enter) {
 
20
                                var b = BindingOperations.GetBindingExpressionBase(this, TextProperty);
 
21
                                if (b != null) {
 
22
                                        b.UpdateSource();
 
23
                                }
 
24
                                SelectAll();
 
25
                        }
 
26
                        else if (e.Key == Key.Escape) {
 
27
                                var b = BindingOperations.GetBindingExpressionBase(this, TextProperty);
 
28
                                if (b != null) {
 
29
                                        b.UpdateTarget();
 
30
                                }
 
31
                        }
 
32
                }
 
33
        }
 
34
}