示例#1
0
        /// <summary>
        /// Rescale font size of x axis labels when the graph is zoomed or resized.
        /// </summary>
        /// <param name="width">Width of the graph in pixels.</param>
        /// <param name="pane">GraphPane of the graph.</param>
        public static void ScaleAxisLabels(int width, GraphPane pane)
        {
            if (pane.XAxis.Scale.TextLabels == null)
                return;

            pane.XAxis.Scale.IsPreventLabelOverlap = false;
            int countLabels = (int) Math.Ceiling(pane.XAxis.Scale.Max - pane.XAxis.Scale.Min) + 1;

            float dxAvailable = (float) width / countLabels;

            var fontSpec = pane.XAxis.Scale.FontSpec;

            int pointSize;

            for (pointSize = 12; pointSize > 4; pointSize--)
            {
                using (var font = new Font(fontSpec.Family, pointSize))
                {
                    // See if the original labels fit with this font
                    int maxWidth = MaxWidth(font, pane.XAxis.Scale.TextLabels);
                    if (maxWidth <= dxAvailable)
                        break;
                }
            }

            pane.XAxis.Scale.FontSpec.Size = pointSize;
            pane.AxisChange();
        }
示例#2
0
文件: Form1.cs 项目: tomaszmat/code
        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();
        }
示例#3
0
        public ZedGraphControl()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            Rectangle rect = new Rectangle(0, 0, this.Size.Width, this.Size.Height);

            graphPane = new GraphPane(rect, "Title", "X-Axis", "Y-Axis");
            graphPane.AxisChange();
        }
示例#4
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();
        }
        private static void AxisChangeAndDraw(GraphPane myPane)
        {
            using (Bitmap b = new Bitmap(640, 480))
            {
                using (Graphics g = Graphics.FromImage(b))
                {
                    myPane.AxisChange(g);

                    myPane.Draw(g);
                }
            }
        }
示例#6
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public ZedGraphControl()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            // Use double-buffering for flicker-free updating:
            SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint
                     | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw, true);
            Rectangle rect = new Rectangle(0, 0, this.Size.Width - 1, this.Size.Height - 1);

            graphPane = new GraphPane(rect, "Title", "X-Axis", "Y-Axis");
            graphPane.AxisChange();
        }
 public void ResetAutoScale(GraphPane pane, Graphics g)
 {
     pane.XAxis.ResetAutoScale(pane, g, false);
     pane.X2Axis.ResetAutoScale(pane, g, false);
     foreach (YAxis axis in pane.YAxisList)
     {
         axis.ResetAutoScale(pane, g, false);
     }
     foreach (Y2Axis axis in pane.Y2AxisList)
     {
         axis.ResetAutoScale(pane, g, false);
     }
     pane.AxisChange(g);
 }
示例#8
0
        /// <summary>This performs an axis change command on the graphPane.
        /// This is the same as
        /// <c>ZedGraphControl.GraphPane.AxisChange( ZedGraphControl.CreateGraphics() )</c>.
        /// </summary>
        public virtual void AxisChange()
        {
            lock (this)
            {
                if (BeenDisposed)
                {
                    return;
                }

                Graphics g = this.CreateGraphics();

                graphPane.AxisChange(g);

                g.Dispose();
            }
        }
        public void GraphInit()
        {
            // Create a new graph
            //TODO: Allow graph to change size when widow is adjusted
            myPane = new ZedGraph.GraphPane(new Rectangle(0, 0, (int)Application.Current.MainWindow.Width, 325),
                                            "Allele Frequency\n",
                                            "Generations",
                                            "Frequency of A");

            myPane.XAxis.Max = generation.Value;
            myPane.XAxis.Min = 0;

            myPane.YAxis.Max = 1;
            myPane.YAxis.Min = 0;

            myPane.AxisChange(graphics);
        }
示例#10
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);
        }
示例#11
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public ZedGraphControl()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            // Use double-buffering for flicker-free updating:
            SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint
                     | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw, true);
            //isTransparentBackground = false;
            SetStyle(ControlStyles.Opaque, false);
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);

            Rectangle rect = new Rectangle(0, 0, this.Size.Width, this.Size.Height);

            graphPane = new GraphPane(rect, "Title", "X-Axis", "Y-Axis");
            graphPane.AxisChange(this.CreateGraphics());

            this.isShowPointValues = false;
            this.pointValueFormat  = PointPair.DefaultFormat;
        }
示例#12
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));
        }
示例#13
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));
        }
示例#14
0
        public void FindNearestObject()
        {
            testee = new GraphPane( new Rectangle( 10, 10, 10, 10 ),
            "Wacky Widget Company\nProduction Report",
            "Time, Days\n(Since Plant Construction Startup)",
            "Widget Production\n(units/hour)" );
            SetSize();

            double[] x = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y = { 20, 10, 50, 25, 35, 75, 90, 40, 33, 50 };
            LineItem curve;
            curve = testee.AddCurve( "Larry", x, y, Color.Green, SymbolType.Circle );
            curve.Line.Width = 1.5F;
            curve.Line.Fill = new Fill( Color.White, Color.FromArgb( 60, 190, 50 ), 90F );
            curve.Line.IsSmooth = true;
            curve.Line.SmoothTension = 0.6F;
            curve.Symbol.Fill = new Fill( Color.White );
            curve.Symbol.Size = 10;
            curve.Tag = "Larry";

            double[] x3 = { 150, 250, 400, 520, 780, 940 };
            double[] y3 = { 5.2, 49.0, 33.8, 88.57, 99.9, 36.8 };
            curve = testee.AddCurve( "Moe", x3, y3, Color.FromArgb( 200, 55, 135 ), SymbolType.Triangle );
            curve.Line.Width = 1.5F;
            //curve.Line.IsSmooth = true;
            curve.Symbol.Fill = new Fill( Color.White );
            curve.Line.Fill = new Fill( Color.White, Color.FromArgb( 160, 230, 145, 205 ), 90F );
            curve.Symbol.Size = 10;
            curve.Tag = "Moe";

            double[] x4 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y4 = { 30, 45, -13, 60, 75, 83, 84, 79, 71, 57 };
            BarItem bar = testee.AddBar( "Wheezy", x4, y4, Color.SteelBlue );
            bar.Bar.Fill = new Fill( Color.RosyBrown, Color.White, Color.RosyBrown );
            bar.Tag = "Wheezy";
            //curve.Bar.Fill = new Fill( Color.Blue );
            //curve.Symbol.Size = 12;

            double[] x2 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y2 = { 10, 15, -7, 20, 25, 27, 29, 26, 24, 18 };
            bar = testee.AddBar( "Curly", x2, y2, Color.RoyalBlue );
            bar.Bar.Fill = new Fill( Color.RoyalBlue, Color.White, Color.RoyalBlue );
            bar.Tag = "Curly";
            //Brush brush = new HatchBrush( HatchStyle.Cross, Color.AliceBlue, Color.Red );
            //GraphicsPath path = new GraphicsPath();
            //path.AddLine( 10, 10, 20, 20 );
            //path.AddLine( 20, 20, 30, 0 );
            //path.AddLine( 30, 0, 10, 10 );

            //brush = new PathGradientBrush( path );
            //bar.Bar.Fill = new Fill( brush );

            testee.BarSettings.ClusterScaleWidth = 100;
            testee.BarSettings.Type = BarType.Stack;

            testee.Fill = new Fill( Color.WhiteSmoke, Color.Lavender, 0F );
            testee.Chart.Fill = new Fill( Color.White, Color.FromArgb( 255, 255, 166 ), 90F );

            testee.XAxis.MajorGrid.IsVisible = true;
            testee.YAxis.MajorGrid.IsVisible = true;
            testee.YAxis.Scale.Max = 120;
            testee.Y2Axis.IsVisible = true;
            testee.Y2Axis.Scale.Max = 120;

            TextObj text = new TextObj( "First Prod\n21-Oct-93", 175F, 80.0F );
            text.Location.AlignH = AlignH.Center;
            text.Location.AlignV = AlignV.Bottom;
            text.FontSpec.Fill = new Fill( Color.White, Color.PowderBlue, 45F );
            text.Tag = "First";
            testee.GraphObjList.Add( text );

            ArrowObj arrow = new ArrowObj( Color.Black, 12F, 175F, 77F, 100F, 45F );
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            testee.GraphObjList.Add( arrow );

            text = new TextObj( "Upgrade", 700F, 50.0F );
            text.FontSpec.Angle = 90;
            text.FontSpec.FontColor = Color.Black;
            text.Location.AlignH = AlignH.Right;
            text.Location.AlignV = AlignV.Center;
            text.FontSpec.Fill.IsVisible = false;
            text.FontSpec.Border.IsVisible = false;
            testee.GraphObjList.Add( text );

            arrow = new ArrowObj( Color.Black, 15, 700, 53, 700, 80 );
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            arrow.Line.Width = 2.0F;
            arrow.Tag = "Arrow";
            testee.GraphObjList.Add( arrow );

            text = new TextObj( "Confidential", 0.8F, -0.03F );
            text.Location.CoordinateFrame = CoordType.ChartFraction;

            text.FontSpec.Angle = 15.0F;
            text.FontSpec.FontColor = Color.Red;
            text.FontSpec.IsBold = true;
            text.FontSpec.Size = 16;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Border.Color = Color.Red;
            text.FontSpec.Fill.IsVisible = false;

            text.Location.AlignH = AlignH.Left;
            text.Location.AlignV = AlignV.Bottom;
            testee.GraphObjList.Add( text );

            testee.IsPenWidthScaled = false;

            EllipseObj ellipse = new EllipseObj( 500, 50, 200, 20, Color.Blue,
                Color.Goldenrod );
            ellipse.Location.CoordinateFrame = CoordType.AxisXYScale;
            ellipse.Tag = "Ellipse";
            testee.GraphObjList.Add( ellipse );

            //			Bitmap bm = new Bitmap( @"c:\temp\sunspot.jpg" );
            Bitmap bm = new Bitmap( @"c:\windows\winnt256.bmp" );
            Image image = Image.FromHbitmap( bm.GetHbitmap() );
            ImageObj imageItem = new ImageObj( image, new RectangleF( 0.8F, 0.8F, 0.2F, 0.2F ),
                CoordType.ChartFraction, AlignH.Left, AlignV.Top );
            imageItem.IsScaled = true;
            imageItem.Tag = "Bitmap";
            testee.GraphObjList.Add( imageItem );

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            TestUtils.ShowMessage( "For each step, read the message in the Title Bar of the form" );

            HandleFind( "Select the ellipse object", "Ellipse", 0, typeof( GraphObj ) );
            HandleFind( "Select the 'First Prod' text object", "First", 0, typeof( GraphObj ) );
            HandleFind( "Select the upgrade arrow object", "Arrow", 0, typeof( GraphObj ) );
            HandleFind( "Select the Graph Title", "", 0, typeof( GraphPane ) );
            HandleFind( "Select the X Axis", "ZedGraph.XAxis", 0, typeof( Axis ) );
            HandleFind( "Select the Y Axis", "ZedGraph.YAxis", 0, typeof( Axis ) );
            HandleFind( "Select the Y2 Axis", "ZedGraph.Y2Axis", 0, typeof( Axis ) );
            HandleFind( "Select the second curve in the legend", "", 1, typeof( Legend ) );
            HandleFind( "Select the tallest blue bar", "Curly", 6, typeof( CurveItem ) );
            HandleFind( "Select the negative brown bar", "Wheezy", 2, typeof( CurveItem ) );
            HandleFind( "Select the negative blue bar", "Curly", 2, typeof( CurveItem ) );
            HandleFind( "Select the highest green circle symbol", "Larry", 6, typeof( CurveItem ) );
            HandleFind( "Select the windows bitmap object", "Bitmap", 0, typeof( GraphObj ) );
        }
