Beispiel #1
0
        /// <summary>
        /// This method executes a dialog key
        /// </summary>
        public bool ExecuteDialogKey(Keys keyData)
        {
            // try, if a dialog key processor was set to use this
            if (DoProcessDialogKey != null && DoProcessDialogKey(keyData))
            {
                return(true);
            }

            // if not (or the process was 'silent', use the standard edit actions
            IEditAction action = motherTextEditorControl.GetEditAction(keyData);

            AutoClearSelection = true;
            if (action != null)
            {
                BeginUpdate();
                try {
                    lock (Document) {
                        action.Execute(this);
                        if (SelectionManager.HasSomethingSelected && AutoClearSelection /*&& caretchanged*/)
                        {
                            if (Document.TextEditorProperties.DocumentSelectionMode == DocumentSelectionMode.Normal)
                            {
                                SelectionManager.ClearSelection();
                            }
                        }
                    }
                } finally {
                    EndUpdate();
                    Caret.UpdateCaretPosition();
                }
                return(true);
            }
            return(false);
        }
        public static void Replace(IProgressMonitor monitor)
        {
            SetSearchOptions(monitor);

            ITextEditorControlProvider provider = WorkbenchSingleton.ActiveControl as ITextEditorControlProvider;

            if (PAT.Common.Ultility.Ultility.IsUnixOS)
            {
                provider = FormMain.CurrentActiveTab;
            }
            if (lastResult != null) //&& WorkbenchSingleton.ActiveControl != null
            {
                if (provider != null)
                {
                    TextEditorControl textarea         = provider.TextEditorControl;
                    SelectionManager  selectionManager = textarea.ActiveTextAreaControl.TextArea.SelectionManager;

                    if (selectionManager.SelectionCollection.Count == 1 &&
                        selectionManager.SelectionCollection[0].Offset == lastResult.Offset &&
                        selectionManager.SelectionCollection[0].Length == lastResult.Length &&
                        lastResult.FileName == textarea.FileName)
                    {
                        string replacePattern = lastResult.TransformReplacePattern(SearchOptions.ReplacePattern);

                        textarea.BeginUpdate();
                        selectionManager.ClearSelection();
                        textarea.Document.Replace(lastResult.Offset, lastResult.Length, replacePattern);
                        textarea.ActiveTextAreaControl.Caret.Position =
                            textarea.Document.OffsetToPosition(lastResult.Offset + replacePattern.Length);
                        textarea.EndUpdate();
                    }
                }
            }
            FindNext(monitor);
        }
        public static bool ReplaceNextInSelection()
        {
            if (lastResult != null)             // && WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null)
            {
                //ITextEditorControlProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorControlProvider;
                //if (provider != null) {
                //TextEditorControl textarea = provider.TextEditorControl;
                var textarea        = FrmMdiParent.Instance.GetActiveSqlTextEditor();
                var activeWorksheet = FrmMdiParent.Instance.GetActiveWorksheet();
                var fileName        = activeWorksheet.WorksheetFile ?? activeWorksheet.Title;
                SelectionManager selectionManager = textarea.ActiveTextAreaControl.TextArea.SelectionManager;

                if (selectionManager.SelectionCollection.Count == 1 &&
                    selectionManager.SelectionCollection[0].Offset == lastResult.Offset &&
                    selectionManager.SelectionCollection[0].Length == lastResult.Length &&
                    lastResult.FileName == fileName)
                {
                    string replacePattern = lastResult.TransformReplacePattern(SearchOptions.ReplacePattern);

                    textarea.BeginUpdate();
                    selectionManager.ClearSelection();
                    textarea.Document.Replace(lastResult.Offset, lastResult.Length, replacePattern);
                    textarea.ActiveTextAreaControl.Caret.Position = textarea.Document.OffsetToPosition(lastResult.Offset + replacePattern.Length);
                    textarea.EndUpdate();

                    textSelection.Length -= lastResult.Length - replacePattern.Length;
                }
                //}
            }
            return(FindNextInSelection());
        }
        public static bool ReplaceNextInSelection(IProgressMonitor monitor)
        {
            if (lastResult != null && WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null)
            {
                ITextEditorControlProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorControlProvider;
                if (provider != null)
                {
                    TextEditorControl textarea         = provider.TextEditorControl;
                    SelectionManager  selectionManager = textarea.ActiveTextAreaControl.TextArea.SelectionManager;

                    if (selectionManager.SelectionCollection.Count == 1 &&
                        selectionManager.SelectionCollection[0].Offset == lastResult.Offset &&
                        selectionManager.SelectionCollection[0].Length == lastResult.Length &&
                        lastResult.FileName == textarea.FileName)
                    {
                        string replacePattern = lastResult.TransformReplacePattern(SearchOptions.ReplacePattern);

                        textarea.BeginUpdate();
                        selectionManager.ClearSelection();
                        textarea.Document.Replace(lastResult.Offset, lastResult.Length, replacePattern);
                        textarea.ActiveTextAreaControl.Caret.Position = textarea.Document.OffsetToPosition(lastResult.Offset + replacePattern.Length);
                        textarea.EndUpdate();

                        textSelection.Length -= lastResult.Length - replacePattern.Length;
                    }
                }
            }
            return(FindNextInSelection(monitor));
        }
