Esempio n. 1
0
 /// <summary>
 /// Constructs a new instance of a MapWin interface where the Map, Legend, Form and MenuStrip
 /// are all specified.
 /// </summary>
 /// <param name="inMap">Any valid implementation of IBasicMap</param>
 /// <param name="inLegend">Any valid implementation of ILegend</param>
 /// <param name="inMainForm">Any valid windows Form</param>
 /// <param name="inMenuStrip">Any valid windows MenuStrip</param>
 public MapWin(IBasicMap inMap, ILegend inLegend, Form inMainForm, MenuStrip inMenuStrip)
 {
     _map = inMap;
     _legend = inLegend;
     _mainForm = inMainForm;
     _menuStrip = inMenuStrip;
     _userInteraction = new UserInteraction();
 }
Esempio n. 2
0
        private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e)
        {
            IBasicMap pMap = null;
            ILayer    pLayer = null;
            object    unk = null, data = null;

            ESRI.ArcGIS.Controls.esriTOCControlItem pItem = ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemNone;
            try
            {
                axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref unk, ref data);
            }
            catch (Exception)
            {
                throw;
            }
            switch (e.button)
            {
            case 2:
                //右键
                if (pItem == ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemMap)
                {
                    axTOCControl1.SelectItem(pMap, null);
                }
                else if (pItem == ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemLayer)
                {
                    axTOCControl1.SelectItem(pLayer, null);
                }

                axMapControl1.CustomProperty = pLayer;
                if (pItem == ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemMap)
                {
                    //
                }
                if (pItem == ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemLayer)
                {
                    var m_pMenuLayer = new ToolbarMenu();
                    m_pMenuLayer.AddItem(new BuildLineBuffer(), -1, 0, false, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuLayer.AddItem(new ShowAttribute(), 1, 1, false, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuLayer.SetHook(axMapControl1);
                    m_pMenuLayer.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
                }
                break;

            default:
                break;
            }
        }
Esempio n. 3
0
        public static IFeatureLayer FindFeatureLayerByFCName(IBasicMap pMap, string fcName, bool bool_0)
        {
            IFeatureLayer featureLayer;
            string        lower    = fcName.ToLower();
            UID           uIDClass = new UID()
            {
                Value = "{6CA416B1-E160-11D2-9F4E-00C04F6BC78E}"
            };
            IEnumLayer layers = pMap.Layers[uIDClass, true];

            layers.Reset();
            ILayer layer = layers.Next();

            while (true)
            {
                if (layer != null)
                {
                    if (layer is IFeatureLayer)
                    {
                        string   name      = ((layer as IFeatureLayer).FeatureClass as IDataset).Name;
                        string[] strArrays = name.Split(new char[] { '.' });
                        if (strArrays[(int)strArrays.Length - 1].ToLower() == lower)
                        {
                            if (!bool_0)
                            {
                                featureLayer = layer as IFeatureLayer;
                                break;
                            }
                            else if (
                                (((layer as IFeatureLayer).FeatureClass as IDataset).Workspace as IWorkspaceEdit)
                                .IsBeingEdited())
                            {
                                featureLayer = layer as IFeatureLayer;
                                break;
                            }
                        }
                    }
                    layer = layers.Next();
                }
                else
                {
                    featureLayer = null;
                    break;
                }
            }
            return(featureLayer);
        }
Esempio n. 4
0
 private void axTOCControl1_OnMouseUp_1(object sender, ITOCControlEvents_OnMouseUpEvent e)
 {
     try
     {
         if (e.button == 1 && pMoveLayer != null && pMoveLayerPoint.Y != e.y)
         {
             esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone;
             IBasicMap          pBasicMap = null; object unk = null;
             object             data = null; ILayer pLayer = null;
             axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pBasicMap, ref pLayer, ref unk, ref data);
             IMap pMap = axMapControl1.ActiveView.FocusMap;
             if (pItem == esriTOCControlItem.esriTOCControlItemLayer || pLayer != null)
             {
                 if (pMoveLayer != pLayer)
                 {
                     ILayer pTempLayer;
                     //获得鼠标弹起时所在图层的索引号
                     for (int i = 0; i < pMap.LayerCount; i++)
                     {
                         pTempLayer = pMap.get_Layer(i);
                         if (pTempLayer == pLayer)
                         {
                             toIndex = i;
                         }
                     }
                 }
             }
             //移动到最前面
             else if (pItem == esriTOCControlItem.esriTOCControlItemMap)
             {
                 toIndex = 0;
             }
             //移动到最后面
             else if (pItem == esriTOCControlItem.esriTOCControlItemNone)
             {
                 toIndex = pMap.LayerCount - 1;
             }
             pMap.MoveLayer(pMoveLayer, toIndex);
             axMapControl1.ActiveView.Refresh();
             axTOCControl1.Update();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 5
0
        /// <summary>
        ///     右键弹出图层管理菜单,进行图层管理
        /// </summary>
        /// <params name="sender"></params>
        /// <params name="e"></params>
        private void tocControl_GM_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button != 2)
            {
                return;                //左键则跳出
            }
            var       item  = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap map   = null;
            ILayer    layer = null;
            object    unk   = null;
            object    data  = null;

            //判断选择类型,确定右键菜单的位置
            tocControl_GM.HitTest(e.x, e.y, ref item, ref map, ref layer, ref unk, ref data);
            if (layer == null)
            {
                return;
            }
            //确认所选项
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                tocControl_GM.SelectItem(map, null);
            }
            else
            {
                tocControl_GM.SelectItem(layer, null); //20140224 有bug
            }
            //设置图层的CustomProperty(在自定义图层命令中使用)
            mapControl_GM.CustomProperty = layer;

            //弹出菜单
            var menuMap = new LayersManagerMap();

            menuMap.SetHook(mapControl_GM);
            var menuLayer = new LayersManagerLayer();

            menuLayer.SetHook(mapControl_GM);
            if (item == esriTOCControlItem.esriTOCControlItemMap) //选中的为地图
            {
                menuMap.PopupMenu(e.x, e.y, tocControl_GM.hWnd);
            }
            if (item == esriTOCControlItem.esriTOCControlItemLayer) //选中的为图层
            {
                menuLayer.PopupMenu(e.x, e.y, tocControl_GM.hWnd);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// TOCC左键设置图例,右键弹出菜单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tocCtrl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            var       item = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap basicMap = null;
            object    unk = null, data = null;

            TocControl.HitTest(e.x, e.y, ref item, ref basicMap, ref SelectedLayer, ref unk, ref data);
            if (e.button == 2)
            {
                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    ToccMenuStrip.Show(TocControl, new System.Drawing.Point(e.x, e.y));
                    LayerIndex = MapControl.GetLayerIndex(SelectedLayer);
                    ShowFieldLabelMenuItems(SelectedLayer);
                }
            }
        }
