private void InitCurrentSegment(PointLocation start) { CurrentSegment = new SegmentLocation() { Start = start }; }
public void SetLocation(SegmentLocation location) { if (_screen != null) { _screen.SetLocation(location.X, location.Y); } }
protected void GetLocationFromChildren() { if (Children.Count > 0) { _location = Children[0].Location; foreach (var child in Children) { if (child.Location == null) { child.GetLocationFromChildren(); } if (_location == null) { _location = child.Location; } else { _location = _location.SmartMerge(child.Location); } } } LocationReady = true; }
/// <summary> /// Expands each packet interval in the source tile /// to a list of tilepart packet intervals. /// Performs the supplied function over the tile-part /// packet interval, with an optional computational /// result. /// </summary> /// <typeparam name="T"> /// The optional aggregate result of perform /// </typeparam> /// <param name="intervals">The packet intervals</param> /// <param name="srcTile">The source tile</param> /// <param name="perform"> /// The function to perform on each tile-part packet interval /// </param> private void EnumerateIntervals <T>( IEnumerable <PacketInterval> intervals, JP2Tile srcTile, Func <JP2TilePart, int, int, T, T> perform) { var scanner = new SegmentScanner(srcTile.GetPacketCounts()); T aggregate = default(T); foreach (var ival in intervals) { // use inclusive end packet index SegmentLocation segStart = scanner.Find(ival.PacketStart); SegmentLocation segEnd = scanner.Find(ival.PacketEnd - 1); int tpStart = segStart.SegmentIdx; int tpEnd = segEnd.SegmentIdx; // an interval of packets in the tile may span across multiple tile-parts. for (int tpIdx = tpStart; tpIdx <= tpEnd; tpIdx++) { JP2TilePart tp = srcTile.OpenTilePart(tpIdx); int pckStart = tpIdx == tpStart ? segStart.InSegmentIdx : 0; int pckEnd = tpIdx == tpEnd ? (segEnd.InSegmentIdx + 1) : tp.Packets; int pckCount = pckEnd - pckStart; aggregate = perform(tp, pckStart, pckCount, aggregate); } } }
public WorldEditor(SegmentManager parent) { ParentSegmentManager = parent; _blockMasks = new List <BlockMask>(); _blockMasks.Add(BlockHelper.BlockMasks.Debug); _blockMasks.Add(BlockHelper.BlockMasks.Soil); _topRampMasks = new List <BlockMask>(); _topRampMasks.Add(BlockHelper.RampBlockMasks.Top.Debug); _topRampMasks.Add(BlockHelper.RampBlockMasks.Top.Soil); _bottomRampMasks = new List <BlockMask>(); _bottomRampMasks.Add(BlockHelper.RampBlockMasks.Bottom.Debug); _bottomRampMasks.Add(BlockHelper.RampBlockMasks.Bottom.Soil); _index = 0; _selectedType = EditorType.Blocks; _keyboardCursor = new SegmentLocation(Vector3.Zero); _RampBlockDirection = RampBlockDirection.North; _activeBlockMask = BlockHelper.BlockMasks.Soil; _previewData = new BlockVertexData(); }
public static bool IsValid(Node root, SegmentLocation blockLocation) { var visitor = new ValidatorVisitor(blockLocation); visitor.Visit(root); return(visitor.CanInsert.Value); }
public void SetLocation(PointLocation start, PointLocation end) { _location = new SegmentLocation() { Start = start, End = end }; LocationReady = true; }
public Node(Node node) { Symbol = node.Symbol; Options = node.Options; Parent = node.Parent; Alias = node.Alias; Children = node.Children; Value = node.Value; _location = node._location; LocationReady = node.LocationReady; }
public S GetDirect(SegmentLocation which) { switch (which) { case SegmentLocation.Repr: return(repr_); case SegmentLocation.Set: return(set_); case SegmentLocation.Period: return(period_); } return(null); }
public void CopyFromNode(Node node) { this.Symbol = node.Symbol; this.Options = node.Options; this.Parent = node.Parent; this.Alias = node.Alias; this.Children = node.Children; this.Value = node.Value; this._location = node._location; this.LocationReady = node.LocationReady; }
public SegmentLocation NextAvailable(SegmentLocation below) { if (below == SegmentLocation.None) { throw new Exception("Can't get lower, than SegmentLocation.None"); } if (below == SegmentLocation.Repr && set_ != null) { return(SegmentLocation.Set); } if (below != SegmentLocation.Period && period_ != null) { return(SegmentLocation.Period); } return(SegmentLocation.None); }
private bool GetSegmentsFromTo(long startPos, long endPos, out SegmentLocation first, out SegmentLocation last) { first = FindSegment(startPos); last = null; if (first == null) { return(false); } if (endPos < Length) { long currentPos = first.StreamPosition; var currentNode = first.Node; while (currentPos < endPos && currentNode != null) { if (endPos <= currentPos + currentNode.Value.Length) { last = new SegmentLocation(currentNode, currentPos, endPos - currentPos); break; } currentPos += currentNode.Value.Length; currentNode = currentNode.Next; } if (last.Node == null) { first = null; } } else { last = new SegmentLocation(Segments.Last, Length - Segments.Last.Value.Length, Segments.Last.Value.Length /* - 1*/); } return(first != null && last != null); }
private long RemoveSegment(SegmentLocation start, SegmentLocation end) { Segment left = Segment.Invaild, right = Segment.Invaild, dummy; if (start.LocalPosition > 0 /* && start.LocalPosition < start.Segment.Length - 1*/) { SplitSegment(start.Segment, start.LocalPosition, out left, out dummy); } if (end.LocalPosition > 0 && end.LocalPosition < end.Segment.Length) { SplitSegment(end.Segment, end.LocalPosition, out dummy, out right); } var nodesToRemove = Segments.GetNodesInBetween(start.Node, end.Node); long amountRemoved = nodesToRemove.Sum(n => n.Value.Length); //_Length -= nodesToRemove.Sum(n => n.Value.Length); if (left != Segment.Invaild) { Segments.AddBefore(start.Node, left); //_Length += left.Length; amountRemoved -= left.Length; } if (right != Segment.Invaild) { Segments.AddAfter(end.Node, right); //_Length += right.Length; amountRemoved -= right.Length; } _Length -= amountRemoved; Segments.RemoveRange(nodesToRemove); return(amountRemoved); }
private void MoveCaretToSource(SegmentLocation loc, ICSharpCode.AvalonEdit.TextEditor editor, bool selectText = true, int?tabToSelect = null) { if (loc != null) { var start = loc.Start.Offset; var end = loc.End.Offset; editor.ScrollToLine(editor.Document.GetLocation(start).Line); if (selectText) { editor.Select(start, end - start + 1); } if (tabToSelect.HasValue) { MainTabs.SelectedIndex = tabToSelect.Value; } } else { editor.Select(0, 0); } }
public void HandleHighlight() { Vector3 newPosition = _keyboardCursor.WorldLocation; if (InputHelper.IsNewKeyPress(Keys.NumPad3)) { newPosition += WorldDirection.East; } if (InputHelper.IsNewKeyPress(Keys.NumPad1)) { newPosition += WorldDirection.North; } if (InputHelper.IsNewKeyPress(Keys.NumPad7)) { newPosition += WorldDirection.West; } if (InputHelper.IsNewKeyPress(Keys.NumPad9)) { newPosition += WorldDirection.South; } if (InputHelper.IsNewKeyPress(Keys.Add)) { newPosition += WorldDirection.Up; } if (InputHelper.IsNewKeyPress(Keys.Subtract)) { newPosition += WorldDirection.Down; } // Following is for valid block ranges only. if (ParentSegmentManager.GetBlockMaskAt(new SegmentLocation(newPosition)) != BlockHelper.BlockMasks.Null) { if (newPosition != _keyboardCursor.WorldLocation) { // check for an object? int segmentX = (int)Math.Floor((double)newPosition.X / WorldGlobal.SegmentSize.X); int segmentZ = (int)Math.Floor((double)newPosition.Z / WorldGlobal.SegmentSize.Z); //_ItemsUnderCursor = ParentSegmentManager.Segments[segmentX, segmentZ].Items.FindItemsAt(newPosition); } _keyboardCursor = new SegmentLocation(newPosition); if (InputHelper.IsNewKeyPress(Keys.Delete)) { ParentSegmentManager.SetBlockMaskAt(_keyboardCursor, BlockHelper.BlockMasks.Air); } if (InputHelper.IsNewKeyPress(Keys.Insert)) { BlockMask maskAtCursor = ParentSegmentManager.GetBlockMaskAt(_keyboardCursor); switch (_selectedType) { case EditorType.Blocks: ParentSegmentManager.SetBlockMaskAt(_keyboardCursor, _activeBlockMask); break; case EditorType.BottomRamps: if (BlockHelper.HasTopRamp(maskAtCursor) && BlockHelper.GetRampBlockDirection(maskAtCursor) == _RampBlockDirection) { ParentSegmentManager.SetBlockMaskAt(_keyboardCursor, maskAtCursor | _activeBlockMask); } else { ParentSegmentManager.SetBlockMaskAt(_keyboardCursor, _activeBlockMask); } break; case EditorType.TopRamps: if (BlockHelper.HasBottomRamp(maskAtCursor) && BlockHelper.GetRampBlockDirection(maskAtCursor) == _RampBlockDirection) { ParentSegmentManager.SetBlockMaskAt(_keyboardCursor, maskAtCursor | _activeBlockMask); } else { ParentSegmentManager.SetBlockMaskAt(_keyboardCursor, _activeBlockMask); } break; default: _previewData = new BlockVertexData(); break; } } } else { DebugLog.Log("Can't move World Cursor to (" + newPosition.X + ", " + newPosition.Y + ", " + newPosition.Z + ") - Out of bounds", DebugMessageType.Warning); } }
public ValidatorVisitor(SegmentLocation blockLocation) { BlockLocation = blockLocation; }
public void ResetLocation() { _location = null; LocationReady = false; }