1 //----------------------------------------------------------------
2 // <copyright company="Microsoft Corporation">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //----------------------------------------------------------------
7 namespace System.Activities.Presentation.Annotations
9 using System.Activities.Presentation.Model;
10 using System.ComponentModel;
12 using System.Windows.Controls;
13 using System.Windows.Data;
14 using System.Windows.Input;
16 internal sealed partial class FloatingAnnotationView : UserControl, IFloatingAnnotation
18 public static readonly DependencyProperty ModelItemProperty = DependencyProperty.Register("ModelItem", typeof(ModelItem), typeof(FloatingAnnotationView));
20 public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.Register("IsReadOnly", typeof(bool), typeof(FloatingAnnotationView));
22 private bool focusOnLoad;
24 public FloatingAnnotationView()
26 this.InitializeComponent();
27 this.Loaded += new RoutedEventHandler(this.OnFloatingAnnotationViewLoaded);
30 public event Action DockButtonClicked;
32 public event EventHandler IsMouseOverChanged
36 DependencyPropertyDescriptor descriptor = DependencyPropertyDescriptor.FromProperty(UIElement.IsMouseOverProperty, typeof(UIElement));
37 descriptor.AddValueChanged(this, value);
42 DependencyPropertyDescriptor descriptor = DependencyPropertyDescriptor.FromProperty(UIElement.IsMouseOverProperty, typeof(UIElement));
43 descriptor.RemoveValueChanged(this, value);
47 public bool IsReadOnly
49 get { return (bool)GetValue(IsReadOnlyProperty); }
50 set { SetValue(IsReadOnlyProperty, value); }
53 public ModelItem ModelItem
55 get { return (ModelItem)GetValue(ModelItemProperty); }
56 set { SetValue(ModelItemProperty, value); }
59 public void FocusOnContent()
61 if (this.annotationTextBox.Focus() != true)
63 this.focusOnLoad = true;
67 public void UpdateModelItem()
69 BindingExpression be = this.annotationTextBox.GetBindingExpression(TextBox.TextProperty);
73 protected override void OnContextMenuOpening(ContextMenuEventArgs e)
78 private void OnFloatingAnnotationViewLoaded(object sender, RoutedEventArgs e)
82 Keyboard.Focus(this.annotationTextBox);
83 this.focusOnLoad = false;
87 private void OnDockButtonClicked(object sender, RoutedEventArgs e)
89 if (this.DockButtonClicked != null)
91 this.DockButtonClicked();