private void FrmSymboloTin_Load(object sender, EventArgs e) { string sInstall = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\ESRI.ServerStyle"; axSymbologyControl1.LoadStyleFile(sInstall); axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps; pSymbolClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps); /* ********************************* * 生成色度带 * *********************************/ for (int i = 0; i < pSymbolClass.get_ItemCount(pSymbolClass.StyleCategory); i++) { stdole.IPictureDisp pPicture = pSymbolClass.PreviewItem(pSymbolClass.GetItem(i), cmbcolor.Width, cmbcolor.Height); Image image = Image.FromHbitmap(new System.IntPtr(pPicture.Handle)); cmbcolor.Items.Add(image); } if (cmbcolor.Items.Count > 0) { cmbcolor.SelectedIndex = 0; } /* ********************************* * 初始化gridview及颜色控件 * *********************************/ if (pTLayer.GetRenderer(0).GetType().Name == "TinFaceRendererClass" || pTLayer.GetRenderer(0).Name == "Faces") { treeshow.SelectedIndex = 1; ITinSingleSymbolRenderer pTinrenderer = pTLayer.GetRenderer(0) as ITinSingleSymbolRenderer; ISimpleFillSymbol psymbol = new SimpleFillSymbolClass(); psymbol = pTinrenderer.Symbol as ISimpleFillSymbol; btncolor.SelectedColor = ClsGDBDataCommon.IColorToColor(psymbol.Color); istrue = true; } else if (pTLayer.GetRenderer(0).Name == "Elevation" || pTLayer.GetRenderer(0).Name == "Edge types") { treeshow.SelectedIndex = 0; btncolor.SelectedColor = System.Drawing.Color.Green; for (int j = 0; j < pTLayer.RendererCount; j++) { if (pTLayer.GetRenderer(j).Name == "Elevation") { ptinColorRampRenderer = pTLayer.GetRenderer(j) as ITinColorRampRenderer; break; } } cmbclasses.SelectedIndex = ptinColorRampRenderer.BreakCount - 1; initialupdatagrid(); } }
private void RasterRenderer_Load(object sender, EventArgs e) { IRasterBandCollection bands = rasterLayer.Raster as IRasterBandCollection; List <string> bds = new List <string>(); for (int i = 0; i < bands.Count; i++) { bds.Add(bands.Item(i).Bandname); } cbSelectedBand.DataSource = bds; try { axSymbologyControl1.LoadStyleFile(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\ESRI\\ESRI.ServerStyle"); axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps; symbol = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps); cbColorRamp.DrawMode = DrawMode.OwnerDrawFixed; cbColorRamp.DropDownStyle = ComboBoxStyle.DropDownList;//这是最关键的一步 for (int i = 0; i < symbol.get_ItemCount(symbol); i++) { stdole.IPictureDisp picture = symbol.PreviewItem(symbol.GetItem(i), cbColorRamp.Width, cbColorRamp.Height); Image image = Image.FromHbitmap(new IntPtr(picture.Handle)); cbColorRamp.Items.Add(image); } } catch { if (lang == Language.Chinese) { MessageBox.Show("色带加载失败!"); } else if (lang == Language.English) { MessageBox.Show("Loading color ribbons failed!"); } } }
/// <summary> /// 获取要色方案集合 /// </summary> /// <param name="width">色带图片的宽度</param> /// <param name="height">色带图片的高度</param> /// <param name="category">色带的类型</param> /// <returns></returns> public List <ColorItem> GetColorScheme(int width, int height, string category) { string sInstall = ModuleCommon.ReadRegistry("SOFTWARE\\ESRI\\CoreRuntime"); if (sInstall == "") //added by chulili 2012-11-13 平台由ArcGIS9.3换成ArcGIS10,相应的注册表路径要修改 { sInstall = ModuleCommon.ReadRegistry("SOFTWARE\\ESRI\\Engine10.0\\CoreRuntime"); } if (sInstall == "") { sInstall = ModuleCommon.ReadRegistry("SOFTWARE\\ESRI\\Desktop10.0\\CoreRuntime"); } //added by chulili 2012-11-13 end m_SymbologyControl.LoadStyleFile(sInstall + "\\Styles\\ESRI.ServerStyle"); ISymbologyStyleClass styleClass = m_SymbologyControl.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps); int count = styleClass.get_ItemCount(""); List <ColorItem> colorScheme = new List <ColorItem>(); for (int i = 0; i < count; i++) { IStyleGalleryItem pItem = styleClass.GetItem(i); if (category.Contains(pItem.Category)) { stdole.IPictureDisp picture = styleClass.PreviewItem(pItem, width, height); Image image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); ColorItem colorItem = new ColorItem(); colorItem.ColorImage = image; colorItem.Name = pItem.Name; colorItem.ColorRamp = pItem.Item as IColorRamp; colorScheme.Add(colorItem); } } return(colorScheme); }
private void SetUI(IElement pElement) { tabProperty.Tabs["tabFrame"].Visible = false; chkRatio.Checked = m_pBoundProp.FixedAspectRatio; if (pElement is IMarkerElement) { //panelLine.Visible = false; //panelPoly.Visible = false; panelText.Visible = false; picLine.Visible = false; picPoly.Visible = false; picPoint.Visible = true; btnLine.Visible = false; btnPoint.Visible = true; btnPoly.Visible = false; picArrow.Visible = false; picScale.Visible = false; picScaleText.Visible = false; btnArrow.Visible = false; btnScale.Visible = false; btnScaleText.Visible = false; //panelPoint.Visible = true; //panelPoint.BringToFront (); picPoint.BringToFront(); tabProperty.Tabs["tabArea"].Visible = false; chkRatio.Enabled = false; } else if (pElement is ILineElement) { panelText.Visible = false; picLine.Visible = true; picPoly.Visible = false; picPoint.Visible = false; btnLine.Visible = true; btnPoint.Visible = false; btnPoly.Visible = false; picArrow.Visible = false; picScale.Visible = false; picScaleText.Visible = false; btnArrow.Visible = false; btnScale.Visible = false; btnScaleText.Visible = false; picLine.BringToFront(); tabProperty.Tabs["tabArea"].Visible = false; chkRatio.Enabled = true; } else if (pElement is IFillShapeElement) { panelText.Visible = false; picLine.Visible = false; picPoly.Visible = true; picPoint.Visible = false; btnLine.Visible = false; btnPoint.Visible = false; btnPoly.Visible = true; picArrow.Visible = false; picScale.Visible = false; picScaleText.Visible = false; btnArrow.Visible = false; btnScale.Visible = false; btnScaleText.Visible = false; picPoly.BringToFront(); chkRatio.Enabled = true; } else if (pElement is ITextElement) { panelText.Visible = true; picLine.Visible = false; picPoly.Visible = false; picPoint.Visible = false; btnLine.Visible = false; btnPoint.Visible = false; btnPoly.Visible = false; picArrow.Visible = false; picScale.Visible = false; picScaleText.Visible = false; btnArrow.Visible = false; btnScale.Visible = false; btnScaleText.Visible = false; panelText.BringToFront(); tabProperty.Tabs["tabArea"].Visible = false; chkRatio.Enabled = false; } else if (pElement is IInkGraphic) { tabProperty.Tabs["tabArea"].Visible = false; tabProperty.Tabs["tabSymbol"].Visible = false; } if (pElement is IFrameElement) { tabProperty.Tabs["tabArea"].Visible = false; tabProperty.Tabs["tabSymbol"].Visible = false; //判断指北针,比例尺,比例文本 IMapSurroundFrame pMapSurroundFrame = pElement as IMapSurroundFrame; if (pMapSurroundFrame != null) { IMapSurround pMapSurround = pMapSurroundFrame.MapSurround; if (pMapSurround != null) { tabProperty.Tabs["tabSymbol"].Visible = true; panelText.Visible = false; if (pMapSurround is INorthArrow) { panelText.Visible = false; picLine.Visible = false; picPoly.Visible = false; picPoint.Visible = false; btnLine.Visible = false; btnPoint.Visible = false; btnPoly.Visible = false; picArrow.Visible = true; picScale.Visible = false; picScaleText.Visible = false; btnArrow.Visible = true; btnScale.Visible = false; btnScaleText.Visible = false; picArrow.BringToFront(); chkRatio.Enabled = true; } else if (pMapSurround is IScaleBar) { panelText.Visible = false; picLine.Visible = false; picPoly.Visible = false; picPoint.Visible = false; btnLine.Visible = false; btnPoint.Visible = false; btnPoly.Visible = false; picArrow.Visible = false; picScale.Visible = true; picScaleText.Visible = false; btnArrow.Visible = false; btnScale.Visible = true; btnScaleText.Visible = false; picScale.BringToFront(); chkRatio.Enabled = true; } else if (pMapSurround is IScaleText) { panelText.Visible = false; picLine.Visible = false; picPoly.Visible = false; picPoint.Visible = false; btnLine.Visible = false; btnPoint.Visible = false; btnPoly.Visible = false; picArrow.Visible = false; picScale.Visible = false; picScaleText.Visible = true; btnArrow.Visible = false; btnScale.Visible = false; btnScaleText.Visible = true; picScaleText.BringToFront(); chkRatio.Enabled = true; } } } else if (pElement is IMapFrame) { tabProperty.Tabs["tabFrame"].Visible = true; } //初始化窗体 //Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\ESRI\\CoreRuntime", true); //if (rk == null) return; //string sInstall = (string)rk.GetValue("InstallDir"); string sInstall = ReadRegistry("SOFTWARE\\ESRI\\CoreRuntime"); if (sInstall == "") //added by chulili 2012-11-13 平台由ArcGIS9.3换成ArcGIS10,相应的注册表路径要修改 { sInstall = ReadRegistry("SOFTWARE\\ESRI\\Engine10.0\\CoreRuntime"); } if (sInstall == "") { sInstall = ReadRegistry("SOFTWARE\\ESRI\\Desktop10.0\\CoreRuntime"); } //added by chulili 2012-11-13 end if (sInstall == "") { MessageBox.Show("系统没有安装Engine Runtime", "提示"); return; } string sPath = sInstall + "\\Styles\\ESRI.ServerStyle"; axSymbologyControl1.Clear(); axSymbologyControl1.LoadStyleFile(sPath); //添加边框符号 IStyleGalleryItem pItem; stdole.IPictureDisp picture; System.Drawing.Image image; DevComponents.Editors.ComboItem valueItem; int i = 0; axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassBorders; ISymbologyStyleClass symbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass); int cnt = symbologyStyleClass.get_ItemCount(symbologyStyleClass.StyleCategory); cmbBorder.Items.Clear(); cmbBorder.Items.Add("<None>"); for (i = 0; i < cnt; i++) { pItem = symbologyStyleClass.GetItem(i); picture = symbologyStyleClass.PreviewItem(pItem, cmbBorder.Width - 80, cmbBorder.Height); image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); valueItem = new DevComponents.Editors.ComboItem(); valueItem.Text = pItem.Name; valueItem.Tag = pItem.Item; valueItem.Image = image; cmbBorder.Items.Add(valueItem); } //添加背景符号 axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassBackgrounds; symbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass); cnt = symbologyStyleClass.get_ItemCount(symbologyStyleClass.StyleCategory); cmbBack.Items.Clear(); cmbBack.Items.Add("<None>"); for (i = 0; i < cnt; i++) { pItem = symbologyStyleClass.GetItem(i); picture = symbologyStyleClass.PreviewItem(pItem, cmbBack.Width - 80, cmbBack.Height); image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); valueItem = new DevComponents.Editors.ComboItem(); valueItem.Text = pItem.Name; valueItem.Tag = pItem.Item; valueItem.Image = image; cmbBack.Items.Add(valueItem); } //添加阴影符号 axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassShadows; symbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass); cnt = symbologyStyleClass.get_ItemCount(symbologyStyleClass.StyleCategory); cmbShadow.Items.Clear(); cmbShadow.Items.Add("<None>"); for (i = 0; i < cnt; i++) { pItem = symbologyStyleClass.GetItem(i); picture = symbologyStyleClass.PreviewItem(pItem, cmbShadow.Width - 80, cmbShadow.Height); image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); valueItem = new DevComponents.Editors.ComboItem(); valueItem.Text = pItem.Name; valueItem.Tag = pItem.Item; valueItem.Image = image; cmbShadow.Items.Add(valueItem); } } }
/// <summary> /// 初始化与拉伸相关控件 /// </summary> private void initstreach() { string sInstall = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\ESRI.ServerStyle"; axSymbologyControl1.LoadStyleFile(sInstall); axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps; pSymbolClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps); pRasterRender = pRLayer.Renderer; pRasterRenderColorRamp = pRasterRender as IRasterRendererColorRamp; //生成色度带 if (pRasterRender is IRasterStretchColorRampRenderer) { IStyleGalleryItem pStyleGalleryItem = new ServerStyleGalleryItem(); pStyleGalleryItem.Item = pRasterRenderColorRamp.ColorRamp; pSymbolClass.AddItem(pStyleGalleryItem, 0); pSymbolClass.SelectItem(0); } for (int i = 0; i < pSymbolClass.get_ItemCount(pSymbolClass.StyleCategory); i++) { stdole.IPictureDisp pPicture = pSymbolClass.PreviewItem(pSymbolClass.GetItem(i), cmbColorRamp.Width, cmbColorRamp.Height); Image image = Image.FromHbitmap(new System.IntPtr(pPicture.Handle)); cmbColorRamp.Items.Add(image); } if (cmbColorRamp.Items.Count > 0) { cmbColorRamp.SelectedIndex = 0; } //判断拉伸方式和拉伸波段 if (pRasterRender is IRasterStretchColorRampRenderer) { pSCRampRender = pRasterRender as IRasterStretchColorRampRenderer; pRasterStretch = pRasterRender as IRasterStretch; int bandindex = pSCRampRender.BandIndex; cmbBand.SelectedIndex = bandindex; if (pRasterStretch.StretchType == esriRasterStretchTypesEnum.esriRasterStretch_Custom) { cmbStreach.SelectedIndex = 1; } else if (pRasterStretch.StretchType == esriRasterStretchTypesEnum.esriRasterStretch_MinimumMaximum) { cmbStreach.SelectedIndex = 2; } else if (pRasterStretch.StretchType == esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations) { cmbStreach.SelectedIndex = 3; } else if (pRasterStretch.StretchType == esriRasterStretchTypesEnum.esriRasterStretch_HistogramEqualize) { cmbStreach.SelectedIndex = 4; } else { cmbStreach.SelectedIndex = 0; } lblminstr.Text = pSCRampRender.LabelLow; lblmaxstr.Text = pSCRampRender.LabelHigh; txtmin.Text = pSCRampRender.LabelLow; txtmax.Text = pSCRampRender.LabelHigh; if (pRasterStretch.StretchType == esriRasterStretchTypesEnum.esriRasterStretch_MinimumMaximum) { txtmax.Visible = true; txtmin.Visible = false; } } else { cmbBand.SelectedIndex = 0; cmbStreach.SelectedIndex = 0; } isminmax = true; }