public static async Task DisplayScaleBarAsync(Layout layout, string mapFrameName) { var arcgis_2d = Project.Current.GetItems <StyleProjectItem>().First(si => si.Name == "ArcGIS 2D"); await QueuedTask.Run(() => { if (arcgis_2d != null) { var scaleBars = arcgis_2d.SearchScaleBars("Alternating Scale Bar"); if (scaleBars == null || scaleBars.Count == 0) { return; } ScaleBarStyleItem scaleBarStyleItem = scaleBars[0]; //Reference the map frame and define the location MapFrame mapFrame = layout.FindElement(mapFrameName) as MapFrame; Coordinate2D location = new Coordinate2D(3.8, 0.3); //Construct the scale bar ScaleBar scaleBar = LayoutElementFactory.Instance.CreateScaleBar(layout, location, mapFrame, scaleBarStyleItem); CIMScaleBar cimScaleBar = (CIMScaleBar)scaleBar.GetDefinition(); cimScaleBar.Divisions = 2; cimScaleBar.Subdivisions = 4; cimScaleBar.DivisionsBeforeZero = 1; cimScaleBar.MarkFrequency = ScaleBarFrequency.Divisions; cimScaleBar.MarkPosition = ScaleBarVerticalPosition.Above; cimScaleBar.UnitLabelPosition = ScaleBarLabelPosition.AfterLabels; scaleBar.SetDefinition(cimScaleBar); } }); }
public async void Examples() { #region Get symbol from SymbolStyleItem SymbolStyleItem symbolItem = null; CIMSymbol symbol = await QueuedTask.Run <CIMSymbol>(() => { return(symbolItem.Symbol); }); #endregion #region Get color from ColorStyleItem ColorStyleItem colorItem = null; CIMColor color = await QueuedTask.Run <CIMColor>(() => { return(colorItem.Color); }); #endregion #region Get color ramp from ColorRampStyleItem ColorRampStyleItem colorRampItem = null; CIMColorRamp colorRamp = await QueuedTask.Run <CIMColorRamp>(() => { return(colorRampItem.ColorRamp); }); #endregion #region Get north arrow from NorthArrowStyleItem NorthArrowStyleItem northArrowItem = null; CIMNorthArrow northArrow = await QueuedTask.Run <CIMNorthArrow>(() => { return(northArrowItem.NorthArrow); }); #endregion #region Get scale bar from ScaleBarStyleItem ScaleBarStyleItem scaleBarItem = null; CIMScaleBar scaleBar = await QueuedTask.Run <CIMScaleBar>(() => { return(scaleBarItem.ScaleBar); }); #endregion #region Get label placement from LabelPlacementStyleItem LabelPlacementStyleItem labelPlacementItem = null; CIMLabelPlacementProperties labelPlacement = await QueuedTask.Run <CIMLabelPlacementProperties>(() => { return(labelPlacementItem.LabelPlacement); }); #endregion #region Get grid from GridStyleItem GridStyleItem gridItem = null; CIMMapGrid grid = await QueuedTask.Run <CIMMapGrid>(() => { return(gridItem.Grid); }); #endregion #region Get legend from LegendStyleItem LegendStyleItem legendItem = null; CIMLegend legend = await QueuedTask.Run <CIMLegend>(() => { return(legendItem.Legend); }); #endregion #region Get table frame from TableFrameStyleItem TableFrameStyleItem tableFrameItem = null; CIMTableFrame tableFrame = await QueuedTask.Run <CIMTableFrame>(() => { return(tableFrameItem.TableFrame); }); #endregion #region Get map surround from MapSurroundStyleItem MapSurroundStyleItem mapSurroundItem = null; CIMMapSurround mapSurround = await QueuedTask.Run <CIMMapSurround>(() => { return(mapSurroundItem.MapSurround); }); #endregion }