Пример #1
0
        internal string GetExpressionEditorType(string localSetting, object root, FrameworkName targetFramework)
        {
            string expressionEditorType = null;

            if (targetFramework.Is45OrHigher())
            {
                //1) check local setting of ETB
                if (expressionEditorType == null)
                {
                    expressionEditorType = localSetting;
                }
                //2) check global setting on root object of the XAML
                if (expressionEditorType == null && root != null)
                {
                    expressionEditorType = ExpressionEditor.GetExpressionActivityEditor(root);
                }

                //3) for all the other cases, always load VB editor for backward compatibility
                if (expressionEditorType == null)
                {
                    expressionEditorType = VisualBasicEditor.ExpressionLanguageName;
                }
            }
            else
            {
                //When the targeting framework is less than 4.5, always load VB editor
                expressionEditorType = VisualBasicEditor.ExpressionLanguageName;
            }

            return(expressionEditorType);
        }
Пример #2
0
        protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            switch (e.Property.Name)
            {
            case "ExpressionActivityEditor":
                ExpressionEditor.ValidateExpressionActivityEditorName((string)e.NewValue);
                break;

            case "HintText":
                if (!this.isHintTextSetInternally)
                {
                    this.HintTextSetbyUser = (string)e.NewValue;
                }
                break;

            case "InternalHintText":
                this.isHintTextSetInternally = true;
                this.HintText = this.InternalHintText;
                this.isHintTextSetInternally = false;
                break;
            }
            base.OnPropertyChanged(e);
        }
Пример #3
0
        internal void InitializeEditor(ExpressionActivityEditor editor, ExpressionTextBox expressionTextBox)
        {
            if (editor != null)
            {
                expressionTextBox.InitializeHintText(editor.HintText);
                expressionTextBox.InternalHintText = expressionTextBox.HintText;
                SetBinding("InternalHintText", ExpressionActivityEditor.HintTextProperty, editor, expressionTextBox, BindingMode.TwoWay);
                SetBinding("IsSupportedExpression", ExpressionActivityEditor.IsSupportedExpressionProperty, editor, expressionTextBox, BindingMode.OneWayToSource, null);
                SetBinding("HorizontalScrollBarVisibility", ExpressionActivityEditor.HorizontalScrollBarVisibilityProperty, editor, expressionTextBox);
                SetBinding("VerticalScrollBarVisibility", ExpressionActivityEditor.VerticalScrollBarVisibilityProperty, editor, expressionTextBox);
                SetBinding("AcceptsReturn", ExpressionActivityEditor.AcceptsReturnProperty, editor, expressionTextBox);
                SetBinding("AcceptsTab", ExpressionActivityEditor.AcceptsTabProperty, editor, expressionTextBox);
                SetBinding("Expression", ExpressionActivityEditor.ExpressionProperty, editor, expressionTextBox, BindingMode.TwoWay, new Collection<ValidationRule> { new ExpressionValidationRule(expressionTextBox) });
                SetBinding("ExpressionType", ExpressionActivityEditor.ExpressionTypeProperty, editor, expressionTextBox);
                SetBinding("OwnerActivity", ExpressionActivityEditor.OwnerActivityProperty, editor, expressionTextBox);
                SetBinding("UseLocationExpression", ExpressionActivityEditor.UseLocationExpressionProperty, editor, expressionTextBox);
                SetBinding("PathToArgument", ExpressionActivityEditor.PathToArgumentProperty, editor, expressionTextBox);
                SetBinding("IsReadOnly", ExpressionActivityEditor.IsReadOnlyProperty, editor, expressionTextBox);
                SetBinding("ExplicitCommit", ExpressionActivityEditor.ExplicitCommitProperty, editor, expressionTextBox);
                SetBinding("ClipToBounds", ExpressionActivityEditor.ClipToBoundsProperty, editor, expressionTextBox);

                TextualExpressionEditor textEditor = editor as TextualExpressionEditor;
                if (textEditor != null)
                {
                    SetBinding("MaxLines", TextualExpressionEditor.MaxLinesProperty, textEditor, expressionTextBox);
                    SetBinding("MinLines", TextualExpressionEditor.MinLinesProperty, textEditor, expressionTextBox);
                    SetBinding("DefaultValue", TextualExpressionEditor.DefaultValueProperty, textEditor, expressionTextBox);
                }

                SetBinding("IsIndependentExpression", ExpressionActivityEditor.IsIndependentExpressionProperty, editor, expressionTextBox);
            }
        }
Пример #4
0
 internal IExpressionEditorService GetExpressionService(ExpressionActivityEditor editor)
 {
     TextualExpressionEditor textualEditor = editor as TextualExpressionEditor;
     if (textualEditor != null)
     {
         return textualEditor.ExpressionEditorService;
     }
     else
     {
         return null;
     }
 }
Пример #5
0
        internal bool TryCreateEditor(string expressionEditorName, out ExpressionActivityEditor editorInstance)
        {
            editorInstance = null;
            if (expressionEditorName == null)
            {
                throw FxTrace.Exception.AsError(new ArgumentNullException(expressionEditorName));
            }

            if (!ExpressionEditorTypeTable.Keys.Contains(expressionEditorName))
            {
                return false;
            }
            Type expressionEditorType = ExpressionEditorTypeTable[expressionEditorName];
            editorInstance = Activator.CreateInstance(expressionEditorType) as ExpressionActivityEditor;
            return true;
        }
Пример #6
0
        void LoadInnerControl(string editorName)
        {
            if (editorName != this.currentEditorName)
            {

                ExpressionActivityEditor newEditor;
                if (this.ViewModel.TryCreateEditor(editorName, out newEditor))
                {
                    if ((this.IsInlinePropertyEditor) && !(newEditor is TextualExpressionEditor))
                    {
                        InitializeHintText(null);
                        this.editor = null;
                        this.currentEditorName = null;
                        this.Content = null;
                        this.ContentTemplate = this.FindResource("disabledInlineEditingTemplate") as DataTemplate;
                    }
                    else
                    {
                        this.currentEditorName = editorName;
                        this.editor = newEditor;
                        this.Content = this.editor;
                        this.ContentTemplate = null;
                        if (this.IsLoaded)
                        {
                            this.InitializeChildEditor();
                        }
                    }
                }
                else
                {
                    this.UnsupportedEditorMessage = string.Format(CultureInfo.CurrentUICulture, SR.NonRegisteredExpressionEditor, editorName);
                    InitializeHintText(null);
                    this.editor = null;
                    this.currentEditorName = null;
                    this.Content = null;
                    this.ContentTemplate = this.FindResource("unsupportedEditorTemplate") as DataTemplate;
                }
            }
        }