Exemple #1
0
        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();
            }
        }
Exemple #2
0
        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();
            }
        }
Exemple #3
0
        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();
            }
        }
Exemple #4
0
        private void runMethod_DoWork(object sender, DoWorkEventArgs e)
        {
            Func <double, double> func = x => Double.Parse(textBoxA.Text) * Math.Cos(Double.Parse(textBoxB.Text) * x)
                                         + Double.Parse(textBoxC.Text) * Math.Sin(Double.Parse(textBoxD.Text) * x);
            Method method = null;

            runMethod.ReportProgress((int)status + 10);

            var xLeft    = Double.Parse(textBoxXBegin.Text);
            var xRight   = Double.Parse(textBoxXEnd.Text);
            var maxSteps = int.Parse(textBoxMaxStepCount.Text);
            var _e       = Double.Parse(textBoxE.Text);

            if (perspective == bruteForce)
            {
                method = new Brute(func, xLeft, xRight, maxSteps, _e);
            }
            else
            {
                var r = Double.Parse(textBoxR.Text);
                if (perspective == piacovsky)
                {
                    method = new Piavsky(func, xLeft, xRight, maxSteps, _e, r);
                }
                if (perspective == strongin)
                {
                    method = new Strongin(func, xLeft, xRight, maxSteps, _e, r);
                }
            }
            runMethod.ReportProgress((int)status + 10);

            var report = method.solve(runMethod);

            status = 60;

            FElem elem = new FElem();

            elem.function = func;
            elem.xLeft    = xLeft;
            elem.xRight   = xRight;

            if (!runMethod.CancellationPending)
            {
                GraphProcessing gp = new GraphProcessing();
                perspective.methodInfo.graphControl.GraphPane.CurveList.Clear();
                gp.drawFunction(perspective.methodInfo.graphControl, ref elem, perspective.colorLine, runMethod);
                perspective.funcInfo = elem;

                perspective.curZoomBorder = new curZoom()
                {
                    xMin = perspective.funcInfo.xMin,
                    xMax = perspective.funcInfo.xMax,
                    yMin = perspective.funcInfo.yMin,
                    yMax = perspective.funcInfo.yMax
                };

                perspective.methodInfo.report = report;
                perspective.a            = Double.Parse(textBoxA.Text);
                perspective.b            = Double.Parse(textBoxB.Text);
                perspective.c            = Double.Parse(textBoxC.Text);
                perspective.d            = Double.Parse(textBoxD.Text);
                perspective.xLeft        = xLeft;
                perspective.xRight       = xRight;
                perspective.maxStepCount = maxSteps;
                perspective.e            = _e;
                if (perspective.withR)
                {
                    perspective.r = Double.Parse(textBoxR.Text);
                }
            }
        }
Exemple #5
0
        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();
            }
        }