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; } }
public void ShowContextMenu(CustomKanbanModel selectedModel) { // Workaround to show context menu next to selected card model foreach (var col in kanbanBoard.ActualColumns) { if (col.Categories.Contains(selectedModel.Category.ToString())) { // Find card inside column foreach (var card in col.Cards) { int cardIndex = 0; var cardModel = card.Content as CustomKanbanModel; if (cardModel.ID == selectedModel.ID) { // Get current index of card cardIndex = col.Cards.IndexOf(card); } // Set flyout to selected card index for (int i = 0; i <= col.Cards.Count; i++) { if (i == cardIndex) { FlyoutShowOptions myOption = new FlyoutShowOptions(); myOption.ShowMode = FlyoutShowMode.Transient; taskFlyout.ShowAt(col.Cards[i], myOption); } } } } } }
private void CardBtnEdit_Click(object sender, RoutedEventArgs e) { var originalSource = (FrameworkElement)sender; SelectedModel = originalSource.DataContext as CustomKanbanModel; // Call helper from ViewModel to handle model-related data ViewModel.EditTaskHelper(SelectedModel, GetColorKeys(kanbanBoard), GetTagCollection(SelectedModel)); // UI RELATED CODE // Set selected item in combo box ViewModel.CurrentCategory = SelectedModel.Category.ToString(); comboBoxColorKey.SelectedItem = SelectedModel.ColorKey; taskFlyout.Hide(); if (splitView.IsPaneOpen == false) { splitView.IsPaneOpen = true; } // Give title textbox focus once pane opens txtBoxTitle.Focus(FocusState.Programmatic); txtBoxTitle.SelectionStart = txtBoxTitle.Text.Length; txtBoxTitle.SelectionLength = 0; }
private void UpdateData() { var list = TodoService.GetAllTodo(CurrentProject.ProjectInfoId); KanbanModels = new ObservableCollection <CustomKanbanModel>(list .Select(x => { var model = new CustomKanbanModel(x) { CurrentUser = TodoAndUsersService.GetUserForTodo(x.TodoId) }; model.Assignee = model.CurrentUser.FullName; model.Title = x.Caption; model.ID = x.TodoId.ToString(); model.Description = x.Content; model.Category = ResolveStateToCategory(x.State); model.ColorKey = ResolveStateToColorKey(x.State); model.ImageURL = new Uri(@"D:\Projects\TaskList\TaskList\ToolKit\iconsMan.png", UriKind.RelativeOrAbsolute); return(model); })); Refresh(); }
/// <summary> /// Removes task from collection and from the database /// </summary> /// <param name="model"></param> /// <returns>If deletion was successful</returns> public bool DeleteTask(CustomKanbanModel model) { Tasks.Remove(model); var deleteSuccess = DataProvider.DeleteTask(model.ID); CardModel = null; return(deleteSuccess); }
/// <summary> /// Initializes properties to show information in the edit task pane /// </summary> /// <param name="selectedModel">Assigned to CardModel to set its properties</param> /// <param name="colorKeys"></param> /// <param name="tags"></param> public void EditTaskHelper(CustomKanbanModel selectedModel, List <string> colorKeys, ObservableCollection <string> tags) { OriginalCardModel = selectedModel; IsEditingTask = true; CardModel = selectedModel; ColorKeys = colorKeys; TagsCollection = tags; PaneTitle = "Edit Task"; }
private void CardBtnDelete_Click(object sender, RoutedEventArgs e) { var originalSource = (FrameworkElement)sender; SelectedModel = originalSource.DataContext as CustomKanbanModel; // Show flyout attached to button // Delete task if "Yes" button is clicked inside flyout FlyoutBase.ShowAttachedFlyout((FrameworkElement)sender); }
public void EditTaskHelper(CustomKanbanModel selectedModel, List <string> categories, List <string> colorKeys, ObservableCollection <string> tags) { // Get content ready to show in splitview pane OriginalCardModel = selectedModel; IsEditingTask = true; CardModel = selectedModel; Categories = categories; ColorKeys = colorKeys; TagsCollection = tags; PaneTitle = "Edit Task"; }
public bool DeleteTask(CustomKanbanModel model) { var previousCount = Tasks.Count; Tasks.Remove(model); DataProvider.DeleteTask(model.ID); // Delete from database CardModel = null; // Determine if deletion was successful return((Tasks.Count == (previousCount - 1)) ? true : false); }
public ObservableCollection <string> GetTagCollection(CustomKanbanModel selectedModel) { // Add selected card tags to a collection // Tags Collection is displayed in a listview in TaskDialog var tagsCollection = new ObservableCollection <string>(); foreach (var tag in selectedModel.Tags) { tagsCollection.Add(tag); // Add card tags to collection } return(tagsCollection); }
private void Card_RightTapped(object sender, RightTappedRoutedEventArgs e) { // Pre: Get information to pass to the dialog for displaying // Set corresponding properties in TaskDialog // Post: Information passed, dialog opened // Always show in standard mode var originalSource = (FrameworkElement)sender; SelectedModel = originalSource.DataContext as CustomKanbanModel; ShowContextMenu(SelectedModel); }
private void BtnCancel_Click(object sender, RoutedEventArgs e) { // Reset changes and close pane // To Do: Change when adding task SelectedModel = ViewModel.OriginalCardModel; if (splitView.IsPaneOpen == true) { splitView.IsPaneOpen = false; } ViewModel.CardModel = null; // Reset selected card property }
//===================================================================== // FUNCTIONS & EVENTS FOR EDITING A TASK //===================================================================== public static ObservableCollection <CustomKanbanModel> GetData() { ObservableCollection <CustomKanbanModel> tasks = new ObservableCollection <CustomKanbanModel>(); // Get tasks and return the collection using (SqliteConnection db = new SqliteConnection("Filename=ktdatabase.db")) { db.Open(); SqliteCommand selectCommand = new SqliteCommand ("SELECT Id, BoardID, DateCreated, Title, Description, Category, ColorKey, Tags from tblTasks", db); SqliteDataReader query = selectCommand.ExecuteReader(); // Query the db and get the tasks while (query.Read()) { string[] tags; if (query.GetString(7).ToString() == "") { tags = new string[] { } } ; // Empty array if no tags are in the col else { tags = query.GetString(7).Split(","); // Turn string of tags into string array, fills listview } CustomKanbanModel row = new CustomKanbanModel() { ID = query.GetString(0), BoardId = query.GetString(1), DateCreated = query.GetString(2), Title = query.GetString(3), Description = query.GetString(4), Category = query.GetString(5), ColorKey = query.GetString(6), Tags = tags // Turn string of tags into string array, fills listview }; tasks.Add(row); } db.Close(); } return(tasks); }
/// <summary> /// Updates the selected card category and column index in the database after dragging /// it to a new column /// </summary> /// <param name="selectedCardModel"></param> /// <param name="targetCategory"></param> /// <param name="targetIndex"></param> public static void UpdateColumnData(CustomKanbanModel selectedCardModel, string targetCategory, string targetIndex) { using (SqliteConnection db = new SqliteConnection(DBName)) { db.Open(); // Update task column/category when dragged to new column/category SqliteCommand updateCommand = new SqliteCommand ("UPDATE tblTasks SET Category=@category, ColumnIndex=@columnIndex WHERE Id=@id", db); updateCommand.Parameters.AddWithValue("@category", targetCategory); updateCommand.Parameters.AddWithValue("@columnIndex", targetIndex); updateCommand.Parameters.AddWithValue("@id", selectedCardModel.ID); updateCommand.ExecuteNonQuery(); db.Close(); } }
public bool AddTask(string tags, object selectedCategory, object selectedColorKey) { // Tags are stored as as string[] in CustomKanbanModel // Strip string into a sting[] string[] tagsArray = new string[] { }; if (tags != null) { tagsArray = tags.Split(','); } else { tags = ""; // No tags } var boardId = App.mainViewModel.Current.BoardId.ToString(); var currentDateTime = DateTimeOffset.Now.ToString(); // Create model and add to Tasks collection var model = new CustomKanbanModel { BoardId = boardId, DateCreated = currentDateTime, Title = Title, Description = Description, Category = selectedCategory, ColorKey = selectedColorKey, Tags = tagsArray }; // Add task to database int newTaskID = DataProvider.AddTask(boardId, currentDateTime, Title, Description, selectedCategory.ToString(), selectedColorKey.ToString(), tags); var previousCount = Tasks.Count; model.ID = newTaskID.ToString(); Tasks.Add(model); // Determine if insertion was successful return((Tasks.Count == (previousCount + 1)) ? true : false); }
/// <summary> /// Creates model and adds it to the database. /// Returns the success flag and the new tasks ID /// </summary> /// <param name="tags"></param> /// <param name="selectedCategory"></param> /// <param name="selectedColorKey"></param> /// <returns>Tuple of values; one for success, other for the new tasks id</returns> public (bool, int) AddTask(string tags, object selectedCategory, object selectedColorKey) { // Tags are stored as as string[] in CustomKanbanModel // Strip string into a sting[] string[] tagsArray = new string[] { }; if (tags != null) { tagsArray = tags.Split(','); } else { tags = ""; // No tags } var boardId = this.BoardId.ToString(); var currentDateTime = DateTimeOffset.Now.ToString(); // Create model, set it's ID after made in database var model = new CustomKanbanModel { BoardId = boardId, DateCreated = currentDateTime, Title = Title, Description = Description, Category = selectedCategory, ColorKey = selectedColorKey, Tags = tagsArray }; // Returns a tuple (bool addSuccess, int id) for success flag and // the new tasks ID for the model var returnedTuple = DataProvider.AddTask(boardId, currentDateTime, Title, Description, selectedCategory.ToString(), selectedColorKey.ToString(), tags); int newTaskID = returnedTuple.Item1; var success = returnedTuple.Item2; model.ID = newTaskID.ToString(); Tasks.Add(model); return(success, newTaskID); }
/// <summary> /// Updates the selected card category and column index after dragging it to /// a new column /// </summary> /// <param name="targetCategory"></param> /// <param name="selectedCardModel"></param> /// <param name="targetIndex"></param> public void UpdateCardColumn(string targetCategory, CustomKanbanModel selectedCardModel, string targetIndex) { DataProvider.UpdateColumnData(selectedCardModel, targetCategory, targetIndex); }
public void SaveTask(string tags, object selectedCategory, object selectedColorKey, CustomKanbanModel selectedCard) { // Tags are stroed as string[] in CustomKanbanModel // Strip string into a string[] string[] tagsArray; if (tags == "") { tagsArray = new string[] { } } ; else { tagsArray = tags.Split(","); } // Update model var selectedModel = selectedCard; selectedModel.Title = Title; selectedModel.Description = Description; selectedModel.Category = selectedCategory; selectedModel.ColorKey = selectedColorKey; selectedModel.Tags = tagsArray; // Update item in database DataProvider.UpdateTask(ID, Title, Description, selectedCategory.ToString(), selectedColorKey.ToString(), tags); }