Esempio n. 1
0
        private void UpdateExpressionEditors()
        {
            AssemblyContextControlItem assemblies = this.Context.Items.GetValue <AssemblyContextControlItem>();
            IExpressionEditorService   expressionEditorService = this.Context.Services.GetService <IExpressionEditorService>();

            if (expressionEditorService != null)
            {
                expressionEditorService.UpdateContext(assemblies, this.importedNamespacesItem);
            }
        }
        void OnGotTextBlockFocus(object sender, RoutedEventArgs e)
        {
            if (this.Context == null)
            {
                return;
            }

            DesignerView designerView = this.Context.Services.GetService<DesignerView>();

            if (!designerView.IsMultipleSelectionMode)
            {
                TextBlock textBlock = sender as TextBlock;
                bool isInReadOnlyMode = this.IsReadOnly;
                if (this.Context != null)
                {
                    ReadOnlyState readOnlyState = this.Context.Items.GetValue<ReadOnlyState>();
                    isInReadOnlyMode |= readOnlyState.IsReadOnly;
                }
                if (null != textBlock)
                {
                    this.blockHeight = textBlock.ActualHeight;
                    this.blockHeight = Math.Max(this.blockHeight, textBlock.MinHeight);
                    this.blockHeight = Math.Min(this.blockHeight, textBlock.MaxHeight);
                    this.blockWidth = textBlock.ActualWidth;
                    this.blockWidth = Math.Max(this.blockWidth, textBlock.MinWidth);
                    this.blockWidth = Math.Min(this.blockWidth, textBlock.MaxWidth);

                    // If it's already an editor, don't need to switch it/reload it (don't create another editor/grid if we don't need to)
                    // Also don't create editor when we are in read only mode
                    if (this.ContentTemplate.Equals((DataTemplate)FindResource("textblock")) && !isInReadOnlyMode)
                    {
                        if (this.Context != null)
                        {
                            // Get the ExpressionEditorService
                            this.expressionEditorService = this.Context.Services.GetService<IExpressionEditorService>();
                        }

                        // If the service exists, use the editor template - else switch to the textbox template
                        if (this.expressionEditorService != null)
                        {
                            this.PerfProvider.WorkflowDesignerExpressionEditorLoadStart();
                            this.ContentTemplate = (DataTemplate)FindResource("editor");
                        }
                        else
                        {
                            this.ContentTemplate = (DataTemplate)FindResource("textbox");
                        }
                    }
                }

                if (!isInReadOnlyMode)
                {
                    //disable the error icon
                    this.StartValidator();
                    this.EditingState = EditingState.Editing;
                    e.Handled = true;
                }
            }
        }