Пример #1
0
        private static Element AddInterval2(GanttView gantt, Element parent, DateTime?start, DateTime?finish, string id, string type, string tag)
        {
            Element child = null;

            if (start != null && finish != null)
            {
                child = gantt.CreateIntervalElement(parent, start.Value, finish.Value, id, type, tag);
                if (type == "Summary")
                {
                    gantt.CreatePointElement(child, start.Value, null, type + "Start", tag);
                    gantt.CreatePointElement(child, finish.Value, null, type + "Finish", tag);
                }
            }
            else
            {
                if (start != null)
                {
                    child = gantt.CreatePointElement(parent, start.Value, id, type + "Start", tag);
                }
                if (finish != null)
                {
                    child = gantt.CreatePointElement(parent, finish.Value, id, type + "Finish", tag);
                }
            }

            return(child);
        }
Пример #2
0
        private static void AddMilestone(GanttView gantt, Element parent, DateTime date, DateTime?basePlanDate, string id, string tag)
        {
            string type = "Milestone";

            gantt.CreatePointElement(parent, date, id, type, tag);

            if (basePlanDate != null && basePlanDate.Value != date)
            {
                string direction = basePlanDate.Value > date ? "Right" : "Left";

                PointElement small = gantt.CreatePointElement(parent, date, null, type, "BasePlanSmall");
                small.AddAttribute("direction", direction);

                PointElement large = gantt.CreatePointElement(parent, basePlanDate.Value, null, type, "BasePlanLarge");
                large.AddAttribute("direction", direction);
            }
        }
Пример #3
0
        public static byte[] RenderLegendItem(string styleFilePath, GanttItem item, bool completed)
        {
            byte[] ret = null;

            DateTime  startDate = DateTime.Now.Date;
            GanttView gantt     = CreateGanttView(startDate, DayOfWeek.Monday, 0, ItemHeight);

            Element spanElement = gantt.CreateSpanElement(null, null, null);

            DateTime pointDate      = startDate.AddHours(36);
            DateTime intervalStart  = startDate.AddHours(12);
            DateTime intervalFinish = intervalStart.AddDays(2);

            string tag = completed ? "Completed" : "";

            switch (item)
            {
            case GanttItem.PointStart:
                gantt.CreatePointElement(spanElement, pointDate, null, "Start", tag);
                break;

            case GanttItem.PointFinish:
                gantt.CreatePointElement(spanElement, pointDate, null, "Finish", tag);
                break;

            case GanttItem.PointActualStart:
                gantt.CreatePointElement(spanElement, pointDate, null, "ActualStart", tag);
                break;

            case GanttItem.PointActualFinish:
                gantt.CreatePointElement(spanElement, pointDate, null, "ActualFinish", tag);
                break;

            case GanttItem.Interval:
                gantt.CreateIntervalElement(spanElement, intervalStart, intervalFinish, null, null, tag);
                break;

            case GanttItem.IntervalActual:
                gantt.CreateIntervalElement(spanElement, intervalStart, intervalFinish, null, "Actual", tag);
                break;

            case GanttItem.IntervalProgress:
                gantt.CreateIntervalElement(spanElement, intervalStart, intervalFinish, null, "Progress", tag);
                break;

            case GanttItem.IntervalSummary:
            case GanttItem.IntervalProject:
                Element interval = gantt.CreateIntervalElement(spanElement, intervalStart, intervalFinish, null, "Summary", tag);
                gantt.CreatePointElement(interval, intervalStart, null, "SummaryStart", tag);
                gantt.CreatePointElement(interval, intervalFinish, null, "SummaryFinish", tag);
                break;

            case GanttItem.PointMilestone:
                AddMilestone(gantt, spanElement, pointDate, null, null, tag);
                break;

            case GanttItem.PointMilestoneBasePlanRight:
                AddMilestone(gantt, spanElement, intervalStart, intervalFinish, null, tag);
                break;

            case GanttItem.PointMilestoneBasePlanLeft:
                AddMilestone(gantt, spanElement, intervalFinish, intervalStart, null, tag);
                break;
            }

            #region Render

            using (MemoryStream stream = new MemoryStream())
            {
                gantt.LoadStyleSheetFromFile(styleFilePath);
                gantt.ApplyStyleSheet();

                gantt.RenderPortion(new Point(0, 0), new Size(24 * 3, Convert.ToInt32(ItemHeight)), 0, 0, ImageFormat.Png, stream);

                ret = stream.ToArray();
            }

            #endregion

            return(ret);
        }