Esempio n. 7
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            IBasicMap          pMap         = null;
            ILayer             pLayer       = null;
            object             legendgp     = null;
            object             index        = null;
            ToolbarMenu        m_pMenuLayer = new ToolbarMenu();
            esriTOCControlItem pItem        = esriTOCControlItem.esriTOCControlItemNone;

            try
            {
                axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref legendgp, ref index);
            }
            catch (Exception)
            {
                throw;
            }
            switch (e.button)
            {
            case 2:
                if (pItem == esriTOCControlItem.esriTOCControlItemMap)
                {
                    axTOCControl1.SelectItem(pMap, null);
                }
                else
                {
                    axTOCControl1.SelectItem(pLayer, null);
                }
                axMapControl1.CustomProperty = pLayer;
                if (pItem == esriTOCControlItem.esriTOCControlItemMap)
                {
                    //.............右键map时
                }
                if (pItem == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    m_pMenuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuLayer.AddItem(new ZoomToLayer(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuLayer.AddItem(new LayerVisibility(), 1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuLayer.AddItem(new LayerVisibility(), 2, 3, false, esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuLayer.AddItem(new OpenAttribute(pLayer), -1, 4, true, esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuLayer.SetHook(axMapControl1);
                    m_pMenuLayer.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
                }
                break;
            }
        }
Esempio n. 8
0
 private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
 {
     if (e.button == 2)
     {
         esriTOCControlItem pItem  = esriTOCControlItem.esriTOCControlItemNone;
         IBasicMap          pMap   = null;
         object             unk    = null;
         object             data   = null;
         ILayer             pLayer = null;
         axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref unk, ref data);
         pTocFeatureLayer = pLayer as IFeatureLayer;
         if (pItem == esriTOCControlItem.esriTOCControlItemLayer && pTocFeatureLayer != null)
         {
             contextMenuStrip2.Show(Control.MousePosition);
         }
     }
 }
Esempio n. 9
0
 private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
 {
     if (e.button == 2)
     {
         esriTOCControlItem Item      = esriTOCControlItem.esriTOCControlItemNone;
         IBasicMap          pBasicMap = null;
         ILayer             pLayer    = null;
         object             other     = null;
         object             index     = null;
         axTOCControl1.HitTest(e.x, e.y, ref Item, ref pBasicMap, ref pLayer, ref other, ref index);
         if (Item == esriTOCControlItem.esriTOCControlItemLayer)
         {
             m_Layer = pLayer;
             contextMenuStrip1.Show(Control.MousePosition);
         }
     }
 }
        public override void OnClick()
        {
            IHookActions hookActions = null;
            IBasicMap    basicMap    = null;

            //Get basic map and set hook actions
            if (m_hookHelper != null)
            {
                basicMap    = m_hookHelper.FocusMap as IBasicMap;
                hookActions = m_hookHelper as IHookActions;
            }

            else if (m_globeHookHelper != null)
            {
                basicMap    = m_globeHookHelper.Globe as IBasicMap;
                hookActions = m_globeHookHelper as IHookActions;
            }

            //Get feature selection
            ISelection selection = basicMap.FeatureSelection;
            //Get enumerator
            IEnumFeature enumFeature = selection as IEnumFeature;

            enumFeature.Reset();
            //Set first feature
            IFeature feature;

            feature = enumFeature.Next();

            //Loop though the features
            IArray array = new ESRI.ArcGIS.esriSystem.Array();

            while (feature != null)
            {
                //Add feature to array
                array.Add(feature.Shape);
                //Set next feature
                feature = enumFeature.Next();
            }

            //If the action is supported perform the action
            if (hookActions.get_ActionSupportedOnMultiple(array, esriHookActions.esriHookActionsZoom))
            {
                hookActions.DoActionOnMultiple(array, esriHookActions.esriHookActionsZoom);
            }
        }
Esempio n. 11
0
 IFeatureLayer tocSelectFeatureLayer = null;//点击图层控件选择的图层
 private void axTOCControl2_OnMouseDown(object sender, AxESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e)
 {
     if (e.button == 2)
     {
         esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
         IBasicMap          basicMap = null;
         object             data = null, unk = null;
         ILayer             layer = null;
         //获取点击的位置,图层等
         axTOCControl2.HitTest(e.x, e.y, ref item, ref basicMap, ref layer, ref unk, ref data);
         tocSelectFeatureLayer = layer as IFeatureLayer;
         if (item == esriTOCControlItem.esriTOCControlItemLayer && tocSelectFeatureLayer != null)
         {
             contextMenuStrip1.Show(Control.MousePosition);
         }
     }
 }
Esempio n. 12
0
 private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e)
 {
     if (e.button == 2)
     {
         esriTOCControlItem Item = esriTOCControlItem.esriTOCControlItemNone;
         //esriTOCControlItem Item = new esriTOCControlItem();
         IBasicMap pMap   = null;
         ILayer    pLayer = null;
         object    pOther = new object();
         object    pIndex = new object();
         axTOCControl1.HitTest(e.x, e.y, ref Item, ref pMap, ref pLayer, ref pOther, ref pIndex);
         if (Item == esriTOCControlItem.esriTOCControlItemLayer)
         {
             rightmenu.Show(MousePosition);
         }
     }
 }
Esempio n. 13
0
 private GisFrm_AttributeFrm attributeFrm = null; //存放图层属性窗体
 private void tOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
 {
     if (e.button == 2)                                                           //如果是右键点击
     {
         esriTOCControlItem tOCItem  = esriTOCControlItem.esriTOCControlItemNone; //用来存储点击的对象
         IBasicMap          basicMap = null;
         ILayer             Layer    = null;
         object             unk      = null;
         object             data     = null;
         tOCControl.HitTest(e.x, e.y, ref tOCItem, ref basicMap, ref Layer, ref unk, ref data); //内置方法,用来判断点击的对象,赋值给tocItem,并将图层信息赋值给layer
         clickLayer = Layer as IFeatureLayer;                                                   //将图层信息交给clickLayer,以便给查看属性表的click时间调用
         if (tOCItem == esriTOCControlItem.esriTOCControlItemLayer && clickLayer != null)       //如果点击的是图层对象
         {
             TOCcontextMenuStrip.Show(Control.MousePosition);                                   //打开右键菜单
         }
     }
 }
Esempio n. 14
0
        private void axTOCControl1_OnDoubleClick(object sender, ITOCControlEvents_OnDoubleClickEvent e)
        {
            esriTOCControlItem itemType = esriTOCControlItem.esriTOCControlItemNone;

            IBasicMap basicMap = null;

            ILayer layer = null;

            object unk = null;

            object data = null;

            axTOCControl1.HitTest(e.x, e.y, ref itemType, ref basicMap, ref layer, ref unk, ref data);

            if (e.button == 1)
            {
                if (itemType == esriTOCControlItem.esriTOCControlItemLegendClass)
                {
                    //取得图例

                    ILegendClass pLegendClass = ((ILegendGroup)unk).get_Class((int)data);

                    //创建符号选择器SymbolSelector实例

                    SymbolSelectorFrm SymbolSelectorFrm = new SymbolSelectorFrm(pLegendClass, layer);

                    if (SymbolSelectorFrm.ShowDialog() == DialogResult.OK)
                    {
                        //局部更新主Map控件

                        axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);

                        //设置新的符号

                        pLegendClass.Symbol = SymbolSelectorFrm.pSymbol;

                        //更新主Map控件和图层控件

                        this.axMapControl1.ActiveView.Refresh();

                        this.axTOCControl1.Refresh();
                    }
                }
            }
        }
Esempio n. 15
0
        //TOCControl打开属性表
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            IBasicMap          pMap     = null;
            ILayer             pLayer   = null;
            object             legendgp = null;
            object             index    = null;
            esriTOCControlItem pItem    = esriTOCControlItem.esriTOCControlItemNone;

            try
            {
                axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref legendgp, ref index);
            }
            catch (Exception)
            {
                throw;
            }
            switch (e.button)
            {
            case 2:
                if (pItem == esriTOCControlItem.esriTOCControlItemMap)
                {
                    axTOCControl1.SelectItem(axMapControl1, null);
                }
                else
                {
                    axTOCControl1.SelectItem(pLayer, null);
                }

                //将该图层设置为地图控件的自定义属性;
                axMapControl1.CustomProperty = pLayer;
                //弹出右键菜单
                if (pItem == esriTOCControlItem.esriTOCControlItemMap)
                {
                    m_pMenuMap.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
                }
                if (pItem == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    m_pMenuMap = new ToolbarMenuClass();
                    m_pMenuMap.AddItem(new OpenAttribute(pLayer), -1, 0, true, esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuMap.SetHook(axMapControl1);
                    m_pMenuMap.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
                }
                break;
            }
        }
