private void AddTaskToPanel(Panel panel, StoryTask st) { Panel newtask = new Panel(); newtask.Name = panel.Name.Split('_')[2] + "_" + st.StoryID + "_" + st.TaskID; newtask.Width = 50; newtask.Height = 30; //convert rgb to Color string colorcode = st.Color; int r = Convert.ToInt32(colorcode.Split(',')[0]); int g = Convert.ToInt32(colorcode.Split(',')[1]); int b = Convert.ToInt32(colorcode.Split(',')[2]); Color stColor = Color.FromArgb(r, g, b); Button detay = new Button(); detay.Name = st.TaskID.ToString(); detay.Text = "?"; detay.Click += task_Detail_Click; detay.Width = 30; detay.Height = 30; detay.Font = new Font("Arial", 15, FontStyle.Bold); detay.Dock = DockStyle.Right; newtask.Controls.Add(detay); Label Text = new Label(); Text.Dock = DockStyle.Left; Text.Text = st.TaskName; Text.Font = new Font("Arial", 12, FontStyle.Bold); newtask.Controls.Add(Text); newtask.BackColor = stColor; newtask.Dock = DockStyle.Top; newtask.Text = st.TaskName; newtask.MouseDown += task_panel_MouseDown; newtask.AllowDrop = true; panel.Controls.Add(newtask); }
private void btnCancel_Click(object sender, EventArgs e) { storyTask = null; this.Close(); }
private void panel_DragDrop(object sender, DragEventArgs e) { Panel pnl_host = (Panel)sender; Panel pnl_task = ((Panel)e.Data.GetData(typeof(Panel))); int taskid = Convert.ToInt32(pnl_task.Name.ToString().Split('_')[2]); StoryTask storytaskToUpdate = null; foreach (StoryTask stT in sprintBoard.StoryTasks) { if (stT.TaskID == taskid) { storytaskToUpdate = stT; } } if (pnl_host.Name == "pnl_Trash") { DialogResult result = MessageBox.Show("Do you want to move the task to the trash? ", "Task Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { pnl_task.Parent = pnl_host; pnl_host.Controls.RemoveAt(1); //deleted status storytaskToUpdate.Status = 4; } } else { string pnl_host_id = pnl_host.Name.Split('_')[2]; string pnl_task_id = pnl_task.Name.ToString().Split('_')[0]; if (pnl_host_id == pnl_task_id) { pnl_task.Parent = pnl_host; string new_status = pnl_host.Name.Split('_')[1]; switch (new_status) { case "todo": storytaskToUpdate.Status = 1; break; case "inprog": storytaskToUpdate.Status = 2; break; case "done": storytaskToUpdate.Status = 3; break; default: break; } } else { storytaskToUpdate = null; } } if (storytaskToUpdate != null) //update task { dbsql.UpdateTask(storytaskToUpdate); checkIfStoryIsFinished(storytaskToUpdate); } }