本文整理汇总了C#中Segment类的典型用法代码示例。如果您正苦于以下问题:C# Segment类的具体用法?C# Segment怎么用?C# Segment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Segment类属于命名空间,在下文中一共展示了Segment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createChangeLine
private CustomerOrderChangeLine createChangeLine(Segment lineSeg)
{
SegmentCount++;
string[] arr = GetEls(lineSeg);
var line = new CustomerOrderChangeLine
{
LineNumber = arr[1].CastToInt(),
RequestedQuantity = arr[3].CastToInt(),
QtyLeftToReceive = arr[4].CastToInt(),
RequestedPrice = arr[6].CastToDecimal(),
ChangeCode = arr[2]
};
for (int i = 8; i < arr.Length - 1; i++)
{
if (arr[i] == "IN" || arr[i] == "BP")
{
line.CustomerPartNumber = arr[i + 1];
}
if (arr[i] == "PD")
line.ItemDescription = arr[i + 1];
if (arr[i] == "VN" || arr[i] == "VP")
line.ItemId = arr[i + 1];
}
return line;
}
示例2: ToEndTest
public void ToEndTest()
{
Segment container = new Segment(2, 5);
var aligned = container.AlignToEnd(2);
Assert.Equal(new Segment(3, 5), aligned);
}
示例3: ToMiddleTest2
public void ToMiddleTest2()
{
Segment container = new Segment(0, 500);
var aligned = container.AlignToMiddle(200);
Assert.Equal(new Segment(150, 350), aligned);
}
示例4: SegmentIteratorFrom
public SegmentIteratorFrom(Segment firstSegment)
{
Contract.Ensures(firstSegment != null);
_firstSegment = firstSegment;
Reset();
}
示例5: isEdge
bool isEdge(List<Vector3> processedPoints, Segment edge)
{
for(int k = 0; k < processedPoints.Count; k++) {
if(edge.isLeft(processedPoints[k])) return false;
}
return true;
}
示例6: Handle
public override bool Handle (State previous, Segment prevSegment, Segment newSegment, bool left)
{
if (newSegment != null && !newSegment.IsPalette && newSegment.Type != ElementType.None) {
if (newSegment.Type == ElementType.Coil ||
newSegment.Type == ElementType.NotCoil ||
newSegment.Type == ElementType.SetCoil ||
newSegment.Type == ElementType.ResetCoil) {
MainClass._main.BindDefaultOutputs ();
} else {
MainClass._main.BindDefaultInputs ();
}
MainClass._main.BindExistingVariables (newSegment);
MainClass._main.BindFunction (newSegment);
AppController.Instance.CheckUserVariables ();
if (newSegment.Variables.Any ()) {
int index = 0;
foreach (var v in newSegment.Variables) {
MainClass._main.BindElementVariables (v.Type, v.Value, index++);
}
for (int i = index; i < 4; i++) {
MainClass._main.BindElementVariables (VariableType.Default, string.Empty, i);
}
}
MainClass._main.DisableProperties ();
}
base.Handle (previous, prevSegment, newSegment, left);
return true;
}
示例7: Insert
public Segment Insert(TrackObject insertedOject, float distanceFromBegining)
{
Segment insertedSegment = new Segment();
IFirstLastAccessor insertedFLAccessor = FirstLastAccessorFactory.Create(_direction, insertedSegment);
IFirstLastAccessor segmentFLAccessor = FirstLastAccessorFactory.Create(_direction, _segment);
insertedFLAccessor.FirstObject = segmentFLAccessor.FirstObject;
insertedFLAccessor.LastObject = insertedOject;
segmentFLAccessor.FirstObject = insertedOject;
Segment prevSegment = segmentFLAccessor.PrevSegment;
insertedFLAccessor.NextSegment = _segment;
insertedFLAccessor.PrevSegment = prevSegment;
segmentFLAccessor.PrevSegment = insertedSegment;
if (prevSegment != null)
{
IFirstLastAccessor prevSegmentFLAccessor = FirstLastAccessorFactory.Create(_direction, prevSegment);
prevSegmentFLAccessor.NextSegment = insertedSegment;
}
float distance = distanceFromBegining - _distanceFull;
if (distance > 0.0)
{
throw new VrException(String.Format("Longer distance '{0}' can't be appended, only appended!", distance));
}
float insertedSegmentDistance = _segment.Distance + distance;
insertedSegment.Distance = insertedSegmentDistance;
_segment.Distance = _segment.Distance - insertedSegmentDistance;
return insertedSegment;
}
示例8: GetConnectedSegment
private Segment GetConnectedSegment(Segment segment)
{
HingeJoint2D hingeJoint = GetHingeJoint(segment);
Segment previousSegment = null;
if (hingeJoint.connectedBody != null) previousSegment = hingeJoint.connectedBody.gameObject.GetComponent<Segment>();
return previousSegment;
}
示例9: AddSegmentText
private void AddSegmentText(SvgDocument document, int index, ComplexLine line,Segment segment, PointF targetPoint, PointF referencePoint)
{
//Get midpoint of segment
PointF location = new PointF(targetPoint.X + ((referencePoint.X - targetPoint.X) / 2), targetPoint.Y + ((referencePoint.Y - targetPoint.Y) / 2));
if (segment.Label.Text.Trim() == "") return;
Style style = new Style();
//Set up text object
location = OffsetPoint(location, segment.Label.Offset);
//location = OffsetPoint(location, line.Rectangle.Location);
Double rotation = Geometry.DegreesFromRadians(Geometry.GetAngle(targetPoint.X, targetPoint.Y, referencePoint.X, referencePoint.Y));
Text text = new Text();
text.Label = segment.Label;
text.LayoutRectangle = new RectangleF(location, new SizeF());
//Get style
string classId = null;
classId = document.AddClass(text.GetStyle());
//Create fragment and add to document
XmlDocumentFragment frag = null;
XmlNode newElementNode = null;
frag = document.CreateDocumentFragment();
frag.InnerXml = text.ExtractText(0, 0, line.Key + index.ToString() + "Text", "rotate(" + rotation.ToString() + "," + location.X.ToString() + "," + location.Y.ToString() + ")");
//frag.InnerXml = text.ExtractText(0, 0, line.Key + index.ToString() + "Text");
frag.FirstChild.Attributes.GetNamedItem("class").InnerText = classId;
newElementNode = document.ContainerNode.AppendChild(frag);
}
示例10: Address
public Address(Segment segment, long value)
: this()
{
this.Type = AddressType.Logical;
this.Value = value;
this.Segment = segment;
}
示例11: Create
public IRun Create(IComparisonGeneratorsFactory factory)
{
var run = new Run(factory);
var json = JSON.FromStream(Stream);
run.GameName = json.run_name as string;
run.AttemptCount = json.run_count;
var timingMethod = (int)(json.timer_type) == 0
? TimingMethod.RealTime
: TimingMethod.GameTime;
var segments = json.splits as IEnumerable<dynamic>;
foreach (var segment in segments)
{
var segmentName = segment.name as string;
var pbSplitTime = parseTime((int?)segment.pb_split, timingMethod);
var bestSegment = parseTime((int?)segment.split_best, timingMethod);
var parsedSegment = new Segment(segmentName, pbSplitTime, bestSegment);
run.Add(parsedSegment);
}
return run;
}
示例12: addSegment
// Add a segment, where the first point shows up in the
// visualization but the second one does not. (Every endpoint is
// part of two segments, but we want to only show them once.)
public void addSegment(float x1, float y1, float x2, float y2)
{
Segment segment = new Segment();//null;
//EndPoint p1 = {begin, x, y, angle,segment, visualize};
//EndPoint p1 = new EndPoint.Init(begin = false, x = 0F, y= 0F, angle = 0F,segment = segment, visualize = true);
//EndPoint p2 = new EndPoint.Init(begin = false, x = 0F, y= 0F, angle = 0F,segment = segment, visualize = false);
EndPoint p1 = new EndPoint{begin = false, x = 0F, y = 0F, angle = 0F,segment = segment, visualize = true};
EndPoint p2 = new EndPoint{begin = false, x = 0F, y = 0F, angle = 0F,segment = segment, visualize = false};
//EndPoint p2 = {begin: false, x: 0.0, y: 0.0, angle: 0.0,segment: segment, visualize: false};
//segment = {p1: p1, p2: p2, d: 0.0};
p1.x = x1; p1.y = y1;
p2.x = x2; p2.y = y2;
p1.segment = segment;
p2.segment = segment;
segment.p1 = p1;
segment.p2 = p2;
segments.Add(segment); //segments.append(segment);
endpoints.Add(p1); //endpoints.append(p1);
endpoints.Add(p2); //endpoints.append(p2);
//Drawline lags one frame behind because off is updated after, no problem
//Debug.DrawLine(new Vector3(p1.x,0F,p1.y)+off,new Vector3(p2.x,0F,p2.y)+off,new Color(1F,1F,1F,0.5F),0F,false);
}
示例13: update
public void update(Point p, bool shiftPressed, bool ctrlPressed)
{
Point s = (Point)start;
segments.Clear();
if (ctrlPressed)
{
// calculate the angle
double A = p.Y < s.Y ? s.Y - p.Y : -(p.Y - s.Y);
double B = p.X < s.X ? -(s.X - p.X) : p.X - s.X;
angle = Math.Tanh(A / B) * 180 / Math.PI;
}
else
{
end = p;
}
Point e = (Point)end;
Point a = s;
Point b = new Point(e.X, a.Y);
Point c = new Point(b.X, e.Y);
Point d = new Point(a.X, c.Y);
Segment AB = new Segment(a, b).Rotate(-angle);
Segment BC = new Segment(b, c).Rotate(-angle).Translate(AB.End);
Segment CD = new Segment(c, d).Rotate(-angle).Translate(BC.End);
Segment DA = new Segment(d, a).Rotate(-angle).Translate(CD.End);
segments.Add(AB);
segments.Add(BC);
segments.Add(CD);
segments.Add(DA);
}
示例14: GetAllowableSegmentPart
private static string GetAllowableSegmentPart(Segment segment, int pos,
int extractStart, int extractLength, bool extractToEnd)
{
var segmentMin = pos;
var segmentMax = pos + segment.Text.Length;
var extractMax = extractStart + (extractToEnd ? segmentMax : extractLength);
var startIsInsideSegment = extractStart >= segmentMin && extractStart <= segmentMax;
var endIsInsideSegment = extractMax >= segmentMin && extractMax <= segmentMax;
var segmentIsInsideRange = extractStart <= segmentMin && extractMax >= segmentMax;
if (segmentIsInsideRange)
return segment.Text;
if (startIsInsideSegment && endIsInsideSegment)
{
var fragmentStart = extractStart - segmentMin;
var fragmentLength = extractMax - extractStart;
return segment.Text.Substring(fragmentStart, fragmentLength);
}
if (startIsInsideSegment)
return segment.Text.Substring(extractStart - segmentMin);
if (endIsInsideSegment)
return segment.Text.Substring(0, extractMax - segmentMin);
return null;
}
示例15: LoadWildcard
private void LoadWildcard(string fileName)
{
lock (_LockObj)
{
_WildcardList = new List<WildcardInfo>();
if (!System.IO.File.Exists(fileName))
{
return;
}
Segment segment = new Segment();
using (StreamReader sr = new StreamReader(fileName, Encoding.UTF8))
{
while (!sr.EndOfStream)
{
string line = sr.ReadLine().Trim();
if (string.IsNullOrEmpty(line))
{
continue;
}
_WildcardList.Add(new WildcardInfo(line, segment, _Options, _Parameter));
}
}
_Init = true;
}
}