Esempio n. 16
0
 public bool AddGroupLayer(IBasicMap pBasicMap, IGroupLayer pParentLayer, string sLayerName)
 {
     try
     {
         if (sLayerName == null)
         {
             sLayerName = "";
         }
         if (pBasicMap == null)
         {
             return(false);
         }
         if (string.IsNullOrEmpty(sLayerName))
         {
             sLayerName = "新建图层组";
         }
         IGroupLayer pLayer = null;
         pLayer = new GroupLayerClass {
             Name = sLayerName
         };
         if (pParentLayer == null)
         {
             pBasicMap.AddLayer(pLayer);
         }
         else
         {
             pParentLayer.Add(pLayer);
         }
         IMapLayers layers = pBasicMap as IMapLayers;
         if (pParentLayer == null)
         {
             layers.MoveLayer(pLayer, 0);
         }
         else if (pBasicMap is IMap)
         {
             layers.MoveLayerEx(pParentLayer, pParentLayer, pLayer, 0);
         }
         return(true);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.LayerFun", "AddGroupLayer", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }
Esempio n. 17
0
        public void OnMouseDown(int button, int shift, int x, int y)
        {
            // TODO:  添加 TOCHelper.OnMouseDown 实现

            IBasicMap          map   = null;
            ILayer             layer = null;
            Object             other = null;
            esriTOCControlItem pItem = 0;

            pTOCCtl.HitTest(x, y, ref pItem, ref map, ref layer, ref other, ref other);
            if (pItem == esriTOCControlItem.esriTOCControlItemLayer)
            {
                if (layer != null)
                {
                    pMainFrm.setCurrentLayer(layer);
                }
            }
        }
Esempio n. 18
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            ITOCControl        pTOCControl = axTOCControl1.Object as ITOCControl;
            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map = null; ILayer layer = null;
            object             other = null; object index = null;

            pTOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            if (e.button == 2)
            {
                switch (item)
                {
                case esriTOCControlItem.esriTOCControlItemMap:
                    this.contextMenuTOCMap.Show(this.axTOCControl1, e.x, e.y);
                    break;
                }
            }
        }
Esempio n. 19
0
        public void ChangeToCheckOutVerstion(string versionName)
        {
            this.superTabControl1.SelectedTabIndex = 1;
            IVersionedWorkspace    vws  = Util.ServerWorkspace as IVersionedWorkspace;
            IVersion               ver  = vws.DefaultVersion;
            IMapAdmin3             ma   = this.axMapControl2.Map as IMapAdmin3;
            IBasicMap              bmap = this.axMapControl2.Map as IBasicMap;
            AppManager             am   = AppManager.GetInstance();
            IChangeDatabaseVersion cdv  = new ChangeDatabaseVersionClass();

            ma.FireChangeVersion(am.CurrentVersion, ver);
            cdv.Execute(am.CurrentVersion, ver, bmap);

            am.CurrentVersion = ver;
            am.TaskName       = versionName;

            LocateTask(versionName);
        }
Esempio n. 20
0
 private void method_4(IBasicMap ibasicMap_0, ILayer ilayer_0, bool bool_1)
 {
     try
     {
         if (bool_1)
         {
             bool flag = true;
             if (ilayer_0 is IGeoFeatureLayer)
             {
                 IFeatureClass featureClass = (ilayer_0 as IGeoFeatureLayer).FeatureClass;
                 flag = featureClass.FeatureCount(null) > 0;
             }
             else if (ilayer_0 is IFDOGraphicsLayer)
             {
                 ITable attributeTable = (ilayer_0 as IAttributeTable).AttributeTable;
                 flag = attributeTable.RowCount(null) > 0;
             }
             if (flag)
             {
                 if (this.ienvelope_0 != null)
                 {
                     IEnvelope areaOfInterest = ilayer_0.AreaOfInterest;
                     if ((areaOfInterest.SpatialReference is IUnknownCoordinateSystem ||
                          this.ienvelope_0.SpatialReference is IUnknownCoordinateSystem ||
                          this.ienvelope_0.SpatialReference == null
                         ? false
                         : areaOfInterest.SpatialReference != null))
                     {
                         areaOfInterest.Project(this.ienvelope_0.SpatialReference);
                         this.ienvelope_0.Union(areaOfInterest);
                     }
                 }
                 else
                 {
                     this.ienvelope_0 = ilayer_0.AreaOfInterest;
                 }
             }
         }
         ibasicMap_0.AddLayer(ilayer_0);
     }
     catch (Exception exception)
     {
     }
 }
Esempio n. 21
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map   = null;
            ILayer             layer = null;
            object             other = null;
            object             index = null;

            //Determine what kind of item is selected
            axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);


            //Ensure the item gets selected
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                axTOCControl1.SelectItem(map, null);
            }
            else if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                axTOCControl1.SelectItem(layer, null);
            }
            else
            {
                return;
            }

            //Set the layer into the CustomProperty (this is used by the custom layer commands)
            m_mapControl.CustomProperty = layer;

            if (e.button != 2)
            {
                return;
            }

            //Popup the correct context menu--
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                m_pTOCMapMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
            }
            if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                m_pTOCLayerMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
            }
        }
