Esempio n. 1
0
        private void button5_Click(object sender, EventArgs e)
        {
            double Ie, Ic, Rc, Re, Rb, Vcc, Vce, Vbe, Imax, Vee, vc, vmax;

            Rc   = Convert.ToDouble(txtemiterpolarmarc.Text) * 1000;
            Rb   = Convert.ToDouble(txtemiterpolarmarb.Text) * 1000;
            Re   = Convert.ToDouble(txtemiterpolarmare.Text) * 1000;
            Vcc  = Convert.ToDouble(txtemiterpolarmavcc.Text);
            Imax = (1000 * Vcc) / Rc;
            Vee  = Convert.ToDouble(txtemiterpolarmavee.Text);

            Vbe  = Convert.ToDouble(txtemiterpolarmavbe.Text);
            Ie   = -1000 * (Vee + Vbe) / Re;
            vc   = Vcc - (Math.Pow(10, -3) * Ie * Rc);
            Vce  = vc + Vbe;
            Imax = 1000 * (Vcc - Vee) / (Rc + Re);
            vmax = Vcc - Vee;
            ZedGraph.ZedGraphControl g = new ZedGraph.ZedGraphControl();
            g.Size = new Size(panel3.Width - 2, panel3.Height - 2);
            ZedGraph.GraphPane myGraphPane = g.GraphPane;
            myGraphPane.Title.Text       = "Dc yük eğrisi ";
            myGraphPane.XAxis.Title.Text = "Volt (V)";
            myGraphPane.YAxis.Title.Text = "Akım(ma)";
            PointPairList list1 = new PointPairList();

            myGraphPane.AddCurve("", new double[] { 0, vmax }, new double[] { Imax, 0 }, Color.Blue, ZedGraph.SymbolType.None);
            myGraphPane.AddCurve("", new double[] { 0, Vce }, new double[] { Ie, Ie }, Color.Blue, ZedGraph.SymbolType.None);
            myGraphPane.AddCurve("", new double[] { Vce, Vce }, new double[] { Ie, 0 }, Color.Blue, ZedGraph.SymbolType.None);

            myGraphPane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.Red, 3.0f);

            g.AxisChange();

            panel3.Controls.Add(g);
        }
Esempio n. 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // set your pane
            myPane = zedGraphControl1.GraphPane;

            // set a title
            myPane.Title.Text = "This is an example!";

            // set X and Y axis titles
            myPane.XAxis.Title.Text = "X Axis";
            myPane.YAxis.Title.Text = "Y Axis";

            // ---- CURVE ONE ----
            // draw a sin curve
            for (int i = 0; i < 100; i++)
            {
                listPointsOne.Add(i, Math.Sin(i));
            }

            // set lineitem to list of points
            myCurveOne = myPane.AddCurve(null, listPointsOne, Color.Black, SymbolType.Circle);
            // ---------------------

            // ---- CURVE TWO ----
            listPointsTwo.Add(10, 50);
            listPointsTwo.Add(50, 50);

            // set lineitem to list of points
            myCurveTwo = myPane.AddCurve(null, listPointsTwo, Color.Blue, SymbolType.None);
            myCurveTwo.Line.Width = 5;
            // ---------------------

            // delegate to draw
            zedGraphControl1.AxisChange();
        }
Esempio n. 3
0
        // ------------------  CHARTING ROUTINES ---------------------

        /// <summary> Sets up the chart. </summary>
        public void SetupChart()
        {
            MasterPane masterPane = chartControl.MasterPane;
            masterPane.PaneList.Clear();

            // get a reference to the GraphPane

            _temperaturePane = new GraphPane(new Rectangle(5, 5, 890, 350),
                "Temperature controller",
                "Time (s)",
                "Temperature (C)");
            masterPane.Add(_temperaturePane);

            // Create data arrays for rolling points
            _analog1List = new RollingPointPairList(3000);
            _analog3List = new RollingPointPairList(3000);
            _analog1List.Clear();
            _analog3List.Clear();

            // Create a smoothened red curve for the current temperature
            LineItem myCurve1 = _temperaturePane.AddCurve("Current temperature", _analog1List, Color.Red, SymbolType.None);
            myCurve1.Line.Width = 2;
            myCurve1.Line.IsSmooth = true;
            myCurve1.Line.SmoothTension = 0.2f;


            // Create a smoothened blue curve for the goal temperature
            LineItem myCurve3 = _temperaturePane.AddCurve("Goal temperature", _analog3List, Color.Blue, SymbolType.None);
            myCurve3.Line.Width = 2;
            myCurve3.Line.IsSmooth = true;
            myCurve3.Line.SmoothTension = 0.2f;
            // Tell ZedGraph to re-calculate the axes since the data have changed
            chartControl.AxisChange();

            _heaterPane = new GraphPane(new Rectangle(5, 360, 890, 250),
                null,
                null,
                null);
            masterPane.Add(_heaterPane);
            
            _heaterList = new RollingPointPairList(3000);
            _heaterPwmList = new RollingPointPairList(3000);
            _heaterList.Clear();
            _heaterPwmList.Clear();

            // Create a red curve for the heater value
            LineItem heaterCurve = _heaterPane.AddCurve(null, _heaterList, Color.YellowGreen, SymbolType.None);
            heaterCurve.Line.Width = 2;
            heaterCurve.Line.IsSmooth = false;

            // Create a red curve for the current heater pwm value
            LineItem heaterPwmCurve = _heaterPane.AddCurve(null, _heaterPwmList, Color.Blue, SymbolType.None);
            heaterPwmCurve.Line.Width = 2;
            heaterPwmCurve.Line.IsSmooth = false;

            SetChartScale(0);
        }
Esempio n. 4
0
        public PressPlot()
        {
            InitializeComponent();
            PressPane = zedGraphControl1.GraphPane;
            PressPane.Title.IsVisible = false;
            PressPane.XAxis.Title.Text = "time (sec)";
            PressPane.YAxis.Title.Text = "pressure (Pa)";
            PressPane.Y2Axis.IsVisible = true;
            PressPane.Y2Axis.Title.Text = "temperature (degC)";

            // Save 1200 points.  At 50 ms sample rate, this is one minute
            // The RollingPointPairList is an efficient storage class that always
            // keeps a rolling set of point data without needing to shift any data values
            RollingPointPairList xlist = new RollingPointPairList(20000);
            RollingPointPairList ylist = new RollingPointPairList(20000);

            // Initially, a curve is added with no data points (list is empty)
            // Color is blue, and there will be no symbols
            LineItem curve1 = PressPane.AddCurve("pressure", xlist, Color.Blue, SymbolType.None);
            LineItem curve2 = PressPane.AddCurve("temparature", ylist, Color.Red, SymbolType.None);
            curve2.IsY2Axis = true;

            // Sample at 50ms intervals
            timer1.Interval = 250;
            timer1.Enabled = true;
            timer1.Start();

            // Just manually control the X axis range so it scrolls continuously
            // instead of discrete step-sized jumps
            PressPane.XAxis.Scale.Min = 0;
            PressPane.XAxis.Scale.Max = (double)numericUpDown1.Value;
            PressPane.XAxis.Scale.MinorStep = 1;
            PressPane.XAxis.Scale.MajorStep = 5;
            PressPane.YAxis.Scale.Max = 110000;
            PressPane.YAxis.Scale.Min = 110000 / 5;
            PressPane.YAxis.MajorTic.IsOpposite = false;
            PressPane.YAxis.MinorTic.IsOpposite = false;
            PressPane.Y2Axis.MajorTic.IsOpposite = false;
            PressPane.Y2Axis.MinorTic.IsOpposite = false;
            PressPane.Y2Axis.MajorGrid.IsZeroLine = false;
            PressPane.Y2Axis.Scale.MajorStep = 20;
            PressPane.Y2Axis.Scale.MinorStep = 5;
            PressPane.Y2Axis.Scale.Max = 80;
            PressPane.Y2Axis.Scale.Min = -20;

            // Scale the axes
            zedGraphControl1.AxisChange();

            // Save the beginning time for reference
            tickStart = Environment.TickCount;
        }
Esempio n. 5
0
		void EveryNumCycleLoad(object sender, EventArgs e)
		{
			MasterPane myMaster = zedGraphControl1 .MasterPane ;			
			myMaster.PaneList.Clear();
			myMaster.Title.Text = "MasterPane Test";
			myMaster.Title.IsVisible = true;
			myMaster.Fill = new Fill( Color.White, Color.MediumSlateBlue, 45.0F );
			int[][] everyRes = DataProcess .AllSingleCycle (MainForm .arr ) ;
			for ( int j=0; j< 10; j++ )
			{
				GraphPane myPane = new GraphPane();
				myPane.Title.Text = "My Test Graph #" + (j+1).ToString();
				myPane.XAxis.Title.Text = "X Axis";
				myPane.YAxis.Title.Text = "Y Axis";
				//myPane.Fill = new Fill( Color.White, Color.LightYellow, 45.0F );
				//myPane.BaseDimension = 6.0F;
				PointPairList list = new PointPairList();
				for ( int i=0; i < everyRes [j ].Length ; i++ )
				{
					int x = i ;
					int y = everyRes [j ][i ] ;
					list.Add( x, y );
				}
				LineItem myCurve = myPane.AddCurve( "label" + j.ToString(),list, Color.Red, SymbolType.Diamond );
				myMaster.Add( myPane );
			}
			using ( Graphics g = this.CreateGraphics() )
			{
				 myMaster .SetLayout( g, PaneLayout.SquareColPreferred );
			}
		}
Esempio n. 6
0
        public void AddCurve(GraphPane pane, string name, Color color, int capacity = 8192)
        {
            _dataPointList = new RollingPointPairList(capacity);

            // Добавим кривую пока еще без каких-либо точек
            pane.AddCurve(name, _dataPointList, color, SymbolType.None);
        }
Esempio n. 7
0
        private void zedGraphControl1_Load(object sender, System.EventArgs e)
        {
            zedGraphControl1.GraphPane.Title = "Test Case for C#";

            /*		double[] x = new double[100];
             *              double[] y = new double[100];
             *              int	i;
             *              for ( i=0; i<100; i++ )
             *              {
             *                      x[i] = (double) i / 100.0 * Math.PI * 2.0;
             *                      y[i] = Math.Sin( x[i] );
             *              }
             *              zedGraphControl1.GraphPane.AddCurve( "Sine Wave", x, y, Color.Red, SymbolType.Square );
             *              zedGraphControl1.GraphPane.AxisChange();
             */
            // Create a new graph with topLeft at (40,40) and size 600x400
            myPane = new GraphPane(new Rectangle(40, 40, 600, 400),
                                   "My Test Graph\n(For CodeProject Sample)",
                                   "My X Axis",
                                   "My Y Axis");
            myPane.Title = "asd";

            // Make up some random data points
            double[] x = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y = { 20, 10, 50, 40, 35, 60, 90, 25, 48, 75 };
            // Generate a red curve with diamond
            // symbols, and "My Curve" in the legend
            CurveItem myCurve = myPane.AddCurve("My Curve",
                                                x, y, Color.Red, SymbolType.Diamond);

            // Tell ZedGraph to refigure the
            // axes since the data have changed
            myPane.AxisChange();
        }
Esempio n. 8
0
        public void AddCurve(GraphPane pane, string name, string measure, Color color, SymbolType sType, int capacity)
        {
            _dataPointList = new RollingPointPairList(capacity);

            // Добавим кривую пока еще без каких-либо точек
            _myCurve = pane.AddCurve(string.Format("{0} ({1})",name,measure), _dataPointList, color, sType);
        }
Esempio n. 9
0
        //初始化曲线控件上的曲线数量及名称
        private void InitCurve(ZedGraph.ZedGraphControl zgControl, string curveName, string path, string lineColor)
        {
            if (curveName != null)
            {
                //_RPPList_Read = new RollingPointPairList(100000);

                _ResultPanel = zgControl.GraphPane;
                zgControl.GraphPane.CurveList.RemoveRange(0, zgControl.GraphPane.CurveList.Count);

                if (_List_Data != null)
                {
                    _List_Data = null;
                }

                //foreach (CurveItem ci in zgControl.GraphPane.CurveList)
                //{
                //    ci.Clear();
                //}

                LineItem CurveList = _ResultPanel.AddCurve(curveName, _RPPList_Read, Color.FromName(lineColor), SymbolType.None);//Y1-X1
                CurveList.Line.IsAntiAlias = true;
                readCurveName(curveName, path);
            }

            //MessageBox.Show(zgControl.GraphPane.CurveList.Count.ToString());
            //初始化曲线名称即 试样编号的名称
            zgControl.AxisChange();
            zgControl.RestoreScale(this._ResultPanel);
        }
Esempio n. 10
0
        public Form1()
        {
            InitializeComponent();
            myPane = myPlot.GraphPane;

            int status = myDevice.connect();
            if (status == 0)
            {
                MessageBox.Show("Device couldn't be found!");
                Environment.Exit(0);
            }

            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = plotWidth;
            myPane.YAxis.Scale.Min = 0;
            myPane.YAxis.Scale.Max = 5;

            myDevice.pinMode(2, 1);

            myLine = myPane.AddCurve("Analog Voltage", myPoints, Color.Blue, SymbolType.None);
            myDevice.initPwm();

            myLine.Line.Width = 1;

            myPlot.Invalidate();
            myPlot.AxisChange();

            myTimer.Start();
        }
Esempio n. 11
0
        private void DrawGraph()
        {
            // Получим панель для рисования
            ZedGraph.GraphPane pane = ZedGraphz.GraphPane;

            // Очистим список кривых на тот случай, если до этого сигналы уже были нарисованы
            pane.CurveList.Clear();

            // Создадим список точек
            PointPairList list = new PointPairList();
            double        xmin = -50;
            double        xmax = 50;

            // Заполняем список точек
            for (double x = xmin; x <= xmax; x += 0.01)
            {
                // добавим в список точку
                list.Add(x, f(x));
            }

            // Создадим кривую с названием "Sinc",
            // которая будет рисоваться голубым цветом (Color.Blue),
            // Опорные точки выделяться не будут (SymbolType.None)
            LineItem myCurve = pane.AddCurve("Sinc", list, Color.Blue, SymbolType.None);

            // Вызываем метод AxisChange (), чтобы обновить данные об осях.
            // В противном случае на рисунке будет показана только часть графика,
            // которая умещается в интервалы по осям, установленные по умолчанию
            ZedGraphz.AxisChange();

            // Обновляем график
            ZedGraphz.Invalidate();
        }
Esempio n. 12
0
        private void btnSolvingType2Mass_Click(object sender, EventArgs e)
        {
            this.btnUpdate_Click(null, null);
            this.listBox1.Items.Clear();
            ZedGraph.GraphPane gp = this.zgSolve1.GraphPane;
            gp.CurveList.Clear();
            this.curves.Clear();
            string fname = listFunctions2.SelectedItem.ToString();

            int randonCount = int.Parse(this.txtRandomCount.Text);

            string[,] curveNames = new string[randonCount, randonCount];
            for (int i = 0; i < randonCount; i++)
            {
                for (int j = 0; j < randonCount; j++)
                {
                    string curveName = string.Format("Line-{0}_{1}", i, j);
                    this.curves.Add(curveName, new PointPairList());
                    Color c = Color.DarkBlue;//Color.FromArgb(255, r.Next(255), r.Next(255), r.Next(255));
                    gp.AddCurve(curveName, this.curves[curveName], c, SymbolType.None);
                    curveNames[i, j] = curveName;
                }
            }
            this.view.ViewActionCall(ViewEventType.SolovePodhod2Type2Mass, fname, curveNames);
        }
Esempio n. 13
0
        private void btnGo1_Click(object sender, EventArgs e)
        {
            this.btnUpdate_Click(null, null);
            this.view.ConfigGraphPane(this.zgc1, this, PaneLayout.SingleRow, new List <Core.ChartInfo>()
            {
                new Core.ChartInfo()
                {
                    Title = "Depends t with z", XAxisTitle = "t", YAxisTitle = "z"
                }
            });
            ZedGraph.GraphPane gp = this.zgc1.MasterPane[0];
            gp.CurveList.Clear();

            string fname = listFunctions1.SelectedItem.ToString();
            int    randn = int.Parse(txtRandomCount.Text);

            this.curves.Clear();
            Random r = new Random();

            for (int i = 0; i < randn; i++)
            {
                string curveName = string.Format("curve{0}", i);
                this.curves.Add(curveName, new PointPairList());
                Color c = Color.Black;//Color.FromArgb(255, r.Next(255), r.Next(255), r.Next(255));
                gp.AddCurve(curveName, this.curves[curveName], c, SymbolType.None);
                this.view.ViewActionCall(ViewEventType.StartSolving1, fname, curveName);
            }
        }
Esempio n. 14
0
 private void drawGraph()
 {
     Dictionary<double, double> coordinats = new Dictionary<double, double>();
     for (double x = xMin; x <= xMax; x += top)
     {
         if (x!=0)
         coordinats.Add(x, a/x);
     }
     GraphPane myPane = new GraphPane();
     zedGraphControl1.GraphPane = myPane;
     myPane.XAxis.Title.Text = "Координата X";
     myPane.YAxis.Title.Text = "Координата Y";
       //  myPane.Fill = new Fill(Color.White, Color.LightSkyBlue, 45.0f);
     myPane.Chart.Fill.Type = FillType.None;
     myPane.Legend.Position = LegendPos.Float;
     myPane.Legend.IsHStack = false;
     if (comboBox1.GetItemText(comboBox1.SelectedIndex) == "1")
     {
         myPane.AddBar("", coordinats.Keys.ToArray(), coordinats.Values.ToArray(), penColor);
     }
     else
     {
         LineItem myCurve = myPane.AddCurve("", coordinats.Keys.ToArray(), coordinats.Values.ToArray(), penColor, SymbolType.None);
         myCurve.Line.Width = penWeight;
         myCurve.Symbol.Fill = new Fill(Color.White);
     }
     zedGraphControl1.AxisChange();
     zedGraphControl1.Refresh();
     zedGraphControl1.Visible = true;
 }
Esempio n. 15
0
        private void Graph_Load(object sender, EventArgs e)
        {
            gp = zdGraph.GraphPane;
            gp.YAxis.IsShowGrid         = true;
            gp.YAxis.Title              = "Voltage";
            gp.YAxis.ScaleFontSpec.Size = 8;
            gp.YAxis.TitleFontSpec.Size = 8;
            gp.YAxis.Min = 0;
            gp.YAxis.Max = 4096;

            gp.XAxis.IsShowGrid         = true;
            gp.XAxis.Max                = data.Length;
            gp.XAxis.Min                = 0;
            gp.XAxis.Title              = "Time";
            gp.XAxis.ScaleFontSpec.Size = 8;
            gp.XAxis.TitleFontSpec.Size = 8;

            zdGraph.IsShowPointValues = true;
            gp.Title = "Voltage Curve";
            zdGraph.AxisChange();

            gp.AddCurve("Data", x, data, Color.Blue, SymbolType.None);

            zdGraph.AxisChange();
            zdGraph.Refresh();
        }
Esempio n. 16
0
        /// <summary>
        ///
        /// </summary>
        public void Draw(ZedGraph.GraphPane pane, object dataSource)
        {
            if (this.GraphPaneConfig == null)
            {
                return;
            }

            if (this.DataSource == null)
            {
                return;
            }

            this.GraphPaneConfig.ConfigGraphPane(pane);
            foreach (CurveConfigBase cfg in this.GraphPaneConfig.CurveConfigBaseCollection)
            {
                CurveDataCollection cds = cfg.Create(dataSource);
                foreach (CurveData cd in cds)
                {
                    switch (this.GraphPaneConfig.CurItemType)
                    {
                    case CurveItemType.Line:
                        if (this.GraphPaneConfig.XAxisType == ZedGraph.AxisType.Date)
                        {
                            ZedGraph.LineItem curve = pane.AddCurve(cd.Name, cd.PointList, cd.Color);
                            curve.Symbol.Fill = new ZedGraph.Fill(Color.White);
                        }
                        else if (this.GraphPaneConfig.XAxisType == ZedGraph.AxisType.Text)
                        {
                            LineItem curve = pane.AddCurve(cd.Name, null, cd.YValues, cd.Color);
                            pane.XAxis.Scale.TextLabels = cd.XAxisLabels;
                            curve.Symbol.Fill           = new Fill(Color.White);
                        }
                        break;

                    case CurveItemType.Bar:
                        pane.AddBar(cd.Name, null, cd.YValues, cd.Color);
                        pane.XAxis.Scale.TextLabels = cd.XAxisLabels;
                        break;

                    case CurveItemType.Pie:
                        pane.AddPieSlices(cd.YValues, cd.XAxisLabels);
                        break;
                    }
                }
            }
        }
