Пример #1
0
 private void BtnDeleteCurrentBoard_Click(object sender, RoutedEventArgs e)
 {
     var currentBoard = kanbanNavView.SelectedItem as BoardViewModel;
     deleteBoardFlyout.Hide();
     if (currentBoard != null)
     {
         try
         {
             var deleteBoardSuccess = ViewModel.DeleteBoard(currentBoard);
             if (deleteBoardSuccess)
             {
                 kanbanNavView.SelectedItem = null;
                 var index = kanbanNavView.MenuItems.IndexOf(currentBoard);
                 kanbanNavView.MenuItems.Remove(currentBoard);
                 if (ViewModel.BoardList.Count == 0)
                 {
                     TitleBarCurrentBoardTextblock.Text = ""; // Clear heading on title bar
                     contentFrame.Navigate(typeof(NoBoardsMessageView));
                 }
                 else
                 {
                     kanbanNavView.SelectedItem = ViewModel.BoardList[index - 1];
                     contentFrame.Navigate(typeof(BoardView), ViewModel.BoardList[index - 1]);
                 }
             }
         }
         catch(Exception ex)
         {
             Console.WriteLine(ex.Message);
             KanbanInAppNotification.Show("Unable to delete board. Try again or restart the application and then try.", 3000);
         }
     }
     else
         UnableToDeleteBoardTeachingTip.IsOpen = true;
 }
Пример #2
0
        /// <summary>
        /// Used for touch screen users, but works for PC users too
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void FlyoutBtnDelete_Click(object sender, RoutedEventArgs e)
        {
            // Hide flyout
            taskFlyout.Hide();

            // Create dialog and check button click result
            var deleteDialog = new DeleteConfirmationView();
            var result       = await deleteDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                // Close pane when done
                splitView.IsPaneOpen = false;

                // Delete Task from collection and databaseIn
                var deleteSuccess = (SelectedModel != null) ? ViewModel.DeleteTask(SelectedModel) : false;


                if (deleteSuccess)
                {
                    UpdateCardIndexes();
                    KanbanInAppNotification.Show("Task deleted from board successfully", 3000);
                }
                else
                {
                    KanbanInAppNotification.Show("Task failed to be deleted. Please try again or restart the application.", 3000);
                }
            }
            else
            {
                return;
            }
        }
Пример #3
0
        private async void CardBtnDelete_Click(object sender, RoutedEventArgs e)
        {
            var originalSource = (FrameworkElement)sender;

            SelectedModel = originalSource.DataContext as CustomKanbanModel;

            // Create dialog and check button click result
            var deleteDialog = new DeleteConfirmationView();
            var result       = await deleteDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                // Close pane when done
                splitView.IsPaneOpen = false;

                // Delete Task from collection and database
                var deleteSuccess = (SelectedModel != null) ? ViewModel.DeleteTask(SelectedModel) : false;

                if (deleteSuccess)
                {
                    KanbanInAppNotification.Show("Task deleted from board successfully", 4000);
                }
            }
            else
            {
                return;
            }
        }
Пример #4
0
        private void BtnDeleteTag_Click(object sender, RoutedEventArgs e)
        {
            var btn           = sender as Button;
            var tagName       = btn.DataContext as string;
            var deleteSuccess = ViewModel.DeleteTag(tagName);

            if (deleteSuccess)
            {
                KanbanInAppNotification.Show("Tag deleted successfully", 3000);
            }
            else
            {
                KanbanInAppNotification.Show("Tag could not be deleted", 3000);
            }
        }
Пример #5
0
        private void FlyoutDeleteCardBtnYes_Click(object sender, RoutedEventArgs e)
        {
            // Close pane when done
            splitView.IsPaneOpen = false;

            // Delete Task from collection and database
            var deleteSuccess = (SelectedModel != null) ? ViewModel.DeleteTask(SelectedModel) : false;

            if (deleteSuccess)
            {
                UpdateCardIndexes();
                KanbanInAppNotification.Show("Task deleted from board successfully", 3000);
            }
            else
            {
                KanbanInAppNotification.Show("Task failed to be deleted. Please try again or restart the application.", 3000);
            }
        }
Пример #6
0
 private void FlyoutBtnUpdateBoard_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var currentBoard = kanbanNavView.SelectedItem as BoardViewModel;
         var currentIndex = kanbanNavView.MenuItems.IndexOf(currentBoard);
         var updateBoardSuccess = ViewModel.UpdateBoard(currentBoard, currentIndex);
         editBoardFlyout.Hide();
         if (updateBoardSuccess)
         {
             // Already updated in db, now update navview
             currentBoard.BoardName = ViewModel.BoardName;
             currentBoard.BoardNotes = ViewModel.BoardNotes;
             kanbanNavView.MenuItems[currentIndex] = currentBoard;
             ViewModel.Current = currentBoard;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         KanbanInAppNotification.Show("Unable to update board. Try again or restart the application and then try.", 3000);
     }
 }
Пример #7
0
 private void TxtBoxTags_KeyDown(object sender, KeyRoutedEventArgs e)
 {
     // Add Tag to listview on keydown event
     if (e.Key == Windows.System.VirtualKey.Enter)
     {
         var tagsTextBox = sender as TextBox;
         if (tagsTextBox.Text == "")
         {
             return;
         }
         else
         {
             if (ViewModel.TagsCollection.Contains(tagsTextBox.Text))
             {
                 KanbanInAppNotification.Show("Tag already exists", 3000);
             }
             else
             {
                 ViewModel.AddTagToCollection(tagsTextBox.Text);
             }
             tagsTextBox.Text = "";
         }
     }
 }