Esempio n. 22
0
 public int FindLayerPosition(IBasicMap pBasicMap, ILayer pLayer, ref IGroupLayer pParentLayer)
 {
     try
     {
         pParentLayer = null;
         if (pBasicMap != null)
         {
             if (pBasicMap.LayerCount <= 0)
             {
                 return(-1);
             }
             if (pLayer == null)
             {
                 return(-1);
             }
             int    index = 0;
             int    num2  = -1;
             ILayer objA  = null;
             for (index = 0; index <= (pBasicMap.LayerCount - 1); index++)
             {
                 objA = pBasicMap.get_Layer(index);
                 if (object.Equals(objA, pLayer))
                 {
                     pParentLayer = null;
                     return(index);
                 }
                 if (objA is IGroupLayer)
                 {
                     num2 = this.FindLayerPositionGroupRecursion(objA as IGroupLayer, pLayer, ref pParentLayer);
                     if (num2 >= 0)
                     {
                         return(num2);
                     }
                 }
             }
         }
         return(-1);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.LayerFun", "FindLayerPosition", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(-1);
     }
 }
Esempio n. 23
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button != 2)
            {
                return;
            }
            esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map   = null;
            ILayer             layer = null;
            object             other = null;
            object             index = null;

            //判断所选菜单的类型
            axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            //m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            //确定选定的菜单类型,Map或是图层菜单
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                axTOCControl1.SelectItem(map, null);
            }
            else if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                axTOCControl1.SelectItem(layer, null);
            }
            else
            {
                return;
            }

            //设置CustomProperty为layer (用于自定义的Layer命令)
            IMapControl3 m_mapControl = (IMapControl3)this.axMapControl1.Object;

            m_mapControl.CustomProperty = layer;
            //弹出右键菜单
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                m_menuMap.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
            }

            if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                m_menuLayer.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
            }
        }
