1 //------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //------------------------------------------------------------
5 namespace System.Activities.Presentation.Expressions
8 using System.Collections.Generic;
11 using System.Windows.Controls;
12 using System.Activities.Presentation.Model;
15 using System.Windows.Automation.Peers;
16 using System.Diagnostics.CodeAnalysis;
18 using System.Globalization;
20 public abstract class ExpressionActivityEditor : UserControl
22 public static readonly DependencyProperty HintTextProperty = DependencyProperty.Register("HintText", typeof(string), typeof(ExpressionActivityEditor));
24 public static readonly DependencyProperty ExpressionProperty = DependencyProperty.Register("Expression", typeof(ModelItem), typeof(ExpressionActivityEditor),
25 new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
27 public static readonly DependencyProperty ExpressionTypeProperty = DependencyProperty.Register("ExpressionType", typeof(Type), typeof(ExpressionActivityEditor),
28 new FrameworkPropertyMetadata(null));
30 public static readonly DependencyProperty OwnerActivityProperty = DependencyProperty.Register("OwnerActivity", typeof(ModelItem), typeof(ExpressionActivityEditor),
31 new FrameworkPropertyMetadata(null));
33 public static readonly DependencyProperty UseLocationExpressionProperty = DependencyProperty.Register("UseLocationExpression", typeof(bool), typeof(ExpressionActivityEditor),
34 new FrameworkPropertyMetadata(false));
36 public static readonly DependencyProperty PathToArgumentProperty = DependencyProperty.Register("PathToArgument", typeof(string), typeof(ExpressionActivityEditor),
37 new FrameworkPropertyMetadata(null));
39 public static readonly DependencyProperty IsSupportedExpressionProperty = DependencyProperty.Register("IsSupportedExpression", typeof(bool), typeof(ExpressionActivityEditor),
40 new FrameworkPropertyMetadata(true));
42 public static readonly DependencyProperty VerticalScrollBarVisibilityProperty = DependencyProperty.Register("VerticalScrollBarVisibility", typeof(ScrollBarVisibility), typeof(ExpressionActivityEditor),
43 new FrameworkPropertyMetadata(ScrollBarVisibility.Hidden));
45 public static readonly DependencyProperty HorizontalScrollBarVisibilityProperty = DependencyProperty.Register("HorizontalScrollBarVisibility", typeof(ScrollBarVisibility), typeof(ExpressionActivityEditor),
46 new FrameworkPropertyMetadata(ScrollBarVisibility.Hidden));
48 public static readonly DependencyProperty ExplicitCommitProperty = DependencyProperty.Register("ExplicitCommit", typeof(bool), typeof(ExpressionActivityEditor),
49 new FrameworkPropertyMetadata(false));
51 public static readonly DependencyProperty AcceptsReturnProperty = DependencyProperty.Register("AcceptsReturn", typeof(bool), typeof(ExpressionActivityEditor),
52 new FrameworkPropertyMetadata(true));
54 public static readonly DependencyProperty AcceptsTabProperty = DependencyProperty.Register("AcceptsTab", typeof(bool), typeof(ExpressionActivityEditor),
55 new FrameworkPropertyMetadata(false));
57 public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.Register("IsReadOnly", typeof(bool), typeof(ExpressionActivityEditor),
58 new FrameworkPropertyMetadata(false));
60 public static readonly DependencyProperty IsIndependentExpressionProperty = DependencyProperty.Register("IsIndependentExpression", typeof(bool), typeof(ExpressionActivityEditor),
61 new FrameworkPropertyMetadata(false));
63 public string HintText
65 get { return (string)GetValue(HintTextProperty); }
66 set { SetValue(HintTextProperty, value); }
69 [Fx.Tag.KnownXamlExternal]
70 public ModelItem Expression
72 get { return (ModelItem)GetValue(ExpressionProperty); }
73 set { SetValue(ExpressionProperty, value); }
76 public Type ExpressionType
78 get { return (Type)GetValue(ExpressionTypeProperty); }
79 set { SetValue(ExpressionTypeProperty, value); }
82 public bool UseLocationExpression
84 get { return (bool)GetValue(UseLocationExpressionProperty); }
85 set { SetValue(UseLocationExpressionProperty, value); }
88 public bool IsIndependentExpression
90 get { return (bool)GetValue(IsIndependentExpressionProperty); }
91 set { SetValue(IsIndependentExpressionProperty, value); }
94 [Fx.Tag.KnownXamlExternal]
95 public ModelItem OwnerActivity
97 get { return (ModelItem)GetValue(OwnerActivityProperty); }
98 set { SetValue(OwnerActivityProperty, value); }
101 public string PathToArgument
103 get { return (string)GetValue(PathToArgumentProperty); }
104 set { SetValue(PathToArgumentProperty, value); }
107 public bool IsSupportedExpression
109 get { return (bool)GetValue(IsSupportedExpressionProperty); }
110 set { SetValue(IsSupportedExpressionProperty, value); }
113 public bool AcceptsReturn
115 get { return (bool)GetValue(AcceptsReturnProperty); }
116 set { SetValue(AcceptsReturnProperty, value); }
119 public bool AcceptsTab
121 get { return (bool)GetValue(AcceptsTabProperty); }
122 set { SetValue(AcceptsTabProperty, value); }
125 public bool IsReadOnly
127 get { return (bool)GetValue(IsReadOnlyProperty); }
128 set { SetValue(IsReadOnlyProperty, value); }
131 public ScrollBarVisibility VerticalScrollBarVisibility
133 get { return (ScrollBarVisibility)GetValue(VerticalScrollBarVisibilityProperty); }
134 set { SetValue(VerticalScrollBarVisibilityProperty, value); }
137 public ScrollBarVisibility HorizontalScrollBarVisibility
139 get { return (ScrollBarVisibility)GetValue(HorizontalScrollBarVisibilityProperty); }
140 set { SetValue(HorizontalScrollBarVisibilityProperty, value); }
143 public bool ExplicitCommit
145 get { return (bool)GetValue(ExplicitCommitProperty); }
146 set { SetValue(ExplicitCommitProperty, value); }
149 static AttachableMemberIdentifier editorPropertyID = new AttachableMemberIdentifier(typeof(ExpressionActivityEditor), "ExpressionActivityEditor");
151 public static void SetExpressionActivityEditor(object target, string name)
153 ValidateExpressionActivityEditorName(name);
154 AttachablePropertyServices.SetProperty(target, editorPropertyID, name);
157 public static string GetExpressionActivityEditor(object target)
160 return AttachablePropertyServices.TryGetProperty(target, editorPropertyID, out value) ? value : null;
163 internal static void ValidateExpressionActivityEditorName(string name)
165 if (name != null && name.Trim().Length == 0)
167 throw FxTrace.Exception.AsError(new ArgumentException(string.Format(CultureInfo.CurrentUICulture, SR.InvalidExpressionEditorNameToSet,
172 internal string ItemStatus
176 return this.OnCreateAutomationPeer().GetItemStatus();
180 protected EditingContext Context
184 if (this.OwnerActivity != null)
186 return this.OwnerActivity.GetEditingContext();
195 protected ExpressionActivityEditor()
198 public virtual void BeginEdit() { }
199 public virtual bool CanCommit() { return true; }
200 public abstract bool Commit(bool isExplicitCommit);