예제 #1
0
        public static void AddData(AxPageLayoutControl pageLayoutControl)
        {
            ControlsAddDataCommand addDataCmd = new ControlsAddDataCommandClass();

            addDataCmd.OnCreate(pageLayoutControl.Object);
            addDataCmd.OnClick();
        }
예제 #2
0
        /// <summary>
        /// 地图及其图层/表格树、鹰眼图、导航工具、页面布局视图的组合控件的管理类
        /// </summary>
        /// <param name="mainMapControl">主地图控件</param>
        /// <param name="eagleMapControl">鹰眼图地图控件</param>
        /// <param name="tocControl">图层树控件</param>
        /// <param name="pageLayoutControl">页面布局控件</param>
        /// <param name="switchView">显示指定的界面视图的操作</param>
        public MapViewerManager(AxMapControl mainMapControl, AxMapControl eagleMapControl,
                                AxTOCControl tocControl, AxPageLayoutControl pageLayoutControl, Action <EViewActionType[]> switchView)
        {
            SwitchView        = switchView;
            MainMapControl    = mainMapControl;
            DocHelper         = new MapCtrlDocument(mainMapControl);
            TocHelper         = new MapCtrlToc(tocControl, mainMapControl, new AttributeForm(), switchView);
            MenuHelper        = new MapCtrlMenu(mainMapControl);
            EagleMapHelper    = new MapCtrlEagleMap(mainMapControl, eagleMapControl);
            DrawElementHelper = new MapCtrlDrawElement(mainMapControl);
            PageLayoutHelper  = new MapCtrlPageLayoutSyn(mainMapControl, pageLayoutControl);

            mainMapControl.OnFullExtentUpdated += delegate { mainMapControl.Refresh(); }; //主地图:刷新地图
            ((IActiveViewEvents_Event)mainMapControl.Map).ItemAdded += item =>            //向map/PageLayout中添加数据(图层、表格等)都会触发ItemAdded事件
            {
                if (item is ILayer)
                {
                    SwitchView(new[] { EViewActionType.MainMap, EViewActionType.LayerToc });
                }
                else if (item is ITable)
                {
                    SwitchView(new[] { EViewActionType.MainMap, EViewActionType.TableList });
                }
            };
        }
예제 #3
0
        /// <summary>
        /// 清除布局所有要素,除了框架
        /// </summary>
        /// <param name="pageLayoutControl">布局控件</param>
        public static void ClearAllLayoutData(AxPageLayoutControl pageLayoutControl)
        {
            if (pageLayoutControl == null)
            {
                return;
            }
            IGraphicsContainer curGraph = pageLayoutControl.ActiveView as IGraphicsContainer;

            if (curGraph == null)
            {
                return;
            }
            curGraph.Reset();
            IElement pElement = curGraph.Next();

            while (pElement != null)
            {
                //不是MapFrame框架对象,则删除
                if (!(pElement is IMapFrame))
                {
                    curGraph.DeleteElement(pElement);
                    //必须重置,不然会叠加之前的元素
                    curGraph.Reset();
                }

                pElement = curGraph.Next();
            }

            pageLayoutControl.Refresh();
        }
 public ExportPictureMessage(string name, AxPageLayoutControl Layout, Object sender)
 {
     InitializeComponent();
     this.layername  = name;
     this.pagelayout = Layout;
     this.Obj_sender = sender;
 }
예제 #5
0
        /// <summary>
        /// 添加图例
        /// </summary>
        /// <param name="layoutControl">布局视图</param>
        /// <param name="pEnv">矩形框</param>
        /// <param name="pLegend">图例</param>
        public static void AddLegend(AxPageLayoutControl layoutControl, IEnvelope pEnv, ILegend2 pLegend)
        {
            if (pLegend == null)
            {
                return;
            }
            IGraphicsContainer pGraphicsContainer = layoutControl.PageLayout as IGraphicsContainer;

            if (pGraphicsContainer == null)
            {
                return;
            }
            IMap      pMap      = layoutControl.ActiveView.FocusMap;
            IMapFrame pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame;

            if (pMapFrame == null)
            {
                return;
            }
            IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass();

            pMapSurroundFrame.MapFrame = pMapFrame;
            //如果已经存在图例,删除已经存在的图例
            MappingHelper.DeleteElementByName(layoutControl, "Legend");
            pMapSurroundFrame.MapSurround = pLegend as IMapSurround;
            //添加图例
            IElement pElement = pMapSurroundFrame as IElement;

            pElement.Geometry = pEnv;
            //添加元素
            MappingHelper.AddElementWithName(pGraphicsContainer, pElement, "Legend");
        }
예제 #6
0
        public static void AddNorthArrow(AxPageLayoutControl pageLayoutControl, IEnvelope envelope)
        {
            IUID uid = new UIDClass()
            {
                Value = "esriCarto.MarkerNorthArrow"
            };

            IFrameElement frameElement = (pageLayoutControl.PageLayout as IGraphicsContainer)
                                         .FindFrame(pageLayoutControl.ActiveView.FocusMap);
            IMapFrame         mapFrame         = frameElement as IMapFrame;
            IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid as UID, null); // Dynamic Cast
            IElement          element          = mapSurroundFrame as IElement;                   // Dynamic Cast

            element.Geometry = envelope;
            element.Activate(pageLayoutControl.ActiveView.ScreenDisplay);
            (pageLayoutControl.PageLayout as IGraphicsContainer).AddElement(element, 0);
            IMapSurround mapSurround = mapSurroundFrame.MapSurround;

            // Change out the default north arrow
            IMarkerNorthArrow      markerNorthArrow      = mapSurround as IMarkerNorthArrow;       // Dynamic Cast
            IMarkerSymbol          markerSymbol          = markerNorthArrow.MarkerSymbol;
            ICharacterMarkerSymbol characterMarkerSymbol = markerSymbol as ICharacterMarkerSymbol; // Dynamic Cast

            characterMarkerSymbol.CharacterIndex = 202;
            markerNorthArrow.MarkerSymbol        = characterMarkerSymbol;
        }
예제 #7
0
        public static void addScalebar(AxPageLayoutControl axPageLayoutControl, String type)
        {
            IPageLayout        pageLayout         = axPageLayoutControl.PageLayout;
            IActiveView        activeView         = pageLayout as IActiveView;
            IMap               pMap               = activeView.FocusMap;
            IGraphicsContainer pGraphicsContainer = pageLayout as IGraphicsContainer;
            IMapFrame          mapFrame           = (IMapFrame)pGraphicsContainer.FindFrame(pMap);
            UID uid = new UIDClass();

            uid.Value = type;
            IMapSurroundFrame pMapSurroundFrame = mapFrame.CreateSurroundFrame(uid, null);
            IMapSurround      pMapSurround      = pMapSurroundFrame.MapSurround;
            IScaleBar         pScaleBar         = (IScaleBar)pMapSurround;

            pScaleBar.LabelPosition = esriVertPosEnum.esriBelow;
            pScaleBar.UseMapSettings();
            IEnvelope pEnvelope = new EnvelopeClass();

            pEnvelope.PutCoords(0.8, 0.8, 13, 2);
            IElement element = pMapSurroundFrame as IElement;

            element.Geometry = pEnvelope;
            pGraphicsContainer.AddElement(element, 0);
            activeView.Refresh();
        }