Esempio n. 24
0
        /// <summary>
        /// 获取图层控制控件中选中的图层
        /// </summary>
        /// <returns></returns>
        private ILayer GetTocSelectedLayer()
        {
            IBasicMap          map   = null;
            ILayer             layer = null;
            object             unk   = null;
            object             data  = null;
            esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;

            //esriTOCControlItemNone | esriTOCControlItemMap | esriTOCControlItemLayer | esriTOCControlItemHeading |esriTOCControlItemLegendClass
            axTOCControl1.GetSelectedItem(ref item, ref map, ref layer, ref unk, ref data);
            if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                return(layer);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 25
0
 private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
 {
     if (e.button == 2)//右键,1为按左键
     {
         esriTOCControlItem pItem  = esriTOCControlItem.esriTOCControlItemNone;
         IBasicMap          pMap   = null;
         object             unk    = null;
         object             data   = null;
         ILayer             pLayer = null;
         axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref unk, ref data);
         pTocFeatureLayer = pLayer as IFeatureLayer;
         if (pItem == esriTOCControlItem.esriTOCControlItemLayer && pTocFeatureLayer != null)
         {
             图层可选ToolStripMenuItem.Enabled  = !pTocFeatureLayer.Selectable; //设置当前为图层为可选,所以此按钮灰色
             图层不可选ToolStripMenuItem.Enabled = pTocFeatureLayer.Selectable;  //图层不可选按钮亮着可以选
             contextMenuStrip1.Show(MousePosition);
         }
     }
 }
