/// <summary>
        /// Windows the got focus.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void WindowGotFocus(object sender, RoutedEventArgs e)
        {
            var foundTextBox = DependencyObjectUtils.FindChild <WorkspaceTextBox>(this.MainTabControl, "TextEditor");

            Keyboard.Focus(foundTextBox);
            foundTextBox.Focus();
        }
        /// <summary>
        /// Renames the current tab.
        /// </summary>
        private void RenameCurrentTab()
        {
            var viewModel = this.DataContext as MainViewModel;

            if (viewModel == null)
            {
                return;
            }

            var tabControl = this.FindName("MainTabControl") as CustomTabControl;

            if (tabControl == null)
            {
                return;
            }

            var selectedTabItem = tabControl.ItemContainerGenerator.ContainerFromItem(viewModel.CurrentWorkspace) as CustomTabItem;

            if (selectedTabItem == null)
            {
                return;
            }

            var textBox = DependencyObjectUtils.FindChild <EditableTextBlock>(selectedTabItem, "LabelTextBox");

            if (textBox != null)
            {
                textBox.EnterEditMode();
            }
        }
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            // Draw lines between connectors
            if (ViewModel?.Nodes != null)
            {
                foreach (var node in ViewModel.Nodes)
                {
                    foreach (var prop in node.LinkableProperties)
                    {
                        // Check if the property has a reference to an expression, if so, find the connector points
                        if (prop.Value is INodeReference nr && nr.Id.HasValue)
                        {
                            var start       = DependencyObjectUtils.ChildOfType <VisualNodeConnector>(this, c => c.NodeID == node.ID && c.PropertyName == prop.Name && c.ConnectorFlow == ConnectorFlow.Destination);
                            var end         = DependencyObjectUtils.ChildOfType <VisualNodeConnector>(this, c => c.NodeID == nr.Id.Value && c.ConnectorFlow == ConnectorFlow.Source);
                            var isStatement = prop.PropertyType == VisualNodePropertyType.Statement;

                            if (start != null && end != null)
                            {
                                drawingContext.DrawConnectorLine(
                                    new Pen(new SolidColorBrush(isStatement ? Colors.Gray : this.ColorForDataType(prop.Type)), 2d),
                                    start.TransformToAncestor(this).Transform(start.MidPoint),
                                    end.TransformToAncestor(this).Transform(end.MidPoint),
                                    isStatement
                                    );
                            }
                        }
                    }
                }
            }

            // If there is a drag going on, run the behaviours custom render method
            ViewModel?.DragBehaviour?.OnRender(this, drawingContext);
        }
        private void ViewModelOnWorkspaceChanged(object sender, EventArgs eventArgs)
        {
            var textEditor = DependencyObjectUtils.FindChild <WorkspaceTextBox>(this.MainTabControl, "TextEditor");

            if (textEditor != null)
            {
                textEditor.ScrollToSelection();
            }
        }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes call <see cref="M:System.Windows.FrameworkElement.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            var content = DependencyObjectUtils.GetFirstDescendantOfType <ContentPresenter>(this);

            if (content != null)
            {
                content.HorizontalAlignment = HorizontalAlignment.Stretch;
            }
        }
        private void SearchString()
        {
            var textBox = DependencyObjectUtils.FindChild <WorkspaceTextBox>(this.MainTabControl, "TextEditor");

            if (textBox == null)
            {
                return;
            }

            try
            {
                textBox.SearchString(this.SearchTextBox.Text);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                ((Storyboard)this.FindResource("NoSearchMatchesStoryboard")).Begin(this);
            }
        }
        private void UIElement_OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            var textEditor = DependencyObjectUtils.FindChild <WorkspaceTextBox>(this.MainTabControl, "TextEditor");

            if (textEditor == null)
            {
                return;
            }

            if ((bool)e.NewValue)
            {
                textEditor.ResetSession();

                this.SearchTextBox.Text           = textEditor.SelectedText;
                this.SearchTextBox.SelectionStart = this.SearchTextBox.Text.Length;

                this.Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(() => this.SearchTextBox.Focus()));
            }
            else
            {
                textEditor.SelectionLength = 0;
                textEditor.Focus();
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Initializes the scroll viewer.
 /// </summary>
 public void InitializeScrollViewer()
 {
     this.TextBoxScrollViewer = DependencyObjectUtils.FindChildOfType <ScrollViewer>(this);
 }