Beispiel #1
0
        /// <summary>
        /// セクション部分の描画処理
        /// </summary>
        private void drawViewerSection(Image img, Graphics g)
        {
            if (img == null)
            {
                //描画領域が存在しない場合は処理しない
                return;
            }

            this.mgrDraw = new ScheduleDrawComponent(this.mgr, g, img.Size);

            //個別タスク
            for (int i = 0, cnt = 0; i < this.mgr.Sections.Count; i++, cnt++)
            {
                //部門名
                g.DrawString(
                    this.mgr.Sections[i].Name,
                    ScheduleDrawComponent.TaskFont,
                    Brushes.Black,
                    5,
                    ScheduleDrawComponent.DrawLineHeight * cnt + ScheduleDrawComponent.OffsetSection
                    );

                //担当者とそのタスク
                for (var j = -1 /*部門全体から始める*/; j < this.mgr.Sections[i].Workers.Count; j++)
                {
                    if (j != -1)
                    {
                        cnt++;
                        g.DrawString(
                            this.mgr.Sections[i].Workers[j].Name,
                            this.Font,
                            Brushes.Black,
                            30,
                            ScheduleDrawComponent.DrawLineHeight * cnt + ScheduleDrawComponent.OffsetSection
                            );
                    }
                }
            }

            //縦罫線
            g.DrawLine(
                Pens.Black,
                img.Width - 1,
                0,
                img.Width - 1,
                img.Height
                );

            //横罫線
            for (var i = 1; i <= this.mgrDraw.HeightCount; i++)
            {
                g.DrawLine(
                    ScheduleDrawComponent.TransLinePen,
                    0,
                    i * ScheduleDrawComponent.DrawLineHeight,
                    img.Width,
                    i * ScheduleDrawComponent.DrawLineHeight
                    );
            }
        }
