protected static bool IsInSel(Location location, ISelection sel)
        {
            // See ExtractMethodTests.WhiteSpaceMatters for why these are commented out.
            // Why were they in #D source in the first place?
            bool result = (sel.ContainsPosition(location.Column /* - 1*/, location.Line /*- 1*/));

            return(result);
        }
        protected void OnDragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(string)))
            {
                textArea.BeginUpdate();
                textArea.Document.UndoStack.StartUndoGroup();

                try
                {
                    int offset = textArea.Caret.Offset;

                    if (textArea.IsReadOnly(offset))
                    {
                        // prevent dragging text into readonly section
                        return;
                    }

                    if (e.Data.GetDataPresent(typeof(DefaultSelection)))
                    {
                        ISelection sel = (ISelection)e.Data.GetData(typeof(DefaultSelection));

                        if (sel.ContainsPosition(textArea.Caret.Position))
                        {
                            return;
                        }

                        if (GetDragDropEffect(e) == DragDropEffects.Move)
                        {
                            if (SelectionManager.SelectionIsReadOnly(textArea.Document, sel))
                            {
                                // prevent dragging text out of readonly section
                                return;
                            }

                            int len = sel.Length;
                            textArea.Document.Remove(sel.Offset, len);

                            if (sel.Offset < offset)
                            {
                                offset -= len;
                            }
                        }
                    }
                    textArea.SelectionManager.ClearSelection();
                    InsertString(offset, (string)e.Data.GetData(typeof(string)));
                    textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
                }
                finally
                {
                    textArea.Document.UndoStack.EndUndoGroup();
                    textArea.EndUpdate();
                }
            }
        }
        protected void OnDragDrop(object sender, DragEventArgs e)
        {
            Point p = textArea.PointToClient(new Point(e.X, e.Y));

            if (e.Data.GetDataPresent(typeof(string)))
            {
                bool two = false;
                textArea.BeginUpdate();
                try {
                    int offset = textArea.Caret.Offset;
                    if (textArea.TextEditorProperties.UseCustomLine &&
                        textArea.Document.CustomLineManager.IsReadOnly(textArea.Caret.Line, false))
                    {
                        // prevent dragging text into readonly section
                        return;
                    }
                    if (e.Data.GetDataPresent(typeof(DefaultSelection)))
                    {
                        ISelection sel = (ISelection)e.Data.GetData(typeof(DefaultSelection));
                        if (sel.ContainsPosition(textArea.Caret.Position))
                        {
                            return;
                        }
                        if (GetDragDropEffect(e) == DragDropEffects.Move)
                        {
                            if (textArea.TextEditorProperties.UseCustomLine &&
                                textArea.Document.CustomLineManager.IsReadOnly(sel, false))
                            {
                                // prevent dragging text out of readonly section
                                return;
                            }
                            int len = sel.Length;
                            textArea.Document.Remove(sel.Offset, len);
                            if (sel.Offset < offset)
                            {
                                offset -= len;
                            }
                        }
                        two = true;
                    }
                    textArea.SelectionManager.ClearSelection();
                    InsertString(offset, (string)e.Data.GetData(typeof(string)));
                    if (two)
                    {
                        textArea.Document.UndoStack.CombineLast(2);
                    }
                    textArea.Document.UpdateQueue.Clear();
                    textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
                } finally {
                    textArea.EndUpdate();
                }
            }
        }
 internal static void CallAllProperties(ISelection selection)
 {
     selection.ContainsOffset(0);
     selection.ContainsPosition(TextLocation.Empty);
     int          offset               = selection.EndOffset;
     TextLocation position             = selection.EndPosition;
     bool         empty                = selection.IsEmpty;
     bool         rectangularSelection = selection.IsRectangularSelection;
     int          length               = selection.Length;
     int          offset2              = selection.Offset;
     string       text          = selection.SelectedText;
     TextLocation startPosition = selection.StartPosition;
 }
 internal static void CallAllProperties(ISelection selection)
 {
     selection.ContainsOffset(0);
     selection.ContainsPosition(TextLocation.Empty);
     int offset = selection.EndOffset;
     TextLocation position = selection.EndPosition;
     bool empty = selection.IsEmpty;
     bool rectangularSelection = selection.IsRectangularSelection;
     int length = selection.Length;
     int offset2 = selection.Offset;
     string text = selection.SelectedText;
     TextLocation startPosition = selection.StartPosition;
 }