示例#15
0
        public void LongFeature()
        {
            bool userOK = TestUtils.waitForUserOK;

            if ( MessageBox.Show( "Do you want to prompt at each step (otherwise, I will just run through" +
                " the whole test)?  Pick YES to Prompt at each step", "Test Setup",
                MessageBoxButtons.YesNo ) == DialogResult.No )
            {
                TestUtils.waitForUserOK = false;
            }

            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "My Test Dual Y Graph", "Date", "My	Y	Axis" );

            //	Make up some random data points
            double[] x = new double[36];
            double[] y = new double[36];
            double[] y2 = new double[36];
            for ( int i = 0; i < 36; i++ )
            {
                x[i] = (double)i * 5.0;
                y[i] = Math.Sin( (double)i * Math.PI / 15.0 ) * 16.0;
                y2[i] = y[i] * 10.5;
            }
            //	Generate a red	curve with diamond
            //	symbols, and "My Curve" in the legend
            CurveItem myCurve = testee.AddCurve( "My Curve",
                x, y, Color.Red, SymbolType.Diamond );

            //	Generate a blue curve with	diamond
            //	symbols, and "My Curve" in the legend
            myCurve = testee.AddCurve( "My Curve	1",
                x, y2, Color.Blue, SymbolType.Circle );
            myCurve.IsY2Axis = true;

            testee.XAxis.MajorGrid.IsVisible = false;
            testee.XAxis.IsVisible = false;
            testee.XAxis.MajorGrid.IsZeroLine = false;
            testee.XAxis.MajorTic.IsOutside = false;
            testee.XAxis.MinorTic.IsOutside = false;
            testee.XAxis.MajorTic.IsInside = false;
            testee.XAxis.MinorTic.IsInside = false;
            testee.XAxis.MinorTic.IsOpposite = false;
            testee.XAxis.MajorTic.IsOpposite = false;
            testee.XAxis.Scale.IsReverse = false;
            //	testee.XAxis.IsLog = false;
            testee.XAxis.Title.Text = "";

            testee.YAxis.MajorGrid.IsVisible = false;
            testee.YAxis.IsVisible = false;
            testee.YAxis.MajorGrid.IsZeroLine = false;
            testee.YAxis.MajorTic.IsOutside = false;
            testee.YAxis.MinorTic.IsOutside = false;
            testee.YAxis.MajorTic.IsInside = false;
            testee.YAxis.MinorTic.IsInside = false;
            testee.YAxis.MinorTic.IsOpposite = false;
            testee.YAxis.MajorTic.IsOpposite = false;
            testee.YAxis.Scale.IsReverse = false;
            //testee.YAxis.IsLog =	false;
            testee.YAxis.Title.Text = "";

            testee.Y2Axis.MajorGrid.IsVisible = false;
            testee.Y2Axis.IsVisible = false;
            testee.Y2Axis.MajorGrid.IsZeroLine = false;
            testee.Y2Axis.MajorTic.IsOutside = false;
            testee.Y2Axis.MinorTic.IsOutside = false;
            testee.Y2Axis.MajorTic.IsInside = false;
            testee.Y2Axis.MinorTic.IsInside = false;
            testee.Y2Axis.MinorTic.IsOpposite = false;
            testee.Y2Axis.MajorTic.IsOpposite = false;
            testee.Y2Axis.Scale.IsReverse = false;
            //testee.Y2Axis.IsLog = false;
            testee.Y2Axis.Title.Text = "";

            testee.Chart.Border.IsVisible = false;
            testee.Border.IsVisible = false;

            testee.Title.IsVisible = false;
            testee.Legend.IsHStack = false;
            testee.Legend.IsVisible = false;
            testee.Legend.Border.IsVisible = false;
            testee.Legend.Fill.Type = FillType.None;
            testee.Legend.Position = LegendPos.Bottom;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Show();

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Do you see a dual Y graph with no axes?" ) );

            testee.Border = new Border( true, Color.Red, 3.0F );

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Pane Frame Added?" ) );

            testee.Border = new Border( Color.Black, 1.0F );

            testee.Chart.Border = new Border( true, Color.Red, 3.0F );

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Axis Frame Added?" ) );

            testee.Chart.Border = new Border( Color.Black, 1.0F );

            testee.Fill = new Fill( Color.White, Color.LightGoldenrodYellow );
            testee.Margin.Top = 50.0F;
            testee.Margin.Bottom = 50.0F;
            testee.Margin.Left = 50.0F;
            testee.Margin.Right = 50.0F;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Pane Background Filled?" ) );

            testee.Margin.Top = 20.0F;
            testee.Margin.Bottom = 20.0F;
            testee.Margin.Left = 20.0F;
            testee.Margin.Right = 20.0F;
            testee.Fill.IsVisible = false;
            testee.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow );

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Axis Background Filled?" ) );

            testee.Chart.Fill.IsVisible = false;

            testee.Title.IsVisible = true;
            testee.Title.FontSpec.FontColor = Color.Red;
            testee.Title.Text = "The Title";

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Title Added?" ) );

            testee.Title.FontSpec.FontColor = Color.Black;

            testee.Legend.IsVisible = true;
            testee.Legend.FontSpec.FontColor = Color.Red;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Legend Added?" ) );

            testee.Legend.FontSpec.FontColor = Color.Black;

            testee.Legend.Border = new Border( true, Color.Red, 3.0F );

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Legend Frame Added?" ) );

            testee.Legend.Border = new Border( Color.Black, 1.0F );

            testee.Legend.Fill.Type = FillType.Brush;
            testee.Legend.Fill.Color = Color.LightGoldenrodYellow;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Legend Fill Added?" ) );

            testee.Legend.Position = LegendPos.InsideBotLeft;
            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Legend Moved to Inside Bottom Left?" ) );

            testee.Legend.Position = LegendPos.InsideBotRight;
            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Legend Moved to Inside Bottom Right?" ) );

            testee.Legend.Position = LegendPos.InsideTopLeft;
            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Legend Moved to Inside Top Left?" ) );

            testee.Legend.Position = LegendPos.InsideTopRight;
            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Legend	Moved to Inside	Top Right?" ) );

            testee.Legend.Position = LegendPos.Left;
            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Legend	Moved to Left?" ) );

            testee.Legend.Position = LegendPos.Right;
            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Legend	Moved to Right?" ) );

            testee.Legend.Position = LegendPos.Top;
            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Legend	Moved to Top?" ) );

            testee.Legend.IsHStack = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Legend	Horizontal Stacked?" ) );
            testee.Legend.Fill.Type = FillType.None;

            /////////	X	AXIS /////////////////////////////////////////////////////////////////////////

            testee.XAxis.IsVisible = true;
            testee.XAxis.Color = Color.Red;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "X Axis Visible?" ) );

            testee.XAxis.Title.Text = "X Axis Title";

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "X Axis Title Visible?" ) );

            //testee.XAxis.TicPenWidth	= 3.0F;
            testee.XAxis.MajorGrid.IsZeroLine = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "X Axis ZeroLine Visible?" ) );

            testee.XAxis.MajorGrid.IsZeroLine = false;
            //testee.XAxis.TicPenWidth	= 1.0F;
            testee.XAxis.MajorTic.IsOutside = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "X Axis major tics Visible?" ) );

            testee.XAxis.MinorTic.IsOutside = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "X Axis minor tics Visible?" ) );

            testee.XAxis.MajorTic.IsInside = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "X Axis Inside tics Visible?" ) );

            testee.XAxis.MajorTic.IsOpposite = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "X Axis Opposite tics Visible?" ) );

            testee.XAxis.MinorTic.IsInside = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "X Axis Minor Inside tics Visible?" ) );

            testee.XAxis.MinorTic.IsOpposite = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "X Axis Minor Opposite tics Visible?" ) );

            testee.XAxis.MajorTic.PenWidth = 1.0F;
            testee.XAxis.Color = Color.Black;
            testee.XAxis.MajorGrid.IsVisible = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "X Axis Grid Visible?" ) );

            testee.XAxis.MajorGrid.PenWidth = 1.0F;
            testee.XAxis.MajorGrid.Color = Color.Black;
            testee.XAxis.Scale.IsReverse = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "X Axis Reversed?" ) );

            testee.XAxis.Scale.IsReverse = false;
            testee.XAxis.Type = AxisType.Log;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "X Axis Log?" ) );

            testee.XAxis.Type = AxisType.Linear;

            ///////////////////////////////////////////////////////////////////////////////

            /////////	Y	AXIS /////////////////////////////////////////////////////////////////////////

            testee.YAxis.IsVisible = true;
            testee.YAxis.Color = Color.Red;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y Axis Visible?" ) );

            testee.YAxis.Title.Text = "Y Axis	Title";

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y Axis Title Visible?" ) );

            //testee.YAxis.TicPenWidth	= 3.0F;
            testee.YAxis.MajorGrid.IsZeroLine = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y Axis ZeroLine Visible?" ) );

            testee.YAxis.MajorGrid.IsZeroLine = false;
            //testee.YAxis.TicPenWidth	= 1.0F;
            testee.YAxis.MajorTic.IsOutside = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y Axis major tics Visible?" ) );

            testee.YAxis.MinorTic.IsOutside = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y Axis minor tics Visible?" ) );

            testee.YAxis.MajorTic.IsInside = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y Axis Inside tics Visible?" ) );

            testee.YAxis.MajorTic.IsOpposite = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y Axis Opposite tics Visible?" ) );

            testee.YAxis.MinorTic.IsInside = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y Axis Minor Inside tics Visible?" ) );

            testee.YAxis.MinorTic.IsOpposite = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y Axis Minor Opposite tics Visible?" ) );

            testee.YAxis.MajorTic.PenWidth = 1.0F;
            testee.YAxis.Color = Color.Black;
            testee.YAxis.MajorGrid.IsVisible = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y Axis Grid Visible?" ) );

            testee.YAxis.MajorGrid.PenWidth = 1.0F;
            testee.YAxis.MajorGrid.Color = Color.Black;
            testee.YAxis.Scale.IsReverse = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y Axis Reversed?" ) );

            testee.YAxis.Scale.IsReverse = false;
            testee.YAxis.Type = AxisType.Log;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y Axis Log?" ) );

            testee.YAxis.Type = AxisType.Linear;

            ///////////////////////////////////////////////////////////////////////////////

            /////////	Y2	AXIS	/////////////////////////////////////////////////////////////////////////

            testee.Y2Axis.IsVisible = true;
            testee.Y2Axis.Color = Color.Red;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y2 Axis Visible?" ) );

            testee.Y2Axis.Title.Text = "Y2	Axis Title";

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y2 Axis Title Visible?" ) );

            //testee.Y2Axis.TicPenWidth	=	3.0F;
            testee.Y2Axis.MajorGrid.IsZeroLine = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y2 Axis ZeroLine Visible?" ) );

            testee.Y2Axis.MajorGrid.IsZeroLine = false;
            //testee.Y2Axis.TicPenWidth	=	1.0F;
            testee.Y2Axis.MajorTic.IsOutside = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y2 Axis major tics Visible?" ) );

            testee.Y2Axis.MinorTic.IsOutside = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y2 Axis minor tics Visible?" ) );

            testee.Y2Axis.MajorTic.IsInside = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y2 Axis Inside tics Visible?" ) );

            testee.Y2Axis.MajorTic.IsOpposite = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y2 Axis Opposite tics Visible?" ) );

            testee.Y2Axis.MinorTic.IsInside = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y2 Axis Minor Inside tics Visible?" ) );

            testee.Y2Axis.MinorTic.IsOpposite = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y2 Axis Minor Opposite tics Visible?" ) );

            testee.Y2Axis.MajorTic.PenWidth = 1.0F;
            testee.Y2Axis.Color = Color.Black;
            testee.Y2Axis.MajorGrid.IsVisible = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y2 Axis Grid Visible?" ) );

            testee.Y2Axis.MajorGrid.PenWidth = 1.0F;
            testee.Y2Axis.MajorGrid.Color = Color.Black;
            testee.Y2Axis.Scale.IsReverse = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y2 Axis Reversed?" ) );

            testee.Y2Axis.Scale.IsReverse = false;
            testee.Y2Axis.Type = AxisType.Log;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Y2 Axis Log?" ) );

            testee.Y2Axis.Type = AxisType.Linear;

            ///////////////////////////////////////////////////////////////////////////////

            for ( float angle = 0.0F; angle <= 360.0F; angle += 10.0F )
            {
                testee.XAxis.Scale.FontSpec.Angle = angle;
                testee.YAxis.Scale.FontSpec.Angle = -angle + 90.0F;
                testee.Y2Axis.Scale.FontSpec.Angle = -angle - 90.0F;
                //testee.XAxis.TitleFontSpec.Angle =	-angle;
                //testee.YAxis.TitleFontSpec.Angle = angle + 180.0F;
                //testee.Y2Axis.TitleFontSpec.Angle = angle;
                //testee.Legend.FontSpec.Angle = angle;
                //testee.FontSpec.Angle = angle;

                form2.Refresh();
                TestUtils.DelaySeconds( 50 );
            }

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Did Fonts Rotate & Axes Accomodate them?" ) );

            testee.XAxis.Scale.FontSpec.Angle = 0;
            testee.YAxis.Scale.FontSpec.Angle = 90.0F;
            testee.Y2Axis.Scale.FontSpec.Angle = -90.0F;

            for ( float angle = 0.0F; angle <= 360.0F; angle += 10.0F )
            {
                testee.XAxis.Title.FontSpec.Angle = -angle;
                testee.YAxis.Title.FontSpec.Angle = angle + 180.0F;
                testee.Y2Axis.Title.FontSpec.Angle = angle;
                //testee.Legend.FontSpec.Angle = angle;
                testee.Title.FontSpec.Angle = angle;

                form2.Refresh();
                TestUtils.DelaySeconds( 50 );
            }

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Did Axis Titles Rotate and the AxisRect adjust properly?" ) );

            testee.XAxis.Scale.FontSpec.Angle = 0;
            testee.YAxis.Scale.FontSpec.Angle = 90.0F;
            testee.Y2Axis.Scale.FontSpec.Angle = -90.0F;
            testee.XAxis.Title.FontSpec.Angle = 0;
            testee.YAxis.Title.FontSpec.Angle = 180.0F;
            testee.Y2Axis.Title.FontSpec.Angle = 0;
            //testee.Legend.FontSpec.Angle = 0;
            testee.Title.FontSpec.Angle = 0;

            ///////////////////////////////////////////////////////////////////////////////

            TextObj text = new TextObj( "ZedGraph TextObj", 0.5F, 0.5F );
            testee.GraphObjList.Add( text );

            text.Location.CoordinateFrame = CoordType.ChartFraction;
            text.FontSpec.IsItalic = false;
            text.FontSpec.IsUnderline = false;
            text.FontSpec.Angle = 0.0F;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Fill.Type = FillType.None;
            text.FontSpec.FontColor = Color.Red;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is TextObj Centered on Graph?" ) );

            text.FontSpec.FontColor = Color.Black;
            text.FontSpec.Border = new Border( true, Color.Red, 3.0F );

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Does TextObj have a Border?" ) );

            text.FontSpec.Border = new Border( Color.Black, 1.0F );

            text.FontSpec.Fill.Color = Color.LightGoldenrodYellow;
            text.FontSpec.Fill.Type = FillType.Brush;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is TextObj background filled?" ) );

            text.FontSpec.Size = 20.0F;
            text.FontSpec.Family = "Garamond";

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Large Garamond Font?" ) );

            text.FontSpec.IsUnderline = true;
            text.FontSpec.IsItalic = true;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Text Underlined & italic?" ) );

            text.FontSpec.IsItalic = false;
            text.FontSpec.IsUnderline = false;

            text.Location.X = 75.0F;
            text.Location.Y = 0.0F;
            text.Location.CoordinateFrame = CoordType.AxisXYScale;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Centered at (75, 0.0)?" ) );

            text.Location.AlignH = AlignH.Right;
            text.Location.AlignV = AlignV.Top;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Top-Right	at (75, 0.0)?" ) );

            text.Location.AlignH = AlignH.Left;
            text.Location.AlignV = AlignV.Bottom;

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Bottom-Left at (75, 0.0)?" ) );

            for ( float angle = 0.0F; angle <= 360.0F; angle += 10.0F )
            {
                text.FontSpec.Angle = angle;

                form2.Refresh();
                TestUtils.DelaySeconds( 50 );
            }

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Text Rotate with Bottom-Left at (75, 0.5)?" ) );

            testee.Fill.Type = FillType.Brush;
            testee.Chart.Fill.Type = FillType.Brush;
            testee.Legend.Fill.Type = FillType.Brush;

            for ( float angle = 0.0F; angle <= 360.0F; angle += 10.0F )
            {
                testee.Fill.Brush = new LinearGradientBrush( testee.Rect, Color.White,
                    Color.Red, angle, true );
                testee.Chart.Fill.Brush = new LinearGradientBrush( testee.Chart.Rect, Color.White,
                    Color.Blue, -angle, true );
                testee.Legend.Fill.Brush = new LinearGradientBrush( testee.Legend.Rect, Color.White,
                    Color.Green, -angle, true );

                form2.Refresh();
                TestUtils.DelaySeconds( 50 );
            }

            TestUtils.waitForUserOK = userOK;

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Did Everything look ok?" ) );
        }
