Exemplo n.º 1
0
        internal static byte[] Render(GanttView ganttView, bool generateDataXml, string styleFilePath, int portionX, int portionY, int portionWidth, int portionHeight, int itemsPerPage, int pageNumber)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                if (generateDataXml)
                {
                    ganttView.GenerateDataXml(Encoding.UTF8, stream);
                }
                else
                {
                    ganttView.LoadStyleSheetFromFile(styleFilePath);
                    ganttView.ApplyStyleSheet();

                    if (portionY < 0)
                    {
                        portionHeight = Convert.ToInt32(ganttView.CalculateHeadHeight());
                    }

                    if (portionHeight > 0 && portionWidth > 0)
                    {
                        ganttView.RenderPortion(new Point(portionX, portionY), new Size(portionWidth, portionHeight), itemsPerPage, pageNumber, ImageFormat.Png, stream);
                    }
                }
                return(stream.ToArray());
            }
        }
Exemplo n.º 2
0
        public static byte[] RenderLegendItem(string styleFilePath, string type)
        {
            byte[] ret = null;

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

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

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

            gantt.CreateIntervalElement(spanElement, intervalStart, intervalFinish, null, type, null);

            #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);
        }
Exemplo n.º 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);
        }