Esempio n. 1
0
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;
            WindowState = WindowState.Maximized;

            _restartCmd        = new RestartCmd(this);
            _soundChangeCmd    = new SoundChangeCmd(this);
            _gamemodeChangeCmd = new GamemodeChangeCmd(this);
            _secondWindowCmd   = new SecondWindowCmd(this);
            _arenaChangeCmd    = new ArenaChangeCmd(this);
            _exitCmd           = new ExitCmd(this);

            timer          = new DispatcherTimer();
            timer.Interval = new TimeSpan(T);
            timer.Tick    += TimerTick;

            RegisterGamemodes();
            SetupGamemodeMenu();

            sound = new SoundPlayer("Sound/timeout2.wav");
            sound.Load();
            leftScore  = 0;
            rightScore = 0;
            UpdateScore();

            arena = 1;

            this.KeyDown += new KeyEventHandler(OnButtonKeyDown);
        }
Esempio n. 2
0
        private void HandleWindowClosing(Window win, bool hideOnWindowClose)
        {
            win.Closing += async(s, e) =>
            {
                e.Cancel = true;
                if (hideOnWindowClose)
                {
                    win.Hide();
                    AppInsights.Post($"Hiding “{CaptionPrefix}” instead of closing it");
                    AppInsights.Flush();
                }
                else
                {
                    AppInsights.Post($"Closing “{CaptionPrefix}”");
                    await ExitCmd.RunAsync();
                }
            };

            win.IsVisibleChanged += (s, e) =>
            {
                if (win.Visibility == Visibility.Visible)
                {
                    _onWindowShown.Raise();
                }
                else
                {
                    _onWindowHidden.Raise();
                }
            };
        }
Esempio n. 3
0
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;
            WindowState = WindowState.Maximized;

            _restartCmd        = new RestartCmd(this);
            _soundChangeCmd    = new SoundChangeCmd(this);
            _gamemodeChangeCmd = new GamemodeChangeCmd(this);
            _secondWindowCmd   = new SecondWindowCmd(this);
            _arenaChangeCmd    = new ArenaChangeCmd(this);
            _exitCmd           = new ExitCmd(this);

            timer          = new DispatcherTimer();
            timer.Interval = new TimeSpan(T);
            timer.Tick    += TimerTick;

            gamemodes = new Dictionary <string, Gamemode>();
            gamemodes.Add("Классика", new Gamemode("Классика", 45, false, 10));
            gamemodes.Add("Военная сабля", new Gamemode("Военная сабля", 120, true, 7, 4));
            gamemodes.Add("Длинный меч", new Gamemode("Длинный меч", 180, true, 10, 4));

            _gamemodeChangeCmd.Execute("Классика");

            sound = new SoundPlayer("Sound/timeout2.wav");
            sound.Load();
            leftScore  = 0;
            rightScore = 0;
            UpdateScore();

            arena = 1;

            this.KeyDown += new KeyEventHandler(OnButtonKeyDown);
        }