Example #6
0
 protected void OnDragDrop(object sender, DragEventArgs e)
 {
     this.textArea.PointToClient(new Point(e.X, e.Y));
     if (e.Data.GetDataPresent(typeof(string)))
     {
         this.textArea.BeginUpdate();
         this.textArea.Document.UndoStack.StartUndoGroup();
         try
         {
             int offset = this.textArea.Caret.Offset;
             if (!this.textArea.IsReadOnly(offset))
             {
                 if (e.Data.GetDataPresent(typeof(DefaultSelection)))
                 {
                     ISelection data = (ISelection)e.Data.GetData(typeof(DefaultSelection));
                     if (data.ContainsPosition(this.textArea.Caret.Position))
                     {
                         return;
                     }
                     else if (TextAreaDragDropHandler.GetDragDropEffect(e) == DragDropEffects.Move)
                     {
                         if (!SelectionManager.SelectionIsReadOnly(this.textArea.Document, data))
                         {
                             int length = data.Length;
                             this.textArea.Document.Remove(data.Offset, length);
                             if (data.Offset < offset)
                             {
                                 offset -= length;
                             }
                         }
                         else
                         {
                             return;
                         }
                     }
                 }
                 this.textArea.SelectionManager.ClearSelection();
                 this.InsertString(offset, (string)e.Data.GetData(typeof(string)));
                 this.textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
             }
         }
         finally
         {
             this.textArea.Document.UndoStack.EndUndoGroup();
             this.textArea.EndUpdate();
         }
     }
 }
        private void templateEditor_DragDrop(object sender, DragEventArgs e)
        {
            TreeNode node = (TreeNode)e.Data.GetData(typeof(TreeNode));

            ICSharpCode.TextEditor.TextArea textArea = (ICSharpCode.TextEditor.TextArea)sender;
            try
            {
                Hashtable idPack = node.Tag as Hashtable;
                switch (idPack["Type"] as string)
                {
                case "promptgroup":
                    return;

                case "prompt":
                    break;
                }

                //Build the variable to insert here
                Prompt prompt = idPack["Data"] as Prompt;

                Point p = textArea.PointToClient(new Point(e.X, e.Y));
                textArea.BeginUpdate();
                textArea.Document.UndoStack.StartUndoGroup();

                int offset = textArea.Caret.Offset;
                if (e.Data.GetDataPresent(typeof(DefaultSelection)))
                {
                    ISelection sel = (ISelection)e.Data.GetData(typeof(DefaultSelection));
                    if (sel.ContainsPosition(textArea.Caret.Position))
                    {
                        return;
                    }
                    int len = sel.Length;
                    textArea.Document.Remove(sel.Offset, len);
                    if (sel.Offset < offset)
                    {
                        offset -= len;
                    }
                }
                insertIntoTemplateEditor(textArea, offset, prompt.VariableName);
            }
            finally
            {
                textArea.Document.UndoStack.EndUndoGroup();
                textArea.EndUpdate();
            }
        }
 protected void OnDragDrop(object sender, DragEventArgs e)
 {
     this.textArea.PointToClient(new Point(e.X, e.Y));
     if (!this.textArea.EnableCutOrPaste)
     {
         return;
     }
     if (e.Data.GetDataPresent(typeof(string)))
     {
         bool flag = false;
         this.textArea.BeginUpdate();
         try
         {
             int num = this.textArea.Caret.Offset;
             if (e.Data.GetDataPresent(typeof(DefaultSelection)))
             {
                 ISelection selection = (ISelection)e.Data.GetData(typeof(DefaultSelection));
                 if (selection.ContainsPosition(this.textArea.Caret.Position))
                 {
                     return;
                 }
                 if (TextAreaDragDropHandler.GetDragDropEffect(e) == DragDropEffects.Move)
                 {
                     int length = selection.Length;
                     this.textArea.Document.Remove(selection.Offset, length);
                     if (selection.Offset < num)
                     {
                         num -= length;
                     }
                 }
                 flag = true;
             }
             this.textArea.SelectionManager.ClearSelection();
             this.InsertString(num, (string)e.Data.GetData(typeof(string)));
             if (flag)
             {
                 this.textArea.Document.UndoStack.UndoLast(2);
             }
             this.textArea.Document.UpdateQueue.Clear();
             this.textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
         }
         finally
         {
             this.textArea.EndUpdate();
         }
     }
 }
