Exemplo n.º 1
0
        /// <summary>
        /// 지정한 기간의 컬렉션에 대해 라벨 발급 함수를 통해 새로운 <see cref="CategoryElement"/> 들을 생성하여, 컬렉션으로 반환한다.
        /// </summary>
        /// <param name="periods"></param>
        /// <param name="labelFunc"></param>
        /// <returns></returns>
        public static CategoriesElement CreateCategoriesAsParallel(IEnumerable <ITimePeriod> periods, Func <ITimePeriod, string> labelFunc)
        {
            var categories = new CategoriesElement();

            periods
            .AsParallel()
            .AsOrdered()
            .Select(period => {
                var category = new CategoryElement
                {
                    Start = period.Start,
                    End   = period.End
                };

                if (labelFunc != null)
                {
                    category.ItemAttr.Label = labelFunc(period);
                }

                return(category);
            })
            .RunEach(category => categories.Add(category));

            return(categories);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 지정한 기간의 컬렉션에 대해 라벨 발급 함수를 통해 새로운 <see cref="CategoryElement"/> 들을 생성하여, 컬렉션으로 반환한다.
        /// </summary>
        /// <param name="periods"></param>
        /// <param name="labelFunc"></param>
        /// <returns></returns>
        public static CategoriesElement CreateCategories(IEnumerable <ITimePeriod> periods, Func <ITimePeriod, string> labelFunc)
        {
            var categories = new CategoriesElement();

            foreach (var period in periods)
            {
                var category = new CategoryElement
                {
                    Start = period.Start,
                    End   = period.End
                };

                if (labelFunc != null)
                {
                    category.ItemAttr.Label = labelFunc(period);
                }

                categories.Add(category);
            }

            return(categories);
        }
Exemplo n.º 3
0
        public void MultipleCategories()
        {
            var chart = CreateSampleChart("Multiple Categories Gantt Chart");

            var quaterCategories = new CategoriesElement();

            // 분기별 Category를 만든다.
            foreach (var quarterRange in ProjectPeriod.ForEachQuarters())
            {
                var category = new CategoryElement
                {
                    Start    = quarterRange.Start,
                    End      = quarterRange.End,
                    ItemAttr = { Label = quarterRange.Start.GetQuarter().ToString() }
                };

                quaterCategories.Add(category);
            }

            chart.CategoriesList.Insert(0, quaterCategories);

            ValidateChartXml(chart);
        }
Exemplo n.º 4
0
        private static GanttChart CreateSampleChart(string caption)
        {
            var chart = new GanttChart
            {
                Caption    = caption,
                SubCaption = "소제목입니다.",
                Palette    = 2,
            };

            var categories = new CategoriesElement
            {
                FontAttr =
                {
                    Font        = "Tahoma",
                    FontColor   = Color.FromArgb(0, 0x03, 0x72, 0xAB),
                    FontSize    =    13.ToString(),
                    IsBold      = true,
                    IsItalic    = true,
                    IsUnderline = true
                },
                BgColor = Color.White,
                Align   = FusionTextAlign.Center,
                VAlign  = FusionVerticalAlign.Middle
            };


            foreach (var month in ProjectPeriod.ForEachMonths())
            {
                var category = new CategoryElement
                {
                    Start = month.Start,
                    End   = month.End,
                };
                category.ItemAttr.Label                = month.Start.Month.ToString();
                category.ItemAttr.FontAttr.Font        = "Tahoma";
                category.ItemAttr.FontAttr.FontColor   = Color.FromArgb(0, 0x03, 0x72, 0xAB);
                category.ItemAttr.FontAttr.FontSize    = 13.ToString();
                category.ItemAttr.FontAttr.IsBold      = true;
                category.ItemAttr.FontAttr.IsItalic    = true;
                category.ItemAttr.FontAttr.IsUnderline = true;
                category.ItemAttr.BgColor              = Color.White;
                category.ItemAttr.Align                = FusionTextAlign.Center;
                category.ItemAttr.VAlign               = FusionVerticalAlign.Middle;

                categories.Add(category);
            }

            chart.CategoriesList.Add(categories);

            chart.Processes.FontAttr.FontSize            = 12.ToString();
            chart.Processes.FontAttr.IsBold              = true;
            chart.Processes.Align                        = FusionTextAlign.Right;
            chart.Processes.HeaderText                   = "What to do?";
            chart.Processes.HeaderAttr.FontAttr.FontSize = 18.ToString();
            chart.Processes.HeaderAttr.Align             = FusionTextAlign.Right;
            chart.Processes.HeaderAttr.VAlign            = FusionVerticalAlign.Bottom;

            var procId = 0;

            foreach (string label in ProcessLabels)
            {
                var process = new ProcessElement("Process" + procId++.ToString())
                {
                    ItemAttr =
                    {
                        Label    = label,
                        FontAttr =
                        {
                            Font        = "Tahoma",
                            FontColor   = Color.FromArgb(0,             0x03, 0x72, 0xAB),
                            FontSize    =          13.ToString(),
                            IsBold      = true,
                            IsItalic    = true,
                            IsUnderline = true
                        },
                        BgColor = Color.White,
                        Align   = FusionTextAlign.Center,
                        VAlign  = FusionVerticalAlign.Middle
                    }
                };

                chart.Processes.Add(process);
            }

            procId = 0;
            var taskId = 0;

            foreach (var taskPeriod in TaskPeriods)
            {
                var task = new TaskElement
                {
                    Start           = taskPeriod.Start,
                    End             = taskPeriod.End,
                    Id              = "Task" + taskId++,
                    ProcessId       = "Process" + procId++,
                    Color           = Color.BlueViolet,
                    ShowLabel       = true,
                    Animation       = true,
                    BorderThickness = 1
                };

                // chart.Tasks.TaskElements.Add(task);
                chart.Tasks.Add(task);
            }

            return(chart);
        }