예제 #1
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add CmdScaleText.OnClick implementation
            IPageLayoutControl3 pPageLayoutControl = null;

            if (m_hookHelper.Hook is IToolbarControl)
            {
                pPageLayoutControl = (IPageLayoutControl3)((IToolbarControl)m_hookHelper.Hook).Buddy;
            }
            //In case the container is MapControl
            else if (m_hookHelper.Hook is IPageLayoutControl3)
            {
                pPageLayoutControl = (IPageLayoutControl3)m_hookHelper.Hook;
            }
            else
            {
                MessageBox.Show("当前界面必须是PageLayoutControl界面!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                //调用文字比例尺窗口
                LibCerMap.FrmScale pFrmScaleText = new LibCerMap.FrmScale(m_hookHelper, esriSymbologyStyleClass.esriStyleClassScaleTexts);
                pFrmScaleText.ShowDialog();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
 /// <summary>
 /// class constructor
 /// </summary>
 /// <param name="mapControl"></param>
 /// <param name="pageLayoutControl"></param>
 public ControlsSynchronizer(IMapControl3 mapControl, IPageLayoutControl3 pageLayoutControl)
     : this()
 {
     //assign the class members
     this.mapControl        = mapControl;
     this.pageLayoutControl = pageLayoutControl;
 }
예제 #3
0
 public FrmVertor(IPageLayoutControl3 pagelayoutcontrol, ISceneControl scenecontrol)
 {
     InitializeComponent();
     this.EnableGlass   = false;
     pPageLayoutControl = pagelayoutcontrol;
     pSceneControl      = scenecontrol;
 }
예제 #4
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add CmdNorthArrow.OnClick implementation
            IPageLayoutControl3 pPageLayoutControl = null;

            if (m_hookHelper.Hook is IToolbarControl)
            {
                pPageLayoutControl = (IPageLayoutControl3)((IToolbarControl)m_hookHelper.Hook).Buddy;
            }
            //In case the container is MapControl
            else if (m_hookHelper.Hook is IPageLayoutControl3)
            {
                pPageLayoutControl = (IPageLayoutControl3)m_hookHelper.Hook;
            }
            else
            {
                MessageBox.Show("Active control must be PageLayoutControl!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                CreateNorhtArrow();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #5
0
        public static IMap GetFocusMap(IHookHelper hookHelper)
        {
            IMap map = null;

            if (hookHelper.Hook is IToolbarControl)
            {
                object obj = ((IToolbarControl)hookHelper.Hook).Buddy;
                if (obj is IMapControl3)
                {
                    IMapControl3 mapCtrl = obj as IMapControl3;
                    map = mapCtrl.Map;
                }
                else if (obj is IPageLayoutControl3)
                {
                    IPageLayoutControl3 pageCtl = obj as IPageLayoutControl3;
                    map = pageCtl.ActiveView.FocusMap;
                }
            }
            else if (hookHelper.Hook is IMapControl3)
            {
                IMapControl3 mapCtrl = hookHelper.Hook as IMapControl3;
                map = mapCtrl.Map;
            }
            else if (hookHelper.Hook is IPageLayoutControl3)
            {
                IPageLayoutControl3 pageCtl = hookHelper.Hook as IPageLayoutControl3;
                map = pageCtl.ActiveView.FocusMap;
            }
            return(map);
        }
예제 #6
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);
        }
예제 #7
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            IPageLayoutControl3 pPageLayoutControl = null;

            if (m_hookHelper.Hook is IToolbarControl)
            {
                pPageLayoutControl = (IPageLayoutControl3)((IToolbarControl)m_hookHelper.Hook).Buddy;
            }
            //In case the container is MapControl
            else if (m_hookHelper.Hook is IPageLayoutControl3)
            {
                pPageLayoutControl = (IPageLayoutControl3)m_hookHelper.Hook;
            }
            else
            {
                MessageBox.Show("µ±Ç°½çÃæ±ØÐëÊÇPageLayoutControl½çÃæ!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            SaveFileDialog dlgFile = new SaveFileDialog();//ÒÔ¶Ô»°¿òÑ¡ÔñÎĵµÂ·¾¶

            dlgFile.Title  = "Áí´æµØͼÎĵµ";
            dlgFile.Filter = "Map Documents(*.mxd)|*.mxd";
            string sFilePath = string.Empty;

            if (dlgFile.ShowDialog() == DialogResult.OK)
            {
                sFilePath = dlgFile.FileName;
                ClsGDBDataCommon cls = new ClsGDBDataCommon();
                m_pDoc = cls.SaveAsDocument(pPageLayoutControl, sFilePath);
            }
        }
예제 #8
0
        public static ILayer GetSelectedLayer(IHookHelper hookHelper)
        {
            ILayer pLayer = null;

            if (hookHelper.Hook is IToolbarControl)
            {
                object obj = ((IToolbarControl)hookHelper.Hook).Buddy;
                if (obj is IMapControl3)
                {
                    IMapControl3 mapCtrl = obj as IMapControl3;
                    pLayer = mapCtrl.CustomProperty as ILayer;
                }
                else if (obj is IPageLayoutControl3)
                {
                    IPageLayoutControl3 pageCtl = obj as IPageLayoutControl3;
                    pLayer = pageCtl.CustomProperty as ILayer;
                }
            }
            else if (hookHelper.Hook is IMapControl3)
            {
                IMapControl3 mapCtrl = hookHelper.Hook as IMapControl3;
                pLayer = mapCtrl.CustomProperty as ILayer;
            }
            else if (hookHelper.Hook is IPageLayoutControl3)
            {
                IPageLayoutControl3 pageCtl = hookHelper.Hook as IPageLayoutControl3;
                pLayer = pageCtl.CustomProperty as ILayer;
            }
            return(pLayer);
        }
예제 #9
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;
                }
            }
            catch
            {
                m_hookHelper = null;
            }

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

            pPageLayoutControl = m_hookHelper.Hook as IPageLayoutControl3;
        }