Esempio n. 17
0
		public GraphPane CreateLineGraph(int nSeries, string title, string xAxisTitle, string yAxisTitle, bool xAxisTitleVisible, bool yAxisTitleVisible, bool xScaleVisible, bool yScaleVisible, bool xMajorGridVisible, bool xIsBetweenLabels, bool yMajorGridVisible, bool yIsBetweenLabels)
		{
			GraphPane graphPane = new GraphPane();
			SetupGraphPane(graphPane, title, xAxisTitle, yAxisTitle, xAxisTitleVisible, yAxisTitleVisible, xScaleVisible, yScaleVisible, xMajorGridVisible, xIsBetweenLabels, yMajorGridVisible, yIsBetweenLabels);
			PointPairList points = new PointPairList();
			graphPane.AddCurve("", points, Color.Yellow, SymbolType.None);
			return graphPane;
		}
Esempio n. 18
0
        private void btnGo2_Click(object sender, EventArgs e)
        {
            this.btnUpdate_Click(null, null);

            List <Core.ChartInfo> chInfo = new List <Core.ChartInfo>();

            chInfo.Add(new Core.ChartInfo()
            {
                Title = "Depends (t,z1)", XAxisTitle = "t", YAxisTitle = "z1"
            });
            chInfo.Add(new Core.ChartInfo()
            {
                Title = "Depends (t,z1)", XAxisTitle = "t", YAxisTitle = "z2"
            });
            chInfo.Add(new Core.ChartInfo()
            {
                Title = "Depends (z1,z2)", XAxisTitle = "z1", YAxisTitle = "z2"
            });

            this.view.ConfigGraphPane(this.zgc1, this, PaneLayout.ExplicitCol21, chInfo);

            ZedGraph.GraphPane gp  = this.zgc1.MasterPane[0];
            ZedGraph.GraphPane gp1 = this.zgc1.MasterPane[1];
            ZedGraph.GraphPane gp2 = this.zgc1.MasterPane[2];
            gp.CurveList.Clear();
            gp1.CurveList.Clear();
            gp2.CurveList.Clear();

            string fname = listFunctions2.SelectedItem.ToString();
            int    randn = int.Parse(txtRandomCount.Text);

            this.curves.Clear();
            this.curves1.Clear();
            this.curves2.Clear();
            Random r = new Random();

            for (int i = 0; i < randn; i++)
            {
                string curveName = string.Format("curve{0}", i);

                this.curves.Add(curveName, new PointPairList());
                this.curves1.Add(curveName, new PointPairList());
                this.curves2.Add(curveName, new PointPairList());

                Color c = Color.Black;//Color.FromArgb(255, r.Next(255), r.Next(255), r.Next(255));

                gp.AddCurve(curveName, this.curves[curveName], c, SymbolType.None);
                gp1.AddCurve(curveName, this.curves1[curveName], c, SymbolType.None);
                gp2.AddCurve(curveName, this.curves2[curveName], c, SymbolType.None);

                this.view.ViewActionCall(ViewEventType.StartSolving2, fname, curveName);
            }


            //this.tabControl.SelectedIndex = 0;
        }
Esempio n. 19
0
        //private static void zedGraphControl1_MouseMove(object sender, MouseEventArgs e)//鼠标移动出现虚线
        //{
        //    using (Graphics gc = MainForm.getInstance().DTSReal.CreateGraphics())
        //    using (Pen pen = new Pen(Color.Gray))
        //    {
        //        pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
        //        RectangleF rect = MainForm.getInstance().DTSReal.GraphPane.Chart.Rect;
        //        //确保在画图区域
        //        if (rect.Contains(e.Location))
        //        {
        //            MainForm.getInstance().DTSReal.Refresh();
        //            gc.DrawLine(pen, e.X, rect.Top, e.X, rect.Bottom);
        //            gc.DrawLine(pen, rect.Left, e.Y, rect.Right, e.Y);
        //        }
        //    }
        //}

        public static void drawRealDTS(List <DataTable> dt)
        {
            float wellzero = ZedGraphClass.getWellZero();

            ZedGraph.GraphPane gp = MainForm.getInstance().DTSReal.GraphPane;
            MainForm.getInstance().DTSReal.PointValueEvent += new ZedGraphControl.PointValueHandler(ZedGraphClass.MyPointValueHandlerTime);//设置节点信息显示样式
            //MainForm.getInstance().DTSReal.IsShowHScrollBar = true;//横向滚动条
            // MainForm.getInstance().DTSReal.MouseMove += zedGraphControl1_MouseMove;//鼠标在图上移动出现x虚线
            MainForm.getInstance().DTSReal.IsShowPointValues = true;    //
            MainForm.getInstance().DTSReal.IsZoomOnMouseCenter = false; //使用滚轮时以鼠标所在点进行缩放还是以图形中心进行缩放。
            gp.GraphObjList.Clear();
            gp.CurveList.Clear();
            //int Linenumber = Convert.ToInt32(MainForm.getInstance().DTSLineNumber.Text);
            //int k = 0;
            //if (dt.Count - Linenumber < 0)
            //{

            //}
            //else
            //{
            //    k = dt.Count - Linenumber;
            //}
            for (int i = 1; i < dt.Count; i++)//从第一条线开始,并且两条线
            {
                DataTable table = dt[i];

                string        Linename = table.Rows[0][0].ToString();
                PointPairList list1    = new PointPairList();
                for (int j = 0; j < table.Rows.Count; j++)
                {
                    double x;
                    float  y;
                    //X轴减去部分井口数据。
                    x = float.Parse(table.Rows[j][1].ToString()) - wellzero;
                    y = float.Parse(table.Rows[j][2].ToString());
                    list1.Add(x, y);
                }
                if (list1.Count == 0)//如果曲线没有数据
                {
                    continue;
                }
                else
                {
                    Color    co         = ZedGraphClass.GetColor(i);
                    LineItem _lineitem2 = gp.AddCurve(Linename, list1, ZedGraphClass.GetColor(i), SymbolType.Circle);
                    _lineitem2.Line.Width = 2.0F;          //线的宽度
                    string la = _lineitem2.Label.Text.ToString();
                    _lineitem2.Symbol.Size = 2.4F;         //线上节点的大小
                    _lineitem2.Symbol.Fill = new Fill(co); //线上节点的颜色
                    //gp.AxisChange();//若是
                }
            }
            gp.AxisChange();//若是放到上面的那一行,因为数据太多,会有延迟,导致图形颜色不断变化(一条线一条线的画)
            MainForm.getInstance().DTSReal.Refresh();
        }
Esempio n. 20
0
        void grafigim(double Vcc, double Ic, double Imax, double Vce)
        {
            ZedGraph.ZedGraphControl g = new ZedGraph.ZedGraphControl();
            g.Size = new Size(panel1.Width - 2, panel1.Height - 2);
            ZedGraph.GraphPane myGraphPane = g.GraphPane;
            myGraphPane.Title.Text       = "Dc yük eğrisi ";
            myGraphPane.XAxis.Title.Text = "Volt (V)";
            myGraphPane.YAxis.Title.Text = "Akım(ma)";
            PointPairList list1 = new PointPairList();

            myGraphPane.AddCurve("", new double[] { 0, Vcc }, new double[] { Imax, 0 }, Color.Blue, ZedGraph.SymbolType.None);
            myGraphPane.AddCurve("", new double[] { 0, Vce }, new double[] { Ic, Ic }, Color.Blue, ZedGraph.SymbolType.None);
            myGraphPane.AddCurve("", new double[] { Vce, Vce }, new double[] { Ic, 0 }, Color.Blue, ZedGraph.SymbolType.None);

            myGraphPane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.Red, 3.0f);

            g.AxisChange();

            panel1.Controls.Add(g);
        }
Esempio n. 21
0
        public AccPlot()
        {
            InitializeComponent();
            gyroPane = zedGraphControl1.GraphPane;
            gyroPane.Title.IsVisible = false;
            gyroPane.XAxis.Title.Text = "time (sec)";
            gyroPane.YAxis.Title.Text = "acceleration (g)";

            // Save 1200 points.  At 50 ms sample rate, this is one minute
            // The RollingPointPairList is an efficient storage class that always
            // keeps a rolling set of point data without needing to shift any data values
            RollingPointPairList xlist = new RollingPointPairList(2000);
            RollingPointPairList ylist = new RollingPointPairList(2000);
            RollingPointPairList zlist = new RollingPointPairList(2000);

            // Initially, a curve is added with no data points (list is empty)
            // Color is blue, and there will be no symbols
            LineItem curve = gyroPane.AddCurve("x axis", xlist, Color.Blue, SymbolType.None);
            curve = gyroPane.AddCurve("y axis", ylist, Color.Red, SymbolType.None);
            curve = gyroPane.AddCurve("z axis", zlist, Color.Green, SymbolType.None);

            // Sample at 50ms intervals
            timer1.Interval = 10;
            timer1.Enabled = true;
            timer1.Start();

            // Just manually control the X axis range so it scrolls continuously
            // instead of discrete step-sized jumps
            gyroPane.XAxis.Scale.Min = 0;
            gyroPane.XAxis.Scale.Max = (double)numericUpDown1.Value;
            gyroPane.XAxis.Scale.MinorStep = 0.5;
            gyroPane.XAxis.Scale.MajorStep = 1;
            gyroPane.YAxis.Scale.Max = A_Page.fullScale_acc / 4;
            gyroPane.YAxis.Scale.Min = -A_Page.fullScale_acc / 4;

            // Scale the axes
            zedGraphControl1.AxisChange();

            // Save the beginning time for reference
            tickStart = Environment.TickCount;
        }
Esempio n. 22
0
		public GraphPane CreateLineGraph(int nSeries, string title, string xAxisTitle, string yAxisTitle, bool xAxisTitleVisible, bool yAxisTitleVisible, bool xScaleVisible, bool yScaleVisible, bool xMajorGridVisible, bool xIsBetweenLabels, bool yMajorGridVisible, bool yIsBetweenLabels)
		{
			GraphPane graphPane = new GraphPane();
			SetupGraphPane(graphPane, title, xAxisTitle, yAxisTitle, xAxisTitleVisible, yAxisTitleVisible, xScaleVisible, yScaleVisible, xMajorGridVisible, xIsBetweenLabels, yMajorGridVisible, yIsBetweenLabels);
			RollingPointPairList[] listArray = new RollingPointPairList[nSeries];
			for (int i = 0; i < listArray.Length; i++)
			{
				listArray[i] = new RollingPointPairList(0x4b0);
				graphPane.AddCurve("", listArray[i], graphDataColors[i], SymbolType.None);
			}
			return graphPane;
		}
Esempio n. 23
0
        private void button3_Click(object sender, EventArgs e)
        {
            double Ib, Ic, Rc, Rb, Vcc, Vce, Vbe, Imax, beta;

            Rc = Convert.ToDouble(txtbeyzrc.Text) * 1000;
            Rb = Convert.ToDouble(txtbeyzrb.Text) * 1000;

            Vcc  = Convert.ToDouble(txtbeyzvcc.Text);
            Imax = (1000 * Vcc) / Rc;
            beta = Convert.ToDouble(txtbeyzbeta.Text);

            Vbe = Convert.ToDouble(txtbeyzvbe.Text);
            Ib  = ((Vcc - Vbe) / Rb) * Math.Pow(10, 6);
            Ic  = beta * Ib * Math.Pow(10, -3);

            Vce              = Vcc - Ic * Rc * Math.Pow(10, -3);
            lblbeyzib.Text   = " = " + Ib.ToString();
            lblbeyzıc.Text   = " = " + Ic.ToString();
            lblbeyzımax.Text = " = " + Imax.ToString();
            lblbeyzvce.Text  = " = " + Vce.ToString();
            ZedGraph.ZedGraphControl g = new ZedGraph.ZedGraphControl();
            g.Size = new Size(panel2.Width - 2, panel2.Height - 2);
            ZedGraph.GraphPane myGraphPane = g.GraphPane;
            myGraphPane.Title.Text       = "Dc yük eğrisi ";
            myGraphPane.XAxis.Title.Text = "Volt (V)";
            myGraphPane.YAxis.Title.Text = "Akım(ma)";
            PointPairList list1 = new PointPairList();

            myGraphPane.AddCurve("", new double[] { 0, Vcc }, new double[] { Imax, 0 }, Color.Blue, ZedGraph.SymbolType.None);
            myGraphPane.AddCurve("", new double[] { 0, Vce }, new double[] { Ic, Ic }, Color.Blue, ZedGraph.SymbolType.None);
            myGraphPane.AddCurve("", new double[] { Vce, Vce }, new double[] { Ic, 0 }, Color.Blue, ZedGraph.SymbolType.None);

            myGraphPane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.Red, 3.0f);

            g.AxisChange();

            panel2.Controls.Add(g);
        }
Esempio n. 24
0
        public GraphPane Draw(GraphPane pane, int id)
        {
            filterDataContext db = new filterDataContext();

            double t_max = (double)(from a in db.Datas where (a.ftype == type[id]) && (a.ftype == "gaussian") select a.p_time).Max();
            double t_min = (double)(from a in db.Datas where (a.ftype == type[id]) && (a.ftype == "gaussian") select a.p_time).Min();
            double p_max = (double)(from a in db.Datas where (a.ftype == type[id]) && (a.ftype == "gaussian") select a.psnr).Max();
            double p_min = (double)(from a in db.Datas where (a.ftype == type[id]) && (a.ftype == "gaussian") select a.psnr).Min();
            double w_max = (double)(from a in db.Datas where (a.ftype == type[id]) && (a.ftype == "gaussian") select a.p1).Max();
            double w_min = (double)(from a in db.Datas where (a.ftype == type[id]) && (a.ftype == "gaussian") select a.p1).Min();

            pane.Title.Text = "Анализ продолжительности вычислений";
            pane.CurveList.Clear();
            pane.YAxis.Scale.Min = p_min;
            pane.YAxis.Scale.Max = p_max;
            pane.YAxis.Title.Text = "PSNR";
            pane.XAxis.Title.Text = "Время обработки";
            pane.XAxis.Scale.Min = t_min;
            pane.XAxis.Scale.Max = t_max;
            pane.Y2Axis.Scale.Min = w_min;
            pane.Y2Axis.Scale.Max = w_max;
            pane.Y2Axis.Title.Text = "Размер окна фильтра";

            PointPairList List1 = new PointPairList(); 
            PointPairList List2 = new PointPairList();

            var query = from a in db.Datas where (a.ftype == type[id]) && (a.ftype == "gaussian") select a;
            foreach (var test in query)
            {
                List1.Add((double)test.p_time, (double)test.psnr);
                List2.Add((double)test.p_time, (double)test.p1);
            }
            LineItem Curve1 = pane.AddCurve("", List1, Color.Blue, SymbolType.None);

            LineItem Curve2 = pane.AddCurve("", List2, Color.Blue, SymbolType.None);

            return pane;
        }
Esempio n. 25
0
        private void button2_Click(object sender, EventArgs e)
        {
            double Ib, Ie, Ic, Rc, Rb, Re, Vcc, Vce, Imax, beta;

            Rc   = Convert.ToDouble(txtemiterdirencRC.Text) * 1000;
            Rb   = Convert.ToDouble(txtemiterdirencRB.Text) * 1000;
            Re   = Convert.ToDouble(txtemiterdirencRe.Text) * 1000;
            Vcc  = Convert.ToDouble(txtemiterdirencVcc.Text);
            Imax = Vcc / (Rc + Re);
            beta = Convert.ToDouble(txtemiterdirencBeta.Text);
            double Vbe;

            Vbe  = Convert.ToDouble(txtemiterdirencVbe.Text);
            Ib   = ((Vcc - Vbe) / (Rb + (beta + 1) * Re));
            Ic   = beta * Ib;
            Ie   = (beta + 1) * Ib;
            Vce  = Vcc - Ic * Rc - Ie * Re;
            Imax = 1000 * Imax;
            Ic   = 1000 * Ic;
            ZedGraph.ZedGraphControl g = new ZedGraph.ZedGraphControl();
            g.Size = new Size(panel1.Width - 2, panel1.Height - 2);
            ZedGraph.GraphPane myGraphPane = g.GraphPane;
            myGraphPane.Title.Text       = "Dc yük eğrisi ";
            myGraphPane.XAxis.Title.Text = "Volt (V)";
            myGraphPane.YAxis.Title.Text = "Akım(ma)";
            PointPairList list1 = new PointPairList();

            myGraphPane.AddCurve("", new double[] { 0, Vcc }, new double[] { Imax, 0 }, Color.Blue, ZedGraph.SymbolType.None);
            myGraphPane.AddCurve("", new double[] { 0, Vce }, new double[] { Ic, Ic }, Color.Blue, ZedGraph.SymbolType.None);
            myGraphPane.AddCurve("", new double[] { Vce, Vce }, new double[] { Ic, 0 }, Color.Blue, ZedGraph.SymbolType.None);

            myGraphPane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.Red, 3.0f);

            g.AxisChange();

            panel1.Controls.Add(g);
        }
Esempio n. 26
0
        public ZedGraphProxy(ZedGraphControl chart)
        {
            Chart = chart;

            master = chart.MasterPane;
            master.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0f);
            master.PaneList.Clear();

            master.Title.IsVisible = true;
            //master.Title.Text = "";

            master.Margin.All = 10;
            master.InnerPaneGap = 0;

            myPane = new GraphPane(new Rectangle(25, 25, chart.Width - 50, chart.Height - 50), "", "", "");

               // myPane.Title.Text = "";
            myPane.XAxis.Title.Text = "Time, s";
            myPane.Y2Axis.IsVisible = true;
            myPane.Fill.IsVisible = false;
            myPane.Chart.Fill = new Fill(Color.White, Color.LightYellow, 45.0F);
            myPane.Margin.All = 0;
            myPane.Margin.Top = 20;

            master.Add(myPane);

            y1List = new PointPairList();
            y2List = new PointPairList();

            var myCurve = myPane.AddCurve("", y1List, Color.Red, SymbolType.Circle);
            myCurve.IsVisible = false;
            myCurve = myPane.AddCurve("", y2List, Color.Green, SymbolType.Circle);
            myCurve.IsVisible = false;
            myCurve.IsY2Axis = true;
            chart.IsSynchronizeYAxes = true;
            chart.Invalidate();
        }
Esempio n. 27
0
 public void AddCurve(GraphPane myPane, Stats dataClass, int Length, string title)
 {
     PointPairList points = new PointPairList();
     for (int i = 0; i < Length; i++)
     {
         double x = Math.Abs(dataClass.DataList[i]);
         double y = (i + 1) * (1.0 / ((double) Length));
         points.Add(x, y);
     }
     myPane.AddCurve(title, points, this.rotator.NextColor, this.rotator.NextSymbol).Symbol.Fill = new Fill(Color.White);
     myPane.YAxis.Scale.MaxAuto = false;
     myPane.YAxis.Scale.MinAuto = false;
     myPane.YAxis.Scale.Max = 1.0;
     myPane.YAxis.Scale.Min = 0.0;
     this.zedGraphControl1.AxisChange();
 }
Esempio n. 28
0
        private void Form1_Load(object sender, EventArgs e)
        {
            saveFileDialog1.ShowDialog();
            writer = new StreamWriter(saveFileDialog1.FileName);
            MyPane = WaveformGraph.GraphPane;

            MyPane.XAxis.Title.Text = "";
            MyPane.YAxis.Scale.Max = 5;
            MyPane.YAxis.Scale.Min = 0;
            MyPane.YAxis.Title.Text = "";
            MyPane.Title.Text = "";
            LineItem myCurve = MyPane.AddCurve("", list1, Color.Red, SymbolType.None);
            WaveformGraph.AxisChange();
            SerialReader.Open();
            Timer_ms.Start();
        }
