/// <summary>
        /// Initialize the nodes in daigram
        /// </summary>
        private void populateNodes()
        {
            //get the root rode
            FlowTask_Backend.Node root = nodes[0];

            //first level of nodes
            Syncfusion.Windows.Forms.Diagram.Rectangle rootRectangle = new Syncfusion.Windows.Forms.Diagram.Rectangle(0, 0, 120, 80);
            rootRectangle.FillStyle.Color     = Color.FromArgb(242, 242, 242);
            rootRectangle.FillStyle.Type      = FillStyleType.LinearGradient;
            rootRectangle.FillStyle.ForeColor = Color.White;

            //give it a label with the node text
            Syncfusion.Windows.Forms.Diagram.Label label = new Syncfusion.Windows.Forms.Diagram.Label(rootRectangle, getNodeText(root));
            label.FontStyle.Family     = "Segoe UI";
            label.FontStyle.Size       = 10;
            label.FontColorStyle.Color = Color.Black;
            rootRectangle.Labels.Add(label);

            sfDecompositionDiagram.Model.AppendChild(rootRectangle);

            //recursively populate children
            foreach (var neighbor in myTask.Decomposition.GetNeighbors(root.NodeIndex))
            {
                generateInnerLevelNodes(rootRectangle, nodes[neighbor.NodeIndex]);
            }
        }
 /// <summary>
 /// Get the rectangle text for a given node
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 string getNodeText(FlowTask_Backend.Node node)
 {
     return(string.Format("{0} due on {1}", node.Name, node.Date.ToString("dddd, dd MMMM yyyy")));
 }
        private void drawNodesDue(DateTime here)
        {
            int nodesRemain = myTask.RemainingFlowSteps;

            Text = string.Format("View Task: {0} - {1} Node{2} Remaining", myTask.AssignmentName, nodesRemain, Mediator.IsPlural(nodesRemain));

            flowLayout.FlowDirection = FlowDirection.TopDown;

            flowLayout.ForeColor = Color.White;
            flowLayout.BackColor = Color.White;

            flowLayout.Controls.Clear();
            var lblHeader = new System.Windows.Forms.Label()
            {
                Font        = nodeHeadingFont,
                Text        = string.Format("Nodes due on {0}", here.ToString("dddd, dd MMMM yyyy")),
                Padding     = new Padding(4, 4, 4, 4),
                Margin      = new Padding(0),
                Height      = 40,
                Width       = flowLayout.Width,
                ForeColor   = Color.Black,
                BackColor   = Color.LightBlue,
                BorderStyle = BorderStyle.FixedSingle,
            };

            flowLayout.Controls.Add(lblHeader);

            var now = DateTime.Now;

            int number = 0;

            foreach (var node in getDrawListForDay(here))
            {
                string node_subtext = string.IsNullOrEmpty(node.Text) ? "" : string.Format("({0})", node.Text);

                if (!node.Complete)
                {
                    if (now > node.Date && now.DayOfYear > node.Date.DayOfYear)
                    {
                        var offset_days = (now - node.Date).Days;
                        node_subtext = string.Format("{0} overdue by {1} day{2}", node_subtext, offset_days, Mediator.IsPlural(offset_days));
                    }
                    else if (now.DayOfYear == node.Date.DayOfYear && now.Year == node.Date.Year)
                    {
                        node_subtext = string.Format("{0} is due today!", node_subtext);
                    }
                    else
                    {
                        //due in the future
                        var offset_days = (node.Date - DateTime.Now).Days;
                        node_subtext = string.Format("{0} Due in {1} day{2}", node_subtext, offset_days, Mediator.IsPlural(offset_days));
                    }
                }
                else
                {
                    node_subtext = string.Format("{0} is complete!", node_subtext);
                }

                System.Windows.Forms.Label lblNodeInfo = new System.Windows.Forms.Label()
                {
                    Font        = nodeLabelFont,
                    Text        = string.Format("{0}. {1} {2}", ++number, node.Name, node_subtext),
                    Margin      = new Padding(0),
                    Padding     = new Padding(28, 4, 4, 4),
                    Height      = 36,
                    BackColor   = Color.White,
                    ForeColor   = node.DrawColor,
                    Width       = flowLayout.Width,
                    BorderStyle = BorderStyle.FixedSingle
                };

                //completion checkbox to left of label
                CheckBox chbx = new SizableCheckBox
                {
                    Size      = new Size(22, 22),
                    Margin    = new Padding(0),
                    Location  = new Point(7, 7),
                    Padding   = new Padding(0, 0, 0, 0),
                    Checked   = node.Complete,
                    TextAlign = ContentAlignment.MiddleCenter
                };

                //tool tip to say what the chckbox does
                var toolTip = new ToolTip
                {
                    ToolTipIcon = ToolTipIcon.Info,
                    IsBalloon   = true,
                    ShowAlways  = true
                };

                string toolTipText = "This node is incomplete. Check to mark as complete.";
                if (chbx.Checked)
                {
                    FlowTask_Backend.Node next = myTask.Decomposition.GetSoonestNode();

                    if (next != null && !string.IsNullOrEmpty(next.Name))
                    {
                        toolTipText = string.Format("This node is complete! The next node is {0}.", next.Name);
                    }
                    else
                    {
                        toolTipText = "This node is complete! There are no remaining nodes in this task.";
                    }
                }

                toolTip.SetToolTip(chbx, toolTipText);

                chbx.CheckedChanged += (object sender, EventArgs e) =>
                {
                    var result = chbx.Checked;
                    var(Success, ErrorMessage) = DatabaseController.GetDBController().UpdateComplete(Mediator.AuthCookie, myTask.UserID, node.NodeID, result);
                    if (Success)
                    {
                        node.SetCompleteStatus(result);
                        //update the task node to reflect the change.
                        myTask.Decomposition.Nodes[node.NodeIndex].SetCompleteStatus(result);
                        int x = myTask.RemainingFlowSteps;

                        drawNodesDue(here);
                        Mediator.MainForm.Redraw();
                    }
                    else
                    {
                        //the database failed to process the node completion update
                        MessageBox.Show(ErrorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                };

                lblNodeInfo.Controls.Add(chbx);

                flowLayout.Controls.Add(lblNodeInfo);
            }
        }