Esempio n. 26
0
        // 在 TOCControl 对象中判断鼠标点中的项目并弹出右键菜单

        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button == 2)
            {
                // 右键
                esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
                IBasicMap          map   = null;
                ILayer             layer = null;
                Object             other = null;
                Object             index = null;

                // HitTest 方法用于按照鼠标指针的位置进行鼠标点击测试
                // 该方法的前两个参数表示鼠标位置的 x 和 y 坐标,
                // 接下来的三个参数是 ref 类型,可以作为返回值,分别表达了:
                // item 参数:点中的项目类型;
                // map 参数:点中的 Map 对象;
                // layer 参数:点中的 Layer 对象。
                // 最后两个参数用的较少,不做详细介绍。
                // 其中利用 item 参数就可以判断点中的是什么项目,
                // 而其后的 map 和 layer 参数按照 item 的结果返回对应类型的接口值

                axTOCControl1.HitTest(
                    e.x, e.y, ref item, ref map, ref layer, ref other, ref index
                    );

                if (item == esriTOCControlItem.esriTOCControlItemMap)
                {
                    //  如果点中了一个 Map 项目

                    MapMenuStrip.Show(axTOCControl1, e.x, e.y);

                    HitMap = map as IMap;
                }
                else if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    // 如果点中了一个图层项目

                    LayerMenuStrip.Show(axTOCControl1, e.x, e.y);

                    HitLayer_ILayer = layer;
                }
            }
        }
