public void Add_Simple() { var visited = new LineRangeVisited(); visited.Add(LineRange.CreateFromBounds(0, 2)); Assert.AreEqual(LineRange.CreateFromBounds(0, 2), visited.LineRange.Value); }
/// <summary> /// <see cref="TrainData.TrainName"/>クラスのインスタンスを<see cref="RawTrainData"/>をパースして作成します。 /// </summary> public static TrainData.TrainName GetTrainName(string trainNameString, string trainTypeString) { TrainData.TrainTypes?subType = null; LineRange range = null; if (trainNameString.Contains("(")) { var rangetext = trainNameString.GetRange('(', ')'); //全角括弧 if (rangetext.Contains("間")) //いしかりライナー及びAP普通用 { subType = TrainData.TrainTypesCreater.FromString(rangetext.GetRangeWithStart('間')); var stations = rangetext.GetRangeWithEnd('間').Split('~'); range = new LineRange(stations[0], stations[1]); } else//すずらん室蘭行用 { subType = TrainData.TrainTypes.Local; range = new LineRange("東室蘭", "室蘭"); } trainNameString = trainNameString.GetRangeWithEnd('('); } var name = ParseTrainNumber(trainNameString, out var number); var mainTrainType = TrainData.TrainTypesCreater.FromString(trainTypeString); return(new TrainData.TrainName(mainTrainType, name, number, subType, range)); }
public BaseEditor(Point startPos, LineRange startRay, IEditable editable) { this.editable = editable; lastDragPosition3d = PointOnSketchPlane(startRay); lastDragPosition2d = startPos; }
private void SetText(LineRange range) { int maxLines = textViewLinesOnScreen; StringBuilder stringBuilder = new StringBuilder(); int firstVisibleLine = 0; string text = String.Empty; if (range != null) { int prev = (int)Min(50, range.PreviousLines.Count); int next = (int)Min(50 + maxLines, range.NextLines.Count); firstVisibleLine = prev; var lines = range.PreviousLines.Skip(range.PreviousLines.Count - prev); if (range.RequestedLine != null) { lines = lines.Append(range.RequestedLine); } lines = lines.Concat(range.NextLines.Take(next)); char[] newLineCh = new char[] { '\r', '\n' }; text = string.Join(System.Environment.NewLine, lines.Select(l => l.Content.TrimEnd(newLineCh))); } if (textViewText != text || textViewFirstVisibleLine != firstVisibleLine) { //Debug.WriteLine($"[{DateTime.Now:HH:mm:ss.fff}] [{nameof(ScrollLogic)}.{nameof(SetText)}] Update Text: {lineRange.RequestedLine.Content}"); textViewText = text; textViewFirstVisibleLine = firstVisibleLine; DataUpdated(); } }
public void Simple() { var visited = new NormalizedLineRangeCollection(); visited.Add(LineRange.CreateFromBounds(0, 2)); Assert.Equal(LineRange.CreateFromBounds(0, 2), visited.OverarchingLineRange.Value); }
/// <summary> /// 文字列を路線区間に変換します。 /// </summary> /// <param name="lineRangeString">変換対象の文字列</param> /// <param name="delimiter">両端の駅を区切る文字</param> /// <param name="range">変換の結果。変換に失敗した場合は<c>null</c>を返します</param> /// <returns>変換が成功したかどうか</returns> private static bool TryParse(string lineRangeString, char delimiter, out LineRange range) { //サッポロビール庭園対策 if (lineRangeString.Contains("サッポロビ-ル庭園")) { lineRangeString = lineRangeString.Replace("サッポロビ-ル庭園", "サッポロビール庭園"); } if (lineRangeString.Contains("(")) { lineRangeString = lineRangeString.GetRange('(', ')'); } var str = lineRangeString.Split(new char[] { delimiter, '間' }); if (str.Length != 3) { range = null; return(false); } else { range = new LineRange(str[0], str[1]); return(true); } }
/* * Add a ceiling to the room */ public void AddCeiling() { GameObject ceiling = new GameObject(); ceiling.transform.parent = transform; int ceilingMaterialIndex = Random.Range(0, _ceilingMaterials.Length); MeshRenderer ceilingRendered = ceiling.AddComponent <MeshRenderer>(); ceilingRendered.material = _ceilingMaterials[ceilingMaterialIndex]; ceiling.transform.name = "Ceiling" + ceilingRendered.material.name; MeshCollider ceilingCollider = ceiling.AddComponent <MeshCollider>(); MeshFilter ceilingMeshFilter = ceiling.AddComponent <MeshFilter>(); List <Vector3> ceilingPoints = new List <Vector3>(); LineRange groundRangeX = _ground.GetXRange(); LineRange groundRangeZ = _ground.GetZRange(); ceilingPoints.Add(new Vector3(groundRangeX.max * _wall.GetWallShrink(), _ceilingHeight, groundRangeZ.min * _wall.GetWallShrink())); ceilingPoints.Add(new Vector3(groundRangeX.min * _wall.GetWallShrink(), _ceilingHeight, groundRangeZ.min * _wall.GetWallShrink())); ceilingPoints.Add(new Vector3(groundRangeX.min * _wall.GetWallShrink(), _ceilingHeight, groundRangeZ.max * _wall.GetWallShrink())); ceilingPoints.Add(new Vector3(groundRangeX.max * _wall.GetWallShrink(), _ceilingHeight, groundRangeZ.max * _wall.GetWallShrink())); PlaneRange ceilingRange = new PlaneRange( 0, 1, 0, 0, 0, 1 ); ceilingMeshFilter.mesh = MeshTools.CreateMeshFromVectors(ceilingPoints, ceilingRange); ceilingCollider.sharedMesh = ceilingMeshFilter.mesh; }
public void Intersects_DoesAtBorder() { var left = LineRange.CreateFromBounds(0, 2); var right = LineRange.CreateFromBounds(3, 4); Assert.IsTrue(left.Intersects(right)); }
int _countLineStyleRuns(LineRange lineRange, int styleRunIndex, out int maxTextCount) { // Exclude trailing whitespace from right-justified lines so the last // visible character in the line will be flush with the right margin. int lineEndIndex = this._paragraphStyle.textAlign == TextAlign.right || this._paragraphStyle.textAlign == TextAlign.center ? lineRange.endExcludingWhitespace : lineRange.end; maxTextCount = 0; int lineStyleRunCount = 0; for (int i = styleRunIndex; i < this._runs.size; i++) { var styleRun = this._runs.getRun(i); int start = Mathf.Max(styleRun.start, lineRange.start); int end = Mathf.Min(styleRun.end, lineEndIndex); // Make sure that each line is not empty if (start < end) { lineStyleRunCount++; maxTextCount = Math.Max(end - start, maxTextCount); } if (styleRun.end >= lineEndIndex) { break; } } return(lineStyleRunCount); }
public void Intersects_SimpleDoesnt() { var left = LineRange.CreateFromBounds(0, 1); var right = LineRange.CreateFromBounds(3, 4); Assert.IsFalse(left.Intersects(right)); }
public void Intersects_SimpleDoes() { var left = LineRange.CreateFromBounds(0, 2); var right = LineRange.CreateFromBounds(1, 4); Assert.IsTrue(left.Intersects(right)); }
private LineRange ShiftLineRange(LineRange lineRange, int shift) { int prevLineCount = lineRange.PreviousLines.Count; int nextLineCount = lineRange.NextLines.Count; if (shift < 0 && prevLineCount > 0) { shift = Min(-shift, prevLineCount); int newPrevLineCount = prevLineCount - shift; List <Line> prev = lineRange.PreviousLines.Take(newPrevLineCount).ToList(); Line cur = lineRange.PreviousLines.Skip(newPrevLineCount).First(); List <Line> next = lineRange.PreviousLines.Skip(newPrevLineCount + 1).Append(lineRange.RequestedLine).Concat(lineRange.NextLines).ToList(); return(new LineRange(cur, prev, next, lineRange.PreviousExtents, lineRange.NextExtents, lineRange.StreamLength)); } else if (shift > 0 && nextLineCount > 0) { shift = Min(shift, nextLineCount); List <Line> prev = lineRange.PreviousLines.Append(lineRange.RequestedLine).Concat(lineRange.NextLines.Take(shift - 1)).ToList(); Line cur = lineRange.NextLines.Skip(shift - 1).First(); List <Line> next = lineRange.NextLines.Skip(shift).ToList(); return(new LineRange(cur, prev, next, lineRange.PreviousExtents, lineRange.NextExtents, lineRange.StreamLength)); } else { return(lineRange); } }
/* * Block a section of the wall, so it doesn't have multiple objects in the same place */ public void AddWallUsage(int wallIndex, LineRange usedWall) { int sectionIndex = 0; while (sectionIndex < _wallEmpty[wallIndex].Count) { LineRange freeWallSection = _wallEmpty[wallIndex][sectionIndex]; if ((freeWallSection.min < usedWall.min && freeWallSection.max > usedWall.min) || (freeWallSection.min < usedWall.max && freeWallSection.max > usedWall.max)) { LineRange newFreeSection = new LineRange(usedWall.max, freeWallSection.max); if (sectionIndex + 1 == _wallEmpty[wallIndex].Count) { // Was last item, so add at end of list _wallEmpty[wallIndex].Add(newFreeSection); } else { // In middle of list so insert in correct place _wallEmpty[wallIndex].Insert(sectionIndex + 1, newFreeSection); } newFreeSection = new LineRange(freeWallSection.min, usedWall.min); _wallEmpty[wallIndex][sectionIndex] = newFreeSection; break; } sectionIndex++; } }
/// <summary> /// <see cref="TrainCondition"/> クラスの新しいインスタンスを初期化します。 /// </summary> /// <param name="condition">列車運行ステータス。</param> /// <param name="suspendRange">運休区間。</param> /// <exception cref="ArgumentException">引数の組がサポートされない場合にスローされる例外。</exception> public TrainCondition(TrainConditions condition, LineRange suspendRange = null) { Condition = condition; SuspendRange = suspendRange; DelayTimeMin = null; DelayTimeMax = null; }
public void GetHashCode_ReturnsSameHashCodeForIdenticalLineRanges(LineRange dummyLineRange1, LineRange dummyLineRange2, bool identical) { // Act and assert Assert.Equal(identical, dummyLineRange1.GetHashCode() == dummyLineRange2.GetHashCode()); }
public string UnformatBindingsXmlForPersistence(string line, LineRange rangeInLine) { string interestingPart = line.Substring(rangeInLine.Start, rangeInLine.Length); int bindingStart = interestingPart.IndexOf("<binding"); return(interestingPart.Substring(bindingStart, rangeInLine.Length - bindingStart)); }
public void Intersects() { var visited = Create(new LineRange(1, 4)); visited.Add(LineRange.CreateFromBounds(3, 5)); Assert.Equal(1, visited.Count); Assert.Equal(LineRange.CreateFromBounds(1, 5), visited.OverarchingLineRange.Value); }
public Point3D To3DPoint(Vector point) { LineRange r = new LineRange(); ViewportInfo.Point2DtoPoint3D(viewPort, point.ToPoint(), out r); return(r.PointFromZ(-100)); }
public void Add_Intersects() { var visited = Create(new LineRange(1, 4)); visited.Add(LineRange.CreateFromBounds(3, 5)); Assert.AreEqual(1, visited.List.Count); Assert.AreEqual(LineRange.CreateFromBounds(1, 5), visited.LineRange.Value); }
public void Simple() { var lineRange = LineRange.CreateFromBounds(1, 3); Assert.Equal(3, lineRange.Count); Assert.Equal(1, lineRange.StartLineNumber); Assert.Equal(3, lineRange.LastLineNumber); }
/// <summary> /// <see cref="TrainName"/> クラスの新しいインスタンスを初期化します。 /// </summary> /// <param name="trainType">列車種別。</param> /// <param name="name">列車名。</param> /// <param name="number">列車番号。</param> /// <param name="subTrainType">サブ列車種別。</param> /// <param name="subTrainTypeRange">サブ列車種別が適用される区間。</param> public TrainName(TrainTypes trainType, string name = null, int?number = null, TrainTypes?subTrainType = null, LineRange subTrainTypeRange = null) { TrainType = trainType; Name = name; Number = number; SubTrainType = subTrainType; SubTrainTypeRange = subTrainTypeRange; }
/* * Calculate what pars fo the wall can be accessed, as they are inside the chaparone area * This is called when _wallEmpty[wallIndex] is the entire wall */ private void CalculateAccessibleWall(int wallIndex) { LineRange wallRange = _wallEmpty[wallIndex][0]; _wallInChaparoneArea[wallIndex] = new List <LineRange>(); // TODO: Check for intersections with the floor? _wallInChaparoneArea[wallIndex].Add(wallRange); // For now just allow anywhere }
public void NotIntersects_ReverseOrder() { var visited = Create(LineRange.CreateFromBounds(4, 6)); visited.Add(LineRange.CreateFromBounds(0, 2)); Assert.Equal(2, visited.Count); Assert.Equal(LineRange.CreateFromBounds(0, 2), visited[0]); Assert.Equal(LineRange.CreateFromBounds(4, 6), visited[1]); }
public void OfSeq_NonIntersecting_WrongOrder() { var visited = Create( LineRange.CreateFromBounds(3, 4), LineRange.CreateFromBounds(0, 1)); Assert.AreEqual(LineRange.CreateFromBounds(0, 1), visited.List[0]); Assert.AreEqual(LineRange.CreateFromBounds(3, 4), visited.List[1]); }
public void Add_NotIntersects() { var visited = Create(LineRange.CreateFromBounds(0, 2)); visited.Add(LineRange.CreateFromBounds(4, 6)); Assert.AreEqual(2, visited.List.Count); Assert.AreEqual(LineRange.CreateFromBounds(0, 2), visited.List[0]); Assert.AreEqual(LineRange.CreateFromBounds(4, 6), visited.List[1]); }
public void Constructor_DoesNotThrowAnyExceptionIfStartAndEndLinesAreAValidCombination(int dummyStartLine, int dummyEndLine) { // Act var result = new LineRange(dummyStartLine, dummyEndLine); // Assert Assert.Equal(dummyStartLine, result.StartLine); Assert.Equal(dummyEndLine, result.EndLine); }
public void NonIntersecting_WrongOrder() { var visited = Create( LineRange.CreateFromBounds(3, 4), LineRange.CreateFromBounds(0, 1)); Assert.Equal(LineRange.CreateFromBounds(0, 1), visited[0]); Assert.Equal(LineRange.CreateFromBounds(3, 4), visited[1]); }
public void Add_MissingLineRange() { var visited = Create(LineRange.CreateFromBounds(0, 1)); visited.Add(LineRange.CreateFromBounds(3, 4)); Assert.AreEqual(2, visited.List.Count); visited.Add(LineRange.CreateFromBounds(2, 2)); Assert.AreEqual(1, visited.List.Count); Assert.AreEqual(LineRange.CreateFromBounds(0, 4), visited.LineRange.Value); }
/// <summary> /// <see cref="TrainData"/>クラスの新しいインスタンスを初期化します。 /// </summary> /// <param name="name"></param> /// <param name="time"></param> /// <param name="arrivalType"></param> /// <param name="departureStation"></param> /// <param name="destination"></param> /// <param name="condition"></param> /// <param name="nowPosition"></param> public TrainData(TrainName name, DateTime time, Station departureStation, ArrivalTypes arrivalType, Station destination, TrainCondition condition, LineRange nowPosition) { Name = name ?? throw new ArgumentNullException(nameof(name)); Time = time; DepartureStation = departureStation; // ?? throw new ArgumentNullException(nameof(departureStation)); ArrivalType = arrivalType; Destination = destination ?? throw new ArgumentNullException(nameof(destination)); Condition = condition ?? throw new ArgumentNullException(nameof(condition)); NowPosition = nowPosition; //nullable }
public void MissingLineRange() { var visited = Create(LineRange.CreateFromBounds(0, 1)); visited.Add(LineRange.CreateFromBounds(3, 4)); Assert.Equal(2, visited.Count); visited.Add(LineRange.CreateFromBounds(2, 2)); Assert.Equal(1, visited.Count); Assert.Equal(LineRange.CreateFromBounds(0, 4), visited.OverarchingLineRange.Value); }
protected override Image3D OnProcess(Image3D image, Progress progress) { Image3D imageOut = GetOutputImage(image); int delta = image.LengthY / threads.Length; LineRange firstRange = null; for (int i = 0; i < threads.Length; i++) { int min = delta * i; int max = (i == threads.Length - 1 ? image.LengthY : (delta * (i + 1))); var range = new LineRange(image, imageOut, progress, min, max); if (i == 0) { // run first range in this thread // so save the range for later firstRange = range; } else { threads[i] = new Thread(new ParameterizedThreadStart(ProcessLines)); threads[i].Start(range); } } // allow other threads to start Thread.Sleep(0); // run first range ProcessLines(firstRange); // join all other threads // Attention: start at 1, beacause 0 is null because it was processed in this Thread for (int i = 1; i < threads.Length; i++) { while (threads[i].ThreadState == ThreadState.Unstarted) { Thread.Sleep(0); } threads[i].Join(); } return imageOut; }
private LineRange method0(CodeFile codeFile, HashIndexRange hashIndexRange, LineRange lineRange) { lineRange.Start = codeFile.HashIndexToLineIndex[hashIndexRange.Start]; if (codeFile.HashIndexToLineIndex.Length <= hashIndexRange.End) { lineRange.End = codeFile.HashIndexToLineIndex[codeFile.HashIndexToLineIndex.Length - 1]; } else { lineRange.End = codeFile.HashIndexToLineIndex[hashIndexRange.End]; } return lineRange; }
public string GetText(CodeFile file, LineRange range, bool includeLineNumbers) { StringBuilder stringBuilder = new StringBuilder(); int num = 1000; for (int i = range.Start; i < range.End; i++) { if (!Similarity.regex_0.IsMatch(file.Lines[i])) { string text = file.Lines[i]; int num2 = 0; while (num2 < text.Length && text[num2] == ' ') { num2++; } if (num > num2) { num = num2; } } } for (int i = range.Start; i < range.End; i++) { if (stringBuilder.Length != 0) { stringBuilder.AppendLine(); } if (includeLineNumbers) { if (file.Lines[i].Length <= num) { stringBuilder.Append(i.ToString().PadLeft(4, ' ')); } else { stringBuilder.Append(i.ToString().PadLeft(4, ' ') + "\t" + file.Lines[i].Substring(num)); } } else if (file.Lines[i].Length <= num) { stringBuilder.Append(""); } else { stringBuilder.Append("\t" + file.Lines[i].Substring(num)); } } return stringBuilder.ToString(); }
public string GetText(CodeFile file, LineRange range) { return GetText(file, range, true); }
public void SetLineRanges() { this.lineRange_0 = this.method_0(this.MyFile, this.hashIndexRange_0, this.lineRange_0); this.lineRange_1 = this.method_0(this.OtherFile, this.hashIndexRange_1, this.lineRange_1); }
private LineRange method_0(CodeFile codeFile_2, HashIndexRange hashIndexRange_2, LineRange lineRange_2) { lineRange_2.Start = codeFile_2.HashIndexToLineIndex[hashIndexRange_2.Start]; if (codeFile_2.HashIndexToLineIndex.Length <= hashIndexRange_2.End) { lineRange_2.End = codeFile_2.HashIndexToLineIndex[codeFile_2.HashIndexToLineIndex.Length - 1]; } else { lineRange_2.End = codeFile_2.HashIndexToLineIndex[hashIndexRange_2.End]; } return lineRange_2; }