Beispiel #1
0
 /// <summary>
 /// Add the <see cref="ZedGraphWebGraphObj" /> objects defined in the webcontrol to
 /// the <see cref="GraphPane" /> as <see cref="GraphObj" /> objects.
 /// </summary>
 /// <param name="g">The <see cref="Graphics" /> instance of interest.</param>
 /// <param name="pane">The <see cref="GraphPane" /> object to receive the
 /// <see cref="GraphObj" /> objects.</param>
 protected void AddWebGraphItems( Graphics g, GraphPane pane )
 {
     try
     {
         ZedGraphWebGraphObj draw;
         for ( int i = 0; i < GraphObjList.Count; i++ )
         {
             draw = GraphObjList[i];
             if ( draw is ZedGraphWebTextObj )
             {
                 ZedGraphWebTextObj item = (ZedGraphWebTextObj)draw;
                 TextObj x = new TextObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZedGraphWebArrowObj )
             {
                 ZedGraphWebArrowObj item = (ZedGraphWebArrowObj)draw;
                 ArrowObj x = new ArrowObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZedGraphWebImageObj )
             {
                 ZedGraphWebImageObj item = (ZedGraphWebImageObj)draw;
                 ImageObj x = new ImageObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZedGraphWebBoxObj )
             {
                 ZedGraphWebBoxObj item = (ZedGraphWebBoxObj)draw;
                 BoxObj x = new BoxObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZedGraphWebEllipseObj )
             {
                 ZedGraphWebEllipseObj item = (ZedGraphWebEllipseObj)draw;
                 EllipseObj x = new EllipseObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
         }
     }
     catch ( Exception )
     {
     }
 }
Beispiel #2
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="ImageObj"/> object from which to copy</param>
 public ImageObj(ImageObj rhs)
     : base(rhs)
 {
     _image = rhs._image;
     _isScaled = rhs.IsScaled;
 }
Beispiel #3
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 ) );
        }
Beispiel #4
0
        // Build the Chart
        private void CreateGraph_ImageObj( ZedGraphControl zg1 )
        {
            // get a reference to the GraphPane
            GraphPane myPane = zg1.GraphPane;

            // Set the Titles
            myPane.Title.Text = "My Test Bar Graph";
            myPane.XAxis.Title.Text = "Label";
            myPane.YAxis.Title.Text = "My Y Axis";
            myPane.X2Axis.Title.Text = "The Top X Axis";
            myPane.Y2Axis.Title.Text = "Y2 Axis";

            myPane.X2Axis.IsVisible = true;
            myPane.X2Axis.Scale.IsReverse = true;
            myPane.Y2Axis.IsVisible = true;

            // Make up some random data points
            string[] labels = { "Panther", "Lion", "Cheetah",
                      "Cougar", "Tiger", "Leopard" };
            double[] x = { 1, 2, 3, 4, 5, 6 };
            double[] y = { 100, 115, 75, 22, 98, 40 };
            double[] y2 = { 90, 100, 95, 35, 80, 35 };
            double[] y3 = { 80, 110, 65, 15, 54, 67 };
            double[] y4 = { 120, 125, 100, 40, 105, 75 };

            // Generate a red bar with "Curve 1" in the legend
            //BarItem myBar = myPane.AddBar( "Curve 1 label is long\nsecond line", null, y, Color.Red );
            BarItem myBar = myPane.AddBar( "Curve 1", null, y, Color.Red );
            myBar.Bar.Fill = new Fill( Color.Red, Color.White, Color.Red );

            // Generate a blue bar with "Curve 2" in the legend
            myBar = myPane.AddBar( "Curve 2", null, y2, Color.Blue );
            myBar.Bar.Fill = new Fill( Color.Blue, Color.White, Color.Blue );

            // Generate a green bar with "Curve 3" in the legend
            //myBar = myPane.AddBar( "Curve 3\ntwo lines", null, y3, Color.Green );
            myBar = myPane.AddBar( "Curve 3", null, y3, Color.Green );
            myBar.Bar.Fill = new Fill( Color.Green, Color.White, Color.Green );

            // Generate a black line with "Curve 4" in the legend
            LineItem myCurve = myPane.AddCurve( "Curve 4",
                    x, y4, Color.Black, SymbolType.Circle );
            myCurve.IsX2Axis = true;

            myCurve.Line.Fill = new Fill( Color.White,
                                         Color.LightSkyBlue, -45F );

            // Fix up the curve attributes a little
            myCurve.Symbol.Size = 8.0F;
            myCurve.Symbol.Fill = new Fill( Color.White );
            myCurve.Line.Width = 2.0F;

            // Draw the X tics between the labels instead of
            // at the labels
            myPane.XAxis.MajorTic.IsBetweenLabels = true;

            // Set the XAxis labels
            myPane.XAxis.Scale.TextLabels = labels;
            // Set the XAxis to Text type
            myPane.XAxis.Type = AxisType.Text;

            // Fill the Axis and Pane backgrounds
            myPane.Chart.Fill = new Fill( Color.White,
                    Color.FromArgb( 255, 255, 166 ), 90F );
            myPane.Fill = new Fill( Color.FromArgb( 250, 250, 255 ) );

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

            LineObj line = new LineObj( Color.Black, 2.3, 0, 2.3, 1 );
            line.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
            line.Line.Width = 2.0f;
            myPane.GraphObjList.Add( line );

            //Image image = Image.FromFile( @"c:\temp\vtx1330.jpg" );
            Image image = Bitmap.FromFile( @"c:\temp\vtx1300crop.jpg" );

            ImageObj imageObj = new ImageObj( image, new RectangleF( 3, 120, 2, 100 ) );
            imageObj.IsScaled = false;
            //			imageObj.IsVisible = true;
            imageObj.ZOrder = ZOrder.E_BehindCurves;
            //			imageObj.Location.CoordinateFrame = CoordType.ChartFraction;
            myPane.GraphObjList.Add( imageObj );

            //			myPane.Chart.Fill = new Fill( image, WrapMode.Tile );

            //            myPane.Title.Text = null;

            //          GraphPane newOne = myPane.Clone();

            // Tell ZedGraph to refigure the
            // axes since the data have changed
            zg1.AxisChange();
        }
Beispiel #5
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="ImageObj"/> object from which to copy</param>
 public ImageObj(ImageObj rhs) : base(rhs)
 {
     _image    = rhs._image;
     _isScaled = rhs.IsScaled;
 }