Esempio n. 27
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            //如果不是右键按下直接返回
            if (e.button != 2)
            {
                return;
            }

            if (e.button == 2)
            {
                esriTOCControlItem item        = esriTOCControlItem.esriTOCControlItemNone;
                IBasicMap          map         = null;
                ILayer             layer       = null;
                object             other       = null;
                object             index       = null;
                RightMenu          rtMenu      = new RightMenu(axTOCControl1);
                IToolbarMenu       m_meunLayer = rtMenu.getToolbarMenu();
                m_meunLayer.SetHook(m_mapControl);
                //判断所选菜单的类型
                rtMenu.m_TocC.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

                //确定选定的菜单类型,Map 或是图层菜单
                if (item == esriTOCControlItem.esriTOCControlItemMap)
                {
                    rtMenu.m_TocC.SelectItem(map, null);
                }
                else
                {
                    rtMenu.m_TocC.SelectItem(layer, null);
                }

                //设置CustomProperty 为layer (用于自定义的Layer 命令)
                m_mapControl.CustomProperty = layer;
                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    //动态添加ShowAttributeTable菜单项
                    m_meunLayer.AddItem(new OpenAttributeTable(layer), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
                    m_meunLayer.PopupMenu(e.x, e.y, rtMenu.m_TocC.hWnd);
                    //移除OpenAttributeTable菜单项,以防止重复添加
                    m_meunLayer.Remove(2);
                }
            }
        }
Esempio n. 28
0
 private void TOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
 {
     if (e.button == 2)
     {
         esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
         IBasicMap          map   = null;
         object             unk   = null;
         object             data  = null;
         ILayer             layer = null;
         TOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref unk, ref data);
         pTocFeatureLayer = layer as IFeatureLayer;
         if (item == esriTOCControlItem.esriTOCControlItemLayer && pTocFeatureLayer != null)
         {
             btnLayerSel.Enabled   = !pTocFeatureLayer.Selectable;
             btnLayerUnSel.Enabled = pTocFeatureLayer.Selectable;
             contextMenuStrip1.Show(Control.MousePosition);
         }
     }
 }
Esempio n. 29
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            //如果不是右键按下直接返回
            if (e.button != 2)
            {
                return;
            }
            esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map   = null;
            ILayer             layer = null;
            object             other = null;
            object             index = null;

            //判断所选菜单的类型
            m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

            //确定选定的菜单类型,Map或是图层菜单
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                m_tocControl.SelectItem(map, null);
            }
            if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                m_tocControl.SelectItem(layer, null);
            }

            //设置CustomPropety为layer(用于自定义的Layer命令)
            m_mapControl.CustomProperty = layer;

            //弹出右键菜单
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                m_menuMap.PopupMenu(e.x, e.y, m_tocControl.hWnd);
            }
            else if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                //动态添加OpenAttributeTable菜单项
                m_menuLayer.AddItem(new OpenAttributeTable(layer), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
                m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);
                //移除OpenAttributeTable菜单项,以防止重复添加
                m_menuLayer.Remove(2);
            }
        }
Esempio n. 30
0
 private TOCTreeNode FindMapNodeByMap(IBasicMap pMap)
 {
     for (int i = 0; i < this.m_pTOCTreeView.Nodes.Count; i++)
     {
         TOCTreeNode node = this.m_pTOCTreeView.Nodes[i] as TOCTreeNode;
         if (node.Tag is IBasicMap)
         {
             if (node.Tag == pMap)
             {
                 return(node);
             }
         }
         else if ((node.Tag is IMapFrame) && ((node.Tag as IMapFrame).Map == pMap))
         {
             return(node);
         }
     }
     return(null);
 }
