//------------------------------------------------------- public override void Draw(CContextDessinObjetGraphique ctx) { base.Draw(ctx); if (SourceEntites is CSourceEntitesPourTableDataChampDeTable) { string strIdTable = ((CSourceEntitesPourTableDataChampDeTable)SourceEntites).IdTable; IObjetDeEasyQuery tableSource = null; foreach (IObjetDeEasyQuery objet in Query.Childs) { CODEQBase o = objet as CODEQBase; if (o != null && o.Id == strIdTable) { tableSource = o; break; } } if (tableSource != null) { Pen pen = new Pen(Brushes.Black, 2); CLienTracable lien = CTraceurLienDroit.GetLienPourLier(tableSource.RectangleAbsolu, RectangleAbsolu, EModeSortieLien.Automatic); lien.RendVisibleAvecLesAutres(ctx.Liens); ctx.AddLien(lien); pen.DashStyle = DashStyle.Dot; AdjustableArrowCap cap = new AdjustableArrowCap(4, 4, true); pen.CustomEndCap = cap; lien.Draw(ctx.Graphic, pen); pen.Dispose(); cap.Dispose(); } } }
//--------------------------------------------------- protected override void MyDraw(CContextDessinObjetGraphique ctx) { base.MyDraw(ctx); IObjetDeEasyQuery source = TableSource; if (source != null) { Pen pen = new Pen(Brushes.Black, 2); CLienTracable lien = CTraceurLienDroit.GetLienPourLier(source.RectangleAbsolu, RectangleAbsolu, EModeSortieLien.Automatic); lien.RendVisibleAvecLesAutres(ctx.Liens); ctx.AddLien(lien); AdjustableArrowCap cap = new AdjustableArrowCap(4, 4, true); pen.CustomEndCap = cap; lien.Draw(ctx.Graphic, pen); pen.Dispose(); cap.Dispose(); } }
//---------------------------------------------------------------------------------------- public void Draw(IObjetDeEasyQuery objetPossedant, CContextDessinObjetGraphique ctxDessin) { if (objetPossedant != null && objetPossedant.Query != null) { IObjetDeEasyQuery objet = objetPossedant.Query.GetObjet(SourceTableId); if (objet != null) { Color c = Color.FromArgb(128, 0, 0, 255); Pen pen = new Pen(c, 1); AdjustableArrowCap cap = new AdjustableArrowCap(4, 4, true); pen.CustomEndCap = cap; CLienTracable lien = CTraceurLienDroit.GetLienPourLier(objet.RectangleAbsolu, objetPossedant.RectangleAbsolu, EModeSortieLien.Automatic); lien.RendVisibleAvecLesAutres(ctxDessin.Liens); ctxDessin.AddLien(lien); lien.Draw(ctxDessin.Graphic, pen); pen.Dispose(); cap.Dispose(); } } }
protected void DrawLien( CContextDessinObjetGraphique ctx, Pen pen, Font ft, CRepresentationExpressionGraphique de, CRepresentationExpressionGraphique vers, string strText ) { CLienTracable lien = CTraceurLienDroit.GetLienPourLier(de.RectangleAbsolu, vers.RectangleAbsolu, EModeSortieLien.Automatic); lien.RendVisibleAvecLesAutres(ctx.Liens); ctx.AddLien(lien); ctx.Graphic.DrawLines(pen, lien.Points.ToArray()); if (strText != "" && lien.Points.Count() > 0) { CSegmentDroite segment = lien.Segments[0]; Point ptMilieu = segment.Milieu; Brush br = new SolidBrush(pen.Color); ctx.Graphic.DrawString(strText, ft, br, ptMilieu); br.Dispose(); } }
private void AssurePositionOk( ) { if (!m_bPositionInvalide)//Vérifie que le départ et l'arrivé n'ont pas bougé { if (ActionDepart != null && ActionDepart.RectangleAbsolu != m_lastRectangleDepart || ActionArrivee != null && ActionArrivee.RectangleAbsolu != m_lastRectangleArrivee) { m_bPositionInvalide = true; } } if (m_bPositionInvalide) { Point pt1; CAction actionDepart = ActionDepart; if (actionDepart == null) { pt1 = m_lastPointDepart; } else { m_lastRectangleDepart = actionDepart.RectangleAbsolu; pt1 = GetCentreRect(m_lastRectangleDepart); } Point pt2; CAction actionArrivee = ActionArrivee; if (actionArrivee == null) { pt2 = m_lastPointArrivee; } else { m_lastRectangleArrivee = actionArrivee.RectangleAbsolu; pt2 = GetCentreRect(m_lastRectangleArrivee); } m_lienTracable = CTraceurLienDroit.GetLien(pt1, pt2, ModeSortieDuLien); if (actionDepart != null) { Point[] pts1 = actionDepart.GetPolygoneDessin(); //Suppression des segments inutiles int nLastIntersect = 0; CSegmentDroite[] segments = m_lienTracable.Segments; for (nLastIntersect = segments.Count() - 1; nLastIntersect > 0; nLastIntersect--) { Point dummy = new Point(0, 0); if (segments[nLastIntersect].GetIntersectionPoint(pts1, ref dummy)) { break; } } for (int n = 0; n < nLastIntersect; n++) { m_lienTracable.RemovePoint(0); } if (m_lienTracable.Points.Count() > 1) { CSegmentDroite segment = new CSegmentDroite(m_lienTracable.Points.ElementAt(0), m_lienTracable.Points.ElementAt(1)); if (segment.GetIntersectionPoint(pts1, ref pt1)) { m_lienTracable.RemplacePoint(0, pt1); } } } if (actionArrivee != null) { Point[] pts2 = actionArrivee.GetPolygoneDessin(); //Suppression des segments inutiles CSegmentDroite[] segments = m_lienTracable.Segments; int nLastIntersect = segments.Count() - 1; for (nLastIntersect = 0; nLastIntersect < segments.Count() - 1; nLastIntersect++) { Point dummy = new Point(0, 0); if (segments[nLastIntersect].GetIntersectionPoint(pts2, ref dummy)) { break; } } for (int n = nLastIntersect + 1; n < segments.Count(); n++) { m_lienTracable.RemovePoint(m_lienTracable.Points.Count() - 1); } if (m_lienTracable.Points.Count() > 1) { CSegmentDroite segment = new CSegmentDroite( m_lienTracable.Points.ElementAt(m_lienTracable.Points.Count() - 2), m_lienTracable.Points.ElementAt(m_lienTracable.Points.Count() - 1)); if (segment.GetIntersectionPoint(pts2, ref pt2)) { m_lienTracable.RemplacePoint(m_lienTracable.Points.Count() - 1, pt2); } } } m_lastPointDepart = m_lienTracable.Points.ElementAt(0);; m_lastPointArrivee = m_lienTracable.Points.ElementAt(m_lienTracable.Points.Count() - 1); m_bPositionInvalide = false; } }
/// ////////////////////////////////////////////////////////////// protected override void MyDraw(CContextDessinObjetGraphique ctx) { Graphics g = ctx.Graphic; AssurePositionOk(); Point pt1 = m_lastPointDepart; Point pt2 = m_lastPointArrivee; CLienTracable lien = new CLienTracable(GetLienTracable()); lien.RendVisibleAvecLesAutres(ctx.Liens); ctx.AddLien(lien); Pen pen = GetNewPenCouleurCadre(); lien.Draw(ctx.Graphic, pen); pt1 = lien.Points.ElementAt(lien.Points.Count() - 2); pt2 = lien.Points.ElementAt(lien.Points.Count() - 1); pen.Dispose(); try { double fDim = 12; double fCosa = (double)Math.Abs(pt1.X - pt2.X) / (double)(Math.Sqrt((pt1.X - pt2.X) * (pt1.X - pt2.X) + (pt1.Y - pt2.Y) * (pt1.Y - pt2.Y))); double fSina = (double)Math.Abs(pt1.Y - pt2.Y) / (double)(Math.Sqrt((pt1.X - pt2.X) * (pt1.X - pt2.X) + (pt1.Y - pt2.Y) * (pt1.Y - pt2.Y))); Point m = new Point(0, 0); Point[] p = new Point[2]; p[0] = new Point(0, 0); p[1] = new Point(0, 0); if (pt1.X > pt2.X) { m.X = (int)(pt2.X + (long)(fDim * Math.Sqrt(3) * fCosa / 2.0)); p[0].X = (int)(m.X + (long)(fDim * fSina / 2.0)); p[1].X = (int)(m.X - (long)(fDim * fSina / 2.0)); } else { m.X = (int)(pt2.X - (long)(fDim * Math.Sqrt(3) * fCosa / 2.0)); p[0].X = (int)(m.X - (long)(fDim * fSina / 2.0)); p[1].X = (int)(m.X + (long)(fDim * fSina / 2.0)); } if (pt1.Y > pt2.Y) { m.Y = (int)(pt2.Y + (long)(fDim * Math.Sqrt(3) * fSina / 2.0)); p[0].Y = (int)(m.Y - (long)(fDim * fCosa / 2.0)); p[1].Y = (int)(m.Y + (long)(fDim * fCosa / 2.0)); } else { m.Y = (int)(pt2.Y - (long)(fDim * Math.Sqrt(3) * fSina / 2.0)); p[0].Y = (int)(m.Y + (long)(fDim * fCosa / 2.0)); p[1].Y = (int)(m.Y - (long)(fDim * fCosa / 2.0)); } pen = GetNewPenCouleurCadre(); g.DrawLine(pen, pt2.X, pt2.Y, p[0].X, p[0].Y); g.DrawLine(pen, pt2.X, pt2.Y, p[1].X, p[1].Y); pen.Dispose(); } catch { } Image img = GetImage(); if (img != null) { Point ptImage = lien.GetMilieu(); ptImage.X -= img.Width / 2; ptImage.Y -= img.Height / 2; g.DrawImage(img, ptImage.X, ptImage.Y, img.Width, img.Height); img.Dispose(); } }
/// ////////////////////////////////////////////////////////////// protected override void MyDraw(CContextDessinObjetGraphique ctx) { Graphics g = ctx.Graphic; AssurePositionOk(); Point pt1 = m_lastPointDepart; Point pt2 = m_lastPointArrivee; CLienTracable lien = new CLienTracable(GetLienTracable()); lien.RendVisibleAvecLesAutres(ctx.Liens); ctx.AddLien(lien); Pen pen = GetNewPenCouleurCadre(); lien.Draw(ctx.Graphic, pen); pt1 = lien.Points.ElementAt(lien.Points.Count() - 2); pt2 = lien.Points.ElementAt(lien.Points.Count() - 1); pen.Dispose(); try { double fDim = 12; double fCosa = (double)Math.Abs(pt1.X - pt2.X) / (double)(Math.Sqrt((pt1.X - pt2.X) * (pt1.X - pt2.X) + (pt1.Y - pt2.Y) * (pt1.Y - pt2.Y))); double fSina = (double)Math.Abs(pt1.Y - pt2.Y) / (double)(Math.Sqrt((pt1.X - pt2.X) * (pt1.X - pt2.X) + (pt1.Y - pt2.Y) * (pt1.Y - pt2.Y))); Point m = new Point(0, 0); Point[] p = new Point[2]; p[0] = new Point(0, 0); p[1] = new Point(0, 0); if (pt1.X > pt2.X) { m.X = (int)(pt2.X + (long)(fDim * Math.Sqrt(3) * fCosa / 2.0)); p[0].X = (int)(m.X + (long)(fDim * fSina / 2.0)); p[1].X = (int)(m.X - (long)(fDim * fSina / 2.0)); } else { m.X = (int)(pt2.X - (long)(fDim * Math.Sqrt(3) * fCosa / 2.0)); p[0].X = (int)(m.X - (long)(fDim * fSina / 2.0)); p[1].X = (int)(m.X + (long)(fDim * fSina / 2.0)); } if (pt1.Y > pt2.Y) { m.Y = (int)(pt2.Y + (long)(fDim * Math.Sqrt(3) * fSina / 2.0)); p[0].Y = (int)(m.Y - (long)(fDim * fCosa / 2.0)); p[1].Y = (int)(m.Y + (long)(fDim * fCosa / 2.0)); } else { m.Y = (int)(pt2.Y - (long)(fDim * Math.Sqrt(3) * fSina / 2.0)); p[0].Y = (int)(m.Y + (long)(fDim * fCosa / 2.0)); p[1].Y = (int)(m.Y - (long)(fDim * fCosa / 2.0)); } pen = GetNewPenCouleurCadre(); g.DrawLine(pen, pt2.X, pt2.Y, p[0].X, p[0].Y); g.DrawLine(pen, pt2.X, pt2.Y, p[1].X, p[1].Y); pen.Dispose(); //Dessin du libelle string strLibelle = ActivationCode; if (strLibelle.Trim().Length > 0) { CSegmentDroite[] segments = lien.Segments; Font ft = new Font("Arial", 6, FontStyle.Regular); SizeF size = g.MeasureString(strLibelle, ft); Rectangle rect = RectangleAbsolu; Point pt = segments[0].Milieu; if (segments[0].Vecteur.Y == 0)//horizontal { pt.Offset(-(int)(size.Width / 2), -(int)(size.Height + 3)); } else { pt.Offset(3, (int)(-size.Height / 2)); } Brush bBlack = new SolidBrush(Color.Black); g.DrawString(strLibelle, ft, bBlack, pt.X, pt.Y); bBlack.Dispose(); ft.Dispose(); } } catch { } /* * Image img = GetImage(); * if (img != null) * { * Point ptImage = lien.GetMilieu(); * ptImage.X -= img.Width / 2; * ptImage.Y -= img.Height / 2; * g.DrawImage(img, ptImage.X, ptImage.Y, img.Width, img.Height); * img.Dispose(); * }*/ }