private void simpleButtonOK_Click(object sender, EventArgs e) { try { PointSymbol pPointSymbol = new PointSymbol(); // 根据选择的图形修改按钮上相应图形 #region switch (this.imageComboPointType.SelectedIndex) { case 0: if (this.fatherform.CurrentThemeType == 1) this.fatherform.BtnSymbolType.Image = Image.FromFile(Application.StartupPath + @"\SymbolImage\Circleblue.png"); else { if (this.fatherform.CurrentThemeType == 2) this.fatherform.BtnSymbolType2.Image = Image.FromFile(Application.StartupPath + @"\SymbolImage\Circleblue.png"); } pPointSymbol.PointType = "Circle"; break; case 1: if (this.fatherform.CurrentThemeType == 1) this.fatherform.BtnSymbolType.Image = Image.FromFile(Application.StartupPath + @"\SymbolImage\Triangleblue.png"); else { if (this.fatherform.CurrentThemeType == 2) this.fatherform.BtnSymbolType2.Image = Image.FromFile(Application.StartupPath + @"\SymbolImage\Triangleblue.png"); } pPointSymbol.PointType = "Triangle"; break; case 2: if (this.fatherform.CurrentThemeType == 1) this.fatherform.BtnSymbolType.Image = Image.FromFile(Application.StartupPath + @"\SymbolImage\Rectangleblue.png"); else { if (this.fatherform.CurrentThemeType == 2) this.fatherform.BtnSymbolType2.Image = Image.FromFile(Application.StartupPath + @"\SymbolImage\Rectangleblue.png"); } pPointSymbol.PointType = "Rectangle"; break; case 3: if (this.fatherform.CurrentThemeType == 1) this.fatherform.BtnSymbolType.Image = Image.FromFile(Application.StartupPath + @"\SymbolImage\Pentagonblue.png"); else { if (this.fatherform.CurrentThemeType == 2) this.fatherform.BtnSymbolType2.Image = Image.FromFile(Application.StartupPath + @"\SymbolImage\Pentagonblue.png"); } pPointSymbol.PointType = "Pentagon"; break; case 4: if (this.fatherform.CurrentThemeType == 1) this.fatherform.BtnSymbolType.Image = Image.FromFile(Application.StartupPath + @"\SymbolImage\Hexagonblue.png"); else { if (this.fatherform.CurrentThemeType == 2) this.fatherform.BtnSymbolType2.Image = Image.FromFile(Application.StartupPath + @"\SymbolImage\Hexagonblue.png"); } pPointSymbol.PointType = "Hexagon"; break; case 5: if (this.fatherform.CurrentThemeType == 1) this.fatherform.BtnSymbolType.Image = Image.FromFile(Application.StartupPath + @"\SymbolImage\Arrowblue.png"); else { if (this.fatherform.CurrentThemeType == 2) this.fatherform.BtnSymbolType2.Image = Image.FromFile(Application.StartupPath + @"\SymbolImage\Arrowblue.png"); } pPointSymbol.PointType = "Arrow"; break; default: break; } #endregion //若datagrid中有加载数据,修改grid中显示图片 #region if (this.fatherform.CurrentThemeType == 1) { if (this.fatherform.SimpleThemeGridView.RowCount > 0) ((DataGridViewImageColumn)this.fatherform.SimpleThemeGridView.Columns[0]).Image = Image.FromFile(Application.StartupPath + @"\SymbolImage\" + pPointSymbol.PointType + "55b.png"); } else { if (this.fatherform.CurrentThemeType == 2) { if (this.fatherform.BreakThemeGridView.RowCount == 1) { this.fatherform.BreakThemeGridView[0, 0].Value = Image.FromFile(Application.StartupPath + @"\SymbolImage\" + pPointSymbol.PointType + "55b.png"); } else { #region int ClassNum = this.fatherform.BreakThemeGridView.RowCount; double Scalestep = 2.0 / (ClassNum - 1); Image pImage = null; pImage = Image.FromFile(Application.StartupPath + @"\SymbolImage\" + pPointSymbol.PointType + "55b.png"); for (int i = 0; i < ClassNum; i++) { this.fatherform.BreakThemeGridView[0, i].Value = ImageHelper.KiResizeImage(pImage, (int)(pImage.Width * (1 + Scalestep * i)), (int)(pImage.Height * (1 + Scalestep * i))); } #endregion } } } #endregion pPointSymbol.PointSize = Convert.ToDouble(this.spinEditPointSize.Text); this.fatherform.CurrentSymbol.CurrentPointSymbol = pPointSymbol; this.Close(); } catch { MessageBox.Show("点符号化失败!"); } }
private void InitialCurrentSymbol(ILayer61 CurrentLayer) { IFeatureGroup61 pFeatureGroup; switch (CurrentLayer.GeometryType) { case LayerGeometryType.LGT_POINT: pFeatureGroup = CurrentLayer.FeatureGroups.Point; PointSymbol pPoint = new PointSymbol(); #region switch (pFeatureGroup.DisplayAs) { case ObjectTypeCode.OT_ARROW: pPoint.PointType = "Arrow"; if (pFeatureGroup.IsClassified("Length")) pPoint.PointSizeClass = pFeatureGroup.GetClassification("Length").ToString(); else { pPoint.PointSize = (double)pFeatureGroup.GetProperty("Length"); //pPoint.PointSizeClass = "NoClass"; } if (pFeatureGroup.IsClassified("Fill Color")) pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Fill Color").ToString(); else { Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Fill Color")); pPoint.PointFillcolor = pColor; //pPoint.PointFillcolorClass = "NoClass"; } if (pFeatureGroup.IsClassified("Fill Opacity")) pPoint.PointFillOpacityClass = pFeatureGroup.GetClassification("Fill Opacity").ToString(); else { pPoint.PointFillOpacity = (double)pFeatureGroup.GetProperty("Fill Opacity"); //pPoint.PointFillOpacityClass = "NoClass"; } pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method"); break; case ObjectTypeCode.OT_CIRCLE: pPoint.PointType = "Circle"; if (pFeatureGroup.IsClassified("Radius X")) pPoint.PointSizeClass = pFeatureGroup.GetClassification("Radius X").ToString(); else { pPoint.PointSize = (double)pFeatureGroup.GetProperty("Radius X"); //pPoint.PointSizeClass = "NoClass"; } if (pFeatureGroup.IsClassified("Number of sides")) pPoint.NumOfSidesClass = pFeatureGroup.GetClassification("Number of sides").ToString(); else { pPoint.NumOfSides = (int)pFeatureGroup.GetProperty("Number of sides"); } if (pFeatureGroup.IsClassified("Fill Color")) pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Fill Color").ToString(); else { Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Fill Color")); pPoint.PointFillcolor = pColor; } if (pFeatureGroup.IsClassified("Fill Opacity")) pPoint.PointFillOpacityClass = pFeatureGroup.GetClassification("Fill Opacity").ToString(); else { pPoint.PointFillOpacity = (double)pFeatureGroup.GetProperty("Fill Opacity"); } pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method"); break; case ObjectTypeCode.OT_RECTANGLE: pPoint.PointType = "Rectangle"; if (pFeatureGroup.IsClassified("Length")) pPoint.PointSizeClass = pFeatureGroup.GetClassification("Length").ToString(); else pPoint.PointSize = (double)pFeatureGroup.GetProperty("Length"); if (pFeatureGroup.IsClassified("Width")) pPoint.PointSizeClass2 = pFeatureGroup.GetClassification("Width").ToString(); else pPoint.PointSize2 = (double)pFeatureGroup.GetProperty("Width"); if (pFeatureGroup.IsClassified("Fill Color")) pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Fill Color").ToString(); else { Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Fill Color")); pPoint.PointFillcolor = pColor; } if (pFeatureGroup.IsClassified("Fill Opacity")) pPoint.PointFillOpacityClass = pFeatureGroup.GetClassification("Fill Opacity").ToString(); else { pPoint.PointFillOpacity = (double)pFeatureGroup.GetProperty("Fill Opacity"); } pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method"); break; case ObjectTypeCode.OT_REGULAR_POLYGON: if (pFeatureGroup.IsClassified("Number of sides")) { pPoint.NumOfSidesClass = pFeatureGroup.GetClassification("Number of sides").ToString(); pPoint.PointType = "Other"; } else { pPoint.NumOfSides = (int)pFeatureGroup.GetProperty("Number of sides"); switch (pPoint.NumOfSides) { case 3: pPoint.PointType = "Triangle"; break; case 5: pPoint.PointType = "Pentagon"; break; case 6: pPoint.PointType = "Hexagon"; break; default: pPoint.PointType = "Other"; break; } } if (pFeatureGroup.IsClassified("Radius X")) pPoint.PointSizeClass = pFeatureGroup.GetClassification("Radius X").ToString(); else pPoint.PointSize = (double)pFeatureGroup.GetProperty("Radius X"); if (pFeatureGroup.IsClassified("Fill Color")) pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Fill Color").ToString(); else { Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Fill Color")); pPoint.PointFillcolor = pColor; } if (pFeatureGroup.IsClassified("Fill Opacity")) pPoint.PointFillOpacityClass = pFeatureGroup.GetClassification("Fill Opacity").ToString(); else { pPoint.PointFillOpacity = (double)pFeatureGroup.GetProperty("Fill Opacity"); } pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method"); break; case ObjectTypeCode.OT_LABEL: pPoint.PointType = "Other"; if (pFeatureGroup.IsClassified("Text Color")) pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Text Color").ToString(); else { Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Text Color")); pPoint.PointFillcolor = pColor; } pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method"); break; case ObjectTypeCode.OT_IMAGE_LABEL: pPoint.PointType = "Other"; if (pFeatureGroup.IsClassified("Image Color")) pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Image Color").ToString(); else { Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Image Color")); pPoint.PointFillcolor = pColor; } if (pFeatureGroup.IsClassified("Image Opacity")) pPoint.PointFillOpacityClass = pFeatureGroup.GetClassification("Image Opacity").ToString(); else { pPoint.PointFillOpacity = (double)pFeatureGroup.GetProperty("Image Opacity"); } pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method"); break; case ObjectTypeCode.OT_MODEL: pPoint.PointType = "Other"; if (pFeatureGroup.IsClassified("Tint Color")) pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Tint Color").ToString(); else { Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Tint Color")); pPoint.PointFillcolor = pColor; } if (pFeatureGroup.IsClassified("Tint Opacity")) pPoint.PointFillOpacityClass = pFeatureGroup.GetClassification("Tint Opacity").ToString(); else { pPoint.PointFillOpacity = (double)pFeatureGroup.GetProperty("Tint Opacity"); } pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method"); break; default: pPoint.PointType = "Other"; if (pFeatureGroup.IsClassified("Fill Color")) pPoint.PointFillcolorClass = pFeatureGroup.GetClassification("Fill Color").ToString(); else { Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Fill Color")); pPoint.PointFillcolor = pColor; } if (pFeatureGroup.IsClassified("Fill Opacity")) pPoint.PointFillOpacityClass = pFeatureGroup.GetClassification("Fill Opacity").ToString(); else { pPoint.PointFillOpacity = (double)pFeatureGroup.GetProperty("Fill Opacity"); } pPoint.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method"); break; } #endregion this.CurrentSymbol.CurrentPointSymbol = pPoint; this.CurrentSymbol.PrePointSymbol = pPoint; break; case LayerGeometryType.LGT_POLYLINE: pFeatureGroup = CurrentLayer.FeatureGroups.Polyline; PolylineSymbol pPolyline = new PolylineSymbol(); #region string LinePattern = pFeatureGroup.GetProperty("Line Pattern").ToString(); switch (LinePattern) { case "-1": pPolyline.PolylineType = "Solidline"; break; case "-1044481": pPolyline.PolylineType = "Dottedline"; break; case "-16776961": pPolyline.PolylineType = "Dottedline2"; break; case "-267390961": pPolyline.PolylineType = "Dottedline3"; break; case "-1010580541": pPolyline.PolylineType = "Dottedline4"; break; case "-1717986919": pPolyline.PolylineType = "Dottedline5"; break; case "-1431655766": pPolyline.PolylineType = "Dottedline6"; break; case "-16678657": pPolyline.PolylineType = "Dottedline7"; break; case "-15978241": pPolyline.PolylineType = "Dottedline8"; break; } if (pFeatureGroup.IsClassified("Line Width")) pPolyline.PolylineWidthClass = pFeatureGroup.GetClassification("Line Width").ToString(); else pPolyline.PolylineWidth = (double)pFeatureGroup.GetProperty("Line Width"); if (pFeatureGroup.IsClassified("Line Color")) { pPolyline.PolylineColorClass = pFeatureGroup.GetClassification("Line Color").ToString(); } else { Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Line Color")); pPolyline.PolylineColor = pColor; } if (pFeatureGroup.IsClassified("Line Opacity")) pPolyline.PolylineOpacityClass = pFeatureGroup.GetClassification("Line Opacity").ToString(); else { pPolyline.PolylineOpacity = (double)pFeatureGroup.GetProperty("Line Opacity"); } if (pFeatureGroup.IsClassified("Line Back Color")) { pPolyline.PolylineBackColorClass = pFeatureGroup.GetClassification("Line Back Color").ToString(); } else { Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Line Back Color")); pPolyline.PolylineBackColor = pColor; } pPolyline.PolylineBackOpacity = (int)pFeatureGroup.GetProperty("Line Back Opacity"); if (pFeatureGroup.IsClassified("Line Back Opacity")) pPolyline.PolylineBackOpacityClass = pFeatureGroup.GetClassification("Line Back Opacity").ToString(); else { pPolyline.PolylineBackOpacity = (int)pFeatureGroup.GetProperty("Line Back Opacity"); } pPolyline.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method"); #endregion this.CurrentSymbol.CurrentPolylineSymbol = pPolyline; this.CurrentSymbol.PrePolylineSymbol = pPolyline; break; case LayerGeometryType.LGT_POLYGON: pFeatureGroup = CurrentLayer.FeatureGroups.Polygon; PolygonSymbol pPolygon = new PolygonSymbol(); #region if (pFeatureGroup.IsClassified("Fill Color")) pPolygon.PolygonFillcolorClass = pFeatureGroup.GetClassification("Fill Color").ToString(); else { Color pColor = Color.FromArgb((int)pFeatureGroup.GetProperty("Fill Color")); pPolygon.PolygonFillcolor = pColor; } if (pFeatureGroup.IsClassified("Fill Opacity")) pPolygon.PolygonFillOpacityClass = pFeatureGroup.GetClassification("Fill Opacity").ToString(); else { pPolygon.PolygonFillOpacity = (double)pFeatureGroup.GetProperty("Fill Opacity"); } pPolygon.AltitMethod = (int)pFeatureGroup.GetProperty("Altitude Method"); #endregion this.CurrentSymbol.PrePolygonSymbol = pPolygon; break; default: break; } }