예제 #1
0
        private void MatchMain_Load(object sender, EventArgs e)
        {
            sMapUnits           = "未知单位";
            m_mapControl        = (IMapControl3)this.axMapControl1.Object;
            m_pageLayoutControl = (IPageLayoutControl2)this.axPageLayoutControl1.Object;
            m_tocControl        = (ITOCControl2)this.axTOCControl1.Object;
            m_menuMap           = new ToolbarMenuClass();
            m_menuLayer         = new ToolbarMenuClass();
            //添加自定义菜单项到TOCCOntrol的Map菜单中
            //打开文档菜单
            //   m_menuMap.AddItem(new OpenNewMapDocument(m_controlsSynchronizer), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText);
            //添加数据菜单
            //-----    m_menuMap.AddItem(new ControlsAddDataCommandClass(), -1, 1, false, esriCommandStyles.esriCommandStyleIconAndText);
            //打开全部图层菜单
            //m_menuMap.AddItem(new LayerVisibility(), 1, 2, false, esriCommandStyles.esriCommandStyleTextOnly);
            //关闭全部图层菜单
            //m_menuMap.AddItem(new LayerVisibility(), 2, 3, false, esriCommandStyles.esriCommandStyleTextOnly);
            //以二级菜单的形式添加内置的“选择”菜单
            //m_menuMap.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 4, true);
            //以二级菜单的形式添加内置的“地图浏览”菜单
            //m_menuMap.AddSubMenu("esriControls.ControlsMapViewMenu", 5, true);

            //添加自定义菜单项到TOCCOntrol的图层菜单中

            // 添加“移除图层”菜单项
            m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            // 添加“放大到整个图层”菜单项
            m_menuLayer.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);


            //设置菜单的Hook
            m_menuLayer.SetHook(m_mapControl);
            m_menuMap.SetHook(m_mapControl);
        }
예제 #2
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="mapControl"></param>
 /// <param name="pageLayoutControl"></param>
 public ControlsSynchronizer(IMapControl4 mapControl, IPageLayoutControl2 pageLayoutControl)
     : this()
 {
     //为类成员赋值
     m_mapControl        = mapControl;
     m_pageLayoutControl = pageLayoutControl;
 }
예제 #3
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="mapControl"></param>
 /// <param name="pageLayoutControl"></param>
 public ControlsSynchronizer(IMapControl3 mapControl, IPageLayoutControl2 pageLayoutControl)
     : this()
 {
     //为类成员赋值
     m_mapControl = mapControl;
     m_pageLayoutControl = pageLayoutControl;
 }
 /// 在构造函数中传入地图控件和布局控件
 /// </summary>
 /// <param name="_MapControl"></param>
 /// <param name="_PageLayoutControl"></param>
 public ControlsSynchronizer(IMapControl3 _MapControl, IPageLayoutControl2 _PageLayoutControl) :
     this()
 {
     //assign the class members
     pMapControl        = _MapControl;
     pPageLayoutControl = _PageLayoutControl;
 }
예제 #5
0
        public MapAndPageLayoutControls(AxMapControl axMapControl_1, AxPageLayoutControl axPageLayoutControl_1)
        {
            this.axMapControl_0        = axMapControl_1;
            this.axPageLayoutControl_0 = axPageLayoutControl_1;
            IGraphicSnapEnvironment2 pageLayout = axPageLayoutControl_1.PageLayout as IGraphicSnapEnvironment2;

            this.imapControl3_0        = axMapControl_1.Object as IMapControl3;
            this.ipageLayoutControl2_0 = axPageLayoutControl_1.Object as IPageLayoutControl2;
            (this.ipageLayoutControl2_0 as IPageLayoutControlEvents_Event).OnMouseMove +=
                new IPageLayoutControlEvents_OnMouseMoveEventHandler(this.method_5);
            (this.imapControl3_0 as IMapControlEvents2_Event).OnMouseMove +=
                new IMapControlEvents2_OnMouseMoveEventHandler(this.method_4);
            (this.ipageLayoutControl2_0 as IPageLayoutControlEvents_Event).OnFocusMapChanged +=
                new IPageLayoutControlEvents_OnFocusMapChangedEventHandler(this.method_6);
            (this.ipageLayoutControl2_0 as IPageLayoutControlEvents_Event).OnPageLayoutReplaced +=
                new IPageLayoutControlEvents_OnPageLayoutReplacedEventHandler(this.method_1);
            this.iactiveViewEvents_Event_0 = this.ipageLayoutControl2_0.ActiveView.FocusMap as IActiveViewEvents_Event;
            try
            {
                if (this.iactiveViewEvents_Event_0 != null)
                {
                    this.iactiveViewEvents_Event_0.ItemAdded +=
                        new IActiveViewEvents_ItemAddedEventHandler(this.method_8);
                    this.iactiveViewEvents_Event_0.ItemReordered +=
                        new IActiveViewEvents_ItemReorderedEventHandler(this.method_0);
                    this.iactiveViewEvents_Event_0.ItemDeleted +=
                        new IActiveViewEvents_ItemDeletedEventHandler(this.method_7);
                }
            }
            catch
            {
            }
        }
