public void syncActionItems()
        {
            HyperlinkCollection hlc = richEditControl1.Document.Hyperlinks;
            List <Hyperlink>    linksRequireUpdate = new List <Hyperlink>();

            foreach (var h in hlc)
            {
                Guid taskID;
                bool taskIDFound = extractTaskIDFromHyperlink(h, out taskID);
                if (taskIDFound == true)
                {
                    //Hyperlink currentHyperlink = h;
                    Tasks t = _parentForm.getTaskByTaskID(taskID);
                    if (t == null)
                    {
                        continue;
                    }

                    h.ToolTip = t.getTaskSummary();
                    string requiredAIText = getAIText(t.getUserName(), t.dueDate);
                    string currentAIText  = richEditControl1.Document.GetText(h.Range);
                    if (requiredAIText != currentAIText)
                    {
                        linksRequireUpdate.Add(h);
                    }

                    DevExpress.XtraRichEdit.API.Native.CharacterProperties characterProperties = richEditControl1.Document.BeginUpdateCharacters(h.Range);
                    if (t.dueDate.HasValue && t.dueDate.Value <= DateTime.Now && !(t.taskStatusID == 5 || t.taskStatusID == 4))
                    {
                        characterProperties.BackColor = Color.Red;
                    }
                    else
                    {
                        characterProperties.BackColor = _parentForm.getColorForStatus(t.taskStatusID.ToString());
                    }
                    richEditControl1.Document.EndUpdateCharacters(characterProperties);
                }
            }

            foreach (Hyperlink h in linksRequireUpdate)
            {
                Guid  taskID;
                bool  taskIDFound = extractTaskIDFromHyperlink(h, out taskID);
                Tasks t           = _parentForm.getTaskByTaskID(taskID);
                richEditControl1.Document.Replace(h.Range, getAIText(t.getUserName(), t.dueDate));
            }
        }
Exemplo n.º 2
0
        public void syncActionItems()
        {
            HyperlinkCollection hlc = richEditControl1.Document.Hyperlinks;
            List <Hyperlink>    linksRequireUpdate = new List <Hyperlink>();

            foreach (var h in hlc)
            {
                Guid taskID;
                bool taskIDFound = extractTaskIDFromHyperlink(h, out taskID);
                if (taskIDFound == true)
                {
                    //Hyperlink currentHyperlink = h;
                    Tasks t = _parent.getTaskByTaskID(taskID);
                    if (t == null)
                    {
                        continue;
                    }

                    h.ToolTip = t.getTaskSummary();
                    string requiredAIText = getAIText(t.getUserName());
                    string currentAIText  = richEditControl1.Document.GetText(h.Range);
                    if (requiredAIText != currentAIText)
                    {
                        linksRequireUpdate.Add(h);
                    }

                    DevExpress.XtraRichEdit.API.Native.CharacterProperties characterProperties = richEditControl1.Document.BeginUpdateCharacters(h.Range);
                    characterProperties.BackColor = _parent.getColorForStatus(t.taskStatusID.ToString());// .Italic = true;
                    richEditControl1.Document.EndUpdateCharacters(characterProperties);
                }
            }

            foreach (Hyperlink h in linksRequireUpdate)
            {
                Guid  taskID;
                bool  taskIDFound = extractTaskIDFromHyperlink(h, out taskID);
                Tasks t           = _parent.getTaskByTaskID(taskID);
                richEditControl1.Document.Replace(h.Range, getAIText(t.getUserName()));
                //int hyperlinkStartLocation = h.Range.Start.ToInt()-1;
                //richEditControl1.Document.Delete(h.Range);
                //DocumentPosition beginingOfHyperLink = richEditControl1.Document.CreatePosition(hyperlinkStartLocation);
                //string AIText = addActionItemText(beginingOfHyperLink, t.ID, t.getUserName());
                //richEditControl1.Document.CaretPosition = beginingOfHyperLink;
                //ChangeTextToHyperlink(AIText, t.ID);
            }
        }
        private void ApplyFormatToSelectedText()
        {
            DocumentRange targetSelectedRange = richEditControl.Document.Selection;

            richEditControl.BeginUpdate();
            SubDocument targetSubDocument = targetSelectedRange.BeginUpdateDocument();
            SubDocument subDocument       = sourceSelectedRange.BeginUpdateDocument();

            DevExpress.XtraRichEdit.API.Native.CharacterProperties targetCharactersProperties = targetSubDocument.BeginUpdateCharacters(targetSelectedRange);
            DevExpress.XtraRichEdit.API.Native.CharacterProperties sourceCharactersProperties = subDocument.BeginUpdateCharacters(sourceSelectedRange);
            targetCharactersProperties.Assign(sourceCharactersProperties);
            subDocument.EndUpdateCharacters(sourceCharactersProperties);
            targetSubDocument.EndUpdateCharacters(targetCharactersProperties);

            DevExpress.XtraRichEdit.API.Native.ParagraphProperties targetParagraphProperties = targetSubDocument.BeginUpdateParagraphs(targetSelectedRange);
            DevExpress.XtraRichEdit.API.Native.ParagraphProperties sourceParagraphProperties = subDocument.BeginUpdateParagraphs(sourceSelectedRange);
            targetParagraphProperties.Assign(sourceParagraphProperties);
            subDocument.EndUpdateParagraphs(sourceParagraphProperties);
            targetSubDocument.EndUpdateParagraphs(targetParagraphProperties);

            sourceSelectedRange.EndUpdateDocument(subDocument);
            targetSelectedRange.EndUpdateDocument(targetSubDocument);
            richEditControl.EndUpdate();
        }