Example #9
0
        protected void OnDragDrop(object sender, DragEventArgs e)
        {
            Point p = textArea.PointToClient(new Point(e.X, e.Y));

            if (textArea.EnableCutOrPaste == false)
            {
                return;
            }
            if (e.Data.GetDataPresent(typeof(string)))
            {
                bool two = false;
                textArea.BeginUpdate();
                try {
                    int offset = textArea.Caret.Offset;
                    if (e.Data.GetDataPresent(typeof(DefaultSelection)))
                    {
                        ISelection sel = (ISelection)e.Data.GetData(typeof(DefaultSelection));
                        if (sel.ContainsPosition(textArea.Caret.Position))
                        {
                            return;
                        }
                        if (GetDragDropEffect(e) == DragDropEffects.Move)
                        {
                            int len = sel.Length;
                            textArea.Document.Remove(sel.Offset, len);
                            if (sel.Offset < offset)
                            {
                                offset -= len;
                            }
                        }
                        two = true;
                    }
                    textArea.SelectionManager.ClearSelection();
                    InsertString(offset, (string)e.Data.GetData(typeof(string)));
                    if (two)
                    {
                        textArea.Document.UndoStack.UndoLast(2);
                    }
                    textArea.Document.UpdateQueue.Clear();
                    textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
                } finally {
                    textArea.EndUpdate();
                }
            }
        }
Example #10
0
        public void ExtendSelection(Point oldPosition, Point newPosition)
        {
            if (oldPosition == newPosition)
            {
                Console.WriteLine("BLUB");
                return;
            }
            Point min;
            Point max;
            bool  oldIsGreater = GreaterEqPos(oldPosition, newPosition);

            if (oldIsGreater)
            {
                min = newPosition;
                max = oldPosition;
            }
            else
            {
                min = oldPosition;
                max = newPosition;
            }
            if (!HasSomethingSelected)
            {
                SetSelection(new DefaultSelection(document, min, max));
                Console.WriteLine("SET");

                return;
            }
            ISelection selection = this.selectionCollection[0];
            bool       changed   = false;

            if (selection.ContainsPosition(newPosition))
            {
                if (oldIsGreater)
                {
                    if (selection.EndPosition != newPosition)
                    {
                        selection.EndPosition = newPosition;
                        changed = true;
                    }
                }
                else
                {
                    if (selection.StartPosition != newPosition)
                    {
                        selection.StartPosition = newPosition;
                        changed = true;
                    }
                }
            }
            else
            {
                if (oldPosition == selection.StartPosition)
                {
                    if (GreaterEqPos(newPosition, selection.EndPosition))
                    {
                        if (selection.StartPosition != selection.EndPosition ||
                            selection.EndPosition != newPosition)
                        {
                            selection.StartPosition = selection.EndPosition;
                            selection.EndPosition   = newPosition;
                            changed = true;
                        }
                    }
                    else
                    {
                        if (selection.StartPosition != newPosition)
                        {
                            selection.StartPosition = newPosition;
                            changed = true;
                        }
                    }
                }
                else
                {
                    if (GreaterEqPos(selection.StartPosition, newPosition))
                    {
                        if (selection.EndPosition != selection.StartPosition ||
                            selection.StartPosition != newPosition)
                        {
                            changed = true;
                        }
                        selection.EndPosition   = selection.StartPosition;
                        selection.StartPosition = newPosition;
                        changed = true;
                    }
                    else
                    {
                        if (selection.EndPosition != newPosition)
                        {
                            selection.EndPosition = newPosition;
                            changed = true;
                        }
                    }
                }
            }
            Console.WriteLine("GGG" + changed);

//			if (GreaterEqPos(selection.StartPosition, min) && GreaterEqPos(selection.EndPosition, max)) {
//				if (oldIsGreater) {
//					selection.StartPosition = min;
//				} else {
//					selection.StartPosition = max;
//				}
//			} else {
//				if (oldIsGreater) {
//					selection.EndPosition = min;
//				} else {
//					selection.EndPosition = max;
//				}
//			}
            if (changed)
            {
                document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, min.Y, max.Y));
                document.CommitUpdate();
                OnSelectionChanged(EventArgs.Empty);
            }
        }
