示例#1
0
        private void FillTasklist(StackPanel stackPanel, bool done)
        {
            stackPanel.Children.Clear();
            foreach (Topic topic in this.TaskManager.Topics)
            {
                string topicname = Topic.None.Equals(topic) ? this.NoneTopicName : topic.Name;
                Task[] tasks     = this.TaskManager.GetTasksByTopic(topic.Name).Where(t => { return(t.Done == done); }).ToArray();
                if (tasks.Length == 0)
                {
                    continue;
                }

                // Sort by Completed Date
                tasks = tasks.OrderBy(t => done ? t.CompletionTime : t.CreationTime).ToArray();
                TopicView2 topicView = CreateTopicView(topicname, GetTopicColor(topicname));

                if (!this.TopicColors.ContainsKey(topicname))
                {
                    this.TopicColors.Add(topicname, topicView.TopicColor);
                }

                foreach (Tasklib.Task task in tasks)
                {
                    topicView.AddTask(task);
                }

                stackPanel.Children.Add(topicView);
            }
        }
示例#2
0
        private void tbNewTask_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                TextBox?tb = sender as TextBox;
                if (tb == null || string.IsNullOrWhiteSpace(tb.Text))
                {
                    e.Handled = true;
                    return;
                }

                string       text = tb.Text;
                Tasklib.Task?t    = this.Parse(text);
                if (t != null)
                {
                    TopicView2 topicView = GetTopicView(stkpnlOpenTasks.Children, t.Topic);
                    topicView.AddTask(t);
                    topicView.OrderTasks();
                }
                tb.Clear();
                this.Save();

                e.Handled = true;
            }
        }