Ejemplo n.º 1
0
        /// <summary>
        /// 印刷初期化
        /// </summary>
        /// <param name="e">発生したイベント</param>
        protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e)
        {
            if (TimeTable == null)
            {
                return;
            }
            CachedStart = Start;
            CachedEnd   = End;
            // タイムテーブルによる設定
            header.TimeTable = TimeTable;
            header.Document  = this;
            footer.TimeTable = TimeTable;
            footer.Document  = this;
            index            = 0;
            // メンバーの一覧設定
            members.Clear();
            int z = TimeTable.Members.Size(true);

            for (int i = 0; i < z; i++)
            {
                CMember member = TimeTable.Members[i, true];
                if (member.IsAvailable(Start) || member.IsAvailable(End))
                {
                    members.Add(member);
                }
            }
            // ページの作成
            TimeSpan ONEDAY = new TimeSpan(1, 0, 0, 0);

            pages.Clear();
            bool       cont1 = true;
            DateTime   k     = Start;
            CPageIndex page  = null;

            while (cont1)
            {
                int  j     = 0;
                bool cont2 = true;
                while (cont2)
                {
                    page                  = new CPageIndex();
                    page.Document         = this;
                    page.Start            = k;
                    page.MemberStartIndex = j;
                    page.CalcPage();
                    pages.Add(page);
                    j = page.MemberEndIndex + 1;
                    if (j >= members.Count)
                    {
                        cont2 = false;
                    }
                }
                k = page.End.AddDays(1);
                if (k >= End)
                {
                    cont1 = false;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>印刷・ボディ部分
        /// </summary>
        /// <param name="g">グラフィックスオブジェクト</param>
        /// <param name="e">イベント</param>
        protected virtual void PaintBody(Graphics g, System.Drawing.Printing.PrintPageEventArgs e)
        {
            //Graphics g = e.Graphics;
            Rectangle  mar = e.MarginBounds;
            RectangleF rect;

            #region 内部の箱
            {
                float itop    = mar.Top + Header.GetHeight(g);
                float ibottom = mar.Bottom - Footer.GetHeight(g) - 2;
                float iheight = ibottom - itop;
                float ileft   = mar.Left;
                float iwidth  = mar.Width;
                float iright  = ileft + iwidth;
                rect = new RectangleF(ileft, itop, iwidth, iheight);
            }
            #endregion
            //
            g.DrawRectangle(this.Pen, rect.Left, rect.Top, rect.Width, rect.Height);
            //
            CPageIndex page = pages[index];
            // 決め打ちできる罫線を引く
            float DateRight = rect.Left + RequireColumnWidth;
            g.DrawLine(this.Pen, DateRight, rect.Top, DateRight, rect.Bottom);
            DrawString(g, "日付", HeaderFont, HeaderBrush, rect.Left, DateRight, rect.Top, tableHeaderHight, EPrintMargin.MARGIN_CENTER, EPrintMargin.MARGIN_CENTER);
            float RequireRight = DateRight;
            if (IsDisplayRequire)
            {
                RequireRight += RequireColumnWidth;
                g.DrawLine(this.Pen, RequireRight, rect.Top, RequireRight, rect.Bottom);
                DrawString(g, "人員配置", HeaderFont, HeaderBrush, DateRight, RequireRight, rect.Top, tableHeaderHight, EPrintMargin.MARGIN_CENTER, EPrintMargin.MARGIN_CENTER);
            }
            // テーブルのヘッダ
            float TableHeadBottom = rect.Top + TableHeaderHight;
            g.DrawLine(this.Pen, rect.Left, TableHeadBottom, rect.Right, TableHeadBottom);
            // メンバー数に応じた罫線を引く
            float MemberColumnBase  = (IsDisplayRequire ? RequireRight : DateRight);
            float MemberColumnSpace = rect.Right - MemberColumnBase;
            float MemberColumnWidth = MemberColumnSpace / page.MemberCount;
            for (int i = 1; i < page.MemberCount; i++)
            {
                float WorkLeft  = MemberColumnBase + MemberColumnWidth * (i - 1);
                float WorkRight = MemberColumnBase + MemberColumnWidth * i;
                g.DrawLine(this.Pen, WorkRight, rect.Top, WorkRight, rect.Bottom);
            }
            // メンバー名
            for (int i = 0; i < page.MemberCount; i++)
            {
                float WorkLeft  = MemberColumnBase + MemberColumnWidth * i;
                float WorkRight = MemberColumnBase + MemberColumnWidth * (i + 1);
                //
                CMember member = this.TimeTable.Members[page.MemberStartIndex + i];
                DrawString(g, member.Name, HeaderFont, HeaderBrush, WorkLeft, WorkRight, rect.Top, tableHeaderHight, EPrintMargin.MARGIN_CENTER, EPrintMargin.MARGIN_CENTER);
            }
            // 日数に応じた罫線を引く
            float DateRowSpace  = rect.Bottom - TableHeadBottom;
            float DateRowHeight = DateRowSpace / page.DateCount;
            for (int i = 1; i < page.DateCount; i++)
            {
                float WorkTop    = TableHeadBottom + DateRowHeight * (i - 1);
                float WorkBottom = TableHeadBottom + DateRowHeight * i;
                g.DrawLine(this.Pen, rect.Left, WorkBottom, rect.Right, WorkBottom);
            }
            // これこそ本体
            DateTime WorkDate = page.Start;
            for (int i = 0; i < page.DateCount; i++)
            {
                float WorkTop    = TableHeadBottom + DateRowHeight * i;
                float WorkBottom = TableHeadBottom + DateRowHeight * (i + 1);
                // 日付
                DrawString(g, WorkDate.ToString(DateFormat), System.Windows.Forms.Control.DefaultFont, Brushes.Black, rect.Left, DateRight, WorkTop, DateRowHeight, EPrintMargin.MARGIN_CENTER, EPrintMargin.MARGIN_CENTER);
                // スケジュール日
                CScheduledDate sdate = this.TimeTable[WorkDate];
                if (IsDisplayRequire)
                {
                    if (sdate.Require != null)
                    {
                        DrawString(g, sdate.Require.Name, BodyFont, BodyBrush, DateRight, RequireRight, WorkTop, DateRowHeight, EPrintMargin.MARGIN_CENTER, EPrintMargin.MARGIN_CENTER);
                    }
                }
                // シフト
                for (int j = 0; j < page.MemberCount; j++)
                {
                    float WorkLeft  = MemberColumnBase + MemberColumnWidth * j;
                    float WorkRight = MemberColumnBase + MemberColumnWidth * (j + 1);
                    //
                    CMember   member   = this.TimeTable.Members[page.MemberStartIndex + j];
                    CSchedule schedule = sdate[member];
                    CPattern  pattern  = (schedule != null ? schedule.Pattern : null);
                    if (pattern != null)
                    {
                        DrawString(g, pattern.Name, BodyFont, BodyBrush, WorkLeft, WorkRight, WorkTop, DateRowHeight, EPrintMargin.MARGIN_CENTER, EPrintMargin.MARGIN_CENTER);
                    }
                }
                //
                WorkDate = WorkDate.AddDays(1);
            }
            //
            e.HasMorePages = page.HasMorePage;
            //
            index++;
        }