示例#16
0
        public void TextAxis()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Text Graph", "Label", "Y Value" );

            //	Make up some random data points
            string[] labels = { "USA", "Spain", "Qatar",	"Morocco", "UK", "Uganda",
                                  "Cambodia", "Malaysia",	"Australia", "Ecuador" };

            double[] y = new double[10];
            for ( int i = 0; i < 10; i++ )
                y[i] = Math.Sin( (double)i * Math.PI / 2.0 );
            //	Generate a red	curve with diamond
            //	symbols, and "My Curve" in the legend
            CurveItem myCurve = testee.AddCurve( "My Curve",
                null, y, Color.Red, SymbolType.Diamond );
            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            //	Set the labels at	an angle so they	don't overlap
            testee.XAxis.Scale.FontSpec.Angle = 0;
            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Show();

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did you	get	an	X	Text axis?" ) );

            ( myCurve.Points as PointPairList ).Clear();
            for ( double i = 0; i < 100; i++ )
                ( myCurve.Points as PointPairList ).Add( i / 10.0, Math.Sin( i / 10.0 * Math.PI / 2.0 ) );

            testee.AxisChange( form2.CreateGraphics() );
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the points fill in between the labels? (Next Resize the graph and check label overlap again)" ) );

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the graph resize ok?" ) );
        }
示例#17
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public ZedGraphControl()
        {
            InitializeComponent();
            InitializeComponentPartial();
            this._tooltip = ValuesToolTip.Create(this, this.pointToolTip);

            // These commands do nothing, but they get rid of the compiler warnings for
            // unused events
            bool b = MouseDown == null || MouseUp == null || MouseMove == null;

            // Link in these events from the base class, since we disable them from this class.
            base.MouseDown += ZedGraphControl_MouseDown;
            base.MouseUp   += ZedGraphControl_MouseUp;
            base.MouseMove += ZedGraphControl_MouseMove;

            //this.MouseWheel += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseWheel );

            // Use double-buffering for flicker-free updating:
            SetStyle(ControlStyles.UserPaint
                     | ControlStyles.AllPaintingInWmPaint
                     | ControlStyles.DoubleBuffer
                     | ControlStyles.ResizeRedraw, true);
            //isTransparentBackground = false;
            //SetStyle( ControlStyles.Opaque, false );
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            //this.BackColor = Color.Transparent;

            Rectangle rect = new Rectangle(0, 0, this.Size.Width, this.Size.Height);

            _masterPane                 = new MasterPane("", rect);
            _masterPane.Margin.All      = 0;
            _masterPane.Title.IsVisible = false;

            string titleStr = ZedGraphLocale.title_def;
            string xStr     = ZedGraphLocale.x_title_def;
            string yStr     = ZedGraphLocale.y_title_def;

            //GraphPane graphPane = new GraphPane( rect, "Title", "X Axis", "Y Axis" );
            GraphPane graphPane = new GraphPane(rect, titleStr, xStr, yStr);

            using (Graphics g = this.CreateGraphics())
            {
                graphPane.AxisChange(g);
                //g.Dispose();
            }
            _masterPane.Add(graphPane);

            this.hScrollBar1.Minimum = 0;
            this.hScrollBar1.Maximum = 100;
            this.hScrollBar1.Value   = 0;

            this.vScrollBar1.Minimum = 0;
            this.vScrollBar1.Maximum = 100;
            this.vScrollBar1.Value   = 0;

            _xScrollRange = new ScrollRange(true);

            YScrollRangeList.Add(new ScrollRange(true));
            Y2ScrollRangeList.Add(new ScrollRange(false));

            _zoomState      = null;
            _zoomStateStack = new ZoomStateStack();

            _graphDragState = new GraphDragState();

            CrossHairFontSpec = new FontSpec
            {
                FontColor = Color.Black,
                Size      = 9,
                Border    = { IsVisible = true },
                Fill      = { Color = Color.Beige, Brush = new SolidBrush(Color.Beige) },
                TextBrush = new SolidBrush(Color.Black)
            };
        }
示例#18
0
        public void HorizClusteredBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Horizontal	Clustered Bar Graph Test ", "Label", "My Y Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty", "Wildcat" };
            double[] y = { 100, 115, 75, -22, 98, 40, -10, 20 };
            double[] y2 = { 90, 100, 95, 35, 80, 35, -35, 30 };
            double[] y3 = { 80, 0, 65, -15, 54, 67, 18, 50 };

            //	Generate three	bars	with	appropriate entries in	the legend
            CurveItem myCurve = testee.AddBar( "Curve	1", y, null, Color.Red );
            CurveItem myCurve1 = testee.AddBar( "Curve	2", y2, null, Color.Blue );
            CurveItem myCurve2 = testee.AddBar( "Curve	3", y3, null, Color.Green );
            //	Draw the Y tics	between the labels instead of	at the labels
            testee.YAxis.MajorTic.IsBetweenLabels = true;

            //	Set the YAxis	labels
            testee.YAxis.Scale.TextLabels = labels;
            testee.YAxis.Scale.FontSpec.Size = 9F;
            //show	the zero	line
            testee.XAxis.MajorGrid.IsZeroLine = true;
            //	Set the YAxis	to Text	type
            testee.YAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.Y;

            testee.YAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            //	Add one step to the	max	scale value	to leave	room for the labels
            testee.XAxis.Scale.Max += testee.YAxis.Scale.MajorStep;

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a horizontal clustered bar graph having the proper number of bars per y-Axis point visible ? <Next Step: Resize the graph>" ) );

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the graph resize ok with all y-Axis labels visible?" ) );
        }