Пример #8
0
        private void BtnSaveTask_Click(object sender, RoutedEventArgs e)
        {
            if (ViewModel.CardModel != null) // Editing a Task
            {
                // UI-related operations
                // Store tags as a single string using csv format
                // When calling GetData(), the string will be parsed into separate tags and stored into the list view
                List <string> tagsList = new List <string>();
                foreach (var tag in lstViewTags.Items)
                {
                    tagsList.Add(tag.ToString());
                }
                var tags = string.Join(',', tagsList); // Convert to a csv string to store in database cell

                // Use view model to operate on model-related data
                var selectedCategory = ViewModel.CurrentCategory;
                var selectedColorKey = comboBoxColorKey.SelectedItem;
                var updateSuccess    = ViewModel.SaveTask(tags, selectedCategory, selectedColorKey, SelectedModel);

                // Close pane when done
                if (splitView.IsPaneOpen == true)
                {
                    splitView.IsPaneOpen = false;
                }

                if (updateSuccess)
                {
                    SelectedModel.ColorKey = selectedColorKey;
                    KanbanInAppNotification.Show("Task successfully updated", 3000);
                }
                else
                {
                    KanbanInAppNotification.Show("Task could not be updated", 3000);
                }
            }
            else if (ViewModel.CardModel == null) // Creating a Task
            {
                List <string> tagsList = new List <string>();
                foreach (var tag in lstViewTags.Items)
                {
                    tagsList.Add(tag.ToString());
                }
                var tags = string.Join(',', tagsList); // Convert to single string
                if (tags == "")
                {
                    tags = null;
                }

                // To allow a draft task, require user to have category and colorkey chosen
                if (comboBoxColorKey.SelectedItem == null)
                {
                    ChoosePriorityInidcatorTeachingTip.IsOpen = true;
                }
                else
                {
                    var selectedCategory = ViewModel.CurrentCategory;
                    var selectedColorKey = comboBoxColorKey.SelectedItem;

                    // Returns a tuple (bool addSuccess, int id) for success validation and
                    // compare the created cards ID to the
                    var returnedTuple = ViewModel.AddTask(tags, selectedCategory, selectedColorKey);
                    var addSuccess    = returnedTuple.Item1;
                    var newTaskId     = returnedTuple.Item2;

                    // Get column index of card just added
                    // To-do: Efficient implementation once functionality is working
                    foreach (var col in kanbanBoard.ActualColumns)
                    {
                        if (col.Title.ToString() == selectedCategory)
                        {
                            foreach (var card in col.Cards)
                            {
                                var currentModel = card.Content as CustomKanbanModel;
                                if (currentModel.ID == newTaskId.ToString())
                                {
                                    // Get column index
                                    var currentCardIndex = col.Cards.IndexOf(card);
                                    currentModel.ColumnIndex = currentCardIndex.ToString();

                                    // Add the column index to the database entry
                                    ViewModel.UpdateCardIndex(currentModel.ID, currentCardIndex);
                                }
                            }
                        }
                    }

                    // Close pane when done
                    if (splitView.IsPaneOpen == true)
                    {
                        splitView.IsPaneOpen = false;
                    }

                    if (addSuccess)
                    {
                        KanbanInAppNotification.Show("Task successfully added to the board", 3000);
                    }
                    else
                    {
                        KanbanInAppNotification.Show("Task could not be created", 3000);
                    }
                }
            }
        }
Пример #9
0
        private async void BtnSaveTask_Click(object sender, RoutedEventArgs e)
        {
            if (ViewModel.CardModel != null) // Editing a Task
            {
                // UI-related operations
                // Store tags as a single string using csv format
                // When calling GetData(), the string will be parsed into separate tags and stored into the list view
                List <string> tagsList = new List <string>();
                foreach (var tag in lstViewTags.Items)
                {
                    tagsList.Add(tag.ToString());
                }
                var tags = string.Join(',', tagsList); // Convert to a csv string to store in database cell

                // Use view model to operate on model-related data
                var selectedCategory = comboBoxCategories.SelectedItem;
                var selectedColorKey = comboBoxColorKey.SelectedItem;
                ViewModel.SaveTask(tags, selectedCategory, selectedColorKey, SelectedModel);

                // Close pane when done
                if (splitView.IsPaneOpen == true)
                {
                    splitView.IsPaneOpen = false;
                }
            }
            else if (ViewModel.CardModel == null) // Creating a Task
            {
                List <string> tagsList = new List <string>();
                foreach (var tag in lstViewTags.Items)
                {
                    tagsList.Add(tag.ToString());
                }
                var tags = string.Join(',', tagsList); // Convert to single string
                if (tags == "")
                {
                    tags = null;
                }

                // To allow a draft task, require user to have category and colorkey chosen
                if (comboBoxCategories.SelectedItem == null || comboBoxColorKey.SelectedItem == null)
                {
                    var messageDialog = new MessageDialog("NOTE: You must fill out a category and color key to be able to create a draft task", "ERROR");
                    await messageDialog.ShowAsync();
                }

                var selectedCategory = comboBoxCategories.SelectedItem;
                var selectedColorKey = comboBoxColorKey.SelectedItem;
                var addSuccess       = ViewModel.AddTask(tags, selectedCategory, selectedColorKey);

                // Close pane when done
                if (splitView.IsPaneOpen == true)
                {
                    splitView.IsPaneOpen = false;
                }

                if (addSuccess)
                {
                    KanbanInAppNotification.Show("Task successfully added to the board", 4000);
                }
                else
                {
                    KanbanInAppNotification.Show("Task could not be created", 4000);
                }
            }
        }