Exemple #1
0
        public void AddPositional(Positional <TBoard> positional)
        {
            // disallow repeated adding
            if (Positionals.Contains(positional))
            {
                return;
            }

            // if it is from another board, we remove it from there first,
            // before adding to the current one.
            if (positional.Board != null)
            {
                positional.Board.RemovePositional(positional);
            }

            positional.SetBoardDirectly(this as TBoard);
            Positionals.Add(positional);

            Position position = positional.Position;

            // very important to reset the position with the new finenessLimit value
            positional.Position = new Position(position.X, position.Y, position.FinenessX, position.FinenessY, this.FinenessLimit);

            OnAddingPositional(new PositionalEventArgs <TBoard>(positional));
        }
Exemple #2
0
        public bool RemovePositional(Positional <TBoard> positional)
        {
            // if it is not supposed to be from this board,
            // just return false and do nothing.
            if (!Positionals.Contains(positional))
            {
                return(false);
            }

            // by setting the positional.Board to null
            // all the bindings from logic to board will be removed
            // this is because positional.Board is made to be virtual
            positional.Board = null;

            Positionals.Remove(positional);
            OnRemovingPositional(new PositionalEventArgs <TBoard>(positional));

            return(true);
        }