/// <summary> /// 刷新预览图 /// 适用于simpleMaker状态 /// </summary> private async Task refreshPreviewAsync() { //if (simpleMarkerSymbol == null) // return; if (simple_RB.Checked) { if (simpleMarkerSymbol == null) { return; } Esri.ArcGISRuntime.UI.RuntimeImage image = await simpleMarkerSymbol.CreateSwatchAsync(Color.WhiteSmoke); System.Windows.Media.ImageSource imageSource = await Esri.ArcGISRuntime.UI.RuntimeImageExtensions.ToImageSourceAsync(image); Image result = imageWpfToGDI(imageSource); previewBox.Image = result; previewBox.SizeMode = PictureBoxSizeMode.AutoSize | PictureBoxSizeMode.CenterImage; } else { if (pictureMarkerSymbol == null) { return; } Esri.ArcGISRuntime.UI.RuntimeImage image = await pictureMarkerSymbol.CreateSwatchAsync(Color.WhiteSmoke); System.Windows.Media.ImageSource imageSource = await Esri.ArcGISRuntime.UI.RuntimeImageExtensions.ToImageSourceAsync(image); Image result = imageWpfToGDI(imageSource); previewBox.Image = result; previewBox.SizeMode = PictureBoxSizeMode.AutoSize | PictureBoxSizeMode.CenterImage; } }
/// <summary> /// 由传进来的layer初始化simpleMaker的样式 /// </summary> private async void initLegend() { //初始化点样式 FeatureLayer feature = layer as FeatureLayer; SimpleRenderer simpleRenderer = feature.Renderer as SimpleRenderer; if (simpleRenderer != null) { //需要注意的是 这里不应该直接引用传递 否则在未确认的情况下也会影响到点的样式 simpleMarkerSymbol = simpleRenderer.Symbol.Clone() as SimpleMarkerSymbol; //如果为空则说明Symbol不为简单点样式 if (simpleMarkerSymbol == null) { //因为后面需要订阅事件 所以不能为null simpleMarkerSymbol = new SimpleMarkerSymbol(); pictureMarkerSymbol = simpleRenderer.Symbol.Clone() as PictureMarkerSymbol; if (pictureMarkerSymbol != null) { Esri.ArcGISRuntime.UI.RuntimeImage image = await pictureMarkerSymbol.CreateSwatchAsync(Color.WhiteSmoke); System.Windows.Media.ImageSource imageSource = await Esri.ArcGISRuntime.UI.RuntimeImageExtensions.ToImageSourceAsync(image); Image result = imageWpfToGDI(imageSource); previewBox.Image = result; previewBox.SizeMode = PictureBoxSizeMode.Zoom; simple_RB.Checked = false; customPic_RB.Checked = true; StyleCombox.Enabled = false; colorBtn.Enabled = false; sizeUpDown.Value = (decimal)pictureMarkerSymbol.Width + 1; transparencyControl.Value = MainWindow.getAlpha(pictureMarkerSymbol.Opacity); } } else { int index = findSelectIndex(x => { return(simpleMarkerSymbol.Style.ToString().Equals(x.ToString())); }); int count = ((List <SimpleMarkerSymbolStyle>)StyleCombox.DataSource).Count; //设置传入的layer的样式 simple_RB.Checked = true; StyleCombox.SelectedIndex = index; colorBtn.BackColor = simpleMarkerSymbol.Color; sizeUpDown.Value = (decimal)simpleMarkerSymbol.Size; transparencyControl.Value = simpleMarkerSymbol.Color.A; await refreshPreviewAsync(); } } //如果Layer是别的数据类型 else { } }