public class DisplayUnitFormats : IDisplayUnitFormats
Public Class DisplayUnitFormats Implements IDisplayUnitFormats
public class DisplayUnitFormats : IDisplayUnitFormats
Public Class DisplayUnitFormats Implements IDisplayUnitFormats
//Must be on the QueuedTask.Run() var unit_formats = Enum.GetValues(typeof(UnitFormatType)) .OfType<UnitFormatType>().ToList(); System.Diagnostics.Debug.WriteLine("All available units\r\n"); foreach (var unit_format in unit_formats) { var units = DisplayUnitFormats.Instance.GetPredefinedProjectUnitFormats(unit_format); System.Diagnostics.Debug.WriteLine(unit_format.ToString()); foreach (var display_unit_format in units) { var line = $"{display_unit_format.DisplayName}, {display_unit_format.UnitCode}"; System.Diagnostics.Debug.WriteLine(line); } System.Diagnostics.Debug.WriteLine(""); }
//Must be on the QueuedTask.Run() var unit_formats = Enum.GetValues(typeof(UnitFormatType)) .OfType<UnitFormatType>().ToList(); System.Diagnostics.Debug.WriteLine("Project units\r\n"); foreach (var unit_format in unit_formats) { var units = DisplayUnitFormats.Instance.GetProjectUnitFormats(unit_format); System.Diagnostics.Debug.WriteLine(unit_format.ToString()); foreach (var display_unit_format in units) { var line = $"{display_unit_format.DisplayName}, {display_unit_format.UnitCode}"; System.Diagnostics.Debug.WriteLine(line); } System.Diagnostics.Debug.WriteLine(""); }
//Must be on the QueuedTask.Run() //UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance, //UnitFormatType.Direction, UnitFormatType.Location, UnitFormatType.Page //UnitFormatType.Symbol2D, UnitFormatType.Symbol3D var units = DisplayUnitFormats.Instance.GetProjectUnitFormats(UnitFormatType.Distance);
//Must be on the QueuedTask.Run() var unit_formats = Enum.GetValues(typeof(UnitFormatType)) .OfType<UnitFormatType>().ToList(); System.Diagnostics.Debug.WriteLine("Default project units\r\n"); foreach (var unit_format in unit_formats) { var default_unit = DisplayUnitFormats.Instance.GetDefaultProjectUnitFormat(unit_format); var line = $"{unit_format.ToString()}: {default_unit.DisplayName}, {default_unit.UnitCode}"; System.Diagnostics.Debug.WriteLine(line); } System.Diagnostics.Debug.WriteLine("");
//Must be on the QueuedTask.Run() //UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance, //UnitFormatType.Direction, UnitFormatType.Location, UnitFormatType.Page //UnitFormatType.Symbol2D, UnitFormatType.Symbol3D var default_unit = DisplayUnitFormats.Instance.GetDefaultProjectUnitFormat( UnitFormatType.Distance);
//Must be on the QueuedTask.Run() //UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance, //UnitFormatType.Direction, UnitFormatType.Location //Get the full list of all available location units var all_units = DisplayUnitFormats.Instance.GetPredefinedProjectUnitFormats( UnitFormatType.Location); //keep units with an even factory code var list_units = all_units.Where(du => du.UnitCode % 2 == 0).ToList(); //set them as the new location unit collection. A new default is not being specified... DisplayUnitFormats.Instance.SetProjectUnitFormats(list_units); //set them as the new location unit collection along with a new default DisplayUnitFormats.Instance.SetProjectUnitFormats( list_units, list_units.First()); //Note: UnitFormatType.Page, UnitFormatType.Symbol2D, UnitFormatType.Symbol3D //cannot be set.
//Must be on the QueuedTask.Run() var unit_formats = Enum.GetValues(typeof(UnitFormatType)).OfType<UnitFormatType>().ToList(); foreach (var unit_type in unit_formats) { var current_default = DisplayUnitFormats.Instance.GetDefaultProjectUnitFormat(unit_type); //Arbitrarily pick the last unit in each unit format list var replacement = DisplayUnitFormats.Instance.GetProjectUnitFormats(unit_type).Last(); DisplayUnitFormats.Instance.SetDefaultProjectUnitFormat(replacement); var line = $"{current_default.DisplayName}, {current_default.UnitName}, {current_default.UnitCode}"; var line2 = $"{replacement.DisplayName}, {replacement.UnitName}, {replacement.UnitCode}"; System.Diagnostics.Debug.WriteLine($"Format: {unit_type.ToString()}"); System.Diagnostics.Debug.WriteLine($" Current default: {line}"); System.Diagnostics.Debug.WriteLine($" Replacement default: {line2}"); }
//UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance, //UnitFormatType.Direction, UnitFormatType.Location var angle_units = DisplayUnitFormats.Instance.GetProjectUnitFormats(UnitFormatType.Angular); //Edit the display name of each unit - append the abbreviation foreach (var unit in angle_units) { unit.DisplayName = $"{unit.DisplayName} ({unit.Abbreviation})"; } //apply the changes to the units and set the default to be the first entry DisplayUnitFormats.Instance.SetProjectUnitFormats(angle_units, angle_units.First()); //The project must be saved to persist the changes...
System.Object
ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormats
Target Platforms: Windows 11, Windows 10, Windows 8.1