Ejemplo n.º 1
0
        private void DeleteItem(object sender, DragEventArgs e)
        {
            base.OnDrop(e);

            if (e.Data.GetDataPresent("Task"))   // task deletion
            {
                Task task = (Task)e.Data.GetData("Task");

                // Process message box results
                string           messageBoxText = "Do you want to delete task?";
                string           caption        = "Dialog window";
                MessageBoxButton button         = MessageBoxButton.YesNo;
                MessageBoxImage  icon           = MessageBoxImage.Warning;
                MessageBoxResult result         = MessageBox.Show(messageBoxText, caption, button, icon);

                // Process message box results
                switch (result)
                {
                case MessageBoxResult.Yes:
                    DatabaseTask.DeleteTask(task);
                    break;

                case MessageBoxResult.No:
                    break;
                }
                Repaint();
            }
            else if (e.Data.GetDataPresent("Note"))     // note deletion
            {
                Note note = (Note)e.Data.GetData("Note");

                // confirmation
                string           messageBoxText = "Do you want to delete the note?";
                string           caption        = "Dialog window";
                MessageBoxButton button         = MessageBoxButton.YesNo;
                MessageBoxImage  icon           = MessageBoxImage.Warning;
                MessageBoxResult result         = MessageBox.Show(messageBoxText, caption, button, icon);

                switch (result)
                {
                case MessageBoxResult.Yes:
                    DatabaseNote.DeleteNote(note);
                    break;

                case MessageBoxResult.No:
                    break;
                }
                Repaint();
            }
            e.Handled = true;
        }