예제 #10
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;
                }
            }
            catch
            {
                m_hookHelper = null;
            }

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

            pPageLayoutControl = m_hookHelper.Hook as IPageLayoutControl3;
            IPageLayout pPageLayout = pPageLayoutControl.PageLayout;
            // TODO:  Add other initialization code
        }
예제 #11
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add CmdLegend.OnClick implementation
            IPageLayoutControl3 pPageLayoutControl = null;

            if (m_hookHelper.Hook is IToolbarControl)
            {
                pPageLayoutControl = (IPageLayoutControl3)((IToolbarControl)m_hookHelper.Hook).Buddy;
            }
            //In case the container is MapControl
            else if (m_hookHelper.Hook is IPageLayoutControl3)
            {
                pPageLayoutControl = (IPageLayoutControl3)m_hookHelper.Hook;
            }
            else
            {
                MessageBox.Show("当前界面必须是PageLayoutControl界面!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                LibCerMap.FrmLegend FrmLegends = new LibCerMap.FrmLegend(SymbolStyle, m_hookHelper);
                FrmLegends.ShowDialog();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #12
0
        /// <summary>
        /// bind the MapControl and PageLayoutControl together by assigning a new joint focus map
        /// </summary>
        /// <param name="inMapControl"></param>
        /// <param name="inPageLayoutControl"></param>
        /// <param name="activateMapFirst">true if the MapControl supposed to be activated first</param>
        public void BindControls(IMapControl3 inMapControl, IPageLayoutControl3 inPageLayoutControl, bool activateMapFirst)
        {
            if (inMapControl == null || inPageLayoutControl == null)
            {
                throw new Exception("ControlsSynchronizer::BindControls:\r\nEither MapControl or PageLayoutControl are not initialized!");
            }
            mapControl        = MapControl;
            pageLayoutControl = inPageLayoutControl;

            this.BindControls(activateMapFirst);
        }
예제 #13
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //get the MapControl
            m_mapControl = (IMapControl3)axMapControl1.Object;

            //get the PageLayoutControl
            m_pageLayoutControl = (IPageLayoutControl3)axPageLayoutControl1.Object;

            //disable the Save menu (since there is no document yet)
            menuSaveDoc.Enabled = false;
        }
예제 #14
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //get the MapControl
            m_mapControl        = (IMapControl3)axMapControl1.Object;
            m_pageLayoutControl = (IPageLayoutControl3)axPageLayoutControl1.Object;

            //disable the Save menu (since there is no document yet)
            menuSaveDoc.Enabled = false;

            Setup();
            axPageLayoutControl1.OnMouseMove += new IPageLayoutControlEvents_Ax_OnMouseMoveEventHandler(axPageLayoutControl1_OnMouseMove);
            axPageLayoutControl1.Visible      = false;
        }
