加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
FrmSetColor.cs 3.28 KB
一键复制 编辑 原始数据 按行查看 历史
baishaowei 提交于 2018-08-07 14:33 . 初始版本:v1.0
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GeoScene.Data;
using GeoScene.Engine;
using GeoScene.Globe;
namespace WorldGIS
{
public partial class FrmSetColor : Form
{
GSOGlobeControl globeControl1;
public FrmSetColor(GSOGlobeControl _globeControl1)
{
InitializeComponent();
globeControl1 = _globeControl1;
}
private void FrmSetColor_Load(object sender, EventArgs e)
{
for (int i = 0; i < globeControl1.Globe.Layers.Count; i++)
{
GSOLayer layer = globeControl1.Globe.Layers[i];
if (layer != null && layer.Type == EnumLayerType.FeatureLayer)
{
LayerString layerstring = new LayerString(layer);
comboBoxEx1.Items.Add(layerstring);
comboBoxEx2.Items.Add(layerstring);
}
}
}
private void buttonX1_Click(object sender, EventArgs e)
{
Color color1 = colorPickerButton1.SelectedColor;
Color color2 = colorPickerButton2.SelectedColor;
Color color3 = colorPickerButton3.SelectedColor;
Color color4 = colorPickerButton4.SelectedColor;
Color color5 = colorPickerButton5.SelectedColor;
Color color6 = colorPickerButton6.SelectedColor;
Color color7 = colorPickerButton7.SelectedColor;
Color color8 = colorPickerButton8.SelectedColor;
List<Color> listColors = new List<Color>();
for (int i = 0; i < 6; i++)
{
listColors.Add(color1);
listColors.Add(color2);
listColors.Add(color3);
listColors.Add(color4);
listColors.Add(color5);
listColors.Add(color6);
listColors.Add(color7);
listColors.Add(color8);
}
GSOLayer layerWaike = (comboBoxEx1.SelectedItem as LayerString).Layer;
GSOLayer layer = (comboBoxEx2.SelectedItem as LayerString).Layer;
for (int i = 0; i < layerWaike.GetAllFeatures().Length; i++)
{
GSOFeature f = layerWaike.GetAt(i);
GSOGeoModel modelWaike = f.Geometry as GSOGeoModel;
GSOEntityStyle3D style = new GSOEntityStyle3D();
style.UsingSingleColor = true;
style.EntityColor = Color.FromArgb(200, listColors[i]);
modelWaike.Style = style;
GSOFeatures fs = layer.GetFeatureByName(f.Name + "_", false);
for (int j = 0; j < fs.Length; j++)
{
GSOFeature feature = fs[j];
GSOGeoModel model = feature.Geometry as GSOGeoModel;
style = new GSOEntityStyle3D();
style.UsingSingleColor = true;
style.EntityColor = Color.FromArgb(122, ((i % 2 == 0) ? listColors[j] : listColors[j + 2]));
model.Style = style;
}
}
globeControl1.Refresh();
MessageBox.Show("成功!");
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化