//------------------------------------------------------- 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 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(); * }*/ }