예제 #8
0
 //导出地图
 public void ExportMapToImage(AxPageLayoutControl axPageLayoutControl1)
 {
     try
     {
         SaveFileDialog saveFileDialog = new SaveFileDialog();
         saveFileDialog.FileName = "";
         saveFileDialog.Filter   = "JPG图片(*.JPG)|*.jpg|tif图片(*.tif)|*.tif|PDF文档(*.PDF)|*.pdf";
         if (saveFileDialog.ShowDialog() == DialogResult.OK)
         {
             double iScreenDispalyResolution = axPageLayoutControl1.ActiveView.ScreenDisplay.
                                               DisplayTransformation.Resolution;// 获取屏幕分辨率的值
             IExporter exporter = new JpegExporterClass();
             exporter.ExportFileName = saveFileDialog.FileName;
             exporter.Resolution     = (short)iScreenDispalyResolution; //分辨率
             tagRECT   deviceRect     = axPageLayoutControl1.ActiveView.ScreenDisplay.DisplayTransformation.get_DeviceFrame();
             IEnvelope deviceEnvelope = new EnvelopeClass();
             deviceEnvelope.PutCoords(deviceRect.left, deviceRect.bottom, deviceRect.right, deviceRect.top);
             exporter.PixelBounds = deviceEnvelope;           // 输出图片的范围
             ITrackCancel pCancle = new CancelTrackerClass(); //可用ESC键取消操作
             axPageLayoutControl1.ActiveView.Output(exporter.StartExporting(), exporter.Resolution, ref deviceRect,
                                                    axPageLayoutControl1.ActiveView.Extent, pCancle);
             Application.DoEvents();
             exporter.FinishExporting();
         }
     }
     catch (Exception Err)
     {
         MessageBox.Show(Err.Message, "输出图片", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #9
0
        public static void CopyAndOverwriteMap(AxMapControl axMapControl, AxPageLayoutControl axPageLayoutControl)
        {
            IObjectCopy objectCopy   = new ObjectCopyClass();
            object      toCopyMap    = axMapControl.Map;
            object      copiedMap    = objectCopy.Copy(toCopyMap);
            IPageLayout pagelayout   = axPageLayoutControl.PageLayout;
            object      overwriteMap = (pagelayout as IActiveView).FocusMap;

            objectCopy.Overwrite(toCopyMap, ref overwriteMap);
            IGraphicsContainer pGraphicsContainer = pagelayout as IGraphicsContainer;
            IMapFrame          pMapFrame          = (IMapFrame)pGraphicsContainer.FindFrame(overwriteMap);
            IElement           pElement           = pMapFrame as IElement;
            IEnumElement       pEnumElement       = pGraphicsContainer.LocateElementsByEnvelope(pElement.Geometry.Envelope);
            IElement           pElementIcon       = pEnumElement.Next();

            while (pElementIcon != null)
            {
                if (pElementIcon is IMapSurroundFrame)
                {
                    if ((pElementIcon as IMapSurroundFrame).MapSurround is IScaleBar)
                    {
                        (pElementIcon as IMapSurroundFrame).MapFrame = pMapFrame;
                    }
                }
                pElementIcon = pEnumElement.Next();
            }
            axPageLayoutControl.ActiveView.Refresh();
        }
예제 #10
0
        public static void changeOritation(AxPageLayoutControl axPageLayoutControl)
        {
            IPageLayout        pageLayout         = axPageLayoutControl.PageLayout;
            IActiveView        activeView         = pageLayout as IActiveView;
            IMap               pMap               = activeView.FocusMap;
            IGraphicsContainer pGraphicsContainer = pageLayout as IGraphicsContainer;
            IMapFrame          mapFrame           = (IMapFrame)pGraphicsContainer.FindFrame(pMap);
            IElement           pElement           = (IElement)mapFrame;
            IEnvelope          pEnvelope          = new EnvelopeClass();

            if (axPageLayoutControl.Page.Orientation == 2)
            {
                pEnvelope.PutCoords(0.5, 0.5, 20.5, 29.2);
                axPageLayoutControl.Page.PutCustomSize(29.7, 21);
                axPageLayoutControl.Page.Orientation = 1;
            }
            else
            {
                pEnvelope.PutCoords(0.5, 0.5, 29.2, 20.5);
                axPageLayoutControl.Page.PutCustomSize(21, 29.7);
                axPageLayoutControl.Page.Orientation = 2;
            }
            pElement.Geometry = pEnvelope;
            activeView.Refresh();
        }
예제 #11
0
        public static void exportMaptoJPEG(AxPageLayoutControl axPageLayoutControl)
        {
            SaveFileDialog saveDialog = new SaveFileDialog();

            saveDialog.Title    = "保存图像";
            saveDialog.FileName = "output";
            saveDialog.Filter   = "JGP图片(*.jpg)|*.jpg";
            if (saveDialog.ShowDialog() == DialogResult.OK)
            {
                double resolution =
                    axPageLayoutControl.ActiveView.ScreenDisplay.DisplayTransformation.Resolution;
                IExport pExport = new ExportJPEGClass();
                pExport.ExportFileName = saveDialog.FileName;
                pExport.Resolution     = resolution;
                tagRECT deviceRect =
                    axPageLayoutControl.ActiveView.ScreenDisplay.DisplayTransformation.get_DeviceFrame();
                IEnvelope pDeviceEnvelope = new EnvelopeClass();
                pDeviceEnvelope.PutCoords(deviceRect.left, deviceRect.bottom,
                                          deviceRect.right, deviceRect.top);
                pExport.PixelBounds = pDeviceEnvelope;

                axPageLayoutControl.ActiveView.Output(pExport.StartExporting(), (int)pExport.Resolution,
                                                      ref deviceRect, axPageLayoutControl.ActiveView.Extent, new CancelTrackerClass());
                Application.DoEvents();
                pExport.FinishExporting();
            }
        }
예제 #12
0
        /// <summary>
        /// 添加指北针
        /// </summary>
        /// <param name="layoutControl">布局视图</param>
        /// <param name="pEnv">矩形框</param>
        /// <param name="pStyleGalleryItem">指北针样式</param>
        public static void AddNorthArrow(AxPageLayoutControl layoutControl, IEnvelope pEnv, IStyleGalleryItem pStyleGalleryItem)
        {
            if (pStyleGalleryItem == null)
            {
                return;
            }
            IGraphicsContainer pGraphicsContainer = layoutControl.PageLayout as IGraphicsContainer;

            if (pGraphicsContainer == null)
            {
                return;
            }
            IMap              pMap              = layoutControl.ActiveView.FocusMap;
            IMapFrame         pMapFrame         = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
            IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass();

            pMapSurroundFrame.MapFrame = pMapFrame;
            //删除已经存在的指北针
            MappingHelper.DeleteElementByName(layoutControl, "North Arrow");
            INorthArrow pNorthArrow = pStyleGalleryItem.Item as INorthArrow;

            if (pNorthArrow != null)
            {
                pNorthArrow.Size = pEnv.Width * 50;
                pMapSurroundFrame.MapSurround = pNorthArrow;//根据用户的选取,获取相应的MapSurround
            }
            IElement pElement = (IElement)pMapSurroundFrame;

            pElement.Geometry = pEnv;
            //添加元素
            MappingHelper.AddElementWithName(pGraphicsContainer, pElement, "North Arrow");
        }
        public static void SaveCurrentToImage(AxPageLayoutControl axPageLayoutControl, string savePath)
        {
            tagRECT rect = new tagRECT();

            rect.left   = rect.top = 0;
            rect.right  = 1000;
            rect.bottom = 600;
            try
            {
                IActiveView pActiveView = axPageLayoutControl.ActiveView;
                Image       image       = new Bitmap(1000, 600);
                Graphics    graphics    = Graphics.FromImage(image);
                //
                graphics.FillRectangle(Brushes.White, 0, 0, 1000, 600);
                int dpi = (int)(1000 / 500);
                //保存范围
                IGraphicsContainer pGraphicsContainer = axPageLayoutControl.GraphicsContainer;
                IMapFrame          pMapFrame          = pGraphicsContainer.FindFrame(pActiveView.FocusMap) as IMapFrame;


                IEnvelope pMapExt = pActiveView.Extent;

                IEnvelope pEnvelope = new EnvelopeClass();
                pEnvelope.PutCoords(pMapExt.XMin - 2, pMapExt.YMin - 2, pMapExt.XMax + 1, pMapExt.YMax + 1);
                pActiveView.Output(graphics.GetHdc().ToInt32(), dpi, ref rect, pEnvelope, null);
                graphics.ReleaseHdc();
                //保存影像
                image.Save(savePath);
            }
            catch (Exception e)
            {
                MessageBox.Show("保存失败:" + e.ToString());
            }
        }
예제 #14
0
        public MapOutPut(AxPageLayoutControl pagecontrol)
        {
            axPageLayoutControl1 = pagecontrol;

            printDialog1 = new System.Windows.Forms.PrintDialog(); //create a print dialog object
            InitializePageSetupDialog();                           //intitialize the page setup dialog

            comboBox1.Items.Add("esriPageMappingTile");
            comboBox1.Items.Add("esriPageMappingCrop");
            comboBox1.Items.Add("esriPageMappingScale");
            comboBox1.SelectedIndex = 0;

            // create a new PrintPreviewDialog using constructor
            printPreviewDialog1 = new PrintPreviewDialog();
            //set the size, location, name and the minimum size the dialog can be resized to
            printPreviewDialog1.ClientSize  = new System.Drawing.Size(800, 600);
            printPreviewDialog1.Location    = new System.Drawing.Point(29, 29);
            printPreviewDialog1.Name        = "PrintPreviewDialog1";
            printPreviewDialog1.MinimumSize = new System.Drawing.Size(375, 250);
            //set UseAntiAlias to true to allow the operating system to smooth fonts
            printPreviewDialog1.UseAntiAlias = true;

            //associate the event-handling method with the document's PrintPage event
            this.document.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(document_PrintPage);
        }
예제 #15
0
        //page放大
        public static void PageZoomInTool(AxPageLayoutControl pageLayoutControl)
        {
            ICommand command1 = new ControlsMapZoomInTool();

            command1.OnCreate(pageLayoutControl.Object);
            pageLayoutControl.CurrentTool = command1 as ITool;
        }
예제 #16
0
 public AddDateTool(AxToolbarControl toolBar, AxPageLayoutControl pageLayout)
 {
     //
     // TODO: Define values for the public properties
     //
     base.m_category = "Custom Command"; //localizable text
     base.m_caption  = "添加日期元素";         //localizable text
     base.m_message  = "添加日期元素";         //localizable text
     base.m_toolTip  = "添加日期元素";         //localizable text
     base.m_name     = "AddDateTool";    //unique id, non-localizable (e.g. "MyCategory_MyTool")
     try
     {
         //
         // TODO: change resource name if necessary
         //
         string bitmapResourceName = GetType().Name + ".bmp";
         base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
         base.m_cursor = new System.Windows.Forms.Cursor(GetType(), GetType().Name + ".cur");
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
     }
     this.toolBar    = toolBar;
     this.pageLayout = pageLayout;
 }
예제 #17
0
        /// <summary>
        /// 地图导出
        /// </summary>
        /// <param name="pLayoutControl">布局控件</param>
        /// <param name="resolution">图片分辨率</param>
        public static void ExportMapToImage(AxPageLayoutControl pLayoutControl, short resolution)
        {
            IExport pExport = GetExport();

            if (pExport == null)
            {
                return;
            }
            IActiveView activeView = pLayoutControl.ActiveView;
            //获取屏幕分辨率的值
            double screenDispalyResolution = activeView.ScreenDisplay.DisplayTransformation.Resolution;
            //获取布局页面宽度和高度
            IEnvelope pEnvelope = GetPageSize(pLayoutControl);
            //布局坐标转为屏幕坐标
            tagRECT deviceRect = new tagRECT();

            activeView.ScreenDisplay.DisplayTransformation.TransformRect(pEnvelope, ref deviceRect, 9);
            //设置输出范围坐标
            deviceRect = SetDeviceRectProperty(deviceRect, resolution, screenDispalyResolution);
            //设置输出图片的范围
            SetExportPixelBounds(pExport, deviceRect);
            ITrackCancel pCancle = new CancelTrackerClass(); //可用ESC键取消操作

            activeView.Output(pExport.StartExporting(), resolution, ref deviceRect, pEnvelope, pCancle);
            Application.DoEvents();
            pExport.FinishExporting();
            MessageBox.Show("导出完成");
        }
예제 #18
0
        /// <summary>
        /// 添加比例尺
        /// </summary>
        /// <param name="layoutControl">布局视图</param>
        /// <param name="pEnv">矩形框</param>
        /// <param name="scaleBar">比例尺</param>
        public static void AddScaleBar(AxPageLayoutControl layoutControl, IEnvelope pEnv, IScaleBar2 scaleBar)
        {
            if (scaleBar == null)
            {
                return;
            }
            IGraphicsContainer pGraphicsContainer = layoutControl.PageLayout as IGraphicsContainer;

            if (pGraphicsContainer == null)
            {
                return;
            }
            IMap              pMap              = layoutControl.ActiveView.FocusMap;
            IMapFrame         pMapFrame         = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
            IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass();

            pMapSurroundFrame.MapFrame = pMapFrame;
            scaleBar.BarHeight         = pEnv.Height * 10;
            //删除已经存在的比例尺
            MappingHelper.DeleteElementByName(layoutControl, "Scale Line");
            pMapSurroundFrame.MapSurround = scaleBar as IMapSurround;
            IElement pElement = (IElement)pMapSurroundFrame;

            pElement.Geometry = pEnv;
            //添加元素
            MappingHelper.AddElementWithName(pGraphicsContainer, pElement, "Scale Line");
        }
예제 #19
0
 public ExportPictureMessage(string name,AxPageLayoutControl Layout,Object sender)
 {
     InitializeComponent();
     this.layername = name;
     this.pagelayout = Layout;
     this.Obj_sender = sender;
 }
예제 #20
0
        /// <summary>
        /// 添加默认比例尺
        /// </summary>
        /// <param name="layoutControl">布局视图</param>
        /// <param name="pEnv">矩形框</param>
        /// <param name="pStyleGalleryItem">比例尺样式</param>
        public static void AddDefaultScaleBar(AxPageLayoutControl layoutControl, IEnvelope pEnv, IStyleGalleryItem pStyleGalleryItem)
        {
            if (pStyleGalleryItem == null)
            {
                return;
            }
            IGraphicsContainer pGraphicsContainer = layoutControl.PageLayout as IGraphicsContainer;

            if (pGraphicsContainer == null)
            {
                return;
            }
            IMap              pMap              = layoutControl.ActiveView.FocusMap;
            IMapFrame         pMapFrame         = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
            IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass();

            pMapSurroundFrame.MapFrame = pMapFrame;
            //删除已经存在的比例尺
            MappingHelper.DeleteElementByName(layoutControl, "Scale Line");
            IScaleBar2 scaleBar2 = pStyleGalleryItem.Item as IScaleBar2;

            if (scaleBar2 != null)
            {
                scaleBar2.BarHeight           = pEnv.Height * 20;
                scaleBar2.Divisions           = 1;
                scaleBar2.Subdivisions        = 2;
                pMapSurroundFrame.MapSurround = scaleBar2 as IMapSurround;
            }
            IElement pElement = (IElement)pMapSurroundFrame;

            pElement.Geometry = pEnv;
            //添加元素
            MappingHelper.AddElementWithName(pGraphicsContainer, pElement, "Scale Line");
        }
예제 #21
0
        //另存为
        public static void SaveDocAs(AxMapControl mapControl, AxPageLayoutControl pageLayoutControl = null)
        {
            IMapDocument pMapDocument = new MapDocumentClass();

            SaveFileDialog saveDlg = new SaveFileDialog();

            saveDlg.Title  = "地图文档另存为";
            saveDlg.Filter = "mxd文件|*.mxd|所有文件(添加后缀名)|*.*";
            saveDlg.ShowDialog();
            string strDocFileN = saveDlg.FileName;

            if (strDocFileN == string.Empty)
            {
                return;
            }
            pMapDocument.Open(mapControl.DocumentFilename);
            if (strDocFileN == mapControl.DocumentFilename)
            {
                pMapDocument.Save(pMapDocument.UsesRelativePaths, true);
                return;
            }
            else
            {
                pMapDocument.SaveAs(strDocFileN, true, true);
                MessageBox.Show("保存成功!", "信息提示");
            }
        }
예제 #22
0
        public MapOutPut(AxPageLayoutControl pagecontrol)
        {
            axPageLayoutControl1 = pagecontrol;

            printDialog1 = new System.Windows.Forms.PrintDialog(); //create a print dialog object
            InitializePageSetupDialog(); //intitialize the page setup dialog

            comboBox1.Items.Add("esriPageMappingTile");
            comboBox1.Items.Add("esriPageMappingCrop");
            comboBox1.Items.Add("esriPageMappingScale");
            comboBox1.SelectedIndex = 0;

            // create a new PrintPreviewDialog using constructor
            printPreviewDialog1 = new PrintPreviewDialog();
            //set the size, location, name and the minimum size the dialog can be resized to
            printPreviewDialog1.ClientSize = new System.Drawing.Size(800, 600);
            printPreviewDialog1.Location = new System.Drawing.Point(29, 29);
            printPreviewDialog1.Name = "PrintPreviewDialog1";
            printPreviewDialog1.MinimumSize = new System.Drawing.Size(375, 250);
            //set UseAntiAlias to true to allow the operating system to smooth fonts
            printPreviewDialog1.UseAntiAlias = true;

            //associate the event-handling method with the document's PrintPage event
            this.document.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(document_PrintPage);
        }
예제 #23
0
        public MapAndPageLayoutControls(AxMapControl axMapControl_1, AxPageLayoutControl axPageLayoutControl_1)
        {
            this.axMapControl_0        = axMapControl_1;
            this.axPageLayoutControl_0 = axPageLayoutControl_1;
            IGraphicSnapEnvironment2 pageLayout = axPageLayoutControl_1.PageLayout as IGraphicSnapEnvironment2;

            this.imapControl3_0        = axMapControl_1.Object as IMapControl3;
            this.ipageLayoutControl2_0 = axPageLayoutControl_1.Object as IPageLayoutControl2;
            (this.ipageLayoutControl2_0 as IPageLayoutControlEvents_Event).OnMouseMove +=
                new IPageLayoutControlEvents_OnMouseMoveEventHandler(this.method_5);
            (this.imapControl3_0 as IMapControlEvents2_Event).OnMouseMove +=
                new IMapControlEvents2_OnMouseMoveEventHandler(this.method_4);
            (this.ipageLayoutControl2_0 as IPageLayoutControlEvents_Event).OnFocusMapChanged +=
                new IPageLayoutControlEvents_OnFocusMapChangedEventHandler(this.method_6);
            (this.ipageLayoutControl2_0 as IPageLayoutControlEvents_Event).OnPageLayoutReplaced +=
                new IPageLayoutControlEvents_OnPageLayoutReplacedEventHandler(this.method_1);
            this.iactiveViewEvents_Event_0 = this.ipageLayoutControl2_0.ActiveView.FocusMap as IActiveViewEvents_Event;
            try
            {
                if (this.iactiveViewEvents_Event_0 != null)
                {
                    this.iactiveViewEvents_Event_0.ItemAdded +=
                        new IActiveViewEvents_ItemAddedEventHandler(this.method_8);
                    this.iactiveViewEvents_Event_0.ItemReordered +=
                        new IActiveViewEvents_ItemReorderedEventHandler(this.method_0);
                    this.iactiveViewEvents_Event_0.ItemDeleted +=
                        new IActiveViewEvents_ItemDeletedEventHandler(this.method_7);
                }
            }
            catch
            {
            }
        }
        public FormPrintPreview(AxPageLayoutControl pageLayoutControl)
        {
            InitializeComponent();

            mMainPageLayoutControl = pageLayoutControl;

            syn(pageLayoutControl);
        }
예제 #25
0
 public void CopyAndOverwriteMap(AxMapControl mapcontrol, AxPageLayoutControl PageLayoutControl)
 {
     IObjectCopy objectCopy = new ObjectCopyClass();
     object toCopyMap = mapcontrol.Map;
     object copiedMap = objectCopy.Copy(toCopyMap);
     object toOverwriteMap = PageLayoutControl.ActiveView.FocusMap;
     objectCopy.Overwrite(copiedMap, ref toOverwriteMap);
 }
예제 #26
0
        public FormTemplate(AxPageLayoutControl pageLayoutControl)
        {
            InitializeComponent();

            mMainPageLayoutControl = pageLayoutControl;

            InitUI();
        }
예제 #27
0
 public static void CopyAndOverwriteMap(AxMapControl map, AxPageLayoutControl page)
 {
     //获取拷贝接口对象
     IObjectCopy objectCopy = new ObjectCopyClass();
     object toCopyMap = map.Map;
     object copiedMap = objectCopy.Copy(toCopyMap);//复制地图到copiedMap
     object toOverWriteMap = page.ActiveView.FocusMap;//获取视图控件的焦点地图
     objectCopy.Overwrite(copiedMap, ref toOverWriteMap);//复制地图
 }
예제 #28
0
        //在OnAfterScreenDraw事件下使用
        public static void Use_OnAfterScreenDraw(AxMapControl mapControl, AxPageLayoutControl axPageLayoutControl)
        {
            IActiveView            pActiveView           = axPageLayoutControl.ActiveView.FocusMap as IActiveView;
            IDisplayTransformation displayTransformation = pActiveView.ScreenDisplay.DisplayTransformation;

            displayTransformation.VisibleBounds = mapControl.Extent;
            axPageLayoutControl.ActiveView.Refresh();
            OperateFile.CopyAndOverwriteMap(mapControl, axPageLayoutControl);
        }
예제 #29
0
            public static void CopyAndOverwriteMap(AxMapControl axMapControl, AxPageLayoutControl axPageLayoutControl)
            {
                IObjectCopy objectCopy   = new ObjectCopyClass();
                object      toCopyMap    = axMapControl.Map;
                object      copiedMap    = objectCopy.Copy(toCopyMap);
                object      overwriteMap = axPageLayoutControl.ActiveView.FocusMap;

                objectCopy.Overwrite(toCopyMap, ref overwriteMap);
            }
예제 #30
0
        public void CopyAndOverwriteMap(AxMapControl mapcontrol, AxPageLayoutControl PageLayoutControl)
        {
            IObjectCopy objectCopy     = new ObjectCopyClass();
            object      toCopyMap      = mapcontrol.Map;
            object      copiedMap      = objectCopy.Copy(toCopyMap);
            object      toOverwriteMap = PageLayoutControl.ActiveView.FocusMap;

            objectCopy.Overwrite(copiedMap, ref toOverwriteMap);
        }
예제 #31
0
        // 添加图例
        public static void MakeLegend(AxPageLayoutControl pageLayoutControl, IEnvelope envelope)
        {
            IActiveView pActiveView = pageLayoutControl.ActiveView;

            UID pUID = new UID()
            {
                Value = "esriCarto.Legend"
            };
            IGraphicsContainer pGraphicsContainer = pageLayoutControl.PageLayout as IGraphicsContainer;
            IMapFrame          pMapFrame          = pGraphicsContainer.FindFrame(pActiveView.FocusMap) as IMapFrame;
            // 根据唯一标识符,创建与之对应的MapSurroundFrame
            IMapSurroundFrame pMapSurroundFrame = pMapFrame.CreateSurroundFrame(pUID, null);
            // 获取PageLayout中的图例元素
            IElement pDeleteElement = pageLayoutControl.FindElementByName("Legend");

            if (pDeleteElement != null)
            {
                pGraphicsContainer.DeleteElement(pDeleteElement); // 如果已存在图例,删除已经存在的图例
            }
            // 设置MapSurroundFrame背景
            ISymbolBackground pSymbolBackground = new SymbolBackgroundClass()
            {
                FillSymbol = new SimpleFillSymbolClass()
                {
                    Color   = AeUtilsSymbology.GetRgbColor(240, 240, 240),
                    Outline = new SimpleLineSymbolClass()
                    {
                        Color = AeUtilsSymbology.GetRgbColor(0, 0, 0)
                    }
                }
            };

            pMapSurroundFrame.Background = pSymbolBackground;
            // 添加图例
            IElement pElement = pMapSurroundFrame as IElement;

            pElement.Geometry = envelope as IGeometry;
            IMapSurround pMapSurround = pMapSurroundFrame.MapSurround;
            ILegend      pLegend      = pMapSurround as ILegend;

            pLegend.ClearItems();
            pLegend.Title = "图例";
            for (int i = 0; i < pActiveView.FocusMap.LayerCount; i++)
            {
                ILegendItem pLegendItem = new HorizontalLegendItemClass()
                {
                    Layer            = pActiveView.FocusMap.get_Layer(i),
                    ShowDescriptions = false,
                    Columns          = 1,
                    ShowHeading      = true,
                    ShowLabels       = true
                };
                pLegend.AddItem(pLegendItem);
            }
            pGraphicsContainer.AddElement(pElement, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
예제 #32
0
        /// <summary>
        /// 删除指定名称的元素
        /// </summary>
        /// <param name="layoutControl">布局视图</param>
        /// <param name="elementName">元素名称</param>
        public static void DeleteElementByName(AxPageLayoutControl layoutControl, string elementName)
        {
            IGraphicsContainer pGraphicsContainer = layoutControl.PageLayout as IGraphicsContainer;
            var pElement = GetElementByName(layoutControl, elementName);

            if (pGraphicsContainer != null && pElement != null)
            {
                pGraphicsContainer.DeleteElement(pElement); //删除指定元素
            }
        }
예제 #33
0
        public ClassRenderFrm(AxMapControl mapControl, AxPageLayoutControl pageControl)
        {
            InitializeComponent();
            m_mapControl  = mapControl;
            m_pageControl = pageControl;

            DrawColorRamp();
            comboBoxColor.SelectedIndex = 21;
            pictureBox1.Image           = comboBoxColor.SelectedItem as Image;
        }
예제 #34
0
        public static void CopyAndOverwriteMap(AxMapControl map, AxPageLayoutControl page)
        {
            //获取拷贝接口对象
            IObjectCopy objectCopy     = new ObjectCopyClass();
            object      toCopyMap      = map.Map;
            object      copiedMap      = objectCopy.Copy(toCopyMap); //复制地图到copiedMap
            object      toOverWriteMap = page.ActiveView.FocusMap;   //获取视图控件的焦点地图

            objectCopy.Overwrite(copiedMap, ref toOverWriteMap);     //复制地图
        }
예제 #35
0
 public CommonMenu(string strBtnText, AxPageLayoutControl axPageLayoutControl1, string strexxpicname)
 {
     AddMapSouround add = new AddMapSouround(axPageLayoutControl1);
     switch (strBtnText)
     {
         case "图名":
             add.AddText();
             break;
         case "图例":
             add.AddLegend();
             break;
         //case "文字比例尺":
         //    add.AddTxtSacleBar();
         //    break;
         case "比例尺":
             add.AddImgScaleBar();
             break;
         case "指北针":
             add.AddNorthArrow();
             break;
         //case "地图边框":
         //    add.AddFrame();
            // break;
         case "页面设置":
             MapOutPut mapout = new MapOutPut(axPageLayoutControl1);
             mapout.PageSetUp();
             break;
         case "打印预览":
             MapOutPut mapoutyl = new MapOutPut(axPageLayoutControl1);
             mapoutyl.PrintPreview();
             break;
         //case "打印地图":找个影像
         //    //FrmPrintPreview frmPP = new FrmPrintPreview(axPageLayoutControl1);
         //    //frmPP.ShowDialog();
         //    break;
         case "打印":
             MapOutPut mapoutdy = new MapOutPut(axPageLayoutControl1);
             mapoutdy.Print();
             break;
         case "保存图片":
             MapOutPut mapoutex = new MapOutPut(axPageLayoutControl1);
             //strexxpicname += "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("D2") + DateTime.Now.Day.ToString("D2");
             mapoutex.ExportPicture(strexxpicname);
             break;
     }
 }
예제 #36
0
 public ArcMapManager(System.Windows.Controls.Panel mapContainer, System.Windows.Controls.Panel layoutContainer, System.Windows.Controls.Panel tocContainer)
 {
     this._mapContainer = mapContainer;
     this._layoutContainer = layoutContainer;
     this._tocContainer = tocContainer;
     this._mode = MapFunctionMode.None;
     this._geoProcessor = new Geoprocessor();
     this._geoProcessor.OverwriteOutput = true;
     this._symWindow = null;
     this._mapFile = "";
     this._polygonName = "";
     this._tempWorkspace = null;
     this._axLayoutCtrl = null;
     this._axTOCCtrl = null;
     this._axMapCtrl = null;
     this._mapAndLayoutSync = null;
 }
예제 #37
0
        public override void Initialize()
        {
            System.Windows.Forms.Integration.WindowsFormsHost host;
            // Initialize the map control.
            host = new System.Windows.Forms.Integration.WindowsFormsHost();
            this._axMapCtrl = new AxMapControl();
            this._axMapCtrl.BeginInit();
            host.Child = this._axMapCtrl;
            this._mapContainer.Children.Add(host);
            this._axMapCtrl.OnMouseDown += new ESRI.ArcGIS.Controls.IMapControlEvents2_Ax_OnMouseDownEventHandler(this.axMapControl_OnMouseDown);
            this._axMapCtrl.EndInit();

            // Initialize the layout control
            host = new System.Windows.Forms.Integration.WindowsFormsHost();
            this._axLayoutCtrl = new AxPageLayoutControl();
            this._axLayoutCtrl.BeginInit();
            host.Child = this._axLayoutCtrl;
            this._layoutContainer.Children.Add(host);
            this._axLayoutCtrl.EndInit();

            // Initialize the toc control
            host = new System.Windows.Forms.Integration.WindowsFormsHost();
            // Create an object of the legend control.
            this._axTOCCtrl = new AxTOCControl();
            this._axTOCCtrl.BeginInit();
            host.Child = this._axTOCCtrl;
            this._tocContainer.Children.Add(host);
            this._axTOCCtrl.OnMouseDown += new ITOCControlEvents_Ax_OnMouseDownEventHandler(this._axTOCCtrl_OnMouseDown);
            this._axTOCCtrl.EndInit();

            //initialize the map and layout synchronization class
            //get a reference to the MapControl and the PageLayoutControl
            IMapControl3 mapCtrl = (IMapControl3)this._axMapCtrl.Object;
            IPageLayoutControl2 layoutCtrl = (IPageLayoutControl2)this._axLayoutCtrl.Object;
            this._mapAndLayoutSync = new MapAndLayoutSynchronizer(mapCtrl, layoutCtrl);
            //bind the controls together (both point at the same map) and set the MapControl as the active control
            this._mapAndLayoutSync.BindControls(true);
            //add the framework controls (TOC and Toolbars) in order to synchronize then when the
            //active control changes (call SetBuddyControl)
            this._mapAndLayoutSync.AddFrameworkControl(this._axTOCCtrl.Object);


            this._symWindow = new SymbologyWindow();
            this._symWindow.Initialize();

            ShapefileWorkspaceFactoryClass tempWSFactory = new ShapefileWorkspaceFactoryClass();
            this._tempWorkspace = tempWSFactory.OpenFromFile(System.IO.Path.GetTempPath(), 0);
                
            /*
            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.AccessWorkspaceFactory");
            IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);

            string tempWSPath = System.IO.Path.GetTempPath();
            string tempWSName = "ArcMapMgr_" + this.GetHashCode().ToString() + "_WS.mdb";

            string tempWSFile = System.IO.Path.Combine(tempWSPath, tempWSName);
            if (System.IO.File.Exists(tempWSFile))
            {
                System.IO.File.Delete(tempWSFile);
            }

            IWorkspaceName workspaceName = workspaceFactory.Create(tempWSPath, tempWSName, null, 0);
            // Cast the workspace name object to the IName interface and open the workspace.
            IName name = (IName)workspaceName;
            this._tempWorkspace = (IWorkspace)name.Open();        
            */
        }
예제 #38
0
 public pagelayoutEdit(AxPageLayoutControl  page,IHookHelper helper)
 {
     this.pagelayout = page;
     this.m_hookHelper = helper;
     InitializeComponent();
 }
예제 #39
0
 public static void ScreenDraw(AxMapControl axMapControl, AxPageLayoutControl axpageLayerOut)
 {
     IActiveView activeView = (IActiveView)axpageLayerOut.ActiveView.FocusMap;
     IDisplayTransformation displayTransformation = activeView.ScreenDisplay.DisplayTransformation;
     displayTransformation.VisibleBounds = axMapControl.Extent;
     axpageLayerOut.ActiveView.Refresh();
 }
예제 #40
0
        ///<summary>Add a Legend to the Page Layout from the Map.</summary>
        ///
        ///<param name="pageLayout">An IPageLayout interface.</param>
        ///<param name="map">An IMap interface.</param>
        ///<param name="posX">A System.Double that is X coordinate value in page units for the start of the Legend. Example: 2.0</param>
        ///<param name="posY">A System.Double that is Y coordinate value in page units for the start of the Legend. Example: 2.0</param>
        ///<param name="legW">A System.Double that is length in page units of the Legend in both the X and Y direction. Example: 5.0</param>
        /// 
        ///<remarks></remarks>
        public static void Addlegend(AxPageLayoutControl axpageLayoutControl, ESRI.ArcGIS.Carto.IMap map, System.Double posX, System.Double posY, System.Double legW)
        {
            IPageLayout pageLayout;
            pageLayout = axpageLayoutControl.PageLayout;
            if (pageLayout == null || map == null)
            {
                return;
            }
            ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer = pageLayout as ESRI.ArcGIS.Carto.IGraphicsContainer; // Dynamic Cast
            ESRI.ArcGIS.Carto.IMapFrame mapFrame = graphicsContainer.FindFrame(map) as ESRI.ArcGIS.Carto.IMapFrame; // Dynamic Cast
            ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
            uid.Value = "esriCarto.Legend";
            ESRI.ArcGIS.Carto.IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame((ESRI.ArcGIS.esriSystem.UID)uid, null); // Explicit Cast

            //Get aspect ratio
            ESRI.ArcGIS.Carto.IQuerySize querySize = mapSurroundFrame.MapSurround as ESRI.ArcGIS.Carto.IQuerySize; // Dynamic Cast
            System.Double w = 0;
            System.Double h = 0;
            querySize.QuerySize(ref w, ref h);
            System.Double aspectRatio = w / h;

            ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass();
            envelope.PutCoords(posX, posY, (posX * legW), (posY * legW / aspectRatio));
            ESRI.ArcGIS.Carto.IElement element = mapSurroundFrame as ESRI.ArcGIS.Carto.IElement; // Dynamic Cast
            element.Geometry = envelope;
            graphicsContainer.AddElement(element, 0);
        }
예제 #41
0
        /// <summary>
        /// 为PageLayout对象添加图例对象
        /// </summary>
        /// <param name="pPageLayout">PageLayout对象</param>
        /// <param name="pEnvelope">图例添加的位置</param>
        public static void AddLegendToPageLayout(AxPageLayoutControl axpagelayoutcontrol, IEnvelope pEnvelope)
        {
            IPageLayout pageLayout;
            pageLayout = axpagelayoutcontrol.PageLayout;
            try
            {
                IActiveView pActiveView = pageLayout as IActiveView;
                IMap pMap = pActiveView.FocusMap;
                IGraphicsContainer pGraphicsContainer = pActiveView as IGraphicsContainer;
                IMapFrame pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
                UID pUID = new UID();
                pUID.Value = "{7A3F91E4-B9E3-11d1-8756-0000F8751720}";
                ISymbolBackground pSymbolBackground = new SymbolBackgroundClass();
                IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
                ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
                pFillSymbol.Color = GetRgbColor(255, 255, 255);
                pLineSymbol.Color = GetRgbColor(255, 255, 255);
                pFillSymbol.Outline = pLineSymbol;
                pSymbolBackground.FillSymbol = pFillSymbol;
                IMapSurroundFrame pMapSurroundFrame = pMapFrame.CreateSurroundFrame(pUID, null);
                pMapSurroundFrame.Background = pSymbolBackground;
                IElement pElement = pMapSurroundFrame as IElement;
                pElement.Geometry = pEnvelope;
                IMapSurround pMapSurround = pMapSurroundFrame.MapSurround;
                ILegend pLegend = pMapSurround as ILegend;
                pLegend.ClearItems();
                pLegend.Title = "图例";
                ITextSymbol pTextSymbol = new TextSymbolClass();
                pTextSymbol.Size = 10;
                pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                ILegendItem pLegendItem = null;

                for (int i = 0; i < pActiveView.FocusMap.LayerCount; i++)
                {
                    ILayer pLayer = pActiveView.FocusMap.get_Layer(i);
                    if (pLayer is IFeatureLayer)
                    {
                        IFeatureLayer pFLayer = pLayer as IFeatureLayer;
                        IFeatureClass pFeatureClass = pFLayer.FeatureClass;
                        if (pFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                        {
                            continue;
                        }
                        else
                        {
                            pLegendItem = new HorizontalBarLegendItemClass();
                            pLegendItem.Layer = pLayer;
                            pLegendItem.Columns = 1;
                            pLegendItem.ShowDescriptions = false;
                            pLegendItem.ShowHeading = false;
                            pLegendItem.ShowLabels = true;
                            pLegendItem.LayerNameSymbol = pTextSymbol;
                            pLegend.AddItem(pLegendItem);
                        }
                    }
                }
            }
            catch(Exception  ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #42
0
 public void AddLayout(System.Windows.Controls.Panel layoutContainer)
 {
     this._layoutContainer = layoutContainer;
     System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();
     // Create an object of the legend control.
     this._axLayoutCtrl = new AxPageLayoutControl();
     this._axLayoutCtrl.BeginInit();
     host.Child = this._axLayoutCtrl;
     this._layoutContainer.Children.Add(host);
     this._axLayoutCtrl.EndInit();
 }
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
            this.lblCulture = new System.Windows.Forms.Label();
            this.axLicenseControl1 = new ESRI.ArcGIS.Controls.AxLicenseControl();
            this.axPageLayoutControl1 = new ESRI.ArcGIS.Controls.AxPageLayoutControl();
            this.axTOCControl1 = new ESRI.ArcGIS.Controls.AxTOCControl();
            this.axToolbarControl1 = new ESRI.ArcGIS.Controls.AxToolbarControl();
            this.tableLayoutPanel1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.axPageLayoutControl1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.axTOCControl1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.axToolbarControl1)).BeginInit();
            this.SuspendLayout();
            // 
            // tableLayoutPanel1
            // 
            this.tableLayoutPanel1.ColumnCount = 2;
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25.05695F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 74.94305F));
            this.tableLayoutPanel1.Controls.Add(this.lblCulture, 0, 2);
            this.tableLayoutPanel1.Controls.Add(this.axLicenseControl1, 1, 2);
            this.tableLayoutPanel1.Controls.Add(this.axPageLayoutControl1, 1, 1);
            this.tableLayoutPanel1.Controls.Add(this.axTOCControl1, 0, 1);
            this.tableLayoutPanel1.Controls.Add(this.axToolbarControl1, 0, 0);
            this.tableLayoutPanel1.Location = new System.Drawing.Point(2, 2);
            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
            this.tableLayoutPanel1.RowCount = 3;
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.598214F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 90.40179F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 39F));
            this.tableLayoutPanel1.Size = new System.Drawing.Size(731, 445);
            this.tableLayoutPanel1.TabIndex = 6;
            // 
            // lblCulture
            // 
            this.lblCulture.AutoSize = true;
            this.lblCulture.Location = new System.Drawing.Point(3, 405);
            this.lblCulture.Name = "lblCulture";
            this.lblCulture.Size = new System.Drawing.Size(35, 13);
            this.lblCulture.TabIndex = 0;
            this.lblCulture.Text = "label1";
            // 
            // axLicenseControl1
            // 
            this.axLicenseControl1.Enabled = true;
            this.axLicenseControl1.Location = new System.Drawing.Point(186, 408);
            this.axLicenseControl1.Name = "axLicenseControl1";
            this.axLicenseControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axLicenseControl1.OcxState")));
            this.axLicenseControl1.Size = new System.Drawing.Size(32, 32);
            this.axLicenseControl1.TabIndex = 1;
            // 
            // axPageLayoutControl1
            // 
            this.axPageLayoutControl1.Location = new System.Drawing.Point(186, 41);
            this.axPageLayoutControl1.Name = "axPageLayoutControl1";
            this.axPageLayoutControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axPageLayoutControl1.OcxState")));
            this.axPageLayoutControl1.Size = new System.Drawing.Size(542, 361);
            this.axPageLayoutControl1.TabIndex = 2;
            // 
            // axTOCControl1
            // 
            this.axTOCControl1.Location = new System.Drawing.Point(3, 41);
            this.axTOCControl1.Name = "axTOCControl1";
            this.axTOCControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axTOCControl1.OcxState")));
            this.axTOCControl1.Size = new System.Drawing.Size(177, 361);
            this.axTOCControl1.TabIndex = 3;
            // 
            // axToolbarControl1
            // 
            this.tableLayoutPanel1.SetColumnSpan(this.axToolbarControl1, 2);
            this.axToolbarControl1.Location = new System.Drawing.Point(3, 3);
            this.axToolbarControl1.Name = "axToolbarControl1";
            this.axToolbarControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axToolbarControl1.OcxState")));
            this.axToolbarControl1.Size = new System.Drawing.Size(725, 28);
            this.axToolbarControl1.TabIndex = 4;
            // 
            // Form1
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(734, 454);
            this.Controls.Add(this.tableLayoutPanel1);
            this.MaximumSize = new System.Drawing.Size(750, 492);
            this.MinimumSize = new System.Drawing.Size(750, 492);
            this.Name = "Form1";
            this.Text = "CulturalResources";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.tableLayoutPanel1.ResumeLayout(false);
            this.tableLayoutPanel1.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.axPageLayoutControl1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.axTOCControl1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.axToolbarControl1)).EndInit();
            this.ResumeLayout(false);

        }
