Example #1
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add TurnAllLayersOnCmd.OnClick implementation
            if (m_hookHelper.Hook is IToolbarControl)
            {
                IToolbarControl toolbarControl = m_hookHelper.Hook as IToolbarControl;
                m_mapcontrol = (IMapControl3)toolbarControl.Buddy;
            }
            if (m_hookHelper.Hook is IMapControl3)
            {
                m_mapcontrol = m_hookHelper.Hook as IMapControl3;
            }
            if (m_mapcontrol != null)
            {
                m_map        = m_mapcontrol.CustomProperty as IMap;
                m_activeView = m_map as IActiveView;
            }
            if (m_map == null)
            {
                return;
            }
            ILayer layer = null;

            for (int i = 0; i < m_map.LayerCount; i++)
            {
                layer         = m_map.get_Layer(i);
                layer.Visible = true;
            }
            m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography,
                                        null, m_activeView.Extent);
        }
Example #2
0
        /// <summary>
        /// Adds the recent file.
        /// </summary>
        /// <param name="featureLayer">The feature layer.</param>
        //private static void AddRecentFile(IFeatureLayer featureLayer)
        //{
        //    FileType shp = FileType.Shp;
        //    string str = "";
        //    switch (featureLayer.DataSourceType)
        //    {
        //        case "Shapefile Feature Class":
        //            shp = FileType.Shp;
        //            str = ".shp";
        //            break;

        //        case "Personal Geodatabase Feature Class":
        //            shp = FileType.MDB;
        //            break;

        //        case "CAD Point Feature Class":
        //        case "CAD Polyline Feature Class":
        //        case "CAD Polygon Feature Class":
        //            shp = FileType.CAD;
        //            break;

        //        case "File Geodatabase Feature Class":
        //            shp = FileType.GDB;
        //            break;

        //        default:
        //            return;
        //    }
        //    IDatasetName dataSourceName = (featureLayer as IDataLayer).DataSourceName as IDatasetName;
        //    RecentFile file = new RecentFile
        //    {
        //        Type = (int)shp,
        //        Name = dataSourceName.Name + str
        //    };
        //    if (shp == FileType.CAD)
        //    {
        //        string name = (dataSourceName as IFeatureClassName).FeatureDatasetName.Name;
        //        file.Path = Path.Combine(dataSourceName.WorkspaceName.PathName, name);
        //        file.FullPath = Path.Combine(file.Path, file.Name);
        //    }
        //    else
        //    {
        //        file.Path = dataSourceName.WorkspaceName.PathName;
        //        IDatasetName featureDatasetName = (dataSourceName as IFeatureClassName).FeatureDatasetName;
        //        if (featureDatasetName != null)
        //        {
        //            string str3 = featureDatasetName.Name;
        //            file.FullPath = Path.Combine(file.Path, str3, file.Name);
        //        }
        //        else
        //        {
        //            file.FullPath = Path.Combine(file.Path, file.Name);
        //        }
        //    }
        //    AddItemToListBox(file);
        //}

        /// <summary>
        /// Adds the recent file.
        /// </summary>
        /// <param name="sFilePath">The s file path.</param>
        /// <param name="type">The type.</param>
        //public static void AddRecentFile(string sFilePath, FileType type)
        //{
        //    RecentFile file = new RecentFile
        //    {
        //        Name = Path.GetFileName(sFilePath),
        //        Path = Path.GetDirectoryName(sFilePath),
        //        FullPath = sFilePath,
        //        Type = (int)type
        //    };
        //    AddItemToListBox(file);
        //}

        /// <summary>
        /// Gets the current layer.
        /// </summary>
        /// <param name="hookHelper">The hook helper.</param>
        /// <returns>ILayer.</returns>
        public static ILayer GetCurrentLayer(IHookHelper hookHelper)
        {
            ILayer              customProperty = null;
            IMapControl4        hook           = null;
            IPageLayoutControl3 control2       = null;

            if (hookHelper.Hook is IMapControl4)
            {
                hook = (IMapControl4)hookHelper.Hook;
                return(hook.CustomProperty as ILayer);
            }
            if (hookHelper.Hook is IPageLayoutControl3)
            {
                control2 = (IPageLayoutControl3)hookHelper.Hook;
                return(control2.CustomProperty as ILayer);
            }
            if (hookHelper.Hook is IToolbarControl)
            {
                IToolbarControl control3 = (IToolbarControl)hookHelper.Hook;
                object          buddy    = control3.Buddy;
                if (buddy is IMapControl4)
                {
                    hook = (IMapControl4)buddy;
                    return(hook.CustomProperty as ILayer);
                }
                if (buddy is IPageLayoutControl3)
                {
                    control2       = (IPageLayoutControl3)buddy;
                    customProperty = control2.CustomProperty as ILayer;
                }
            }
            return(customProperty);
        }
