private void zedGraphControlMain_DoubleClick(object sender, EventArgs e) { conLog.Add("Graph"); if (perspective.withLine) { var pane = zedGraphControlMain.GraphPane; if (perspective.withCurLine) { pane.CurveList.Remove(pane.CurveList.Count - 1); perspective.withCurLine = false; } var repeatMainLine = false; if (perspective.withMainLine) { pane.CurveList.Remove(pane.CurveList.Count - 1); repeatMainLine = perspective.mainLineX == perspective.curLineX; perspective.withMainLine = false; } perspective.mainLineX = perspective.curLineX; if (!repeatMainLine) { var gp = new GraphProcessing(); gp.drawVerticalLine(perspective, true); perspective.withMainLine = true; } zedGraphControlMain.AxisChange(); if (pane.GraphItemList.Count != 0) { pane.GraphItemList.RemoveAt(0); } Method.Trial trialOfMin = new Method.Trial(); foreach (var pointInfo in perspective.methodInfo.report.iterations) { if (perspective.curLineX == pointInfo.x) { trialOfMin = pointInfo; break; } } var point = new ZedGraph.TextItem(string.Format("{0}({1}; {2})", trialOfMin.i - 2, trialOfMin.x, trialOfMin.y), (float)trialOfMin.x, (float)pane.YAxis.Max); point.FontSpec.FontColor = perspective.colorLine; point.FontSpec.Border.Color = perspective.colorPoint; point.FontSpec.Fill.Color = perspective.colorBack; //point.FontSpec.Angle = 2; pane.GraphItemList.Add(point); zedGraphControlMain.Invalidate(); } }
private void labelMinBegin_Click(object sender, EventArgs e) { conLog.Add("Minimum"); if (perspective.withLine) { var pane = zedGraphControlMain.GraphPane; if (perspective.withCurLine) { pane.CurveList.Remove(pane.CurveList.Count - 1); perspective.withCurLine = false; } var repeatMainLine = false; if (perspective.withMainLine) { pane.CurveList.Remove(pane.CurveList.Count - 1); repeatMainLine = perspective.mainLineX == perspective.methodInfo.report.minimum.x; perspective.withMainLine = false; } perspective.mainLineX = perspective.methodInfo.report.minimum.x; if (pane.GraphItemList.Count != 0) { pane.GraphItemList.RemoveAt(0); } if (!repeatMainLine) { var gp = new GraphProcessing(); gp.drawVerticalLine(perspective, true); perspective.withMainLine = true; } zedGraphControlMain.AxisChange(); if (!repeatMainLine) { var minimum = perspective.methodInfo.report.minimum; var point = new ZedGraph.TextItem(string.Format("{0}({1}; {2})", minimum.i - 2, minimum.x, minimum.y), (float)minimum.x, (float)pane.YAxis.Max); point.FontSpec.FontColor = perspective.colorLine; point.FontSpec.Border.Color = perspective.colorPoint; point.FontSpec.Fill.Color = perspective.colorBack; //point.FontSpec.Angle = 2; pane.GraphItemList.Add(point); } zedGraphControlMain.Invalidate(); } }
public void ClickOnTableLayoutPanel(object sender, MouseEventArgs e) { int column = tableLayoutPanel.GetColumn((Control)sender); var control = tableLayoutPanel.GetControlFromPosition(column, 0); var param = control.Text.Split('\n'); if (perspective.withLine) { var pane = zedGraphControlMain.GraphPane; if (perspective.withCurLine) { pane.CurveList.Remove(pane.CurveList.Count - 1); perspective.withCurLine = false; } if (perspective.withMainLine) { pane.CurveList.Remove(pane.CurveList.Count - 1); perspective.withMainLine = false; } perspective.mainLineX = perspective.curLineX; var gp = new GraphProcessing(); gp.drawVerticalLine(perspective, true); perspective.withMainLine = true; zedGraphControlMain.AxisChange(); if (pane.GraphItemList.Count != 0) { pane.GraphItemList.RemoveAt(0); } Method.Trial trialOfMin = new Method.Trial(); trialOfMin = perspective.methodInfo.report.iterations[int.Parse(param[0]) + 1]; var point = new ZedGraph.TextItem(string.Format("{0}({1}; {2})", trialOfMin.i - 2, trialOfMin.x, trialOfMin.y), (float)trialOfMin.x, (float)pane.YAxis.Max); point.FontSpec.FontColor = perspective.colorLine; point.FontSpec.Border.Color = perspective.colorPoint; point.FontSpec.Fill.Color = perspective.colorBack; //point.FontSpec.Angle = 2; pane.GraphItemList.Add(point); zedGraphControlMain.Invalidate(); } }
private void zedGraphControlMain_MouseMove(object sender, MouseEventArgs e) { if (pressed) { var pane = zedGraphControlMain.GraphPane; Point eventPoint = new Point(e.X, e.Y); labelMousePosition.Text = string.Format("({0}; {1})", eventPoint.X, eventPoint.Y); double graphX, graphY, Y; pane.ReverseTransform(new PointF(e.X, e.Y), out graphX, out graphY, out Y); labelMousePosition.Text += string.Format("({0:F3}; {1:F3})", graphX, graphY); var newPoint = new PointF((float)graphX, (float)graphY); PointF controlPoint = pane.GeneralTransform(newPoint, ZedGraph.CoordType.AxisXYScale); labelMousePosition.Text += string.Format("({0}; {1})", controlPoint.X, controlPoint.Y); moveScales(oldPointGraph, newPoint); zedGraphControlMain.Refresh(); oldPointGraph = newPoint; } else if (perspective.withLine) { var pane = zedGraphControlMain.GraphPane; Point eventPoint = new Point(e.X, e.Y); double x, y, z; pane.ReverseTransform(new PointF(e.X, e.Y), out x, out y, out z); var xList = new List <Method.Trial>(perspective.methodInfo.report.iterations); xList.Sort(delegate(Method.Trial left, Method.Trial right) { return(left.x.CompareTo(right.x)); }); var eX = xList.GetEnumerator(); eX.MoveNext(); var rXMin = eX.Current; for (; eX.MoveNext();) { if (Math.Abs(eX.Current.x - x) > Math.Abs(rXMin.x - x)) { break; } rXMin = eX.Current; } if (perspective.withCurLine) { pane.CurveList.Remove(pane.CurveList.Count - 1); } perspective.curLineX = rXMin.x; var gp = new GraphProcessing(); gp.drawVerticalLine(perspective, false); perspective.withCurLine = true; zedGraphControlMain.AxisChange(); if (!perspective.withMainLine) { if (pane.GraphItemList.Count != 0) { pane.GraphItemList.RemoveAt(0); } var point = new ZedGraph.TextItem(string.Format("{0}({1}; {2})", rXMin.i - 2, rXMin.x, rXMin.y), (float)rXMin.x, (float)pane.YAxis.Max); point.FontSpec.FontColor = perspective.colorLine; point.FontSpec.Border.Color = perspective.colorPoint; point.FontSpec.Fill.Color = perspective.colorBack; //point.FontSpec.Angle = 2; pane.GraphItemList.Add(point); } zedGraphControlMain.Invalidate(); } }