private void axSymbologyControl1_OnItemSelected(object sender, ESRI.ArcGIS.Controls.ISymbologyControlEvents_OnItemSelectedEvent e) { IStyleGalleryItem styleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem; //Get the frame containing the focus map IFrameProperties frameProperties = (IFrameProperties)axPageLayoutControl1.GraphicsContainer.FindFrame(axPageLayoutControl1.ActiveView.FocusMap); if (styleGalleryItem.Item is IBackground) { //Set the frame's background frameProperties.Background = (IBackground)styleGalleryItem.Item; } else if (styleGalleryItem.Item is IBorder) { //Set the frame's border frameProperties.Border = (IBorder)styleGalleryItem.Item; } else if (styleGalleryItem.Item is IShadow) { //Set the frame's shadow frameProperties.Shadow = (IShadow)styleGalleryItem.Item; } //Refresh the PageLayoutControl axPageLayoutControl1.Refresh(esriViewDrawPhase.esriViewBackground, null, null); }
private void syn(AxPageLayoutControl mainlayoutControl) { IObjectCopy objectcopy = new ObjectCopyClass(); object tocopymap = mainlayoutControl.ActiveView.GraphicsContainer; //获取mapcontrol中的map 这个是原始的 object copiedmap = objectcopy.Copy(tocopymap); //复制一份map,是一个副本 object tooverwritemap = PrintPagelayoutControl.ActiveView.GraphicsContainer; //IActiveView.FocusMap : The map that tools and controls act on. 控件和工具作用的地图,大概是当前地图吧!!! objectcopy.Overwrite(copiedmap, ref tooverwritemap); System.Runtime.InteropServices.Marshal.ReleaseComObject(objectcopy); IGraphicsContainer mainGraphCon = tooverwritemap as IGraphicsContainer; mainGraphCon.Reset(); IElement pElement = mainGraphCon.Next(); IArray pArray = new ArrayClass(); while (pElement != null) { pArray.Add(pElement); pElement = mainGraphCon.Next(); } int pElementCount = pArray.Count; IPageLayout PrintPageLayout = PrintPagelayoutControl.PageLayout; IGraphicsContainer PrintGraphCon = PrintPageLayout as IGraphicsContainer; PrintGraphCon.Reset(); IElement pPrintElement = PrintGraphCon.Next(); while (pPrintElement != null) { PrintGraphCon.DeleteElement(pPrintElement); pPrintElement = PrintGraphCon.Next(); } for (int i = 0; i < pArray.Count; i++) { PrintGraphCon.AddElement(pArray.get_Element(pElementCount - 1 - i) as IElement, 0); } PrintPagelayoutControl.Refresh(); }
private void axPageLayoutControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnMouseDownEvent e) { if (e.button != 2) { return; } //Create a new point IPoint pPoint = new PointClass(); pPoint.PutCoords(e.pageX, e.pageY); //Create a new text element ITextElement textElement = new TextElementClass(); //Set the text to display today's date textElement.Text = DateTime.Now.ToShortDateString(); //Add element to graphics container using the CommandsEnvironment default text symbol axPageLayoutControl1.AddElement((IElement)textElement, pPoint, m_graphicProperties.TextSymbol, "", 0); //Refresh the graphics axPageLayoutControl1.Refresh(esriViewDrawPhase.esriViewGraphics, null, null); }
private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e) { //Exit if not right mouse button if (e.button != 2) { return; } IBasicMap map = new MapClass(); ILayer layer = new FeatureLayerClass(); object other = new Object(); object index = new Object(); esriTOCControlItem item = new esriTOCControlItem(); //Determine what kind of item has been clicked on axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //QI to IFeatureLayer and IGeoFeatuerLayer interface if (layer == null) { return; } IFeatureLayer featureLayer = layer as IFeatureLayer; if (featureLayer == null) { return; } IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featureLayer; ISimpleRenderer simpleRenderer = (ISimpleRenderer)geoFeatureLayer.Renderer; //Create the form with the SymbologyControl frmSymbol symbolForm = new frmSymbol(); //Get the IStyleGalleryItem IStyleGalleryItem styleGalleryItem = null; //Select SymbologyStyleClass based upon feature type switch (featureLayer.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassMarkerSymbols, simpleRenderer.Symbol); break; case esriGeometryType.esriGeometryPolyline: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassLineSymbols, simpleRenderer.Symbol); break; case esriGeometryType.esriGeometryPolygon: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassFillSymbols, simpleRenderer.Symbol); break; } //Release the form symbolForm.Dispose(); this.Activate(); if (styleGalleryItem == null) { return; } //Create a new renderer simpleRenderer = new SimpleRendererClass(); //Set its symbol from the styleGalleryItem simpleRenderer.Symbol = (ISymbol)styleGalleryItem.Item; //Set the renderer into the geoFeatureLayer geoFeatureLayer.Renderer = (IFeatureRenderer)simpleRenderer; //Fire contents changed event that the TOCControl listens to axPageLayoutControl1.ActiveView.ContentsChanged(); //Refresh the display axPageLayoutControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null); }
private void UpdateSymbol(IStyleGalleryItem styleGalleryItem) { //Get IPage interface IPage page = axPageLayoutControl1.Page; //Apply the symbol as a property to the page if (optIPropertySupport.Checked) { //Query interface for IPropertySupport IPropertySupport propertySupport = page as IPropertySupport; //If the symbol can be applied if (propertySupport.CanApply(styleGalleryItem.Item)) { //Apply the object propertySupport.Apply(styleGalleryItem.Item); } else { MessageBox.Show("Unable to apply this symbol!"); } } //Apply the symbol as an IFrameProperties property if (optIFrameProperties.Checked) { //Query interface for IFrameProperties IFrameProperties frameProperties = page as IFrameProperties; if (styleGalleryItem.Item is IBorder) { //Set the frame's border frameProperties.Border = styleGalleryItem.Item as IBorder; } else if (styleGalleryItem.Item is IBackground) { //Set the frame's background frameProperties.Background = styleGalleryItem.Item as IBackground; } else if (styleGalleryItem.Item is IColor) { MessageBox.Show("There is no color property on IFrameProperties!"); } else if (styleGalleryItem.Item is IShadow) { //Set the frame's shadow frameProperties.Shadow = styleGalleryItem.Item as IShadow; } } //Apply the symbol as an IPage property if (optIPage.Checked) { if (styleGalleryItem.Item is IBorder) { //Set the frame's border page.Border = styleGalleryItem.Item as IBorder; } else if (styleGalleryItem.Item is IBackground) { //Set the frame's background page.Background = styleGalleryItem.Item as IBackground; } else if (styleGalleryItem.Item is IColor) { //Set the frame's background color page.BackgroundColor = styleGalleryItem.Item as IColor; } else if (styleGalleryItem.Item is IShadow) { MessageBox.Show("There is no shadow property on IPage!"); } } //Refresh axPageLayoutControl1.Refresh(esriViewDrawPhase.esriViewBackground, null, null); }