Example #3
0
        public ClsEditorMain(IToolbarControl pToolbarControl, AxMapControl pMapControl, object _frmMain)
        {
            m_EditType        = "CallOut";
            frmMain           = _frmMain;
            ToolState         = false;
            mToolbarControl   = pToolbarControl;
            m_pOperationStack = pToolbarControl.OperationStack;

            PToolbar       = pToolbarControl;
            m_pMapControl  = pMapControl;
            DefaultVersion = null;
            SnapEnv        = null;
            BEndInkText    = false;

            //初始化有个默认的捕捉类,避免程序中某些用到的地方出现错误
            SnapPoint = new SnapPointClass();

            Type type = frmMain.GetType();

            MethodInfo_RefreshCommandArgs         = type.GetMethod("RefreshCommandArgs");
            MethodInfo_GetCommandTipEventArgs     = type.GetMethod("GetCommandTipEventArgs");
            MethodInfo_SetFocusEventArgs          = type.GetMethod("SetFocusEventArgs");
            MethodInfo_PopupMenuEventArgs         = type.GetMethod("PopupMenuEventArgs");
            MethodInfo_GetGeometryEventArgs       = type.GetMethod("GetGeometry");
            MethodInfo_SetBuddyTB                 = type.GetMethod("SetBuddyTool");
            MethodInfo_CustomSetToolState         = type.GetMethod("CustomSetToolState");
            MethodInfo_GetCurrentVersionID        = type.GetMethod("GetCurrentVersionID");
            MethodInfo_GetToolbar                 = type.GetMethod("GetToolbar");
            MethodInfo_CartoCommondTip            = type.GetMethod("CartoCommondTip");
            MethodInfo_PopupMenuEventArgsForCarto = type.GetMethod("PopupMenuEventArgsForCarto");
            MethodInfo_GetBufferSetForm           = type.GetMethod("GetBufferSetForm");
        }
Example #4
0
        /// <summary>
        /// Occurs when this tool is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            m_hookHelper      = new HookHelperClass();
            m_hookHelper.Hook = hook;
            try
            {
                m_hookHelper      = new HookHelperClass();
                m_hookHelper.Hook = hook;
                if (m_hookHelper.ActiveView == null)
                {
                    m_hookHelper = null;
                }
            }
            catch
            {
                m_hookHelper = null;
            }

            if (m_hookHelper == null)
            {
                base.m_enabled = false;
            }
            else
            {
                base.m_enabled = true;
            }

            // TODO:  Add other initialization code
            if (hook is IToolbarControl)
            {
                IToolbarControl toolbarControl = (IToolbarControl)hook;
                pMapControl = (IMapControl3)toolbarControl.Buddy;
            }
        }
        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (hook == null)
            {
                return;
            }
            //在这里对hook进行判断
            //if (m_hookHelper == null)
            //    m_hookHelper = new HookHelperClass();

            //m_hookHelper.Hook = hook;

            if (hook is IToolbarControl)
            {
                IToolbarControl pToolBar = hook as IToolbarControl;
                pMapControl = pToolBar.Buddy as IMapControl2;
            }
            else if (hook is IMapControl2)
            {
                pMapControl = hook as IMapControl2;
            }


            // TODO:  Add other initialization code
        }
        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (hook == null)
            {
                return;
            }

            try
            {
                m_globeHookHelper      = new GlobeHookHelperClass();
                m_globeHookHelper.Hook = hook;

                pToolbarControl = hook as IToolbarControl;

                //if (m_globeHookHelper.ActiveViewer == null)
                //{
                //    m_globeHookHelper = null;
                //}
            }
            catch
            {
                m_globeHookHelper = null;
            }

            if (m_globeHookHelper == null)
            {
                base.m_enabled = false;
            }
            else
            {
                base.m_enabled = true;
            }

            // TODO:  Add other initialization code
        }
