Пример #1
0
 public void InvalidParseTest()
 {
     Row testRow = new Row("");
     Assert.IsFalse(testRow.HasText, "Row shouldn't have text.");
     Assert.IsFalse(testRow.HasContexts, "Row shouldn't have contexts.");
     Assert.IsFalse(testRow.HasProjects, "Row shouldn't have projects.");
 }
Пример #2
0
        public void CompletedParseTest()
        {
            Row testRow = new Row("x 2013-04-19 (B) due:2013-04-20 +CS3241 Lab 5 @Coding +University");
            Assert.IsTrue(testRow.IsCompleted, "Row should be completed.");
            Assert.IsTrue(testRow.HasContexts, "Row should have contexts.");
            Assert.IsTrue(testRow.HasProjects, "Row should have projects.");
            Assert.IsTrue(testRow.HasPriority, "Row should have priority.");

            Assert.AreEqual(testRow.CompletionDate, new DateTime(2013, 04, 19), "Row should have correct completion date.");
        }
Пример #3
0
        public void BasicParseTest()
        {
            Row testRow = new Row("Initial version of +Todopad @Coding");
            Assert.IsNotNull(testRow, "Row shouldn't be null.");

            Assert.IsTrue(testRow.HasContexts, "Row should have contexts.");
            Assert.AreEqual(testRow.Contexts[0], "+Todopad", "Row should have correct context.");
            Assert.IsTrue(testRow.HasProjects, "Row should have projects.");
            Assert.AreEqual(testRow.Projects[0], "@Coding", "Row should have correct project.");
        }
Пример #4
0
        private static void FormatParagraph(Paragraph currentParagraph)
        {
            // Get the text on this row.
            TextPointer start = currentParagraph.ContentStart;
            TextPointer end = currentParagraph.ContentEnd;
            TextRange currentTextRange = new TextRange(start, end);

            // Parse the row.
            Row currentRow = new Row(currentTextRange.Text);

            // Format the displayed text.
            TaskParser.FormatTextRange(currentTextRange, currentRow);
        }
Пример #5
0
        public static void FormatTextRange(TextRange range, Row row)
        {
            range.ClearAllProperties();

            if (!row.HasText)
            {
                return;
            }

            if (row.IsCompleted)
            {
                range.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Gray);
                range.ApplyPropertyValue(TextElement.FontStyleProperty, FontStyles.Italic);
                return;
            }

            TextPointer start = range.Start;

            if (row.HasPriority)
            {
                TextPointer priorityStart = GetTextPointAtOffset(start, row.PriorityRange.Item1);
                TextPointer priorityEnd = GetTextPointAtOffset(start, row.PriorityRange.Item2);
                TextRange priorityRange = new TextRange(priorityStart, priorityEnd);

                priorityRange.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
                priorityRange.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Blue);
            }

            if (row.HasCreationDate)
            {
                TextPointer dateStart = GetTextPointAtOffset(start, row.CreationDateRange.Item1);
                TextPointer dateEnd = GetTextPointAtOffset(start, row.CreationDateRange.Item2);
                TextRange dateRange = new TextRange(dateStart, dateEnd);

                dateRange.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
                dateRange.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.DarkGreen);
            }

            if (row.HasContexts)
            {
                foreach (Tuple<int, int> contextRange in row.ContextRanges)
                {
                    TextPointer contextStart = GetTextPointAtOffset(start, contextRange.Item1);
                    TextPointer contextEnd = GetTextPointAtOffset(start, contextRange.Item2);
                    TextRange contextTextRange = new TextRange(contextStart, contextEnd);

                    contextTextRange.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
                    contextTextRange.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.DarkCyan);
                }
            }

            if (row.HasProjects)
            {
                foreach (Tuple<int, int> projectRange in row.ProjectRanges)
                {
                    TextPointer projectStart = GetTextPointAtOffset(start, projectRange.Item1);
                    TextPointer projectEnd = GetTextPointAtOffset(start, projectRange.Item2);
                    TextRange projectTextRange = new TextRange(projectStart, projectEnd);

                    projectTextRange.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
                    projectTextRange.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.SaddleBrown);
                }
            }
        }