public CIMColorRamp ColorRamp {get; set;}
Public Property ColorRamp As CIMColorRamp
public CIMColorRamp ColorRamp {get; set;}
Public Property ColorRamp As CIMColorRamp
Exception | Description |
---|---|
ArcGIS.Core.CalledOnWrongThreadException | This property must be called within the lambda passed to QueuedTask.Run |
ColorRampStyleItem colorRampItem = null; CIMColorRamp colorRamp = await QueuedTask.Run<CIMColorRamp>(() => { return colorRampItem.ColorRamp; });
public async Task ApplyColorRampAsync(FeatureLayer featureLayer, List<string> fields) { StyleProjectItem style = Project.Current.GetItems<StyleProjectItem>() .FirstOrDefault(s => s.Name == "ColorBrewer Schemes (RGB)"); if (style == null) return; var colorRampList = await QueuedTask.Run(() => style.SearchColorRamps("Red-Gray (10 Classes)")); if (colorRampList == null || colorRampList.Count == 0) return; CIMColorRamp cimColorRamp = null; CIMRenderer renderer = null; await QueuedTask.Run(() => { cimColorRamp = colorRampList[0].ColorRamp; var rendererDef = new UniqueValueRendererDefinition(fields, null, cimColorRamp); renderer = featureLayer?.CreateRenderer(rendererDef); featureLayer?.SetRenderer(renderer); }); }
string colorBrewerSchemesName = "ColorBrewer Schemes (RGB)"; StyleProjectItem style = Project.Current.GetItems<StyleProjectItem>().First(s => s.Name == colorBrewerSchemesName); string colorRampName = "Greens (Continuous)"; IList<ColorRampStyleItem> colorRampList = await QueuedTask.Run(() => { return style.SearchColorRamps(colorRampName); }); ColorRampStyleItem colorRamp = colorRampList[0]; await QueuedTask.Run(() => { GraduatedColorsRendererDefinition gcDef = new GraduatedColorsRendererDefinition() { ClassificationField = "CROP_ACR07", ClassificationMethod = ArcGIS.Core.CIM.ClassificationMethod.NaturalBreaks, BreakCount = 6, ColorRamp = colorRamp.ColorRamp, SymbolTemplate = SymbolFactory.Instance.ConstructPolygonSymbol( ColorFactory.Instance.GreenRGB, SimpleFillStyle.Solid, null).MakeSymbolReference(), ExclusionClause = "CROP_ACR07 = -99", ExclusionSymbol = SymbolFactory.Instance.ConstructPolygonSymbol( ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, null).MakeSymbolReference(), ExclusionLabel = "No yield", }; var featureLayerCreationParams = new FeatureLayerCreationParams((new Uri(@"c:\Data\CountyData.gdb\Counties"))) { Name = "Crop", RendererDefinition = gcDef }; LayerFactory.Instance.CreateLayer<FeatureLayer>(featureLayerCreationParams, MapView.Active.Map); });
//Must be called on the MCT //var pcsl = ...; //At 2.x - var fields = pcsl.QueryAvailablePointCloudRendererFields( // PointCloudRendererType.StretchRenderer); var fields = pcsl.GetAvailablePointCloudRendererFields( PointCloudRendererType.StretchRenderer); var stretchDef = new PointCloudRendererDefinition( PointCloudRendererType.StretchRenderer) { //Will be either ELEVATION or INTENSITY Field = fields[0] }; //Create the CIM Renderer var stretchRenderer = pcsl.CreateRenderer(stretchDef) as CIMPointCloudStretchRenderer; //Apply a color ramp var style = Project.Current.GetItems<StyleProjectItem>() .First(s => s.Name == "ArcGIS Colors"); var colorRamp = style.SearchColorRamps("").First(); stretchRenderer.ColorRamp = colorRamp.ColorRamp; //Apply modulation stretchRenderer.ColorModulation = new CIMColorModulationInfo() { MinValue = 0, MaxValue = 100 }; //apply the renderer pcsl.SetRenderer(stretchRenderer);
//Must be called on the MCT //var pcsl = ...; //At 2.x - var fields = pcsl.QueryAvailablePointCloudRendererFields( // PointCloudRendererType.ClassBreaksRenderer); var fields = pcsl.GetAvailablePointCloudRendererFields( PointCloudRendererType.ClassBreaksRenderer); var classBreakDef = new PointCloudRendererDefinition( PointCloudRendererType.ClassBreaksRenderer) { //ELEVATION or INTENSITY Field = fields[0] }; //create the renderer var cbr = pcsl.CreateRenderer(classBreakDef) as CIMPointCloudClassBreaksRenderer; //Set up a color scheme to use var style = Project.Current.GetItems<StyleProjectItem>() .First(s => s.Name == "ArcGIS Colors"); var rampStyle = style.LookupItem( StyleItemType.ColorRamp, "Spectrum By Wavelength-Full Bright_Multi-hue_2") as ColorRampStyleItem; var colorScheme = rampStyle.ColorRamp; //Set up 6 manual class breaks var breaks = 6; var colors = ColorFactory.Instance.GenerateColorsFromColorRamp( colorScheme, breaks); var classBreaks = new List<CIMColorClassBreak>(); var min = cbr.Breaks[0].UpperBound; var max = cbr.Breaks[cbr.Breaks.Count() - 1].UpperBound; var step = (max - min) / (double)breaks; //add in the class breaks double upper = min; for (int b = 1; b <= breaks; b++) { double lower = upper; upper = b == breaks ? max : min + (b * step); var cb = new CIMColorClassBreak() { UpperBound = upper, Label = string.Format("{0:#0.0#} - {1:#0.0#}", lower, upper), Color = colors[b - 1] }; classBreaks.Add(cb); } cbr.Breaks = classBreaks.ToArray(); pcsl.SetRenderer(cbr);
Target Platforms: Windows 11, Windows 10