FrameworkElement renderTodoItem(FrameworkElement content, TodoTextItem item) { var stack = new StackPanel() { Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left }; stack.Children.Add(content); stack.Children.Add(new Image() { Source = new BitmapImage(new Uri("ms-appx:///Assets/todo.png")), Height = 10, Margin = new Thickness() { Left = 10 } }); var check = new CheckBox() { Content = stack }; return(check); }
private List <TextItem> GetContentFromText(string text) { List <TextItem> items = new List <TextItem>(); foreach (var line in text.Split('\n')) { if (line.Trim().ToLower().StartsWith("todo:")) { items.Add(TodoTextItem.Create(line)); } else { items.Add(new TextItem() { Text = line }); } } return(items); }
async void EditContext_TextUpdating(CoreTextEditContext sender, CoreTextTextUpdatingEventArgs args) { CoreTextRange range = args.Range; string newText = args.Text; CoreTextRange newSelection = args.NewSelection; var line = _content[CurrentLine].Text; //// Modify the internal text store. _content[CurrentLine].Text = line.Substring(0, range.StartCaretPosition) + newText + line.Substring(Math.Min(line.Length, range.EndCaretPosition)); if (_content[CurrentLine].Text.Trim().ToLower().StartsWith("todo:") && _content[CurrentLine] is not TodoTextItem) { var todoItem = new TodoTextItem() { Text = _content[CurrentLine].Text.Trim().Substring(5) }; // convert item to todo _content.RemoveAt(CurrentLine); _content.Insert(CurrentLine, todoItem); newSelection.StartCaretPosition = newSelection.EndCaretPosition = 0; // had to add this to make sure it works await Task.Delay(2); SetSelectionAndNotify(newSelection); } else { //// Modify the current selection. newSelection.EndCaretPosition = newSelection.StartCaretPosition; //// Update the selection of the edit context. There is no need to notify the system //// because the system itself changed the selection. SetSelection(newSelection); } }