/// <summary> /// Open New Document menu event handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void menuOpenDoc_Click(object sender, System.EventArgs e) { // switch to map view tabControl1.SelectedTab = (TabPage)tabControl1.Controls[0]; //launch the OpenMapDoc command OpenNewMapDocument openMapDoc = new OpenNewMapDocument(m_controlsSynchronizer); openMapDoc.OnCreate(m_controlsSynchronizer.MapControl.Object); openMapDoc.OnClick(); m_documentFileName = openMapDoc.DocumentFileName; }
/// <summary> /// Form.Load method /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmMain_Load(object sender, System.EventArgs e) { //get a reference to the MapControl and the PageLayoutControl m_mapControl = (IMapControl3)axMapControl1.Object; m_pageLayoutControl = (IPageLayoutControl2)axPageLayoutControl1.Object; //initialize the controls synchronization class m_controlsSynchronizer = new ControlsSynchronizer(m_mapControl, m_pageLayoutControl); //bind the controls together (both point at the same map) and set the MapControl as the active control m_controlsSynchronizer.BindControls(true); //add the framework controls (TOC and Toolbars) in order to synchronize then when the //active control changes (call SetBuddyControl) m_controlsSynchronizer.AddFrameworkControl(axToolbarControl1.Object); m_controlsSynchronizer.AddFrameworkControl(axToolbarControl2.Object); m_controlsSynchronizer.AddFrameworkControl(axTOCControl1.Object); //add the Open Map Document command onto the toolbar OpenNewMapDocument openMapDoc = new OpenNewMapDocument(m_controlsSynchronizer); axToolbarControl1.AddItem(openMapDoc, -1, 0, false, -1, esriCommandStyles.esriCommandStyleIconOnly); }