예제 #6
0
        private void LoadMxdFile(string filename)
        {
            if (axPageLayoutControl1.CheckMxFile(filename))
            {
                //ESRI.ArcGIS.Framework.IDocument doc = new ESRI.ArcGIS.ArcMapUI.MxDocumentClass();
                //m_application = doc.Parent;
                //m_application.Visible = false;
                //mxdocument = m_application.Document as IMxDocument;
                mapdocument = new MapDocument();
                mapdocument.Open(filename);
                map = mapdocument.Map[0];
                mapdocument.SetActiveView((IActiveView)map);
                m_pageLayoutControl            = (IPageLayoutControl2)axPageLayoutControl1.Object;
                m_pageLayoutControl.PageLayout = mapdocument.PageLayout;
                //axPageLayoutControl1.LoadMxFile(filename);
                this.Text = mapdocument.DocumentFilename;

                saveAsToolStripMenuItem.Enabled = true;
                saveToolStripMenuItem.Enabled   = true;
                printToolStripMenuItem.Enabled  = true;
            }
            else
            {
                MessageBox.Show("The Selected file is not suppoted !!!");
            }
        }
 /// <summary>
 /// class constructor
 /// </summary>
 /// <param name="mapControl"></param>
 /// <param name="pageLayoutControl"></param>
 public ControlsSynchronizer(IMapControl3 mapControl, IPageLayoutControl2 pageLayoutControl)
   : this()
 {
   //assign the class members
   m_mapControl = mapControl;
   m_pageLayoutControl = pageLayoutControl;
 }
예제 #8
0
 internal void StartCreateBar(string XMLConfig, TOCTreeViewEx pTOCTreeView, IApplication pApp,
                              IMapControl2 pInMapCtrl, IPageLayoutControl2 pPageLayoutCtrl, BarManager barManager1, List <BarItem> baritems,
                              List <bool> isgroups)
 {
     try
     {
         this.m_pTOCTreeView    = pTOCTreeView;
         this.m_pApp            = pApp;
         this.m_pInMapCtrl      = pInMapCtrl;
         this.m_pPageLayoutCtrl = pPageLayoutCtrl;
         this.m_barManager1     = barManager1;
         this.baritems          = baritems;
         this.isgroups          = isgroups;
         XmlDocument document = new XmlDocument();
         try
         {
             document.Load(XMLConfig);
             XmlElement documentElement = document.DocumentElement;
             for (int i = 0; i < documentElement.ChildNodes.Count; i++)
             {
                 XmlNode pNode = documentElement.ChildNodes[i];
                 this.ReadBarItems(null, pNode);
             }
         }
         catch
         {
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.ToString());
     }
 }
예제 #9
0
 /// <summary>
 /// class constructor
 /// </summary>
 /// <param name="mapControl"></param>
 /// <param name="pageLayoutControl"></param>
 public ControlsSynchronizer(IMapControl3 mapControl, IPageLayoutControl2 pageLayoutControl)
     : this()
 {
     //assign the class members
     m_mapControl        = mapControl;
     m_pageLayoutControl = pageLayoutControl;
 }
