|
@@ -0,0 +1,78 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using System.Windows;
|
|
|
+using System.Windows.Controls;
|
|
|
+using System.Windows.Data;
|
|
|
+using System.Windows.Documents;
|
|
|
+using System.Windows.Input;
|
|
|
+using System.Windows.Media;
|
|
|
+using System.Windows.Media.Imaging;
|
|
|
+using System.Windows.Navigation;
|
|
|
+using System.Windows.Shapes;
|
|
|
+
|
|
|
+namespace PixiEditor.Views
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// Interaction logic for EditableTextBlock.xaml
|
|
|
+ /// </summary>
|
|
|
+ public partial class EditableTextBlock : UserControl
|
|
|
+ {
|
|
|
+ public EditableTextBlock()
|
|
|
+ {
|
|
|
+ InitializeComponent();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public Visibility TextBlockVisibility
|
|
|
+ {
|
|
|
+ get { return (Visibility)GetValue(TextBlockVisibilityProperty); }
|
|
|
+ set { SetValue(TextBlockVisibilityProperty, value); }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Using a DependencyProperty as the backing store for TextBlockVisibility. This enables animation, styling, binding, etc...
|
|
|
+ public static readonly DependencyProperty TextBlockVisibilityProperty =
|
|
|
+ DependencyProperty.Register("TextBlockVisibility", typeof(Visibility), typeof(EditableTextBlock), new PropertyMetadata(Visibility.Visible));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc...
|
|
|
+ public static readonly DependencyProperty TextProperty =
|
|
|
+ DependencyProperty.Register("Text", typeof(string), typeof(EditableTextBlock), new PropertyMetadata(default(string)));
|
|
|
+
|
|
|
+ public string Text
|
|
|
+ {
|
|
|
+ get { return (string)GetValue(TextProperty); }
|
|
|
+ set { SetValue(TextProperty, value); }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e)
|
|
|
+ {
|
|
|
+ if(e.ClickCount == 2)
|
|
|
+ {
|
|
|
+ TextBlockVisibility = Visibility.Hidden;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void TextBox_KeyDown(object sender, KeyEventArgs e)
|
|
|
+ {
|
|
|
+ if(e.Key == Key.Enter)
|
|
|
+ {
|
|
|
+ TextBlockVisibility = Visibility.Visible;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void TextBox_LostFocus(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ TextBlockVisibility = Visibility.Visible;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void textBox_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
|
|
|
+ {
|
|
|
+ TextBlockVisibility = Visibility.Visible;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|