Example #11
0
        public void ExtendSelection(Point oldPosition, Point newPosition)
        {
            if (oldPosition == newPosition)
            {
                return;
            }
            Point min;
            Point max;
            bool  oldIsGreater = GreaterEqPos(oldPosition, newPosition);

            if (oldIsGreater)
            {
                min = newPosition;
                max = oldPosition;
            }
            else
            {
                min = oldPosition;
                max = newPosition;
            }
            if (!HasSomethingSelected)
            {
                SetSelection(new DefaultSelection(document, min, max));
                return;
            }
            ISelection selection = this.selectionCollection[0];
            bool       changed   = false;

            if (selection.ContainsPosition(newPosition))
            {
                if (oldIsGreater)
                {
                    if (selection.EndPosition != newPosition)
                    {
                        selection.EndPosition = newPosition;
                        changed = true;
                    }
                }
                else
                {
                    if (selection.StartPosition != newPosition)
                    {
                        // we're back to the line we started from and it was a gutter selection
                        if (selectFrom.where == WhereFrom.Gutter && newPosition.Y >= selectionStart.Y)
                        {
                            selection.StartPosition = selectionStart;
                            selection.EndPosition   = NextValidPosition(selection.StartPosition.Y);
                        }
                        else
                        {
                            selection.StartPosition = newPosition;
                        }
                        changed = true;
                    }
                }
            }
            else
            {
                if (oldPosition == selection.StartPosition)
                {
                    if (GreaterEqPos(newPosition, selection.EndPosition))
                    {
                        if (selection.StartPosition != selection.EndPosition ||
                            selection.EndPosition != newPosition)
                        {
                            selection.StartPosition = selection.EndPosition;
                            selection.EndPosition   = newPosition;
                            changed = true;
                        }
                    }
                    else
                    {
                        if (selection.StartPosition != newPosition)
                        {
                            selection.StartPosition = newPosition;
                            changed = true;
                        }
                    }
                }
                else
                {
                    if (GreaterEqPos(selection.StartPosition, newPosition))
                    {
                        if (selection.EndPosition != selection.StartPosition ||
                            selection.StartPosition != newPosition)
                        {
                            changed = true;
                        }
                        if (selectFrom.where == WhereFrom.Gutter)
                        {
                            if (selectFrom.first == WhereFrom.Gutter)
                            {
                                if (newPosition.Y == selectionStart.Y)
                                {
                                    selection.EndPosition   = NextValidPosition(selection.StartPosition.Y);
                                    selection.StartPosition = new Point(0, newPosition.Y);
                                }
                                else
                                {
                                    selection.EndPosition   = NextValidPosition(selection.StartPosition.Y);
                                    selection.StartPosition = newPosition;
                                }
                            }
                            else
                            {
                                if (newPosition.Y == selectionStart.Y)
                                {
                                    selection.EndPosition   = NextValidPosition(selection.StartPosition.Y);
                                    selection.StartPosition = new Point(selectionStart.X, newPosition.Y);
                                }
                                else
                                {
                                    selection.EndPosition   = new Point(selectionStart.X, selection.StartPosition.Y);
                                    selection.StartPosition = newPosition;
                                }
                            }
                        }
                        else
                        {
                            selection.EndPosition   = selection.StartPosition;
                            selection.StartPosition = newPosition;
                        }
                        changed = true;
                    }
                    else
                    {
                        if (selection.EndPosition != newPosition)
                        {
                            selection.EndPosition = newPosition;
                            changed = true;
                        }
                    }
                }
            }

//			if (GreaterEqPos(selection.StartPosition, min) && GreaterEqPos(selection.EndPosition, max)) {
//				if (oldIsGreater) {
//					selection.StartPosition = min;
//				} else {
//					selection.StartPosition = max;
//				}
//			} else {
//				if (oldIsGreater) {
//					selection.EndPosition = min;
//				} else {
//					selection.EndPosition = max;
//				}
//			}
            if (changed)
            {
                document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, min.Y, max.Y));
                document.CommitUpdate();
                OnSelectionChanged(EventArgs.Empty);
            }
        }
