public enum UnitFormatType : System.Enum, System.IComparable, System.IConvertible, System.IFormattable
Public Enum UnitFormatType Inherits System.Enum Implements System.IComparable, System.IConvertible, System.IFormattable
public enum UnitFormatType : System.Enum, System.IComparable, System.IConvertible, System.IFormattable
Public Enum UnitFormatType Inherits System.Enum Implements System.IComparable, System.IConvertible, System.IFormattable
Member | Description |
---|---|
Angular | Angular |
Area | Area |
Direction | Direction |
Distance | Distance |
Location | Location |
Page | Page |
Symbol2D | Symbol 2D |
Symbol3D | Symbol 3D |
//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
System.ValueType
System.Enum
ArcGIS.Desktop.Core.UnitFormats.UnitFormatType
Target Platforms: Windows 11, Windows 10