예제 #1
0
        private void printDocWeek_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            float topMargin   = 30;
            float leftMargin  = 0;
            float RightMargin = e.MarginBounds.Right;

            //Facrication des objet font
            Font printFont6      = new Font("Times New Roman", 6, FontStyle.Regular);
            Font printFont       = new Font("Times New Roman", 8, FontStyle.Regular);
            Font printFontBold   = new Font("Times New Roman", 8, FontStyle.Bold);
            Font printFont10     = new Font("Times New Roman", 12, FontStyle.Regular);
            Font printFont12     = new Font("Times New Roman", 12, FontStyle.Regular);
            Font printFontBold12 = new Font("Times New Roman", 12, FontStyle.Bold);
            Font printFontBold10 = new Font("Times New Roman", 10, FontStyle.Bold);
            Font printFontBold14 = new Font("Times New Roman", 14, FontStyle.Bold);
            Font printFontBold16 = new Font("Times New Roman", 16, FontStyle.Bold);

            float yPos         = 0f;
            float yPosCalandar = 0f;
            float linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics);

            //en-tête
            yPos = topMargin;
            e.Graphics.DrawString("Gestion Auto Ecole - Horaire : " + cbEmploye.Text, printFontBold14, Brushes.Black, leftMargin, yPos, new StringFormat());
            yPos += printFontBold16.Height;

            //Cadrage et ligne de séparation
            const int TotalDay            = 7;
            int       CadrageWidth        = e.MarginBounds.Width + 150;
            int       CacrageHeigth       = e.MarginBounds.Height + 100;
            int       CadrageSectionWidth = (e.MarginBounds.Width + 150) / TotalDay;
            Rectangle Cadrage             = new Rectangle((int)leftMargin, (int)yPos, CadrageWidth, CacrageHeigth);

            e.Graphics.DrawRectangle(Pens.Black, Cadrage);

            //Creation des Description de chaque jours pour l'impression
            ScheduleDescriptionCollection HoraireDescriptions = new ScheduleDescriptionCollection();

            HoraireDescriptions.Add(scheduleControl1.HoraireDescription);
            HoraireDescriptions.Add(scheduleControl2.HoraireDescription);
            HoraireDescriptions.Add(scheduleControl3.HoraireDescription);
            HoraireDescriptions.Add(scheduleControl4.HoraireDescription);
            HoraireDescriptions.Add(scheduleControl5.HoraireDescription);
            HoraireDescriptions.Add(scheduleControl6.HoraireDescription);
            HoraireDescriptions.Add(scheduleControl7.HoraireDescription);

            //Imprime les ligne de séparation et le calandrier
            int LeftColumn = 0;             //Position gauche de la colone courante

            for (int i = 0; i < TotalDay; i++)
            {
                LeftColumn = (int)leftMargin + CadrageSectionWidth * i;
                Point pTop  = new Point(LeftColumn, Cadrage.Top);
                Point pDown = new Point(LeftColumn, Cadrage.Bottom);
                e.Graphics.DrawLine(Pens.Black, pTop, pDown);

                //Cree le calandrier en parcourant la liste des horaires
                yPosCalandar = Cadrage.Top + 3;
                e.Graphics.DrawString(DateTimeFunc.DayOfWeekFRShort(HoraireDescriptions[i].Jour.DayOfWeek) + " " + HoraireDescriptions[i].Jour.ToLongDateString(), printFontBold12, Brushes.Black, LeftColumn + 3, yPosCalandar);
                yPosCalandar += printFontBold12.Height;
                e.Graphics.DrawString(GetOffDate(HoraireDescriptions[i].Jour), printFont10, Brushes.Black, LeftColumn + 3, yPosCalandar);
                yPosCalandar += printFont10.Height;
                string[] ClientName;
                for (int j = 0; j < HoraireDescriptions[i].HoraireJour.Count; j++)
                {
                    ClientName = HoraireDescriptions[i].HoraireJour[j].ClientName.Split(' ');
                    e.Graphics.DrawString(DateTimeFunc.FormatHour(HoraireDescriptions[i].HoraireJour[j].Heures), printFont, Brushes.Black, LeftColumn + 2, yPosCalandar);
                    if (ClientName.Length > 1)
                    {
                        e.Graphics.DrawString(ClientName[ClientName.Length - 1], printFont6, Brushes.Black, LeftColumn + 38, yPosCalandar);
                        e.Graphics.DrawString(HoraireDescriptions[i].HoraireJour[j].SeanceNumber, printFont6, Brushes.Black, LeftColumn + 150, yPosCalandar);
                        e.Graphics.DrawString(HoraireDescriptions[i].HoraireJour[j].SeanceCode, printFont6, Brushes.Black, LeftColumn + 165, yPosCalandar);

                        e.Graphics.DrawString(HoraireDescriptions[i].HoraireJour[j].PhoneNumber, printFont6, Brushes.Black, LeftColumn + 38, yPosCalandar + printFont6.Height);
                        e.Graphics.DrawString("(" + HoraireDescriptions[i].HoraireJour[j].ContratNumber + ")", printFont6, Brushes.Black, LeftColumn + 150, yPosCalandar + printFont6.Height);
                    }

                    yPosCalandar += printFont.Height * 1.75f;
                }
            }
        }