コード例 #1
0
        public void UpdateStyle(CoordinateView coordinateView, MouseState mouseState, bool highlight = false)
        {
            var shipInfo = BattlefieldView.Battlefield.GetShipInfo(coordinateView.Coordinate);

            coordinateView.Dispatcher.Invoke(() =>
            {
                coordinateView.Style = battlefieldViewStyleFactory.CreateCoordinateViewStyle(
                    mouseState, BattlefieldViewStyleSettings.HideUndamagedShips, coordinateView.Coordinate, shipInfo, highlight
                    );
            });
        }
コード例 #2
0
        public BattlefieldView CreateBattlefieldView(Battlefield battlefield)
        {
            var battlefieldView = new BattlefieldView(battlefield);

            //battlefieldView.Style = battlefieldViewStyleFactory.CreateStyle(battlefield.Dimensions);
            foreach (var coordinate in battlefield.Coordinates)
            {
                var coordinateView = new CoordinateView(coordinate);

                /*
                 * var (hasShip, isDamaged, isSunk) = battlefield.GetInfo(coordinate);
                 * coordinateView.Style = coordinateViewStyleFactory.CreateMouseAwayStyle(
                 *  hideShips, coordinate, hasShip, isDamaged, isSunk
                 * );
                 */

                battlefieldView.Children.Add(coordinateView);
                OnCoordinateViewAdded?.Invoke(this, new CoordinateViewAddedEventArgs(coordinate, coordinateView,
                                                                                     battlefield, battlefieldView));
            }

            return(battlefieldView);
        }