RE: [Shapedotnet-development] m_map and Canvas to be public
Status: Beta
Brought to you by:
k5jvc
From: E. P. <er...@pe...> - 2004-01-18 19:45:59
|
Hi John, ok, good thinking there :D It seems i overlooked the 'adding layer by string',... think i used in 0.8 or 0.9. BTW, could you post a snippet on handling the stretch/warp as you tried, but where not satisfied with? Me. -----Original Message----- From: sha...@li... [mailto:sha...@li...] On Behalf Of John Coleman Sent: zondag 18 januari 2004 20:01 To: sha...@li... Subject: Re: [Shapedotnet-development] m_map and Canvas to be public Yep, you're right they need to be public. It makes the control significantly easier to use and to maintain. I added the property "MapCanvas" to the control and it returns the PictureBox that the map is drawn to. I added the property "MapCollection" to the control and it returns the Map object of the control. So your example will look like this now: private void DrawAtCenter (double ptX, double ptY) { // Center & Draw mapControl.MapCollection.Center(ptX, ptY); mapControl.Draw(); // Visualize point Graphics g; g = mapControl.MapCanvas.CreateGraphics(); g.CompositingMode = CompositingMode.SourceOver; g.SmoothingMode = SmoothingMode.HighQuality; g.TranslateTransform(mapControl.Width /2,mapControl.Height/2); Point[] curvePoints = { new Point( 0, 10), new Point( 3, 3), new Point( 10, 0), new Point( 3, -3), new Point( 0, -10), new Point( -3, -3), new Point( -10, 0), new Point( -3, 3), }; // Draw polygon g.DrawPolygon(new Pen(Color.Black,1), curvePoints); g.FillPolygon(Brushes.Chartreuse, curvePoints, FillMode.Winding); g.FillEllipse(Brushes.Red, -2, -2, 4, 4); g.Dispose(); } How's that? As for your last request, I added the ability to add a new layer by passing in a string in beta 1. Thanks! John E. Perik wrote: Hi John, For certain tasks it needs the m_map and Canvas to be public, see the examples below. Any intents of changing them to a non-protected status? Also using an aditional add-layer method (see below),...think this would be interesting to fit in too. For an application one can add some layers by default when starting up. HTH, Me. // Modified in the control: public System.Windows.Forms.PictureBox Canvas; public Map m_map; // Example to draw upon the canvas // --> Needs m_map and Canvas set to public: private void DrawAtCenter (double ptX, double ptY) { // Center & Draw mapControl.m_map.Center(ptX, ptY); mapControl.Draw(); // Visualize point Graphics g; g = mapControl.Canvas.CreateGraphics(); g.CompositingMode = CompositingMode.SourceOver; g.SmoothingMode = SmoothingMode.HighQuality; g.TranslateTransform(mapControl.Width /2,mapControl.Height/2); Point[] curvePoints = { new Point( 0, 10), new Point( 3, 3), new Point( 10, 0), new Point( 3, -3), new Point( 0, -10), new Point( -3, -3), new Point( -10, 0), new Point( -3, 3), }; // Draw polygon g.DrawPolygon(new Pen(Color.Black,1), curvePoints); g.FillPolygon(Brushes.Chartreuse, curvePoints, FillMode.Winding); g.FillEllipse(Brushes.Red, -2, -2, 4, 4); g.Dispose(); } // Example for hardcoded zooming // --> Needs m_map and Canvas set to public: myRect = new GIS.RectangleD(); myPoint1 = new GIS.PointD(); myPoint2 = new GIS.PointD(); myPoint1.X = 3.3; myPoint1.Y = 53.7; myPoint2.X = 7.5; myPoint2.Y = 50.6; myRect.UL = myPoint1; myRect.LR = myPoint2; mapControl.m_map.ZoomArea(myRect); mapControl.Draw(); // GIS.Map.cs --> Add a map without dialog box [Description("Read file without dialog"), Browsable( false )] public void AddLayerFromString(string path_and_name_of_shapefile) { this.Cursor = Cursors.AppStarting; m_map.Add( path_and_name_of_shapefile ); this.Cursor = Cursors.Default; Draw(); } CalculateExtents is not used in the AddLayerFromString example above,... this would be something for the user to decide. ------------------------------------------------------- The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. http://www.eclipsecon.org/osdn _______________________________________________ Shapedotnet-development mailing list Sha...@li... https://lists.sourceforge.net/lists/listinfo/shapedotnet-development |