public void Close_CreateTask(object sender, RoutedEventArgs e)
        {
            CreateTaskStackPanel.Visibility = Visibility.Collapsed;
            AddTaskBtn.Visibility           = Visibility.Visible;

            Screenbuilder.BuildTaskField(taskStack);
        }
        public MainWindow()
        {
            InitializeComponent();
            DatabaseConnector.Connect();


            Closing += new CancelEventHandler(MainWindow_Closing);

            double screenHeight = SystemParameters.MaximizedPrimaryScreenHeight;

            Height = screenHeight;
            Top    = 0;
            Width  = 600;
            Left   = SystemParameters.PrimaryScreenWidth - Width;

            FontFamily = new FontFamily("Franklin Gothic Medium");

            addBtn.Background     = Brushes.Aquamarine;
            settingBtn.Background = Brushes.PaleVioletRed;
            settingBtn.FontSize   = 8;
            saveBtn.Background    = Brushes.Aquamarine;
            cancelBtn.Background  = Brushes.Tomato;

            comboImportance.ItemsSource = new List <string> {
                "Low", "Medium", "High"
            };
            comboState.ItemsSource = new List <string> {
                "New", "InProgress", "Paused", "Done"
            };

            Screenbuilder.BuildTaskField(taskStack);

            TaskStackPanel       = taskStack;
            CreateTaskStackPanel = CreateTaskStack;
            AddTaskBtn           = addBtn;

            StateStackPanel = StateStack;
            TaskID          = txtID;
            TaskName        = txtName;
            TaskDescription = txtDescription;
            TaskDueDate     = DatePick;
            TaskImportance  = comboImportance;
            TaskState       = comboState;

            HideDoneTasks = false;
        }
        public void Hide_UnhideTask(object sender, RoutedEventArgs e)
        {
            if (HideDoneTasks)
            {
                HideDoneTasks         = false;
                settingBtn.Content    = "Hide Done Tasks";
                settingBtn.Background = Brushes.PaleVioletRed;
            }
            else
            {
                HideDoneTasks         = true;
                settingBtn.Content    = "Show Done Tasks";
                settingBtn.Background = Brushes.DarkCyan;
            }

            Screenbuilder.BuildTaskField(taskStack);
        }
        public void Save_Task(object sender, RoutedEventArgs e)
        {
            if (Validate())
            {
                Importance importance = Importance.Low;
                switch (comboImportance.Text)
                {
                case "Medium": importance = Importance.Medium; break;

                case "High": importance = Importance.High; break;
                }

                State state = State.New;
                switch (comboState.Text)
                {
                case "InProgress": state = State.InProgress; break;

                case "Paused": state = State.Paused; break;

                case "Done": state = State.Done; break;
                }

                if (SaveCommand == "Create")
                {
                    var task = new Task(0, txtName.Text, txtDescription.Text, DateTime.Parse(DatePick.Text), State.New, importance, string.Empty, null);
                    DatabaseManager.InsertTask(task);
                }
                else if (SaveCommand == "Edit")
                {
                    var task = new Task(Convert.ToInt32(txtID.Text), txtName.Text, txtDescription.Text, DateTime.Parse(DatePick.Text), state, importance, string.Empty, null);
                    DatabaseManager.UpdateTask(task);
                }

                CreateTaskStackPanel.Visibility = Visibility.Collapsed;
                AddTaskBtn.Visibility           = Visibility.Visible;

                txtID.Text  = string.Empty;
                SaveCommand = string.Empty;

                Screenbuilder.BuildTaskField(taskStack);
            }
        }
Exemple #5
0
        private static void DeleteTask(object sender, RoutedEventArgs e)
        {
            var tasks = DatabaseManager.GetAllTasks();

            if (tasks != null && tasks.Any())
            {
                var deleteBtn = (Button)sender;
                var task      = tasks.Find(t => t.ID == Convert.ToInt32(deleteBtn.Name.Split('_')[1]));

                if (task != null)
                {
                    var result = MessageBox.Show($"Do you really want to delete Task {task.Name}?", "Confirm deletion", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (result == MessageBoxResult.Yes)
                    {
                        DatabaseManager.DeleteTask(task.ID);
                    }
                }
            }

            Screenbuilder.BuildTaskField(MainWindow.TaskStackPanel);
        }