コード例 #1
1
ファイル: Steam.cs プロジェクト: Trontor/SteamAccountSwitcher
        public bool StartSteamAccount(SteamAccount a)
        {
            bool finished = false;

            if(IsSteamRunning())
            {
                KillSteam();
            }

            while (finished == false)
            {
                if (IsSteamRunning() == false)
                {
                    Process p = new Process();
                    if (File.Exists(installDir))
                    {
                        p.StartInfo = new ProcessStartInfo(installDir, a.getStartParameters());
                        p.Start();
                        finished = true;
                        return true;
                    }
                }
            }
            return false;
        }
コード例 #2
0
        public void Restore(SteamAccount newAccount)
        {
            // Restore from backup

            steamReg.SetValue("AlreadyRetriedOfflineMode", newAccount.offline, RegistryValueKind.DWord);
            steamReg.SetValue("AutoLoginUser", newAccount.username);
            steamReg.SetValue("PseudoUUID", newAccount.uuid);

            string sourceFile, newFile;

            // Restore %STEAM%/config/config.vdf
            sourceFile = newAccount.filePath + "/steamfiles/config/config.vdf";
            newFile    = Path + "/config/config.vdf";
            if (System.IO.File.Exists(sourceFile))
            {
                if (System.IO.File.Exists(newFile))
                {
                    System.IO.File.Delete(newFile);
                }
                System.IO.File.Copy(sourceFile, newFile);
            }

            // Restore %STEAM%/ssfn* files
            foreach (string file in System.IO.Directory.GetFiles(newAccount.filePath + "/steamfiles/", "ssfn*").Select(System.IO.Path.GetFileName))
            {
                sourceFile = newAccount.filePath + "/steamfiles/" + file;
                newFile    = Path + "/" + file;
                if (System.IO.File.Exists(newFile))
                {
                    System.IO.File.Delete(newFile);
                }
                System.IO.File.Copy(sourceFile, newFile);
            }
        }
コード例 #3
0
        public bool StartSteamAccount(SteamAccount a)
        {
            //LogoutSteam();
            LoginBnet(a);

            return(false);
        }
コード例 #4
0
        public bool LoginBnet(SteamAccount b)
        {
            if (!IsSteamRunning())
            {
                LogoutSteam();
            }
            if (DownloadMissing.CheckIfMissing())
            {
                var messBox = MessageBox.Show("Autohotkey file not found. Would you like to download it? \n Clicking yes will download from github over HTTPS \n Clicking no will prevent login. ", "Battle.net Switcher", MessageBoxButton.YesNo);
                if (messBox == MessageBoxResult.Yes)
                {
                    DownloadMissing.Download();
                }
                else
                {
                    return(false);
                }
            }
            Process ahk = new Process {
                StartInfo = new ProcessStartInfo(AppDomain.CurrentDomain.BaseDirectory + @"\main.ahk", b.Username + " " + b.Password)
            };

            ahk.Start();
            return(true);
        }
コード例 #5
0
        public bool StartSteamAccount(SteamAccount a)
        {
            bool finished = false;

            if (IsSteamRunning())
            {
                KillSteam();
            }

            while (finished == false)
            {
                if (IsSteamRunning() == false)
                {
                    Process p = new Process();
                    if (File.Exists(installDir))
                    {
                        p.StartInfo = new ProcessStartInfo(installDir, a.getStartParameters());
                        p.Start();
                        finished = true;
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #6
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (account != null)
     {
         if (account.Username == "" || account.Username == null)
         {
             account = null;
         }
     }
 }
コード例 #7
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (account != null)
     {
         if (account.Username == "" || account.Username == null)
         {
             account = null;
         }
     }
 }
コード例 #8
0
        public AddAccount(SteamAccount editAccount)
        {
            InitializeComponent();
            account = editAccount;
            comboBoxType.ItemsSource = Enum.GetValues(typeof(AccountType));

            comboBoxType.SelectedItem = editAccount.Type;
            textBoxProfilename.Text   = editAccount.Name;
            textBoxUsername.Text      = editAccount.Username;
            textBoxPassword.Password  = editAccount.Password;
        }
コード例 #9
0
        public AddAccount(SteamAccount editAccount)
        {
            InitializeComponent();
            account = editAccount;
            comboBoxType.ItemsSource = Enum.GetValues(typeof(AccountType));

            comboBoxType.SelectedItem = editAccount.Type;
            textBoxProfilename.Text = editAccount.Name;
            textBoxUsername.Text = editAccount.Username;
            textBoxPassword.Password = editAccount.Password;
            
        }
コード例 #10
0
        public AddAccount(SteamAccount editAccount)
        {
            InitializeComponent();
            account = editAccount;

            tb_Name.Text         = editAccount.Name;
            tb_Username.Text     = editAccount.Username;
            tb_Password.Password = editAccount.Password;

            btn_Add.Content = "Edit";
            Title           = "Edit Acount";
        }
コード例 #11
0
        private void btn_Add_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                account = new SteamAccount(tb_Name.Text, tb_Username.Text, tb_Password.Password);
            }
            catch
            {
                account = null;
            }

            Close();
        }
