Exemplo n.º 1
0
        internal MainWindow(MainWindowViewModel mainWindowViewModel, GameSessionMap gameSessionMap, GameMonitor gameMonitor)
        {
            if (mainWindowViewModel == null)
            {
                throw new Exception("Null MainWindowViewModel in MainWindow()");
            }
            if (gameSessionMap == null)
            {
                throw new Exception("Null GameSessionMap in MainWindow()");
            }
            if (gameMonitor == null)
            {
                throw new Exception("Null GameMonitor in MainWindow()");
            }

            _viewModel             = mainWindowViewModel;
            _viewModel.CloseAction = new Action(() => this.Close());

            _gameSessionMap = gameSessionMap;
            _gameMonitor    = gameMonitor;
            _launchWorker   = new LaunchWorker(_worker, _gameSessionMap);
            _launchWorker.ReportAccountStatusEvent += (accountStatus, item) => UpdateAccountStatus(accountStatus, item);
            _launchWorker.ProgressChangedEvent     += _worker_ProgressChanged;
            _launchWorker.WorkerCompletedEvent     += _worker_RunWorkerCompleted;
            _uicontext = SynchronizationContext.Current;

            _viewModel.OpeningSimpleLauncherEvent += () => this.Hide();
            _viewModel.LaunchingSimpleGameEvent   += (li) => this.LaunchSimpleClient(li);

            _autoLaunchOnStart = Properties.Settings.Default.AutoLaunchOnStart;

            if (Properties.Settings.Default.AutoRelaunch)
            {
                CheckForProgramUpdate();
            }

            InitializeComponent();
            DataContext = _viewModel;
            mainWindowViewModel.PropertyChanged += MainWindowViewModel_PropertyChanged;

            EnsureDataFoldersExist();

            PopulateServerList();

            LoadUserAccounts(initialLoad: true);
            LoadImages();
            ChangeBackgroundImageRandomly();

            SubscribeToGameMonitorEvents();
            _timer          = new System.Timers.Timer(5000); // every five seconds
            _timer.Elapsed += _timer_Elapsed;
            StartStopTimerIfAutoChecked();

            if (_autoLaunchOnStart)
            {
                LaunchGame();
            }

            SteelBotLauncher.AppSettings.WpfWindowPlacementSetting.Persist(this);
        }
Exemplo n.º 2
0
        public MainWindowViewModel(AccountManager accountManager, GameSessionMap gameSessionMap, Configurator configurator)
        {
            if (accountManager == null)
            {
                throw new ArgumentException("Null AccountManager in MainWindowViewModel()", "accountManager");
            }
            if (gameSessionMap == null)
            {
                throw new ArgumentException("Null GameSessionMap in MainWindowViewModel()", "gameSessionMap");
            }
            if (configurator == null)
            {
                throw new ArgumentException("Null Configurator in MainWindowViewModel()", "configurator");
            }

            _accountManager = accountManager;
            _gameSessionMap = gameSessionMap;
            _configurator   = configurator;

            _accountManager.UserAccounts.CollectionChanged    += UserAccountsCollectionChanged;
            _accountManager.SomeAccountLaunchableChangedEvent += accountManager_SomeAccountLaunchableChangedEvent;

            NewProfileCommand     = new DelegateCommand(CreateNewProfile);
            NextProfileCommand    = new DelegateCommand(GoToNextProfile);
            PrevProfileCommand    = new DelegateCommand(GoToPrevProfile);
            DeleteProfileCommand  = new DelegateCommand(DeleteProfile);
            EditCharactersCommand = new DelegateCommand(EditCharacters);
            LoadStatusSymbols();
        }
Exemplo n.º 3
0
        public GameMonitor(GameSessionMap map, Configurator configurator)
        {
            if (map == null)
            {
                throw new Exception("Null GameSessionMap in GameMonitor()");
            }
            if (configurator == null)
            {
                throw new Exception("Null Configurator in GameMonitor()");
            }

            _map          = map;
            _configurator = configurator;
        }
Exemplo n.º 4
0
        public CommandManager(GameMonitor gameMonitor, GameSessionMap gameSessionMap)
        {
            if (gameMonitor == null)
            {
                throw new Exception("Null GameMonitor in CommandManager()");
            }
            if (gameSessionMap == null)
            {
                throw new Exception("Null GameSessionMap in CommandManager()");
            }

            _gameMonitor    = gameMonitor;
            _gameSessionMap = gameSessionMap;

            StartHandling();
        }
Exemplo n.º 5
0
        private void BeginMonitoringGame()
        {
            _configurator = new Configurator();
            RecordGameDll();
            _gameSessionMap = new GameSessionMap();
            _gameMonitor    = new GameMonitor(_gameSessionMap, _configurator);
            _accountManager = new AccountManager(_gameMonitor);
            _mainViewModel  = new MainWindowViewModel(_accountManager, _gameSessionMap, _configurator);
            _mainViewModel.RequestShowMainWindowEvent += () => _mainWindow.Show();
            _commandManager = new CommandManager(_gameMonitor, _gameSessionMap);
            bool testCommandTokenParser = true;

            if (testCommandTokenParser)
            {
                _commandManager.TestParse();
            }
            _uiGameMonitorBridge = new UiGameMonitorBridge(_gameMonitor, _mainViewModel);
            _uiGameMonitorBridge.Start();
            _gameMonitor.Start();
        }
Exemplo n.º 6
0
 public LaunchWorker(BackgroundWorker worker, GameSessionMap gameSessionMap)
 {
     _worker         = worker;
     _gameSessionMap = gameSessionMap;
     Initialize();
 }
Exemplo n.º 7
0
        private void RemoveDeadSessionByPid(int processId)
        {
            string pidkey = GameSessionMap.GetProcessIdKey(processId);

            RemoveSessionByPidKey(pidkey);
        }