예제 #44
0
 public AddMapSouround(AxPageLayoutControl  pagecontrol)
 {
     this.mainPage = pagecontrol;
 }
예제 #45
0
        public static void AddNorthArrow(AxPageLayoutControl axpagelayoutcontrol, ESRI.ArcGIS.Carto.IMap map)
        {
            IPageLayout pageLayout;
               pageLayout = axpagelayoutcontrol.PageLayout;

            if (pageLayout == null || map == null)
            {
                return;
            }
            ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass();
            envelope.PutCoords(16, 24, 21, 29); //  Specify the location and size of the north arrow

            ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
            uid.Value = "esriCarto.MarkerNorthArrow";

            // Create a Surround. Set the geometry of the MapSurroundFrame to give it a location
            // Activate it and add it to the PageLayout's graphics container
            ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer = pageLayout as ESRI.ArcGIS.Carto.IGraphicsContainer; // Dynamic Cast
            ESRI.ArcGIS.Carto.IActiveView activeView = pageLayout as ESRI.ArcGIS.Carto.IActiveView; // Dynamic Cast
            ESRI.ArcGIS.Carto.IFrameElement frameElement = graphicsContainer.FindFrame(map);
            ESRI.ArcGIS.Carto.IMapFrame mapFrame = frameElement as ESRI.ArcGIS.Carto.IMapFrame; // Dynamic Cast
            ESRI.ArcGIS.Carto.IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid as ESRI.ArcGIS.esriSystem.UID, null); // Dynamic Cast
            ESRI.ArcGIS.Carto.IElement element = mapSurroundFrame as ESRI.ArcGIS.Carto.IElement; // Dynamic Cast
            element.Geometry = envelope;
            element.Activate(activeView.ScreenDisplay);
            graphicsContainer.AddElement(element, 0);
            ESRI.ArcGIS.Carto.IMapSurround mapSurround = mapSurroundFrame.MapSurround;

            // Change out the default north arrow
            ESRI.ArcGIS.Carto.IMarkerNorthArrow markerNorthArrow = mapSurround as ESRI.ArcGIS.Carto.IMarkerNorthArrow; // Dynamic Cast
            ESRI.ArcGIS.Display.IMarkerSymbol markerSymbol = markerNorthArrow.MarkerSymbol;
            ESRI.ArcGIS.Display.ICharacterMarkerSymbol characterMarkerSymbol = markerSymbol as ESRI.ArcGIS.Display.ICharacterMarkerSymbol; // Dynamic Cast
            characterMarkerSymbol.CharacterIndex = 202; // change the symbol for the North Arrow
            markerNorthArrow.MarkerSymbol = characterMarkerSymbol;
        }
