public void CopyMapToPageLayOutDataFrameforPrint(IMap MapControlOfMap) { this.m_OldMap = MapControlOfMap; IGraphicsContainerSelect graphicsContainer = this.axPageLayoutControl1.ActiveView.GraphicsContainer as IGraphicsContainerSelect; IElement element = null; IMapFrame frame = null; if (graphicsContainer.ElementSelectionCount <= 0) { this.CopyMapToPageLayOutforPrint(MapControlOfMap); } else { for (int i = 0; i < graphicsContainer.ElementSelectionCount; i++) { element = graphicsContainer.SelectedElement(i); if (element is IMapFrame) { frame = element as IMapFrame; break; } } if (frame != null) { SimpleLineSymbolClass class2 = new SimpleLineSymbolClass(); IRgbColor color = new RgbColorClass { Red = 255, Green = 255, Blue = 255 }; class2.Color = color; ISymbolBorder border = new SymbolBorderClass { LineSymbol = class2 }; frame.Border = border; IObjectCopy copy = new ObjectCopyClass(); object pInObject = MapControlOfMap; object obj3 = copy.Copy(pInObject); object map = frame.Map; copy.Overwrite(obj3, ref map); this.fullPageLayerOut(this.axPageLayoutControl1.ActiveView.FocusMap, (MapControlOfMap as IActiveView).Extent); this.axPageLayoutControl1.ActiveView.Refresh(); } else { this.CopyMapToPageLayOutforPrint(MapControlOfMap); } } }
public override void OnDblClick() { m_Geometry = (IGeometry)m_NewPolygonFeedback.Stop(); IMap pMap = m_hookHelper.FocusMap; ISpatialReference spatialReferencr = pMap.SpatialReference; m_Geometry.SpatialReference = spatialReferencr; IBorder pBorder = new SymbolBorderClass(); m_hookHelper.FocusMap.ClipBorder = pBorder; // m_hookHelper.FocusMap.ClipGeometry = m_Geometry; m_ActiveView.Extent = m_Geometry.Envelope; m_ActiveView.Refresh(); m_cursor = base.m_cursor; m_InUse = false; /* string textTitle=""; //标题,制作者等信息 * string textName=""; * string textProject=""; * string textDate=""; * string textelevation=""; * string textOtherInfo=""; * frmTempleteProperties frmTempletePro = new frmTempleteProperties( pMap , m_Geometry); * frmTempletePro.ShowDialog(); * textTitle = frmTempletePro.ptextTitle; * textName = frmTempletePro.ptextName; * textProject = frmTempletePro.ptextProject; * textDate = frmTempletePro.ptextTime; * * textelevation = frmTempletePro.elevationName; * textOtherInfo =frmTempletePro .pOtherInfo ;*/ m_ActiveView.Refresh(); if (!frmTempletePro.ifCancle) { frmPrintByAnyRegion frmPrint = new frmPrintByAnyRegion(pMap, m_Geometry, textTitle, textName, textProject, textDate, textelevation, textOtherInfo);// checkLegend, checkNorthArrow, checkMapGrid, checkScaleBar, checkText); frmPrint.ShowDialog(); } else { } }
public void CopyMapToPageLayOutforPrint(IMap MapControlOfMap) { try { this.m_OldMap = MapControlOfMap; this.axPageLayoutControl1.GraphicsContainer.DeleteAllElements(); IObjectCopy copy = new ObjectCopyClass(); object pInObject = MapControlOfMap; object obj3 = copy.Copy(pInObject); object focusMap = this.axPageLayoutControl1.ActiveView.FocusMap; copy.Overwrite(obj3, ref focusMap); this.fullPageLayerOut(this.axPageLayoutControl1.ActiveView.FocusMap, (MapControlOfMap as IActiveView).Extent); SimpleLineSymbolClass class2 = new SimpleLineSymbolClass(); IRgbColor color = new RgbColorClass { Red = 255, Green = 255, Blue = 255 }; class2.Color = color; ISymbolBorder border = new SymbolBorderClass { LineSymbol = class2 }; IElement element = this.axPageLayoutControl1.ActiveView.GraphicsContainer.Next(); if ((element != null) && (element is IMapFrame)) { (element as IFrameElement).Border = border; } this.axPageLayoutControl1.ActiveView.Refresh(); } catch (Exception exception) { MessageBox.Show(exception.Message, "提示"); } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { //m_Cursor = new System.Windows.Forms.Cursor(GetType().Assembly.GetManifestResourceStream(GetType(), "AopenMap.cur")); if (Button == 1) { if (m_InUse == true) { m_pAV = m_HookHelper.ActiveView; m_pScrD = m_pAV.ScreenDisplay; IMap pMap = m_HookHelper.FocusMap; IPoint pPnt; pPnt = (IPoint)m_pScrD.DisplayTransformation.ToMapPoint(X, Y); if (m_pNewPolygonFeedback == null) { m_pNewPolygonFeedback = new NewPolygonFeedbackClass(); ISimpleLineSymbol pSLnSym; IRgbColor pRGB = new RgbColorClass(); pSLnSym = (ISimpleLineSymbol)m_pNewPolygonFeedback.Symbol; pRGB.Red = 140; pRGB.Green = 140; pRGB.Blue = 255; pSLnSym.Color = pRGB; pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid; pSLnSym.Width = 2; m_pNewPolygonFeedback.Display = m_pScrD; m_pNewPolygonFeedback.Start(pPnt); } else { m_pNewPolygonFeedback.AddPoint(pPnt); } } } else if (Button == 2) { IPolygon pGeomLn; pGeomLn = m_pNewPolygonFeedback.Stop(); m_pNewPolygonFeedback = null; IMap pMap = m_HookHelper.FocusMap; ISpatialReference spatialReference = pMap.SpatialReference; //IBorder pBorder = new SymbolBorderClass(); //*****************************************88888888 if (pFirstGeom == null) { pFirstGeom = pGeomLn; } if (mGeomln != null) { pFirstGeom = mGeomln; } if (pFirstGeom != pGeomLn) { IPolygon mFirstGeom; mFirstGeom = pFirstGeom; IRelationalOperator pROperator = (IRelationalOperator)mFirstGeom; if (pROperator.Disjoint((IGeometry)pGeomLn) == false) { //先定义一个IGeometrycollection的多边形,将每个画出来的IgeometryCollection添加进去 //先添一个构成一个IPolygon,转化为ITopo_ ,再同样构成另一个,进行Union IGeometryCollection pcGeometry = new PolygonClass(); object o = System.Type.Missing; IPolygon cFirstGeom = new PolygonClass(); cFirstGeom = pFirstGeom; ITopologicalOperator tempTopo = (ITopologicalOperator)cFirstGeom; tempTopo.Simplify(); ITopologicalOperator pTopo = (ITopologicalOperator)pGeomLn; pTopo.Simplify(); IGeometry kGeom; kGeom = pTopo.Union((IGeometry)cFirstGeom); mGeomln = (IPolygon)kGeom; mGeomln.SpatialReference = spatialReference; m_pAV.FocusMap.ClipGeometry = mGeomln; //IBorder pBorder = new SymbolBorderClass(); //m_HookHelper.FocusMap.ClipBorder = pBorder; m_pAV.Extent = mGeomln.Envelope; m_pAV.Refresh(); m_Cursor = base.m_cursor; //layVisbleExceptMap(); } } else { //*************************************************8 //mGeomln = pGeomLn; pGeomLn.SpatialReference = spatialReference; LayerControl.LyrPolygon = pGeomLn; m_HookHelper.FocusMap.ClipGeometry = pGeomLn; IBorder pBorder = new SymbolBorderClass(); m_HookHelper.FocusMap.ClipBorder = pBorder; m_pAV.Extent = pGeomLn.Envelope; m_pAV.Refresh(); m_Cursor = base.m_cursor; pGeomLn = null; } } }
private void btnOpnMap_Click(object sender, EventArgs e) { double dobX, dobY; string txtCoodX, txtCoodY; if (lstVwCood.Items.Count < 3) { MessageBox.Show("请输入三个以上的点!"); return; } else { for (int i = 0; i < lstVwCood.Items.Count; i++) { txtCoodX = lstVwCood.Items[i].SubItems[1].Text; txtCoodY = lstVwCood.Items[i].SubItems[2].Text; dobX = Convert.ToDouble(txtCoodX); dobY = Convert.ToDouble(txtCoodY); pPnt.PutCoords(dobX, dobY); if (pNPolFeback == null) { pNPolFeback = new NewPolygonFeedbackClass(); ISimpleLineSymbol pSLnSym; IRgbColor pRGB = new RgbColorClass(); pSLnSym = (ISimpleLineSymbol)pNPolFeback.Symbol; pRGB.Red = 140; pRGB.Green = 140; pRGB.Blue = 255; pSLnSym.Color = pRGB; pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid; pSLnSym.Width = 2; pNPolFeback.Display = pScreen; pNPolFeback.Start(pPnt); } else { pNPolFeback.AddPoint(pPnt); } } pActivew = pMapControl.ActiveView; pScreen = pActivew.ScreenDisplay; IGeometry pGeomLn; pGeomLn = (IGeometry)pNPolFeback.Stop(); IMap pMap = pMapControl.Map; ISpatialReference spatialReference = pMap.SpatialReference; pGeomLn.SpatialReference = spatialReference; IBorder pBorder = new SymbolBorderClass(); LayerControl.LyrPolygon = pGeomLn; pMapControl.Map.ClipBorder = pBorder; pMapControl.Map.ClipGeometry = pGeomLn; pActivew.Extent = pGeomLn.Envelope; //pActivew.Refresh(); this.DialogResult = DialogResult.OK; ////打开地形图图层 //layVisbleExceptMap(); this.Close(); pActivew.Refresh(); } }
private List<string> ExportSymbol(IStyleGallery sg,string symbolType, int col, int row, int size,int width, int labelsize, int label_h, int size_w, int size_h, double height, string cat, IPageLayout3 layout) { List<string> pdfpages = new List<string>(); IGraphicsContainer con = layout as IGraphicsContainer; IPage page = layout.Page; int r = 0; int c = 0; int p = 0; IEnumStyleGalleryItem items = sg.get_Items(symbolType, "", cat); IStyleGalleryItem item = items.Next(); while (item != null) { #region Symbol if (symbolType == "Marker Symbols") { IMarkerElement mele = new MarkerElementClass(); IPoint ptn = new PointClass(); ptn.PutCoords(c * size_w + size / 2, height - (r * size_h + size / 2)); IElement ele_i = mele as IElement; ele_i.Geometry = ptn; IMarkerSymbol sym_m = item.Item as IMarkerSymbol; sym_m.Size = size; mele.Symbol = sym_m; con.AddElement(ele_i, 0); } else if (symbolType == "Line Symbols") { ILineElement lele = new LineElementClass(); IPolyline line = new PolylineClass(); IPoint ptn_f = new PointClass(); ptn_f.PutCoords(c * size_w + size / 4, height - (r * size_h + size * 3 / 4)); IPoint ptn_t = new PointClass(); ptn_t.PutCoords(c * size_w + size * 3 / 4, height - (r * size_h + size / 4)); line.FromPoint = ptn_f; line.ToPoint = ptn_t; IElement ele_i = lele as IElement; ele_i.Geometry = line; ILineSymbol sym_l = item.Item as ILineSymbol; sym_l.Width = width; lele.Symbol = sym_l; con.AddElement(ele_i, 0); } else if (symbolType == "Fill Symbols") { IRectangleElement fele = new RectangleElementClass(); IFillShapeElement fsele = fele as IFillShapeElement; IEnvelope env_f = new EnvelopeClass(); env_f.PutCoords(c * size_w + size / 4, height - (r * size_h + size * 3 / 4), c * size_w + size * 3 / 4, height - (r * size_h + size / 4)); IElement ele_i = fele as IElement; ele_i.Geometry = env_f; IFillSymbol sym_f = item.Item as IFillSymbol; fsele.Symbol = sym_f; con.AddElement(ele_i, 0); } #endregion if (cbGrid.Checked) { #region Grid IEnvelope env_g = new EnvelopeClass(); env_g.PutCoords(c * size_w, height - r * size_h, c * size_w + size_w, height - r * size_h - size_h); IRectangleElement gele = new RectangleElementClass(); IElement ele_g = gele as IElement; ele_g.Geometry = env_g; IFillSymbol sym_g = new SimpleFillSymbolClass(); IRgbColor color_g = new RgbColorClass(); color_g.NullColor = true; sym_g.Color = color_g; IFillShapeElement fshp_g = ele_g as IFillShapeElement; fshp_g.Symbol = sym_g; con.AddElement(ele_g, 0); #endregion } #region Label ITextElement tele = new ParagraphTextElementClass(); IElement ele_t = tele as IElement; tele.Text = item.Name; IEnvelope env_l = new EnvelopeClass(); env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h); env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h); env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h); env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h); env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h); ele_t.Geometry = env_l; ITextSymbol sym_label = new TextSymbolClass(); sym_label.Size = labelsize/2; IRgbColor color = new RgbColorClass(); color.NullColor = true; ISimpleLineSymbol sym_border = new SimpleLineSymbolClass(); sym_border.Color = color; ISymbolBorder border = new SymbolBorderClass(); border.LineSymbol = sym_border; IFrameProperties fp = ele_t as IFrameProperties; fp.Border = border; con.AddElement(ele_t, 0); #endregion if (c < col - 1) { c++; } else { c = 0; if (r < row - 1) { r++; } else { IActiveView av = layout as IActiveView; string temp_pdf = System.IO.Path.GetTempFileName() + ".pdf"; ExportPDF(av, temp_pdf); pdfpages.Add(temp_pdf); con.DeleteAllElements(); r = 0; c = 0; p++; } } item = items.Next(); } if (con.Next() != null) { IActiveView av = layout as IActiveView; string temp_pdf = System.IO.Path.GetTempFileName() + ".pdf"; ExportPDF(av, temp_pdf); pdfpages.Add(temp_pdf); con.DeleteAllElements(); } return pdfpages; }
public override void OnDblClick() { m_Geometry = (IGeometry)m_NewPolygonFeedback.Stop(); IMap pMap = m_hookHelper.FocusMap; ISpatialReference spatialReferencr = pMap.SpatialReference; m_Geometry.SpatialReference = spatialReferencr; IBorder pBorder = new SymbolBorderClass(); m_hookHelper.FocusMap.ClipBorder = pBorder; // m_hookHelper.FocusMap.ClipGeometry = m_Geometry; m_ActiveView.Extent = m_Geometry.Envelope; m_ActiveView.Refresh(); m_cursor = base.m_cursor; m_InUse = false; /* string textTitle=""; //标题,制作者等信息 string textName=""; string textProject=""; string textDate=""; string textelevation=""; string textOtherInfo=""; frmTempleteProperties frmTempletePro = new frmTempleteProperties( pMap , m_Geometry); frmTempletePro.ShowDialog(); textTitle = frmTempletePro.ptextTitle; textName = frmTempletePro.ptextName; textProject = frmTempletePro.ptextProject; textDate = frmTempletePro.ptextTime; textelevation = frmTempletePro.elevationName; textOtherInfo =frmTempletePro .pOtherInfo ;*/ m_ActiveView.Refresh(); if (!frmTempletePro.ifCancle) { frmPrintByAnyRegion frmPrint = new frmPrintByAnyRegion(pMap , m_Geometry, textTitle, textName, textProject, textDate, textelevation, textOtherInfo);// checkLegend, checkNorthArrow, checkMapGrid, checkScaleBar, checkText); frmPrint.ShowDialog(); } else { } }
private void frmSymbolProperty_Load(object sender, EventArgs e) { if (this.m_pStyleGalleryItem != null) { this.txtName.Text = this.m_pStyleGalleryItem.Name; this.txtCategory.Text = this.m_pStyleGalleryItem.Category; this.symbolItem1.Symbol = this.m_pStyleGalleryItem.Item; if (this.symbolItem1.Symbol is IMarkerSymbol) { this.m_SymbolType = enumSymbolType.enumSTPoint; } else if (this.symbolItem1.Symbol is ILineSymbol) { this.m_SymbolType = enumSymbolType.enumSTLine; } else if (this.symbolItem1.Symbol is IFillSymbol) { this.m_SymbolType = enumSymbolType.enumSTFill; } else if (this.symbolItem1.Symbol is ITextSymbol) { this.m_SymbolType = enumSymbolType.enumSTText; } else if (this.symbolItem1.Symbol is IColorRamp) { this.m_SymbolType = enumSymbolType.enumSTColorRamp; } else if (this.symbolItem1.Symbol is IColor) { this.m_SymbolType = enumSymbolType.enumSTColor; } else if (this.symbolItem1.Symbol is ISymbolBorder) { this.m_SymbolType = enumSymbolType.enumSTBorder; } else if (this.symbolItem1.Symbol is ISymbolBackground) { this.m_SymbolType = enumSymbolType.enumSTBackground; } else if (this.symbolItem1.Symbol is ISymbolShadow) { this.m_SymbolType = enumSymbolType.enumSTShadow; } else if (this.symbolItem1.Symbol is IMarkerNorthArrow) { this.m_SymbolType = enumSymbolType.enumSTNorthArrow; } else if (this.symbolItem1.Symbol is IScaleBar) { this.m_SymbolType = enumSymbolType.enumSTScaleBar; } else if (this.symbolItem1.Symbol is IScaleText) { this.m_SymbolType = enumSymbolType.enumSTScaleText; } else if (this.symbolItem1.Symbol is ILegendItem) { this.m_SymbolType = enumSymbolType.enumSTLegendItem; } else { this.m_SymbolType = enumSymbolType.enumSTUnknown; } } else { this.m_pStyleGalleryItem = new ServerStyleGalleryItemClass(); object obj2 = null; switch (this.m_SymbolType) { case enumSymbolType.enumSTPoint: this.txtName.Text = "点符号"; obj2 = new MultiLayerMarkerSymbolClass(); ((IMultiLayerMarkerSymbol)obj2).AddLayer(new SimpleMarkerSymbolClass()); break; case enumSymbolType.enumSTLine: this.txtName.Text = "线符号"; obj2 = new MultiLayerLineSymbolClass(); ((IMultiLayerLineSymbol)obj2).AddLayer(new SimpleLineSymbolClass()); break; case enumSymbolType.enumSTFill: this.txtName.Text = "面符号"; obj2 = new MultiLayerFillSymbolClass(); ((IMultiLayerFillSymbol)obj2).AddLayer(new SimpleFillSymbolClass()); break; case enumSymbolType.enumSTText: case enumSymbolType.enumSTColorRamp: case enumSymbolType.enumSTColor: case enumSymbolType.enumSTLinePatch: case enumSymbolType.enumSTAreaPatch: return; case enumSymbolType.enumSTNorthArrow: this.txtName.Text = "指北针"; obj2 = new MarkerNorthArrowClass(); break; case enumSymbolType.enumSTScaleBar: this.txtName.Text = "比例尺"; obj2 = new ScaleLineClass(); break; case enumSymbolType.enumSTScaleText: this.txtName.Text = "比例尺文本"; obj2 = new ScaleTextClass(); break; case enumSymbolType.enumSTBorder: this.txtName.Text = "边界"; obj2 = new SymbolBorderClass(); break; case enumSymbolType.enumSTShadow: this.txtName.Text = "阴影"; obj2 = new SymbolShadowClass(); break; case enumSymbolType.enumSTBackground: this.txtName.Text = "背景"; obj2 = new SymbolBackgroundClass(); break; case enumSymbolType.enumSTLegendItem: this.txtName.Text = "图例项"; obj2 = new HorizontalLegendItemClass(); break; case enumSymbolType.enumSTLabel: this.txtName.Text = "标注"; obj2 = new LabelStyleClass(); break; default: return; } this.symbolItem1.Symbol = obj2; this.m_pStyleGalleryItem.Name = this.txtName.Text; this.m_pStyleGalleryItem.Category = this.txtCategory.Text; this.m_pStyleGalleryItem.Item = obj2; } }