Beispiel #5
0
    /// <summary>
    ///
    /// </summary>
    private void Update()
    {
        if (Input.GetKey(KeyCode.C))
        {
            // if (selectionManager.SelectionCount() > 0) {
            EnableCutMode();
            // }
        }
        else
        {
            DisableCutMode();
        }

        if (Input.GetKey(KeyCode.B))
        {
            SessionEvents.current.EnableSelection();
        }
        else
        {
            SessionEvents.current.DisableSelection();
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            selectionManager.ClearSelection();
        }
    }
Beispiel #6
0
        /// <summary>
        /// Selects the specified text range.
        /// </summary>
        static void SelectText(SelectionManager selectionManager, IDocument document, int startOffset, int length)
        {
            selectionManager.ClearSelection();
            TextLocation selectionStart = document.OffsetToPosition(startOffset);
            TextLocation selectionEnd   = document.OffsetToPosition(startOffset + length);

            selectionManager.SetSelection(selectionStart, selectionEnd);
        }
 void OnMouseDown()
 {
     //single-click
     if (Input.GetMouseButton(0))
     {
         selectionManager.ClearSelection();
     }
 }
Beispiel #8
0
        public override void HandleParsingException(ParsingException ex)
        {
            try
            {
                if (ex is GraphParsingException)
                {
                    string pname = (ex as GraphParsingException).ProcessName;
                    foreach (TreeNode node in ProblemsNode.Nodes)
                    {
                        if (node.Text == pname)
                        {
                            TreeView_Structure.SelectedNode = node;
                            TreeView_Structure_NodeMouseDoubleClick(node,
                                                                    new TreeNodeMouseClickEventArgs(node, MouseButtons.Left,
                                                                                                    2, 0, 0));
                            break;
                        }
                    }
                }
                else
                {
                    TreeView_Structure.SelectedNode = TreeView_Structure.Nodes[0];
                    TreeView_Structure_NodeMouseDoubleClick(TreeView_Structure.Nodes[0],
                                                            new TreeNodeMouseClickEventArgs(null, MouseButtons.Left,
                                                                                            2, 0, 0));


                    if (ex.Line >= 1 && ex.CharPositionInLine >= 0 && ex.Text != null)
                    {
                        textEditorControl.ActiveTextAreaControl.JumpTo(ex.Line - 1);
                        SelectionManager selectionManager =
                            textEditorControl.ActiveTextAreaControl.TextArea.SelectionManager;
                        selectionManager.ClearSelection();
                        selectionManager.SetSelection(new TextLocation(ex.CharPositionInLine, ex.Line - 1),
                                                      new TextLocation(ex.CharPositionInLine + ex.Text.Length,
                                                                       ex.Line - 1));
                        textEditorControl.Refresh();
                    }
                }
            }
            catch
            {
            }
        }
