private LineProject GetLineProject(MouseEventArgs e) { PointF mousePos = UtilsModel.InvertFromGraph(new PointF(e.X, e.Y), 0, rectLimit.Location.X); PointF graphMouse = UtilsModel.ConvertToGraph(mousePos, rectLimit.Width, rectLimit.Location.X); float length = UtilsModel.LineLength(selectedAxe.Line.P1, selectedAxe.Line.P2); PointF xtm = UtilsModel.CalculateCurrPoint(length, selectedAxe.Angle, rectLimit.Width, rectLimit.Location.X); PointF graphXtm = UtilsModel.ConvertToGraph(xtm, rectLimit.Width, rectLimit.Location.X); float a = graphXtm.X, b = graphXtm.Y, c = -1 * ((graphXtm.X * graphMouse.X) + (graphXtm.Y * graphMouse.Y)); return(new LineProject(a, b, c)); }
private void PaintCurr(PaintEventArgs e) { List <PointF> peaks = new List <PointF>(); Pen pen = new Pen(ColorTranslator.FromHtml("#cf7b1f")); foreach (Axe axe in axes) { float length = UtilsModel.RuleOfThree(axe.UpperX, UtilsModel.LineLength(axe.Line.P1, axe.Line.P2), axe.CurrValue); PointF tmp = UtilsModel.CalculateCurrPoint(length, axe.Angle, rectLimit.Width, rectLimit.Location.X); peaks.Add(tmp); } e.Graphics.DrawPolygon(pen, peaks.ToArray()); }
private void PaintCmp(PaintEventArgs e) { List <PointF> peaks = new List <PointF>(); Brush pen = new SolidBrush(ColorTranslator.FromHtml("#d2d6d0")); foreach (Axe axe in axesCmp) { Axe vrai = this.FindAxe(axe); float lineLength = UtilsModel.LineLength(vrai.Line.P1, vrai.Line.P2); float length = UtilsModel.RuleOfThree(axe.UpperX, lineLength, axe.CurrValue); PointF tmp = UtilsModel.CalculateCurrPoint(length, vrai.Angle, rectLimit.Width, rectLimit.Location.X); peaks.Add(tmp); } e.Graphics.FillPolygon(pen, peaks.ToArray()); }
private void DragAndDrop_MouseDown(object sender, MouseEventArgs e) { PointF mousePos = UtilsModel.InvertFromGraph(new PointF(e.X, e.Y), 0, rectLimit.Location.X); foreach (Axe axe in axes) { float length = UtilsModel.RuleOfThree(axe.UpperX, UtilsModel.LineLength(axe.Line.P1, axe.Line.P2), axe.CurrValue); PointF tmp = UtilsModel.CalculateCurrPoint(length, axe.Angle, rectLimit.Width, rectLimit.Location.X); float distance = UtilsModel.LineLength(mousePos, tmp); if (distance <= 10) { this.selectedAxe = axe; this.textAxe.Text = this.selectedAxe.Name; this.valeurAxe.Text = this.selectedAxe.CurrValue + ""; this.uniteAxe.Text = this.selectedAxe.Unit; showSimilaire = false; axesSimilsaires = null; break; } } }