예제 #15
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add CmdPrintMap.OnClick implementation

            if (m_hookHelper.Hook is IToolbarControl)
            {
                pPageLayoutControl = ((IToolbarControl)m_hookHelper.Hook).Buddy as IPageLayoutControl3;
                if (pPageLayoutControl == null)
                {
                    MessageBox.Show("当前界面必须是PageLayoutControl界面!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }
            //In case the container is MapControl
            else if (m_hookHelper.Hook is IPageLayoutControl3)
            {
                pPageLayoutControl = (IPageLayoutControl3)m_hookHelper.Hook;
            }
            else
            {
                MessageBox.Show("当前界面必须是PageLayoutControl界面!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                //打印开始
                //allow the user to choose the page range to be printed
                pPrintDialog.AllowSomePages = true;
                //show the help button.
                pPrintDialog.ShowHelp = true;

                //set the Document property to the PrintDocument for which the PrintPage Event
                //has been handled. To display the dialog, either this property or the
                //PrinterSettings property must be set
                pPrintDialog.Document = pPrintDocument;

                //show the print dialog and wait for user input
                DialogResult result = pPrintDialog.ShowDialog();

                // If the result is OK then print the document.
                if (result == DialogResult.OK)
                {
                    pPrintDocument.Print();
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #16
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //get the MapControl
            m_mapControl        = (IMapControl3)axMapControl1.Object;
            m_pageLayoutControl = (IPageLayoutControl3)axPageLayoutControl1.Object;

            menuSaveDoc.Enabled = false;

            basicToolbarControl.AddItem(new CreateNewDocument(), 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //TOCControl图层右键菜单
            m_TocLayerMenu.AddItem(new OpenAttributeTableCmd(), 0, 0, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocLayerMenu.AddItem(new RemoveLayerCmd(), 0, 1, false, esriCommandStyles.esriCommandStyleIconAndText);

            m_TocLayerMenu.AddItem(new ScaleThreSholds(), 1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_TocLayerMenu.AddItem(new ScaleThreSholds(), 2, 3, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_TocLayerMenu.AddItem(new ScaleThreSholds(), 3, 4, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_TocLayerMenu.AddItem(new LayerSelectable(), 1, 5, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_TocLayerMenu.AddItem(new LayerSelectable(), 2, 6, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_TocLayerMenu.AddItem(new ZoomToLayerCmd(), 0, 7, true, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocLayerMenu.AddItem(new LayerPropertiesCmd(), 0, 8, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocLayerMenu.SetHook(axMapControl1);

            //TOCControlMap右键菜单
            m_TocMapMenu.AddItem(new ControlsAddDataCommandClass(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocMapMenu.AddItem(new TurnAllLayersOnCmd(), 0, -1, true, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocMapMenu.AddItem(new TurnAllLayersOffCmd(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocMapMenu.AddItem(new SetReferenceScaleCmd(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocMapMenu.AddItem(new ClearReferenceScaleCmd(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocMapMenu.AddItem(new ZoomToReferenceScaleCmd(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocMapMenu.SetHook(axMapControl1);

            //axMapControl控件中右键菜单
            m_toolbarMenu.AddItem(new ClearCurrentTool(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_toolbarMenu.AddItem(new ClearFeatureSelection(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_toolbarMenu.AddItem(new ZoomIn3X(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_toolbarMenu.AddItem(new Refresh(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            // m_toolbarMenu.AddItem("esriControls.ControlsEditingSketchContextMenu", 0, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_toolbarMenu.SetHook(axMapControl1);

            //axPageLayoutControl右键菜单
            m_toolbarMenu2.AddItem(new ClearCurrentTool(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_toolbarMenu2.SetHook(m_pageLayoutControl);

            CreateCustomizeDialog();

            SetupNetworkAnalysis();
        }
예제 #17
0
파일: MainForm.cs 프로젝트: lidan233/C---
        private void MainForm_Load(object sender, EventArgs e)
        {
            //get the MapControl
            m_mapControl = (IMapControl3)axMapControl1.Object;

            m_PageLayControl = (IPageLayoutControl3)axPageLayoutControl1.Object;
            //disable the Save menu (since there is no document yet)
            menuSaveDoc.Enabled = false;


            toolStripComboBox1.ComboBox.Items.Clear();
            toolStripComboBox1.ComboBox.Items.Add("");
            toolStripComboBox1.ComboBox.Items.Add("Legend");
            toolStripComboBox1.ComboBox.Items.Add("MarkerNorthArrow");
            toolStripComboBox1.ComboBox.Items.Add("ScaleLine");
            toolStripComboBox1.ComboBox.Items.Add("ScaleText");
        }
예제 #18
0
        public static IPageLayoutControl3 GetPageLayoutControl(IHookHelper hookHelper)
        {
            IPageLayoutControl3 pageCtrl = null;

            if (hookHelper.Hook is IToolbarControl)
            {
                object obj = ((IToolbarControl)hookHelper.Hook).Buddy;
                if (obj is IPageLayoutControl3)
                {
                    pageCtrl = obj as IPageLayoutControl3;
                }
            }
            else if (hookHelper.Hook is IPageLayoutControl3)
            {
                pageCtrl = hookHelper.Hook as IPageLayoutControl3;
            }
            return(pageCtrl);
        }
예제 #19
0
        private void FrmExportActiveViewFig_Load(object sender, EventArgs e)
        {
            //设置缺少的文件名和路径
            IPageLayoutControl3 pPageLayoutControl = null;

            if (m_HookHelper != null)
            {
                if (m_HookHelper.Hook is IToolbarControl)
                {
                    if (((IToolbarControl)m_HookHelper.Hook).Buddy is IPageLayoutControl3)
                    {
                        pPageLayoutControl = (IPageLayoutControl3)((IToolbarControl)m_HookHelper.Hook).Buddy;
                    }
                }
                else if (m_HookHelper.Hook is IPageLayoutControl3)
                {
                    pPageLayoutControl = m_HookHelper.Hook as IPageLayoutControl3;
                }
            }
            else
            {
                pPageLayoutControl = pSceneControl as IPageLayoutControl3;
            }

            if (pPageLayoutControl != null)
            {
                string strDocName = pPageLayoutControl.DocumentFilename;
                if (strDocName == null)
                {
                    this.txtImagePath.Text = System.IO.Path.GetPathRoot(Application.StartupPath) + "CEMapping.jpg";
                }
                else
                {
                    this.txtImagePath.Text = System.IO.Path.GetDirectoryName(strDocName) + "\\" + System.IO.Path.GetFileNameWithoutExtension(strDocName) + ".jpg";
                }
            }
            else
            {
                this.txtImagePath.Text = System.IO.Path.GetPathRoot(Application.StartupPath) + "CEMapping.jpg";
            }
        }
예제 #20
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add CmdPrintPreview.OnClick implementation

            if (m_hookHelper.Hook is IToolbarControl)
            {
                pPageLayoutControl = (IPageLayoutControl3)((IToolbarControl)m_hookHelper.Hook).Buddy;
            }
            //In case the container is MapControl
            else if (m_hookHelper.Hook is IPageLayoutControl3)
            {
                pPageLayoutControl = (IPageLayoutControl3)m_hookHelper.Hook;
            }
            else
            {
                MessageBox.Show("µ±Ç°½çÃæ±ØÐëÊÇPageLayoutControl½çÃæ!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            //pPageLayoutControl.ActiveView.Refresh();

            ////´òÓ¡Ô¤ÀÀÉèÖÃ
            //InitializePrintPreviewDialog(); //initialize the print preview dialog
            //printDialog1 = new PrintDialog(); //create a print dialog object
            //InitializePageSetupDialog(); //initialize the page setup dialog

            //initialize the currently printed page number
            m_CurrentPrintPage = 0;

            //check if a document is loaded into PageLayout	control
            //if (pPageLayoutControl.DocumentFilename == null) return;
            //set the name of the print preview document to the name of the mxd doc
            document.DocumentName = pPageLayoutControl.DocumentFilename;

            //set the PrintPreviewDialog.Document property to the PrintDocument object selected by the user
            printPreviewDialog1.Document = document;

            //show the dialog - this triggers the document's PrintPage event
            printPreviewDialog1.ShowDialog();
        }
예제 #21
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //get the MapControl
            m_mapControl = (IMapControl3)axMapControl1.Object;
            //disable the Save menu (since there is no document yet)
            menuSaveDoc.Enabled = false;
            m_pageLayoutControl = (IPageLayoutControl3)axPageLayoutControl1.Object;
            //Initialize controls synchronization calss
            m_controlsSynchronizer = new ControlsSynchronizer(m_mapControl, m_pageLayoutControl);
            //Bind MapControl and PageLayoutControl(Point to the same Map), Set MapControl as the active Control
            m_controlsSynchronizer.BindControls(true);
            //In order to switch MapControl and PageLayoutControl, we need to add Framework Control
            m_controlsSynchronizer.AddFrameworkControl(axToolbarControl1.Object);
            m_controlsSynchronizer.AddFrameworkControl(this.axTOCControl1.Object);
            IHookHelper hookHelper = new HookHelperClass();

            //hookHelper.Hook = axMapControl1.Object;
            hookHelper.Hook = m_controlsSynchronizer.MapControl.Object;
            poverView       = new EagleEyes(hookHelper);
            OpenNewMapDocument openMapDoc = new OpenNewMapDocument(m_controlsSynchronizer);

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


            m_TocLayerMenu.AddItem(new OpenAttributeTableCmd(), 0, 0, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocLayerMenu.AddItem(new RemoveLayerCmd(), 0, 1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocLayerMenu.SetHook(axMapControl1);

            m_TocMapMenu.AddItem(new ControlsAddDataCommandClass(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocMapMenu.AddItem(new TurnAllLayersOnCmd(), 0, -1, true, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocMapMenu.AddItem(new TurnAllLayersOffCmd(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_TocMapMenu.SetHook(axMapControl1);

            m_toolbarMenu.AddItem(new ClearCurrentTool(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_toolbarMenu.AddItem(new ClearFeatureSelection(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_toolbarMenu.AddItem(new Refresh(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_toolbarMenu.SetHook(axMapControl1);
        }
예제 #22
0
 public LayoutAddGrid(IPageLayoutControl3 m_PageLayControl1)
 {
     //
     // TODO: Define values for the public properties
     //
     base.m_category  = "";                                                        //localizable text
     base.m_caption   = "";                                                        //localizable text
     base.m_message   = "This should work in ArcMap/MapControl/PageLayoutControl"; //localizable text
     base.m_toolTip   = "";                                                        //localizable text
     base.m_name      = "";                                                        //unique id, non-localizable (e.g. "MyCategory_MyCommand")
     m_PageLayControl = m_PageLayControl1;
     try
     {
         //
         // TODO: change bitmap name if necessary
         //
         string bitmapResourceName = GetType().Name + ".bmp";
         base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
     }
 }
예제 #23
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            IPageLayoutControl3 pPageLayoutControl = null;

            if (m_hookHelper.Hook is IToolbarControl)
            {
                pPageLayoutControl = (IPageLayoutControl3)((IToolbarControl)m_hookHelper.Hook).Buddy;
            }
            //In case the container is MapControl
            else if (m_hookHelper.Hook is IPageLayoutControl3)
            {
                pPageLayoutControl = (IPageLayoutControl3)m_hookHelper.Hook;
            }
            else
            {
                MessageBox.Show("当前界面必须是PageLayoutControl界面!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                string strDocName = pPageLayoutControl.DocumentFilename;
                if (strDocName != null)
                {
                    if (pPageLayoutControl.CheckMxFile(strDocName))
                    {
                        //create a new instance of a MapDocument
                        IMapDocument mapDoc = new MapDocumentClass();
                        mapDoc.Open(strDocName, string.Empty);

                        //Make sure that the MapDocument is not readonly
                        if (mapDoc.get_IsReadOnly(strDocName))
                        {
                            MessageBox.Show("Map document is read only!");
                            mapDoc.Close();
                            return;
                        }

                        //Replace its contents with the current map
                        mapDoc.ReplaceContents((IMxdContents)pPageLayoutControl.PageLayout);

                        //save the MapDocument in order to persist it
                        mapDoc.Save(true, true);

                        //close the MapDocument
                        mapDoc.Close();
                    }
                }
                else
                {
                    IMapDocument   mDoc    = new MapDocumentClass(); //地图文档对象
                    SaveFileDialog dlgFile = new SaveFileDialog();   //以对话框选择文档路径
                    string         sFilePath;
                    dlgFile.Title  = "另存地图文档";
                    dlgFile.Filter = "Map Documents(*.mxd)|*.mxd";
                    if (dlgFile.ShowDialog() == DialogResult.OK)
                    {
                        sFilePath = dlgFile.FileName;
                        mDoc.New(sFilePath);
                        mDoc.ReplaceContents((IMxdContents)pPageLayoutControl.PageLayout);
                        mDoc.Save(true, true);
                        pPageLayoutControl.DocumentFilename = sFilePath;
                        mDoc.Close();
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #24
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add CmdPageSetup.OnClick implementation

            IPageLayoutControl3 pPageLayoutControl = null;

            if (m_hookHelper.Hook is IToolbarControl)
            {
                pPageLayoutControl = (IPageLayoutControl3)((IToolbarControl)m_hookHelper.Hook).Buddy;
            }
            //In case the container is MapControl
            else if (m_hookHelper.Hook is IPageLayoutControl3)
            {
                pPageLayoutControl = (IPageLayoutControl3)m_hookHelper.Hook;
            }
            else
            {
                MessageBox.Show("当前界面必须是PageLayoutControl界面!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            FrmPageSetup frmPage = new FrmPageSetup(pPageLayoutControl);

            if (frmPage.ShowDialog() == DialogResult.OK)
            {
                return;
            }

            #region

            //try
            //{
            //    //开始页面设置调用
            //    DialogResult result = pPageSetupDialog.ShowDialog();
            //    if (result == DialogResult.OK)
            //    {
            //        //set the printer settings of the preview document to the selected printer settings
            //        document.PrinterSettings = pPageSetupDialog.PrinterSettings;
            //        //set the page settings of the preview document to the selected page settings
            //        document.DefaultPageSettings = pPageSetupDialog.PageSettings;

            //        //due to a bug in PageSetupDialog the PaperSize has to be set explicitly by iterating through the
            //        //available PaperSizes in the PageSetupDialog finding the selected PaperSize
            //        int i;
            //        IEnumerator paperSizes = pPageSetupDialog.PrinterSettings.PaperSizes.GetEnumerator();
            //        paperSizes.Reset();
            //        for (i = 0; i < pPageSetupDialog.PrinterSettings.PaperSizes.Count; ++i)
            //        {
            //            paperSizes.MoveNext();
            //            if (((PaperSize)paperSizes.Current).Kind == document.DefaultPageSettings.PaperSize.Kind)
            //                if (((PaperSize)paperSizes.Current).PaperName == document.DefaultPageSettings.PaperSize.PaperName)
            //            {
            //                document.DefaultPageSettings.PaperSize = ((PaperSize)paperSizes.Current);
            //            }
            //        }

            //        IPaper paper = new PaperClass(); //create a paper object
            //        IPrinter printer = new EmfPrinterClass(); //create a printer object
            //        paper.Attach(pPageSetupDialog.PrinterSettings.GetHdevmode(pPageSetupDialog.PageSettings).ToInt32(), pPageSetupDialog.PrinterSettings.GetHdevnames().ToInt32());

            //        //pass the paper to the emf printer
            //        printer.Paper = paper;
            //        //set the page layout control's printer to the currently selected printer
            //        pPageLayoutControl.Printer = printer;
            //        //pPageLayoutControl.PageLayout.Page
            //        pPageLayoutControl.ActiveView.Refresh();
            //    }
            //}
            //catch (System.Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}
            #endregion
        }
예제 #25
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add CmdAddText.OnClick implementation
            IPageLayoutControl3 pPageLayoutControl = ClsGlobal.GetPageLayoutControl(m_hookHelper);

            if (pPageLayoutControl == null)
            {
                return;
            }
            //if (m_hookHelper.Hook is IToolbarControl)
            //{
            //    if (((IToolbarControl)m_hookHelper.Hook).Buddy is IPageLayoutControl3)
            //    {
            //        pPageLayoutControl = (IPageLayoutControl3)((IToolbarControl)m_hookHelper.Hook).Buddy;
            //    }

            //}
            ////In case the container is MapControl
            //else if (m_hookHelper.Hook is IPageLayoutControl3)
            //{
            //    pPageLayoutControl = (IPageLayoutControl3)m_hookHelper.Hook;
            //}
            //else
            //{
            //    MessageBox.Show("当前界面必须是PageLayoutControl界面!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //    return;
            //}

            try
            {
                ITextElement pTextElement = new TextElementClass();
                IElement     pElement     = (IElement)pTextElement;

                //添加文本
                pTextElement.Text      = "Text";
                pTextElement.ScaleText = false;

                ITextSymbol pTextSymbol = pTextElement.Symbol;
                pTextSymbol.Size    = 48;
                pTextElement.Symbol = pTextSymbol;

                IGraphicsContainer pGraphicContainer = m_hookHelper.ActiveView.GraphicsContainer;
                IActiveView        pActiveView       = m_hookHelper.ActiveView;
                IPageLayout        pPageLayout       = (IPageLayout)pActiveView;
                IPage pPage = pPageLayout.Page;

                IEnvelope pPrintPageEnvolope = pPage.PrintableBounds;
                double    dbCenterX          = (pPrintPageEnvolope.XMax + pPrintPageEnvolope.XMin) / 2;
                double    dbCenterY          = (pPrintPageEnvolope.YMax + pPrintPageEnvolope.YMin) / 2;
                double    pWidth             = 20;
                double    pHeigth            = 20;
                double    dbXmin             = dbCenterX - pWidth / 2;
                double    dbYmin             = dbCenterY - pHeigth / 2;
                double    dbXmax             = dbCenterX + pWidth / 2;
                double    dbYmax             = dbCenterY + pHeigth / 2;

                IEnvelope pEnvelope = new EnvelopeClass();
                pEnvelope.PutCoords(dbXmin, dbYmin, dbXmax, dbYmax);
                pElement.Geometry = pEnvelope as IGeometry;
                pGraphicContainer.AddElement(pElement, 0);

                //刷新
                m_hookHelper.ActiveView.Refresh();

                //LibCerMap.FrmAddText FrmAddtext = new LibCerMap.FrmAddText(null);
                //if (FrmAddtext.ShowDialog() == DialogResult.OK)
                //{

                //}
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #26
0
파일: Menu.cs 프로젝트: AgentWord/SiPing
 public override void OnCreate(object hook)
 {
     p_PageLayoutControl = (IPageLayoutControl3)hook;
 }
예제 #27
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;
                }
            }
            catch
            {
                m_hookHelper = null;
            }

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

              pPageLayoutControl = m_hookHelper.Hook as IPageLayoutControl3;
        }
예제 #28
0
 public FrmExportMxd(IPageLayoutControl3 pageCtl)
 {
     InitializeComponent();
     m_pPageLayoutCtl = pageCtl;
 }
예제 #29
0
 public FrmPageSetup(IPageLayoutControl3 pageCtl)
 {
     InitializeComponent();
     m_pPageLayoutCtl = pageCtl;
 }
예제 #30
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add CmdPictureElement.OnClick implementation
            IPageLayoutControl3 pPageLayoutControl = null;

            if (m_hookHelper.Hook is IToolbarControl)
            {
                if (((IToolbarControl)m_hookHelper.Hook).Buddy is IPageLayoutControl3)
                {
                    pPageLayoutControl = (IPageLayoutControl3)((IToolbarControl)m_hookHelper.Hook).Buddy;
                }
            }
            //In case the container is MapControl
            else if (m_hookHelper.Hook is IPageLayoutControl3)
            {
                pPageLayoutControl = (IPageLayoutControl3)m_hookHelper.Hook;
            }

            try
            {
                OpenFileDialog ODialog = new OpenFileDialog();
                ODialog.Title            = "ÇëÑ¡ÔñͼƬ";
                ODialog.Filter           = "bmpͼƬ|*.bmp|pngͼƬ|*.png|JPEGͼƬ|*.jpg";
                ODialog.RestoreDirectory = true;
                if (ODialog.ShowDialog() == DialogResult.OK)
                {
                    string picturePath = ODialog.FileName;
                    if (System.IO.Path.GetFileName(picturePath).Contains(".bmp") || System.IO.Path.GetFileName(picturePath).Contains(".BMP"))
                    {
                        pPictureElement = new BmpPictureElementClass();
                    }
                    else if (System.IO.Path.GetFileName(picturePath).Contains(".png") || System.IO.Path.GetFileName(picturePath).Contains(".PNG"))
                    {
                        pPictureElement = new PngPictureElementClass();
                    }
                    else if (System.IO.Path.GetFileName(picturePath).Contains(".jpg") || System.IO.Path.GetFileName(picturePath).Contains(".JPG"))
                    {
                        pPictureElement = new JpgPictureElementClass();
                    }
                    pPictureElement.ImportPictureFromFile(picturePath);
                    pPictureElement.SavePictureInDocument = true;

                    IGraphicsContainer pGraphicContainer = m_hookHelper.ActiveView.GraphicsContainer;
                    IActiveView        pActiveView       = m_hookHelper.ActiveView;
                    IPageLayout        pPageLayout       = (IPageLayout)pActiveView;
                    IPage pPage = pPageLayout.Page;

                    IRasterLayer pRLayer = new RasterLayerClass();
                    pRLayer.CreateFromFilePath(picturePath);
                    double pictureX = pRLayer.ColumnCount;
                    double pictureY = pRLayer.RowCount;

                    IEnvelope pPrintPageEnvolope = pPage.PrintableBounds;
                    double    dbCenterX          = (pPrintPageEnvolope.XMax + pPrintPageEnvolope.XMin) / 2;
                    double    dbCenterY          = (pPrintPageEnvolope.YMax + pPrintPageEnvolope.YMin) / 2;
                    double    pWidth             = 5;
                    double    pHeigth            = 5 * (pictureY / pictureX);
                    double    dbXmin             = dbCenterX - pWidth / 2;
                    double    dbYmin             = dbCenterY - pHeigth / 2;
                    double    dbXmax             = dbCenterX + pWidth / 2;
                    double    dbYmax             = dbCenterY + pHeigth / 2;

                    IElement  pElement  = (IElement)pPictureElement;
                    IEnvelope pEnvelope = new EnvelopeClass();
                    pEnvelope.PutCoords(dbXmin, dbYmin, dbXmax, dbYmax);
                    pElement.Geometry = pEnvelope as IGeometry;
                    pGraphicContainer.AddElement(pElement, 0);

                    m_hookHelper.ActiveView.Refresh();
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #31
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;
                }
            }
            catch
            {
                m_hookHelper = null;
            }

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

            pPageLayoutControl = m_hookHelper.Hook as IPageLayoutControl3;
            IPageLayout pPageLayout = pPageLayoutControl.PageLayout;
            // TODO:  Add other initialization code
        }
예제 #32
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            IPageLayoutControl3 pPageLayoutControl = null;

            try
            {
                if (m_hookHelper.Hook is IToolbarControl)
                {
                    pPageLayoutControl = (IPageLayoutControl3)((IToolbarControl)m_hookHelper.Hook).Buddy;
                }
                //In case the container is MapControl
                else if (m_hookHelper.Hook is IPageLayoutControl3)
                {
                    pPageLayoutControl = (IPageLayoutControl3)m_hookHelper.Hook;
                }
                else
                {
                    MessageBox.Show("当前界面必须是PageLayoutControl界面!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            try
            {
                if (string.IsNullOrEmpty(m_strDocName))
                {
                    OpenFileDialog dlgFile = new OpenFileDialog();//以对话框选择文档路径
                    dlgFile.Title  = "打开一个地图文档";
                    dlgFile.Filter = "Map Documents(*.mxd)|*.mxd";
                    if (dlgFile.ShowDialog() == DialogResult.OK)
                    {
                        m_strDocName = dlgFile.FileName;
                    }
                }
                IMapDocument mapDoc = new MapDocumentClass(); //地图文档对象
                IMap         map    = null;
                if (mapDoc.get_IsPresent(m_strDocName) && !mapDoc.get_IsPasswordProtected(m_strDocName))
                {
                    mapDoc.Open(m_strDocName, string.Empty);

                    IMaps maps = new Maps();
                    for (int i = 0; i < mapDoc.MapCount; i++)
                    {
                        maps.Add(mapDoc.get_Map(i));
                    }
                    // set the first map as the active view
                    map = mapDoc.get_Map(0);
                    mapDoc.SetActiveView((IActiveView)map);

                    m_controlsSynchronizer.PageLayoutControl.PageLayout       = mapDoc.PageLayout;
                    m_controlsSynchronizer.PageLayoutControl.Printer          = mapDoc.Printer;
                    m_controlsSynchronizer.PageLayoutControl.DocumentFilename = m_strDocName;
                    //m_controlsSynchronizer.ReplaceMap(map);
                    m_controlsSynchronizer.AddNewMaps(maps);

                    mapDoc.Close();

                    m_strDocName = string.Empty;
                }

                /////////////////////////////
                //关闭属性表
                if (m_barTable.Visible == true)
                {
                    if (m_AttributeRemove != null)
                    {
                        m_AttributeRemove.Clear();
                        m_AttributeRemove.Columns.Clear();
                        m_barTable.Visible = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "打开地图文档失败");
            }
        }