//------------------------------------------ public void Draw( CContextDessinObjetGraphique ctx, IElementDeSchemaReseau element, C2iObjetGraphique objetGraphique) { ApplyOnSymbole(element); if (m_symbole != null) { m_symbole.Transparency = 100; Matrix oldMat = ctx.Graphic.Transform; C2iLienDeSchemaReseau lien = objetGraphique as C2iLienDeSchemaReseau; if (lien != null) { //Se place au centre du lien Point pt = lien.GetPointCentral(); pt.Offset(-m_symbole.Width / 2, -m_symbole.Height / 2); ctx.Graphic.TranslateTransform(pt.X, pt.Y); } else { float fEchelleX = (float)objetGraphique.Size.Width / (float)m_symbole.Size.Width; float fEchelleY = (float)objetGraphique.Size.Height / (float)m_symbole.Size.Height; ctx.Graphic.InterpolationMode = InterpolationMode.HighQualityBilinear; ctx.Graphic.TranslateTransform(objetGraphique.Position.X, objetGraphique.Position.Y); ctx.Graphic.ScaleTransform(fEchelleX, fEchelleY); } m_symbole.Draw(ctx); ctx.Graphic.Transform = oldMat; } }
//-------------------------------------------------------------------- private void DrawSelectionLien(Graphics g, C2iLienDeSchemaReseau dessinLien) { int fDist = 3; Pen pen = new Pen(Color.Black, 1); pen.DashStyle = DashStyle.Dot; for (int nCote = -1; nCote <= 1; nCote += 2) { for (int nPoint = 0; nPoint < dessinLien.Points.Length - 1; nPoint++) { Point pt1 = dessinLien.Points[nPoint]; Point pt2 = dessinLien.Points[nPoint + 1]; if (pt1.Y == pt2.Y) { pt1.Offset(00, (int)(fDist * nCote)); pt2.Offset(0, (int)(fDist * nCote)); } else { double fPente = -((pt1.X - pt2.X) / (pt1.Y - pt2.Y)); double fX = fDist / (Math.Sqrt(1 + fPente * fPente)) * nCote; double fY = fPente * fX; pt1.Offset((int)fX, (int)fY); pt2.Offset((int)fX, (int)fY); } g.DrawLine(pen, pt1, pt2); } } pen.Dispose(); }
//--------------------------------------------------------------------------------------------- public override void BeforeDrawObjet(CContextDessinObjetGraphique ctx, C2iObjetDeSchema objet) { if (!IsConcerneParAlarme) { return; } C2iLienDeSchemaReseau dessinLien = objet as C2iLienDeSchemaReseau; Color couleur = CSpvAlarmcouleur.GetColor(CouleurAlarme, dessinLien.ElementDeSchema.ContexteDonnee); Pen pen = new Pen(couleur, 3); Point[] pts = dessinLien.Points; for (int nPoint = 0; nPoint <= pts.Length - 2; nPoint++) { ctx.Graphic.DrawLine(pen, pts[nPoint], pts[nPoint + 1]); } pen.Dispose(); }
//--------------------------------------------------------------------------------------------- public override void BeforeDrawObjet(CContextDessinObjetGraphique ctx, C2iObjetDeSchema objet) { if (!IsConcerneParAlarme) { return; } C2iLienDeSchemaReseau dessinLien = objet as C2iLienDeSchemaReseau; Color couleur = SeveriteAlarme != null ? SeveriteAlarme.Couleur : Color.White; Pen pen = new Pen(couleur, 3); Point[] pts = dessinLien.Points; for (int nPoint = 0; nPoint <= pts.Length - 2; nPoint++) { ctx.Graphic.DrawLine(pen, pts[nPoint], pts[nPoint + 1]); } pen.Dispose(); }
public bool DoDessinSupplementaireBefore(CContextDessinObjetGraphique ctx, C2iObjetGraphique objet) { C2iLienDeSchemaReseau dessinLien = objet as C2iLienDeSchemaReseau; if (dessinLien == null) //Optim : seuls les liens sont dessinés avant. Pour le moment, les autres non { return(true); } //Dessine sous les segments CInfoElementDeSchemaSupervise infoSupervision = null; if (!m_dicElementDeSchemaToInfoSupervision.TryGetValue(dessinLien.ElementDeSchema.Id, out infoSupervision)) { return(true); } infoSupervision.BeforeDrawObjet(ctx, dessinLien); return(true); }
//-------------------------------------------------------------------- private void DrawSelection(Graphics g) { if (m_objetDeSchemaSelectionne == null || (m_objetDeSchemaSelectionne is C2iSchemaReseau)) { return; } C2iLienDeSchemaReseau dessinLien = m_objetDeSchemaSelectionne as C2iLienDeSchemaReseau; if (dessinLien != null) { DrawSelectionLien(g, dessinLien); return; } Rectangle rct = m_objetDeSchemaSelectionne.RectangleAbsolu; rct = new Rectangle( GetScreenPoint(rct.Location, false), GetScreenSize(rct.Size)); Pen pen = new Pen(Color.Black, 2); pen.DashStyle = DashStyle.Dot; g.DrawRectangle(pen, rct); pen.Dispose(); }
public override void AfterDrawObjet(CContextDessinObjetGraphique ctx, C2iObjetDeSchema objet) { if (!IsConcerneParAlarme) { return; } C2iLienDeSchemaReseau dessinLien = objet as C2iLienDeSchemaReseau; if (dessinLien == null) { return; } //Image img = m_base.GetImageIsOperationnel(m_bIsOperationnel); Image img = m_base.GetImageEtatOperationnel(m_etatOperationnel); Point[] pts = dessinLien.Points; Point pt; if (pts.Length % 2 == 0) { //trouve les points du milieu Point pt1 = pts[pts.Length / 2 - 1]; Point pt2 = pts[pts.Length / 2]; pt = new Point((pt1.X + pt2.X) / 2, (pt1.Y + pt2.Y) / 2); } else { pt = pts[pts.Length / 2]; } Image imgMask = null; if (HasMasquageAdministrateur) { imgMask = SpvDataResource.Mask_adm; } else if (HasMasquageBrigadier) { imgMask = SpvDataResource.mask_bri; } Size sz = new Size(0, 0); if (img != null) { sz = new Size(img.Size.Width, img.Size.Height); } if (imgMask != null) { sz = new Size(sz.Width + imgMask.Width, Math.Max(sz.Height, imgMask.Height)); } if (img != null) { Point ptImg = pt; ptImg.Offset(-sz.Width / 2, -img.Height / 2); pt.Offset(-sz.Width / 2 + img.Width, 0); ctx.Graphic.DrawImageUnscaled(img, ptImg); } else { pt.Offset(sz.Width / 2, 0); } if (imgMask != null) { pt.Offset(0, -imgMask.Height / 2); ctx.Graphic.DrawImageUnscaled(imgMask, pt); } }