예제 #1
0
 public double this[GridIndex i]
 {
     get
     {
         if (CanIndex(i))
         {
             return(m_Data[i.I, i.J]);
         }
         else
         {
             throw new IndexOutOfRangeException();
         }
     }
     set
     {
         if (CanIndex(i))
         {
             m_Data[i.I, i.J] = value;
         }
         else
         {
             throw new IndexOutOfRangeException();
         }
     }
 }
예제 #2
0
        public GridRegion Shrink(int margin)
        {
            var pos  = new GridIndex(Pos.I + margin, Pos.J + margin);
            var size = new GridSize(Size.Width - 2 * margin, Size.Height - 2 * margin);

            if (size.Height < 0 || size.Width < 0)
            {
                throw new InvalidOperationException("Region cannot shrink.");
            }
            return(new GridRegion(pos, size));
        }
예제 #3
0
        public GridRegion(GridIndex pos, GridSize size)
        {
            if (pos == null)
            {
                throw new ArgumentException("pos can't be null.");
            }

            if (size == null)
            {
                throw new ArgumentException("size can't be null.");
            }

            Pos  = pos;
            Size = size;
        }
예제 #4
0
 public bool IsInside(GridIndex index)
 {
     return(index.I >= Pos.I && index.I < Pos.I + Size.Height && index.J >= Pos.J && index.J < Pos.J + Size.Width);
 }
예제 #5
0
 public bool CanIndex(GridIndex index) => Bounds.IsInside(index) && !Inaccessable.IsInside(index);
예제 #6
0
 public bool CanIndex(GridIndex index) => Bounds.IsInside(index);