public Range(Loc start, Loc end, SelectionType type = SelectionType.Normal) { if (start < end) { this.start = start; this.end = end; } else { this.start = end; this.end = start; } this.type = type; }
public Range(Loc start, Loc end) { if (start < end) { this.startY = start.Y; this.startX = start.X; this.endY = end.Y; this.endX = end.X; } else { this.endY = start.Y; this.endX = start.X; this.startY = end.Y; this.startX = end.X; } }
public bool Contains(Loc l) { if (IsRectangularSelection) return l.X >= (Start.X < End.X ? Start.X : End.X) && l.X < (Start.X > End.X ? Start.X : End.X) && l.Y >= Start.Y && l.Y <= End.Y; else return (IsSingleLine ? (Start.X <= l.X && End.X >= l.X) : (Start.Y < l.Y && End.Y > l.Y) || (Start.Y == l.Y && Start.X <= l.Y) || (End.Y == l.Y && End.X >= l.Y)); }
// Constructor public Range(int startY, int startX, int endY, int endX, SelectionType type = SelectionType.Normal) { start = new Loc(startY, startX); end = new Loc(endY, endX); this.type = type; }
public Loc WithOffset(Loc offset) { return new Loc(y + offset.y, x + offset.x); }