Example #7
0
        /// <summary>
        /// Occurs when this tool is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            try
            {
                m_hookHelper      = new HookHelperClass();
                m_hookHelper.Hook = hook;
                if (m_hookHelper.ActiveView == null)
                {
                    m_hookHelper = null;
                }

                if (m_hookHelper.Hook is IToolbarControl)
                {
                    IToolbarControl toolbarControl = m_hookHelper.Hook as IToolbarControl;
                    m_pMapControl = toolbarControl.Buddy as IMapControl3;
                }
                else if (m_hookHelper.Hook is IMapControl3)
                {
                    m_pMapControl = m_hookHelper.Hook as IMapControl3;
                }
            }
            catch
            {
                m_hookHelper = null;
            }
        }
Example #8
0
        public GPClip(IHookHelper hookHelper)
        {
            InitializeComponent();
            if (hookHelper == null)
            {
                return;
            }

            m_hookHelper = hookHelper;
            m_activeView = m_hookHelper.ActiveView;
            m_map        = m_hookHelper.FocusMap;

            if (m_hookHelper.Hook is IApplication)
            {
                m_application = m_hookHelper.Hook as IApplication;
                UID uID = new UID();
                uID.Value = "esriEditor.Editor";
                if (m_application == null)
                {
                    return;
                }
                m_editor = m_application.FindExtensionByCLSID(uID) as IEditor;
            }

            if (m_hookHelper.Hook is IToolbarControl)
            {
                IToolbarControl toolbarControl = m_hookHelper.Hook as IToolbarControl;
                m_mapControl = (IMapControl3)toolbarControl.Buddy;
            }
            if (m_hookHelper.Hook is IMapControl3)
            {
                m_mapControl = m_hookHelper.Hook as IMapControl3;
            }
        }
Example #9
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            if (m_hookHelper.Hook is IToolbarControl)
            {
                IToolbarControl ToolBarControl = m_hookHelper.Hook as IToolbarControl;
                m_mapcontrol = (IMapControl3)ToolBarControl.Buddy;
            }
            if (m_hookHelper.Hook is IMapControl3)
            {
                m_mapcontrol = m_hookHelper.Hook as IMapControl3;
            }
            if (m_mapcontrol.LayerCount == 0)
            {
                return;
            }
            m_pMap.m_RefLayers.Clear();
            m_pMap.m_TagLayers.Clear();
            m_pMap.RefReset();
            m_pMap.TagReset();
            m_pMap.BufferReset();
            m_pMap.BufferPtReset();
            m_pMap.InterReset();

            指定匹配图层 pSecifyDataCmd = new 指定匹配图层(m_mapcontrol, m_pMap);

            pSecifyDataCmd.Show();
            // TODO: Add SpecifyDataCmd1.OnClick implementation
        }
