Example #1
0
 public void SetStyleJourAn(int nJour, int nMois, CJourStyle style)
 {
     m_tableStylesParAn[nMois * 32 + nJour] = style;
 }
Example #2
0
 public void SetStyleJourMois(int nJour, CJourStyle style)
 {
     m_tableStylesParMois[nJour] = style;
 }
Example #3
0
 public void SetStyleJour(DateTime jour, CJourStyle style)
 {
     m_tableStylesParJour[jour] = style;
 }
Example #4
0
 public void SetStyleJourSemaine(DayOfWeek jour, CJourStyle style)
 {
     m_tableStylesParSemaine[jour] = style;
 }
Example #5
0
        private void RedrawCalendrier(Graphics gToDraw)
        {
            //Dessin dans un bitamp
            if (m_bitmap != null)
            {
                m_bitmap.Dispose();
            }
            m_bitmap = new Bitmap(m_panelCalendrier.Width, m_panelCalendrier.Height);

            m_tableJourToRectangle.Clear();

            Graphics g = Graphics.FromImage(m_bitmap);

            g.FillRectangle(Brushes.White, ClientRectangle);
            string[] mois = new string[] { I.T("January|30092"), I.T("February|30093"), I.T("March|30094"), I.T("April|30095"),
                                           I.T("May|30096"), I.T("June|30097"), I.T("July|30098"), I.T("August|30099"), I.T("September|30100"),
                                           I.T("October|30101"), I.T("November|30102"), I.T("December|30103") };

            /*int nLargeurMois = m_labelModeleEntete.Width;
             * int nLargeurJour = m_labelModeleJour.Width;
             * int nHauteurJour = m_labelModeleJour.Height;
             * int nHauteurTotaleMois = m_labelModeleEntete.Height+m_labelModeleJour.Height*6;*/
            int nNbLignes          = (int)(12 / m_nNbColonnes + 0.99999);
            int nLargeurMois       = Math.Max(1, m_panelCalendrier.Width / m_nNbColonnes);
            int nLargeurJour       = Math.Max(1, nLargeurMois / 7);
            int nHauteurTotaleMois = Math.Max(1, m_panelCalendrier.Height / nNbLignes);
            int nHauteurJour       = Math.Max(1, (nHauteurTotaleMois - m_labelModeleEntete.Height) / 6);

            for (int nMois = 0; nMois < 12; nMois++)
            {
                int       nX         = (nMois % m_nNbColonnes) * nLargeurMois;
                int       nY         = (int)(nMois / m_nNbColonnes) * nHauteurTotaleMois;
                Rectangle rectTotal  = new Rectangle(nX, nY, nLargeurMois, nHauteurTotaleMois);
                Rectangle rectEntete = new Rectangle(nX, nY, nLargeurMois, m_labelModeleEntete.Height);
                g.FillRectangle(Brushes.DarkGreen, rectEntete);
                StringFormat format = new StringFormat(StringFormatFlags.NoWrap);
                format.Alignment     = StringAlignment.Center;
                format.LineAlignment = StringAlignment.Center;
                g.DrawString(mois[nMois], m_labelModeleEntete.Font, Brushes.White,
                             rectEntete, format);
                DateTime dt = new DateTime(m_nAnnee, nMois + 1, 1);

                int nXJour;
                nY += m_labelModeleEntete.Height;
                while (dt.Month - 1 == nMois)
                {
                    int nDay = (int)dt.DayOfWeek;
                    nDay   = (nDay + 6) % 7;
                    nXJour = nDay * nLargeurJour;
                    if (nDay == 0 && dt.Day != 1)
                    {
                        nY += nHauteurJour;
                    }
                    //Récupère le style pour le jour
                    CJourStyle style = m_defaultStyle;
                    object     obj   = m_tableStylesParJour[dt];
                    if (obj == null)
                    {
                        obj = m_tableStylesParAn[dt.Month * 32 + dt.Day];
                    }
                    if (obj == null)
                    {
                        obj = m_tableStylesParMois[dt.Day];
                    }
                    if (obj == null)
                    {
                        obj = m_tableStylesParSemaine[dt.DayOfWeek];
                    }
                    if (obj != null)
                    {
                        style = (CJourStyle)obj;
                    }
                    Rectangle rect = new Rectangle(nX + nXJour, nY, nLargeurJour + 1, nHauteurJour + 1);
                    Brush     br   = new SolidBrush(style.CouleurFond);
                    g.FillRectangle(br, rect);
                    br.Dispose();
                    br = new SolidBrush(style.CouleurTexte);
                    g.DrawString(dt.Day.ToString(), m_labelModeleJour.Font, br, rect, format);
                    br.Dispose();
                    m_tableJourToRectangle[dt] = rect;



                    dt = dt.AddDays(1);
                }
                g.DrawRectangle(Pens.Black, rectTotal);
            }
            gToDraw.DrawImage(m_bitmap, 0, 0);
            g.Dispose();
            ShowSelection();
        }