コード例 #12
0
        private void li_Accounts_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (Properties.Settings.Default.SteamDirectory == "Select Steam Directory")
            {
                Settings newSettingsWindow = new Settings();
                newSettingsWindow.Owner = this;
                newSettingsWindow.requiredValidator.Visibility = Visibility.Visible;
                newSettingsWindow.ShowDialog();
            }
            steam = new Steam(Properties.Settings.Default.SteamDirectory);
            SteamAccount selectedAcc = (SteamAccount)li_Accounts.SelectedItem;

            steam.StartSteamAccount(selectedAcc);
        }
コード例 #13
0
 private void buttonSave_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         account.Type = (AccountType)comboBoxType.SelectedItem;
         account.Name = textBoxProfilename.Text;
         account.Username = textBoxUsername.Text;
         account.Password = textBoxPassword.Password;
     }
     catch
     {
         account = null;
     }
     Close();
 }
コード例 #14
0
 private void buttonSave_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         account.Type     = (AccountType)comboBoxType.SelectedItem;
         account.Name     = textBoxProfilename.Text;
         account.Username = textBoxUsername.Text;
         account.Password = textBoxPassword.Password;
     }
     catch
     {
         account = null;
     }
     Close();
 }
コード例 #15
0
        private void Image_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Image itemClicked = (Image)e.Source;

            SteamAccount     selectedAcc  = (SteamAccount)itemClicked.DataContext;
            MessageBoxResult dialogResult = MessageBox.Show("Are you sure you want to delete the '" + selectedAcc.Name + "' account?", "Delete Account", MessageBoxButton.YesNo);

            if (dialogResult == MessageBoxResult.Yes)
            {
                accountList.Accounts.Remove((SteamAccount)listBoxAccounts.SelectedItem);
                listBoxAccounts.Items.Refresh();
            }
            else if (dialogResult == MessageBoxResult.No)
            {
                //do something else
            }
        }
コード例 #16
0
        private void btn_Remove_Click(object sender, RoutedEventArgs e)
        {
            Button       buttonClicked = (Button)e.Source;
            SteamAccount selectedAcc   = (SteamAccount)buttonClicked.DataContext;

            MessageBoxResult result = MessageBox.Show($"Are you sure you want to delete {selectedAcc.Username}", "Delete Account", MessageBoxButton.YesNo);

            switch (result)
            {
            case MessageBoxResult.Yes:
                accountList.Accounts.Remove(selectedAcc);
                li_Accounts.Items.Refresh(); break;

            case MessageBoxResult.Cancel:
                break;
            }
        }
コード例 #17
0
        public void Backup(string outputDir)
        {
            SteamAccount currentAccount = GetCurrentUser();

            UpdateInfo(currentAccount);
            string sourceFile, newFile;
            string userFolder = outputDir + "/" + currentAccount.username;

            System.IO.Directory.CreateDirectory(userFolder + "/steamfiles/config/");

            // Backup %STEAM%/config/config.vdf
            sourceFile = Path + "/config/config.vdf";
            newFile    = userFolder + "/steamfiles/config/config.vdf";
            if (System.IO.File.Exists(sourceFile))
            {
                if (System.IO.File.Exists(newFile))
                {
                    System.IO.File.Delete(newFile);
                }
                System.IO.File.Copy(sourceFile, newFile);
            }

            // Backup %STEAM%/ssfn* files
            foreach (string file in System.IO.Directory.GetFiles(Path, "ssfn*").Select(System.IO.Path.GetFileName))
            {
                sourceFile = Path + "/" + file;
                newFile    = userFolder + "/steamfiles/" + file;
                if (System.IO.File.Exists(newFile))
                {
                    System.IO.File.Delete(newFile);
                }
                System.IO.File.Copy(sourceFile, newFile);
            }

            // Export data
            newFile = userFolder + "/account.json";
            if (System.IO.File.Exists(newFile))
            {
                System.IO.File.Delete(newFile);
            }

            string jsonString = JsonConvert.SerializeObject(currentAccount);

            System.IO.File.WriteAllText(newFile, jsonString);
        }