예제 #10
0
 private void method_1()
 {
     if (this.object_0 is IMapControl2)
     {
         IMapControl2 control = this.object_0 as IMapControl2;
         control.ClearLayers();
         IMap map = control.Map;
         (map as IStandaloneTableCollection).RemoveAllStandaloneTables();
         (map as IGraphicsContainer).DeleteAllElements();
         control.Extent = control.FullExtent;
         control.ActiveView.Refresh();
     }
     else if (this.object_0 is IPageLayoutControl2)
     {
         IPageLayoutControl2 control2 = this.object_0 as IPageLayoutControl2;
         (control2.PageLayout as IGraphicsContainer).DeleteAllElements();
     }
     else if (this.object_0 is MapAndPageLayoutControls)
     {
         ((this.object_0 as MapAndPageLayoutControls).PageLayoutControl.PageLayout as IGraphicsContainer)
         .DeleteAllElements();
     }
     //if (ApplicationRef.Application != null)
     //{
     //    ApplicationRef.Application.MapDocumentChanged();
     //}
 }
        /// <summary>
        /// �ڹ��캯���д����ͼ�ؼ��Ͳ��ֿؼ�
        /// </summary>
        /// <param name="_MapControl"></param>
        /// <param name="_PageLayoutControl"></param>
        public ControlsSynchronizer(IMapControl3 _MapControl, IPageLayoutControl2 _PageLayoutControl)
            : this()
        {
            //assign the class members
              pMapControl = _MapControl;

              pPageLayoutControl = _PageLayoutControl;
        }
예제 #12
0
        public FrmExportActiveViewFig(IPageLayoutControl2 pagelayoutcontrol)
        {
            InitializeComponent();
            this.EnableGlass    = false;
            m_PagelayoutControl = pagelayoutcontrol;

            FrmIndex = 1;
        }
예제 #13
0
 public FrmExportActiveViewFig(IPageLayoutControl2 pagelayoutcontrol, string xmlFileFullPath, ControlsSynchronizer synchronizer)
 {
     InitializeComponent();
     this.EnableGlass    = false;
     m_PagelayoutControl = pagelayoutcontrol;
     m_pSynchronizer     = synchronizer;
     FrmIndex            = 1;
     AcceptFile(xmlFileFullPath);
 }
예제 #14
0
 /// <summary>
 /// bind the MapControl and PageLayoutControl together by assigning a new joint focus map
 /// 指定共同的Map来把MapControl和PageLayoutControl绑在一起
 /// </summary>
 /// <param name="mapControl"></param>
 /// <param name="pageLayoutControl"></param>
 /// <param name="activateMapFirst">true if the MapControl supposed to be activated first,如果MapControl被首先激活,则为true</param>
 public void BindControls(IMapControl4 mapControl, IPageLayoutControl2 pageLayoutControl, bool activateMapFirst)
 {
     if (mapControl == null || pageLayoutControl == null)
     {
         throw new Exception("ControlsSynchronizer::BindControls:\r\nEither MapControl or PageLayoutControl are not initialized!");
     }
     m_mapControl        = MapControl;
     m_pageLayoutControl = pageLayoutControl;
     this.BindControls(activateMapFirst);
 }
예제 #15
0
 public MapAndPageLayoutControlsold(IMapControl3 imapControl3_1, IPageLayoutControl2 ipageLayoutControl2_1)
     : this()
 {
     this.imapControl3_0        = imapControl3_1;
     this.ipageLayoutControl2_0 = ipageLayoutControl2_1;
     (this.ipageLayoutControl2_0 as IPageLayoutControlEvents_Event).OnMouseMove +=
         (new IPageLayoutControlEvents_OnMouseMoveEventHandler(this.method_3));
     (this.imapControl3_0 as IMapControlEvents2_Event).OnMouseMove +=
         (new IMapControlEvents2_OnMouseMoveEventHandler(this.method_2));
 }
예제 #16
0
 public MapAndPageLayoutControlsold()
 {
     this.imapControl3_0        = null;
     this.ipageLayoutControl2_0 = null;
     this.itool_0     = null;
     this.itool_1     = null;
     this.bool_0      = true;
     this.arrayList_0 = null;
     this.bool_1      = true;
     this.arrayList_0 = new ArrayList();
 }
예제 #17
0
 public NewMainView(IAppContext context)
 {
     _context = context;
     InitializeComponent();
     _mapControl           = this.axMapControl1.Object as IMapControl3;
     _layoutControl        = this.axPageLayoutControl1.Object as IPageLayoutControl2;
     _controlsSynchronizer = new ControlsSynchronizer(_mapControl, _layoutControl);
     this.FormClosing     += MainView_FormClosing;
     this.Shown           += MainView_Shown;
     Logger.Current.Trace("End MainView");
 }
        /// <summary>
        /// 绑定地图控件和布局控件
        /// </summary>
        /// <param name="_MapControl"></param>
        /// <param name="_PageLayoutControl"></param>
        /// <param name="_ActivateMapFirst"></param>
        public void BindControls(IMapControl3 _MapControl, IPageLayoutControl2 _PageLayoutControl, bool _ActivateMapFirst)
        {
            if (_MapControl == null || _PageLayoutControl == null)
            {
                throw new Exception("ControlsSynchronizer::BindControls:\r\nEither MapControl or PageLayoutControl are not initialized!");
            }

            pMapControl = MapControl;

            pPageLayoutControl = _PageLayoutControl;

            this.BindControls(_ActivateMapFirst);
        }