示例#19
0
        public void ErrorBarChart()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "ErrorBar Chart Test ", "X AXIS", "Y Value" );

            double[] hi = new double[20];
            double[] low = new double[20];
            double[] x = new double[20];

            for ( int i = 45; i < 65; i++ )
            {
                x[i - 45] = (double)new XDate( 2004, 12, i - 30, 0, 0, 0 );
                if ( i % 2 == 1 )
                    hi[i - 45] = (double)i * 1.03;
                else
                    hi[i - 45] = (double)i * .99;

                low[i - 45] = .97 * hi[i - 45];
            }

            ErrorBarItem myCurve = testee.AddErrorBar( "My	Curve", x, hi, low, Color.Blue );

            testee.XAxis.Scale.FontSpec.Size = 12;
            testee.XAxis.Scale.FontSpec.Angle = 90;

            //	Set the XAxis	to date type
            testee.XAxis.Type = AxisType.Date;
            testee.XAxis.Scale.Min = x[0] - 1;
            myCurve.Bar.PenWidth = 2;

            testee.YAxis.MajorGrid.IsVisible = true;
            testee.YAxis.MinorGrid.IsVisible = true;

            form2.WindowState = FormWindowState.Maximized;
            testee.AxisChange( form2.CreateGraphics() );

            TestUtils.DelaySeconds( 3000 );
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Was the typical Error Bar chart with a date X-Axis displayed?" ) );
        }
示例#20
0
        public void ClusteredBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Clustered Bar Graph Test", "Label", "My	Y	Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty" };
            double[] y = { 100, 115, 75, -22, 98, 40, -10 };
            double[] y2 = { 90, 100, 95, 35, 0, 35, -35 };
            double[] y3 = { 80, 110, 65, -15, 54, 67, 18 };

            double[] y4 = { 120, 125, 100, 20, 105, 75, -40 };

            //	Generate three	bars	with	appropriate entries in	the legend
            CurveItem myCurve = testee.AddBar( "Curve	1", null, y, Color.Red );
            CurveItem myCurve1 = testee.AddBar( "Curve	2", null, y2, Color.Blue );
            CurveItem myCurve2 = testee.AddBar( "Curve	3", null, y3, Color.Green );
            //	Draw the X tics	between the labels instead of	at the labels
            testee.XAxis.MajorTic.IsBetweenLabels = true;

            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            testee.XAxis.Scale.FontSpec.Size = 9F;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.X;

            testee.XAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;

            //Add Labels to the curves

            //	Shift	the text items up by	5 user	scale units	above	the	bars
            const float shift = 5;

            for ( int i = 0; i < y.Length; i++ )
            {
                //	format	the label string to	have	1 decimal place
                string lab = y2[i].ToString( "F1" );
                //	create	the text item (assumes	the	x	axis is	ordinal or	text)
                //	for negative bars, the	label appears just	above	the zero	value
                TextObj text = new TextObj( lab, (float)( i + 1 ), (float)( y2[i] < 0 ? 0.0 : y2[i] ) + shift );
                //	tell	Zedgraph to use user	scale units	for locating	the	TextObj
                text.Location.CoordinateFrame = CoordType.AxisXYScale;
                //	Align the left-center	of the text to the	specified	point
                text.Location.AlignH = AlignH.Left;
                text.Location.AlignV = AlignV.Center;
                text.FontSpec.Border.IsVisible = false;
                //	rotate the	text 90 degrees
                text.FontSpec.Angle = 90;
                //	add the	TextObj to	the	list
                testee.GraphObjList.Add( text );
            }

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            //	Add one step to the	max	scale value	to leave	room for the labels
            testee.YAxis.Scale.Max += testee.YAxis.Scale.MajorStep;

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a clustered bar graph having the proper number of bars per x-Axis point visible ?  <Next Step: Resize the chart>" ) );

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the graph resize ok with all x-Axis labels visible?" ) );
        }
示例#21
0
        /// <summary>
        /// Initliase the Active Learning graph
        /// </summary>
        private void InitialiseActiveLearningGraphs()
        {
            //AccuracyGraph Settings
            accuracyGraphPane = graphControlAccuracyGraph.GraphPane;
            accuracyGraphPane.CurveList.Clear() ; //clear the curveList in the graphpane

            //set x starting point of the AccuracyGraph
            accuracyGraphPane.XAxis.Scale.Min = currentExperimentSetting.initialStartingLabel - 1;

            //add curves into the accuracyGraphPane
            List<ExperimentModel> currentExperimentItemsList = currentExperimentSetting.experimentModels;

            for (int i = 0; i < currentExperimentItemsList.Count; i++)
            {
                // The RollingPointPairList is an efficient storage class that always
                // keeps a rolling set of point data without needing to shift any data values
                RollingPointPairList list = new RollingPointPairList(currentExperimentSetting.currentDataset.totalNumberOfLabellingRows);

                //Add the curve with an empty datalist into the accuracyGraphPane
                LineItem curve = accuracyGraphPane.AddCurve(currentExperimentItemsList[i].ToString(), list, colourOptions[i], SymbolType.None);
                curve.Line.Width = 2.0f;
            }

            //scale the axes
            accuracyGraphPane.AxisChange();
            //set the CurveList
            accuracyGraphCurveList = accuracyGraphPane.CurveList;
            graphControlAccuracyGraph.Visible = true;
           
        }
示例#22
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;
        }
示例#23
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;
        }
示例#24
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();
        }
示例#25
0
        public void AnimatedDateGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Date	Graph	Test ", "X AXIS", "Y Value" );

            //	start	with an empty list for testing
            PointPairList pointList = new PointPairList();

            //	Generate a red	curve with diamond
            //	symbols, and "My Curve" in the legend
            LineItem myCurve = testee.AddCurve( "My	Curve",
                pointList, Color.Red, SymbolType.Diamond );

            //	Set the XAxis	to date type
            testee.XAxis.Type = AxisType.Date;

            //	make the	symbols filled blue
            myCurve.Symbol.Fill.Type = FillType.Solid;
            myCurve.Symbol.Fill.Color = Color.Blue;

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Show();

            //	Draw a sinusoidal curve, adding one	point at a	time
            //	and refiguring/redrawing each time.	(a stress test)
            //	redo	creategraphics()	each time to stress test
            for ( int i = 0; i < 300; i++ )
            {
                double x = (double)new XDate( 1995, i + 1, 1 );
                double y = Math.Sin( (double)i * Math.PI / 30.0 );

                ( myCurve.Points as PointPairList ).Add( x, y );
                testee.AxisChange( form2.CreateGraphics() );
                form2.Refresh();

                //	delay for 10 ms
                //DelaySeconds(	50	);
            }

            while ( myCurve.Points.Count > 0 )
            {
                //	remove the	first point	in the list
                ( myCurve.Points as PointPairList ).RemoveAt( 0 );
                testee.AxisChange( form2.CreateGraphics() );
                form2.Refresh();

                //	delay for 10 ms
                //DelaySeconds(	50	);
            }

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did you see points added one by one, then deleted one by one?" ) );
        }
示例#26
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();
        }
示例#27
0
        public void DualY()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "My Test Dual Y Graph", "Date", "My	Y Axis" );
            testee.Y2Axis.Title.Text = "My Y2 Axis";

            //	Make up some random data points
            double[] x = new double[36];
            double[] y = new double[36];
            double[] y2 = new double[36];
            for ( int i = 0; i < 36; i++ )
            {
                x[i] = (double)new XDate( 1995, i + 1, 1 );
                y[i] = Math.Sin( (double)i * Math.PI / 15.0 );
                y2[i] = y[i] * 3.6178;
            }
            //	Generate a red	curve with diamond
            //	symbols, and "My Curve" in the legend
            CurveItem myCurve = testee.AddCurve( "My Curve",
                x, y, Color.Red, SymbolType.Diamond );
            //	Set the XAxis	to date type
            testee.XAxis.Type = AxisType.Date;

            //	Generate a blue curve with	diamond
            //	symbols, and "My Curve" in the legend
            myCurve = testee.AddCurve( "My Curve	1",
                x, y2, Color.Blue, SymbolType.Circle );
            myCurve.IsY2Axis = true;
            testee.YAxis.IsVisible = true;
            testee.Y2Axis.IsVisible = true;
            testee.Y2Axis.MajorGrid.IsVisible = true;
            testee.XAxis.MajorGrid.IsVisible = true;
            testee.YAxis.MajorTic.IsOpposite = false;
            testee.YAxis.MinorTic.IsOpposite = false;
            testee.YAxis.MajorGrid.IsZeroLine = false;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Show();

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Do you see a dual Y graph?" ) );
        }
示例#28
0
        public void SortedOverlayBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Sorted Overlay Bar Graph Test ", "Label", "My	Y	Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty" };
            double[] y = { 100, -115, 75, 22, 98, 40, 10 };
            double[] y2 = { 90, -100, 95, -35, 0, 35, 35 };
            double[] y3 = { 80, -110, 65, 15, 54, 67, 18 };

            //	Generate three	bars	with	appropriate entries in	the legend
            CurveItem myCurve = testee.AddBar( "Curve	1", null, y3, Color.Red );
            CurveItem myCurve1 = testee.AddBar( "Curve	2", null, y2, Color.Blue );
            CurveItem myCurve2 = testee.AddBar( "Curve	3", null, y, Color.Green );
            //	Draw the X tics	between the labels instead of	at the labels
            testee.XAxis.MajorTic.IsBetweenLabels = true;

            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            testee.XAxis.Scale.FontSpec.Size = 9F;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.X;
            //display as	overlay bars
            testee.BarSettings.Type = BarType.SortedOverlay;
            //display horizontal grid	lines
            testee.YAxis.MajorGrid.IsVisible = true;

            testee.XAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;

            //	Shift	the text items up by	5 user	scale units	above	the	bars
            const float shift = 5;

            string lab = "";
            TextObj text = null;
            for ( int x = 0; x < 3; x++ )
                for ( int i = 0; i < y.Length; i++ )
                {
                    //	format	the label string to	have	1 decimal place
                    switch ( x )
                    {
                        case 0:
                            lab = y[i].ToString();
                            text = new TextObj( lab, (float)( i + 1 ), (float)( y[i] < 0 ? y[i] + 2 * shift : y[i] ) - shift );
                            break;
                        case 1:
                            lab = y2[i].ToString();
                            text = new TextObj( lab, (float)( i + 1 ), (float)( y2[i] < 0 ? y2[i] + 2 * shift : y2[i] ) - shift );
                            break;
                        case 2:
                            lab = y3[i].ToString();
                            text = new TextObj( lab, (float)( i + 1 ), (float)( y3[i] < 0 ? y3[i] + 2 * shift : y3[i] ) - shift );
                            break;
                        default:
                            break;
                    }
                    text.FontSpec.Size = 4;
                    text.FontSpec.IsBold = true;
                    //	tell	Zedgraph to use user	scale units	for locating	the	TextObj
                    text.Location.CoordinateFrame = CoordType.AxisXYScale;
                    //	Align the left-center	of the text to the	specified	point
                    text.Location.AlignH = AlignH.Center;
                    text.Location.AlignV = AlignV.Center;
                    text.FontSpec.Border.IsVisible = false;
                    //	add the	TextObj to	the	list
                    testee.GraphObjList.Add( text );
                }

            form2.WindowState = FormWindowState.Maximized;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            //	Add one step to the	max	scale value	to leave	room for the labels
            testee.YAxis.Scale.Max += testee.YAxis.Scale.MajorStep;

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a Sorted Overlay Stack Bar displayed with the segments in increasing value order as indicated by the embedded values? " ) );
        }