Example #12
0
        public void ExtendSelection(Point oldPosition, Point newPosition)
        {
            if (oldPosition == newPosition)
            {
                Console.WriteLine("BLUB");
                return;
            }
            bool  flag = this.GreaterEqPos(oldPosition, newPosition);
            Point startPosition;
            Point endPosition;

            if (flag)
            {
                startPosition = newPosition;
                endPosition   = oldPosition;
            }
            else
            {
                startPosition = oldPosition;
                endPosition   = newPosition;
            }
            if (!this.HasSomethingSelected)
            {
                this.SetSelection(new DefaultSelection(this.document, startPosition, endPosition));
                Console.WriteLine("SET");
                return;
            }
            ISelection selection = this.selectionCollection[0];
            bool       flag2     = false;

            if (selection.ContainsPosition(newPosition))
            {
                if (flag)
                {
                    if (selection.EndPosition != newPosition)
                    {
                        selection.EndPosition = newPosition;
                        flag2 = true;
                    }
                }
                else
                {
                    if (selection.StartPosition != newPosition)
                    {
                        selection.StartPosition = newPosition;
                        flag2 = true;
                    }
                }
            }
            else
            {
                if (oldPosition == selection.StartPosition)
                {
                    if (this.GreaterEqPos(newPosition, selection.EndPosition))
                    {
                        if (selection.StartPosition != selection.EndPosition || selection.EndPosition != newPosition)
                        {
                            selection.StartPosition = selection.EndPosition;
                            selection.EndPosition   = newPosition;
                            flag2 = true;
                        }
                    }
                    else
                    {
                        if (selection.StartPosition != newPosition)
                        {
                            selection.StartPosition = newPosition;
                            flag2 = true;
                        }
                    }
                }
                else
                {
                    if (this.GreaterEqPos(selection.StartPosition, newPosition))
                    {
                        if (selection.EndPosition != selection.StartPosition || selection.StartPosition != newPosition)
                        {
                        }
                        selection.EndPosition   = selection.StartPosition;
                        selection.StartPosition = newPosition;
                        flag2 = true;
                    }
                    else
                    {
                        if (selection.EndPosition != newPosition)
                        {
                            selection.EndPosition = newPosition;
                            flag2 = true;
                        }
                    }
                }
            }
            Console.WriteLine("GGG" + flag2);
            if (flag2)
            {
                this.document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, startPosition.Y, endPosition.Y));
                this.document.CommitUpdate();
                this.OnSelectionChanged(EventArgs.Empty);
            }
        }
        protected static bool IsInSel(Location location, ISelection sel)
        {
            bool result = (sel.ContainsPosition(new ICSharpCode.TextEditor.TextLocation(location.Column - 1, location.Line - 1)));

            return(result);
        }
		protected static bool IsInSel(Location location, ISelection sel)
		{
			bool result = (sel.ContainsPosition(new ICSharpCode.TextEditor.TextLocation(location.Column - 1, location.Line - 1)));
			return result;
		}
 protected static bool IsInSel(Location location, ISelection sel)
 {
     // See ExtractMethodTests.WhiteSpaceMatters for why these are commented out.
     // Why were they in #D source in the first place?
     bool result = (sel.ContainsPosition(location.Column/* - 1*/, location.Line /*- 1*/));
     return result;
 }