示例#1
0
        public View()
        {
            game = new Game(10, 20)
            {
                CellHeight = CellHeight,
                CellWidth  = CellWidth
            };
            game.PropertyChanged += (s, e) =>
            {
                OnPropertyChanged(e.PropertyName);
            };

            InitializeComponent();

            game.OnGameOver += Game_OnGameOver;

            timer = new Timer()
            {
                Interval = 16
            };

            PreviewKeyDown += (s, e) => e.IsInputKey = true;
            KeyDown        += (s, e) => game.MoveBrick(e, true);
            KeyUp          += (s, e) => game.MoveBrick(e, false);

            timer.Tick += (s, e) => Invalidate();

            timer.Start();
        }