//----------------------------------------------- public override void Draw( Rectangle rct, IFournisseurXGantt fournisseurX, System.Drawing.Graphics g) { base.Draw(rct, fournisseurX, g); if (ProjetAssocie != null && ProjetAssocie.HasChilds() && !ProjetAssocie.DateDebutAuto && ProjetAssocie.DateDebutPlanifieeCalculee != null && ProjetAssocie.DateFinPlanifieeCalculee != null) { Brush brFondBarre; if (CouleurFondBarre1 == CouleurFondBarre2) { brFondBarre = new SolidBrush(Color.FromArgb(128, CouleurFondBarre1)); } else { brFondBarre = new HatchBrush(HatchStyle.Percent50, Color.FromArgb(128, CouleurFondBarre1), Color.FromArgb(128, CouleurFondBarre2)); } Rectangle rctTmp = new Rectangle( fournisseurX.GetX(ProjetAssocie.DateDebutPlanifieeCalculee.Value), rct.Top + 4, fournisseurX.GetX(ProjetAssocie.DateFinPlanifieeCalculee.Value) - fournisseurX.GetX(ProjetAssocie.DateDebutPlanifieeCalculee.Value), 4); g.FillRectangle(brFondBarre, rctTmp); brFondBarre.Dispose(); } }
//------------------------------------------------------------------- public void Init( CParametresAffichageGantt parametre, IBaseGantt baseGantt, IFournisseurXGantt fournisseurX, IFournisseurYGantt fournisseurY) { m_baseGantt = baseGantt; ParametreAffichage = parametre; m_fournisseurX = fournisseurX; m_fournisseurY = fournisseurY; }
//------------------------------------------------------ public virtual void Draw( Rectangle rct, IFournisseurXGantt fournisseurX, System.Drawing.Graphics g) { AppliqueParametreDessin(); Font ft = new Font("System", 7); if (!g.ClipBounds.IntersectsWith(rct)) { return; } Brush br = null; Brush brFondBarre; if (CouleurFondBarre1 == CouleurFondBarre2) { brFondBarre = new SolidBrush(CouleurFondBarre1); } else { brFondBarre = new HatchBrush(HatchStyle.Percent50, CouleurFondBarre1, CouleurFondBarre2); } Rectangle rctBarre = rct; //Zone centrale if (!DrawHasGroup) //Gantt classique { if (DateDebut == DateFin) //Jalon { rctBarre = new Rectangle(rct.Left - 5, rct.Top, 10, 10); g.FillEllipse(brFondBarre, rctBarre); } else { g.FillRectangle(brFondBarre, rct); g.DrawRectangle(Pens.Black, rct); br = new SolidBrush(CouleurProgress); Rectangle rctProgress = rct; rctProgress = new Rectangle(rctProgress.Left, rctProgress.Top + (rctProgress.Height / 2 - 2), rctProgress.Width, 4); rctProgress.Width = (int)(rct.Width * PctAvancement / 100); g.FillRectangle(br, rctProgress); br.Dispose(); } } else//Regroupement { Pen pen = new Pen(CouleurFondBarre1); g.FillRectangle(brFondBarre, new Rectangle(rct.Left, rct.Top, rct.Size.Width, 4)); Point[] pts = new Point[] { new Point(rct.Left, rct.Top), new Point(rct.Left, rct.Bottom), new Point(rct.Left + 8, rct.Top) }; g.DrawPolygon(pen, pts); g.FillPolygon(brFondBarre, pts); pts = new Point[] { new Point(rct.Right, rct.Top), new Point(rct.Right, rct.Bottom), new Point(rct.Right - 8, rct.Top) }; g.DrawPolygon(pen, pts); g.FillPolygon(brFondBarre, pts); br = new SolidBrush(CouleurProgress); Rectangle rctProgress = rct; rctProgress.Width = (int)(rct.Width * PctAvancement / 100); rctProgress.Height = 2; rctProgress.Offset(0, 1); g.FillRectangle(br, rctProgress); br.Dispose(); } Rectangle rctLibelleBarre = DrawIcones(g, IconesBarre, rctBarre, false); //Libellé de la barre if (LibelleBarre != "") { SizeF szTmp = g.MeasureString(LibelleBarre, ft); szTmp = new SizeF(Math.Min(szTmp.Width, rctBarre.Width), Math.Min(szTmp.Height, rctBarre.Height)); br = new SolidBrush(Color.Transparent); Rectangle rctLibelle = new Rectangle(rctBarre.Left + (rctBarre.Width - (int)szTmp.Width) / 2, rctBarre.Top + (rctBarre.Height - (int)szTmp.Height) / 2, (int)szTmp.Width, (int)szTmp.Height); rctLibelle.Inflate(2, 0); g.FillRectangle(br, rctLibelle); br.Dispose(); br = new SolidBrush(CouleurTexteBarre); StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; g.DrawString(LibelleBarre, ft, br, rctLibelle, sf); br.Dispose(); } /*if ( DureeHeures != 0 ) * { * if ( AvancementTheorique > PctAvancement ) * { * Image alerte = Resource.exclamation_rect; * g.DrawImageUnscaled ( alerte, new Point ( rct.Right+2, rct.Top+(rct.Height-alerte.Height)/2-1)); * alerte.Dispose(); * } * }*/ //Affichage du pct avancement /* * Brush brFond = new SolidBrush(Color.FromArgb(255, 255, 255)); * string strPct = PctAvancement.ToString("00")+" %"; * SizeF sz = g.MeasureString(strPct, ft); * Point ptCenter = new Point ( rct.Left+(rct.Width-(int)(sz.Width))/2, * rct.Top+(rct.Height-(int)sz.Height)/2 ); * g.FillRectangle ( brFond, new Rectangle ( ptCenter.X, ptCenter.Y, * (int)sz.Width, (int)sz.Height )); * g.DrawString ( strPct, ft, Brushes.Black, ptCenter); * brFond.Dispose(); */ //Affichage zone de gauche Rectangle rctGauche = new Rectangle(0, rctBarre.Top, rctBarre.Left - 2, rctBarre.Height); rctGauche = DrawIcones(g, IconesGauche, rctGauche, false); if (LibelleGauche != "") { br = new SolidBrush(CouleurTexteGauche); StringFormat sf = new StringFormat(StringFormatFlags.DirectionRightToLeft | StringFormatFlags.NoWrap); g.DrawString(LibelleGauche, ft, br, rctGauche, sf); br.Dispose(); } //Affichage zone de droite Rectangle rctDroite = new Rectangle(rctBarre.Right + 2, rctBarre.Top, 1000, rctBarre.Height); rctDroite = DrawIcones(g, IconesDroite, rctDroite, true); if (LibelleDroite != "") { br = new SolidBrush(CouleurTexteDroite); g.DrawString(LibelleDroite, ft, br, rctDroite); br.Dispose(); } ft.Dispose(); brFondBarre.Dispose(); }