コード例 #1
0
        private TopicView2 GetTopicView(UIElementCollection elementCollection, string topic)
        {
            string topicName = Topic.None.Equals(topic.ToLower().Trim()) ? this.NoneTopicName : topic.Trim();

            foreach (UIElement?view in elementCollection)
            {
                TopicView2?topicView = view as TopicView2;
                if (topicView == null)
                {
                    continue;
                }

                if (topicView.TopicName.ToLower().Trim() == topicName.ToLower())
                {
                    return(topicView);
                }
            }


            // If we didn't find a TopicView2, Create one and add it to the given ElementCollection
            TopicView2 tView = CreateTopicView(topicName, GetTopicColor(topicName));

            elementCollection.Add(tView);
            if (!this.TopicColors.ContainsKey(topicName))
            {
                this.TopicColors.Add(topicName, tView.TopicColor);
            }
            return(tView);
        }
コード例 #2
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);
            }
        }
コード例 #3
0
        private void TopicView_TaskStatusChanged(TopicView2 topicView, Tasklib.Task task, bool newStatus)
        {
            if (newStatus != task.Done)
            {
                // Remove the Task from the TopicView2 it was in
                topicView.RemoveTask(task);
                if (newStatus) // status is done, was open
                {
                    task.SetDone();
                    MoveTask(task, stkpnlCompletedTasks);
                    if (topicView.Tasks == 0)
                    {
                        stkpnlOpenTasks.Children.Remove(topicView);
                    }
                }
                else
                {
                    task.SetUndone();
                    MoveTask(task, stkpnlOpenTasks);
                    if (topicView.Tasks == 0)
                    {
                        stkpnlCompletedTasks.Children.Remove(topicView);
                    }
                }

                this.Save();
            }
            topicView.OrderTasks();
        }
コード例 #4
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;
            }
        }
コード例 #5
0
        private TopicView2 CreateTopicView(string topicname, HSVColor topicColor)
        {
            TopicView2 topicView = new TopicView2();

            topicView.Margin             = new Thickness(0, 0, 0, 10);
            topicView.TopicName          = topicname;
            topicView.TopicColor         = topicColor;
            topicView.TaskStatusChanged += TopicView_TaskStatusChanged;
            return(topicView);
        }