Migrating your applications to ArcGIS for Windows Mobile 3
With the new release a lot of namespaces changes have been made to better organize the classes, and outdated classes have been removed, which means backwards compatibility has been broken. Applications will need to be updated and rebuilt to take advantage of these changes. By removing many of the components the developer is now responsible for creating tools such as the zoominmapaction, but this also provides greater control.
These steps below cover the basics needed to migrate your applications; there may be addition code changes required beyond the scope of this document. For example, the move to the .NET framework 3.5 may affect your application outside of the ArcGIS parts. This is one of many reasons to save a backup copy of your solution code, before starting the migration.
If you try to open the main form that contains your map control, in design mode, you will likely see an message to resolve errors before loading to avoid losing data. Open the form in code mode, to fix these errors, before opening in design mode.
-
Update the references. When you open the main form as code, or the entry class in your solution, you will observe a underlining of the replaced namespaces, and a tooltip that the namespace does not exist. Update the using statements to the new namespaces as needed for your solution.
For example this code from 10.0
using ESRI.ArcGIS.Mobile; using ESRI.ArcGIS.Mobile.Geometries; using ESRI.ArcGIS.Mobile.MapActions; using ESRI.ArcGIS.Mobile.MobileServices; using ESRI.ArcGIS.Mobile.SdcData; using ESRI.ArcGIS.Mobile.Sketch; using ESRI.ArcGIS.Mobile.DataProducts.RasterData;
Would change to this at 3
using ESRI.ArcGIS.Mobile; using ESRI.ArcGIS.Mobile.Geometries; using ESRI.ArcGIS.Mobile.FeatureCaching; using ESRI.ArcGIS.Mobile.FeatureCaching.Synchronization; using ESRI.ArcGIS.Mobile.DataProducts.StreetMapData; using ESRI.ArcGIS.Mobile.WinForms; using ESRI.ArcGIS.Mobile.DataProducts.RasterData;
- Remove the code used to instantiate components no longer available. Open the form designer class and remove the ESRI.ArcGIS.Mobile classes.
Remove these lines
private ESRI.ArcGIS.Mobile.MapActions.PanMapAction panMapAction1; private ESRI.ArcGIS.Mobile.MapActions.ZoomOutMapAction zoomOutMapAction1; private ESRI.ArcGIS.Mobile.MapActions.ZoomInMapAction zoomInMapAction1; private ESRI.ArcGIS.Mobile.MapActions.SelectionMapAction selectionMapAction1; private ESRI.ArcGIS.Mobile.Sketch.SketchGraphicLayer sketchGraphicLayer1; private ESRI.ArcGIS.Mobile.Sketch.AddVertexSketchTool addVertexSketchTool1; private ESRI.ArcGIS.Mobile.Sketch.DeleteVertexSketchTool deleteVertexSketchTool1; private ESRI.ArcGIS.Mobile.MapActions.DragRectangleMapAction dragRectangleMapAction1; private ESRI.ArcGIS.Mobile.Sketch.InsertVertexSketchTool insertVertexSketchTool1; private ESRI.ArcGIS.Mobile.Sketch.MoveVertexSketchTool moveVertexSketchTool1; private void InitializeComponent() { this.panMapAction1 = new ESRI.ArcGIS.Mobile.MapActions.PanMapAction(this.components); this.zoomInMapAction1 = new ESRI.ArcGIS.Mobile.MapActions.ZoomInMapAction(this.components); this.zoomOutMapAction1 = new ESRI.ArcGIS.Mobile.MapActions.ZoomOutMapAction(this.components); this.selectionMapAction1 = new ESRI.ArcGIS.Mobile.MapActions.SelectionMapAction(this.components); this.addVertexSketchTool1 = new ESRI.ArcGIS.Mobile.Sketch.AddVertexSketchTool(); this.deleteVertexSketchTool1 = new ESRI.ArcGIS.Mobile.Sketch.DeleteVertexSketchTool(); this.dragRectangleMapAction1 = new ESRI.ArcGIS.Mobile.MapActions.DragRectangleMapAction(this.components); this.insertVertexSketchTool1 = new ESRI.ArcGIS.Mobile.Sketch.InsertVertexSketchTool(); this.moveVertexSketchTool1 = new ESRI.ArcGIS.Mobile.Sketch.MoveVertexSketchTool(); this.sketchGraphicLayer1 = new ESRI.ArcGIS.Mobile.Sketch.SketchGraphicLayer(); this.scaleBar1 = new ESRI.ArcGIS.Mobile.ScaleBar(this.components); this.map1.MapActions.Add(this.addVertexSketchTool1); this.map1.MapActions.Add(this.deleteVertexSketchTool1); this.map1.MapActions.Add(this.dragRectangleMapAction1); this.map1.MapActions.Add(this.insertVertexSketchTool1); this.map1.MapActions.Add(this.moveVertexSketchTool1); // // selectionMapAction1 // this.selectionMapAction1.StatusChanged += new System.EventHandler<ESRI.ArcGIS.Mobile.MapActions.MapActionStatusChangedEventArgs>(this.selectionMapAction1_StatusChanged); // // scaleBar1 // this.scaleBar1.BarColor = System.Drawing.SystemColors.ActiveCaption; this.scaleBar1.Font = new System.Drawing.Font("Tahoma", 8F); this.scaleBar1.HaloColor = System.Drawing.SystemColors.HighlightText; this.scaleBar1.Map = null; this.scaleBar1.TextColor = System.Drawing.SystemColors.ActiveCaption; this.scaleBar1.UnitLabels = usCustomaryUnitLabels2; // // map1 // this.map1.DataSources.Add(this.mobileCache1); this.map1.MapActions.Add(this.addVertexSketchTool1); this.map1.MapActions.Add(this.deleteVertexSketchTool1); this.map1.MapActions.Add(this.dragRectangleMapAction1); this.map1.MapActions.Add(this.insertVertexSketchTool1); this.map1.MapActions.Add(this.moveVertexSketchTool1); }
Update the folowing lines of code in the designer.cs
private void InitializeComponent() this.mobileServiceConnection1 = new ESRI.ArcGIS.Mobile.MobileServices.MobileServiceConnection(this.components); this.mobileCache1 = new ESRI.ArcGIS.Mobile.MobileServices.MobileCache(this.components); to this.mobileServiceConnection1 = new ESRI.ArcGIS.Mobile.FeatureCaching.Synchronization.MobileServiceConnection(this.components); this.mobileCache1 = new ESRI.ArcGIS.Mobile.FeatureCaching.MobileCache(this.components); this.map1 = new ESRI.ArcGIS.Mobile.WinForms.Map(); and private ESRI.ArcGIS.Mobile.ScaleBar scaleBar1; private ESRI.ArcGIS.Mobile.MobileServices.MobileServiceConnection mobileServiceConnection1; private ESRI.ArcGIS.Mobile.MobileServices.MobileCache mobileCache1; private ESRI.ArcGIS.Mobile.Map map1; to private ESRI.ArcGIS.Mobile.WinForms.ScaleBar scaleBar1; private ESRI.ArcGIS.Mobile.FeatureCaching.Synchronization.MobileServiceConnection mobileServiceConnection1; private ESRI.ArcGIS.Mobile.FeatureCaching.MobileCache mobileCache1; private ESRI.ArcGIS.Mobile.WinForms.Map map1;
- Instantiate the MapActions in the code of the form now that they are no longer toolbox components.
Add to the form code
private SelectionMapAction selectionMapAction1 = new SelectionMapAction(); AddVertexSketchTool addVertexSketchTool1 = new AddVertexSketchTool(); DeleteVertexSketchTool deleteVertexSketchTool1 = new DeleteVertexSketchTool(); DragRectangleMapAction dragRectangleMapAction1 = new DragRectangleMapAction(); InsertVertexSketchTool insertVertexSketchTool1 = new InsertVertexSketchTool(); MoveVertexSketchTool moveVertexSketchTool1 = new MoveVertexSketchTool(); SketchGraphicLayer sketchGraphicLayer1 = new SketchGraphicLayer(); PanMapAction panMapAction1 = new PanMapAction(); ZoomInMapAction zoomInMapAction1 = new ZoomInMapAction(); ZoomOutMapAction zoomOutMapAction1 = new ZoomOutMapAction();
- Change the code to use new classes
Change the FeatureLayer class declarations and usage to FeatureSource
FeatureLayer editlayer to FeatureSource editsource foreach (FeatureLayer alayer in mobileCache1.Layers) to foreach (FeatureSource alayer in mobileCache1.FeatureSources) FeatureLayer flayer = mobileCache1.Layers[mitem.ToString()] as FeatureLayer; to FeatureSource fsource = mobileCache1.FeatureSources[mitem.ToString()] as FeatureSource; m_featureLayerDataTable.SaveInFeatureLayer(); to m_featureLayerDataTable.SaveInFeatureSource(); selectionMapAction1.SelectionLayers.Clear(); to selectionMapAction1.SelectionFeatureSources.Clear(); selectionMapAction1.SelectionLayers.Add(alayer); to selectionMapAction1.SelectionFeatureSources.Add(alayer); tabControlGrid.TabPages.Add(fdtable.FeatureLayer.Name); to tabControlGrid.TabPages.Add(fdtable.FeatureSource.Name);
- Replace the deprecated AddRange method with the Add method.
map1.MapLayers.AddRange(mobileCache1); to map1.MapLayers.Add(mobileCache1);
- Replace the DataSources property with MapLayers property.
change datasources property map1.DataSources.Clear(); to map1.MapLayers.Clear();
- Replace the GetExtent and SetExtent method with Extent property.
Change the SetExtent amd GetExtent method to use the Extent property map1.SetExtent(map1.GetExtent().Resize(0.5)); to map1.Extent = map1.Extent.Resize(0.5);
- Replace the CurrentMapAction property with MapAction property.
map1.CurrentMapAction = panMapAction1; to map1.MapAction = panMapAction1;
- Replace the SelectionGraphicLayer with a MapGraphicLayer.
SelectionGraphicLayer selectlayer = new SelectionGraphicLayer(); to MapGraphicLayer selectlayer = new MapGraphicLayer("selectlayer");