Re: [Shapedotnet-development] m_map and Canvas to be public
Status: Beta
Brought to you by:
k5jvc
From: John C. <jo...@k5...> - 2004-01-18 19:00:09
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"> <title></title> </head> <body text="#000000" bgcolor="#ffffff"> Yep, you're right they need to be public. It makes the control significantly easier to use and to maintain.<br> <br> I added the property "MapCanvas" to the control and it returns the PictureBox that the map is drawn to.<br> I added the property "MapCollection" to the control and it returns the Map object of the control.<br> <br> So your example will look like this now:<br> <br> <big><tt><font size="2"><big>private void <span class="139190511-18012004"> DrawAtCenter </span>(double ptX, double ptY)<br> {<br> // Center & Draw<br> mapControl.<b>MapCollection</b>.Center(ptX, ptY);<br> mapControl.Draw();<br> // Visualize point<br> Graphics g;<br> g = mapControl.<b>MapCanvas</b>.CreateGraphics();<br> g.CompositingMode = CompositingMode.SourceOver; <br> g.SmoothingMode = SmoothingMode.HighQuality;<br> g.TranslateTransform(mapControl.Width /2,mapControl.Height/2);<br> Point[] curvePoints =<br> {<br> new Point( 0, 10),<br> new Point( 3, 3),<br> new Point( 10, 0),<br> new Point( 3, -3),<br> new Point( 0, -10),<br> new Point( -3, -3),<br> new Point( -10, 0),<br> new Point( -3, 3),<br> };<br> // Draw polygon <br> g.DrawPolygon(new Pen(Color.Black,1), curvePoints);<br> g.FillPolygon(Brushes.Chartreuse, curvePoints, FillMode.Winding);<br> g.FillEllipse(Brushes.Red, -2, -2, 4, 4);<br> g.Dispose();<br> }</big></font></tt></big><br> <br> How's that?<br> <br> As for your last request, I added the ability to add a new layer by passing in a string in beta 1.<br> <br> Thanks!<br> John<br> <br> E. Perik wrote:<br> <blockquote type="cite" cite="mid000001c3ddb3$cc966a40$0a01a8c0@xp"> <meta http-equiv="Content-Type" content="text/html; "> <title>Message</title> <meta content="MSHTML 6.00.2800.1106" name="GENERATOR"> <div><font face="Arial"><font size="2"><span class="139190511-18012004">Hi John,</span></font></font></div> <div><font face="Arial"><font size="2"><span class="139190511-18012004"> </span></font></font></div> <div><font><font face="Arial"><font size="2">For certain tasks it needs the m_map and Canvas to be public, see the examples below. <br> Any intents of changing them to a non-protected status?<span class="139190511-18012004"> </span></font></font></font></div> <div> </div> <div><font><font face="Arial"><font size="2"><span class="139190511-18012004">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. </span></font></font></font></div> <div> </div> <div><font><font face="Arial"><font size="2"><span class="139190511-18012004">HTH,</span></font></font></font></div> <div> </div> <div><font><font face="Arial"><font size="2"><span class="139190511-18012004">Me. </span></font></font></font></div> <div> </div> <blockquote dir="ltr" style="margin-right: 0px;"> <div><font face="Arial"><font size="2"><span class="139190511-18012004"> //</span><span class="139190511-18012004"> Modified in the control: </span><br> public System.Windows.Forms.PictureBox <strong>Canvas</strong>;<br> public Map <strong>m_map</strong>;</font></font></div> <div> </div> <div><br> <font face="Arial" size="2"> // Example to draw upon the canvas<br> // --> Needs <strong>m_map</strong> and <strong>Canvas</strong> set to public:<br> private void <span class="139190511-18012004"> DrawAtCenter </span>(double ptX, double ptY)<br> {<br> // Center & Draw<br> mapControl.m_map.Center(ptX, ptY);<br> mapControl.Draw();<br> // Visualize point<br> Graphics g;<br> g = mapControl.Canvas.CreateGraphics();<br> g.CompositingMode = CompositingMode.SourceOver; <br> g.SmoothingMode = SmoothingMode.HighQuality;<br> g.TranslateTransform(mapControl.Width /2,mapControl.Height/2);<br> Point[] curvePoints =<br> {<br> new Point( 0, 10),<br> new Point( 3, 3),<br> new Point( 10, 0),<br> new Point( 3, -3),<br> new Point( 0, -10),<br> new Point( -3, -3),<br> new Point( -10, 0),<br> new Point( -3, 3),<br> };<br> // Draw polygon <br> g.DrawPolygon(new Pen(Color.Black,1), curvePoints);<br> g.FillPolygon(Brushes.Chartreuse, curvePoints, FillMode.Winding);<br> g.FillEllipse(Brushes.Red, -2, -2, 4, 4);<br> g.Dispose();<br> }</font></div> <div> </div> <div><br> <font face="Arial" size="2"> // Example for hardcoded zooming<br> // --> Needs <strong>m_map</strong> and <strong>Canvas</strong> set to public:<br> myRect = new GIS.RectangleD();<br> myPoint1 = new GIS.PointD();<br> myPoint2 = new GIS.PointD();<br> myPoint1.X = 3.3;<br> myPoint1.Y = 53.7;<br> myPoint2.X = 7.5;<br> myPoint2.Y = 50.6;<br> myRect.UL = myPoint1;<br> myRect.LR = myPoint2;<br> mapControl.m_map.ZoomArea(myRect);<br> mapControl.Draw();</font></div> <div> </div> <div> </div> <div> </div> <div><font face="Arial" size="2"> // <strong>GIS.Map.cs</strong> --> Add a map without dialog box<br> [Description("Read file without dialog"), <br> Browsable( false )]<br> public void AddLayerFromString(string path_and_name_of_shapefile)<br> {<br> this.Cursor = Cursors.AppStarting;<br> m_map.Add( path_and_name_of_shapefile );<br> this.Cursor = Cursors.Default; <br> Draw();<br> }</font></div> </blockquote> <div> </div> <div><font face="Arial"><font size="2">CalculateExtents is not used in the AddLayerFromString example above,... this would be something for the user to decide.<span class="139190511-18012004"> </span></font></font></div> <div> </div> <div> </div> </blockquote> </body> </html> |