Hi Guys,
Below is my current code snippet.
I want to change my custom scale bar number format to be whole number without decimal place.
And would like to change the Kilometer wording Label as well.
Have any idea to do it?
StyleProjectItem arcgis_2dStyle <SPAN class="operator token">=</SPAN> Project<SPAN class="punctuation token">.</SPAN>Current<SPAN class="punctuation token">.</SPAN>GetItems<SPAN class="operator token"><</SPAN>StyleProjectItem<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">First</SPAN><SPAN class="punctuation token">(</SPAN>si <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> si<SPAN class="punctuation token">.</SPAN>Name <SPAN class="operator token">==</SPAN> <SPAN class="string token">"ArcGIS 2D"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Construct on the worker thread</SPAN>
QueuedTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Run</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">//Reference the specific scale bar by name </SPAN>
ScaleBarStyleItem scaleBarItem <SPAN class="operator token">=</SPAN> arcgis_2dStyle<SPAN class="punctuation token">.</SPAN><SPAN class="token function">SearchScaleBars</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Alternating Scale Bar 1 Metric"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">FirstOrDefault</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">double</SPAN> GuessX <SPAN class="operator token">=</SPAN> <SPAN class="number token">0.5</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">double</SPAN> GuessY <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Reference the map frame and define the location </SPAN>
Coordinate2D coord2D <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Coordinate2D</SPAN><SPAN class="punctuation token">(</SPAN>GuessX<SPAN class="punctuation token">,</SPAN> GuessY<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Construct the scale bar</SPAN>
ScaleBar settedBar <SPAN class="operator token">=</SPAN> LayoutElementFactory<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN><SPAN class="token function">CreateScaleBar</SPAN><SPAN class="punctuation token">(</SPAN>activeLayoutView<SPAN class="punctuation token">.</SPAN>Layout<SPAN class="punctuation token">,</SPAN> coord2D<SPAN class="punctuation token">,</SPAN> activedMapFrame<SPAN class="punctuation token">,</SPAN> scaleBarItem<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
settedBar<SPAN class="punctuation token">.</SPAN><SPAN class="token function">SetName</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Custom Scale bar"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
CIMDoubleFillScaleBar scaleBarElement <SPAN class="operator token">=</SPAN> settedBar<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetDefinition</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> CIMDoubleFillScaleBar<SPAN class="punctuation token">;</SPAN>
scaleBarElement<SPAN class="punctuation token">.</SPAN>UnitLabelPosition <SPAN class="operator token">=</SPAN> ScaleBarLabelPosition<SPAN class="punctuation token">.</SPAN>Below<SPAN class="punctuation token">;</SPAN>
scaleBarElement<SPAN class="punctuation token">.</SPAN>Division <SPAN class="operator token">=</SPAN> <SPAN class="number token">5</SPAN><SPAN class="punctuation token">;</SPAN>
scaleBarElement<SPAN class="punctuation token">.</SPAN>Subdivisions <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">;</SPAN>
scaleBarElement<SPAN class="punctuation token">.</SPAN>DivisionsBeforeZero <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">;</SPAN>
scaleBarElement<SPAN class="punctuation token">.</SPAN>DivisionsBeforeZero <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">;</SPAN>
scaleBarElement<SPAN class="punctuation token">.</SPAN>LabelFrequency <SPAN class="operator token">=</SPAN> ScaleBarFrequency<SPAN class="punctuation token">.</SPAN>Divisions<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Division resize behavior -> adjust width</SPAN>
<SPAN class="comment token">//Division Value -> how to dynamically appropriately add the value(to be 50) or dynamic width, </SPAN>
<SPAN class="comment token">//interval will be whole number(Need to figure out)</SPAN>
<SPAN class="comment token">//scaleBarElement.NumberFormat = </SPAN>
<SPAN class="comment token">//Need to change label text to Kilometres</SPAN>
scaleBarElement<SPAN class="punctuation token">.</SPAN>BarHeight <SPAN class="operator token">=</SPAN> <SPAN class="number token">3</SPAN><SPAN class="punctuation token">;</SPAN>
settedBar<SPAN class="punctuation token">.</SPAN><SPAN class="token function">SetDefinition</SPAN><SPAN class="punctuation token">(</SPAN>scaleBarElement<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN> ps<SPAN class="punctuation token">.</SPAN>Progressor<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Thank in advance 