示例#29
0
        public void HiLowChart()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "HiLow Chart Test ", "Date", "Y Value Range" );

            double[] hi = new double[20];
            double[] low = new double[20];
            string[] x = new string[20];

            for ( int i = 45; i < 65; i++ )
            {
                XDate date = (double)new XDate( 2004, 12, i - 30, 0, 0, 0 );
                x[i - 45] = date.ToString( "d" );

                if ( i % 2 == 1 )
                    hi[i - 45] = (double)i * 1.03;
                else
                    hi[i - 45] = (double)i * .99;

                low[i - 45] = .97 * hi[i - 45];
            }

            //		HiLowBarItem myCurve	=	testee.AddHiLowBar(	"My	Curve",null,hi,low, Color.Green );
            HiLowBarItem myCurve = testee.AddHiLowBar( "My	Curve", null, hi, low, Color.Green );

            testee.XAxis.Scale.FontSpec.Size = 8;
            testee.XAxis.Scale.FontSpec.Angle = 60;
            testee.XAxis.Scale.FontSpec.IsBold = true;

            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            testee.XAxis.Scale.TextLabels = x;
            testee.XAxis.Scale.MajorStep = 1;
            testee.XAxis.MajorTic.IsBetweenLabels = false;

            testee.YAxis.MajorGrid.IsVisible = true;
            testee.YAxis.MinorGrid.IsVisible = true;

            form2.WindowState = FormWindowState.Maximized;
            testee.AxisChange( form2.CreateGraphics() );

            TestUtils.DelaySeconds( 3000 );
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Was a HiLow chart with a date X-Axis displayed?" ) );
        }
示例#30
0
        public void StkBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Stack Bar	Graph	Test ", "Label", "My	Y	Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty" };
            double[] y = { 100, 115, 75, -22, 0, 40, -10 };
            double[] y2 = { 90, 100, -95, 35, 0, 35, -35 };
            double[] y3 = { 80, 110, 65, -15, 54, 67, -18 };

            double[] y4 = { 120, 125, 100, 20, 105, 75, -40 };

            //	Generate three	bars	with	appropriate entries in	the legend
            CurveItem myCurve = testee.AddBar( "Curve	1", null, y, Color.Red );
            CurveItem myCurve1 = testee.AddBar( "Curve	2", null, y2, Color.Blue );
            CurveItem myCurve2 = testee.AddBar( "Curve	3", null, y3, Color.Green );
            //	Draw the X tics	between the labels instead of	at the labels
            testee.XAxis.MajorTic.IsBetweenLabels = true;

            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            testee.XAxis.Scale.FontSpec.Size = 9F;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.X;
            //display as	stack bar
            testee.BarSettings.Type = BarType.Stack;
            //display horizontal grid	lines
            testee.YAxis.MajorGrid.IsVisible = true;

            testee.XAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;
            //turn	off pen width	scaling
            testee.IsPenWidthScaled = false;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a stack bar graph having three bars per x-Axis point visible ?  <Next Step: Maximize the display>" ) );

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the graph resize ok with all x-Axis labels visible?  <Next Step: Add a curve>" ) );

            LineItem curve = new LineItem( "Curve A", null, y4, Color.Black, SymbolType.TriangleDown );
            testee.CurveList.Insert( 0, curve );
            curve.Line.Width = 1.5F;
            curve.Line.IsSmooth = true;
            curve.Line.SmoothTension = 0.6F;
            curve.Symbol.Fill = new Fill( Color.Yellow );
            curve.Symbol.Size = 8;

            form2.Refresh();

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Was a new curve displayed on top of the bars?" ) );
        }
示例#31
0
        public void readData(string fn,GraphPane graph)
        {
            SqlConnection con = DBSettings.getConnection();
            con.Open();
            Int64 timeStart = EPADB.GetIntDate(DateStart);
            Int64 timeEnd = EPADB.GetIntDate(DateEnd);
            Dictionary<Int64, Dictionary<string, double>> Data = new Dictionary<long, Dictionary<string, double>>();

            Int64 time = timeStart;
            while (time <= timeEnd) {
                Data.Add(time, new Dictionary<string, double>());
                foreach (SignalInfo si in epa.SelectedAnalogSignals) {
                    Data[time].Add(si.KKS, double.NaN);
                }
                time += Step;
            }

            List<string> kksQList = new List<string>();
            List<int> numSignQList = new List<int>();
            List<int> timesQList = new List<int>();
            Dictionary<int, int> timesDict = new Dictionary<int, int>();
            List<int> timesList = new List<int>();
            foreach (int ss in SignalsBySubSys.Keys) {
                foreach (string table in tables) {
                    if (subSystemsByTables[table] != ss)
                        continue;
                    Status.Text = "Обработка таблицы " + table;
                    SqlCommand com = con.CreateCommand();
                    com.CommandText = String.Format("Select * from {0} where time_page>={1} and time_page<={2}", table.Replace("state", "time"), timeStart, timeEnd);
                    List<Int32> times = new List<int>();

                    try {
                        Status.Text += "---|";
                        SqlDataReader reader = com.ExecuteReader();
                        while (reader.Read()) {
                            try {
                                int tm = reader.GetInt32(0);
                                times.Add(tm);
                            }
                            catch { }
                        }
                        times.Sort();
                        reader.Close();

                        foreach (SignalInfo si in SignalsBySubSys[ss]) {
                            kksQList.Add("'" + si.KKS + "'");
                            numSignQList.Add(si.numSign);
                            if (kksQList.Count() <= 10 && si != SignalsBySubSys[ss].Last())
                                continue;
                            string kksQ=String.Join(",", kksQList);
                            string numQ = String.Join(",", numSignQList);
                            kksQList.Clear();
                            timesDict.Clear();
                            numSignQList.Clear();
                            timesQList.Clear();

                            foreach (int t in Data.Keys) {
                                if (t >= times.First() && t <= times.Last()) {
                                    int valT = times.First(tempT => { return tempT >= t; });
                                    if (valT - t < Step) {
                                        timesQList.Add(valT);
                                        timesDict.Add(valT, t);
                                    }
                                }
                                if (timesQList.Count < 100 && t != Data.Keys.Last())
                                    continue;
                                string timesQ=String.Join(",", timesQList);
                                timesQList.Clear();

                                try {
                                    com = con.CreateCommand();
                                    //com.CommandText = String.Format("Select kks_id_signal,time_page,data from {0} where time_page in ({2}) and kks_id_signal in ({1})", table, kksQ, timesQ);
                                    //com.CommandText = String.Format("Select kks_id_signal,time_page,data from {0} where time_page={2} and kks_id_signal = '{1}'", table, kks, valT);
                                    if (!epa.UseNumSignals) {
                                        com.CommandText = String.Format("Select kks_id_signal,time_page,data from {0} where time_page in ({2}) and kks_id_signal in ({1})", table, kksQ, timesQ);
                                    }
                                    else {
                                        com.CommandText = String.Format("Select kks_id_signal,time_page,data from {0} where time_page in ({2}) and num_sign in ({1})", table, numQ, timesQ);
                                    }

                                    Status.Text += "---|";
                                    reader = com.ExecuteReader();
                                    while (reader.Read()) {
                                        try {
                                            int timeRes = reader.GetInt32(1);
                                            string kksAsu = reader.GetString(0);
                                            double val = reader.GetFloat(2);

                                            long resultTime = timesDict[timeRes];
                                            Data[resultTime][kksAsu] = val;
                                        }
                                        catch (Exception e) {Logger.Info(e.ToString()); }
                                    }
                                    reader.Close();
                                }
                                catch (Exception e) {Logger.Info(e.ToString()); }
                            }
                        }
                    }
                    catch (Exception e) { Logger.Info(e.ToString()); }
                }
            }
            con.Close();

            Status.Text = "Чтение завершено";
            List<string> thAsuList = new List<string>();
            List<string> thTechList = new List<string>();

            foreach (SignalInfo si in epa.SelectedAnalogSignals) {
                thAsuList.Add(String.Format("<th>{0}</th>", si.ShortName));
                try {
                    string kksTech = epa.ASUTechDict[si.KKS];
                    SignalInfo tech = epa.FindSignal(epa.TechRoot, kksTech, null);
                    thTechList.Add(String.Format("<th>{0}</th>", tech.ShortName));
                }
                catch {
                    thTechList.Add("<th>-</th>");
                }
            }
            OutputData.writeToOutput(fn, String.Format("<table border='1'><tr><th rowspan='2'>Дата</th>{0}</tr><tr>{1}</tr>",string.Join(" ",thAsuList),string.Join(" ",thTechList)));
            foreach (int tm in Data.Keys) {
                OutputData.writeToOutput(fn, String.Format("<tr><th>{0}</th><td>{1}</td></tr>", EPADB.GetDate(tm), String.Join("</td><td>", Data[tm].Values)));
            }
            OutputData.writeToOutput(fn,"</table>");

            graph.CurveList.Clear();
            graph.XAxis.Scale.Min = Data.Keys.First();
            graph.XAxis.Scale.Max = Data.Keys.Last();
            graph.XAxis.Scale.MinAuto = false;
            graph.XAxis.Scale.MaxAuto = false;
            graph.XAxis.Title.IsVisible = false;
            graph.YAxis.IsVisible = false;
            graph.YAxis.Title.IsVisible = false;
            graph.Legend.FontSpec.Size = 6;
            graph.Legend.Location.X = 0;
            graph.Legend.Location.Y = 0;
            graph.Title.IsVisible = false;
            graph.YAxis.Scale.FontSpec.Size = 6;
            graph.YAxis.IsVisible = false;
            graph.XAxis.Scale.FontSpec.Size = 6;
            int index = 0;
            foreach (SignalInfo si in epa.SelectedAnalogSignals) {
                try {
                    string name = si.ShortName;
                        int axInd=graph.AddYAxis("");
                        graph.YAxisList[axInd].Color = Colors[index % 8];
                        graph.YAxisList[axInd].Scale.FontSpec.Size = 6;
                        graph.YAxisList[axInd].Scale.FontSpec.FontColor = Colors[index % 8];

                    try {
                        string kksTech = epa.ASUTechDict[si.KKS];
                        SignalInfo tech = epa.FindSignal(epa.TechRoot, kksTech, null);
                        name = name + " (" + tech.ShortName + ")";
                    }
                    catch { }
                    PointPairList list = new PointPairList();
                    foreach (int tm in Data.Keys) {
                        list.Add(new PointPair(tm, Data[tm][si.KKS]));
                    }
                    graph.AddCurve(name, list, Colors[index % 8], SymbolType.None);
                    graph.CurveList[index].YAxisIndex = axInd;

                }
                catch (Exception e) {
                    Logger.Info(e.ToString());
                }
                graph.AxisChange();
                index++;
            }
        }
