예제 #1
0
파일: View.cs 프로젝트: Gallimathias/Tetris
        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();
        }