[Shapedotnet-development] m_map and Canvas to be public
Status: Beta
Brought to you by:
k5jvc
From: E. P. <er...@pe...> - 2004-01-18 11:11:20
|
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. |