public void PointCreate(string name, double x, double y, double theta, double radius, Color fillColor, Color borderColor) { if (zedGraphControl.GraphPane == null) { return; } //foreach (zedGraphControl.GraphPane.GraphObjList.) var robot = new ZedGraph.EllipseObj { Location = new Location(x, y, radius, radius, CoordType.AxisXYScale, AlignH.Center, AlignV.Center), ZOrder = ZedGraph.ZOrder.A_InFront, Fill = new Fill(fillColor), Border = new Border(borderColor, 2), Tag = name }; zedGraphControl.GraphPane.GraphObjList.Add(robot); }
/// <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 ) { } }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="EllipseObj"/> object from /// which to copy</param> public EllipseObj(EllipseObj rhs) : base(rhs) { rhs._angle = this._angle; }
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 ) ); }