Esempio n. 29
0
        public void CreateChart2(ZedGraphControl zedGraphControl2)
        {
            ZedGraph.GraphPane myPane2 = zedGraphControl2.GraphPane;
            myPane2.Title.Text       = "Spectrum Analysis (DFT)";
            myPane2.XAxis.Title.Text = "Frequency";
            zedGraphControl2.GraphPane.CurveList.Clear();
            zedGraphControl2.GraphPane.GraphObjList.Clear();
            if (Linear.Checked)
            {
                myPane2.YAxis.Title.Text = "[Linearized]";
                for (int x = 199; x > 0; x--)
                {
                    list1.Add(-1 * x, wave[x]);
                }
                for (int x = 0; x < 199; x++)
                {
                    list1.Add(x, wave[x]);
                }
            }
            else
            {
                myPane2.YAxis.Title.Text = "[dB]";

                for (int x = 199; x > 0; x--)
                {
                    list1.Add(-1 * x, 20 * Math.Log10(wave[x]));
                }
                for (int x = 0; x < 199; x++)
                {
                    list1.Add(x, 20 * Math.Log10(wave[x]));
                }
            }
            ZedGraph.LineItem myCurve = myPane2.AddCurve("", list1, Color.Black, SymbolType.None);
            myPane2.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f);
            myPane2.XAxis.MajorGrid.IsVisible = true;
            myPane2.YAxis.MajorGrid.IsVisible = true;
            zedGraphControl2.GraphPane.YAxis.Scale.MaxAuto = true;
            myPane2.XAxis.Scale.Min       = 0;
            myPane2.XAxis.Scale.Max       = 200;
            myPane2.XAxis.Scale.MinorStep = 1;
            myPane2.XAxis.Scale.MajorStep = 10;
            zedGraphControl2.AxisChange();
            zedGraphControl2.Invalidate();
        }
Esempio n. 30
0
        public void SaveImage(int width, int height, string title, string outputFile, ImageFormat imageFormat)
        {
            GraphPane myPane = new GraphPane(new RectangleF(0, 0, width, height), title, "Week", "Hours");
            myPane.IsBoundedRanges = true;

            var ppl = new PointPairList();
            foreach (var week in data)
            {
                ppl.Add(week.Item1, week.Item2);
            }

            // Hide the legend
            myPane.Legend.IsVisible = false;
            var foreground = Color.FromArgb(255, 55, 108, 153);

            myPane.XAxis.AxisGap = 1f;
            myPane.XAxis.Type = AxisType.Text;
            myPane.XAxis.Scale.TextLabels = data.Select(t => "Week " + t.Item1).ToArray();

            myPane.YAxis.Scale.Min = 0;
            myPane.YAxis.Scale.MinorStep = 1;
            myPane.YAxis.MinorTic.Color = Color.Transparent;

            myPane.Border.IsVisible = false;

            LineItem curve = myPane.AddCurve("Hours of effort", ppl, foreground, SymbolType.Circle);
            curve.Line.Width = 2.0F;
            curve.Line.IsAntiAlias = true;
            curve.Symbol.Fill = new Fill(Color.White);
            curve.Symbol.Size = 7;

            // Leave some extra space on top for the labels to fit within the chart rect
            myPane.YAxis.Scale.MaxGrace = 0.1;

            myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45);
            myPane.Fill = new Fill(Color.White);

            Bitmap bm = new Bitmap(1, 1);
            using (Graphics g = Graphics.FromImage(bm))
                myPane.AxisChange(g);

            myPane.GetImage().Save(outputFile, imageFormat);
        }
Esempio n. 31
0
File: Graph.cs Progetto: altanis/AVR
        /// <summary>
        /// Public constructor.
        /// Initializes form and graph.
        /// </summary>
        /// <param name="f"></param>
        public Graph(Form1 f)
        {
            InitializeComponent();
            m_parentForm = f;
            this.Disposed += new EventHandler(Graph_Disposed);

            m_pane = zedGraphControl1.GraphPane;

            m_pane.Title.Text = TITLE;
            m_pane.XAxis.Title.Text = X_AXIS_NAME;
            m_pane.YAxis.Title.Text = Y_AXIS_NAME;
            m_pane.XAxis.Type = AxisType.Date;

            m_pairList = new PointPairList();

            m_tempLine = m_pane.AddCurve(CURVE_NAME,
                  m_pairList, Color.Red, SymbolType.None);

            zedGraphControl1.AxisChange();
        }
Esempio n. 32
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.btnUpdate_Click(null, null);
            this.listBox1.Items.Clear();


            ZedGraph.GraphPane gp = this.zgSolve1.GraphPane;
            gp.CurveList.Clear();
            this.curves.Clear();

            string fname = listFunctions2.SelectedItem.ToString();

            string curveName = "Line2";

            this.curves.Add(curveName, new PointPairList());
            Color c = Color.DarkBlue;//Color.FromArgb(255, r.Next(255), r.Next(255), r.Next(255));

            gp.AddCurve(curveName, this.curves[curveName], c, SymbolType.None);
            this.view.ViewActionCall(ViewEventType.SolovePodhod2Type2, fname, curveName);
        }
Esempio n. 33
0
        public void AllowMagnitudeScalingToEpsilon()
        {
            int height = 720;
            int width = 1280;

            var min = double.Epsilon;
            var max = min * 2;

            int expectedScale = -324;

            GraphPane graphPane = new GraphPane();
            graphPane.AddCurve(string.Empty, new[] { min, max }, new[] { min, max }, Color.Blue, SymbolType.None);

            Bitmap bitmap = new Bitmap(width, height);
            using (Graphics graphics = Graphics.FromImage(bitmap))
            {
                graphPane.AxisChange(graphics);
            }

            Assert.That(graphPane.YAxis.Scale.Mag, Is.EqualTo(expectedScale));
        }
Esempio n. 34
0
        //private static void zedGraphControl1_MouseMove(object sender, MouseEventArgs e)//鼠标移动出现虚线
        //{
        //    using (Graphics gc = MainForm.getInstance().GratReal.CreateGraphics())
        //    using (Pen pen = new Pen(Color.Gray))
        //    {
        //        pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
        //        RectangleF rect = MainForm.getInstance().GratReal.GraphPane.Chart.Rect;
        //        //确保在画图区域
        //        if (rect.Contains(e.Location))
        //        {
        //            MainForm.getInstance().GratReal.Refresh();
        //            gc.DrawLine(pen, e.X, rect.Top, e.X, rect.Bottom);
        //            gc.DrawLine(pen, rect.Left, e.Y, rect.Right, e.Y);
        //        }
        //    }
        //}
        public static void drawRealGrat(List <DataTable> dt)
        {
            int   Linenumber = Convert.ToInt32(MainForm.getInstance().GratLineNumber.Text);
            float wellzero   = ZedGraphClass.getWellZero();

            //if (dt.Count <= Linenumber)
            //{
            //    //画图

            //}
            //else
            //{
            //    //达到11的话,删除最初的列表。并作图。
            //    int j = dt.Count - Linenumber;
            //    if (j > 0)
            //    {
            //        for (int i = 0; i < j; i++)
            //        {
            //            dt.RemoveAt(0);
            //        }
            //    }
            //}
            ZedGraph.GraphPane gp = MainForm.getInstance().GratReal.GraphPane;
            MainForm.getInstance().GratReal.PointValueEvent += new ZedGraphControl.PointValueHandler(ZedGraphClass.MyPointValueHandlerTime);//设置节点信息显示样式
            //MainForm.getInstance().GratReal.IsShowHScrollBar = true;//横向滚动条
            //MainForm.getInstance().GratReal.MouseMove += zedGraphControl1_MouseMove;//鼠标在图上移动出现x虚线
            MainForm.getInstance().GratReal.IsShowPointValues = true;    //
            MainForm.getInstance().GratReal.IsZoomOnMouseCenter = false; //使用滚轮时以鼠标所在点进行缩放还是以图形中心进行缩放。
            gp.GraphObjList.Clear();
            gp.CurveList.Clear();
            int k = 0;

            if (dt.Count - Linenumber < 0)
            {
            }
            else
            {
                k = dt.Count - Linenumber;
            }
            for (int i = k; i < dt.Count; i++)//从第几条线开始,到结束
            {
                DataTable     table    = dt[i];
                string        Linename = table.Rows[0][0].ToString();
                PointPairList list1    = new PointPairList();
                for (int j = 0; j < table.Rows.Count; j++)
                {
                    double x;
                    float  y;
                    x = float.Parse(table.Rows[j]["fb"].ToString()) - wellzero;
                    y = float.Parse(table.Rows[j]["fc"].ToString());
                    list1.Add(x, y);
                }
                if (list1.Count == 0)//如果曲线没有数据
                {
                    //MessageBox.Show("曲线不存在");
                    continue;
                }
                else
                {
                    Color    co         = ZedGraphClass.GetColor(i);
                    LineItem _lineitem2 = gp.AddCurve(Linename, list1, ZedGraphClass.GetColor(i), SymbolType.Circle);
                    _lineitem2.Line.Width = 2.0F;          //线的宽度
                    string la = _lineitem2.Label.Text.ToString();
                    _lineitem2.Symbol.Size = 2.4F;         //线上节点的大小
                    _lineitem2.Symbol.Fill = new Fill(co); //线上节点的颜色
                    gp.AxisChange();
                }
            }
            MainForm.getInstance().GratReal.Refresh();
        }
Esempio n. 35
0
        private void CreateAgreementGraph(GraphPane gp, string[] files)
        {
            DateTime dtLastDate = DateTime.Now;
            for (int f = 0; f < files.Length; f++)
            {
                DateTime dt = dtLastDate.AddMinutes(5);

                string[] values = FileReadWrite.ReadLinesFromFile(files[f]);
                string name = Path.GetFileNameWithoutExtension(files[f]).Replace("average-a_", "");

                PointPairList listAnnotator = new PointPairList();
                PointPairList listClassifier = new PointPairList();
                PointPairList listDifference = new PointPairList();
                ArrayList alAgree_lists = new ArrayList();
                ArrayList alAgree_values = new ArrayList();
                double lastDifference = 0;

                //PointPairList listAgree = new PointPairList();
                //PointPairList listDisagree = new PointPairList();
                //PointPairList listConfusion = new PointPairList();
                double yClass = 2.3, yAnnotate = 1.1;
                for (int i = 0; i < values.Length; i++)
                {
                    try
                    {
                        string[] split = values[i].Split(',');
                        if (split.Length > 2)
                        {
                            
                            int msec = Convert.ToInt32(split[0]);
                            dtLastDate = dt.AddMilliseconds(msec * 400);
                            double x = (double)new XDate(dtLastDate);

                            #region BLOCK GRAPH ANNOTATOR
                            double yA = Convert.ToDouble(split[1]) + 1.1;
                            if (yA != yAnnotate)
                            {
                                listAnnotator.Add(x, yAnnotate);
                                yAnnotate = yA;
                            }
                            listAnnotator.Add(x, yA);
                            yA -= 1.1;
                            #endregion

                            #region BLOCK GRAPH CLASSIFIER
                            double yC = Convert.ToDouble(split[2]) + 2.3;
                            if (yC != yClass)
                            {
                                listClassifier.Add(x, yClass);
                                yClass = yC;
                            }
                            listClassifier.Add(x, yC);
                            yC -= 2.3;
                            #endregion

                            double difference = yC - yA;
                            if (!alAgree_values.Contains(difference))
                            {
                                alAgree_values.Add(difference);
                                alAgree_lists.Add(new PointPairList());
                            }
                            int index = alAgree_values.IndexOf(difference);

                            if (difference != lastDifference)
                            {
                                listDifference.Add(x, lastDifference);
                                int lastindex = alAgree_values.IndexOf(lastDifference);
                                ((PointPairList)alAgree_lists[lastindex]).Add(x, 1);
                                ((PointPairList)alAgree_lists[index]).Add(x, 0);
                                lastDifference = difference;
                            }

                            
                            for (int a = 0; a < alAgree_lists.Count; a++)
                            {
                                if (a != index)
                                    ((PointPairList)alAgree_lists[a]).Add(x, 0);
                            }
                            ((PointPairList)alAgree_lists[index]).Add(x, 1);

                            listDifference.Add(x, difference);

                            //double nyA = 0, nyD = 0, nyC = 0;
                            //if (split[1] == split[2])
                            //{
                            //    if (split[2] == split[3])
                            //        nyA = 3;
                            //    else
                            //        nyD = 3;

                            //}
                            //else nyC = 3;

                            //if (yA != nyA) listAgree.Add(x, yA);
                            //if (yC != nyC) listConfusion.Add(x, yC);
                            //if (yD != nyD) listDisagree.Add(x, yD);
                            //listAgree.Add(x, nyA);
                            //listDisagree.Add(x, nyD);
                            //listConfusion.Add(x, nyC);
                            //yA = nyA; yC = nyC; yD = nyD;

                        }

                    }
                    catch { }
                }
                AddHorizontalText(gp, name, (double)new XDate(dt), Color.Black);
                LineItem lineCurve1 = gp.AddCurve("Annotator 1 " + name, listAnnotator, Color.Green, SymbolType.Default);
                lineCurve1.Symbol.IsVisible = false;
                lineCurve1.Line.IsVisible = true;
                _alLinesWithSymbols.Add(lineCurve1);

                AddVerticalText(gp, "Annotators", 1.1F, Color.Green);


                LineItem lineCurveC = gp.AddCurve("Classifier " + name, listClassifier, Color.Blue, SymbolType.Default);
                lineCurveC.Line.IsVisible = true;
                lineCurveC.Symbol.IsVisible = false;

                AddVerticalText(gp, "Classifier", 2.3F, Color.Blue);

                LineItem lineCurveD = gp.AddCurve("Difference " + name, listDifference, Color.Tomato, SymbolType.Default);
                lineCurveD.Line.IsVisible = true;
                lineCurveD.Line.Width = 0.5F;
                lineCurveD.Symbol.IsVisible = false;
                lineCurveD.Line.Fill = new Fill(Color.Tomato);

                AddVerticalText(gp, "Over\nestimate", 0, Color.Tomato);
                AddVerticalText(gp, "Under\nestimate", -1.0F, Color.Tomato);


                //for (int a = 0; a < alAgree_lists.Count; a++)
                //{
                //    Color fillColor = Color.Yellow;
                //    double diff = ((double)alAgree_values[a]);
                //    if (diff != 0)
                //    {
                //        int percent = Convert.ToInt32(Math.Round((1.1 - Math.Abs(diff)) * 255));
                //        if (diff < 0) fillColor = Color.FromArgb(percent, percent, 255);
                //        else fillColor = Color.FromArgb(255, percent, percent);
                //    }
                //    LineItem lineCurveAgree = gp.AddCurve("Agreement " + name + " " + alAgree_values[a].ToString(), ((PointPairList)alAgree_lists[a]), fillColor, SymbolType.Default);
                //    lineCurveAgree.Line.IsVisible = true;
                //    lineCurveAgree.Symbol.IsVisible = false;
                //    // Fill the area under the curve with a white-red gradient at 45 degrees
                //    lineCurveAgree.Line.Fill = new Fill(fillColor);
                //}

                //LineItem lineCurveAgree = gp.AddCurve("Agreement " + name, listAgree, Color.Green, SymbolType.Default);
                //lineCurveAgree.Line.IsVisible = true;
                //lineCurveAgree.Symbol.IsVisible = false;
                //// Fill the area under the curve with a white-red gradient at 45 degrees
                //lineCurveAgree.Line.Fill = new Fill(Color.White, Color.Green, 45F);

                //LineItem lineCurveDisagree = gp.AddCurve("Disgreement " + name, listDisagree, Color.Red, SymbolType.Default);
                //lineCurveDisagree.Line.IsVisible = true;
                //lineCurveDisagree.Symbol.IsVisible = false;
                //// Fill the area under the curve with a white-red gradient at 45 degrees
                //lineCurveDisagree.Line.Fill = new Fill(Color.White, Color.Red, 45F);

                //LineItem lineCurveConfusion = gp.AddCurve("Confusion " + name, listConfusion, Color.Yellow, SymbolType.Default);
                //lineCurveConfusion.Line.IsVisible = true;
                //lineCurveConfusion.Symbol.IsVisible = false;
                //// Fill the area under the curve with a white-red gradient at 45 degrees
                //lineCurveConfusion.Line.Fill = new Fill(Color.White, Color.Yellow, 45F);



                WidenDatesIfNeeded(listAnnotator);




            }

        }
Esempio n. 36
0
        private void CreateSurveyGraph(GraphPane gp, string filepath)
        {
            PointPairList list = new PointPairList();
            string[] values = FileReadWrite.ReadLinesFromFile(filepath);
            for (int i = 0; i < values.Length; i++)
            {
                try
                {
                    string[] split = values[i].Split(',');
                    double x = (double)new XDate(DateTime.Parse(split[0]));
                    list.Add(x, 20, split[1].Replace(";","\n"));
                }
                catch { }
            }

            LineItem pointsCurve = gp.AddCurve("surveys", list, Color.Purple, SymbolType.Diamond);
            pointsCurve.Line.IsVisible = false;
            pointsCurve.Symbol.Fill = new Fill(Color.Plum);
            pointsCurve.Symbol.Size = 10F;

            WidenDatesIfNeeded(list);
        }
Esempio n. 37
0
        private void CreatePhotoGraph(GraphPane gp, string filepath, string imagedir)
        {
            PointPairList list_Photo = new PointPairList();
            string[] values = FileReadWrite.ReadLinesFromFile(filepath);
            for (int i = 0; i < values.Length; i++)
            {
                try
                {
                    string[] split = values[i].Split(',');
                    double x = (double)new XDate(DateTime.Parse(split[0]));
                    list_Photo.Add(x, 25, split[2]+","+Path.Combine(imagedir,split[1]));
                }
                catch { }
            }

            LineItem pointsCurve = gp.AddCurve("photos", list_Photo, Color.Black, SymbolType.Square);
            pointsCurve.Line.IsVisible = false;
            pointsCurve.Symbol.Fill = new Fill(Color.LightGray);
            pointsCurve.Symbol.Size = 10F;

            WidenDatesIfNeeded(list_Photo);
        }
Esempio n. 38
0
        private void CreatePOIGraph(GraphPane gp, string filepath)
        {
            PointPairList list = new PointPairList();
            string[] values = FileReadWrite.ReadLinesFromFile(filepath);
            for (int i = 0; i < values.Length; i++)
            {
                try
                {
                    string[] split = values[i].Split(',');
                    double x = (double)new XDate(DateTime.Parse(split[0]));
                    string tag = "";
                    split = values[i].Split(':', '(');
                    for (int j = 5; j < split.Length; j += 2)
                    {
                        tag += split[j] + "\n";
                    }                   

                    list.Add(x, 200, tag);
                }
                catch { }
            }

            LineItem pointsCurve = gp.AddCurve("POI", list, Color.Black, SymbolType.Star);
            pointsCurve.Line.IsVisible = false;
            pointsCurve.Symbol.Fill = new Fill(Color.Black);
            pointsCurve.Symbol.Size = 6F;
            if (!_isAdaptingPointSize) pointsCurve.Symbol.Size = 1F;
            _alLinesWithSymbols.Add(pointsCurve);
            WidenDatesIfNeeded(list);
        }