예제 #19
0
 public void SetBuddyControl()
 {
     if (_context.MainView.ControlType == GISControlType.MapControl)
     {
         _mapControl3   = _context.MapControl as IMapControl3;
         _layoutControl = null;
     }
     else
     {
         _layoutControl = _context.MainView.PageLayoutControl;
         _mapControl3   = null;
     }
 }
예제 #20
0
 public void BindControls(IMapControl3 imapControl3_1, IPageLayoutControl2 ipageLayoutControl2_1, bool bool_2)
 {
     if ((imapControl3_1 == null) || (ipageLayoutControl2_1 == null))
     {
         throw new Exception(
                   "ControlsSynchronizer::BindControls:\r\nEither MapControl or PageLayoutControl are not initialized!");
     }
     this.imapControl3_0        = this.MapControl;
     this.ipageLayoutControl2_0 = ipageLayoutControl2_1;
     (this.ipageLayoutControl2_0 as IPageLayoutControlEvents_Event).OnFocusMapChanged +=
         (new IPageLayoutControlEvents_OnFocusMapChangedEventHandler(this.method_4));
     this.BindControls(bool_2);
 }
예제 #21
0
파일: MainForm.cs 프로젝트: arcpad/epsgis
        private void MainForm_Load(object sender, EventArgs e)
        {
            //get a reference to the MapControl and the PageLayoutControl
            m_tocControl        = (ITOCControl2)axTOCControl1.Object;
            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(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);

            //Add custom commands to the map menu
            m_menuMap = new ToolbarMenuClass();
            m_menuMap.AddItem(new LayerVisibility(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuMap.AddItem(new LayerVisibility(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuMap.AddItem(new BufferAnalysis(), 3, 2, false, esriCommandStyles.esriCommandStyleTextOnly);

            //Add pre-defined menu to the map menu as a sub menu
            m_menuMap.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 2, true);
            //Add custom commands to the map menu
            m_menuLayer = new ToolbarMenuClass();
            m_menuLayer.AddItem(new ZoomToLayer(), -1, 0, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new RemoveLayer(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new ScaleThresholds(), 1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new ScaleThresholds(), 2, 3, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new ScaleThresholds(), 3, 4, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new LayerSelectable(), 1, 5, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new LayerSelectable(), 2, 6, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new LayerRendering(), -1, 7, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new LayerProperties(), -1, 8, false, esriCommandStyles.esriCommandStyleTextOnly);

            axToolbarControl1.AddItem(new IdentifyTool(), -1, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);  


            //Set the hook of each menu
            m_menuLayer.SetHook(m_mapControl);

            m_menuMap.SetHook(m_mapControl);
        }
예제 #22
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string filename = mapdocument.DocumentFilename;

            mapdocument.Close();
            IMapDocument newmapdocument = new MapDocument();

            m_pageLayoutControl = (IPageLayoutControl2)axPageLayoutControl1.Object;
            //m_pageLayoutControl.PageLayout = mapdocument.PageLayout;
            newmapdocument.Open(filename);
            newmapdocument.ReplaceContents((IMxdContents)m_pageLayoutControl.PageLayout);
            newmapdocument.Save(newmapdocument.UsesRelativePaths, false);
            newmapdocument.Close();
            LoadMxdFile(filename);
        }
예제 #23
0
 public void Initialize(IAppContext context, PrintingPlugin plugin)
 {
     try
     {
         _context       = context;
         _plugin        = plugin;
         _layoutControl = _context.MainView.PageLayoutControl;
         LoadMapTemplate();
         FillScaleList();
         LoadIndexMaps();
         InitCommands();
     }
     catch (Exception ex)
     {
         MessageService.Current.Warn(ex.Message);
     }
 }
예제 #24
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add CmdActivMap.OnClick implementation
            IPageLayoutControl2 pLayeoutctr = (m_hookHelper.Hook) as IPageLayoutControl2;
            //if (pLayeoutctr != null && pLayeoutctr.CustomProperty != null)
            //{
            //    ArrayList al = pLayeoutctr.CustomProperty as ArrayList;
            //    IMap pMap = al[1] as IMap;
            //    IMapControl2 pmapctr = al[0] as IMapControl2;
            //    while (!pLayeoutctr.ActiveView.FocusMap.Equals(pMap))
            //    {
            //        pLayeoutctr.PageLayout.FocusNextMapFrame();
            //    }
            //    pmapctr.Map = pMap;

            //}
        }
예제 #25
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string filter = "Map document (*.mxd)|*.mxd";

            saveFileDialog1.Filter = filter;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string       filename       = saveFileDialog1.FileName;
                IMapDocument newmapdocument = new MapDocument();
                newmapdocument.New(filename);
                m_pageLayoutControl = (IPageLayoutControl2)axPageLayoutControl1.Object;
                newmapdocument.ReplaceContents((IMxdContents)m_pageLayoutControl.PageLayout);
                newmapdocument.Save(newmapdocument.UsesRelativePaths, false);
                newmapdocument.Close();
                LoadMxdFile(filename);
            }
        }
    /// <summary>
    /// bind the MapControl and PageLayoutControl together by assigning a new joint focus map
    /// </summary>
    /// <param name="mapControl"></param>
    /// <param name="pageLayoutControl"></param>
    /// <param name="activateMapFirst">true if the MapControl supposed to be activated first</param>
    public void BindControls(IMapControl3 mapControl, IPageLayoutControl2 pageLayoutControl, bool activateMapFirst)
    {
      if (mapControl == null || pageLayoutControl == null)
        throw new Exception("ControlsSynchronizer::BindControls:\r\nEither MapControl or PageLayoutControl are not initialized!");

      m_mapControl = MapControl;
      m_pageLayoutControl = pageLayoutControl;

      this.BindControls(activateMapFirst);
    }
