Exemplo n.º 1
0
        static async Task Main()
        {
            AppDomain.CurrentDomain.ProcessExit += new EventHandler(onClose);

            steamService = OperatingSystem.IsWindows() ? new SteamServiceWindows() : new SteamServiceLinux();
            string redirectUrl = @"http://localhost:8888/";

            keySender    = new InputSenderWindows();
            keyFormatter = new KeyFormatterWindows();
            pathResolver = new PathResolver();

            requestsManager = new SpotifyRequestsManager("7633771350404368ac3e05c9cf73d187",
                                                         "29bd9ec2676c4bf593f3cc2858099838", redirectUrl);

            process = new GameProcess();
            process.Start();

            steamContext = steamService.GetSteamContext();
            var accounts = steamContext.GetAccounts();

            Console.WriteLine("Awaiting user authorization...");
            var server = new AuthServer(redirectUrl);

            string authUrl = requestsManager.GetAuthUrl().Replace("&", "^&");

            Process.Start(new ProcessStartInfo("cmd", $"/c start {authUrl}")
            {
                CreateNoWindow = true
            });
            string code = await server.GetAuthCode();

            await requestsManager.StartTokenRequests(code);

            int accSteamId3 = accounts.FirstOrDefault((x) => x.Name == steamContext.LastAccount).SteamId3;

            string writePath = pathResolver.GetWritePath(process.CurrentProcess, steamContext.UserdataPath, accSteamId3.ToString());

            configWriter = new ConfigWriter(writePath);

            Console.WriteLine("Press the bind key");
            var consoleInput = Console.ReadKey(true);

            currentKeyVirtual = (ushort)consoleInput.Key;
            currentKey        = keyFormatter.GetSourceKey(currentKeyVirtual);

            trackInfoUpdater = new SpotifyTrackUpdater(requestsManager);
            trackInfoUpdater.OnPlaybackStateUpdate += onPlaybackStateUpdate;
            trackInfoUpdater.StartPlaybackUpdate();
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();

            HeaderBlock.CloseButton.MouseLeftButtonDown +=
                new MouseButtonEventHandler((o, s) => Application.Current.Shutdown());
            HeaderBlock.CollapseButton.MouseLeftButtonDown       +=
                new MouseButtonEventHandler((o, s) => WindowState = WindowState.Minimized);

            _spotify = new SpotifyRequestsManager("7633771350404368ac3e05c9cf73d187",
                                                  "29bd9ec2676c4bf593f3cc2858099838", @"http://localhost:8888/");
            _steamService    = new SteamServiceWindows();
            _pathResolver    = new PathResolver();
            _keySender       = new InputSenderWindows();
            _appConfigWorker = new UserSettingsWorker();
            _appConfig       = _appConfigWorker.ReadConfigFile();
            _userContext     = _steamService.GetSteamContext();

            _accounts = _userContext.GetAccounts();

            _gameProcess = new GameProcess();
            _gameProcess.Start();

            int    steamid3  = _accounts.FirstOrDefault((x) => x.Name == _userContext.LastAccount).SteamId3;
            string writePath = _pathResolver.GetWritePath(_gameProcess.CurrentProcess, _userContext.UserdataPath, steamid3.ToString());

            _configWriter = new ConfigWriter(writePath, _appConfig.CfgText);

            _playbackStateUpdater = new SpotifyTrackUpdater(_spotify);
            _playbackStateUpdater.OnPlaybackStateUpdate += UpdateTrackInfo;

            UserSettingsBlock.CurrentAccountText.Text = _userContext.LastAccount;
            UserSettingsBlock.UpdateKey(_appConfig.LastUsedKey);

            if (_appConfig.IsAutoSendEnabled)
            {
                UserSettingsBlock.AutosendCheck.Toggle();
            }
        }