예제 #46
0
        public static void AddScalebar(AxPageLayoutControl axpagelayoutcontrol, ESRI.ArcGIS.Carto.IMap map)
        {
            IPageLayout pageLayout;
            pageLayout = axpagelayoutcontrol.PageLayout;

            if (pageLayout == null || map == null)
            {
                return;
            }

            ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass();
            envelope.PutCoords(8, 3, 15, 3.8); // Specify the location and size of the scalebar
            ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
            uid.Value = "esriCarto.AlternatingScaleBar";

            // Create a Surround. Set the geometry of the MapSurroundFrame to give it a location
            // Activate it and add it to the PageLayout's graphics container
            ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer = pageLayout as ESRI.ArcGIS.Carto.IGraphicsContainer; // Dynamic Cast
            ESRI.ArcGIS.Carto.IActiveView activeView = pageLayout as ESRI.ArcGIS.Carto.IActiveView; // Dynamic Cast
            ESRI.ArcGIS.Carto.IFrameElement frameElement = graphicsContainer.FindFrame(map);
            ESRI.ArcGIS.Carto.IMapFrame mapFrame = frameElement as ESRI.ArcGIS.Carto.IMapFrame; // Dynamic Cast
            ESRI.ArcGIS.Carto.IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid as ESRI.ArcGIS.esriSystem.UID, null); // Dynamic Cast
            ESRI.ArcGIS.Carto.IElement element = mapSurroundFrame as ESRI.ArcGIS.Carto.IElement; // Dynamic Cast
            element.Geometry = envelope;
            element.Activate(activeView.ScreenDisplay);
            graphicsContainer.AddElement(element, 0);
            ESRI.ArcGIS.Carto.IMapSurround mapSurround = mapSurroundFrame.MapSurround;

            ESRI.ArcGIS.Carto.IScaleBar markerScaleBar = ((ESRI.ArcGIS.Carto.IScaleBar)(mapSurround));
            ITextSymbol scalbarsm = markerScaleBar.LabelSymbol;
            markerScaleBar.Units = esriUnits.esriKilometers;
            markerScaleBar.Name = "比例尺";
            markerScaleBar.Map = axpagelayoutcontrol.ActiveView.FocusMap;

            markerScaleBar.LabelPosition = ESRI.ArcGIS.Carto.esriVertPosEnum.esriTop;
            //markerScaleBar.UseMapSettings();
        }