Beispiel #9
0
        /// <summary>
        /// Scrolls to the specified line and column and also selects the given
        /// length of text at this location.
        /// </summary>
        void ScrollTo(string fileName, int line, int column, int length)
        {
            XmlView view = XmlView.ActiveXmlView;

            if (view != null && IsFileNameMatch(view))
            {
                TextAreaControl textAreaControl = view.TextEditorControl.ActiveTextAreaControl;
                if (length > 0 && line < textAreaControl.Document.TotalNumberOfLines)
                {
                    SelectionManager selectionManager = textAreaControl.SelectionManager;
                    selectionManager.ClearSelection();
                    TextLocation startPos = new TextLocation(column, line);
                    TextLocation endPos   = new TextLocation(column + length, line);
                    selectionManager.SetSelection(startPos, endPos);
                }
                line = Math.Min(line, textAreaControl.Document.TotalNumberOfLines - 1);
                textAreaControl.ScrollTo(line, column);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Processes a dialog key.
        /// </summary>
        /// <param name="keyData">One of the <see cref="Keys"></see> values that represents the key to process.</param>
        /// <returns>
        /// true if the key was processed by the control; otherwise, false.
        /// </returns>
        protected override bool ProcessDialogKey(Keys keyData)
        {
            // Try, if a dialog key is handled by a subscriber of the DialogKeyPress event.
            KeyEventArgs keyEventArgs = new KeyEventArgs(keyData);

            OnDialogKeyPress(keyEventArgs);
            if (keyEventArgs.Handled)
            {
                return(true);
            }

            // if not (or the process was 'silent'), use the standard edit actions
            IEditAction action = _motherTextEditorControl.GetEditAction(keyData);

            AutoClearSelection = true;
            if (action != null)
            {
                BeginUpdate();
                try
                {
                    lock (Document)
                    {
                        action.Execute(this);
                        if (SelectionManager.HasSomethingSelected && AutoClearSelection /*&& caretchanged*/)
                        {
                            if (Document.TextEditorProperties.DocumentSelectionMode == DocumentSelectionMode.Normal)
                            {
                                SelectionManager.ClearSelection();
                            }
                        }
                    }
                }
                finally
                {
                    EndUpdate();
                }
                return(true);
            }

            return(base.ProcessDialogKey(keyData));
        }
Beispiel #11
0
 public virtual void HandleParsingException(ParsingException ex)
 {
     try
     {
         if (string.IsNullOrEmpty(ex.FileName) || ex.FileName == this.FileName)
         {
             if (ex.Line >= 1 && ex.CharPositionInLine >= 0 && ex.Text != null)
             {
                 this.textEditorControl.ActiveTextAreaControl.JumpTo(ex.Line - 1);
                 SelectionManager selectionManager =
                     textEditorControl.ActiveTextAreaControl.TextArea.SelectionManager;
                 selectionManager.ClearSelection();
                 selectionManager.SetSelection(new TextLocation(ex.CharPositionInLine, ex.Line - 1),
                                               new TextLocation(ex.CharPositionInLine + ex.Text.Length,
                                                                ex.Line - 1));
                 textEditorControl.Refresh();
             }
         }
     }
     catch
     {
     }
 }
Beispiel #12
0
 public void OneClickActions()
 {
     //Debug.Log("Single click actions");
     selectionManager.ClearSelection();
     selectionManager.AddUnitToSelection(this);
 }
Beispiel #13
0
        void ProcessLeftClick(Event p_event, Rect p_rect)
        {
            if (p_event.button != 0)
            {
                return;
            }

            if (p_event.type == EventType.MouseDown)
            {
                GUI.FocusControl("");
            }

            // Select
            if (p_event.type == EventType.MouseDown && !p_event.alt && Graph != null && !p_event.control)
            {
                DashEditorWindow.SetDirty(true);

                NodeBase hitNode      = Graph.HitsNode(p_event.mousePosition * Zoom - new Vector2(p_rect.x, p_rect.y));
                int      hitNodeIndex = Graph.Nodes.IndexOf(hitNode);

                if (!SelectionManager.IsSelected(hitNodeIndex) && (!p_event.shift || hitNodeIndex == 0))
                {
                    SelectionManager.ClearSelection();
                }

                if (hitNodeIndex >= 0)
                {
                    AddSelectedNode(hitNodeIndex);

                    dragging = DraggingType.NODE_DRAG;
                }
                else
                {
                    GraphBox box = Graph.HitsBoxDrag(p_event.mousePosition * Zoom - new Vector2(p_rect.x, p_rect.y));

                    if (box != null)
                    {
                        DashEditorCore.selectedBox = box;
                        DashEditorCore.selectedBox.StartDrag();
                        dragging = DraggingType.BOX_DRAG;
                    }
                    else
                    {
                        box = Graph.HitsBoxResize(p_event.mousePosition * Zoom - new Vector2(p_rect.x, p_rect.y));

                        if (box != null)
                        {
                            DashEditorCore.selectedBox = box;
                            DashEditorCore.selectedBox.StartResize();
                            dragging = DraggingType.BOX_RESIZE;
                        }
                        else
                        {
                            dragging = DraggingType.SELECTION;
                            DashEditorCore.selectedBox = null;
                            Graph.connectingNode       = null;
                            selectedRegion             = new Rect(p_event.mousePosition.x, p_event.mousePosition.y, 0, 0);
                        }
                    }
                }
            }

            // Dragging
            if (p_event.type == EventType.MouseDrag)
            {
                switch (dragging)
                {
                case DraggingType.NODE_DRAG:
                    Vector2 delta = p_event.alt ? Snapping.Snap(p_event.delta, new Vector2(10, 10)): p_event.delta;
                    SelectionManager.DragSelectedNodes(delta, Graph);
                    break;

                case DraggingType.BOX_DRAG:
                    DashEditorCore.selectedBox.Drag(new Vector2(p_event.delta.x * Zoom, p_event.delta.y * Zoom));
                    break;

                case DraggingType.BOX_RESIZE:
                    DashEditorCore.selectedBox.Resize(new Vector2(p_event.delta.x * Zoom, p_event.delta.y * Zoom));
                    break;

                case DraggingType.SELECTION:
                    selectedRegion.width  += p_event.delta.x;
                    selectedRegion.height += p_event.delta.y;
                    Rect fixedRect = FixRect(selectedRegion);
                    SelectionManager.SelectingNodes(Graph.Nodes.FindAll(n => n.IsInsideRect(fixedRect)).Select(n => n.Index).ToList());
                    break;
                }

                DashEditorWindow.SetDirty(true);
            }

            if (p_event.type == EventType.MouseUp)
            {
                if (dragging == DraggingType.SELECTION)
                {
                    SelectionManager.SelectingToSelected();
                }

                if (dragging == DraggingType.NODE_DRAG || dragging == DraggingType.BOX_DRAG || dragging == DraggingType.BOX_RESIZE)
                {
                    DashEditorCore.SetDirty();
                }

                dragging       = DraggingType.NONE;
                selectedRegion = Rect.zero;
                DashEditorWindow.SetDirty(true);
            }
        }
        private void LoadMonth(MonthControl month)
        {
            SelectionManager.ClearSelection();
            CopyPasteManager.ResetCopy();
            foreach (var existedMonth in xtraTabControl.TabPages.OfType <MonthControl>().ToList())
            {
                existedMonth.RaiseEvents(false);
            }

            var calendarMonth = (CalendarMonth)month.Tag;

            if (!month.HasData)
            {
                var weeks        = new List <DayControl[]>();
                var datesByWeeks = Calendar.CalendarContent.GetDaysByWeek(calendarMonth.DaysRangeBegin, calendarMonth.DaysRangeEnd);
                foreach (var weekDays in datesByWeeks)
                {
                    var week = new List <DayControl>();
                    foreach (var calendarDay in weekDays.Select(weekDay =>
                                                                Calendar.ActiveCalendarSection.Days.FirstOrDefault(x => x.Date.Equals(weekDay))))
                    {
                        if (calendarDay != null)
                        {
                            var dayControl = new DayControl(calendarDay);
                            dayControl.AllowToPasteNote = CopyPasteManager.SourceNote != null;
                            dayControl.DaySelected     += (sender, e) =>
                            {
                                SelectionManager.SelectDay(e.SelectedDay.Day, e.ModifierKeys);
                                CopyPasteManager.SetCopyDay();
                            };
                            dayControl.DayCopied      += (sender, e) => CopyDay();
                            dayControl.DayPasted      += (sender, e) => PasteDay();
                            dayControl.DayCloned      += (sender, e) => CloneDay();
                            dayControl.DayDataDeleted += (sender, e) =>
                            {
                                foreach (var day in SelectionManager.SelectedDays)
                                {
                                    day.ClearData();
                                    RefreshData();
                                }
                                Calendar.SettingsNotSaved = true;
                                Calendar.CalendarView.RefreshData();
                                Calendar.SlideInfo.LoadData();
                                Calendar.UpdateDataManagementAndOutputFunctions();
                            };
                            dayControl.DataChanged += (sender, e) =>
                            {
                                var day = sender as DayControl;
                                if (day == null)
                                {
                                    return;
                                }
                                Calendar.UpdateDataManagementAndOutputFunctions();
                                Calendar.SettingsNotSaved = true;
                            };

                            dayControl.SelectionStateRequested += (sender, e) => SelectionManager.ProcessSelectionStateRequest();
                            dayControl.DayMouseMove            += (sender, e) =>
                            {
                                foreach (var day in _days)
                                {
                                    if (day.Day.BelongsToSchedules && day.ClientRectangle.Contains(day.PointToClient(Cursor.Position)) &&
                                        day.RaiseEvents)
                                    {
                                        SelectionManager.SelectDay(day.Day, Keys.Control);
                                    }
                                }
                            };
                            dayControl.NoteAdded += (sender, e) =>
                            {
                                var noteDateRange = Calendar.CalendarContent
                                                    .CalculateDateRange(SelectionManager.SelectedDays.Select(x => x.Date).ToArray()).LastOrDefault();
                                AddNote(noteDateRange);
                                RefreshData();
                                Calendar.UpdateDataManagementAndOutputFunctions();
                            };
                            dayControl.NotePasted += (sender, e) =>
                            {
                                PasteNote();
                                RefreshData();
                            };
                            dayControl.ImageCopied += (sender, e) => CopyImage();
                            dayControl.ImagePasted += (sender, e) =>
                            {
                                ImageSource imageSource    = null;
                                var         clipboardImage = ClipboardHelper.GetPngFormClipboard();
                                if (clipboardImage != null)
                                {
                                    imageSource = ImageSource.FromImage(clipboardImage);
                                }
                                else if (Clipboard.ContainsText(TextDataFormat.Html))
                                {
                                    var textContent = Clipboard.GetText(TextDataFormat.Html);
                                    try
                                    {
                                        imageSource = ImageSource.FromString(textContent);
                                    }
                                    catch
                                    {
                                    }
                                }
                                PasteImage(imageSource);
                            };
                            dayControl.ImageDeleted += (sender, e) =>
                            {
                                foreach (var day in SelectionManager.SelectedDays)
                                {
                                    day.Logo = new ImageSource();
                                    RefreshData();
                                }
                                Calendar.SettingsNotSaved = true;
                                Calendar.CalendarView.RefreshData();
                                Calendar.UpdateDataManagementAndOutputFunctions();
                            };

                            SelectionManager.SelectionStateResponse += (sender, e) =>
                                                                       dayControl.UpdateNoteMenuAccordingSelection(SelectionManager.SelectedDays.OrderBy(x => x.Date).ToList());

                            CopyPasteManager.CopyDaySet += (sender, e) =>
                            {
                                dayControl.toolStripMenuItemCopy.Enabled  = true;
                                dayControl.toolStripMenuItemClone.Enabled = true;
                            };
                            CopyPasteManager.CopyReset += (sender, e) =>
                            {
                                dayControl.toolStripMenuItemCopy.Enabled  = false;
                                dayControl.toolStripMenuItemClone.Enabled = false;
                                dayControl.ChangeCopySource(false);
                            };
                            CopyPasteManager.PasteReset += (sender, e) =>
                            {
                                dayControl.toolStripMenuItemPaste.Enabled = false;
                                dayControl.AllowToPasteNote = false;
                            };
                            CopyPasteManager.DayCopied += (sender, e) =>
                            {
                                dayControl.toolStripMenuItemPaste.Enabled = true;
                                dayControl.ChangeCopySource(dayControl.Day.Date.Equals(CopyPasteManager.SourceDay.Date));
                            };
                            CopyPasteManager.NoteCopied += (sender, e) => { dayControl.AllowToPasteNote = true; };
                            Calendar.AssignCloseActiveEditorsonOutSideClick(dayControl);
                            week.Add(dayControl);
                            _days.Add(dayControl);
                        }
                        Application.DoEvents();
                    }
                    weeks.Add(week.ToArray());
                    Application.DoEvents();
                }
                month.AddDays(weeks.ToArray());
                month.AddNotes(GetNotesByWeeeks(calendarMonth));
            }
            month.RefreshData(Calendar.GetColorSchema(calendarMonth.OutputData.SlideColor));
            month.RaiseEvents(true);
            month.ResizeControls();
        }
Beispiel #15
0
 void TextContentChanged(object sender, EventArgs e)
 {
     Caret.Position = new TextLocation(0, 0);
     SelectionManager.ClearSelection();
 }
        /// <summary>
        /// This method executes a dialog key
        /// </summary>
        public bool ExecuteDialogKey(Keys keyData)
        {
            // try, if a dialog key processor was set to use this
            if (DoProcessDialogKey != null && DoProcessDialogKey(keyData))
            {
                return(true);
            }

            if (keyData == Keys.Back || keyData == Keys.Delete || keyData == Keys.Enter)
            {
                if (TextEditorProperties.UseCustomLine == true)
                {
                    if (SelectionManager.HasSomethingSelected)
                    {
                        if (Document.CustomLineManager.IsReadOnly(SelectionManager.SelectionCollection[0], false))
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        int curLineNr = Document.GetLineNumberForOffset(Caret.Offset);
                        if (Document.CustomLineManager.IsReadOnly(curLineNr, false) == true)
                        {
                            return(true);
                        }
                        if ((Caret.Column == 0) && (curLineNr - 1 >= 0) && keyData == Keys.Back &&
                            Document.CustomLineManager.IsReadOnly(curLineNr - 1, false) == true)
                        {
                            return(true);
                        }
                        if (keyData == Keys.Delete)
                        {
                            LineSegment curLine = Document.GetLineSegment(curLineNr);
                            if (curLine.Offset + curLine.Length == Caret.Offset &&
                                Document.CustomLineManager.IsReadOnly(curLineNr + 1, false) == true)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            // if not (or the process was 'silent', use the standard edit actions
            IEditAction action = motherTextEditorControl.GetEditAction(keyData);

            AutoClearSelection = true;
            if (action != null)
            {
                motherTextEditorControl.BeginUpdate();
                try {
                    lock (Document) {
                        action.Execute(this);
                        if (SelectionManager.HasSomethingSelected && AutoClearSelection /*&& caretchanged*/)
                        {
                            if (Document.TextEditorProperties.DocumentSelectionMode == DocumentSelectionMode.Normal)
                            {
                                SelectionManager.ClearSelection();
                            }
                        }
                    }
                } finally {
                    motherTextEditorControl.EndUpdate();
                    Caret.UpdateCaretPosition();
                }
                return(true);
            }
            return(false);
        }