462 lines
16 KiB
C#
462 lines
16 KiB
C#
using System.Globalization;
|
|
using System.Linq.Expressions;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Xml.Serialization;
|
|
using Microsoft.CSharp.RuntimeBinder;
|
|
|
|
namespace ShrlAlgoToolkit.RevitAddins.RvIndependent.MetroGauges.LandXMLData
|
|
{
|
|
[Serializable]
|
|
public class TextPoint2D : Point3D
|
|
{
|
|
public TextPoint2D()
|
|
{
|
|
_first = 0.0;
|
|
_second = 0.0;
|
|
_text = "0 0";
|
|
}
|
|
|
|
public TextPoint2D(TextPoint2D source)
|
|
: base(source)
|
|
{
|
|
_first = source._first;
|
|
_second = source._second;
|
|
_text = source._text;
|
|
}
|
|
|
|
public TextPoint2D(dynamic xyz, dynamic point)
|
|
{
|
|
if (Constructor.p__Sitee == null)
|
|
{
|
|
Constructor.p__Sitee = CallSite<Func<CallSite, object, string>>.Create(
|
|
Binder.Convert(CSharpBinderFlags.None, typeof(string), typeof(TextPoint2D))
|
|
);
|
|
}
|
|
|
|
Func<CallSite, object, string> target = Constructor.p__Sitee.Target;
|
|
CallSite p__Sitee = Constructor.p__Sitee;
|
|
if (Constructor.p__Sitef == null)
|
|
{
|
|
Constructor.p__Sitef = CallSite<Func<CallSite, object, object, object>>.Create(
|
|
Binder.BinaryOperation(
|
|
CSharpBinderFlags.None,
|
|
ExpressionType.Add,
|
|
typeof(TextPoint2D),
|
|
new[]
|
|
{
|
|
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
|
|
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
|
|
}
|
|
)
|
|
);
|
|
}
|
|
|
|
Func<CallSite, object, object, object> target2 = Constructor.p__Sitef.Target;
|
|
CallSite p__Sitef = Constructor.p__Sitef;
|
|
if (Constructor.p__Site10 == null)
|
|
{
|
|
Constructor.p__Site10 = CallSite<Func<CallSite, object, string, object>>.Create(
|
|
Binder.BinaryOperation(
|
|
CSharpBinderFlags.None,
|
|
ExpressionType.Add,
|
|
typeof(TextPoint2D),
|
|
new[]
|
|
{
|
|
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
|
|
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
|
|
}
|
|
)
|
|
);
|
|
}
|
|
|
|
Func<CallSite, object, string, object> target3 = Constructor.p__Site10.Target;
|
|
CallSite p__Site = Constructor.p__Site10;
|
|
if (Constructor.p__Site11 == null)
|
|
{
|
|
Constructor.p__Site11 = CallSite<Func<CallSite, object, object>>.Create(
|
|
Binder.InvokeMember(
|
|
CSharpBinderFlags.None,
|
|
"ToString",
|
|
null,
|
|
typeof(TextPoint2D),
|
|
new[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }
|
|
)
|
|
);
|
|
}
|
|
|
|
Func<CallSite, object, object> target4 = Constructor.p__Site11.Target;
|
|
CallSite p__Site2 = Constructor.p__Site11;
|
|
if (Constructor.p__Site12 == null)
|
|
{
|
|
Constructor.p__Site12 = CallSite<Func<CallSite, object, int, object>>.Create(
|
|
Binder.GetIndex(
|
|
CSharpBinderFlags.None,
|
|
typeof(TextPoint2D),
|
|
new[]
|
|
{
|
|
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
|
|
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
|
|
}
|
|
)
|
|
);
|
|
}
|
|
|
|
object arg = target3(p__Site, target4(p__Site2, Constructor.p__Site12.Target(Constructor.p__Site12, point, 1)), " ");
|
|
if (Constructor.p__Site13 == null)
|
|
{
|
|
Constructor.p__Site13 = CallSite<Func<CallSite, object, object>>.Create(
|
|
Binder.InvokeMember(
|
|
CSharpBinderFlags.None,
|
|
"ToString",
|
|
null,
|
|
typeof(TextPoint2D),
|
|
new[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }
|
|
)
|
|
);
|
|
}
|
|
|
|
Func<CallSite, object, object> target5 = Constructor.p__Site13.Target;
|
|
CallSite p__Site3 = Constructor.p__Site13;
|
|
if (Constructor.p__Site14 == null)
|
|
{
|
|
Constructor.p__Site14 = CallSite<Func<CallSite, object, int, object>>.Create(
|
|
Binder.GetIndex(
|
|
CSharpBinderFlags.None,
|
|
typeof(TextPoint2D),
|
|
new[]
|
|
{
|
|
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
|
|
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
|
|
}
|
|
)
|
|
);
|
|
}
|
|
|
|
Text = target(p__Sitee, target2(p__Sitef, arg, target5(p__Site3, Constructor.p__Site14.Target(Constructor.p__Site14, point, 0))));
|
|
if (Constructor.p__Site15 == null)
|
|
{
|
|
Constructor.p__Site15 = CallSite<Func<CallSite, object, double>>.Create(
|
|
Binder.Convert(CSharpBinderFlags.None, typeof(double), typeof(TextPoint2D))
|
|
);
|
|
}
|
|
|
|
Func<CallSite, object, double> target6 = Constructor.p__Site15.Target;
|
|
CallSite p__Site4 = Constructor.p__Site15;
|
|
if (Constructor.p__Site16 == null)
|
|
{
|
|
Constructor.p__Site16 = CallSite<Func<CallSite, object, int, object>>.Create(
|
|
Binder.GetIndex(
|
|
CSharpBinderFlags.None,
|
|
typeof(TextPoint2D),
|
|
new[]
|
|
{
|
|
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
|
|
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
|
|
}
|
|
)
|
|
);
|
|
}
|
|
|
|
X = target6(p__Site4, Constructor.p__Site16.Target(Constructor.p__Site16, xyz, 0));
|
|
if (Constructor.p__Site17 == null)
|
|
{
|
|
Constructor.p__Site17 = CallSite<Func<CallSite, object, double>>.Create(
|
|
Binder.Convert(CSharpBinderFlags.None, typeof(double), typeof(TextPoint2D))
|
|
);
|
|
}
|
|
|
|
Func<CallSite, object, double> target7 = Constructor.p__Site17.Target;
|
|
CallSite p__Site5 = Constructor.p__Site17;
|
|
if (Constructor.p__Site18 == null)
|
|
{
|
|
Constructor.p__Site18 = CallSite<Func<CallSite, object, int, object>>.Create(
|
|
Binder.GetIndex(
|
|
CSharpBinderFlags.None,
|
|
typeof(TextPoint2D),
|
|
new[]
|
|
{
|
|
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
|
|
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
|
|
}
|
|
)
|
|
);
|
|
}
|
|
|
|
Y = target7(p__Site5, Constructor.p__Site18.Target(Constructor.p__Site18, xyz, 1));
|
|
if (Constructor.p__Site19 == null)
|
|
{
|
|
Constructor.p__Site19 = CallSite<Func<CallSite, object, double>>.Create(
|
|
Binder.Convert(CSharpBinderFlags.None, typeof(double), typeof(TextPoint2D))
|
|
);
|
|
}
|
|
|
|
Func<CallSite, object, double> target8 = Constructor.p__Site19.Target;
|
|
CallSite p__Site6 = Constructor.p__Site19;
|
|
if (Constructor.p__Site1a == null)
|
|
{
|
|
Constructor.p__Site1a = CallSite<Func<CallSite, object, int, object>>.Create(
|
|
Binder.GetIndex(
|
|
CSharpBinderFlags.None,
|
|
typeof(TextPoint2D),
|
|
new[]
|
|
{
|
|
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
|
|
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
|
|
}
|
|
)
|
|
);
|
|
}
|
|
|
|
Z = target8(p__Site6, Constructor.p__Site1a.Target(Constructor.p__Site1a, xyz, 2));
|
|
}
|
|
|
|
protected double _first;
|
|
|
|
protected double _second;
|
|
|
|
protected string _text;
|
|
|
|
[XmlIgnore]
|
|
public double First
|
|
{
|
|
get => _first;
|
|
set
|
|
{
|
|
if (_first != value)
|
|
{
|
|
_first = value;
|
|
_text = _first.ToString(CultureInfo.InvariantCulture) + " " + _second.ToString(CultureInfo.InvariantCulture);
|
|
}
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public double Second
|
|
{
|
|
get => _second;
|
|
set
|
|
{
|
|
if (_second != value)
|
|
{
|
|
_second = value;
|
|
_text = _first.ToString(CultureInfo.InvariantCulture) + " " + _second.ToString(CultureInfo.InvariantCulture);
|
|
}
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public double SinTextAngle
|
|
{
|
|
get
|
|
{
|
|
if (Second == 0.0)
|
|
{
|
|
return 0.0;
|
|
}
|
|
|
|
return Second / TextLength;
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public double TanTextAngle
|
|
{
|
|
get
|
|
{
|
|
if (Second == 0.0)
|
|
{
|
|
return 0.0;
|
|
}
|
|
|
|
if (First == 0.0)
|
|
{
|
|
return double.PositiveInfinity;
|
|
}
|
|
|
|
return Second / First;
|
|
}
|
|
}
|
|
|
|
[XmlText]
|
|
public string Text
|
|
{
|
|
get => _text;
|
|
set
|
|
{
|
|
if (_text != value)
|
|
{
|
|
_text = value;
|
|
if (_text != null && _text.Contains(' '))
|
|
{
|
|
string[] array = _text.Split(' ');
|
|
if (array.Length > 1)
|
|
{
|
|
double.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out _first);
|
|
double.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out _second);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public double TextAngle
|
|
{
|
|
get
|
|
{
|
|
double num =
|
|
Second != 0.0
|
|
? First != 0.0
|
|
? Math.Asin(Second / TextLength)
|
|
: Math.Sign(Second) * 3.1415926535897931 * 0.5
|
|
: 0.0;
|
|
if (First >= 0.0)
|
|
{
|
|
return num;
|
|
}
|
|
|
|
return 3.1415926535897931 - num;
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
public double TextLength => Math.Sqrt(TextLengthSquared);
|
|
|
|
[XmlIgnore]
|
|
public double TextLengthSquared => First * First + Second * Second;
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
return Equals(obj as TextPoint2D);
|
|
}
|
|
|
|
public bool Equals(TextPoint2D p2d)
|
|
{
|
|
return !ReferenceEquals(p2d, null) && ValuesEqual(this, p2d);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
|
|
public static TextPoint2D operator +(TextPoint2D p1, TextPoint2D p2)
|
|
{
|
|
if (p1 != null)
|
|
{
|
|
if (p2 != null)
|
|
{
|
|
return new TextPoint2D
|
|
{
|
|
X = p1.X + p2.X,
|
|
Y = p1.Y + p2.Y,
|
|
Z = p1.Z + p2.Z,
|
|
_first = p1._first + p2._first,
|
|
Second = p1._second + p2._second
|
|
};
|
|
}
|
|
|
|
return p1;
|
|
}
|
|
|
|
if (p2 != null)
|
|
{
|
|
return p2;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public static bool operator ==(TextPoint2D p1, TextPoint2D p2)
|
|
{
|
|
return ReferenceEquals(p1, p2) || (!ReferenceEquals(p1, null) && !ReferenceEquals(p2, null) && ValuesEqual(p1, p2));
|
|
}
|
|
|
|
public static bool operator !=(TextPoint2D p1, TextPoint2D p2)
|
|
{
|
|
return !ReferenceEquals(p1, p2) && (ReferenceEquals(p1, null) || ReferenceEquals(p2, null) || !ValuesEqual(p1, p2));
|
|
}
|
|
|
|
public static TextPoint2D operator -(TextPoint2D p1, TextPoint2D p2)
|
|
{
|
|
if (p1 != null)
|
|
{
|
|
if (p2 != null)
|
|
{
|
|
return new TextPoint2D
|
|
{
|
|
X = p1.X - p2.X,
|
|
Y = p1.Y - p2.Y,
|
|
Z = p1.Z - p2.Z,
|
|
_first = p1._first - p2._first,
|
|
Second = p1._second - p2._second
|
|
};
|
|
}
|
|
|
|
return p1;
|
|
}
|
|
|
|
if (p2 != null)
|
|
{
|
|
return new TextPoint2D
|
|
{
|
|
X = -p2.X,
|
|
Y = -p2.Y,
|
|
Z = -p2.Z,
|
|
_first = -p1._first,
|
|
Second = -p2._second
|
|
};
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public void setText(double x, double y)
|
|
{
|
|
_text = x.ToString(CultureInfo.InvariantCulture) + " " + y.ToString(CultureInfo.InvariantCulture);
|
|
_first = x;
|
|
_second = y;
|
|
}
|
|
|
|
public void Transform(GeometryTransformations transformations, bool dz)
|
|
{
|
|
setText(First * transformations.ScaleFactor, Second * transformations.ScaleFactor + (dz ? transformations.Dz : 0.0));
|
|
transformations.Transform(this);
|
|
}
|
|
|
|
public static bool ValuesEqual(TextPoint2D p1, TextPoint2D p2)
|
|
{
|
|
return p1.Text == p2.Text && Point3D.ValuesEqual(p1, p2);
|
|
}
|
|
|
|
[CompilerGenerated]
|
|
private static class Constructor
|
|
{
|
|
public static CallSite<Func<CallSite, object, string, object>> p__Site10;
|
|
|
|
public static CallSite<Func<CallSite, object, object>> p__Site11;
|
|
|
|
public static CallSite<Func<CallSite, object, int, object>> p__Site12;
|
|
|
|
public static CallSite<Func<CallSite, object, object>> p__Site13;
|
|
|
|
public static CallSite<Func<CallSite, object, int, object>> p__Site14;
|
|
|
|
public static CallSite<Func<CallSite, object, double>> p__Site15;
|
|
|
|
public static CallSite<Func<CallSite, object, int, object>> p__Site16;
|
|
|
|
public static CallSite<Func<CallSite, object, double>> p__Site17;
|
|
|
|
public static CallSite<Func<CallSite, object, int, object>> p__Site18;
|
|
|
|
public static CallSite<Func<CallSite, object, double>> p__Site19;
|
|
|
|
public static CallSite<Func<CallSite, object, int, object>> p__Site1a;
|
|
public static CallSite<Func<CallSite, object, string>> p__Sitee;
|
|
|
|
public static CallSite<Func<CallSite, object, object, object>> p__Sitef;
|
|
}
|
|
}
|
|
}
|