Ejemplo n.º 1
0
        public bool LoginBnet(SteamAccount b)
        {
            if (!IsSteamRunning())
            {
                LogoutSteam();
            }
            FileUpdateManager.Updater();
            Process ahk = new Process {
                StartInfo = new ProcessStartInfo(@"main.ahk", b.Username + " " + b.Password)
            };

            ahk.Start();
            _recentSteamAccount = b;
            ScheduleHandleAutoStart();
            return(true);
        }
Ejemplo n.º 2
0
        public MainWindow()
        {
            try
            {
                // Set application directory to %appdata%
                // Ref: https://github.com/ProAltis/Launcher/blob/master/ProjectAltisLauncher/Program.cs#L35
                string filesDir = Path.Combine(_appDataPath, "battlenetswitcher");
                if (!Directory.Exists(filesDir))
                {
                    Directory.CreateDirectory(filesDir);
                }
                Directory.SetCurrentDirectory(filesDir);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                MessageBox.Show($"There was an error creating the installation directory:" +
                                $"\n{e.Message}\nPlease report this on the github page:\n" +
                                $"https://github.com/Squirrel/Squirrel.Windows/issues");
                Environment.Exit(0);
            }
            InitializeComponent();

            FileUpdateManager.Updater();

            Top    = Properties.Settings.Default.Top;
            Left   = Properties.Settings.Default.Left;
            Height = Properties.Settings.Default.Height;
            Width  = Properties.Settings.Default.Width;

            if (Properties.Settings.Default.Maximized)
            {
                WindowState = WindowState.Maximized;
            }

            _accountList = new AccountList();

            //Get directory of Executable
            //GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase)?.TrimStart(@"file:\\".ToCharArray());

            buttonInfo.ToolTip = "Build Version: " + Assembly.GetEntryAssembly().GetName().Version;

            try
            {
                ReadAccountsFromFile();
            }
            catch
            {
                //Maybe create file?
            }



            listBoxAccounts.ItemsSource = _accountList.Accounts;
            listBoxAccounts.Items.Refresh();

            if (_accountList.InstallDir == "" || (_accountList.InstallDir == null))
            {
                _accountList.InstallDir = SelectSteamFile();
                if (_accountList.InstallDir == null)
                {
                    MessageBox.Show("You cannot use Battle.net switcher without selecting your Battle.net.exe. Program will close now.", "BNET missing", MessageBoxButton.OK, MessageBoxImage.Error);
                    Close();
                }
            }

            _steam = new Steam(_accountList.InstallDir);

#if !DEBUG
            FileUpdateManager.PerformStartupCheck();
#endif
        }