Пример #1
0
		public GridSpanList GetNonOverlappedSpans(bool reversed = false)
		{
			var result = new GridSpanList();
			if (Count == 0) {
				return result;
			}
			IEnumerable<GridSpan> gridEnumerable =
				reversed ?
				this.OrderByDescending(s => s.B) :
				this.OrderBy(s => s.A);
			foreach (var span in gridEnumerable) {
				bool isOverlapping = false;
				int last = result.Count - 1;
				if (last >= 0) {
					isOverlapping =
						reversed ?
						span.B >= result[last].A :
						result[last].B >= span.A;
				};
				if (result.Count > 0 && isOverlapping) {
					result[last] = new GridSpan {
						A = reversed ? Math.Min(result[last].A, span.A) : result[last].A,
						B = reversed ? result[last].B : Math.Max(result[last].B, span.B)
					};
				} else {
					result.Add(span);
				}
			}
			return result;
		}
Пример #2
0
        public GridSpanList GetNonOverlappedSpans()
        {
            if (Count == 0)
            {
                return(this);
            }
            var result = new GridSpanList();
            var hSpans = new SortedSet <int>();

            foreach (var r in this)
            {
                hSpans.Add(r.A);
                hSpans.Add(r.B);
            }
            int?prevCol = null;

            foreach (int col in hSpans)
            {
                if (prevCol.HasValue)
                {
                    var cell = (col + prevCol.Value) / 2;
                    if (IsCellSelected(cell))
                    {
                        result.Add(new GridSpan(prevCol.Value, col, true));
                    }
                }
                prevCol = col;
            }
            return(result);
        }
Пример #3
0
		public void DeselectGridSpan(GridSpan span)
		{
			if (span.B - span.A != 1) {
				throw new NotSupportedException("Deselection of areas, longer than 1, is not supported");
			} 
			var result = new GridSpanList();
			foreach (var s in this) {
				if (s.B < span.A || s.A >= span.B) {
					result.Add(s);
					continue;
				}
				if (s.A <= span.A) {
					result.Add(s.A, span.A);
				}
				if (s.B >= span.B) {
					result.Add(span.B, s.B);
				}
			}
			Clear();
			AddRange(result);
		}
Пример #4
0
		public GridSpanListComponent(GridSpanList spans) { Spans = spans; }
Пример #5
0
		public GridSpanListComponent() { Spans = new GridSpanList(); }