整理代码
This commit is contained in:
@@ -0,0 +1,536 @@
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace ShrlAlgo.RvKits.RvIndependent.MetroGauges.LandXMLData
|
||||
{
|
||||
[Serializable]
|
||||
public abstract class Unit
|
||||
{
|
||||
[XmlIgnore]
|
||||
public int AcadAngularUnit
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (_angularUnit)
|
||||
{
|
||||
default:
|
||||
return 179;
|
||||
|
||||
case LandXMLData.DirectionUnit.grads:
|
||||
return 180;
|
||||
|
||||
case LandXMLData.DirectionUnit.radians:
|
||||
return 178;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 178:
|
||||
_angularUnit = LandXMLData.DirectionUnit.radians;
|
||||
return;
|
||||
|
||||
default:
|
||||
_angularUnit = LandXMLData.DirectionUnit.decimal_degrees;
|
||||
return;
|
||||
|
||||
case 180:
|
||||
_angularUnit = LandXMLData.DirectionUnit.grads;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public int AcadAreaUnit
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (AreaUnit)
|
||||
{
|
||||
default:
|
||||
return 55;
|
||||
|
||||
case AreaUnit.squareFoot:
|
||||
return 56;
|
||||
|
||||
case AreaUnit.squareYard:
|
||||
return 93;
|
||||
|
||||
case AreaUnit.acre:
|
||||
return 57;
|
||||
|
||||
case AreaUnit.hectare:
|
||||
return 61;
|
||||
|
||||
case AreaUnit.squareKilometer:
|
||||
return 75;
|
||||
|
||||
case AreaUnit.squareMile:
|
||||
return 83;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value <= 75)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 55:
|
||||
case 58:
|
||||
case 59:
|
||||
case 60:
|
||||
break;
|
||||
|
||||
case 56:
|
||||
AreaUnit = AreaUnit.squareFoot;
|
||||
return;
|
||||
|
||||
case 57:
|
||||
AreaUnit = AreaUnit.acre;
|
||||
return;
|
||||
|
||||
case 61:
|
||||
AreaUnit = AreaUnit.hectare;
|
||||
return;
|
||||
|
||||
default:
|
||||
if (value == 75)
|
||||
{
|
||||
AreaUnit = AreaUnit.squareKilometer;
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value == 83)
|
||||
{
|
||||
AreaUnit = AreaUnit.squareMile;
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == 93)
|
||||
{
|
||||
AreaUnit = AreaUnit.squareYard;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AreaUnit = AreaUnit.squareMeter;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public int AcadDiameterUnit
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (DiameterUnit)
|
||||
{
|
||||
case DiameterUnit.meter:
|
||||
return 2;
|
||||
|
||||
case DiameterUnit.millimeter:
|
||||
return 25;
|
||||
|
||||
default:
|
||||
return 24;
|
||||
|
||||
case DiameterUnit.decimeter:
|
||||
return 23;
|
||||
|
||||
case DiameterUnit.kilometer:
|
||||
return 20;
|
||||
|
||||
case DiameterUnit.inch:
|
||||
return 31;
|
||||
|
||||
case DiameterUnit.foot:
|
||||
return 30;
|
||||
|
||||
case DiameterUnit.yard:
|
||||
return 33;
|
||||
|
||||
case DiameterUnit.mile:
|
||||
return 44;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value <= 25)
|
||||
{
|
||||
if (value == 2)
|
||||
{
|
||||
DiameterUnit = DiameterUnit.meter;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case 20:
|
||||
DiameterUnit = DiameterUnit.kilometer;
|
||||
return;
|
||||
|
||||
case 23:
|
||||
DiameterUnit = DiameterUnit.decimeter;
|
||||
return;
|
||||
|
||||
case 25:
|
||||
DiameterUnit = DiameterUnit.millimeter;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 30:
|
||||
DiameterUnit = DiameterUnit.foot;
|
||||
return;
|
||||
|
||||
case 31:
|
||||
DiameterUnit = DiameterUnit.inch;
|
||||
return;
|
||||
|
||||
case 32:
|
||||
break;
|
||||
|
||||
case 33:
|
||||
DiameterUnit = DiameterUnit.yard;
|
||||
return;
|
||||
|
||||
default:
|
||||
if (value == 44)
|
||||
{
|
||||
DiameterUnit = DiameterUnit.mile;
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DiameterUnit = DiameterUnit.centimeter;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public int AcadDirectionUnit
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (_directionUnit)
|
||||
{
|
||||
default:
|
||||
return 179;
|
||||
|
||||
case LandXMLData.DirectionUnit.grads:
|
||||
return 180;
|
||||
|
||||
case LandXMLData.DirectionUnit.radians:
|
||||
return 178;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 178:
|
||||
_directionUnit = LandXMLData.DirectionUnit.radians;
|
||||
return;
|
||||
|
||||
default:
|
||||
_directionUnit = LandXMLData.DirectionUnit.decimal_degrees;
|
||||
return;
|
||||
|
||||
case 180:
|
||||
_directionUnit = LandXMLData.DirectionUnit.grads;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public int AcadLinearUnit
|
||||
{
|
||||
get => LinearUnitId(LinearUnit);
|
||||
set
|
||||
{
|
||||
if (value <= 25)
|
||||
{
|
||||
if (value == 2)
|
||||
{
|
||||
LinearUnit = LinearUnit.meter;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case 20:
|
||||
LinearUnit = LinearUnit.kilometer;
|
||||
return;
|
||||
|
||||
case 23:
|
||||
LinearUnit = LinearUnit.decimeter;
|
||||
return;
|
||||
|
||||
case 25:
|
||||
LinearUnit = LinearUnit.milimeter;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 30:
|
||||
LinearUnit = LinearUnit.foot;
|
||||
return;
|
||||
|
||||
case 31:
|
||||
LinearUnit = LinearUnit.inch;
|
||||
return;
|
||||
|
||||
case 32:
|
||||
break;
|
||||
|
||||
case 33:
|
||||
LinearUnit = LinearUnit.yard;
|
||||
return;
|
||||
|
||||
default:
|
||||
if (value == 44)
|
||||
{
|
||||
LinearUnit = LinearUnit.mile;
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LinearUnit = LinearUnit.centimeter;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public int AcadVolumeUnit
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (VolumeUnit)
|
||||
{
|
||||
default:
|
||||
return 96;
|
||||
|
||||
case VolumeUnit.cubicInch:
|
||||
return 3;
|
||||
|
||||
case VolumeUnit.cubicFoot:
|
||||
return 130;
|
||||
|
||||
case VolumeUnit.cubicYard:
|
||||
return 153;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value <= 96)
|
||||
{
|
||||
if (value == 3)
|
||||
{
|
||||
VolumeUnit = VolumeUnit.cubicInch;
|
||||
return;
|
||||
}
|
||||
|
||||
if (value != 96) { }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value == 130)
|
||||
{
|
||||
VolumeUnit = VolumeUnit.cubicFoot;
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == 153)
|
||||
{
|
||||
VolumeUnit = VolumeUnit.cubicYard;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VolumeUnit = VolumeUnit.cubicMeter;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlAttribute("angularUnit")]
|
||||
public string AngularUnit
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (_angularUnit)
|
||||
{
|
||||
default:
|
||||
return "decimal degrees";
|
||||
|
||||
case LandXMLData.DirectionUnit.grads:
|
||||
return "grads";
|
||||
|
||||
case LandXMLData.DirectionUnit.radians:
|
||||
return "radians";
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && !(value == "decimal degrees"))
|
||||
{
|
||||
if (value == "grads")
|
||||
{
|
||||
_angularUnit = LandXMLData.DirectionUnit.grads;
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == "radians")
|
||||
{
|
||||
_angularUnit = LandXMLData.DirectionUnit.radians;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_angularUnit = LandXMLData.DirectionUnit.decimal_degrees;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlAttribute("directionUnit")]
|
||||
public string DirectionUnit
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (_directionUnit)
|
||||
{
|
||||
default:
|
||||
return "decimal degrees";
|
||||
|
||||
case LandXMLData.DirectionUnit.grads:
|
||||
return "grads";
|
||||
|
||||
case LandXMLData.DirectionUnit.radians:
|
||||
return "radians";
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && !(value == "decimal degrees"))
|
||||
{
|
||||
if (value == "grads")
|
||||
{
|
||||
_directionUnit = LandXMLData.DirectionUnit.grads;
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == "radians")
|
||||
{
|
||||
_directionUnit = LandXMLData.DirectionUnit.radians;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_directionUnit = LandXMLData.DirectionUnit.decimal_degrees;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlAttribute("areaUnit")]
|
||||
public AreaUnit AreaUnit { get; set; }
|
||||
|
||||
[XmlAttribute("diameterUnit")]
|
||||
public DiameterUnit DiameterUnit { get; set; }
|
||||
|
||||
[XmlIgnore]
|
||||
public DirectionUnit _directionUnit { get; set; }
|
||||
|
||||
[XmlIgnore]
|
||||
public DirectionUnit _angularUnit { get; set; }
|
||||
|
||||
[XmlAttribute("linearUnit")]
|
||||
public LinearUnit LinearUnit { get; set; }
|
||||
|
||||
[XmlAttribute("pressureUnit")]
|
||||
public PressureUnit PressureUnit { get; set; }
|
||||
|
||||
[XmlAttribute("temperatureUnit")]
|
||||
public TemperatureUnit TemperatureUnit { get; set; }
|
||||
|
||||
[XmlAttribute("volumeUnit")]
|
||||
public VolumeUnit VolumeUnit { get; set; }
|
||||
|
||||
public abstract void Initialize();
|
||||
|
||||
public static int LinearUnitId(LinearUnit linearUnit)
|
||||
{
|
||||
switch (linearUnit)
|
||||
{
|
||||
case LinearUnit.milimeter:
|
||||
return 25;
|
||||
|
||||
case LinearUnit.centimeter:
|
||||
return 24;
|
||||
|
||||
case LinearUnit.decimeter:
|
||||
return 23;
|
||||
|
||||
case LinearUnit.kilometer:
|
||||
return 20;
|
||||
|
||||
case LinearUnit.inch:
|
||||
return 31;
|
||||
|
||||
case LinearUnit.foot:
|
||||
return 30;
|
||||
|
||||
case LinearUnit.yard:
|
||||
return 33;
|
||||
|
||||
case LinearUnit.mile:
|
||||
return 44;
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
public static int LinearUnitIdCOM(LinearUnit linearUnit)
|
||||
{
|
||||
switch (linearUnit)
|
||||
{
|
||||
case LinearUnit.milimeter:
|
||||
return 7;
|
||||
|
||||
case LinearUnit.centimeter:
|
||||
return 8;
|
||||
|
||||
case LinearUnit.decimeter:
|
||||
return 9;
|
||||
|
||||
case LinearUnit.kilometer:
|
||||
return 2;
|
||||
|
||||
case LinearUnit.inch:
|
||||
return 4;
|
||||
|
||||
case LinearUnit.foot:
|
||||
return 3;
|
||||
|
||||
case LinearUnit.yard:
|
||||
return 5;
|
||||
|
||||
case LinearUnit.mile:
|
||||
return 6;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user