예제 #1
0
        // Determine whether the given point is within the RenderScope but not covered by chrome,
        // scroll bars, etc.
        //
        // Note that the passed point must be relative to the UiScope.
        private static bool IsPointWithinRenderScope(TextEditor textEditor, Point point)
        {
            DependencyObject textContainerOwner = textEditor.TextContainer.Parent;
            UIElement        renderScope        = textEditor.TextView.RenderScope;
            CaretElement     caretElement       = textEditor.Selection.CaretElement;

            HitTestResult hitTestResult = VisualTreeHelper.HitTest(textEditor.UiScope, point);

            if (hitTestResult != null)
            {
                bool check = false;
                if (hitTestResult.VisualHit is Visual)
                {
                    check = ((Visual)hitTestResult.VisualHit).IsDescendantOf(renderScope);
                }
                if (hitTestResult.VisualHit is Visual3D)
                {
                    check = ((Visual3D)hitTestResult.VisualHit).IsDescendantOf(renderScope);
                }

                if (hitTestResult.VisualHit == renderScope ||
                    check ||
                    hitTestResult.VisualHit == caretElement)
                {
                    return(true);
                }
            }

            DependencyObject hitElement = textEditor.UiScope.InputHitTest(point) as DependencyObject;

            while (hitElement != null)
            {
                if (hitElement == textContainerOwner ||
                    hitElement == renderScope ||
                    hitElement == caretElement)
                {
                    return(true);
                }

                if (hitElement is FrameworkElement && ((FrameworkElement)hitElement).TemplatedParent == textEditor.UiScope)
                {
                    // The element belongs to control's chrome
                    hitElement = null;
                }
                else if (hitElement is Visual)
                {
                    hitElement = VisualTreeHelper.GetParent(hitElement);
                }
                else if (hitElement is FrameworkContentElement)
                {
                    hitElement = ((FrameworkContentElement)hitElement).Parent;
                }
                else
                {
                    hitElement = null;
                }
            }

            return(false);
        }
        // Token: 0x0600388A RID: 14474 RVA: 0x000FDBF0 File Offset: 0x000FBDF0
        private static bool IsPointWithinRenderScope(TextEditor textEditor, Point point)
        {
            DependencyObject parent        = textEditor.TextContainer.Parent;
            UIElement        renderScope   = textEditor.TextView.RenderScope;
            CaretElement     caretElement  = textEditor.Selection.CaretElement;
            HitTestResult    hitTestResult = VisualTreeHelper.HitTest(textEditor.UiScope, point);

            if (hitTestResult != null)
            {
                bool flag = false;
                if (hitTestResult.VisualHit is Visual)
                {
                    flag = ((Visual)hitTestResult.VisualHit).IsDescendantOf(renderScope);
                }
                if (hitTestResult.VisualHit is Visual3D)
                {
                    flag = ((Visual3D)hitTestResult.VisualHit).IsDescendantOf(renderScope);
                }
                if (hitTestResult.VisualHit == renderScope || flag || hitTestResult.VisualHit == caretElement)
                {
                    return(true);
                }
            }
            DependencyObject dependencyObject = textEditor.UiScope.InputHitTest(point) as DependencyObject;

            while (dependencyObject != null)
            {
                if (dependencyObject == parent || dependencyObject == renderScope || dependencyObject == caretElement)
                {
                    return(true);
                }
                if (dependencyObject is FrameworkElement && ((FrameworkElement)dependencyObject).TemplatedParent == textEditor.UiScope)
                {
                    dependencyObject = null;
                }
                else if (dependencyObject is Visual)
                {
                    dependencyObject = VisualTreeHelper.GetParent(dependencyObject);
                }
                else if (dependencyObject is FrameworkContentElement)
                {
                    dependencyObject = ((FrameworkContentElement)dependencyObject).Parent;
                }
                else
                {
                    dependencyObject = null;
                }
            }
            return(false);
        }
            // Creates DropCaret
            internal void TargetEnsureDropCaret()
            {
                if (_caretDragDrop == null)
                {
                    //

                    // Add the caret.
                    // Create caret to show it during the dragging operation.
                    _caretDragDrop = new CaretElement(_textEditor, /*isBlinkEnabled:*/ false);

                    // Initialize the caret.
                    //
                    _caretDragDrop.Hide();
                }
            }