示例#32
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);
            }
        }
示例#33
0
        private MemoryStream CreatePlayerCountImageOneMonth(GameServer server, out string fileName)
        {
            LordControl.PlayerCountStatisticInfo[] _infoArray = null;
            DateTime _endTime = DateTime.Now;
            DateTime _startTime = _endTime.AddMonths(-1);

            _infoArray = server.GetPlugInData(0, LordControl.PlugInGuid, LordControl.DataKeyPlayerCountStatistic, _startTime, _endTime) as LordControl.PlayerCountStatisticInfo[];

            if (_infoArray.Length != 0)
            {
                ArrayList playerCountArrayList = new ArrayList();

                LordControl.PlayerCountStatisticInfo tempInfo = new LordControl.PlayerCountStatisticInfo();
                tempInfo.Time = _infoArray[0].Time;

                int countInOneDay = 0;

                for (int i = 0; i < _infoArray.Length; i++)
                {
                    LordControl.PlayerCountStatisticInfo info = _infoArray[i];

                    if (tempInfo.Time.Date == info.Time.Date)
                    {
                        if (info.MaxCount > tempInfo.MaxCount)
                            tempInfo.MaxCount = info.MaxCount;
                        if (info.MinCount < tempInfo.MinCount)
                            tempInfo.MinCount = info.MinCount;
                        tempInfo.AverageCount += info.AverageCount;
                        countInOneDay++;

                        if (i == _infoArray.Length - 1)
                        {
                            tempInfo.AverageCount /= countInOneDay;
                            playerCountArrayList.Add(tempInfo);
                        }
                    }
                    else
                    {
                        tempInfo.AverageCount /= countInOneDay;

                        playerCountArrayList.Add(tempInfo);

                        tempInfo = new LordControl.PlayerCountStatisticInfo();

                        tempInfo.Time = info.Time;
                        tempInfo.AverageCount = info.AverageCount;
                        tempInfo.MaxCount = info.MaxCount;
                        tempInfo.MinCount = info.MinCount;

                        countInOneDay = 1;

                        if (i == _infoArray.Length - 1)
                        {
                            playerCountArrayList.Add(tempInfo);
                        }
                    }
                }

                double[] maxCountArray = new double[playerCountArrayList.Count];
                double[] minCountArray = new double[playerCountArrayList.Count];
                double[] averageCountArray = new double[playerCountArrayList.Count];
                double[] timeArray = new double[playerCountArrayList.Count];

                for (int i = 0; i < playerCountArrayList.Count; i++)
                {
                    LordControl.PlayerCountStatisticInfo info = playerCountArrayList[i] as LordControl.PlayerCountStatisticInfo;
                    maxCountArray[i] = info.MaxCount;
                    minCountArray[i] = info.MinCount;
                    averageCountArray[i] = info.AverageCount;
                    timeArray[i] = new XDate(info.Time);
                }

                GraphPane graphPane = new GraphPane(new Rectangle(0, 0, 840, 450), String.Empty, String.Empty, String.Empty);

                graphPane.Fill = new Fill(Color.FromArgb(212, 208, 200));

                graphPane.Legend.Fill.IsVisible = false;
                graphPane.Legend.Border.IsVisible = false;
                graphPane.Legend.FontSpec.Fill.IsVisible = false;

                graphPane.XAxis.Title.Text = "时间";
                graphPane.XAxis.MajorGrid.Color = Color.DarkGreen;
                graphPane.XAxis.Type = AxisType.Date;
                graphPane.XAxis.Scale.FontSpec.Size = 11;

                graphPane.YAxis.Title.Text = "玩家数量";
                //graphPane.YAxis.MajorGrid.IsVisible = true;
                //graphPane.YAxis.MajorGrid.DashOff = 0;
                //graphPane.YAxis.MajorGrid.Color = Color.Gray;
                //graphPane.YAxis.MinorGrid.IsVisible = true;
                //graphPane.YAxis.MinorGrid.Color = Color.LightGray;
                //graphPane.YAxis.MinorGrid.DashOff = 0;
                graphPane.YAxis.Scale.Min = 0;

                graphPane.Title.Text = string.Format("{0} [ {1}  {2} ]", "玩家数量", _startTime, _endTime);

                graphPane.AddCurve("最大", timeArray, maxCountArray, Color.Red, SymbolType.Triangle);
                graphPane.AddCurve("最小", timeArray, minCountArray, Color.Green, SymbolType.TriangleDown);
                graphPane.AddCurve("平均", timeArray, averageCountArray, Color.Orange, SymbolType.Diamond);

                graphPane.AxisChange();

                fileName = server.Group.Name + "-" + DateTime.Now.Date.ToString("yyyy-MM-dd") + "-(Month)" + ".jpg";

                MemoryStream imageMemoryStream = new MemoryStream();
                graphPane.GetImage().Save(imageMemoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                imageMemoryStream.Position = 0;

                return imageMemoryStream;
            }
            else
            {
                fileName = String.Empty;
                return null;
            }
        }
示例#34
0
        public void SingleValue()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Wacky	Widget Company\nProduction Report",
                "Time, Years\n(Since Plant Construction Startup)",
                "Widget Production\n(units/hour)" );

            double[] x = { 0.4875 };
            double[] y = { -123456 };

            LineItem curve;
            curve = testee.AddCurve( "One	Value", x, y, Color.Red, SymbolType.Diamond );
            curve.Symbol.Fill.Type = FillType.Solid;

            testee.XAxis.MajorGrid.IsVisible = true;
            testee.YAxis.MajorGrid.IsVisible = true;

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Show();

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Do you see a single value in the middle of the scale ranges?" ) );
        }
示例#35
0
        /// <summary>
        /// Zoom a specified pane in or out according to the specified zoom fraction.
        /// </summary>
        /// <remarks>
        /// The zoom will occur on the <see cref="XAxis" />, <see cref="YAxis" />, and
        /// <see cref="Y2Axis" /> only if the corresponding flag, <see cref="IsEnableHZoom" /> or
        /// <see cref="IsEnableVZoom" />, is true.  Note that if there are multiple Y or Y2 axes, all of
        /// them will be zoomed.
        /// </remarks>
        /// <param name="pane">The <see cref="GraphPane" /> instance to be zoomed.</param>
        /// <param name="zoomFraction">The fraction by which to zoom, less than 1 to zoom in, greater than
        /// 1 to zoom out.  For example, 0.9 will zoom in such that the scale is 90% of what it was
        /// originally.</param>
        /// <param name="centerPt">The screen position about which the zoom will be centered.  This
        /// value is only used if <see paramref="isZoomOnCenter" /> is true.
        /// </param>
        /// <param name="isZoomOnCenter">true to cause the zoom to be centered on the point
        /// <see paramref="centerPt" />, false to center on the <see cref="Chart.Rect" />.
        /// </param>
        /// <param name="isRefresh">true to force a refresh of the control, false to leave it unrefreshed</param>
        protected void ZoomPane(GraphPane pane, double zoomFraction, PointF centerPt,
            bool isZoomOnCenter, bool isRefresh)
        {
            double x;
            double x2;
            double[] y;
            double[] y2;

            pane.ReverseTransform(centerPt, out x, out x2, out y, out y2);

            if (_isEnableHZoom) {
                ZoomScale(pane.XAxis, zoomFraction, x, isZoomOnCenter);
                ZoomScale(pane.X2Axis, zoomFraction, x2, isZoomOnCenter);
            }
            if (_isEnableVZoom) {
                for (int i = 0; i < pane.YAxisList.Count; i++)
                    ZoomScale(pane.YAxisList[i], zoomFraction, y[i], isZoomOnCenter);
                for (int i = 0; i < pane.Y2AxisList.Count; i++)
                    ZoomScale(pane.Y2AxisList[i], zoomFraction, y2[i], isZoomOnCenter);
            }

            using (Graphics g = this.CreateGraphics()) {
                pane.AxisChange(g);
                //g.Dispose();
            }

            this.SetScroll(this.hScrollBar1, pane.XAxis, _xScrollRange.Min, _xScrollRange.Max);
            this.SetScroll(this.vScrollBar1, pane.YAxis, _yScrollRangeList[0].Min,
                           _yScrollRangeList[0].Max);

            if (isRefresh)
                Refresh();
        }
示例#36
0
        public void SmoothCurve()
        {
            //			memGraphics.CreateDoubleBuffer( form2.CreateGraphics(),
            //				form2.ClientRectangle.Width,	form2.ClientRectangle.Height );

            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Text Graph", "Label", "Y Value" );

            //	Make up some random data points
            string[] labels = { "USA", "Spain", "Qatar",	"Morocco", "UK", "Uganda",
                                  "Cambodia", "Malaysia",	"Australia", "Ecuador" };

            PointPairList points = new PointPairList();
            double numPoints = 10.0;
            for ( double i = 0; i < numPoints; i++ )
                points.Add( i / ( numPoints / 10.0 ) + 1.0, Math.Sin( i / ( numPoints / 10.0 ) * Math.PI / 2.0 ) );

            //	Generate a red	curve with diamond
            //	symbols, and "My Curve" in the legend
            LineItem myCurve = testee.AddCurve( "My	Curve",
                points, Color.Red, SymbolType.Diamond );
            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            //	Set the labels at	an angle so they	don't overlap
            testee.XAxis.Scale.FontSpec.Angle = 0;
            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            myCurve.Line.IsSmooth = true;

            for ( float tension = 0.0F; tension < 3.0F; tension += 0.1F )
            {
                myCurve.Line.SmoothTension = tension;
                form2.Refresh();

                TestUtils.DelaySeconds( 50 );
            }
            for ( float tension = 3.0F; tension >= 0F; tension -= 0.1F )
            {
                myCurve.Line.SmoothTension = tension;
                form2.Refresh();

                TestUtils.DelaySeconds( 50 );
            }

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did you see varying levels of smoothing?" ) );
        }
示例#37
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);
            }
        }
示例#38
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);
            }
        }
示例#39
0
        public void AllNaN()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "My Test NaN Graph", "Date", "My	Y	Axis" );

            //	Make up some random data points
            double[] x = new double[36];
            double[] y = new double[36];
            for ( int i = 0; i < 36; i++ )
            {
                x[i] = (double)new XDate( 1995, i + 1, 1 );
                y[i] = System.Double.NaN;
            }
            //	Generate a red	curve with diamond
            //	symbols, and "My Curve" in the legend
            CurveItem myCurve = testee.AddCurve( "My Curve",
                x, y, Color.Red, SymbolType.Circle );
            //	Set the XAxis	to date type
            testee.XAxis.Type = AxisType.Date;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Show();

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Do you see a graph with all values missing (NaN's)?" ) );
        }
示例#40
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 );
        }
