Пример #1
0
        private void SelectCurrentLine()
        {
            StartOfLineCommand startOfLineCommand = new StartOfLineCommand(richEditControl1);
            EndOfLineCommand   endOfLineCommand   = new EndOfLineCommand(richEditControl1);

            startOfLineCommand.Execute();

            int start = richEditControl1.Document.CaretPosition.ToInt();

            endOfLineCommand.Execute();

            int length = richEditControl1.Document.CaretPosition.ToInt() - start;

            DocumentRange AITextRange            = richEditControl1.Document.CreateRange(start, length);
            DocumentRange AITextRangeWithNewLine = richEditControl1.Document.CreateRange(start, length + 1);

            string text = richEditControl1.Document.GetText(AITextRangeWithNewLine);

            if (text.EndsWith(Environment.NewLine))
            {
                richEditControl1.Document.Selection = AITextRangeWithNewLine;
            }
            else
            {
                richEditControl1.Document.Selection = AITextRange;
            }
        }
        DocumentRange GetNewLineRange(DocumentPosition caret)
        {
            isSelectionLocked = true;
            DocumentPosition currentPosition = richEditControl1.Document.CaretPosition;

            StartOfLineCommand startOfLineCommand = new StartOfLineCommand(richEditControl1);
            EndOfLineCommand   endOfLineCommand   = new EndOfLineCommand(richEditControl1);

            startOfLineCommand.Execute();

            int start = richEditControl1.Document.CaretPosition.ToInt();

            endOfLineCommand.Execute();

            int length = richEditControl1.Document.CaretPosition.ToInt() - start;

            DocumentRange range  = richEditControl1.Document.CreateRange(start, length);
            DocumentRange range2 = richEditControl1.Document.CreateRange(start, length + 1);

            string text = richEditControl1.Document.GetText(range2);

            richEditControl1.Document.CaretPosition = currentPosition;
            isSelectionLocked = false;
            if (text.EndsWith(Environment.NewLine))
            {
                return(range2);
            }
            else
            {
                return(range);
            }
        }
        private void createTask(enTaskType type)
        {
            saveCaretPosition();
            string selectedLineText = getSelectedLineText();

            System.Text.RegularExpressions.Match match = FindActionItemPatternInText(selectedLineText);
            if (match.Captures.Count > 0)
            {
                MessageBox.Show(string.Format("This line is already attached with Action Item: '{0}'", match.ToString()), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            StartOfLineCommand startOfLineCommand = new StartOfLineCommand(richEditControl1);

            startOfLineCommand.Execute();
            DocumentPosition beginOfLine = richEditControl1.Document.CaretPosition;

            if (_parentForm.isTaskListDirty())
            {
                _parentForm.save(false);
            }

            //create task
            TaskForm newTaskForm = new TaskForm(_parentForm, new Tasks()
            {
                taskName = selectedLineText.Substring(0, Math.Min(128, selectedLineText.Length)), remarks = selectedLineText, updateRequester = false, projectID = Guid.Parse("00000000-0000-0000-0000-000000000000"), requesterID = Guid.Parse("00000000-0000-0000-0000-000000000000")
            }, formMode.add, type);

            _parentForm.openTaskForm(newTaskForm);

            if (newTaskForm.DialogResult == DialogResult.OK)
            {
                using (new Splash(this.Parent as Form))
                {
                    using (var model = new DocumentModel())
                    {
                        string aiCaption = addActionItemText(beginOfLine, newTaskForm._task.ID, newTaskForm._task.getUserName(), newTaskForm._task.dueDate);
                        startOfLineCommand.Execute();     //Go back to begining of line and make the inserted text as hyperlink
                        ChangeTextToHyperlink(aiCaption, newTaskForm._task.ID);
                        SaveMeetingRTF();
                    }
                    syncActionItems();
                }
            }
        }
Пример #4
0
        public void focusOnHyperlink(Guid taskID)
        {
            HyperlinkCollection hlc = richEditControl1.Document.Hyperlinks;

            StartOfLineCommand startOfLineCommand = new StartOfLineCommand(richEditControl1);

            startOfLineCommand.Execute();

            foreach (var h in hlc)
            {
                Guid extractedTaskID;
                bool taskIDFound = extractTaskIDFromHyperlink(h, out extractedTaskID);
                if (taskIDFound == true && extractedTaskID == taskID)
                {
                    richEditControl1.Document.CaretPosition = richEditControl1.Document.CreatePosition(h.Range.Start.ToInt());
                    richEditControl1.ScrollToCaret();
                    richEditControl1.Document.Selection = h.Range;
                }
            }
        }