private void TryToRestoreSessionPlacementInfo(GameSession session) { bool restoreWindows = Properties.Settings.Default.RestoreGameWindows; if (!restoreWindows) { return; } string key = GameMonitor.GetSessionSettingsKey(Server: session.ServerName, Account: session.AccountName); var settings = PersistenceHelper.SettingsFactory.Get(); string placementString = settings.GetString(key); IntPtr hwnd = session.WindowHwnd; var prevPlacement = WindowPlacementUtil.WindowPlacement.GetPlacementFromString(placementString); if (prevPlacement.length > 0) { var placementInfo = WindowPlacementUtil.WindowPlacement.GetPlacementInfo(hwnd); if (AreSameNormalSize(prevPlacement, placementInfo.Placement)) { Logger.WriteDebug("Windows are same normal size."); WindowPlacementUtil.WindowPlacement.SetPlacement(hwnd, prevPlacement); } else { Logger.WriteDebug("Windows are not the same normal size."); Logger.WriteDebug("PREVPLACEMENT - Height:" + GetNormalHeight(prevPlacement) + " width:" + GetNormalWidth(prevPlacement)); Logger.WriteDebug("PLACEMENT - Height:" + GetNormalHeight(placementInfo.Placement) + " width:" + GetNormalWidth(placementInfo.Placement)); } } Logger.WriteDebug("Restored game position server: {0}, account: {1}", session.ServerName, session.AccountName); }
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(); } ThwargLauncher.AppSettings.WpfWindowPlacementSetting.Persist(this); }
public UiGameMonitorBridge(GameMonitor gameMonitor, MainWindowViewModel viewModel) { if (gameMonitor == null) { throw new Exception("Null GameMonitor in UiGameMonitorBridge()"); } if (viewModel == null) { throw new Exception("Null MainWindowViewModel in UiGameMonitorBridge()"); } _gameMonitor = gameMonitor; _viewModel = viewModel; _uicontext = SynchronizationContext.Current; }
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(); }
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; _uicontext = SynchronizationContext.Current; _viewModel.OpeningSimpleLauncherEvent += () => this.Hide(); _viewModel.LaunchingSimpleGameEvent += (li) => this.LaunchSimpleClient(li); CheckForProgramUpdate(); InitializeComponent(); DataContext = _viewModel; mainWindowViewModel.PropertyChanged += MainWindowViewModel_PropertyChanged; MigrateSettingsIfNeeded(); EnsureDataFoldersExist(); PopulateServerList(); LoadUserAccounts(initialLoad: true); LoadImages(); ChangeBackgroundImageRandomly(); WireUpBackgroundWorker(); if (Properties.Settings.Default.ACLocation != "") { txtLauncherLocation.Text = Properties.Settings.Default.ACLocation; } ThwargLauncher.AppSettings.WpfWindowPlacementSetting.Persist(this); }
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; _uicontext = SynchronizationContext.Current; _viewModel.OpeningSimpleLauncherEvent += () => this.Hide(); _viewModel.LaunchingSimpleGameEvent += (li) => this.LaunchSimpleClient(li); CheckForProgramUpdate(); InitializeComponent(); DataContext = _viewModel; mainWindowViewModel.PropertyChanged += MainWindowViewModel_PropertyChanged; MigrateSettingsIfNeeded(); EnsureDataFoldersExist(); PopulateServerList(); LoadUserAccounts(initialLoad: true); LoadImages(); ChangeBackgroundImageRandomly(); WireUpBackgroundWorker(); SubscribeToGameMonitorEvents(); _timer = new System.Timers.Timer(5000); // every five seconds _timer.Elapsed += _timer_Elapsed; _timer.Enabled = ConfigSettings.GetConfigBool("AutoRelaunch", false); ThwargLauncher.AppSettings.WpfWindowPlacementSetting.Persist(this); }
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(); }
private void BeginMonitoringGame() { // Logger is a static object, so it already exists string logfilepath = GetLauncherLogPath(); _logWriter = new LogWriter(logfilepath); _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(); }
public AccountManager(GameMonitor gameMonitor) { _gameMonitor = gameMonitor; _gameMonitor.CharacterFileChanged += _gameMonitor_CharacterFileChanged; }