public ArcMapManager(System.Windows.Controls.Panel mapContainer, System.Windows.Controls.Panel layoutContainer, System.Windows.Controls.Panel tocContainer) { this._mapContainer = mapContainer; this._layoutContainer = layoutContainer; this._tocContainer = tocContainer; this._mode = MapFunctionMode.None; this._geoProcessor = new Geoprocessor(); this._geoProcessor.OverwriteOutput = true; this._symWindow = null; this._mapFile = ""; this._polygonName = ""; this._tempWorkspace = null; this._axLayoutCtrl = null; this._axTOCCtrl = null; this._axMapCtrl = null; this._mapAndLayoutSync = null; }
public override void Initialize() { System.Windows.Forms.Integration.WindowsFormsHost host; // Initialize the map control. host = new System.Windows.Forms.Integration.WindowsFormsHost(); this._axMapCtrl = new AxMapControl(); this._axMapCtrl.BeginInit(); host.Child = this._axMapCtrl; this._mapContainer.Children.Add(host); this._axMapCtrl.OnMouseDown += new ESRI.ArcGIS.Controls.IMapControlEvents2_Ax_OnMouseDownEventHandler(this.axMapControl_OnMouseDown); this._axMapCtrl.EndInit(); // Initialize the layout control host = new System.Windows.Forms.Integration.WindowsFormsHost(); this._axLayoutCtrl = new AxPageLayoutControl(); this._axLayoutCtrl.BeginInit(); host.Child = this._axLayoutCtrl; this._layoutContainer.Children.Add(host); this._axLayoutCtrl.EndInit(); // Initialize the toc control host = new System.Windows.Forms.Integration.WindowsFormsHost(); // Create an object of the legend control. this._axTOCCtrl = new AxTOCControl(); this._axTOCCtrl.BeginInit(); host.Child = this._axTOCCtrl; this._tocContainer.Children.Add(host); this._axTOCCtrl.OnMouseDown += new ITOCControlEvents_Ax_OnMouseDownEventHandler(this._axTOCCtrl_OnMouseDown); this._axTOCCtrl.EndInit(); //initialize the map and layout synchronization class //get a reference to the MapControl and the PageLayoutControl IMapControl3 mapCtrl = (IMapControl3)this._axMapCtrl.Object; IPageLayoutControl2 layoutCtrl = (IPageLayoutControl2)this._axLayoutCtrl.Object; this._mapAndLayoutSync = new MapAndLayoutSynchronizer(mapCtrl, layoutCtrl); //bind the controls together (both point at the same map) and set the MapControl as the active control this._mapAndLayoutSync.BindControls(true); //add the framework controls (TOC and Toolbars) in order to synchronize then when the //active control changes (call SetBuddyControl) this._mapAndLayoutSync.AddFrameworkControl(this._axTOCCtrl.Object); this._symWindow = new SymbologyWindow(); this._symWindow.Initialize(); ShapefileWorkspaceFactoryClass tempWSFactory = new ShapefileWorkspaceFactoryClass(); this._tempWorkspace = tempWSFactory.OpenFromFile(System.IO.Path.GetTempPath(), 0); /* Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.AccessWorkspaceFactory"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType); string tempWSPath = System.IO.Path.GetTempPath(); string tempWSName = "ArcMapMgr_" + this.GetHashCode().ToString() + "_WS.mdb"; string tempWSFile = System.IO.Path.Combine(tempWSPath, tempWSName); if (System.IO.File.Exists(tempWSFile)) { System.IO.File.Delete(tempWSFile); } IWorkspaceName workspaceName = workspaceFactory.Create(tempWSPath, tempWSName, null, 0); // Cast the workspace name object to the IName interface and open the workspace. IName name = (IName)workspaceName; this._tempWorkspace = (IWorkspace)name.Open(); */ }