|
@@ -7,19 +7,24 @@ using PixiEditor.Models.Controllers.Shortcuts;
|
|
|
namespace PixiEditor.Views
|
|
|
{
|
|
|
/// <summary>
|
|
|
- /// Interaction logic for EditableTextBlock.xaml
|
|
|
+ /// Interaction logic for EditableTextBlock.xaml.
|
|
|
/// </summary>
|
|
|
public partial class EditableTextBlock : UserControl
|
|
|
{
|
|
|
// 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),
|
|
|
+ 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),
|
|
|
+ DependencyProperty.Register(
|
|
|
+ "Text",
|
|
|
+ typeof(string),
|
|
|
+ typeof(EditableTextBlock),
|
|
|
new PropertyMetadata(default(string)));
|
|
|
|
|
|
// Using a DependencyProperty as the backing store for EnableEditing. This enables animation, styling, binding, etc...
|
|
@@ -38,14 +43,12 @@ namespace PixiEditor.Views
|
|
|
set => SetValue(TextBlockVisibilityProperty, value);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public bool IsEditing
|
|
|
{
|
|
|
get => (bool) GetValue(EnableEditingProperty);
|
|
|
set => SetValue(EnableEditingProperty, value);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public string Text
|
|
|
{
|
|
|
get => (string) GetValue(TextProperty);
|
|
@@ -80,12 +83,18 @@ namespace PixiEditor.Views
|
|
|
|
|
|
private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
- if (e.ChangedButton == MouseButton.Left && e.ClickCount == 2) EnableEditing();
|
|
|
+ if (e.ChangedButton == MouseButton.Left && e.ClickCount == 2)
|
|
|
+ {
|
|
|
+ EnableEditing();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void TextBox_KeyDown(object sender, KeyEventArgs e)
|
|
|
{
|
|
|
- if (e.Key == Key.Enter) DisableEditing();
|
|
|
+ if (e.Key == Key.Enter)
|
|
|
+ {
|
|
|
+ DisableEditing();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void TextBox_LostFocus(object sender, RoutedEventArgs e)
|