예제 #27
0
        private void LoadPrintPage(IPrintPageInfo pageInfo)
        {
            if (_template == null)
            {
                return;
            }
            //因为前面的操作可能对Template有赋值,因此,在将参数付过去之前需要进行初始化
            _template.Load();

            //! 首先将PageInfo里面的属性值赋给 template

            foreach (MapTemplateParam param in _template.MapTemplateParam)
            {
                string            paramName = param.Name;
                IPrintPageElement element   =
                    pageInfo.AutoElements.FirstOrDefault(c => c.Name == param.Name || c.AliasName == param.Name);
                if (element == null)
                {
                    continue;
                }
                switch (param.ParamDataType)
                {
                case DataType.Boolean:
                    param.Value = Convert.ToBoolean(element.Value);
                    break;

                case DataType.DateTime:
                    param.Value = Convert.ToDateTime(element.Value);
                    break;

                case DataType.Interger:
                    param.Value = Convert.ToInt32(element.Value);
                    break;

                case DataType.Float:
                    param.Value = Convert.ToDouble(element.Value);
                    break;

                case DataType.String:
                    param.Value = element.Value;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }


            _layoutControl = _context.MainView.PageLayoutControl;
            this.DeleteAllElements(this._layoutControl.ActiveView);
            ((_layoutControl.ActiveView as IActiveView).FocusMap as IMapClipOptions).ClipType =
                esriMapClipType.esriMapClipNone;
            if ((_layoutControl.ActiveView as IActiveView).FocusMap is IMapAutoExtentOptions)
            {
                ((_layoutControl.ActiveView as IActiveView).FocusMap as IMapAutoExtentOptions).AutoExtentType =
                    esriExtentTypeEnum.esriExtentDefault;
            }
            IEnvelope extent = pageInfo.Boundary.Envelope;

            MessageService.Current.Info(string.Format("{0},{1},{2},{3}", extent.XMin, extent.YMin, extent.XMax, extent.YMax));

            if (_template.MapFramingType == MapFramingType.StandardFraming)
            {
                _template.CreateTKN(_layoutControl.ActiveView as IActiveView, extent.LowerLeft);
            }
            else
            {
                _template.CreateTKByRect2(_layoutControl.ActiveView as IActiveView, extent);
            }

            (_layoutControl.ActiveView as IGraphicsContainerSelect).UnselectAllElements();
        }
        /// <summary>
        /// �󶨵�ͼ�ؼ��Ͳ��ֿؼ�
        /// </summary>
        /// <param name="_MapControl"></param>
        /// <param name="_PageLayoutControl"></param>
        /// <param name="_ActivateMapFirst"></param>
        public void BindControls(IMapControl3 _MapControl, IPageLayoutControl2 _PageLayoutControl, bool _ActivateMapFirst)
        {
            if (_MapControl == null || _PageLayoutControl == null)
            throw new Exception("ControlsSynchronizer::BindControls:\r\nEither MapControl or PageLayoutControl are not initialized!");

              pMapControl = MapControl;

              pPageLayoutControl = _PageLayoutControl;

              this.BindControls(_ActivateMapFirst);
        }
예제 #29
0
        private void axTOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            //if (e.button == 1)
            //{
            //    esriTOCControlItem pItem = new esriTOCControlItem();
            //    IBasicMap pMap = new MapClass();
            //    ILayer pLayer = new FeatureLayerClass();
            //    object other = new object();
            //    object index = new object();
            //    ILegendGroup pLegendGroup;
            //    _SelSymLayer = null;

            //    axTOCControl.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref other, ref index);
            //    if (pLayer == null)
            //        return;

            //    if (pItem == esriTOCControlItem.esriTOCControlItemLayer)
            //    {
            //        if (pLayer.GetType() is IAnnotationSublayer) return;
            //        else
            //        {
            //            _SelSymLayer = pLayer;
            //        }
            //    }
            //}
            IBasicMap pMap   = null;
            ILayer    pLayer = null;

            System.Object        other      = null;
            System.Object        LayerIndex = null;
            System.Drawing.Point pPoint     = new System.Drawing.Point(e.x, e.y);

            esriTOCControlItem TOCItem    = esriTOCControlItem.esriTOCControlItemNone;
            ITOCControl2       tocControl = (ITOCControl2)axTOCControl.Object;

            tocControl.HitTest(e.x, e.y, ref TOCItem, ref pMap, ref pLayer, ref other, ref LayerIndex);
            if (e.button == 2 && GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu != null)
            {
                DevComponents.DotNetBar.ButtonItem     item         = null;
                DevComponents.DotNetBar.ContextMenuBar menuBar      = GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCContextMenu2"];
                DevComponents.DotNetBar.ContextMenuBar menuBarLayer = GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCLayerContextMenu2"];
                this.Controls.Add(menuBar);
                this.Controls.Add(menuBarLayer);
                switch (TOCItem)
                {
                case esriTOCControlItem.esriTOCControlItemMap:
                    if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu.ContainsKey("TOCContextMenu2"))
                    {
                        if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCContextMenu2"] != null)
                        {
                            if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCContextMenu2"].Items.Count > 0)
                            {
                                item = GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCContextMenu2"].Items[0] as DevComponents.DotNetBar.ButtonItem;
                                if (item != null)
                                {
                                    item.Popup(axTOCControl.PointToScreen(pPoint));
                                }
                            }
                        }
                    }
                    break;

                case esriTOCControlItem.esriTOCControlItemLayer:

                    if (!(pLayer is IGroupLayer || pLayer is IFeatureLayer || pLayer is IDataLayer))
                    {
                        return;
                    }
                    if (pLayer is IFeatureLayer || pLayer is IDataLayer)
                    {
                        IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                        if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu.ContainsKey("TOCLayerContextMenu2"))
                        {
                            if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCLayerContextMenu2"] != null)
                            {
                                if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCLayerContextMenu2"].Items.Count > 0)
                                {
                                    item = GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCLayerContextMenu2"].Items[0] as DevComponents.DotNetBar.ButtonItem;
                                    if (item != null)
                                    {
                                        item.Popup(axTOCControl.PointToScreen(pPoint));
                                    }
                                }
                            }
                        }
                        if (axTOCControl.Buddy is IPageLayoutControl2)
                        {
                            IPageLayoutControl2 pPageLayoutControl = axTOCControl.Buddy as IPageLayoutControl2;
                            pPageLayoutControl.CustomProperty = pLayer;
                        }
                        else if (axTOCControl.Buddy is IMapControl3)
                        {
                            IMapControl3 pMapcontrol = axTOCControl.Buddy as IMapControl3;
                            pMapcontrol.CustomProperty = pLayer;
                        }
                    }
                    break;
                }
            }
        }