示例#41
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public ZedGraphControl()
        {
            InitializeComponent();

            // These commands do nothing, but they get rid of the compiler warnings for
            // unused events
            bool b = MouseDown == null || MouseUp == null || MouseMove == null;

            // Link in these events from the base class, since we disable them from this class.
            base.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ZedGraphControl_MouseDown);
            base.MouseUp   += new System.Windows.Forms.MouseEventHandler(this.ZedGraphControl_MouseUp);
            base.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ZedGraphControl_MouseMove);

            //this.MouseWheel += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseWheel );

            // Use double-buffering for flicker-free updating:
            SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint
                     | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw, true);
            //isTransparentBackground = false;
            //SetStyle( ControlStyles.Opaque, false );
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            //this.BackColor = Color.Transparent;

            _resourceManager = new ResourceManager("ZedGraph.ZedGraph.ZedGraphLocale",
                                                   Assembly.GetExecutingAssembly());

            Rectangle rect = new Rectangle(0, 0, this.Size.Width, this.Size.Height);

            _masterPane                 = new MasterPane("", rect);
            _masterPane.Margin.All      = 0;
            _masterPane.Title.IsVisible = false;

            string titleStr = _resourceManager.GetString("title_def");
            string xStr     = _resourceManager.GetString("x_title_def");
            string yStr     = _resourceManager.GetString("y_title_def");

            //GraphPane graphPane = new GraphPane( rect, "Title", "X Axis", "Y Axis" );
            GraphPane graphPane = new GraphPane(rect, titleStr, xStr, yStr);

            using (Graphics g = this.CreateGraphics())
            {
                graphPane.AxisChange(g);
                //g.Dispose();
            }
            _masterPane.Add(graphPane);

            this.hScrollBar1.Minimum = 0;
            this.hScrollBar1.Maximum = 100;
            this.hScrollBar1.Value   = 0;

            this.vScrollBar1.Minimum = 0;
            this.vScrollBar1.Maximum = 100;
            this.vScrollBar1.Value   = 0;

            _xScrollRange      = new ScrollRange(true);
            _yScrollRangeList  = new ScrollRangeList();
            _y2ScrollRangeList = new ScrollRangeList();

            _yScrollRangeList.Add(new ScrollRange(true));
            _y2ScrollRangeList.Add(new ScrollRange(false));

            _zoomState      = null;
            _zoomStateStack = new ZoomStateStack();
        }
示例#42
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public ZedGraphControl()
        {
            InitializeComponent();

            // These commands do nothing, but they get rid of the compiler warnings for
            // unused events
            bool b = MouseDown == null || MouseUp == null || MouseMove == null;

            // Link in these events from the base class, since we disable them from this class.
            base.MouseDown += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseDown );
            base.MouseUp += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseUp );
            base.MouseMove += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseMove );

            //this.MouseWheel += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseWheel );

            // Use double-buffering for flicker-free updating:
            SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint
                | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw, true );
            //isTransparentBackground = false;
            //SetStyle( ControlStyles.Opaque, false );
            SetStyle( ControlStyles.SupportsTransparentBackColor, true );
            //this.BackColor = Color.Transparent;

            _resourceManager = new ResourceManager( "VixenModules.App.Curves.ZedGraph.ZedGraphLocale",
                Assembly.GetExecutingAssembly());

            Rectangle rect = new Rectangle( 0, 0, this.Size.Width, this.Size.Height );
            _masterPane = new MasterPane( "", rect );
            _masterPane.Margin.All = 0;
            _masterPane.Title.IsVisible = false;

            string titleStr = _resourceManager.GetString( "title_def" );
            string xStr = _resourceManager.GetString( "x_title_def" );
            string yStr = _resourceManager.GetString( "y_title_def" );

            //GraphPane graphPane = new GraphPane( rect, "Title", "X Axis", "Y Axis" );
            GraphPane graphPane = new GraphPane( rect, titleStr, xStr, yStr );
            using ( Graphics g = this.CreateGraphics() )
            {
                graphPane.AxisChange( g );
                //g.Dispose();
            }
            _masterPane.Add( graphPane );

            this.hScrollBar1.Minimum = 0;
            this.hScrollBar1.Maximum = 100;
            this.hScrollBar1.Value = 0;

            this.vScrollBar1.Minimum = 0;
            this.vScrollBar1.Maximum = 100;
            this.vScrollBar1.Value = 0;

            _xScrollRange = new ScrollRange( true );
            _yScrollRangeList = new ScrollRangeList();
            _y2ScrollRangeList = new ScrollRangeList();

            _yScrollRangeList.Add( new ScrollRange( true ) );
            _y2ScrollRangeList.Add( new ScrollRange( false ) );

            _zoomState = null;
            _zoomStateStack = new ZoomStateStack();
        }
示例#43
0
 /// <summary>
 /// Restore the scale ranging to automatic mode, and recalculate the
 /// <see cref="Axis"/> scale ranges
 /// </summary>
 /// <param name="pane">
 /// A reference to the <see cref="GraphPane"/> object that is the parent or
 /// owner of this object.
 /// </param>
 /// <param name="g">
 /// A graphic device object to be drawn into.  This is normally e.Graphics from the
 /// PaintEventArgs argument to the Paint() method.
 /// </param>
 /// <seealso cref="ZedGraph.Scale.MinAuto"/>
 /// <seealso cref="ZedGraph.Scale.MaxAuto"/>
 /// <seealso cref="ZedGraph.Scale.MajorStepAuto"/>
 /// <seealso cref="ZedGraph.Scale.MagAuto"/>
 /// <seealso cref="ZedGraph.Scale.FormatAuto"/>
 public void ResetAutoScale( GraphPane pane, IGraphics g )
 {
     _scale._minAuto = true;
     _scale._maxAuto = true;
     _scale._majorStepAuto = true;
     _scale._minorStepAuto = true;
     _crossAuto = true;
     _scale._magAuto = true;
     //this.numDecAuto = true;
     _scale._formatAuto = true;
     pane.AxisChange( g );
 }
示例#44
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public ZedGraphControl()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            // Use double-buffering for flicker-free updating:
            SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint
                | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw, true );
            //isTransparentBackground = false;
            SetStyle( ControlStyles.Opaque, false );
            SetStyle( ControlStyles.SupportsTransparentBackColor, true );

            Rectangle rect = new Rectangle( 0, 0, this.Size.Width, this.Size.Height );
            graphPane = new GraphPane( rect, "Title", "X-Axis", "Y-Axis" );
            graphPane.AxisChange( this.CreateGraphics() );

            this.isShowPointValues = false;
            this.pointValueFormat = PointPair.DefaultFormat;
        }
示例#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;
        }