Esempio n. 39
0
        /// <summary>
        /// 图形描绘
        /// </summary>
        public override void DrawGraph()
        {
            #region 图形所需数据
            //线条数组[线条数] [每条线的刻度值]
            double[][] lines;
            //X轴刻度
            double[] xAixsScale;
            //线条标注
            string[] labels;
            //X轴刻度标注
            string[] xAxisScaleLabels;

            if (base.XAxisScaleRefrence == DataTableStruct.Rows)
            {
                xAixsScale       = new double[base.DataSource.Rows.Count];
                xAxisScaleLabels = new string[base.DataSource.Rows.Count];
                for (int i = 0; i < base.DataSource.Rows.Count; i++)
                {
                    xAixsScale[i]       = i;
                    xAxisScaleLabels[i] = base.DataSource.Rows[i][base.CNNameColumn].ToString();
                }
                //要绘制的线条数为数据列数
                lines = new double[base.ShowValueColumns.Length][];
                //线条标注
                labels = new string[lines.Length];
                for (int i = 0; i < base.ShowValueColumns.Length; i++)
                {
                    labels[i] = base.ShowValueColumns[i].ColumnName;
                }


                //填充每条线的数据值
                for (int i = 0; i < lines.Length; i++)
                {
                    lines[i] = new double[xAixsScale.Length];
                    for (int j = 0; j < base.DataSource.Rows.Count; j++)
                    {
                        if (Convert.IsDBNull(base.DataSource.Rows[j][base.ShowValueColumns[i].ColumnField]))
                        {
                            lines[i][j] = 0;
                        }
                        else
                        {
                            lines[i][j] = Convert.ToDouble(base.DataSource.Rows[j][base.ShowValueColumns[i].ColumnField]);
                        }
                    }
                }
            }
            else
            {
                xAixsScale       = new double[base.ShowValueColumns.Length];
                xAxisScaleLabels = new string[base.ShowValueColumns.Length];
                for (int i = 0; i < base.ShowValueColumns.Length; i++)
                {
                    xAixsScale[i]       = i;
                    xAxisScaleLabels[i] = base.ShowValueColumns[i].ColumnName;
                }
                //要绘制的线条数为数据集的纪录数
                lines = new double[base.DataSource.Rows.Count][];
                //线条标注
                labels = new string[lines.Length];
                for (int i = 0; i < base.DataSource.Rows.Count; i++)
                {
                    labels[i] = base.DataSource.Rows[i][base.CNNameColumn].ToString();
                }
                //填充每条线的数据值
                for (int i = 0; i < lines.Length; i++)
                {
                    lines[i] = new double[xAixsScale.Length];
                    for (int j = 0; j < base.ShowValueColumns.Length; j++)
                    {
                        if (Convert.IsDBNull(base.DataSource.Rows[i][base.ShowValueColumns[j].ColumnField]))
                        {
                            lines[i][j] = 0;
                        }
                        else
                        {
                            lines[i][j] = Convert.ToDouble(base.DataSource.Rows[i][base.ShowValueColumns[j].ColumnField]);
                        }
                    }
                }
            }

            int maxXaisxScale = xAixsScale.Length;

            //Console.Beep();

            #endregion

            #region 显示图形
            base.GraphContainer.Controls.Clear();

            ZedGraph.ZedGraphControl grphTx = new ZedGraph.ZedGraphControl();

            grphTx.IsEnableHZoom     = false;
            grphTx.IsEnableVZoom     = false;
            grphTx.IsEnableWheelZoom = false;
            grphTx.Dock = System.Windows.Forms.DockStyle.Fill;


            ZedGraph.GraphPane myPane = grphTx.GraphPane;
            myPane.Title.Text       = base.GraphTitle;
            myPane.XAxis.Title.Text = base.XAxisTitle;
            myPane.YAxis.Title.Text = base.YAxisTitle;

            myPane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245), Color.FromArgb(255, 255, 190), 90F);
            //线条显示
            for (int i = 0; i < lines.Length; i++)
            {
                Color color;
                if (base.Colors == null)
                {
                    color = GetColor();
                }
                else
                {
                    color = base.Colors[i];
                }

                ZedGraph.LineItem myCurve = myPane.AddCurve(labels[i], xAixsScale, lines[i], color);

                myCurve.Symbol.Fill = new Fill(Color.White);
            }

            //X轴属性
            myPane.XAxis.Scale.Min            = 0;                //X轴刻度起始值
            myPane.XAxis.Scale.Max            = maxXaisxScale;    //X轴刻度最大值
            myPane.XAxis.Scale.TextLabels     = xAxisScaleLabels; //x轴刻度中文标注
            myPane.XAxis.Type                 = AxisType.Text;    //类型
            myPane.XAxis.Scale.FontSpec.Angle = 90;               //文字方向
            myPane.XAxis.Scale.FontSpec.Size = 11F;               //文字大小

            // Display the Y axis grid lines
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MinorGrid.IsVisible = true;


            BoxObj box = new BoxObj(0, 100, 1, 30, Color.Empty,
                                    Color.FromArgb(150, Color.LightGreen));
            box.Fill = new Fill(Color.White, Color.FromArgb(200, Color.LightGreen), 45.0F);

            box.ZOrder = ZOrder.E_BehindCurves;

            box.IsClippedToChartRect = true;

            box.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            myPane.GraphObjList.Add(box);

            TextObj text = new TextObj("", 0.95f, 85, CoordType.AxisXYScale,
                                       AlignH.Right, AlignV.Center);
            text.FontSpec.Fill.IsVisible   = false;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.IsBold           = true;
            text.FontSpec.IsItalic         = true;
            text.Location.CoordinateFrame  = CoordType.XChartFractionYScale;
            text.IsClippedToChartRect      = true;

            myPane.GraphObjList.Add(text);

            myPane.Fill = new Fill(Color.WhiteSmoke, Color.Lavender, 0F);

            grphTx.AxisChange();

            base.GraphContainer.Controls.Add(grphTx);
            #endregion
        }
Esempio n. 40
0
        //public static void getsejie(int max, int min )
        //{
        //    ZedGraph.GraphPane myPane1 = MainForm.getInstance().zedGraphControl1.GraphPane;
        //    myPane1.Title.Text = "色阶";
        //    myPane1.Title.IsVisible = false;
        //    Point topLeft1 = new Point(0, 0);
        //    Size howBig1 = new Size(60, 255);
        //    Rectangle rectangleArea = new Rectangle(topLeft1, howBig1);
        //    myPane1.Chart.Rect = rectangleArea;
        //    MainForm.getInstance().zedGraphControl1.MasterPane.Border.IsVisible = false;
        //    myPane1.Legend.IsVisible = false;//图例是不可见的
        //    myPane1.Border.IsVisible = false;//外边框消失
        //    myPane1.Chart.Border.IsVisible = false;//边框是否可见
        //    myPane1.YAxis.Scale.IsReverse = true;//Y轴值翻转,图像一样翻转

        //    myPane1.X2Axis.IsVisible = false;//上方X轴显示
        //    myPane1.XAxis.IsVisible = false;//下方X轴消失
        //    myPane1.Y2Axis.IsVisible = false;//上方Y轴显示
        //    myPane1.YAxis.IsVisible = false;//下方Y轴消失
        //    myPane1.YAxis.Scale.IsReverse = true;
        //    int jishu = System.Math.Abs(min) + System.Math.Abs(max);
        //    for (int j = 0; j <jishu-1; j++)
        //    {
        //        int a = j +min;
        //        PointPairList list1 = new PointPairList();
        //        for (int i = 0; i <10; i++)
        //        {
        //            double x = i;
        //            double y1 = j;
        //            list1.Add(x, y1);
        //        }
        //        LineItem myCurve = myPane1.AddCurve("Porsche",
        //           list1, getColor(a, max, min), SymbolType.Diamond);
        //        myCurve.Line.Width = 20f;
        //        myCurve.Symbol.Size = 10.0F;//线上节点的大小
        //        myPane1.AxisChange();

        //    }
        //    MainForm.getInstance().zedGraphControl1.Refresh();
        //}
        public static void getsejie(int max, int min)
        {
            ZedGraph.GraphPane myPane1 = MainForm.getInstance().zedGraphControl1.GraphPane;
            myPane1.CurveList.Clear();//清除上一步画的图
            myPane1.Title.Text      = "色阶";
            myPane1.Title.IsVisible = false;
            Point     topLeft1      = new Point(0, 0);
            Size      howBig1       = new Size(44, 165);
            Rectangle rectangleArea = new Rectangle(topLeft1, howBig1);

            myPane1.Chart.Rect = rectangleArea;
            MainForm.getInstance().zedGraphControl1.MasterPane.Border.IsVisible = false;
            MainForm.getInstance().zedGraphControl1.IsEnableVZoom = false; //Y轴缩放
            MainForm.getInstance().zedGraphControl1.IsEnableHZoom = false; //x轴缩放
            myPane1.Legend.IsVisible       = false;                        //图例是不可见的
            myPane1.Border.IsVisible       = false;                        //外边框消失
            myPane1.Chart.Border.IsVisible = false;                        //边框是否可见
            myPane1.YAxis.Scale.IsReverse  = true;                         //Y轴值翻转,图像一样翻转

            myPane1.X2Axis.IsVisible      = false;                         //上方X轴显示
            myPane1.XAxis.IsVisible       = false;                         //下方X轴消失
            myPane1.Y2Axis.IsVisible      = false;                         //上方Y轴显示
            myPane1.YAxis.IsVisible       = false;                         //下方Y轴消失
            myPane1.YAxis.Scale.IsReverse = true;

            //12-14 将max.min 写死,不在使用,max he
            int jishu = max - min;

            for (int j = 0; j < jishu - 1; j++)
            {
                PointPairList list1 = new PointPairList();
                for (int i = 0; i < 10; i++)
                {
                    double x  = i;
                    double y1 = j;
                    list1.Add(x, y1);
                }
                LineItem myCurve = myPane1.AddCurve("Porsche",
                                                    list1, getColor(j, max, min, Color.Blue, Color.Cyan), SymbolType.None);
                myCurve.Line.Width = 20f;
                //  myCurve.Symbol.Size = 10.0F;//线上节点的大小
                myPane1.AxisChange();
            }
            for (int j = 0; j < jishu - 1; j++)
            {
                PointPairList list1 = new PointPairList();
                for (int i = 0; i < 10; i++)
                {
                    double x  = i;
                    double y1 = j + jishu;
                    list1.Add(x, y1);
                }
                LineItem myCurve = myPane1.AddCurve("Porsche",
                                                    list1, getColor(j, max, min, Color.Cyan, Color.Yellow), SymbolType.None);
                myCurve.Line.Width = 20f;
                //  myCurve.Symbol.Size = 10.0F;//线上节点的大小
                myPane1.AxisChange();
            }
            for (int j = 0; j < jishu - 1; j++)
            {
                PointPairList list1 = new PointPairList();
                for (int i = 0; i < 10; i++)
                {
                    double x  = i;
                    double y1 = j + jishu * 2;
                    list1.Add(x, y1);
                }
                LineItem myCurve = myPane1.AddCurve("Porsche",
                                                    list1, getColor(j, max, min, Color.Yellow, Color.Red), SymbolType.None);
                myCurve.Line.Width = 20f;
                //  myCurve.Symbol.Size = 10.0F;//线上节点的大小
                myPane1.AxisChange();
            }
            MainForm.getInstance().zedGraphControl1.Refresh();
        }
Esempio n. 41
0
        private void button6_Click(object sender, EventArgs e)
        {
            double Ie, Ic, Ib, Vth, Rth, Rc, Re, Vcc, Vce, Vbe, Imax, vmax, beta, R1, R2;

            try
            {
                Rc   = Convert.ToDouble(txtgerilimbölücüpolarmarc.Text) * 1000;
                R1   = Convert.ToDouble(txtgerilimbölücüpolarmaR1.Text) * 1000;
                R2   = Convert.ToDouble(txtgerilimbölücüpolarmaR2.Text) * 1000;
                Re   = Convert.ToDouble(txtgerilimbölücüpolarmare.Text) * 1000;
                Vcc  = Convert.ToDouble(txtgerilimbölücüpolarmavcc.Text);
                beta = Convert.ToDouble(txtgerilimbölücüpolarmabeta.Text);
                Vbe  = Convert.ToDouble(txtgerilimbölücüpolarmavbe.Text);

                if (Rc > 0 & R1 > 0 & R2 > 0 & Re > 0)
                {
                    Imax = (1000 * Vcc) / (Rc + Re);
                    Vth  = R2 * Vcc / (R1 + R2);
                    Rth  = R2 * R1 / (R1 + R2);
                    Ib   = (Vth - Vbe) / (Rth + (beta + 1) * Re);
                    Ie   = (beta + 1) * Ib;
                    Ic   = Ie - Ib;
                    Vce  = Vcc - Ic * Rc - Ie * Re;
                    vmax = Vcc;

                    lblgerilimbölücüpolarmaıb.Text   = " = " + (Math.Pow(10, 6) * Ib).ToString() + "μA";
                    lblgerilimbölücüpolarmaıc.Text   = " = " + (1000 * Ic).ToString() + "mA";
                    lblgerilimbölücüpolarmaıe.Text   = " = " + (1000 * Ie).ToString() + "mA";
                    lblgerilimbölücüpolarmaImax.Text = " = " + Imax.ToString() + "mA";
                    lblgerilimbölücüpolarmavth.Text  = Vth.ToString() + "Volt";
                    lblgerilimbölücüpolarmarth.Text  = Rth.ToString();
                    lblgerilimbölücüpolarmavce.Text  = Vce.ToString() + "Volt";
                    Ic = Ic * 1000;


                    ZedGraph.ZedGraphControl g = new ZedGraph.ZedGraphControl();
                    g.Size = new Size(panel4.Width - 2, panel4.Height - 2);
                    ZedGraph.GraphPane myGraphPane = g.GraphPane;
                    myGraphPane.Title.Text       = "Dc yük eğrisi ";
                    myGraphPane.XAxis.Title.Text = "Volt (V)";
                    myGraphPane.YAxis.Title.Text = "Akım(ma)";
                    PointPairList list1 = new PointPairList();
                    myGraphPane.AddCurve("", new double[] { 0, vmax }, new double[] { Imax, 0 }, Color.Blue, ZedGraph.SymbolType.None);
                    myGraphPane.AddCurve("", new double[] { 0, Vce }, new double[] { Ic, Ic }, Color.Blue, ZedGraph.SymbolType.None);
                    myGraphPane.AddCurve("", new double[] { Vce, Vce }, new double[] { Ic, 0 }, Color.Blue, ZedGraph.SymbolType.None);

                    myGraphPane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.Red, 3.0f);

                    g.AxisChange();

                    panel4.Controls.Add(g);
                }
                else
                {
                    MessageBox.Show("Direnc Degerlerini yanlış girdiniz:");
                }
            }
            catch (Exception)
            {
                Form1.HataMesaji();
            }
        }
