Exemple #1
0
        private void deleteButton_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Are you sure you want delete this category? Any task that's assigned to this category will be assigned to the None category.", "Delete category?", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
            {
                return;
            }

            CategoriesListItem item = categoriesListView.SelectedItem as CategoriesListItem;

            if (item != null)
            {
                int category_index = Workspace.Instance.Categories.IndexOf(item.Category);
                if (category_index >= 0)
                {
                    // Reset all tasks that are assigned to this category
                    foreach (Workspace.Pile pile in Workspace.Instance.Piles)
                    {
                        foreach (Workspace.Task task in pile.Tasks)
                        {
                            if (task.CategoryIndex == category_index)
                            {
                                task.CategoryIndex = -1;
                            }
                        }
                    }

                    Workspace.Instance.RemoveCategoryAt(category_index);
                    RebuildListView();
                }
            }
        }
Exemple #2
0
        private void RebuildListView()
        {
            Workspace.Category selected_item = null;

            if (categoriesListView.SelectedItem != null)
            {
                selected_item = (categoriesListView.SelectedItem as CategoriesListItem).Category;
            }

            categoriesListView.Items.Clear();

            foreach (Workspace.Category category in Workspace.Instance.Categories)
            {
                CategoriesListItem item = new CategoriesListItem();
                item.Color    = category.Color.ToString();
                item.Title    = category.Title;
                item.Category = category;

                categoriesListView.Items.Add(item);
            }

            if (selected_item != null)
            {
                int idx = Workspace.Instance.Categories.IndexOf(selected_item);
                if (idx >= 0)
                {
                    categoriesListView.SelectedIndex = idx;
                }
            }
        }
Exemple #3
0
        private void pickColorRect_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            CategoriesListItem item = categoriesListView.SelectedItem as CategoriesListItem;

            if (item != null)
            {
                colorRect.Fill = (sender as Rectangle).Fill;
            }
        }
Exemple #4
0
        private void modifyButton_Click(object sender, RoutedEventArgs e)
        {
            CategoriesListItem item = categoriesListView.SelectedItem as CategoriesListItem;

            if (item != null)
            {
                item.Category.Title = titleTextBox.Text;
                item.Category.Color = (colorRect.Fill as SolidColorBrush).Color;
                RebuildListView();
            }
        }
Exemple #5
0
        private void UpdateSelectedItemFields()
        {
            CategoriesListItem item = categoriesListView.SelectedItem as CategoriesListItem;

            if (item != null)
            {
                titleTextBox.IsEnabled       = true;
                modifyButton.IsEnabled       = true;
                colorPickersPanel.Visibility = Visibility.Visible;

                colorRect.Fill    = new SolidColorBrush(item.Category.Color);
                titleTextBox.Text = item.Title;
            }
            else
            {
                titleTextBox.IsEnabled       = false;
                modifyButton.IsEnabled       = false;
                colorPickersPanel.Visibility = Visibility.Hidden;

                titleTextBox.Text = "";
            }
        }