示例#46
0
文件: Curve.cs 项目: Jchuchla/vixen
        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;
        }
        public void UpdateGraph()
        {
            try
            {
                try
                {
                    DateTime startTime = DateTime.Now;

                    // Take a copy of the metrics file.
                    if (File.Exists(m_metricsFileCopyName))
                    {
                        File.Delete(m_metricsFileCopyName);
                    }

                    logger.Debug("Copying " + m_metricsFileName + " to " + m_metricsFileCopyName);
                    File.Copy(m_metricsFileName, m_metricsFileCopyName);

                    StreamReader metricsReader = new StreamReader(m_metricsFileCopyName);
                    m_totalSIPPacketsList.Clear();
                    m_sipRequestsInList.Clear();
                    m_sipResponsesInList.Clear();
                    m_sipRequestsOutList.Clear();
                    m_sipResponsesOutList.Clear();
                    m_pendingTransactionsList.Clear();
                    m_discardsList.Clear();
                    m_unrecognisedList.Clear();
                    m_tooLargeList.Clear();
                    m_badSIPList.Clear();
                    m_stunList.Clear();
                    m_totalParseTimeList.Clear();
                    m_avgParseTimeList.Clear();
                    m_sipMethodsLists = new Dictionary<SIPMethodsEnum, RollingPointPairList>();
                    m_topTalkersLists.Clear();
                    m_topTalkersCount.Clear();

                    string metricsLine = metricsReader.ReadLine();
                    int sampleCount = 0;
                    while (metricsLine != null)
                    {
                        #region Process metrics line.

                        if (metricsLine.Trim().Length != 0 && Regex.Match(metricsLine, ",").Success)
                        {
                            string[] fields = metricsLine.Split(',');
                            XDate sampleDate = new XDate(DateTime.Parse(fields[1]));
                            int samplePeriod = Convert.ToInt32(fields[2]);              // Sample period in seconds.
                            if (samplePeriod == 0)
                            {
                                throw new ApplicationException("The sample period for a measurement was 0 in SIPTransportMetricsGraphAgent.");
                            }

                            if (metricsLine.StartsWith(m_trafficMetrics))
                            {
                                try
                                {
                                    m_totalSIPPacketsList.Add(sampleDate, Convert.ToDouble(fields[3]) / samplePeriod);
                                    m_sipRequestsInList.Add(sampleDate, Convert.ToDouble(fields[4]) / samplePeriod);
                                    m_sipResponsesInList.Add(sampleDate, Convert.ToDouble(fields[5]) / samplePeriod);
                                    m_sipRequestsOutList.Add(sampleDate, Convert.ToDouble(fields[6]) / samplePeriod);
                                    m_sipResponsesOutList.Add(sampleDate, Convert.ToDouble(fields[7]) / samplePeriod);
                                    m_pendingTransactionsList.Add(sampleDate, Convert.ToDouble(fields[8]));
                                    m_unrecognisedList.Add(sampleDate, Convert.ToDouble(fields[9]) / samplePeriod);
                                    m_badSIPList.Add(sampleDate, Convert.ToDouble(fields[10]) / samplePeriod);
                                    m_stunList.Add(sampleDate, Convert.ToDouble(fields[11]) / samplePeriod);
                                    m_discardsList.Add(sampleDate, Convert.ToDouble(fields[12]) / samplePeriod);
                                    m_tooLargeList.Add(sampleDate, Convert.ToDouble(fields[13]) / samplePeriod);
                                    m_totalParseTimeList.Add(sampleDate, Convert.ToDouble(fields[14]) / samplePeriod);
                                    m_avgParseTimeList.Add(sampleDate, Convert.ToDouble(fields[15]));
                                    sampleCount++;
                                }
                                catch (Exception sampleExcp)
                                {
                                    logger.Warn("Could not process metrics sample: " + metricsLine + ". " + sampleExcp.Message);
                                }
                            }
                            else if (metricsLine.StartsWith(m_methodMetrics))
                            {
                                for (int index = 3; index < fields.Length; index++)
                                {
                                    string[] methodSplit = fields[index].Split('=');
                                    SIPMethodsEnum method = SIPMethods.GetMethod(methodSplit[0]);
                                    int methodPackets = Convert.ToInt32(methodSplit[1]) / samplePeriod;

                                    if(!m_sipMethodsLists.ContainsKey(method))
                                    {
                                        m_sipMethodsLists.Add(method, new RollingPointPairList(GRAPH_SAMPLES));
                                    }

                                    m_sipMethodsLists[method].Add(sampleDate, methodPackets);
                                }
                            }
                            else if (metricsLine.StartsWith(m_topTalkerMetrics))
                            {
                                for (int index = 3; index < fields.Length; index++)
                                {
                                    string[] talkersSplit = fields[index].Split('=');
                                    string topTalkerSocket = talkersSplit[0];
                                    int topTalkerPackets = Convert.ToInt32(talkersSplit[1]) / samplePeriod;

                                    if (!m_topTalkersLists.ContainsKey(topTalkerSocket))
                                    {
                                        m_topTalkersLists.Add(topTalkerSocket, new RollingPointPairList(GRAPH_SAMPLES));
                                        m_topTalkersCount.Add(topTalkerSocket, 0);
                                    }

                                    //logger.Debug("Adding point for " + topTalkerSocket + " and " + topTalkerPackets + ".");
                                    m_topTalkersLists[topTalkerSocket].Add(sampleDate, topTalkerPackets);
                                    m_topTalkersCount[topTalkerSocket] = m_topTalkersCount[topTalkerSocket] + topTalkerPackets;
                                }
                            }
                        }

                        #endregion

                        metricsLine = metricsReader.ReadLine();
                    }
                    metricsReader.Close();

                    #region Create the traffic graphs.

                    GraphPane totalSIPPacketsGraphPane = new GraphPane(new Rectangle(0, 0, GRAPH_WIDTH, GRAPH_HEIGHT), "Total SIP Packets per Second", "Time", "Packets/s");
                    GraphPane pendingSIPTransactionsGraphPane = new GraphPane(new Rectangle(0, 0, GRAPH_WIDTH, GRAPH_HEIGHT), "Pending SIP Transactions", "Time", "Total");
                    GraphPane breakdownGraphPane = new GraphPane(new Rectangle(0, 0, GRAPH_WIDTH, GRAPH_HEIGHT), "SIP Request and Responses per Second", "Time", "Packets/s");
                    GraphPane anomaliesGraphPane = new GraphPane(new Rectangle(0, 0, GRAPH_WIDTH, GRAPH_HEIGHT), "Anomalous Packets per Second", "Time", "Packets/s");
                    GraphPane totalParseTimesGraphPane = new GraphPane(new Rectangle(0, 0, GRAPH_WIDTH, GRAPH_HEIGHT), "SIP Packet Parse Time per Second", "Time", "Total Parse Tme (ms)/s");
                    GraphPane averageParseTimesGraphPane = new GraphPane(new Rectangle(0, 0, GRAPH_WIDTH, GRAPH_HEIGHT), "Average SIP Packet Parse Time", "Time", "Average Parse Tme (ms)");

                    totalSIPPacketsGraphPane.Legend.IsVisible = false;
                    totalSIPPacketsGraphPane.XAxis.Type = AxisType.Date;
                    totalSIPPacketsGraphPane.XAxis.Scale.Format = "HH:mm:ss";

                    pendingSIPTransactionsGraphPane.Legend.IsVisible = false;
                    pendingSIPTransactionsGraphPane.XAxis.Type = AxisType.Date;
                    pendingSIPTransactionsGraphPane.XAxis.Scale.Format = "HH:mm:ss";

                    breakdownGraphPane.Legend.Location.AlignH = AlignH.Right;
                    breakdownGraphPane.XAxis.Type = AxisType.Date;
                    breakdownGraphPane.XAxis.Scale.Format = "HH:mm:ss";

                    anomaliesGraphPane.XAxis.Type = AxisType.Date;
                    anomaliesGraphPane.XAxis.Scale.Format = "HH:mm:ss";

                    totalParseTimesGraphPane.XAxis.Type = AxisType.Date;
                    totalParseTimesGraphPane.Legend.IsVisible = false;
                    totalParseTimesGraphPane.XAxis.Scale.Format = "HH:mm:ss";

                    averageParseTimesGraphPane.XAxis.Type = AxisType.Date;
                    averageParseTimesGraphPane.Legend.IsVisible = false;
                    averageParseTimesGraphPane.XAxis.Scale.Format = "HH:mm:ss";

                    LineItem totalSIPPacketsCurve = totalSIPPacketsGraphPane.AddCurve("Total SIP Packets", m_totalSIPPacketsList, Color.Black, SymbolType.None);
                    LineItem pendingTransactionsCurve = pendingSIPTransactionsGraphPane.AddCurve("Pending SIP Transactions", m_pendingTransactionsList, Color.Black, SymbolType.None);
                    LineItem sipRequestsInCurve = breakdownGraphPane.AddCurve("Requests In", m_sipRequestsInList, Color.Blue, SymbolType.None);
                    LineItem sipResponsesInCurve = breakdownGraphPane.AddCurve("Responses In", m_sipResponsesInList, Color.DarkGreen, SymbolType.None);
                    LineItem sipRequestsOutCurve = breakdownGraphPane.AddCurve("Requests Out", m_sipRequestsOutList, Color.BlueViolet, SymbolType.None);
                    LineItem sipResponsesOutCurve = breakdownGraphPane.AddCurve("Responses Out", m_sipResponsesOutList, Color.DarkKhaki, SymbolType.None);
                    LineItem discardsCurve = anomaliesGraphPane.AddCurve("Discards", m_discardsList, Color.Red, SymbolType.None);
                    LineItem badSIPCurve = anomaliesGraphPane.AddCurve("Bad SIP", m_badSIPList, Color.Purple, SymbolType.None);
                    LineItem unrecognisedCurve = anomaliesGraphPane.AddCurve("Unrecognised", m_unrecognisedList, Color.Green, SymbolType.None);
                    LineItem tooLargeCurve = anomaliesGraphPane.AddCurve("Too Large", m_tooLargeList, Color.Coral, SymbolType.None);
                    LineItem stunCurve = anomaliesGraphPane.AddCurve("STUN", m_stunList, Color.Blue, SymbolType.None);
                    LineItem totalParseTimeCurve = totalParseTimesGraphPane.AddCurve("Total Parse Time", m_totalParseTimeList, Color.Black, SymbolType.None);
                    LineItem averageParseTimeCurve = averageParseTimesGraphPane.AddCurve("Average Parse Time", m_avgParseTimeList, Color.Black, SymbolType.None);

                    totalSIPPacketsGraphPane.AxisChange(m_g);
                    pendingSIPTransactionsGraphPane.AxisChange(m_g);
                    breakdownGraphPane.AxisChange(m_g);
                    anomaliesGraphPane.AxisChange(m_g);
                    totalParseTimesGraphPane.AxisChange(m_g);
                    averageParseTimesGraphPane.AxisChange(m_g);

                    Bitmap totalsGraphBitmap = totalSIPPacketsGraphPane.GetImage();
                    totalsGraphBitmap.Save(m_localGraphsDir + "siptotals.png", ImageFormat.Png);

                    Bitmap pendingTransactionsGraphBitmap = pendingSIPTransactionsGraphPane.GetImage();
                    pendingTransactionsGraphBitmap.Save(m_localGraphsDir + "siptransactions.png", ImageFormat.Png);

                    Bitmap breakdownGraphBitmap = breakdownGraphPane.GetImage();
                    breakdownGraphBitmap.Save(m_localGraphsDir + "sipmessagetypes.png", ImageFormat.Png);

                    Bitmap anomaliesGraphBitmap = anomaliesGraphPane.GetImage();
                    anomaliesGraphBitmap.Save(m_localGraphsDir + "anomalies.png", ImageFormat.Png);

                    Bitmap totalParseTimeGraphBitmap = totalParseTimesGraphPane.GetImage();
                    totalParseTimeGraphBitmap.Save(m_localGraphsDir + "siptotalparse.png", ImageFormat.Png);

                    Bitmap averageParseTimeGraphBitmap = averageParseTimesGraphPane.GetImage();
                    averageParseTimeGraphBitmap.Save(m_localGraphsDir + "sipaverageparse.png", ImageFormat.Png);

                    #endregion

                    #region Create SIP methods graph.

                    GraphPane methodsGraphPane = new GraphPane(new Rectangle(0, 0, GRAPH_WIDTH, GRAPH_HEIGHT), "SIP Packets for Method per Second", "Time", "SIP Packets/s");
                    methodsGraphPane.XAxis.Type = AxisType.Date;
                    methodsGraphPane.XAxis.Scale.Format = "HH:mm:ss";

                    foreach (KeyValuePair<SIPMethodsEnum, RollingPointPairList> entry in m_sipMethodsLists)
                    {
                        Color methodColor = (m_methodColours.ContainsKey(entry.Key)) ? m_methodColours[entry.Key] : Color.Black;
                        LineItem methodCurve = methodsGraphPane.AddCurve(entry.Key.ToString(), entry.Value, methodColor, SymbolType.None);
                    }

                    methodsGraphPane.AxisChange(m_g);
                    Bitmap methodsGraphBitmap = methodsGraphPane.GetImage();
                    methodsGraphBitmap.Save(m_localGraphsDir + "sipmethods.png", ImageFormat.Png);

                    #endregion

                    #region Create top talkers graph.

                    // Get the top 10 talkers.
                    if (m_topTalkersCount.Count > 0)
                    {
                        string[] topTalkerSockets = new string[m_topTalkersCount.Count];
                        int[] topTalkerValues = new int[m_topTalkersCount.Count];
                        m_topTalkersCount.Keys.CopyTo(topTalkerSockets, 0);
                        m_topTalkersCount.Values.CopyTo(topTalkerValues, 0);

                        Array.Sort<int, string>(topTalkerValues, topTalkerSockets);

                        GraphPane toptalkersGraphPane = new GraphPane(new Rectangle(0, 0, GRAPH_WIDTH, GRAPH_HEIGHT), "SIP Top Talkers", "Time", "SIP Packets/s");
                        toptalkersGraphPane.XAxis.Type = AxisType.Date;
                        toptalkersGraphPane.XAxis.Scale.Format = "HH:mm:ss";

                        //foreach (KeyValuePair<string, RollingPointPairList> entry in m_topTalkersLists)
                        for (int index = topTalkerSockets.Length - 1; (index >= topTalkerSockets.Length - NUMBER_TOPTALKERS_TOPPLOT && index >= 0); index--)
                        {
                            string socket = topTalkerSockets[index];
                            RollingPointPairList topTalkerPoints = m_topTalkersLists[socket];
                            Color topTalkerColor = m_topTalkerColours[topTalkerSockets.Length - 1 - index];
                            //logger.Debug("Adding curve for " + socket + " (count=" + topTalkerValues[index] + ").");
                            LineItem topTalkersCurve = toptalkersGraphPane.AddCurve(socket, topTalkerPoints, topTalkerColor, SymbolType.None);
                            //break;
                        }

                        toptalkersGraphPane.AxisChange(m_g);
                        Bitmap topTalkersGraphBitmap = toptalkersGraphPane.GetImage();
                        topTalkersGraphBitmap.Save(m_localGraphsDir + "siptoptalkers.png", ImageFormat.Png);
                    }

                    #endregion

                    logger.Debug("Metrics graph for " + m_metricsFileCopyName + " completed in " + DateTime.Now.Subtract(startTime).TotalMilliseconds.ToString("0.##") + "ms, " + sampleCount + " samples.");

                    #region Uplodad file to server.

                    /*if (m_serverFilename != null && m_serverFilename.Trim().Length > 0)
                    {
                        Uri target = new Uri(m_serverFilename);
                        FtpWebRequest request = (FtpWebRequest)WebRequest.Create(target);
                        request.Method = WebRequestMethods.Ftp.UploadFile;
                        request.Credentials = new NetworkCredential("anonymous", "*****@*****.**");

                        FileStream localStream = File.OpenRead(m_totalsGraphFilename);
                        Stream ftpStream = request.GetRequestStream();
                        byte[] buffer = new byte[localStream.Length];
                        localStream.Read(buffer, 0, buffer.Length);
                        localStream.Close();
                        ftpStream.Write(buffer, 0, buffer.Length);
                        ftpStream.Close();

                        FtpWebResponse response = (FtpWebResponse)request.GetResponse();
                        response.Close();
                        //logger.Debug("Result of ftp upload to " + m_serverFilename + " is " + response.StatusDescription + ".");
                    }*/

                    #endregion
                }
                catch (Exception graphExcp)
                {
                    logger.Error("Exception Saving Graph. " + graphExcp.Message);
                }
            }
            catch (Exception excp)
            {
                logger.Debug("Exception UpdateGraph. " + excp.Message);
            }
        }
 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;
 }