This class is used to synchronize a given PageLayoutControl and a MapControl. When initialized, the user must pass the reference of these control to the class, bind the control together by calling 'BindControls' which in turn sets a joined Map referenced by both control; and set all the buddy controls joined between these two controls. When alternating between the MapControl and PageLayoutControl, you should activate the visible control and deactivate the other by calling ActivateXXX. This class is limited to a situation where the controls are not simultaneously visible.
Esempio n. 1
0
        public OpenNewMapDocument(ControlsSynchronizer controlsSynchronizer)
        {
            base.m_category = ".NET Samples";
            base.m_caption  = "Open Map Document";
            base.m_message  = "Open Map Document";
            base.m_toolTip  = "Open Map Document";
            base.m_name     = "DotNetSamplesOpenMapDocument";

            m_controlsSynchronizer = controlsSynchronizer;

            try
            {
                string bitmapResourceName = GetType().Name + ".bmp";
                base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
        }
        /// <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);
        }
    public OpenNewMapDocument(ControlsSynchronizer controlsSynchronizer)
    {
      base.m_category = ".NET Samples";
      base.m_caption = "Open Map Document";
      base.m_message = "Open Map Document";
      base.m_toolTip = "Open Map Document";
      base.m_name = "DotNetSamplesOpenMapDocument";

      m_controlsSynchronizer = controlsSynchronizer;

      try
      {
        string bitmapResourceName = GetType().Name + ".bmp";
        base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
      }
      catch (Exception ex)
      {
        System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
      }
    }
    /// <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);
    }