예제 #47
0
        public static void AddTextElement(AxPageLayoutControl PageLayoutControl, double x, double y, string textName)
        {
            IPageLayout pPageLayout;
            IActiveView pAV;
            IGraphicsContainer pGraphicsContainer;
            IPoint pPoint;
            ITextElement pTextElement;
            IElement pElement;
            ITextSymbol pTextSymbol;
            IRgbColor pColor;
            pPageLayout = PageLayoutControl.PageLayout;
            pAV = (IActiveView)pPageLayout;
            pGraphicsContainer = (IGraphicsContainer)pPageLayout;
            pTextElement = new TextElementClass();

            IFontDisp pFont = new StdFontClass() as IFontDisp;
            pFont.Bold = true;
            pFont.Name = "宋体";
            pFont.Size = 26;

            pColor = new RgbColorClass();
            pColor.Red = 255;

            pTextSymbol = new TextSymbolClass();
            pTextSymbol.Color = (IColor)pColor;
            pTextSymbol.Font = pFont;

            pTextElement.Text = textName;
            pTextElement.Symbol = pTextSymbol;

            pPoint = new PointClass();
            pPoint.X = x;
            pPoint.Y = y;

            pElement = (IElement)pTextElement;
            pElement.Geometry = (IGeometry)pPoint;
            pGraphicsContainer.AddElement(pElement, 0);

            pAV.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
예제 #48
0
 public static void copyToPageLayerOut(AxMapControl axMapControl, AxPageLayoutControl axpageLayerOut)
 {
     IObjectCopy objectCopy = new ObjectCopyClass();
     object copyFromMap = axMapControl.Map;
     object copyMap = objectCopy.Copy(copyFromMap);
     object copyToMap = axpageLayerOut.ActiveView.FocusMap;
     objectCopy.Overwrite(copyMap, ref copyToMap);
 }