Beispiel #2
0
        /// <summary>
        /// タイトル部分の描画処理
        /// </summary>
        private void drawViewerTitle(Image img, Graphics g)
        {
            if (img == null)
            {
                //描画領域が存在しない場合は処理しない
                return;
            }

            this.mgrDraw = new ScheduleDrawComponent(this.mgr, g, img.Size);

            //マイルストーン
            g.DrawString(
                Resources.Sche_MilestoneName,
                this.Font,
                Brushes.Black,
                0,
                ScheduleDrawComponent.DrawHeaderHeight + (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * -1 + ScheduleDrawComponent.OffsetHeaderLine - 1
                );

            //年月日凡例
            g.DrawString("年", this.Font, Brushes.Black, img.Width - 25, (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * 0 + 1);
            g.DrawString("月", this.Font, Brushes.Black, img.Width - 25, (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * 1 + 1);
            g.DrawString("日", this.Font, Brushes.Black, img.Width - 25, (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * 2 + 1);

            //横罫線
            //年
            g.DrawLine(
                Pens.Silver,
                0,
                (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * 1 - 2,
                img.Width - 1,
                (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * 1 - 2
                );

            //月
            g.DrawLine(
                Pens.Silver,
                0,
                (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * 2 - 2,
                img.Width - 1,
                (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * 2 - 2
                );

            //日
            g.DrawLine(
                ScheduleDrawComponent.TaskFramePen,
                0,
                ScheduleDrawComponent.DrawHeaderHeight - (ScheduleDrawComponent.DrawLineHeight - ScheduleDrawComponent.OffsetHeaderLine) - 2,
                img.Width - 2,
                ScheduleDrawComponent.DrawHeaderHeight - (ScheduleDrawComponent.DrawLineHeight - ScheduleDrawComponent.OffsetHeaderLine) - 2
                );

            //マイルストーン
            g.DrawLine(
                ScheduleDrawComponent.TaskFramePen,
                0,
                ScheduleDrawComponent.DrawHeaderHeight,
                img.Width - ScheduleDrawComponent.DrawRightMargin, ScheduleDrawComponent.DrawHeaderHeight
                );
        }
Beispiel #3
0
        /// <summary>
        /// 実際にガントチャートを描画します。
        /// </summary>
        /// <param name="Reset">スクロール設定も含めてすべてリセットするかどうか</param>
        private void DrawSchedule(bool skipRedraw = false)
        {
            this.mgrDraw = new ScheduleDrawComponent(this.mgr);

            //描画先のキャンバスを生成
            var bmpTitle = new Bitmap(this.pnlSection.Width, ScheduleDrawComponent.DrawHeaderHeight);
            var bmpDate  = new Bitmap((this.mgrDraw.WidthCount + 1) * ScheduleDrawComponent.DrawDayWidth + ScheduleDrawComponent.DrawRightMargin, ScheduleDrawComponent.DrawHeaderHeight);
            var bmpSec   = new Bitmap(this.pnlSection.Width, this.mgrDraw.HeightCount * ScheduleDrawComponent.DrawLineHeight + 1);
            var bmpTask  = new Bitmap((this.mgrDraw.WidthCount + 1) * ScheduleDrawComponent.DrawDayWidth + ScheduleDrawComponent.DrawRightMargin, this.mgrDraw.HeightCount * ScheduleDrawComponent.DrawLineHeight + 1);

            //リサイズしたらキャンバスを更新
            Image temp;

            temp = this.picTitle.Image;
            if (this.picTitle.Image == null || this.picTitle.Image.Size != bmpTitle.Size)
            {
                this.picTitle.Image = bmpTitle;
                temp?.Dispose();
            }

            temp = this.picDate.Image;
            if (this.picDate.Image == null || this.picDate.Image.Size != bmpDate.Size)
            {
                this.picDate.Image = bmpDate;
                temp?.Dispose();
            }

            temp = this.picSection.Image;
            if (this.picSection.Image == null || this.picSection.Image.Size != bmpSec.Size)
            {
                this.picSection.Image = bmpSec;
                temp?.Dispose();
            }

            temp = this.picTask.Image;
            if (this.picTask.Image == null || this.picTask.Image.Size != bmpTask.Size)
            {
                this.picTask.Image = bmpTask;
                this.pnlTask.AutoScrollPosition = Point.Empty;
                this.picDate.Left   = 0;
                this.picSection.Top = 0;
                temp?.Dispose();
            }

            //再描画を指示
            if (!skipRedraw)
            {
                this.picTitle.Refresh();
                this.picDate.Refresh();
                this.picSection.Refresh();
                this.picTask.Refresh();
            }
        }
Beispiel #4
0
        /// <summary>
        /// 日程部分の描画処理
        /// </summary>
        private void drawViewerTask(Image img, Graphics g)
        {
            if (img == null)
            {
                //描画領域が存在しない場合は処理しない
                return;
            }

            this.mgrDraw = new ScheduleDrawComponent(this.mgr, g, img.Size);

            //マイルストーン
            foreach (var item in this.mgr.Tasks)
            {
                if (item.SectionID == -1)
                {
                    g.FillRectangle(
                        new SolidBrush(Color.FromArgb(ScheduleDrawComponent.DayTrans, item.ViewColor)),
                        (item.StartDate.Date - this.mgrDraw.StartDate).Days * ScheduleDrawComponent.DrawDayWidth,
                        0,
                        item.Span * ScheduleDrawComponent.DrawDayWidth,
                        img.Height - 1
                        );
                    g.DrawRectangle(
                        ScheduleDrawComponent.TaskFramePen,
                        (item.StartDate.Date - this.mgrDraw.StartDate).Days * ScheduleDrawComponent.DrawDayWidth,
                        0,
                        item.Span * ScheduleDrawComponent.DrawDayWidth,
                        img.Height - 1
                        );
                }
            }

            //個別タスク
            var cnt = 0;

            for (var sec = 0; sec < this.mgr.Sections.Count; sec++)
            {
                for (var worker = -1 /*部門全体から始める*/; worker < this.mgr.Sections[sec].Workers.Count; worker++)
                {
                    if (worker != -1)
                    {
                        cnt++;
                    }
                    //該当タスクがあれば描画する
                    foreach (var item in this.mgr.Tasks)
                    {
                        if ((worker == -1 && item.SectionID == this.mgr.Sections[sec].ID && item.WorkerID == -1) ||
                            (worker >= 0 && item.SectionID == this.mgr.Sections[sec].ID && item.WorkerID == this.mgr.Sections[sec].Workers[worker].ID))
                        {
                            if (item.DependTaskID == -1)
                            {
                                //独立タスクは通常通り描画
                                g.FillRectangle(
                                    new SolidBrush(Color.FromArgb(ScheduleDrawComponent.DayTrans, item.ViewColor)),
                                    (item.StartDate.Date - this.mgrDraw.StartDate).Days * ScheduleDrawComponent.DrawDayWidth,
                                    cnt * ScheduleDrawComponent.DrawLineHeight,
                                    item.Span * ScheduleDrawComponent.DrawDayWidth,
                                    ScheduleDrawComponent.DrawLineHeight
                                    );
                                g.DrawRectangle(
                                    ScheduleDrawComponent.TaskFramePen,
                                    (item.StartDate.Date - this.mgrDraw.StartDate).Days * ScheduleDrawComponent.DrawDayWidth,
                                    cnt * ScheduleDrawComponent.DrawLineHeight,
                                    item.Span * ScheduleDrawComponent.DrawDayWidth,
                                    ScheduleDrawComponent.DrawLineHeight
                                    );
                                g.DrawString(
                                    $"{item.TaskName} [{item.Progress}%]",
                                    ScheduleDrawComponent.TaskFont,
                                    Brushes.Black,
                                    (item.StartDate.Date - this.mgrDraw.StartDate).Days * ScheduleDrawComponent.DrawDayWidth + ScheduleDrawComponent.OffsetSection,
                                    cnt * ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetSection
                                    );
                            }
                            else
                            {
                                //依存タスクは開始日を算出してセットする
                                g.FillRectangle(
                                    new SolidBrush(Color.FromArgb(ScheduleDrawComponent.DayTrans, item.ViewColor)),
                                    (this.mgr.GetStartDateFromDependTaskID(item.DependTaskID) - this.mgrDraw.StartDate).Days * ScheduleDrawComponent.DrawDayWidth,
                                    cnt * ScheduleDrawComponent.DrawLineHeight,
                                    item.Span * ScheduleDrawComponent.DrawDayWidth,
                                    ScheduleDrawComponent.DrawLineHeight
                                    );
                                g.DrawRectangle(
                                    ScheduleDrawComponent.TaskFramePen,
                                    (this.mgr.GetStartDateFromDependTaskID(item.DependTaskID) - this.mgrDraw.StartDate).Days * ScheduleDrawComponent.DrawDayWidth,
                                    cnt * ScheduleDrawComponent.DrawLineHeight,
                                    item.Span * ScheduleDrawComponent.DrawDayWidth,
                                    ScheduleDrawComponent.DrawLineHeight
                                    );
                                g.DrawString(
                                    $"{item.TaskName} [{item.Progress}%]",
                                    ScheduleDrawComponent.TaskFont,
                                    Brushes.Black,
                                    (this.mgr.GetStartDateFromDependTaskID(item.DependTaskID) - this.mgrDraw.StartDate).Days * ScheduleDrawComponent.DrawDayWidth + ScheduleDrawComponent.OffsetSection,
                                    cnt * ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetSection
                                    );
                            }
                        }
                    }
                }
                cnt++;
            }

            //縦罫線
            for (var i = 1; i <= this.mgrDraw.WidthCount + 1; i++)
            {
                g.DrawLine(
                    ScheduleDrawComponent.TransLinePen,
                    i * ScheduleDrawComponent.DrawDayWidth,
                    0,
                    i * ScheduleDrawComponent.DrawDayWidth,
                    img.Height
                    );
            }

            //横罫線
            //セクション
            for (var i = 1; i <= this.mgrDraw.HeightCount; i++)
            {
                g.DrawLine(
                    ScheduleDrawComponent.TransLinePen,
                    0,
                    i * ScheduleDrawComponent.DrawLineHeight,
                    img.Width - ScheduleDrawComponent.DrawRightMargin,
                    i * ScheduleDrawComponent.DrawLineHeight
                    );
            }
        }
Beispiel #5
0
        /// <summary>
        /// カレンダー部分の描画処理
        /// </summary>
        private void drawViewerDate(Image img, Graphics g)
        {
            if (img == null)
            {
                //描画領域が存在しない場合は処理しない
                return;
            }

            this.mgrDraw = new ScheduleDrawComponent(this.mgr, g, img.Size);

            //マイルストーン
            foreach (var item in this.mgr.Tasks)
            {
                if (item.SectionID == -1)
                {
                    g.FillRectangle(
                        new SolidBrush(Color.FromArgb(ScheduleDrawComponent.DayTrans, item.ViewColor)),
                        (item.StartDate.Date - this.mgrDraw.StartDate).Days * ScheduleDrawComponent.DrawDayWidth,
                        ScheduleDrawComponent.DrawHeaderHeight - ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine - 2,
                        item.Span * ScheduleDrawComponent.DrawDayWidth, this.picTask.Image.Height
                        );
                    g.DrawRectangle(
                        ScheduleDrawComponent.TaskFramePen,
                        (item.StartDate.Date - this.mgrDraw.StartDate).Days * ScheduleDrawComponent.DrawDayWidth,
                        ScheduleDrawComponent.DrawHeaderHeight - ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine - 2,
                        item.Span * ScheduleDrawComponent.DrawDayWidth, this.picTask.Image.Height
                        );
                    g.DrawString(
                        item.TaskName,
                        ScheduleDrawComponent.TaskFont,
                        Brushes.Black,
                        (item.StartDate.Date - this.mgrDraw.StartDate).Days * ScheduleDrawComponent.DrawDayWidth + ScheduleDrawComponent.OffsetSection,
                        ScheduleDrawComponent.DrawHeaderHeight - ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine + ScheduleDrawComponent.OffsetSection
                        );
                }
            }

            //ヘッダー部
            for (var i = 0; i <= this.mgrDraw.WidthCount; i++)
            {
                var currentDate = this.mgrDraw.StartDate.AddDays(i);

                //本日ハイライト
                if (currentDate == DateTime.Today)
                {
                    g.FillRectangle(
                        Brushes.Yellow,
                        i * ScheduleDrawComponent.DrawDayWidth,
                        2,
                        ScheduleDrawComponent.DrawDayWidth,
                        (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * 3
                        );
                }

                if (i == 0 || currentDate.Day == 1)
                {
                    //月の初日に年を描画する
                    g.DrawString(
                        currentDate.Year.ToString(),
                        this.Font,
                        Brushes.Black,
                        i * ScheduleDrawComponent.DrawDayWidth,
                        (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * 0
                        );
                }

                if (i == 0 || currentDate.Day == 1 || currentDate.Day == 15)
                {
                    //月の初日と15日に月を描画する
                    g.DrawString(
                        $"{currentDate.Month,2}",
                        this.Font,
                        Brushes.Black,
                        ScheduleDrawComponent.OffsetHeaderDay + i * ScheduleDrawComponent.DrawDayWidth,
                        (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * 1
                        );
                }

                //日付は曜日で色分けする
                g.DrawString(
                    $"{currentDate.Day,2}",
                    this.Font,
                    (currentDate.DayOfWeek == DayOfWeek.Sunday) ? Brushes.Red : (currentDate.DayOfWeek == DayOfWeek.Saturday) ? Brushes.Blue : Brushes.Black,
                    ScheduleDrawComponent.OffsetHeaderDay + i * ScheduleDrawComponent.DrawDayWidth,
                    (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * 2 + 1
                    );
            }

            //縦罫線
            for (var i = 1; i <= this.mgrDraw.WidthCount + 1; i++)
            {
                g.DrawLine(
                    ScheduleDrawComponent.TransLinePen,
                    i * ScheduleDrawComponent.DrawDayWidth,
                    0,
                    i * ScheduleDrawComponent.DrawDayWidth,
                    img.Height
                    );
            }

            //横罫線
            //年
            g.DrawLine(
                Pens.Silver,
                0,
                (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * 1 - 2,
                img.Width - ScheduleDrawComponent.DrawRightMargin,
                (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * 1 - 2
                );

            //月
            g.DrawLine(
                Pens.Silver,
                0,
                (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * 2 - 2,
                img.Width - ScheduleDrawComponent.DrawRightMargin, (ScheduleDrawComponent.DrawLineHeight + ScheduleDrawComponent.OffsetHeaderLine) * 2 - 2
                );

            //日
            g.DrawLine(
                ScheduleDrawComponent.TaskFramePen,
                0,
                ScheduleDrawComponent.DrawHeaderHeight - (ScheduleDrawComponent.DrawLineHeight - ScheduleDrawComponent.OffsetHeaderLine) - 2,
                img.Width - ScheduleDrawComponent.DrawRightMargin,
                ScheduleDrawComponent.DrawHeaderHeight - (ScheduleDrawComponent.DrawLineHeight - ScheduleDrawComponent.OffsetHeaderLine) - 2
                );

            //マイルストーン
            g.DrawLine(
                ScheduleDrawComponent.TaskFramePen,
                0,
                ScheduleDrawComponent.DrawHeaderHeight,
                img.Width - ScheduleDrawComponent.DrawRightMargin,
                ScheduleDrawComponent.DrawHeaderHeight
                );
        }