예제 #4
0
            // Creates DropCaret
            internal void TargetEnsureDropCaret()
            {
                if (_caretDragDrop == null)
                {
                    //  We never delete drop caret, never detach it from view. Not a big deal, but not clear...

                    // Add the caret.
                    // Create caret to show it during the dragging operation.
                    _caretDragDrop = new CaretElement(_textEditor, /*isBlinkEnabled:*/ false);

                    // Initialize the caret.
                    // (psarrett) Understand why this call is so important for AdornerLayer.
                    _caretDragDrop.Hide();
                }
            }
        // Token: 0x06002B1E RID: 11038 RVA: 0x000C4BC0 File Offset: 0x000C2DC0
        internal void UpdateSelection()
        {
            Geometry selectionGeometry = this._selectionGeometry;

            this._selectionGeometry = null;
            if (!this._textEditor.Selection.IsEmpty)
            {
                this.EnsureAttachedToView();
                List <TextSegment> textSegments = this._textEditor.Selection.TextSegments;
                for (int i = 0; i < textSegments.Count; i++)
                {
                    TextSegment textSegment = textSegments[i];
                    Geometry    tightBoundingGeometryFromTextPositions = this._textEditor.Selection.TextView.GetTightBoundingGeometryFromTextPositions(textSegment.Start, textSegment.End);
                    CaretElement.AddGeometry(ref this._selectionGeometry, tightBoundingGeometryFromTextPositions);
                }
            }
            if (this._selectionGeometry != selectionGeometry)
            {
                this.RefreshCaret(this._italic);
            }
        }
예제 #6
0
        private CaretElement EnsureCaret(bool isBlinkEnabled, bool isSelectionActive, CaretScrollMethod scrollMethod)
        {
            TextEditorThreadLocalStore threadLocalStore = TextEditor._ThreadLocalStore;

            if (_caretElement == null)
            {
                // Create new caret
                _caretElement = new CaretElement(_textEditor, isBlinkEnabled);
                _caretElement.IsSelectionActive = isSelectionActive;

                // Check the current input language to draw the BiDi caret in case of BiDi language
                // like as Arabic or Hebrew input language.
                // 
                if (IsBidiInputLanguage(InputLanguageManager.Current.CurrentInputLanguage))
                {
                    TextEditor._ThreadLocalStore.Bidi = true;
                }
                else
                {
                    TextEditor._ThreadLocalStore.Bidi = false;
                }
            }
            else
            {
                // Please note that it is important to set the IsSelectionActive property before 
                // calling SetBlinking. This is because SetBlinking calls Win32CreateCaret & 
                // Win32DestroyCaret both of which meaningfully use this flag.
                _caretElement.IsSelectionActive = isSelectionActive;
                _caretElement.SetBlinking(isBlinkEnabled);
            }

            UpdateCaretState(scrollMethod);

            return _caretElement;
        }
예제 #7
0
            // Creates DropCaret
            internal void TargetEnsureDropCaret()
            {
                if (_caretDragDrop == null)
                {
                    // 

                    // Add the caret.
                    // Create caret to show it during the dragging operation.
                    _caretDragDrop = new CaretElement(_textEditor, /*isBlinkEnabled:*/false);

                    // Initialize the caret.
                    // 
                    _caretDragDrop.Hide();
                }
            }
 // Token: 0x06002B2E RID: 11054 RVA: 0x000C510E File Offset: 0x000C330E
 private FrameworkElement GetOwnerElement()
 {
     return(CaretElement.GetOwnerElement(this._textEditor.UiScope));
 }
예제 #9
0
        private CaretElement EnsureCaret(bool isBlinkEnabled, CaretScrollMethod scrollMethod) 
        { 
            TextEditorThreadLocalStore threadLocalStore = TextEditor._ThreadLocalStore;
 
            if (_caretElement == null)
            {
                // Create new caret
                _caretElement = new CaretElement(_textEditor, isBlinkEnabled); 

                // Check the current input language to draw the BiDi caret in case of BiDi language 
                // like as Arabic or Hebrew input language. 
                //
                if (IsBidiInputLanguage(InputLanguageManager.Current.CurrentInputLanguage)) 
                {
                    TextEditor._ThreadLocalStore.Bidi = true;
                }
                else 
                {
                    TextEditor._ThreadLocalStore.Bidi = false; 
                } 
            }
            else 
            {
                _caretElement.SetBlinking(isBlinkEnabled);
            }
 
            UpdateCaretState(scrollMethod);
 
            return _caretElement; 
        }