private GanttChartForm toGanttChartForm() { GanttChartForm gcf = new GanttChartForm(); for (int i = 0; i < method.preganttchart.Count; i++) { if (i <= time) { if (i == 0) { gcf.processname.Add(method.preganttchart[i]); gcf.time.Add(i); gcf.time.Add(i + 1); } else if (method.preganttchart[i] == method.preganttchart[i - 1]) { gcf.time.RemoveAt(gcf.time.Count - 1); gcf.time.Add(i + 1); } else if (method.preganttchart[i] != method.preganttchart[i - 1]) { gcf.processname.Add(method.preganttchart[i]); gcf.time.Add(i + 1); } } } return(gcf); }
private void updateGanttChartView() { GanttChartForm gcf = toGanttChartForm(); ganttchartpanel.Controls.Remove(ganttlayoutContainer); ganttlayoutContainer = tableLayoutWithStyle((gcf.processname.Count / 14 * 2) + 2, 1, AnchorStyles.Top, AnchorStyles.Bottom); ganttlayoutContainer.AutoScroll = true; for (int i = 0; i < ganttlayoutContainer.RowCount; i++) { if (i % 2 == 0) { ganttlayoutContainer.RowStyles.Add(new RowStyle(SizeType.Absolute, 40)); } else { ganttlayoutContainer.RowStyles.Add(new RowStyle(SizeType.Absolute, 60)); } } TableLayoutPanel ganttlayoutRow = tableLayoutWithStyle(1, 13, AnchorStyles.Left, AnchorStyles.Right); TableLayoutPanel ganttlayoutRowSecond = tableLayoutWithStyle(1, 14, AnchorStyles.Left, AnchorStyles.Right); int finalcolnum = 0; for (int j = 0; j < ganttlayoutContainer.RowCount / 2; j++) { ganttlayoutRow = tableLayoutWithStyle(1, 13, AnchorStyles.Left, AnchorStyles.Right); ganttlayoutRowSecond = tableLayoutWithStyle(1, 14, AnchorStyles.Left, AnchorStyles.Right); for (int i = 0; i < 13; i++) { if (j * 13 + i < gcf.processname.Count) { ganttlayoutRow = labelAddToLayout(gcf.processname[j * 13 + i], ganttlayoutRow, i, 0, true); ganttlayoutRowSecond = labelAddToLayout(gcf.time[j * 13 + i] + "", ganttlayoutRowSecond, i, 0, false); finalcolnum = i; } } TableLayoutPanel rightpush = tableLayoutWithStyle(1, 2, AnchorStyles.Left, AnchorStyles.Right); rightpush.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 2)); rightpush.Controls.Add(ganttlayoutRow, 2, 0); ganttlayoutContainer.Controls.Add(rightpush, 0, j * 2); //ganttlayoutContainer.Controls.Add(ganttlayoutRow, 0, j * 2); ganttlayoutContainer.Controls.Add(ganttlayoutRowSecond, 0, j * 2 + 1); } ganttlayoutRowSecond = labelAddToLayout(gcf.time[gcf.time.Count - 1] + "", ganttlayoutRowSecond, finalcolnum + 1, 0, false); ganttchartpanel.Controls.Add(ganttlayoutContainer); }