Exemple #1
0
        private void Remove_Button_Click(object sender, RoutedEventArgs e)
        {
            var result = MessageBox.Show("Are you sure you want to remove the selected task?", "Confirm removal", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (MessageBoxResult.No == result)
            {
                return;
            }


            ReSorter sorter = new ReSorter(Display_DataGrid);

            sorter.PrepareToReSort();

            Task tmp = Display_DataGrid.SelectedItem as Task;

            int index = Display_DataGrid.SelectedIndex;

            TaskManagerDB.RemoveTask(tmp.Id);

            PrepareDataGridBinding();

            // When a row is removed, another one is selected
            // If there are none left to be selected, buttons are disabled

            Display_DataGrid.SelectedIndex = index - 1;

            if (Display_DataGrid.SelectedItem == null)
            {
                Modify_Button.IsEnabled = false;
                Remove_Button.IsEnabled = false;
            }
            sorter.ReSort();
        }
Exemple #2
0
        private void Add_Button_Click(object sender, RoutedEventArgs e)
        {
            ReSorter sorter = new ReSorter(Display_DataGrid);

            sorter.PrepareToReSort();


            Add addWindow = new Add();

            addWindow.ShowDialog();

            PrepareDataGridBinding();

            sorter.ReSort();
        }
Exemple #3
0
        private void Modify()
        {
            ReSorter sorter = new ReSorter(Display_DataGrid);

            sorter.PrepareToReSort();

            Task tmp = Display_DataGrid.SelectedItem as Task;

            Edit editWindow = new Edit(tmp);

            editWindow.ShowDialog();

            PrepareDataGridBinding();

            sorter.ReSort();
        }