Esempio n. 31
0
        public static ISurface GetCurrentSurface(ISceneGraph isceneGraph_0)
        {
            IBasicMap basicMap = isceneGraph_0.Scene as IBasicMap;
            short     num      = 0;
            ISurface  result;

            while ((int)num < basicMap.LayerCount)
            {
                ISurface surfaceFromLayer = SurfaceInfo.GetSurfaceFromLayer(basicMap.get_Layer((int)num));
                if (surfaceFromLayer != null)
                {
                    result = surfaceFromLayer;
                    return(result);
                }
                num += 1;
            }
            result = null;
            return(result);
        }
Esempio n. 32
0
 /// <summary>
 /// Initializes the map tool, telling it what map that it will be working with.
 /// </summary>
 /// <param name="map">Any implementation of IBasicMap that the tool can work with</param>
 public virtual void Init(IBasicMap map)
 {
     _basicMap = map;
 }
Esempio n. 33
0
 /// <summary>
 /// Constructs and initializes this toolbar using the specified IBasicMap
 /// </summary>
 /// <param name="map">The map for the toolbar to interact with</param>
 public mwToolStrip(IBasicMap map)
 {
     Init(map);
     InitializeComponent();
 }
Esempio n. 34
0
 /// <summary>
 /// 取得图层的上一级对象,可能是igrouplayer,或ibasicmap
 /// </summary>
 /// <param name="map"></param>
 /// <param name="layer"></param>
 /// <returns></returns>
 public static object GetLayerParent(IBasicMap map, ILayer layer)
 {
     ILayer tmpLayer;
     for (int i = 0; i <= map.LayerCount - 1; i++)
     {
         tmpLayer = map.get_Layer(i);
         if (tmpLayer == layer)
         {
             return map;
         }
         else if (tmpLayer is IGroupLayer)
         {
             IGroupLayer ly = FindParentGroupLayer(tmpLayer as IGroupLayer, layer);
             if (ly != null)
                 return ly;
         }
     }
     return map;
 }
    public void Init(IBasicMap mapOrGlobe)
    {
      System.Diagnostics.Trace.WriteLine("Init - Thread ID: " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());

      if (mapOrGlobe == null)
        return;

      m_mapOrGlobe = mapOrGlobe;

      try
      {
        //initialize the tables (main table as well as the symbols table)
        InitializeTables();

        //get the location list from a featureclass (US major cities) and synchronize it with the 
        //cached information in case it exists.
        if (null == m_locations)
          InitializeLocations();

        m_point = new PointClass();
        m_SRWGS84 = CreateGeographicSpatialReference();
        m_point.SpatialReference = m_SRWGS84;

        m_textSymbol = new TextSymbolClass() as ISimpleTextSymbol;
        m_textSymbol.Font = ToFontDisp(new Font("Tahoma", 10.0f, FontStyle.Bold));
        m_textSymbol.Size = 10.0;
        m_textSymbol.Color = (IColor)ToRGBColor(Color.FromArgb(0, 255, 0));
        m_textSymbol.XOffset = 0.0;
        m_textSymbol.YOffset = 16.0;
        
        
        m_graphicTracker = new GraphicTrackerClass();
        m_graphicTracker.Initialize(mapOrGlobe as object);

        if (m_weatherItemTable.Rows.Count > 0)
          PopulateGraphicTracker();

        m_invokeHelper = new InvokeHelper(this);

        this.OnWeatherItemAdded += new WeatherItemAdded(OnWeatherItemAddedEvent);

        //instantiate the timer for the weather update thread
        m_timer = new System.Timers.Timer(1000);
        m_timer.Elapsed += new ElapsedEventHandler(OnUpdateTimer);  
        //enable the update timer
        m_timer.Enabled = true;
      }
      catch (Exception ex)
      {
        System.Diagnostics.Trace.WriteLine(ex.Message);
      }
    }
Esempio n. 36
0
 /// <summary>
 /// Initializes the map tool, telling it what map that it will be working with.
 /// </summary>
 /// <param name="map">Any implementation of IBasicMap that the tool can work with</param>
 private void Init(IBasicMap map)
 {
     _basicMap = map;
 }
Esempio n. 37
0
        /// <summary>
        /// Constructs and initializes this toolbar using the specified IBasicMap
        /// </summary>
        /// <param name="map">The map for the toolbar to interact with</param>
        public SpatialToolStrip(IBasicMap map)
        {
            Init(map);
            InitializeComponent();

            map.MapFrame.ViewExtentsChanged += MapFrame_ViewExtentsChanged;
        }