Esempio 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();
        }
Esempio n. 2
0
        private async void WindowLoaded(object sender, RoutedEventArgs e)
        {
            AcrylicMaterial.EnableBlur(this);
            this.Hide();
            string code = await AskCode();

            if (code == default)
            {
                Application.Current.Shutdown();
            }

            await _spotify.StartTokenRequests(code);

            _playbackStateUpdater.StartPlaybackUpdate();
            this.Show();
        }