/// <summary>
            /// Checks whether mouse down position belongs to selected portion of text,
            /// and initiates a drad-and-drop process in this case.
            /// Drag-drop initiation does not capture mouse yet, and do not start
            /// OleDragDrop; this will happen on a subsequent mouse move event
            /// (if it will happen before mouse up).
            /// </summary>
            /// <param name="mouseDownPoint">
            /// TextView-relative coordinates of mouse down event.
            /// </param>
            /// <returns>
            /// true if this mouse down was inside of selection and drag-drop process was activated.
            /// false if the mouse down was outside of selected portion.
            /// </returns>
            internal bool SourceOnMouseLeftButtonDown(Point mouseDownPoint)
            {
                ITextSelection selection = _textEditor.Selection;

                if (_textEditor.UiScope is PasswordBox)
                {
                    //
                    _dragStarted = false;
                }
                else
                {
                    // Get the drag minimum width/height from SystemMetrics.DragMinimumWidth/DragMinimumHeight.
                    // dragMinimumWidth and dragMinimumheight of a rectangle centered on a drag point to allow for limited movement
                    // of the mouse pointer before a drag operation begins.
                    // It allows the user to click and release the mouse button easily without unintentionally starting a drag operation.
                    int minimumHorizontalDragDistance = (int)SystemParameters.MinimumHorizontalDragDistance;
                    int minimumVerticalDragDistance   = (int)SystemParameters.MinimumVerticalDragDistance;

                    _dragRect = new Rect(mouseDownPoint.X - minimumHorizontalDragDistance, mouseDownPoint.Y - minimumVerticalDragDistance, minimumHorizontalDragDistance * 2, minimumVerticalDragDistance * 2);

                    // Check if click happened within existing selection
                    _dragStarted = selection.Contains(mouseDownPoint);
                }

                return(_dragStarted);
            }
Example #2
0
            // Token: 0x060085B5 RID: 34229 RVA: 0x0024A500 File Offset: 0x00248700
            internal bool SourceOnMouseLeftButtonDown(Point mouseDownPoint)
            {
                ITextSelection selection = this._textEditor.Selection;

                if (this._textEditor.UiScope is PasswordBox)
                {
                    this._dragStarted = false;
                }
                else
                {
                    int num  = (int)SystemParameters.MinimumHorizontalDragDistance;
                    int num2 = (int)SystemParameters.MinimumVerticalDragDistance;
                    this._dragRect    = new Rect(mouseDownPoint.X - (double)num, mouseDownPoint.Y - (double)num2, (double)(num * 2), (double)(num2 * 2));
                    this._dragStarted = selection.Contains(mouseDownPoint);
                }
                return(this._dragStarted);
            }
Example #3
0
            // Token: 0x060085C0 RID: 34240 RVA: 0x0024AD64 File Offset: 0x00248F64
            private bool IsSelectionContainsDropPosition(ITextSelection selection, ITextPointer dropPosition)
            {
                bool flag = selection.Contains(dropPosition);

                if (flag && selection.IsTableCellRange)
                {
                    for (int i = 0; i < selection.TextSegments.Count; i++)
                    {
                        if (dropPosition.CompareTo(selection._TextSegments[i].End) == 0)
                        {
                            flag = false;
                            break;
                        }
                    }
                }
                return(flag);
            }
            // Table cell selection currently include the next adjacent cell start element so that
            // selection always contains the drop position even though the drop position is on the next cell.
            // This private method check the table range really contains the drop position or not.
            private bool IsSelectionContainsDropPosition(ITextSelection selection, ITextPointer dropPosition)
            {
                bool selectionContainedDropPosition = selection.Contains(dropPosition);

                if (selectionContainedDropPosition && selection.IsTableCellRange)
                {
                    for (int i = 0; i < selection.TextSegments.Count; i++)
                    {
                        TextSegment textSegment = selection._TextSegments[i];

                        if (dropPosition.CompareTo(textSegment.End) == 0)
                        {
                            selectionContainedDropPosition = false;
                            break;
                        }
                    }
                }

                return(selectionContainedDropPosition);
            }
Example #5
0
            // Table cell selection currently include the next adjacent cell start element so that
            // selection always contains the drop position even though the drop position is on the next cell.
            // This private method check the table range really contains the drop position or not.
            private bool IsSelectionContainsDropPosition(ITextSelection selection, ITextPointer dropPosition)
            {
                bool selectionContainedDropPosition = selection.Contains(dropPosition);

                if (selectionContainedDropPosition && selection.IsTableCellRange)
                {
                    for (int i = 0; i < selection.TextSegments.Count; i++)
                    {
                        TextSegment textSegment = selection._TextSegments[i];

                        if (dropPosition.CompareTo(textSegment.End) == 0)
                        {
                            selectionContainedDropPosition = false;
                            break;
                        }
                    }
                }

                return selectionContainedDropPosition;
            }