Example #10
0
 /// <summary>
 /// when the active control changes, the class iterates through the array of the framework controls
 ///  and calls SetBuddyControl on each of the controls.
 /// </summary>
 /// <param name="buddy">the active control</param>
 private void SetBuddies(object buddy)
 {
     try
     {
         if (buddy == null)
         {
             throw new Exception("ControlsSynchronizer::SetBuddies:\r\nTarget Buddy Control is not initialized!");
         }
         foreach (object obj in frameworkControls)
         {
             IToolbarControl toolbarControl = obj as IToolbarControl;
             if (toolbarControl != null)
             {
                 toolbarControl.SetBuddyControl(buddy);
             }
             else if (obj is ITOCControl)
             {
                 ((ITOCControl)obj).SetBuddyControl(buddy);
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(string.Format("ControlsSynchronizer::SetBuddies:\r\n{0}", ex.Message));
     }
 }
Example #11
0
 public void BuddyToolBarControl(IToolbarControl pControl)
 {
     //this._oStack = new ControlsOperationStackClass();
     //pControl.OperationStack = this._oStack;
     //IExtension extension = this._editor as IExtension;
     //object initializationData = pControl.Object;
     //extension.Startup(ref initializationData);
 }
Example #12
0
        public static void Addtool(AxMapControl axMapControl, IMapControl3 mapControl, IToolbarControl toolbarControl, IWorkspace workSpace)
        {
            //全局变量赋值
            DataEditCommon.g_tbCtlEdit = toolbarControl;
            DataEditCommon.g_pMyMapCtrl = mapControl;
            DataEditCommon.g_pCurrentWorkSpace = workSpace;
            DataEditCommon.g_pAxMapControl = axMapControl;
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.UndoEdit(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.RedoEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AttributeQueryEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.MeasureDistance(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.MeasureArea(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.FeatureSelect(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.FeatureClearSelect(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.SaveEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);

            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.FixedZoomInCommand(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.FixedZoomOutCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ZoomInTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ZoomOutTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ExtentBackCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ExtentForwardCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.PanTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ZoomToTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.RefreshViewCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.FullExtentTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.MapRotateTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            //Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ToolbarLocalView(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.LocalView(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ClearView(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);

            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.RotateTool(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.FeatureMoveEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.MirrorFeature(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.EditCopyCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.EditCutCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.EditPasteCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.DeleteFeature(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.ExtendTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.TrimLineTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);

            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.LayersList(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.AddPoint(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddStraightFeatureLine(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.AddFeatureLine(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddBezierCurve(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddRectangle(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddText(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddCircle(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddArc(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddEllipse(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.AddPolygon(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
        }
Example #13
0
 public SpatialExtentQuery(IHookHelper hookHelper)
 {
     InitializeComponent();
     m_hookHelper = hookHelper;
     m_activeView = m_hookHelper.ActiveView;
     m_map        = m_hookHelper.FocusMap;
     if (m_hookHelper.Hook is IToolbarControl)
     {
         IToolbarControl toolbarControl = m_hookHelper.Hook as IToolbarControl;
         m_mapControl = (IMapControl3)toolbarControl.Buddy;
     }
     if (m_hookHelper.Hook is IMapControl3)
     {
         m_mapControl = m_hookHelper.Hook as IMapControl3;
     }
 }
Example #14
0
        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (hook == null)
            {
                return;
            }

            if (m_hookHelper == null)
            {
                m_hookHelper = new HookHelperClass();
            }

            m_hookHelper.Hook = hook;
            control           = m_hookHelper.Hook as IToolbarControl;
            // TODO:  Add other initialization code
        }
Example #15
0
        public SymbolizationByLayerPropPage(IHookHelper hookHelper)
        {
            InitializeComponent();

            m_hookHelper = hookHelper;
            m_activeView = m_hookHelper.ActiveView;
            m_map        = m_hookHelper.FocusMap;

            if (m_hookHelper.Hook is IToolbarControl)
            {
                IToolbarControl toolbarControl = m_hookHelper.Hook as IToolbarControl;
                m_mapControl = (IMapControl3)toolbarControl.Buddy;
            }
            if (m_hookHelper.Hook is IMapControl3)
            {
                m_mapControl = m_hookHelper.Hook as IMapControl3;
            }
        }
Example #16
0
        /// <summary>
        /// Occurs when this tool is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (m_hookHelper == null)
            {
                m_hookHelper = new HookHelperClass();
            }

            m_hookHelper.Hook = hook;
            if (hook is IMapControlDefault)
            {
                m_mapCtrl = hook as IMapControlDefault;
            }
            else if (hook is IToolbarControl)
            {
                IToolbarControl toolbarCtrl = hook as IToolbarControl;
                m_mapCtrl = toolbarCtrl.Buddy as IMapControlDefault;
            }

            // TODO:  Add QueryTool.OnCreate implementation
        }
Example #17
0
        public GIS_ToolbarEdit(AxMapControl axMapControl, IMapControl3 mapControl, IToolbarControl toolbarControl, IWorkspace workSpace)
        {
            //全局变量赋值
            DataEditCommon.g_tbCtlEdit         = toolbarControl;
            DataEditCommon.g_pMyMapCtrl        = mapControl;
            DataEditCommon.g_pCurrentWorkSpace = workSpace;
            DataEditCommon.g_pAxMapControl     = axMapControl;

            BeginGroup();
            //AddItem("GIS.GraphicModify.RotateTool");
            AddItem("GIS.GraphicEdit.UndoEdit");
            AddItem("GIS.GraphicEdit.RedoEdit");
            AddItem("GIS.GraphicEdit.AttributeQueryEdit");
            AddItem("GIS.GraphicEdit.MeasureDistance");
            AddItem("GIS.GraphicEdit.MeasureArea");
            //AddItem("GIS.GraphicEdit.MenuFeatureSelect");
            AddItem("GIS.GraphicEdit.FeatureSelect");
            AddItem("GIS.GraphicEdit.FeatureClearSelect");
            //AddItem("GIS.GraphicEdit.SnapSetting");
            AddItem("GIS.GraphicEdit.SaveEdit");
        }
        public GIS_ToolbarEdit(AxMapControl axMapControl, IMapControl3 mapControl, IToolbarControl toolbarControl, IWorkspace workSpace)
        {
            //ȫ�ֱ�����ֵ
            DataEditCommon.g_tbCtlEdit = toolbarControl;
            DataEditCommon.g_pMyMapCtrl = mapControl;
            DataEditCommon.g_pCurrentWorkSpace = workSpace;
            DataEditCommon.g_pAxMapControl = axMapControl;

            BeginGroup();
            //AddItem("GIS.GraphicModify.RotateTool");
            AddItem("GIS.GraphicEdit.UndoEdit");
            AddItem("GIS.GraphicEdit.RedoEdit");
            AddItem("GIS.GraphicEdit.AttributeQueryEdit");
            AddItem("GIS.GraphicEdit.MeasureDistance");
            AddItem("GIS.GraphicEdit.MeasureArea");
            //AddItem("GIS.GraphicEdit.MenuFeatureSelect");
            AddItem("GIS.GraphicEdit.FeatureSelect");
            AddItem("GIS.GraphicEdit.FeatureClearSelect");
            //AddItem("GIS.GraphicEdit.SnapSetting");
            AddItem("GIS.GraphicEdit.SaveEdit");
        }
Example #19
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            if (m_hookHelper.Hook is IToolbarControl)
            {
                IToolbarControl toolbarControl = m_hookHelper.Hook as IToolbarControl;
                m_mapcontrol = (IMapControl3)toolbarControl.Buddy;
            }
            if (m_hookHelper.Hook is IMapControl3)
            {
                m_mapcontrol = m_hookHelper.Hook as IMapControl3;
            }
            if (m_mapcontrol != null)
            {
                currentLayer = m_mapcontrol.CustomProperty as IFeatureLayer;
                m_activeView = m_mapcontrol.ActiveView;
            }

            if (currentLayer == null)
            {
                return;
            }
            SetupFeaturePropertySheet(currentLayer);
        }
Example #20
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            if (m_hookHelper.Hook is IToolbarControl)
            {
                IToolbarControl toolbarControl = m_hookHelper.Hook as IToolbarControl;
                m_mapcontrol = (IMapControl3)toolbarControl.Buddy;
            }
            if (m_hookHelper.Hook is IMapControl3)
            {
                m_mapcontrol = m_hookHelper.Hook as IMapControl3;
            }
            if (m_mapcontrol != null)
            {
                m_map        = m_mapcontrol.CustomProperty as IMap;
                m_activeView = m_map as IActiveView;
            }

            if (m_map == null)
            {
                return;
            }
            m_map.ReferenceScale = m_map.MapScale;
        }
        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (hook == null)
            {
                return;
            }
            //在这里对hook进行判断

            if (hook is IToolbarControl)

            {
                IToolbarControl pToolBar = hook as IToolbarControl;
                pMapControl = pToolBar.Buddy as IMapControl2;
            }
            else if (hook is IMapControl2)
            {
                pMapControl = hook as IMapControl2;
            }



            // TODO:  Add other initialization code
        }
Example #22
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            if (m_hookHelper.Hook is IToolbarControl)
            {
                IToolbarControl toolbarControl = m_hookHelper.Hook as IToolbarControl;
                m_mapcontrol = (IMapControl3)toolbarControl.Buddy;
            }
            if (m_hookHelper.Hook is IMapControl3)
            {
                m_mapcontrol = m_hookHelper.Hook as IMapControl3;
            }
            if (m_mapcontrol != null)
            {
                m_map        = m_mapcontrol.CustomProperty as IMap;
                m_activeView = m_map as IActiveView;
            }

            if (m_map == null)
            {
                return;
            }
            TurnAllLayersOff();
            m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_activeView.Extent);
        }
Example #23
0
        public void OnClick(int EditMode)
        {
            m_pAV = m_pHookHelper.ActiveView;
            IViewManager pViewManager = (IViewManager)m_pAV;
            IEnumElement pEnumElement = (IEnumElement)pViewManager.ElementSelection;

            pEnumElement.Reset();
            IElement pElement = pEnumElement.Next();

            if (pElement == null)
            {
                return;
            }
            int i = 0;

            while (pElement != null)
            {
                i++;
                pElement = pEnumElement.Next();
                if (i > 1)
                {
                    return;
                }
            }

            pEnumElement.Reset();
            pElement = pEnumElement.Next();

            if (pElement is IMapSurroundFrame)
            {
                IMapSurroundFrame pMapSFrame = (IMapSurroundFrame)pElement;
                if (pMapSFrame.MapSurround is ILegend)
                {
                    frmAddLegend vFrmLegend = new frmAddLegend(false);
                    vFrmLegend.SetMapSurroundFrame(pMapSFrame);
                    return;
                }
            }

            IPageLayoutControl pPageLayoutControl = null;

            if (EditMode == 1)
            {
                if (m_pHookHelper.Hook is IToolbarControl)
                {
                    IToolbarControl pToolBarControl = m_pHookHelper.Hook as IToolbarControl;
                    if (pToolBarControl.Buddy is IPageLayoutControl)
                    {
                        pPageLayoutControl = pToolBarControl.Buddy as IPageLayoutControl;
                    }
                }
                else if (m_pHookHelper.Hook is IPageLayoutControl)
                {
                    pPageLayoutControl = m_pHookHelper.Hook as IPageLayoutControl;
                }
            }
            frmElementProperty frm = new frmElementProperty(EditMode);

            frm.set_PageLayoutControl = pPageLayoutControl;
            frm.StartEditElement(m_pAV, ref pElement);
            frm.ShowDialog();
            frm.Dispose();
        }
Example #24
0
        public static void Addtool(AxMapControl axMapControl, IMapControl3 mapControl, IToolbarControl toolbarControl, IWorkspace workSpace)
        {
            //全局变量赋值
            DataEditCommon.g_tbCtlEdit         = toolbarControl;
            DataEditCommon.g_pMyMapCtrl        = mapControl;
            DataEditCommon.g_pCurrentWorkSpace = workSpace;
            DataEditCommon.g_pAxMapControl     = axMapControl;
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.UndoEdit(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.RedoEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AttributeQueryEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.MeasureDistance(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.MeasureArea(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.FeatureSelect(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.FeatureClearSelect(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.SaveEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);

            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.FixedZoomInCommand(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.FixedZoomOutCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ZoomInTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ZoomOutTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ExtentBackCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ExtentForwardCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.PanTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ZoomToTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.RefreshViewCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.FullExtentTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.MapRotateTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            //Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ToolbarLocalView(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.LocalView(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ClearView(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);

            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.RotateTool(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.FeatureMoveEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.MirrorFeature(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.EditCopyCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.EditCutCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.EditPasteCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.DeleteFeature(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.ExtendTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.TrimLineTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);


            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.LayersList(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.AddPoint(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddStraightFeatureLine(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.AddFeatureLine(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddBezierCurve(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddRectangle(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddText(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddCircle(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddArc(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddEllipse(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.AddPolygon(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
        }
Example #25
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            try
            {
                pt = ((m_hookHelper.ActiveView.ScreenDisplay).DisplayTransformation).ToMapPoint(X, Y);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            bool ddd = snapEnvironment.SnapPoint(pt);

            if (pMPfeedback != null)
            {
                pMPfeedback.Stop();
            }
            pMPfeedback = null;

            bool hasCut         = false;
            ISet newFeaturesSet = null;

            try
            {
                IFeatureSelection featureSelection = m_editLayer.TargetLayer as IFeatureSelection;
                ISelectionSet     selectionSet     = featureSelection.SelectionSet;
                IEnumIDs          enumIDs          = selectionSet.IDs;
                int iD = enumIDs.Next();
                while (iD != -1) //-1 is reutned after the last valid ID has been reached
                {
                    m_engineEditor.StartOperation();
                    IFeatureClass featureClass = m_editLayer.TargetLayer.FeatureClass;
                    IFeature      feature      = featureClass.GetFeature(iD);
                    // 判断点是否在线上,不是则跳过
                    ITopologicalOperator pto       = feature.Shape as ITopologicalOperator;
                    IGeometry            pgeometry = pto.Intersect(pt, esriGeometryDimension.esriGeometry0Dimension);
                    if (pgeometry.IsEmpty == true)
                    {
                        iD = enumIDs.Next();
                        continue;
                    }
                    IFeatureEdit featureedit = feature as IFeatureEdit;
                    /*ISet*/
                    newFeaturesSet = featureedit.Split(pgeometry);
                    if (newFeaturesSet != null)
                    {
                        newFeaturesSet.Reset();
                        hasCut = true;
                        break;
                    }
                    iD = enumIDs.Next();
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            if (hasCut)
            {
                //如果操作成功,选中切割的两条线
                //IFeatureSelection featureSelection = m_editLayer.TargetLayer as IFeatureSelection;
                //ISelectionSet selectionSet = featureSelection.SelectionSet;
                //for (int i = 0; i < newFeaturesSet.Count; i++)
                //{
                //    selectionSet.Add(((IFeature)newFeaturesSet.Next()).OID);
                //}
                //selectionSet.Refresh();

                //Refresh the display including modified layer and any previously selected component.
                IActiveView activeView = m_engineEditor.Map as IActiveView;
                activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography | esriViewDrawPhase.esriViewGeoSelection, null, activeView.Extent);
                activeView.Refresh();
                //Complete the edit operation.
                m_engineEditor.StopOperation("Split a line");
                // 将当前工具设置为选择工具
                IToolbarControl toolbarctl = m_hookHelper.Hook as IToolbarControl;
                //ICommand com = new ControlsEditingEditToolClass();
                //com.OnCreate(m_mapControl.Object);
                //this.m_mapControl.CurrentTool = com as ITool;
                for (int i = 0; i < toolbarctl.Count; i++)
                {
                    IToolbarItem tbi = toolbarctl.GetItem(i);
                    if (tbi.Command != null && tbi.Command.Name.Equals("ControlToolsEditing_Edit"))
                    {
                        tbi.Command.OnClick();// = true;
                        toolbarctl.CurrentTool = tbi.Command as ITool;
                        IToolbarBuddy toolbarbuddy = (IToolbarBuddy)((IToolbarControl)m_hookHelper.Hook).Buddy;
                        break;
                    }
                }
                //  操作成功后将当前工具置为以前的工具
                //IToolbarBuddy toolbarbuddy = (IToolbarBuddy)((IToolbarControl)m_hookHelper.Hook).Buddy;
                //toolbarbuddy.CurrentTool = oldtool;
                //((IToolbarControl)m_hookHelper.Hook).SetBuddyControl(toolbarbuddy);
                this.Deactivate();
            }
            else
            {
                m_engineEditor.AbortOperation();
                MessageBox.Show("切割点不在线上,未能成功切割选择的线段");
                //重新开始选点
                this.OnClick();
            }
            base.OnMouseDown(Button, Shift, X, Y);
        }