コード例 #18
0
        public void buildMenu()
        {
            // Current account
            if (updateInfoThread != null)
            {
                updateInfoThread.Abort();
            }
            currentUser.Items.Clear();
            if (steam.IsAuthorized())
            {
                currentUser.Items.Add(steam.GetCurrentUser());
                // Get avatar & profile name [sync void]
                updateInfoThread = new Thread(() => {
                    steam.UpdateInfo((SteamAccount)currentUser.Items[0]);
                    Dispatcher.Invoke((Action)(() =>
                    {
                        currentUser.Items.Refresh();
                    }));
                });
                updateInfoThread.Start();
            }

            // Other accounts
            steamAccounts.Items.Clear();
            if (System.IO.Directory.Exists(accountDir))
            {
                foreach (string subdirectory in System.IO.Directory.GetDirectories(accountDir).Select(System.IO.Path.GetFileName))
                {
                    string profileDir = accountDir + "/" + subdirectory;
                    string configFile = profileDir + "/account.json";
                    if (System.IO.File.Exists(configFile))
                    {
                        SteamAccount account = JsonConvert.DeserializeObject <SteamAccount>(System.IO.File.ReadAllText(configFile));
                        account.selected = false;
                        account.filePath = profileDir;

                        if (currentUser.Items.Count == 0 || !(((SteamAccount)currentUser.Items[0]).selected && ((SteamAccount)currentUser.Items[0]).username == account.username))
                        {
                            steamAccounts.Items.Add(account);
                        }
                    }
                }
            }
        }
コード例 #19
0
        public void StartSteamAccount(SteamAccount a)
        {
            var counter = 0;

            while (IsSteamRunning())
            {
                if (counter > 10)
                {
                    throw new Exception("Could not stop Steam");
                }
                KillSteam();
                counter++;
            }

            var p = new Process();

            p.StartInfo = new ProcessStartInfo(SteamPath, a.GetStartParameters());
            p.Start();
        }
コード例 #20
0
        public void UpdateInfo(SteamAccount account)
        {
            HttpWebRequest  req          = (HttpWebRequest)WebRequest.Create("https://steamcommunity.com/profiles/" + account.steamID);
            HttpWebResponse response     = (HttpWebResponse)req.GetResponse();
            Stream          resStream    = response.GetResponseStream();
            var             sr           = new StreamReader(response.GetResponseStream());
            string          responseText = sr.ReadToEnd();

            Match m;

            m = Regex.Match(responseText, "<div class=\"playerAvatarAutoSizeInner\">[\\s\\S]+?<img src=\"(https:\\/\\/cdn.cloudflare.steamstatic.com\\/steamcommunity\\/public\\/images\\/avatars\\/[\\s\\S]+?)\">", RegexOptions.IgnoreCase);
            if (m.Success)
            {
                account.profilePhoto = m.Groups[1].Value;
            }

            m = Regex.Match(responseText, "<span class=\"actual_persona_name\">([\\s\\S]+?)<\\/span>", RegexOptions.IgnoreCase);
            if (m.Success)
            {
                account.name = m.Groups[1].Value;
            }
        }
コード例 #21
0
 public AddAccount()
 {
     account = new SteamAccount();
     InitializeComponent();
     comboBoxType.ItemsSource = Enum.GetValues(typeof(AccountType));
 }
コード例 #22
0
        private void listBoxAccounts_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            SteamAccount selectedAcc = (SteamAccount)listBoxAccounts.SelectedItem;

            steam.StartSteamAccount(selectedAcc);
        }
コード例 #23
0
 public AddAccount()
 {
     account = new SteamAccount();
     InitializeComponent();
     comboBoxType.ItemsSource = Enum.GetValues(typeof(AccountType));
 }