Esempio n. 42
0
        public static void DrawingGratTime()//画深度温度曲线
        {
            float wellzero = ZedGraphClass.getWellZero();

            MainForm.getInstance().groupBox4.Enabled = false;
            MainForm.getInstance().GTime.Enabled = false;
            MySqlConnection mycon = new MySqlConnection();

            mycon = getMycon();
            string button = MainForm.getInstance().number.Text;
            //ArrayList h2 = getGTime(mycon);//获取表名称列表
            DataTable SQLTableTime = getGTime(mycon);                        //获取时间值

            if (SQLTableTime.Rows.Count < 15 && SQLTableTime.Rows.Count > 0) //15条线之内
            {
                ZedGraph.GraphPane gp = MainForm.getInstance().GTime.GraphPane;
                gp.GraphObjList.Clear();
                gp.CurveList.Clear();    //清除上一步画的图
                if (MainForm.getInstance().label1.Text == "1")
                {
                    MainForm.getInstance().GTime.IsEnableVZoom = true;    //Y轴缩放
                    MainForm.getInstance().GTime.IsEnableHZoom = true;    //x轴缩放
                }
                else
                {
                    MainForm.getInstance().GTime.IsEnableVZoom = false;                                                                       //禁止Y轴缩放
                    MainForm.getInstance().GTime.IsEnableHZoom = true;                                                                        //x轴缩放
                }
                MainForm.getInstance().GTime.PointValueEvent += new ZedGraphControl.PointValueHandler(ZedGraphClass.MyPointValueHandlerTime); //设置节点信息显示样式
                //MainForm.getInstance().GTime.IsShowHScrollBar = true;//横向滚动条
                MainForm.getInstance().GTime.MouseMove += zedGraphControl1_MouseMove;                                                         //鼠标在图上移动出现x虚线
                MainForm.getInstance().GTime.IsShowPointValues = true;                                                                        //
                MainForm.getInstance().GTime.IsZoomOnMouseCenter = false;                                                                     //使用滚轮时以鼠标所在点进行缩放还是以图形中心进行缩放。

                //设置XY轴的起始点

                if (MainForm.getInstance().GratDepTM3.Text != "" && MainForm.getInstance().GratDepTM4.Text != "")
                {
                    gp.YAxis.Scale.Min = float.Parse(MainForm.getInstance().GratDepTM3.Text);
                    gp.YAxis.Scale.Max = float.Parse(MainForm.getInstance().GratDepTM4.Text);
                }
                else
                {
                    gp.YAxis.Scale.MaxAuto = true;
                    gp.YAxis.Scale.MinAuto = true;
                }

                MainForm.getInstance().GTime.IsAutoScrollRange = false;

                //ZedGraphClass.stile(gp);//在程序打开时已经加载过了
                //坐标轴标题格式
                // gp.Title.Text = "LD27-2平台 A22H井 温度深度曲线"; //图表轴名称
                //gp.XAxis.Title.Text = "深度"; //X轴名称;
                //gp.YAxis.Title.Text = "温度"; //Y轴名称



                string[] hn = new string[SQLTableTime.Rows.Count]; //图例名称
                if (button == "two")                               //循环生成
                {
                    for (int k = 0; k < 4; k++)                    //循环四次结束循环
                    {
                        gp.GraphObjList.Clear();
                        gp.CurveList.Clear();
                        for (int i = 0; i < SQLTableTime.Rows.Count; i++)
                        {
                            //清除上一步画的图
                            System.Threading.Thread.Sleep(1500);
                            string    Str     = null;
                            DataTable dtValue = new DataTable();
                            Str = "SELECT Depth,RecordTime,TM from " + SQLTableTime.Rows[i]["folderTable"] + " where  RecordTime=\'" + Convert.ToDateTime(SQLTableTime.Rows[i]["folderTime"]) + "\' ORDER BY Depth";
                            // str3 = "SELECT COUNT(*) from " + tableName.Rows[j][0] + " WHERE RecordTime between  \'" + DintervalTime1 + "\'  AND \'" + DintervalTime2 + "\'";
                            dtValue = getDataTable(Str, mycon);
                            hn[i]   = SQLTableTime.Rows[i]["folderTime"].ToString();
                            PointPairList list1 = new PointPairList();
                            for (int j = 0; j < dtValue.Rows.Count; j++)
                            {
                                double x;
                                float  y;
                                if (num == 1)
                                {
                                    x = float.Parse(dtValue.Rows[j]["TM"].ToString());
                                    y = float.Parse(dtValue.Rows[j]["Depth"].ToString()) - wellzero;
                                }
                                else
                                {
                                    x = float.Parse(dtValue.Rows[j]["Depth"].ToString()) - wellzero;
                                    y = float.Parse(dtValue.Rows[j]["TM"].ToString());
                                }
                                list1.Add(x, y);
                            }
                            if (list1.Count == 0 && k == 0)    //如果曲线没有数据
                            {
                                messageError += "时间" + (MainForm.getInstance().TimeList.Items[i]).ToString() + "无数据\n";
                                continue;
                            }
                            else
                            {
                                Color    co         = ZedGraphClass.GetColor(i);
                                LineItem _lineitem2 = gp.AddCurve(hn[i], list1, ZedGraphClass.GetColor(i), SymbolType.Circle);
                                _lineitem2.Line.Width  = 2.0F;   //线的宽度
                                _lineitem2.Symbol.Size = 2.4F;   //线上节点的大小
                                if (drawAttribute.Linenum == 2)
                                {
                                    _lineitem2.Line.IsVisible = false;
                                }
                                _lineitem2.Symbol.Fill = new Fill(co);    //线上节点的颜色
                                gp.AxisChange();
                                MainForm.getInstance().GTime.Refresh();
                            }
                        }
                    }
                }
                else    //生成
                {
                    for (int i = 0; i < SQLTableTime.Rows.Count; i++)
                    {
                        string    Str     = null;
                        DataTable dtValue = new DataTable();
                        Str = "SELECT Depth,RecordTime,TM from " + SQLTableTime.Rows[i]["folderTable"] + " where  RecordTime=\'" + Convert.ToDateTime(SQLTableTime.Rows[i]["folderTime"]) + "\' ORDER BY Depth";
                        // str3 = "SELECT COUNT(*) from " + tableName.Rows[j][0] + " WHERE RecordTime between  \'" + DintervalTime1 + "\'  AND \'" + DintervalTime2 + "\'";
                        dtValue = getDataTable(Str, mycon);
                        hn[i]   = SQLTableTime.Rows[i]["folderTime"].ToString();
                        PointPairList list1 = new PointPairList();
                        for (int j = 0; j < dtValue.Rows.Count; j++)
                        {
                            double x;
                            float  y;
                            if (num == 1)
                            {
                                x = float.Parse(dtValue.Rows[j]["TM"].ToString());
                                y = float.Parse(dtValue.Rows[j]["Depth"].ToString()) - wellzero;
                            }
                            else
                            {
                                x = float.Parse(dtValue.Rows[j]["Depth"].ToString()) - wellzero;
                                y = float.Parse(dtValue.Rows[j]["TM"].ToString());
                            }
                            list1.Add(x, y);
                        }
                        if (list1.Count == 0)    //如果曲线没有数据
                        {
                            messageError += "时间" + (MainForm.getInstance().TimeList.Items[i]).ToString() + "无数据\n";
                            continue;
                        }
                        else
                        {
                            Color    co         = ZedGraphClass.GetColor(i);
                            LineItem _lineitem2 = gp.AddCurve(hn[i], list1, ZedGraphClass.GetColor(i), SymbolType.Circle);
                            _lineitem2.Line.Width = 2.0F;    //线的宽度
                            //string la = _lineitem2.Label.Text.ToString();
                            if (drawAttribute.Linenum == 2)
                            {
                                _lineitem2.Line.IsVisible = false;
                            }
                            _lineitem2.Symbol.Size = 2.4F;         //线上节点的大小
                            _lineitem2.Symbol.Fill = new Fill(co); //线上节点的颜色
                            gp.AxisChange();
                            MainForm.getInstance().GTime.Refresh();
                        }
                    }
                }
            }
            else if (SQLTableTime.Rows.Count > 15)
            {
                MessageBox.Show("时间区间太大,曲线条数大于15");
            }
            else
            {
                if (messageError == null)
                {
                    MessageBox.Show("没有添加时间点!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            MainForm.getInstance().groupBox4.Enabled = true;
            MainForm.getInstance().GTime.Enabled = true;
            mycon.Close();
            if (messageError != null)
            {
                MessageBox.Show("以下时间点无数据!\n" + messageError, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Calculates and draws the four lines on the graph
        /// </summary>
        public void DrawGraph()
        {
            /// this code has the possibility to draw ZedGraph
            /// has worked for many people online, the problem is getting graphControl to take a child

            //WindowsFormsHost host = new WindowsFormsHost();
            //ZedGraph.ZedGraphControl graph = new ZedGraphControl();
            //graph.IsEnableZoom = false;
            //host.Child = graph;
            //graphControl.Children.Add(host);
            //this.Width = graph.Width + 2 * 20;
            //this.Height = graph.Height + 3 * 20;

            externPopSettings = App.externPopForm;
            ExternPopForm EPS = externPopSettings;

            myPane.CurveList.Clear();

            //TODO: Lines drawn simultaneously
            ZedGraph.LineItem myCurve = myPane.AddCurve("1",
                                                        new ZedGraph.PointPairList(), Color.Red, ZedGraph.SymbolType.None);

            ZedGraph.LineItem myCurve2 = myPane.AddCurve("2",
                                                         new ZedGraph.PointPairList(), Color.Blue, ZedGraph.SymbolType.None);

            ZedGraph.LineItem myCurve3 = myPane.AddCurve("3",
                                                         new ZedGraph.PointPairList(), Color.LimeGreen, ZedGraph.SymbolType.None);

            ZedGraph.LineItem myCurve4 = myPane.AddCurve("4",
                                                         new ZedGraph.PointPairList(), Color.Black, ZedGraph.SymbolType.None);

            double p       = 0;
            double q       = 0;
            double AA      = 0;
            double Aa      = 0;
            double aa      = 0;
            int    AAcount = 0;
            int    Aacount = 0;
            int    aacount = 0;
            int    AAnext  = 0;
            int    Aanext  = 0;
            int    aanext  = 0;
            int    psize   = 0;
            int    times   = 1;

            p = mutationModifier(initAlleleFrequency.Value);

            q = 1 - p;

            AA = Math.Pow(p, 2) * popSize.Value * fitnessAA.Value;
            Aa = 2 * p * q * popSize.Value * fitnessAa.Value;
            aa = Math.Pow(q, 2) * popSize.Value * fitnessaa.Value;

            //Console.WriteLine(((Math.Pow(p,2))+(Math.Pow(q,2))+(2*p*q)).ToString());

            /*Console.WriteLine((Math.Pow(q,2)).ToString());
             * Console.WriteLine((2*p*q).ToString());*/

            AAcount = (int)Math.Round(AA);
            Aacount = (int)Math.Round(Aa);
            aacount = (int)Math.Round(aa);

            myPane.CurveList[0].Points.Add(0, p);
            myPane.CurveList[1].Points.Add(0, p);
            myPane.CurveList[2].Points.Add(0, p);
            myPane.CurveList[3].Points.Add(0, p);


            ///This while loop runs once for each line
            /// in order to calculate a line point by point to allow simultaneous line drawing
            /// this loop needs to do all 4 lines at once, not 1 after the other
            while (times < 5)
            {
                p = mutationModifier(initAlleleFrequency.Value);
                q = 1 - p;

                AA = Math.Pow(p, 2) * popSize.Value * fitnessAA.Value;
                Aa = 2 * p * q * popSize.Value * fitnessAa.Value;
                aa = Math.Pow(q, 2) * popSize.Value * fitnessaa.Value;


                AAcount = (int)Math.Round(AA);
                Aacount = (int)Math.Round(Aa);
                aacount = (int)Math.Round(aa);



                for (int i = 1; i < generation.Value; i++)
                {
                    psize  = AAcount + Aacount + aacount;
                    AAnext = 0;
                    Aanext = 0;
                    aanext = 0;

                    #region Generate New Population
                    for (int k = 0; k < this.popSize.Value; k++)
                    {
                        int r = rand.Next(psize);


                        allele first;
                        allele second;

                        if (r < AAcount)
                        {
                            first = allele.AA;
                        }
                        else if (AAcount <= r && r < AAcount + Aacount)
                        {
                            first = allele.Aa;
                        }
                        else
                        {
                            first = allele.aa;
                        }

                        r = rand.Next(psize);

                        if (0 <= r && r < AAcount)
                        {
                            second = allele.AA;
                        }
                        else if (AAcount <= r && r < AAcount + Aacount)
                        {
                            second = allele.Aa;
                        }
                        else
                        {
                            second = allele.aa;
                        }

                        if (first == allele.AA)
                        {
                            switch (second)
                            {
                            case allele.AA:
                                AAnext++;
                                break;

                            case allele.Aa:
                                if (rand.Next(2) == 0)
                                {
                                    AAnext++;
                                }
                                else
                                {
                                    Aanext++;
                                }
                                break;

                            case allele.aa:
                                Aanext++;
                                break;
                            }
                        }
                        else if (first == allele.Aa)
                        {
                            switch (second)
                            {
                            case allele.AA:
                                if (rand.Next(2) == 0)
                                {
                                    AAnext++;
                                }
                                else
                                {
                                    Aanext++;
                                }
                                break;

                            case allele.Aa:
                                switch (rand.Next(4))
                                {
                                case 0:
                                    AAnext++;
                                    break;

                                case 1:
                                    aanext++;
                                    break;

                                default:
                                    Aanext++;
                                    break;
                                }
                                break;

                            case allele.aa:
                                if (rand.Next(2) == 0)
                                {
                                    Aanext++;
                                }
                                else
                                {
                                    aanext++;
                                }
                                break;
                            }
                        }
                        else
                        {
                            switch (second)
                            {
                            case allele.AA:
                                Aanext++;
                                break;

                            case allele.Aa:
                                if (rand.Next(2) == 0)
                                {
                                    aanext++;
                                }
                                else
                                {
                                    Aanext++;
                                }
                                break;

                            case allele.aa:
                                aanext++;
                                break;
                            }
                        }
                    }
                    #endregion


                    if (EPS.enabled && (i >= EPS.ExposureBegin.Value) && (i <= (EPS.ExposureBegin.Value + EPS.ExposureDuration.Value)) && (randnum.NextDouble() < EPS.ExposureChance.Value))
                    {
                        double tot       = EPS.AADistribution.Value + EPS.AaDistribution.Value + EPS.aaDistribution.Value;
                        double ExternAA  = (EPS.AADistribution.Value / tot);
                        double ExternAa  = (EPS.AaDistribution.Value / tot);
                        double Externaa  = (EPS.aaDistribution.Value / tot);
                        int    totnext   = AAnext + Aanext + aanext;
                        int    totAA     = (int)(ExternAA * totnext * EPS.MigrationSize.Value + (AAnext) * (1 - EPS.MigrationSize.Value));
                        int    totAa     = (int)(ExternAa * totnext * EPS.MigrationSize.Value + (Aanext) * (1 - EPS.MigrationSize.Value));
                        int    totaa     = (int)(Externaa * totnext * EPS.MigrationSize.Value + (aanext) * (1 - EPS.MigrationSize.Value));
                        int    skewedtot = totAA + totAa + totaa;
                        if (skewedtot < totnext)
                        {
                            totAa += (totnext - skewedtot);
                        }
                        AAnext = totAA; Aanext = totAa; aanext = totaa;
                    }
                    if (AAnext + Aanext + aanext != popSize.Value)
                    {
                        throw new Exception("You calculated wrong, stupid.");
                    }

                    p = (2 * AAnext + Aanext) / (2 * popSize.Value);


                    //adds the point to the list of points to be drawn?
                    myPane.CurveList[times - 1].Points.Add(i, p);

                    p = mutationModifier(p);
                    q = 1 - p;

                    AA = Math.Pow(p, 2) * popSize.Value * fitnessAA.Value;
                    Aa = 2 * p * q * popSize.Value * fitnessAa.Value;
                    aa = Math.Pow(q, 2) * popSize.Value * fitnessaa.Value;

                    AAcount = (int)Math.Round(AA);
                    Aacount = (int)Math.Round(Aa);
                    aacount = (int)Math.Round(aa);
                }

                // draw the graph, line-by-line (will redraw 4 times)
                //myPane.Draw(g.CreateGraphics());

                times++;
            }
            //draw the graph, all lines together
            myPane.Draw(graphics);
        }
Esempio n. 44
0
        public static void DrawingGratDep()//画时间温度曲线
        {
            MyThread myt = new MyThread();

            string messageError = null;
            string GratDepth    = MainForm.getInstance().textBox3.Text;
            String SQLstr       = getstr();//获取str

            MainForm.getInstance().groupBox1.Enabled = false;
            MainForm.getInstance().GDep.Enabled = false;
            MySqlConnection mycon = new MySqlConnection();

            mycon = getMycon();
            string button   = MainForm.getInstance().number.Text;
            float  wellzero = ZedGraphClass.getWellZero();

            if (SQLstr != null)
            {
                DataTable SQLName = getTNameTable(GratDepTime1, GratDepTime2);//获取需要使用的表名称
                if (SQLName.Rows.Count != 0)
                {
                    ArrayList SQLList = MyDataTable.getDepth(wellzero, GratDepth);//获取深度值
                    if (SQLList.Count != 0)
                    {
                        SQLList = ZedGraphClass.getNewDepth(SQLList);//去重
                        ZedGraph.GraphPane gp = MainForm.getInstance().GDep.GraphPane;
                        gp.GraphObjList.Clear();
                        gp.CurveList.Clear();
                        if (MainForm.getInstance().label1.Text == "1")
                        {
                            MainForm.getInstance().GDep.IsEnableVZoom = true; //Y轴缩放
                            MainForm.getInstance().GDep.IsEnableHZoom = true; //x轴缩放
                        }
                        else
                        {
                            MainForm.getInstance().GDep.IsEnableVZoom = false;                                                                      //禁止Y轴缩放
                            MainForm.getInstance().GDep.IsEnableHZoom = true;                                                                       //x轴缩放
                        }
                        MainForm.getInstance().GDep.PointValueEvent += new ZedGraphControl.PointValueHandler(ZedGraphClass.MyPointValueHandlerDep); //设置节点信息显示样式
                        //MainForm.getInstance().GDep.IsShowHScrollBar = true;  //是否显示横向滚动条。
                        //MainForm.getInstance().GDep.ZoomStepFraction = 0;//不允许鼠标放大缩小
                        MainForm.getInstance().GDep.MouseMove += zedGraphControl1_MouseMove; //鼠标在图上移动出现x虚线
                        MainForm.getInstance().GDep.IsShowPointValues = true;                //显示节点坐标值
                        MainForm.getInstance().GDep.IsZoomOnMouseCenter = false;             //使用滚轮时以鼠标所在点进行缩放还是以图形中心进行缩放。
                        if (MainForm.getInstance().GratDepTM1.Text != "" && MainForm.getInstance().GratDepTM2.Text != "")
                        {
                            gp.YAxis.Scale.Min = float.Parse(MainForm.getInstance().GratDepTM1.Text);
                            gp.YAxis.Scale.Max = float.Parse(MainForm.getInstance().GratDepTM2.Text);
                        }
                        else
                        {
                            gp.YAxis.Scale.MaxAuto = true;//自动设置大小
                            gp.YAxis.Scale.MinAuto = true;
                        }
                        MainForm.getInstance().GDep.IsAutoScrollRange = false;
                        gp.XAxis.Scale.Format = "yyyy-MM-dd HH:mm:ss"; //横轴格式
                        gp.XAxis.Type         = AxisType.Date;         //格式
                        string[] hn = new string[SQLList.Count];       //折现的标签
                        if (button == "two")
                        {
                            for (int k = 0; k < 4; k++)
                            {
                                gp.GraphObjList.Clear();
                                gp.CurveList.Clear();//清除上一步画的图

                                for (int i = 0; i < SQLList.Count; i++)
                                {
                                    System.Threading.Thread.Sleep(1000);
                                    DataTable dtValue = new DataTable();
                                    string    SQLque  = "RecordTime";
                                    dtValue = MyDataTable.getDataTable(SQLName, Convert.ToInt32(SQLList[i]), SQLstr, SQLque, mycon);
                                    float e = Convert.ToInt32(SQLList[i].ToString()) - wellzero;
                                    hn[i] = e + "m";
                                    //hn[i] = SQLList[i] + "m";
                                    PointPairList list1 = new PointPairList();
                                    for (int j = 0; j < dtValue.Rows.Count; j++)
                                    {
                                        int bili = 1;
                                        if (dtValue.Rows.Count > 1000)
                                        {
                                            bili = dtValue.Rows.Count / 500;
                                        }
                                        if (j % bili == 0)
                                        {
                                            // string a = dt.Rows[j]["RecordTime"].ToString();
                                            double x = (double)new XDate((DateTime)dtValue.Rows[j]["RecordTime"]);
                                            //double x = (double)new XDate((DateTime)dt.Rows[j]["RecordTime"]);
                                            float y = float.Parse(dtValue.Rows[j]["TM"].ToString());
                                            list1.Add(x, y);
                                        }
                                        //TextObj text = new TextObj("shiji", x, y);
                                        //gp.GraphObjList.Add(text);
                                    }

                                    if (list1.Count == 0 && k == 0)//如果曲线没有数据或缺少数据
                                    {
                                        //MessageBox.Show("曲线不存在");
                                        messageError += "深度" + SQLList[i] + "m无数据\n";
                                        continue;
                                    }
                                    else
                                    {
                                        Color    co         = ZedGraphClass.GetColor(i);
                                        LineItem _lineitem2 = gp.AddCurve(hn[i], list1, ZedGraphClass.GetColor(i), SymbolType.Circle);
                                        //_lineitem2.Label.IsVisible = false;//名称不见的一种形式
                                        _lineitem2.Line.Width = 2.0F;//线的宽度
                                        //节点设置
                                        if (drawAttribute.Linenum == 2)
                                        {
                                            _lineitem2.Line.IsVisible = false;
                                        }
                                        _lineitem2.Symbol.Size = 2.4F;         //线上节点的大小
                                        _lineitem2.Symbol.Fill = new Fill(co); //线上节点的颜色
                                        gp.AxisChange();
                                        MainForm.getInstance().GDep.Refresh();
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < SQLList.Count; i++)//先做深度循环
                            {
                                DataTable dtValue = new DataTable();
                                string    SQLque  = "RecordTime";
                                dtValue = MyDataTable.getDataTable(SQLName, Convert.ToInt32(SQLList[i]), SQLstr, SQLque, mycon);
                                float e = Convert.ToInt32(SQLList[i].ToString()) - wellzero;
                                hn[i] = e + "m";
                                PointPairList list1 = new PointPairList();
                                for (int j = 0; j < dtValue.Rows.Count; j++)
                                {
                                    int bili = 1;
                                    if (dtValue.Rows.Count > 1000)
                                    {
                                        bili = dtValue.Rows.Count / 500;
                                    }
                                    if (j % bili == 0)
                                    {
                                        double x = (double)new XDate((DateTime)dtValue.Rows[j]["RecordTime"]);
                                        //  string a = dt.Rows[j]["RecordTime"].ToString();
                                        double y = double.Parse(dtValue.Rows[j]["TM"].ToString());

                                        list1.Add(x, y);
                                    }
                                }
                                if (list1.Count == 0)//如果曲线没有数据
                                {
                                    messageError += "深度" + SQLList[i] + "m无数据\n";
                                    continue;
                                }
                                else
                                {
                                    Color    co         = ZedGraphClass.GetColor(i);
                                    LineItem _lineitem2 = gp.AddCurve(hn[i], list1, co, SymbolType.Circle);
                                    _lineitem2.Line.Width = 2.0F;//线的宽度
                                    string la = _lineitem2.Label.Text.ToString();
                                    //节点设置
                                    if (drawAttribute.Linenum == 2)
                                    {
                                        _lineitem2.Line.IsVisible = false;
                                    }
                                    _lineitem2.Symbol.Size = 2.4F;         //线上节点的大小
                                    _lineitem2.Symbol.Fill = new Fill(co); //线上节点的颜色
                                    gp.AxisChange();
                                    MainForm.getInstance().GDep.Refresh();
                                }
                            }
                        }
                    }
                    else
                    {
                        //MessageBox.Show("深度输入不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MessageBox.Show("请填写深度!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    //MessageBox.Show("所选时间区间内没有数据,请更改时间区域!"); //没有表
                    MessageBox.Show("所选时间区间内没有数据,请更改时间区域!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (messageError != null)
                {
                    MessageBox.Show("以下深度点无数据!\n" + messageError, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("时间区间选择不正确,请修改!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            MainForm.getInstance().groupBox1.Enabled = true;
            MainForm.getInstance().GDep.Enabled = true;
            mycon.Close();
            mycon.Dispose();
            SQLstr = null;
        }
Esempio n. 45
0
        public static void DrawingDep()//画时间温度曲线
        {
            //获取时间的查询条件
            string          messageError = null;
            String          SQLstr       = getSQLstr();
            MySqlConnection mycon        = new MySqlConnection();

            mycon = getMycon();
            //获取井口位置
            float wellzero = ZedGraphClass.getWellZero();
            //获取循环(单循环还是多循环)
            string button = MainForm.getInstance().number.Text;

            //画图图禁止菜单和画图区域
            MainForm.getInstance().groupBox2.Enabled = false;
            MainForm.getInstance().zgcDep.Enabled = false;
            //新建数据库连接
            string DsingleDepth = MainForm.getInstance().DsingleDepth.Text;

            if (SQLstr != null)
            {
                DataTable SQLName = getTNameTable(DintervalTime1, DintervalTime2);//获取需要使用的表名称
                if (SQLName.Rows.Count != 0)
                {
                    ArrayList SQLList = MyDataTable.getDepth(wellzero, DsingleDepth); //获取深度值
                    if (SQLList.Count <= 15 && SQLList.Count > 0)                     //15条线之内
                    {
                        SQLList = ZedGraphClass.getNewDepth(SQLList);                 //去重
                        ZedGraph.GraphPane gp = MainForm.getInstance().zgcDep.GraphPane;
                        //gp.CurveList.Clear();//清除上一步画的图
                        gp.GraphObjList.Clear();
                        gp.CurveList.Clear();
                        //是否X、Y轴缩放的定义
                        if (MainForm.getInstance().label1.Text == "1")
                        {
                            MainForm.getInstance().zgcDep.IsEnableVZoom = true;    //Y轴缩放
                            MainForm.getInstance().zgcDep.IsEnableHZoom = true;    //x轴缩放
                        }
                        else
                        {
                            MainForm.getInstance().zgcDep.IsEnableVZoom = false;                                                                      //禁止Y轴缩放
                            MainForm.getInstance().zgcDep.IsEnableHZoom = true;                                                                       //x轴缩放
                        }
                        MainForm.getInstance().zgcDep.PointValueEvent += new ZedGraphControl.PointValueHandler(ZedGraphClass.MyPointValueHandlerDep); //设置节点信息显示样式
                        MainForm.getInstance().zgcDep.MouseMove += zedGraphControl1_MouseMove;                                                        //鼠标在图上移动出现x虚线
                        MainForm.getInstance().zgcDep.IsShowPointValues = true;                                                                       //显示节点坐标值
                        MainForm.getInstance().zgcDep.IsZoomOnMouseCenter = false;                                                                    //使用滚轮时以鼠标所在点进行缩放还是以图形中心进行缩放。
                        if (MainForm.getInstance().DintervalTM1.Text != "" && MainForm.getInstance().DintervalTM2.Text != "")
                        {
                            gp.YAxis.Scale.Min = float.Parse(MainForm.getInstance().DintervalTM1.Text);
                            gp.YAxis.Scale.Max = float.Parse(MainForm.getInstance().DintervalTM2.Text);
                        }
                        else
                        {
                            gp.YAxis.Scale.MaxAuto = true;    //自动设置大小
                            gp.YAxis.Scale.MinAuto = true;
                        }
                        MainForm.getInstance().zgcDep.IsAutoScrollRange = false;
                        //坐标轴刻度格式
                        gp.XAxis.Scale.Format = "yyyy-MM-dd HH:mm:ss"; //横轴格式
                        gp.XAxis.Type         = AxisType.Date;         //格式
                        string[] hn = new string[SQLList.Count];       //折线的标签
                        if (button == "two")                           //循环作图
                        {
                            for (int xunhuan = 0; xunhuan < 4; xunhuan++)
                            {
                                //清除上一步画的图
                                gp.GraphObjList.Clear();
                                gp.CurveList.Clear();

                                for (int i = 0; i < SQLList.Count; i++)
                                {
                                    System.Threading.Thread.Sleep(1000);
                                    PointPairList list1   = new PointPairList();
                                    DataTable     dtValue = new DataTable();
                                    string        SQLque  = "RecordTime";
                                    dtValue = MyDataTable.getDataTable(SQLName, Convert.ToInt32(SQLList[i]), SQLstr, SQLque, mycon);
                                    float e = Convert.ToInt32(SQLList[i].ToString()) - wellzero;
                                    hn[i] = e + "m";
                                    for (int k = 0; k < dtValue.Rows.Count; k++)
                                    {
                                        int bili = 1;
                                        if (dtValue.Rows.Count > 1000)
                                        {
                                            bili = dtValue.Rows.Count / 500;
                                        }
                                        if (k % bili == 0)
                                        {
                                            double x = (double)new XDate((DateTime)dtValue.Rows[k]["RecordTime"]);
                                            string a = dtValue.Rows[k]["RecordTime"].ToString();
                                            double y = double.Parse(dtValue.Rows[k]["TM"].ToString());
                                            list1.Add(x, y);
                                        }
                                    }
                                    if (list1.Count == 0 && xunhuan == 0)    //如果曲线没有数据
                                    {
                                        messageError += "深度" + SQLList[i] + "m无数据\n";
                                        continue;
                                    }
                                    else
                                    {
                                        Color    co         = ZedGraphClass.GetColor(i);
                                        LineItem _lineitem2 = gp.AddCurve(hn[i], list1, co, SymbolType.Circle);
                                        _lineitem2.Line.Width = 2.0F;    //线的宽度
                                        //节点设置
                                        if (drawAttribute.Linenum == 2)
                                        {
                                            _lineitem2.Line.IsVisible = false;
                                        }
                                        _lineitem2.Symbol.Size = 2.4F;         //线上节点的大小
                                        _lineitem2.Symbol.Fill = new Fill(co); //线上节点的颜色
                                        gp.AxisChange();
                                        MainForm.getInstance().zgcDep.Refresh();
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < SQLList.Count; i++)
                            {
                                PointPairList list1   = new PointPairList();
                                DataTable     dtValue = new DataTable();
                                string        SQLque  = "RecordTime";
                                dtValue = MyDataTable.getDataTable(SQLName, Convert.ToInt32(SQLList[i]), SQLstr, SQLque, mycon);
                                float e = Convert.ToInt32(SQLList[i].ToString()) - wellzero;
                                hn[i] = e + "m";
                                for (int k = 0; k < dtValue.Rows.Count; k++)
                                {
                                    int bili = 1;
                                    if (dtValue.Rows.Count > 1000)
                                    {
                                        bili = dtValue.Rows.Count / 500;
                                    }
                                    if (k % bili == 0)
                                    {
                                        double x = (double)new XDate((DateTime)dtValue.Rows[k]["RecordTime"]);
                                        string a = dtValue.Rows[k]["RecordTime"].ToString();
                                        double y = double.Parse(dtValue.Rows[k]["TM"].ToString());
                                        list1.Add(x, y);
                                    }
                                }
                                if (list1.Count == 0)    //如果曲线没有数据
                                {
                                    messageError += "深度" + SQLList[i] + "m无数据\n";
                                    continue;
                                }
                                else
                                {
                                    Color    co         = ZedGraphClass.GetColor(i);
                                    LineItem _lineitem2 = gp.AddCurve(hn[i], list1, co, SymbolType.Circle);
                                    _lineitem2.Line.Width = 2.0F;    //线的宽度
                                    //节点设置
                                    if (drawAttribute.Linenum == 2)
                                    {
                                        _lineitem2.Line.IsVisible = false;
                                    }
                                    _lineitem2.Symbol.Size = 2.4F;         //线上节点的大小
                                    _lineitem2.Symbol.Fill = new Fill(co); //线上节点的颜色
                                    gp.AxisChange();
                                    MainForm.getInstance().zgcDep.Refresh();
                                }
                            }
                        }
                    }
                    else if (SQLList.Count > 15)
                    {
                        //MessageBox.Show("深度区间太大,曲线条数大于15");
                        MessageBox.Show("深度区间太大,曲线条数大于15!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        // MessageBox.Show("在所选时间区间内数据库中无数据");//表中无数据
                        MessageBox.Show("请填写深度!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    //  MessageBox.Show("所选时间区间内没有数据,请更改时间区域!"); //没有表
                    MessageBox.Show("所选时间区间内没有数据,请更改时间区域!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (messageError != null)
                {
                    MessageBox.Show("以下深度点无数据!\n" + messageError, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                // MessageBox.Show("时间区间选择不正确,请修改!");
                MessageBox.Show("时间区间选择不正确,请修改!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            MainForm.getInstance().groupBox2.Enabled = true;
            MainForm.getInstance().zgcDep.Enabled = true;
            mycon.Close();
            mycon.Dispose();
            SQLstr = null;
        }
Esempio n. 46
0
        public Bitmap GenerateCurveImage(Size size)
        {
            GraphPane pane = new GraphPane(new RectangleF(0, 0, size.Width, size.Height), string.Empty, string.Empty, string.Empty);
            Bitmap result = new Bitmap(size.Width, size.Height);

            pane.AddCurve(string.Empty, Points, ActiveCurveGridColor);

            pane.XAxis.Scale.Min = 0;
            pane.XAxis.Scale.Max = 100;
            pane.YAxis.Scale.Min = 0;
            pane.YAxis.Scale.Max = 100;
            pane.XAxis.IsVisible = false;
            pane.YAxis.IsVisible = false;
            pane.Legend.IsVisible = false;
            pane.Title.IsVisible = false;

            pane.Chart.Fill = new Fill(SystemColors.Control);
            pane.Border = new Border(SystemColors.Control, 0);

            using (Graphics g = Graphics.FromImage(result)) {
                pane.AxisChange(g);
                result = pane.GetImage(true);
            }

            return result;
        }
Esempio n. 47
0
        public override Image Draw(
            GraphDefinition graphDefinition,
            IEnumerable <PersistedCityStatisticsWithFinancialData> statistics,
            Font font,
            Size size)
        {
            using (var chartMemoryStream = new MemoryStream())
            {
                var chart = new ZedGraph.GraphPane();

                foreach (var axis in new[] { chart.XAxis, chart.YAxis as Axis })
                {
                    axis.Scale.IsUseTenPower = false;
                    axis.Scale.Format        = "F0";
                }

                chart.XAxis.Title.Text = "Time";
                chart.XAxis.Type       = AxisType.LinearAsOrdinal;
                chart.YAxis.Type       = AxisType.Linear;
                chart.YAxis.Title.Text = graphDefinition.Title;

                foreach (var z in graphDefinition.GraphSeriesSet)
                {
                    var pointPairList = new PointPairList();

                    foreach (var statistic in statistics)
                    {
                        pointPairList.Add(statistic.PersistedCityStatistics.TimeCode, z.GetValue(statistic));
                    }

                    chart.AddCurve(z.Label, pointPairList, z.Color, SymbolType.None);
                }

                chart.Title.Text = graphDefinition.Title;

                if (graphDefinition.IsCurrency)
                {
                    chart.YAxis.ScaleFormatEvent += (pane, axis, val, index) =>
                    {
                        return(val.ToString("C"));
                    };
                }

                graphDefinition.DataMeter.WithResultIfHasMatch(dataMeter =>
                {
                    chart.YAxis.ScaleFormatEvent += (pane, axis, val, index) =>
                    {
                        var meter = dataMeter.Thresholds.SingleOrDefault(
                            x => x.MinMeasureUnitThreshold <= val && x.MaxMeasureUnitThreshold > val);

                        if (meter != null)
                        {
                            return(meter.Category.ToString());
                        }
                        return(string.Empty);
                    };
                });

                return(chart.GetImage());
            }
        }
        private void InitializeTemperatureGraph()
        {
            tempPane = zgcTemperature.GraphPane;
            tempPane.Chart.Fill = new Fill(Color.AntiqueWhite, Color.Honeydew, -45F);
            tempPane.CurveList.Clear();
            tempPane.Title.Text = "Temperature Sensor";
            tempPane.XAxis.Title.Text = "Time (second)";
            tempPane.YAxis.Title.Text = "Temperature (°C)";
            tempPane.XAxis.MajorTic.IsOutside = false;
            tempPane.XAxis.MinorTic.IsOutside = false;
            tempPane.YAxis.MajorTic.IsOutside = false;
            tempPane.YAxis.MinorTic.IsOutside = false;
            tempPane.XAxis.MajorGrid.IsVisible = true;
            tempPane.YAxis.MajorGrid.IsVisible = true;
            tempPane.XAxis.MajorGrid.Color = Color.LightGray;
            tempPane.YAxis.MajorGrid.Color = Color.LightGray;
            //tempPane.XAxis.Scale.MajorStep = 1d;

            // Just manually control the X axis range so it scrolls continuously
            // instead of discrete step-sized jumps
            tempPane.XAxis.Scale.Min = 0;
            tempPane.XAxis.Scale.Max = 30;
            tempPane.XAxis.Scale.MinorStepAuto = true;
            tempPane.XAxis.Scale.MajorStepAuto = true;

            //tempPane.XAxis.Scale.MajorUnit = DateUnit.Minute;
            //tempPane.XAxis.Scale.MinorUnit = DateUnit.Second;
            //tempPane.XAxis.Scale.Format = "HH:mm:ss";
            //tempPane.XAxis.Type = AxisType.DateAsOrdinal;

            // Save 60000 points. At 50 ms sample rate. this is one minute
            // The RollingPointPairList is an efficint storage class the always
            // Keeps a rolling set of point data without needing to shif any data values
            RollingPointPairList list = new RollingPointPairList(60000);

            LineItem curve = tempPane.AddCurve("Temperature", list, pointColor, symbolType);
            curve.Symbol.Fill.Type = FillType.Solid;
            curve.Symbol.Size = pointWidth;
            curve.Line.Width = lineWidth;
            //curve.Line.IsSmooth = true;
            //curve.Line.SmoothTension = 0.3f;

            // Scale the axes
            zgcTemperature.AxisChange();

            // Save the beginning time for reference
            tickStart = Environment.TickCount;
        }
Esempio n. 49
0
        private void button7_Click(object sender, EventArgs e)
        {
            double Ie, Ic, Ib, Rb, Rc, Re, Vcc, Vce, Vbe, Imax, vmax, beta;

            try
            {
                Rc   = Convert.ToDouble(txtgeribeslemelirc.Text) * 1000;
                Rb   = Convert.ToDouble(txtgeribeslemelirb.Text) * 1000;
                Re   = Convert.ToDouble(txtgeribeslemeliRe.Text) * 1000;
                Vcc  = Convert.ToDouble(txtgeribeslemeliVcc.Text);
                beta = Convert.ToDouble(txtgeribeslemelibeta.Text);
                Vbe  = Convert.ToDouble(txtgeribeslemelivbe.Text);
                if (Rc > 0 & Rb > 0 & Re > 0)
                {
                    Imax = (1000 * Vcc) / (Rc + Re);

                    Ib   = (Vcc - Vbe) / (Rb + (beta + 1) * (Re + Rc));
                    Ie   = (beta + 1) * Ib;
                    Ic   = beta * Ib;
                    Vce  = Vcc - Ie * (Rc + Re);
                    vmax = Vcc;



                    lblgeribeslemeliIb.Text   = " = " + (Math.Pow(10, 6) * Ib).ToString() + "μA";
                    lblgeribeslemeliIc.Text   = " = " + (1000 * Ic).ToString() + "mA";
                    lblgeribeslemeliIe.Text   = " = " + (1000 * Ie).ToString() + "mA";
                    lblgeribeslemeliımax.Text = " = " + Imax.ToString() + "mA";

                    lblgeribeslemeliVce.Text = Vce.ToString() + "Volt";



                    Ic = Ic * 1000;



                    ZedGraph.ZedGraphControl g = new ZedGraph.ZedGraphControl();
                    g.Size = new Size(panel5.Width - 2, panel5.Height - 2);
                    ZedGraph.GraphPane myGraphPane = g.GraphPane;
                    myGraphPane.Title.Text       = "Dc yük eğrisi ";
                    myGraphPane.XAxis.Title.Text = "Volt (V)";
                    myGraphPane.YAxis.Title.Text = "Akım(ma)";
                    PointPairList list1 = new PointPairList();
                    myGraphPane.AddCurve("", new double[] { 0, vmax }, new double[] { Imax, 0 }, Color.Blue, ZedGraph.SymbolType.None);
                    myGraphPane.AddCurve("", new double[] { 0, Vce }, new double[] { Ic, Ic }, Color.Blue, ZedGraph.SymbolType.None);
                    myGraphPane.AddCurve("", new double[] { Vce, Vce }, new double[] { Ic, 0 }, Color.Blue, ZedGraph.SymbolType.None);

                    myGraphPane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.Red, 3.0f);

                    g.AxisChange();

                    panel5.Controls.Add(g);
                }
                else
                {
                    MessageBox.Show("Direnc Degerlerini yanlış girdiniz:");
                }
            }
            catch (Exception)
            {
                Form1.HataMesaji();
            }
        }
Esempio n. 50
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gp"></param>
        /// <param name="gpconfig"></param>
        /// <param name="stationInfo"></param>
        private void Draw(GraphPane gp, GraphPaneConfig gpconfig, GRStationCurveInfo stationInfo)
        {
            DataTable tbl = CZGRQRCApp.Default.DBI.ExecuteGRDataTable(
                stationInfo.StationName, stationInfo.Begin, stationInfo.End);
            gpconfig.ConfigGraphPane(gp, stationInfo);

            GRDataCurveConfigCollection ccs = stationInfo.GRCurveType.GRDataCurveConfigCollection;

            foreach (GRDataCurveConfig cc in ccs )
            {
                IPointList pts = GetPointList(tbl, cc);
                string dataCurveName = GRData.GetGRDataText(cc.GRDataEnum);
                gp.AddCurve(dataCurveName, pts, cc.Color, cc.SymbolType);
            }
        }
Esempio n. 51
0
        public SynchronizedPanes()
            : base("A demo that shows how multiple GraphPanes can be synchronized to scroll together." +
						"  Test it by zooming in on one pane (all panes will zoom together).  Then, scroll to" +
						" see all panes move together.",
						"Synchronized Panes Demo", DemoType.Line)
        {
            MasterPane master = base.MasterPane;

            master.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45.0f );
            master.PaneList.Clear();

            master.Title.IsVisible = true;
            master.Title.Text = "Synchronized Graph Demo";

            master.Margin.All = 10;
            master.InnerPaneGap = 0;

            ColorSymbolRotator rotator = new ColorSymbolRotator();

            for ( int j = 0; j < 3; j++ )
            {
                // Create a new graph with topLeft at (40,40) and size 600x400
                GraphPane myPaneT = new GraphPane( new Rectangle( 40, 40, 600, 400 ),
                    "Case #" + ( j + 1 ).ToString(),
                    "Time, Days",
                    "Rate, m/s" );

                myPaneT.Fill.IsVisible = false;

                myPaneT.Chart.Fill = new Fill( Color.White, Color.LightYellow, 45.0F );
                myPaneT.BaseDimension = 3.0F;
                myPaneT.XAxis.Title.IsVisible = false;
                myPaneT.XAxis.Scale.IsVisible = false;
                myPaneT.Legend.IsVisible = false;
                myPaneT.Border.IsVisible = false;
                myPaneT.Title.IsVisible = false;
                myPaneT.XAxis.MajorTic.IsOutside = false;
                myPaneT.XAxis.MinorTic.IsOutside = false;
                myPaneT.XAxis.MajorGrid.IsVisible = true;
                myPaneT.XAxis.MinorGrid.IsVisible = true;
                myPaneT.Margin.All = 0;
                if ( j == 0 )
                    myPaneT.Margin.Top = 20;
                if ( j == 2 )
                {
                    myPaneT.XAxis.Title.IsVisible = true;
                    myPaneT.XAxis.Scale.IsVisible = true;
                    myPaneT.Margin.Bottom = 10;
                }

                if ( j > 0 )
                    myPaneT.YAxis.Scale.IsSkipLastLabel = true;

                // This sets the minimum amount of space for the left and right side, respectively
                // The reason for this is so that the ChartRect's all end up being the same size.
                myPaneT.YAxis.MinSpace = 60;
                myPaneT.Y2Axis.MinSpace = 20;

                // Make up some data arrays based on the Sine function
                double x, y;
                PointPairList list = new PointPairList();
                for ( int i = 0; i < 36; i++ )
                {
                    x = (double)i + 5 + j * 3;
                    y = 3.0 * ( 1.5 + Math.Sin( (double)i * 0.2 + (double)j ) );
                    list.Add( x, y );
                }

                LineItem myCurve = myPaneT.AddCurve( "Type " + j.ToString(),
                    list, rotator.NextColor, rotator.NextSymbol );
                myCurve.Symbol.Fill = new Fill( Color.White );

                master.Add( myPaneT );
            }

            using ( Graphics g = base.ZedGraphControl.CreateGraphics() )
            {
                ZedGraphControl z1 = base.ZedGraphControl;

                master.SetLayout( g, PaneLayout.SingleColumn );
                z1.AxisChange();

                z1.IsAutoScrollRange = true;
                z1.IsShowHScrollBar = true;
                z1.IsShowVScrollBar = true;
                z1.IsSynchronizeXAxes = true;

            }

            base.ZedGraphControl.AxisChange();
        }
Esempio n. 52
0
        private void CreatePercentGraph(OSPCResult r)
        {
            GraphPane g = new GraphPane(GraphRect, "Distribution of % similarity", "-", "% similarity");
            SetupGraph(g);

            var lst = r.Results.SelectMany(i => new[] { 100.0 * i.SimilarityA, 100.0 * i.SimilarityB }).OrderBy(i => i).ToArray();

            var c = g.AddCurve("Similarity",
                Enumerable.Range(1, lst.Length).Select(i => (double)i).ToArray(),
                lst,
                Color.Red);
            c.Symbol.IsVisible = false;

            #if SHOW_DERIVATION_2
            var derv_2 = lst.CalcDerv2();
            c = g.AddCurve("Derivation 2",
                Enumerable.Range(1, derv_2.Length).Select(i => (double)i).ToArray(),
                derv_2.ToArray(),
                Color.Green);
            c.IsY2Axis = true;
            c.Symbol.IsVisible = false;
            #endif

            AddLine(g, 100.0 * r.AVG_Similarity, Color.Blue, "Avg");
            AddLine(g, 100.0 * r.POI_Similarity, Color.Green, "POI");

            g.AxisChange();
            using (var img = g.GetImage(512, 256, 72.0f))
            {
                img.Save(Path.Combine(OutPath, "PercentGraph.png"), ImageFormat.Png);
            }
        }
Esempio n. 53
0
        private void CreateTokenMatchGraph(OSPCResult r)
        {
            GraphPane g = new GraphPane(GraphRect, "Distribution of token / match", "-", "Token / match");
            SetupGraph(g);

            var lst = r.Results.Select(i => (double)i.TokenCount / (double)i.MatchCount).OrderBy(i => i).ToArray();

            var c = g.AddCurve("Token / match",
                Enumerable.Range(1, lst.Length).Select(i => (double)i).ToArray(),
                lst,
                Color.Red);
            c.Symbol.IsVisible = false;

            #if SHOW_DERIVATION_2
            var derv_2 = lst.CalcDerv2();
            c = g.AddCurve("Derivation 2",
                Enumerable.Range(1, derv_2.Length).Select(i => (double)i).ToArray(),
                derv_2.ToArray(),
                Color.Green);
            c.IsY2Axis = true;
            c.Symbol.IsVisible = false;
            #endif

            AddLine(g, r.AVG_TokenPerMatch, Color.Blue, "Avg");
            AddLine(g, r.POI_TokenPerMatch, Color.Green, "POI");

            g.AxisChange();
            using (var img = g.GetImage())
            {
                img.Save(Path.Combine(OutPath, "TokenMatchGraph.png"), ImageFormat.Png);
            }
        }
Esempio n. 54
0
        /// <summary>
        /// Renders the demo graph with one call.
        /// </summary>
        /// <param name="g">A <see cref="Graphics"/> object for which the drawing will be done.</param>
        /// <param name="pane">A reference to the <see cref="GraphPane"/></param>
        public static void RenderDemo( Graphics g, GraphPane pane )
        {
            // Set the titles and axis labels
            pane.Title.Text = "Wacky Widget Company\nProduction Report";
            pane.XAxis.Title.Text = "Time, Days\n(Since Plant Construction Startup)";
            pane.YAxis.Title.Text = "Widget Production\n(units/hour)";

            LineItem curve;

            // Set up curve "Larry"
            double[] x = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y = { 20, 10, 50, 25, 35, 75, 90, 40, 33, 50 };
            // Use green, with circle symbols
            curve = pane.AddCurve( "Larry", x, y, Color.Green, SymbolType.Circle );
            curve.Line.Width = 1.5F;
            // Fill the area under the curve with a white-green gradient
            curve.Line.Fill = new Fill( Color.White, Color.FromArgb( 60, 190, 50 ), 90F );
            // Make it a smooth line
            curve.Line.IsSmooth = true;
            curve.Line.SmoothTension = 0.6F;
            // Fill the symbols with white
            curve.Symbol.Fill = new Fill( Color.White );
            curve.Symbol.Size = 10;

            // Second curve is "moe"
            double[] x3 = { 150, 250, 400, 520, 780, 940 };
            double[] y3 = { 5.2, 49.0, 33.8, 88.57, 99.9, 36.8 };
            // Use a red color with triangle symbols
            curve = pane.AddCurve( "Moe", x3, y3, Color.FromArgb( 200, 55, 135 ), SymbolType.Triangle );
            curve.Line.Width = 1.5F;
            // Fill the area under the curve with semi-transparent pink using the alpha value
            curve.Line.Fill = new Fill( Color.White, Color.FromArgb( 160, 230, 145, 205 ), 90F );
            // Fill the symbols with white
            curve.Symbol.Fill = new Fill( Color.White );
            curve.Symbol.Size = 10;

            // Third Curve is a bar, called "Wheezy"
            double[] x4 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y4 = { 30, 45, 53, 60, 75, 83, 84, 79, 71, 57 };
            BarItem bar = pane.AddBar( "Wheezy", x4, y4, Color.SteelBlue );
            // Fill the bars with a RosyBrown-White-RosyBrown gradient
            bar.Bar.Fill = new Fill( Color.RosyBrown, Color.White, Color.RosyBrown );

            // Fourth curve is a bar
            double[] x2 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y2 = { 10, 15, 17, 20, 25, 27, 29, 26, 24, 18 };
            bar = pane.AddBar( "Curly", x2, y2, Color.RoyalBlue );
            // Fill the bars with a RoyalBlue-White-RoyalBlue gradient
            bar.Bar.Fill = new Fill( Color.RoyalBlue, Color.White, Color.RoyalBlue );

            // Fill the pane background with a gradient
            pane.Fill = new Fill( Color.WhiteSmoke, Color.Lavender, 0F );
            // Fill the axis background with a gradient
            pane.Chart.Fill = new Fill( Color.FromArgb( 255, 255, 245 ),
                Color.FromArgb( 255, 255, 190 ), 90F );

            // Make each cluster 100 user scale units wide.  This is needed because the X Axis
            // type is Linear rather than Text or Ordinal
            pane.BarSettings.ClusterScaleWidth = 100;
            // Bars are stacked
            pane.BarSettings.Type = BarType.Stack;

            // Enable the X and Y axis grids
            pane.XAxis.MajorGrid.IsVisible = true;
            pane.YAxis.MajorGrid.IsVisible = true;

            // Manually set the scale maximums according to user preference
            pane.XAxis.Scale.Max = 1200;
            pane.YAxis.Scale.Max = 120;

            // Add a text item to decorate the graph
            TextObj text = new TextObj( "First Prod\n21-Oct-93", 175F, 80.0F );
            // Align the text such that the Bottom-Center is at (175, 80) in user scale coordinates
            text.Location.AlignH = AlignH.Center;
            text.Location.AlignV = AlignV.Bottom;
            text.FontSpec.Fill = new Fill( Color.White, Color.PowderBlue, 45F );
            text.FontSpec.StringAlignment = StringAlignment.Near;
            pane.GraphObjList.Add( text );

            // Add an arrow pointer for the above text item
            ArrowObj arrow = new ArrowObj( Color.Black, 12F, 175F, 77F, 100F, 45F );
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            pane.GraphObjList.Add( arrow );

            // Add a another text item to to point out a graph feature
            text = new TextObj( "Upgrade", 700F, 50.0F );
            // rotate the text 90 degrees
            text.FontSpec.Angle = 90;
            // Align the text such that the Right-Center is at (700, 50) in user scale coordinates
            text.Location.AlignH = AlignH.Right;
            text.Location.AlignV = AlignV.Center;
            // Disable the border and background fill options for the text
            text.FontSpec.Fill.IsVisible = false;
            text.FontSpec.Border.IsVisible = false;
            pane.GraphObjList.Add( text );

            // Add an arrow pointer for the above text item
            arrow = new ArrowObj( Color.Black, 15, 700, 53, 700, 80 );
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            arrow.Line.Width = 2.0F;
            pane.GraphObjList.Add( arrow );

            // Add a text "Confidential" stamp to the graph
            text = new TextObj( "Confidential", 0.85F, -0.03F );
            // use ChartFraction coordinates so the text is placed relative to the ChartRect
            text.Location.CoordinateFrame = CoordType.ChartFraction;
            // rotate the text 15 degrees
            text.FontSpec.Angle = 15.0F;
            // Text will be red, bold, and 16 point
            text.FontSpec.FontColor = Color.Red;
            text.FontSpec.IsBold = true;
            text.FontSpec.Size = 16;
            // Disable the border and background fill options for the text
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Fill.IsVisible = false;
            // Align the text such the the Left-Bottom corner is at the specified coordinates
            text.Location.AlignH = AlignH.Left;
            text.Location.AlignV = AlignV.Bottom;
            pane.GraphObjList.Add( text );

            // Add a BoxObj to show a colored band behind the graph data
            BoxObj box = new BoxObj( 0, 110, 1200, 10,
                Color.Empty, Color.FromArgb( 225, 245, 225 ) );
            box.Location.CoordinateFrame = CoordType.AxisXYScale;
            // Align the left-top of the box to (0, 110)
            box.Location.AlignH = AlignH.Left;
            box.Location.AlignV = AlignV.Top;
            // place the box behind the axis items, so the grid is drawn on top of it
            box.ZOrder = ZOrder.D_BehindAxis;
            pane.GraphObjList.Add( box );

            // Add some text inside the above box to indicate "Peak Range"
            TextObj myText = new TextObj( "Peak Range", 1170, 105 );
            myText.Location.CoordinateFrame = CoordType.AxisXYScale;
            myText.Location.AlignH = AlignH.Right;
            myText.Location.AlignV = AlignV.Center;
            myText.FontSpec.IsItalic = true;
            myText.FontSpec.IsBold = false;
            myText.FontSpec.Fill.IsVisible = false;
            myText.FontSpec.Border.IsVisible = false;
            pane.GraphObjList.Add( myText );

            pane.AxisChange( g );
        }
 public bool AddCurve(string label, Color color)
 {
     PointsLists.Add(new RollingPointPairList(defaultCurveCapacity));
     myPane.AddCurve(label, PointsLists.Last(), color, SymbolType.None);
     return(true);
 }
Esempio n. 56
0
        public static void DrawingWell()//画图well
        {
            MySqlConnection mycon = new MySqlConnection();

            mycon = getMycon();
            ZedGraph.GraphPane myPane = MainForm.getInstance().WellTM.GraphPane;

            MainForm.getInstance().WellTM.PointValueEvent += new ZedGraphControl.PointValueHandler(ZedGraphClass.MyPointValueHandlerWell); //设置节点信息显示样式
            MainForm.getInstance().WellTM.IsShowPointValues = true;                                                                        //
            MainForm.getInstance().WellTM.MouseMove += zedGraphControl1_MouseMove;                                                         //鼠标在图上移动出现x虚线
            myPane.CurveList.Clear();                                                                                                      //清除上一步画的图

            //float WellK = float.Parse(MainForm.getInstance().nn1.Text.ToString());//井套管的线宽度
            //float WellD = float.Parse(MainForm.getInstance().nn2.Text.ToString());//井套管的线的节点大小
            float WellK = 2;
            float WellD = 1;

            if (MainForm.getInstance().Diameter1.Text != "" && MainForm.getInstance().Diameter2.Text != "" && MainForm.getInstance().Diameter3.Text != "" && MainForm.getInstance().Diameter4.Text != "")
            {
                try
                {
                    float Diameter1 = float.Parse(MainForm.getInstance().Diameter1.Text.ToString()); //隔水导管直径
                    float Diameter2 = float.Parse(MainForm.getInstance().Diameter2.Text.ToString()); //表层套管直径
                    float Diameter3 = float.Parse(MainForm.getInstance().Diameter3.Text.ToString()); //技术套管直径
                    float Diameter4 = float.Parse(MainForm.getInstance().Diameter4.Text.ToString()); //油管直径
                    float b1        = Diameter1 / Diameter4;                                         //隔水导管
                    float b2        = Diameter2 / Diameter4;
                    float b3        = Diameter3 / Diameter4;                                         //技术套管
                }
                catch { }

                //SymbolType c=new SymbolType();
                //object h = SymbolType.Circle;
                //c = (SymbolType)h;
                if (MainForm.getInstance().Length1.Text != "" && MainForm.getInstance().Length2.Text != "" && MainForm.getInstance().Length3.Text != "")
                {
                    float Length1 = 0;
                    float Length2 = 0;
                    float Length3 = 0;
                    try
                    {
                        Length1 = float.Parse(MainForm.getInstance().Length1.Text.ToString()); //隔水导管长度
                        Length2 = float.Parse(MainForm.getInstance().Length2.Text.ToString()); //表层套管长度
                        Length3 = float.Parse(MainForm.getInstance().Length3.Text.ToString()); //技术套管长度
                    }
                    catch
                    {
                        MessageBox.Show("长度填写不是小数或整数,图像生成会不完整!");
                    }


                    try
                    {
                        string Str = getWellStr();
                        if (Str == null)
                        {
                            MessageBox.Show("该时间点之后时间无温度数据");
                        }
                        else
                        {
                            string l = Str + " order by TM";
                            System.Data.DataTable dt1 = getDataTable(l, mycon);
                            float Min = float.Parse(dt1.Rows[0][4].ToString());
                            float Max = float.Parse(dt1.Rows[dt1.Rows.Count - 1][4].ToString());
                            int   max = (int)(Max + 0.5);
                            int   min = (int)(Min - 0.5);
                            MainForm.getInstance().label104.Text = min + "℃";
                            MainForm.getInstance().label105.Text = max + "℃";
                            getsejie(max, min);
                            System.Data.DataTable dt = getDataTable(Str, mycon);
                            DataTable             dt2 = getDatatable(dt, 20);
                            //  string  vv=dt.Rows[dt.Rows.Count-1][1].ToString();
                            float v1  = float.Parse(dt.Rows[dt.Rows.Count - 1][1].ToString());
                            float v2  = float.Parse(dt.Rows[dt.Rows.Count - 1][2].ToString());
                            int   Num = 300;
                            if (v1 > v2)
                            {
                                Num = (int)v1 * 1 / 6;
                            }
                            else
                            {
                                Num = (int)v2 * 1 / 6;
                            }
                            myPane.X2Axis.Scale.Min = 0;
                            myPane.X2Axis.Scale.Max = Num * 8;
                            myPane.YAxis.Scale.Min  = 0;
                            myPane.YAxis.Scale.Max  = Num * 7;
                            // myPane.AxisChange();
                            //int Num = 300;//画图时井口的位置偏移程度(防止井身贴着Y轴)
                            DataTable dt3 = getDatatable(dt, (20 + 40));
                            DataTable dt4 = getDatatable(dt, (-22 - 40));
                            DataTable dt5 = getDatatable(dt, (20 + 80));
                            DataTable dt6 = getDatatable(dt, (-22 - 80));
                            DataTable dt7 = getDatatable(dt, (20 + 120));
                            DataTable dt8 = getDatatable(dt, (-22 - 120));

                            //DataTable dt3 = getDatatable(dt, (10 + 40 * 1));
                            //DataTable dt4 = getDatatable(dt, (-12 - 40 * 1));
                            //DataTable dt5 = getDatatable(dt, (10 + 40 * 2));
                            //DataTable dt6 = getDatatable(dt, (-12 - 40 * 2));
                            //DataTable dt7 = getDatatable(dt, (10 + 40 * 3));
                            //DataTable dt8 = getDatatable(dt, (-12 - 40 * 3));
                            myPane.Fill       = new Fill(Color.White, Color.FromArgb(200, 200, 255), 45.0f); //控件颜色填充
                            myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0f);    //画板颜色填充

                            //myPane.X2Axis.Scale.Min = 0;
                            //myPane.X2Axis.Scale.Max =1500;
                            myPane.Legend.IsVisible           = false; //图例是不可见的
                            myPane.YAxis.Scale.IsReverse      = true;  //Y轴值翻转,图像一样翻转
                            myPane.YAxis.MinorTic.IsOpposite  = false; //Y轴对面的小刻度是否可见
                            myPane.YAxis.MajorTic.IsOpposite  = false; //Y轴对面的大刻度是否可见
                            myPane.X2Axis.IsVisible           = true;
                            myPane.X2Axis.Title.IsVisible     = true;
                            myPane.XAxis.IsVisible            = false; //下方X轴消失
                            myPane.X2Axis.IsVisible           = false; //下方X轴消失
                            myPane.X2Axis.MinorTic.IsOpposite = false; //X轴对面的小刻度是否可见
                            myPane.X2Axis.MajorTic.IsOpposite = false; //X轴对面的大刻度是否可见
                            myPane.YAxis.MinorTic.IsOutside   = false; //IsOutside ->> 刻度条是否要显示到坐标轴的外边。
                            myPane.YAxis.MajorTic.IsOutside   = false; //IsOutside ->> 刻度条是否要显示到坐标轴的外边。
                            myPane.X2Axis.MinorTic.IsOutside  = false; //IsOutside ->> 刻度条是否要显示到坐标轴的外边。
                            myPane.X2Axis.MajorTic.IsOutside  = false; //IsOutside ->> 刻度条是否要显示到坐标轴的外边。
                            myPane.X2Axis.MinorTic.IsInside   = false; //IsInside ->> 刻度条是否要显示到坐标轴的里边。
                            myPane.X2Axis.MajorTic.IsInside   = false; //IsInside ->> 刻度条是否要显示到坐标轴的里边。

                            //内外边框设置
                            MainForm.getInstance().WellTM.MasterPane.Border.IsVisible = true;

                            //为chart 设置坐标值,大小

                            int jishu = max - min;
                            int w     = 0;
                            for (int j = 0; j < dt.Rows.Count; j++)                                  //
                            {
                                int           a     = (int)float.Parse(dt.Rows[j]["TM"].ToString()); //温度取整数
                                string        name  = dt.Rows[j]["TM"].ToString() + "$" + j;
                                PointPairList list1 = new PointPairList();
                                double        x     = float.Parse(dt.Rows[j]["DepthH"].ToString()) + Num;
                                double        y     = float.Parse(dt.Rows[j]["TVD"].ToString());
                                double        x2    = float.Parse(dt2.Rows[j]["fb"].ToString()) + Num;
                                double        y2    = float.Parse(dt2.Rows[j]["fc"].ToString());
                                list1.Add(x, y);
                                list1.Add(x2, y2);
                                Color c1; Color c2;
                                a = a - min;
                                //if (a == 69)
                                //{
                                //    int k = 0;
                                //}
                                float b = (float)a / jishu;
                                float t = (float)1 / (float)3;
                                if (b <= t)
                                {
                                    w  = 1;
                                    c1 = Color.Blue;
                                    c2 = Color.Cyan;
                                }
                                else if (b > t && b <= 2 * t)
                                {
                                    w  = 2;
                                    c1 = Color.Cyan;
                                    c2 = Color.Yellow;
                                }
                                else
                                {
                                    w  = 3;
                                    c1 = Color.Yellow;
                                    c2 = Color.Red;
                                }
                                LineItem myCurve = myPane.AddCurve(name,
                                                                   list1, getColorTM(a, max, min, c1, c2, w), SymbolType.Circle);
                                myCurve.Line.Width  = 2f;
                                myCurve.Symbol.Size = 7.0F;                                         //线上节点的大小
                                myCurve.Symbol.Fill = new Fill(getColorTM(a, max, min, c1, c2, w)); //线上节点的颜色
                                myCurve.IsX2Axis    = true;                                         //手动改为按【X2Axis】的刻度描画
                                //myPane.AxisChange();
                            }
                            //技术套管上面的线
                            PointPairList list3 = new PointPairList();
                            int           a3; float x3; float y3;
                            for (int j = 0; j < dt.Rows.Count - 10; j++)//
                            {
                                if (j < 1000)
                                {
                                    if (j % 15 == 0 && j < Length3)
                                    {
                                        a3 = (int)float.Parse(dt.Rows[j]["TM"].ToString());//温度取整数
                                        x3 = float.Parse(dt3.Rows[j]["fb"].ToString()) + Num + 25;
                                        y3 = float.Parse(dt3.Rows[j]["fc"].ToString());
                                        list3.Add(x3, y3);
                                    }
                                }
                                else if (800 <= j && j < 1000)
                                {
                                    if (j % 15 == 0 && j < Length3)
                                    {
                                        a3 = (int)float.Parse(dt.Rows[j]["TM"].ToString());//温度取整数
                                        x3 = float.Parse(dt3.Rows[j]["fb"].ToString()) + Num + 25;
                                        y3 = float.Parse(dt3.Rows[j]["fc"].ToString()) - 5;
                                        list3.Add(x3, y3);
                                    }
                                }
                                else if (1000 <= j && j < 1200)
                                {
                                    if (j % 15 == 0 && j < Length3)
                                    {
                                        a3 = (int)float.Parse(dt.Rows[j]["TM"].ToString());//温度取整数
                                        x3 = float.Parse(dt3.Rows[j]["fb"].ToString()) + Num + 25;
                                        y3 = float.Parse(dt3.Rows[j]["fc"].ToString()) - 10;
                                        list3.Add(x3, y3);
                                    }
                                }
                                else
                                {
                                    if (j % 15 == 0 && j < Length3)
                                    {
                                        a3 = (int)float.Parse(dt.Rows[j]["TM"].ToString());//温度取整数
                                        x3 = float.Parse(dt3.Rows[j]["fb"].ToString()) + Num + 25;
                                        y3 = float.Parse(dt3.Rows[j]["fc"].ToString()) - 15;
                                        list3.Add(x3, y3);
                                    }
                                }
                            }
                            LineItem myCurve3 = myPane.AddCurve("Porsche", list3, Color.Black, SymbolType.Circle);
                            myCurve3.Line.Width  = WellK;
                            myCurve3.Symbol.Size = WellD; //线上节点的大小
                            // myCurve1.Symbol.Fill = new Fill(getColor(a, max, min));//线上节点的颜色
                            myCurve3.IsX2Axis = true;     //手动改为按【X2Axis】的刻度描画
                            // myPane.AxisChange();
                            //技术套管下面的线
                            PointPairList list4 = new PointPairList();
                            int           a4; float x4; float y4;
                            for (int j = 0; j < dt.Rows.Count; j++)//
                            {
                                if (j % 15 == 0 && j < Length3)
                                {
                                    a4 = (int)float.Parse(dt.Rows[j]["TM"].ToString());//温度取整数
                                    x4 = float.Parse(dt4.Rows[j]["fb"].ToString()) + Num;
                                    y4 = float.Parse(dt4.Rows[j]["fc"].ToString());
                                    list4.Add(x4, y4);
                                }
                            }
                            LineItem myCurve4 = myPane.AddCurve("Porsche", list4, Color.Black, SymbolType.Circle);
                            myCurve4.Line.Width  = WellK;
                            myCurve4.Symbol.Size = WellD; //线上节点的大小
                            // myCurve1.Symbol.Fill = new Fill(getColor(a, max, min));//线上节点的颜色
                            myCurve4.IsX2Axis = true;     //手动改为按【X2Axis】的刻度描画
                            //myPane.AxisChange();

                            //表层套管上面的线
                            PointPairList list5 = new PointPairList();
                            int           a5; float x5; float y5;
                            for (int j = 0; j < dt.Rows.Count; j++)//
                            {
                                if (j % 15 == 0 && j < (Length2 + 15))
                                {
                                    a5 = (int)float.Parse(dt.Rows[j]["TM"].ToString());        //温度取整数
                                    x5 = float.Parse(dt5.Rows[j]["fb"].ToString()) + Num + 20; //+10是为了使得油管在表层套管中间
                                    y5 = float.Parse(dt5.Rows[j]["fc"].ToString());
                                    list5.Add(x5, y5);
                                }
                            }
                            LineItem myCurve5 = myPane.AddCurve("Porsche", list5, Color.Black, SymbolType.Circle);
                            myCurve5.Line.Width  = WellK;
                            myCurve5.Symbol.Size = WellD; //线上节点的大小
                            // myCurve1.Symbol.Fill = new Fill(getColor(a, max, min));//线上节点的颜色
                            myCurve5.IsX2Axis = true;     //手动改为按【X2Axis】的刻度描画
                            //  myPane.AxisChange();
                            //表层套管下面的线
                            PointPairList list6 = new PointPairList();

                            int a6; float x6; float y6;
                            for (int j = 0; j < dt.Rows.Count; j++)//
                            {
                                if (j % 15 == 0 && j < (Length2 + 15))
                                {
                                    a6 = (int)float.Parse(dt.Rows[j]["TM"].ToString());//温度取整数
                                    x6 = float.Parse(dt6.Rows[j]["fb"].ToString()) + Num;
                                    y6 = float.Parse(dt6.Rows[j]["fc"].ToString());
                                    list6.Add(x6, y6);
                                }
                            }
                            LineItem myCurve6 = myPane.AddCurve("Porsche", list6, Color.Black, SymbolType.Circle);
                            myCurve6.Line.Width  = WellK;
                            myCurve6.Symbol.Size = WellD; //线上节点的大小
                            // myCurve1.Symbol.Fill = new Fill(getColor(a, max, min));//线上节点的颜色
                            myCurve6.IsX2Axis = true;     //手动改为按【X2Axis】的刻度描画
                            // myPane.AxisChange();

                            //隔水导管上面的线
                            PointPairList list7 = new PointPairList();
                            int           a7; float x7; float y7;
                            for (int j = 0; j < dt.Rows.Count; j++)//
                            {
                                if (j % 15 == 0 && j < (Length1 + 15))
                                {
                                    a7 = (int)float.Parse(dt.Rows[j]["TM"].ToString());//温度取整数
                                    x7 = float.Parse(dt7.Rows[j]["fb"].ToString()) + Num + 20;
                                    y7 = float.Parse(dt7.Rows[j]["fc"].ToString());
                                    //x7  = float.Parse(dt.Rows[j]["DepthH"].ToString()) + Num+200;
                                    //y7 = float.Parse(dt.Rows[j]["TVD"].ToString());
                                    list7.Add(x7, y7);
                                }
                            }
                            LineItem myCurve7 = myPane.AddCurve("Porsche", list7, Color.Black, SymbolType.Circle);
                            myCurve7.Line.Width  = WellK;
                            myCurve7.Symbol.Size = WellD; //线上节点的大小
                            // myCurve1.Symbol.Fill = new Fill(getColor(a, max, min));//线上节点的颜色
                            myCurve7.IsX2Axis = true;     //手动改为按【X2Axis】的刻度描画
                            // myPane.AxisChange();


                            //隔水导管下面的线
                            PointPairList list8 = new PointPairList();
                            int           a8; float x8; float y8;
                            for (int j = 0; j < dt.Rows.Count; j++)//
                            {
                                if (j % 15 == 0 && j < (Length1 + 15))
                                {
                                    a8 = (int)float.Parse(dt.Rows[j]["TM"].ToString());//温度取整数
                                    x8 = float.Parse(dt8.Rows[j]["fb"].ToString()) + Num;
                                    y8 = float.Parse(dt8.Rows[j]["fc"].ToString());
                                    //x8 = float.Parse(dt.Rows[j]["DepthH"].ToString()) + Num-200;
                                    //y8 = float.Parse(dt.Rows[j]["TVD"].ToString());
                                    list8.Add(x8, y8);
                                }
                            }
                            LineItem myCurve8 = myPane.AddCurve("Porsche", list8, Color.Black, SymbolType.Circle);
                            myCurve8.Line.Width  = WellK;
                            myCurve8.Symbol.Size = WellD; //线上节点的大小
                            // myCurve1.Symbol.Fill = new Fill(getColor(a, max, min));//线上节点的颜色
                            myCurve8.IsX2Axis = true;     //手动改为按【X2Axis】的刻度描画
                            myPane.AxisChange();
                            //顶峰
                            try
                            {
                                PointPairList list9 = new PointPairList();
                                float         x91;
                                float         x92;
                                float         y91;
                                float         y92;
                                // a9 = (int)float.Parse(dt.Rows[j]["TM"].ToString());//温度取整数
                                x91 = float.Parse(dt4.Rows[int.Parse(MainForm.getInstance().dingfeng.Text)]["fb"].ToString()) + Num;
                                y91 = float.Parse(dt4.Rows[int.Parse(MainForm.getInstance().dingfeng.Text)]["fc"].ToString());
                                //x8 = float.Parse(dt.Rows[j]["DepthH"].ToString()) + Num-200;
                                //y8 = float.Parse(dt.Rows[j]["TVD"].ToString());
                                list9.Add(x91, y91);
                                x92 = float.Parse(dt3.Rows[int.Parse(MainForm.getInstance().dingfeng.Text)]["fb"].ToString()) + Num;
                                y92 = float.Parse(dt3.Rows[int.Parse(MainForm.getInstance().dingfeng.Text)]["fc"].ToString()) - 20;
                                //x8 = float.Parse(dt.Rows[j]["DepthH"].ToString()) + Num-200;
                                //y8 = float.Parse(dt.Rows[j]["TVD"].ToString());
                                list9.Add(x92, y92);
                                LineItem myCurve9 = myPane.AddCurve("Porsche", list9, Color.Blue, SymbolType.Square);
                                myCurve9.Line.Width  = 5;
                                myCurve9.Symbol.Size = 5;                    //线上节点的大小
                                myCurve9.Symbol.Fill = new Fill(Color.Blue); //线上节点的颜色
                                myCurve9.IsX2Axis    = true;                 //手动改为按【X2Axis】的刻度描画
                                myPane.AxisChange();
                            }
                            catch
                            {
                                MessageBox.Show("顶峰深度不正确");
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("数据不正确/未导入数据/时间点无数据" + e);
                    }

                    MainForm.getInstance().WellTM.Refresh();
                }
                else
                {
                    MessageBox.Show("各个套管的深度未全部填写");
                }
            }
            else
            {
                MessageBox.Show("各个套管的直径未全部填写");
            }
            MainForm.getInstance().groupBox8.Enabled = true;
        }
        private void button3_Click(object sender, EventArgs e)
        {
            panellllacccdevre3.Visible = true;
            double Ie, Avs, A, Ic, Imax, e0, ein, Re, Ib, Vth, VceAC, IcAC, Rth, Vin, Rc, Re1, Re2, Vcc, Vce, Vbe, rdd, rb, beta, R1, v0, R2, RL, Rs, Res, gm, rin, Rin;

            try
            {
                rb   = Convert.ToDouble(txtdevre3rbb.Text) * 1000;
                rdd  = Convert.ToDouble(txtdevre3rd.Text) * 1000;
                Rc   = Convert.ToDouble(txtdevre3rc.Text) * 1000;
                R1   = Convert.ToDouble(txtdevre3rb1.Text) * 1000;
                R2   = Convert.ToDouble(txtdevre3Rb2.Text) * 1000;
                Re1  = Convert.ToDouble(txtdevre3Re1.Text) * 1000;
                Re2  = Convert.ToDouble(txtdevre3Re2.Text) * 1000;
                Vcc  = Convert.ToDouble(txtdevre3Vcc.Text);
                beta = Convert.ToDouble(txtdevre3beta.Text);
                Vbe  = Convert.ToDouble(txtdevre3vbe.Text);
                Rs   = Convert.ToDouble(txtdevre3Rs.Text) * 1000;
                RL   = Convert.ToDouble(txtdevre3rL.Text) * 1000;
                ein  = Convert.ToDouble(txtdevre3Ein.Text);
                Re   = Re1 + Re2;
                Vth  = R2 * Vcc / (R1 + R2);
                Rth  = R2 * R1 / (R1 + R2);
                Ib   = (Vth - Vbe) / (Rth + (beta + 1) * Re);
                Ie   = (beta + 1) * Ib;
                Ic   = Ie - Ib;
                Vce  = Vcc - Ic * Rc - Ie * Re;
                Imax = Vcc / (Rc + Re);
                Imax = Imax * 1000;

                rin   = rb + (beta + 1) * (rdd + Re1);
                Rin   = (Rth * rin) / (Rth + rin);
                Res   = (Rc * RL) / (Rc + RL);
                A     = -beta * Res / rin;
                Avs   = (Rin * A) / (Rin + Rs);
                e0    = ein * Avs;
                VceAC = Vce + Ic * Res;
                IcAC  = Ic + Vce / Res;

                IcAC = IcAC * 1000;
                Ic   = Ic * 1000;

                lbldevre3Avs.Text      = " = " + Avs.ToString();
                lbldevre3e0.Text       = " = " + e0.ToString() + "mV";
                lbldevre3Rin.Text      = " = " + (Math.Pow(10, -3) * Rin).ToString() + "kOhm";
                lbldevre3kücükrin.Text = " = " + (Math.Pow(10, -3) * rin).ToString() + "kOhm";
                lbldevre3rES.Text      = "=" + (Math.Pow(10, -3) * Res).ToString() + "kOhm";
                lbldevre3A.Text        = "=" + A.ToString() + "Avs";
                ZedGraph.ZedGraphControl g = new ZedGraph.ZedGraphControl();
                g.Size = new Size(panel8.Width - 2, panel8.Height - 2);
                ZedGraph.GraphPane myGraphPane = g.GraphPane;
                myGraphPane.Title.Text       = "Ac-Dc yük eğrisi ";
                myGraphPane.XAxis.Title.Text = "Volt (V)";
                myGraphPane.YAxis.Title.Text = "Akım(ma)";
                PointPairList list1 = new PointPairList();
                myGraphPane.AddCurve("", new double[] { 0, VceAC }, new double[] { IcAC, 0 }, Color.Blue, ZedGraph.SymbolType.None);
                myGraphPane.AddCurve("", new double[] { 0, Vcc }, new double[] { Imax, 0 }, Color.Blue, ZedGraph.SymbolType.None);

                myGraphPane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.Red, 3.0f);

                g.AxisChange();

                panel8.Controls.Add(g);
            }
            catch (Exception)
            {
                Form1.HataMesaji();
            }
        }
Esempio n. 58
0
        private void btnSolveRK_Click(object sender, EventArgs e)
        {
            this.rtbResult1.Text      = this.rtbResult2.Text = string.Empty;
            this.dgvTabRes.DataSource = null;
            this.n        = int.Parse(this.txtN.Text);
            this.setCount = this.rbN1.Checked ? 1 : 2;
            //this.gamma = double.Parse(txtGamma.Text);

            ZedGraph.GraphPane gp = this.zgcMainChart2.GraphPane;
            gp.CurveList.Clear();
            this.curves.Clear();

            this.curves.Add(this.curveName, new PointPairList());
            gp.AddCurve(this.curveName, this.curves[curveName], Color.Black, SymbolType.None);


            List <double> gammaList = new List <double>();
            List <double> p         = new List <double>();

            for (int i = 0; i < dgvGama.ColumnCount; i++)
            {
                gammaList.Add(Convert.ToDouble(dgvGama.Rows[0].Cells[i].Value));
            }

            List <TaskParameter> list = new List <TaskParameter>();

            for (int i = 0; i < dgvParameters.RowCount; i++)
            {
                TaskParameter tp = new TaskParameter(dgvParameters.ColumnCount);
                for (int j = 0; j < dgvParameters.ColumnCount; j++)
                {
                    double val = Convert.ToDouble(dgvParameters.Rows[i].Cells[j].Value);
                    tp.Param[j] = val;
                }
                list.Add(tp);
            }

            this.tps = new TaskParameters(list, gammaList);
            string mfName = this.setCount == 1 ? "MF1" : "MF2";

            this.funcDescr = new Functions_2_2(mfName, this.fnames[(sfList.SelectedItem as string).ToUpper()]);

            this.tw = new TaskWorker(tps, funcDescr.GetType(), funcDescr.MainFuncName, funcDescr.SecFuncName, funcDescr);


            this.startVector = this.setCount == 1 ? new Vector(1, double.Parse(this.txtY0.Text)) :
                               new Vector(2, double.Parse(this.txtY00.Text), double.Parse(this.txtY01.Text));

            RKVectorForm rk = new RKVectorForm(tw, curveName, double.Parse(this.txtT0.Text), double.Parse(this.txtT1.Text), startVector);

            this.res = rk.SolveWithConstH(n, RKMetodType.RK4_1);

            if (this.rbN1.Checked)
            {
                res.ForEach(r => this.curves[curveName].Add(r.X, r.Y[0]));
            }
            else
            {
                res.ForEach(r => this.curves[curveName].Add(r.Y[0], r.Y[1]));
            }
            this.zgcMainChart2.AxisChange();
            this.zgcMainChart2.Refresh();


            if (this.setCount == 1)
            {
                this.tblResList = new List <ResPointViewType1>();
                for (int i = 0; i < res.Count - 1; i++)
                {
                    (this.tblResList as List <ResPointViewType1>).Add(new ResPointViewType1(res[i].X, res[i].Y[0], -1, -1));
                }
                this.dgvTabRes.DataSource = null;
                this.dgvTabRes.DataSource = tblResList;
            }
            else
            {
                this.tblResList = new List <ResPointViewType2>();
                for (int i = 0; i < res.Count - 2; i++)
                {
                    (this.tblResList as List <ResPointViewType2>).Add(new ResPointViewType2(res[i].X, res[i].Y[0], res[i].Y[1], -1, -1));
                }
                this.dgvTabRes.DataSource = null;
                this.dgvTabRes.DataSource = tblResList;
            }
            this.dgvTabRes.RefreshDataSource();

            this.randomStartParameters = this.GetRandomStartParam();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            panelaccdevree12.Visible = true;

            double Ie, Avs, A, Ic, e0, ein, Imax, Ib, Vth, VceAC, IcAC, Rth, Vin, Rc, Re, Vcc, Vce, Vbe, rdd, rb, beta, R1, v0, R2, RL, Rs, Res, gm, rin, Rin;

            try
            {
                rb   = Convert.ToDouble(txtemitertekkatrbb.Text) * 1000;
                rdd  = Convert.ToDouble(txtemitertekkatrd.Text) * 1000;
                Rc   = Convert.ToDouble(txtemitertekkatRc.Text) * 1000;
                R1   = Convert.ToDouble(txtemitertekkatR1.Text) * 1000;
                R2   = Convert.ToDouble(txtemitertekkatR2.Text) * 1000;
                Re   = Convert.ToDouble(txtemitertekkatrE.Text) * 1000;
                Vcc  = Convert.ToDouble(txtemitertekkatVcc.Text);
                beta = Convert.ToDouble(txtemitertekkatBeta.Text);
                Vbe  = Convert.ToDouble(txtemitertekkatVbe.Text);
                Rs   = Convert.ToDouble(txtemitertekkatRs.Text) * 1000;
                RL   = Convert.ToDouble(txtemitertekkatRl.Text) * 1000;
                ein  = Convert.ToDouble(txtemiterein.Text);
                if (rb > 0 & Rc > 0 & rdd > 0 & Re > 0 & Rs > 0 & RL > 0 & Vbe > 0 & R1 > 0 & R2 > 0)
                {
                    Vth = R2 * Vcc / (R1 + R2);
                    Rth = R2 * R1 / (R1 + R2);
                    Ib  = (Vth - Vbe) / (Rth + (beta + 1) * Re);
                    Ie  = (beta + 1) * Ib;
                    Ic  = Ie - Ib;
                    Vce = Vcc - Ic * Rc - Ie * Re;

                    rin   = rb + (beta + 1) * rdd;
                    Rin   = (Rth * rin) / (Rth + rin);
                    Res   = (Rc * RL) / (Rc + RL);
                    A     = -beta * Res / rin;
                    Avs   = (Rin * A) / (Rin + Rs);
                    e0    = ein * Avs;
                    VceAC = Vce + Ic * Res;
                    IcAC  = Ic + Vce / Res;

                    IcAC = IcAC * 1000;
                    Ic   = Ic * 1000;
                    Imax = Vcc / (Rc + Re);
                    Imax = Imax * 1000;



                    lblemitertekkatAvs.Text = " = " + Math.Round(Avs, 3);
                    lblemitertekkate0.Text  = " = " + e0.ToString() + "mV";
                    lblemitertekkatRİN.Text = " = " + (Math.Pow(10, -3) * Rin).ToString() + "kOhm";
                    lblemitertekkatrin.Text = " = " + (Math.Pow(10, -3) * rin).ToString() + "kOhm";
                    lblemitertekkatRes.Text = "=" + (Math.Pow(10, -3) * Res).ToString() + "kOhm";
                    lblemitertekkatAv.Text  = "=" + A.ToString() + "Avs";
                    ZedGraph.ZedGraphControl g = new ZedGraph.ZedGraphControl();
                    g.Size = new Size(panel6.Width - 2, panel6.Height - 2);
                    ZedGraph.GraphPane myGraphPane = g.GraphPane;
                    myGraphPane.Title.Text       = "Ac-Dc yük eğrisi ";
                    myGraphPane.XAxis.Title.Text = "Volt (V)";
                    myGraphPane.YAxis.Title.Text = "Akım(ma)";
                    PointPairList list1 = new PointPairList();
                    myGraphPane.AddCurve("", new double[] { 0, VceAC }, new double[] { IcAC, 0 }, Color.Blue, ZedGraph.SymbolType.None);


                    myGraphPane.AddCurve("", new double[] { 0, Vcc }, new double[] { Imax, 0 }, Color.Blue, ZedGraph.SymbolType.None);


                    myGraphPane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.Red, 3.0f);

                    g.AxisChange();

                    panel6.Controls.Add(g);
                }

                else
                {
                    MessageBox.Show("hatalideger girdiniz:");
                }
            }
            catch (Exception)
            {
                Form1.HataMesaji();
            }
        }
 protected override Image DoCreateChartImage()
 {
     var pg = new GraphPane();
     var seria = new PointPairList();
     foreach (var pointPair in Parameters.SeriaData.Select(p => new PointPair(p.Key, p.Value)))
     {
         seria.Add(pointPair);
     }
     pg.AddCurve("Test", seria, Color.DeepSkyBlue);
     pg.AxisChange();
     Image tmpImage = new Bitmap(Parameters.ChartWidth, Parameters.ChartHeight);
     var g = Graphics.FromImage(tmpImage);
     pg.ReSize(g, new RectangleF(0, 0, Parameters.ChartWidth, Parameters.ChartHeight));
     pg.Draw(g);
     return tmpImage;
 }