Exemple #1
0
        public static string CheckSteamPath()
        {
            var settingsFile = new IniFile("SAMSettings.ini");

            string steamPath = settingsFile.Read("Path", "Steam");

            int tryCount = 0;

            // If Steam's filepath was not specified in settings or is invalid, attempt to find it and save it.
            while (steamPath == null || !File.Exists(steamPath + "\\steam.exe"))
            {
                // Check registry keys first.
                string regPath   = GetSteamPathFromRegistry();
                string localPath = System.Windows.Forms.Application.StartupPath;

                if (Directory.Exists(regPath))
                {
                    steamPath = regPath;
                }

                // Check if SAM is isntalled in Steam directory.
                // Useful for users in portable mode.
                else if (File.Exists(localPath + "\\steam.exe"))
                {
                    steamPath = localPath;
                }

                // Prompt user for manual selection.
                else
                {
                    if (tryCount == 0)
                    {
                        MessageBox.Show("Could not find Steam path automatically.\n\nPlease select Steam manually.");
                    }

                    // Create OpenFileDialog
                    OpenFileDialog dlg = new OpenFileDialog
                    {
                        DefaultExt = ".exe",
                        Filter     = "Steam (*.exe)|*.exe"
                    };

                    // Display OpenFileDialog by calling ShowDialog method
                    Nullable <bool> result = dlg.ShowDialog();

                    // Get the selected file path
                    if (result == true)
                    {
                        steamPath = Path.GetDirectoryName(dlg.FileName) + "\\";
                    }
                }

                if (steamPath == null || steamPath == string.Empty)
                {
                    MessageBoxResult messageBoxResult = MessageBox.Show("Steam path required!\n\nTry again?", "Confirm", MessageBoxButton.YesNo);

                    if (messageBoxResult.Equals(MessageBoxResult.No))
                    {
                        Environment.Exit(0);
                    }
                }

                tryCount++;
            }

            // Save path to settings file.
            settingsFile.Write("Path", steamPath, "Steam");

            return(steamPath);
        }
Exemple #2
0
        private void editEntry(object butt)
        {
            Button button = butt as Button;
            int    index  = Int32.Parse(button.Tag.ToString());

            var dialog = new TextDialog();

            dialog.AccountText     = decryptedAccounts[index].Name;
            dialog.PasswordText    = decryptedAccounts[index].Password;
            dialog.UrlText         = decryptedAccounts[index].ProfUrl;
            dialog.DescriptionText = decryptedAccounts[index].Description;

            // Reload slected boolean
            if (settingsFile.Read("Selected", "AutoLog") == "True")
            {
                selected = true;
            }
            else
            {
                selected = false;
            }

            if (selected == true && selectedAcc == index)
            {
                dialog.autoLogCheckBox.IsChecked = true;
            }

            if (dialog.ShowDialog() == true)
            {
                string aviUrl = htmlAviScrape(dialog.UrlText);

                // If the auto login checkbox was checked, update settings file and global variables.
                if (dialog.AutoLogAccountIndex == true)
                {
                    settingsFile.Write("SelectedAcc", button.Tag.ToString(), "AutoLog");
                    settingsFile.Write("Selected", "True", "AutoLog");
                    settingsFile.Write("Recent", "False", "AutoLog");
                    selected    = true;
                    recent      = false;
                    selectedAcc = index;
                }
                else
                {
                    settingsFile.Write("SelectedAcc", "-1", "AutoLog");
                    settingsFile.Write("Selected", "False", "AutoLog");
                    selected    = false;
                    selectedAcc = -1;
                }

                try
                {
                    // Encrypt info before saving to file
                    ePassword = StringCipher.Encrypt(dialog.PasswordText, eKey);

                    encryptedAccounts[index].Name        = dialog.AccountText;
                    encryptedAccounts[index].Password    = ePassword;
                    encryptedAccounts[index].ProfUrl     = dialog.UrlText;
                    encryptedAccounts[index].AviUrl      = aviUrl;
                    encryptedAccounts[index].Description = dialog.DescriptionText;

                    Utils.Serialize(encryptedAccounts);
                    RefreshWindow();
                }
                catch (Exception m)
                {
                    MessageBox.Show(m.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    editEntry(butt);
                }
            }
        }
Exemple #3
0
        private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Verion number from assembly
            AssemblyVer = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            MenuItem ver = new MenuItem();
            MenuItem newExistMenuItem = (MenuItem)this.FileMenu.Items[2];

            ver.Header    = "v" + AssemblyVer;
            ver.IsEnabled = false;
            newExistMenuItem.Items.Add(ver);

            // Check for a new version.
            if (await UpdateCheck.CheckForUpdate("http://textuploader.com/58mva/raw") == 1)
            {
                // An update is available, but user has chosen not to update.
                ver.Header    = "Update Available!";
                ver.Click    += Ver_Click;
                ver.IsEnabled = true;
            }

            // If no settings file exists, create one and initialize values.
            if (!File.Exists("SAMSettings.ini"))
            {
                settingsFile = new IniFile("SAMSettings.ini");
                settingsFile.Write("Version", AssemblyVer, "System");
                settingsFile.Write("AccountsPerRow", "5", "Settings");
                settingsFile.Write("StartWithWindows", "False", "Settings");
                settingsFile.Write("StartMinimized", "False", "Settings");
                settingsFile.Write("AccountsPerRow", "5", "Settings");
                settingsFile.Write("Recent", "False", "AutoLog");
                settingsFile.Write("RecentAcc", "", "AutoLog");
                settingsFile.Write("Selected", "False", "AutoLog");
                settingsFile.Write("SelectedAcc", "", "AutoLog");
                accPerRow = "5";
            }
            // Else load settings from preexisting file.
            else
            {
                settingsFile = new IniFile("SAMSettings.ini");
                accPerRow    = settingsFile.Read("AccountsPerRow", "Settings");

                if (!Regex.IsMatch(accPerRow, @"^\d+$") || Int32.Parse(accPerRow) < 1)
                {
                    accPerRow = "1";
                }

                if (settingsFile.KeyExists("Steam", "Settings"))
                {
                    steamPath = settingsFile.Read("Steam", "Settings");
                }

                // If the recent autolog entry exists and is set to true.
                // else create defualt settings file entry.
                if (settingsFile.KeyExists("Recent", "AutoLog") && settingsFile.Read("Recent", "AutoLog") == "True" && Int32.Parse(settingsFile.Read("RecentAcc", "AutoLog")) >= 0)
                {
                    recent    = true;
                    recentAcc = Int32.Parse(settingsFile.Read("RecentAcc", "AutoLog"));
                }
                else if (!settingsFile.KeyExists("Recent", "AutoLog"))
                {
                    settingsFile.Write("Recent", "False", "AutoLog");
                    settingsFile.Write("RecentAcc", "-1", "AutoLog");
                }

                // If the selected autolog entry exists and is set to true.
                // else create defualt settings file entry.
                if (settingsFile.KeyExists("Selected", "AutoLog") && settingsFile.Read("Selected", "AutoLog") == "True")
                {
                    selected    = true;
                    selectedAcc = Int32.Parse(settingsFile.Read("SelectedAcc", "AutoLog"));
                }
                else if (!settingsFile.KeyExists("Selected", "AutoLog"))
                {
                    settingsFile.Write("Selected", "False", "AutoLog");
                    settingsFile.Write("SelectedAcc", "-1", "AutoLog");
                }

                if (settingsFile.KeyExists("StartMinimized", "Settings") && settingsFile.Read("StartMinimized", "Settings") == "True")
                {
                    WindowState = WindowState.Minimized;
                }
                else if (!settingsFile.KeyExists("StartMinimized", "Settings"))
                {
                    settingsFile.Write("StartMinimized", "False", "Settings");
                }

                if (File.Exists("info.dat"))
                {
                    StreamReader datReader = new StreamReader("info.dat");
                    string       temp      = datReader.ReadLine();
                    datReader.Close();

                    // If the user is some how using an older info.dat, delete it.
                    if (!temp.Contains("xml"))
                    {
                        MessageBox.Show("Your info.dat is out of date and must be deleted.\nSorry for the inconvenience!", "Invalid File", MessageBoxButton.OK, MessageBoxImage.Information);

                        try
                        {
                            File.Delete("info.dat");
                        }
                        catch (Exception m)
                        {
                            Console.WriteLine(m.Message);
                        }
                    }
                }
                settingsFile.Write("Version", AssemblyVer, "System");
            }

            // Load window with account buttons.
            RefreshWindow();

            // Login to auto log account if enabled and steam is not already open.
            Process[] SteamProc = Process.GetProcessesByName("Steam");

            if (SteamProc.Length == 0)
            {
                if (recent == true)
                {
                    Login(recentAcc);
                }
                else if (selected == true)
                {
                    Login(selectedAcc);
                }
            }
        }
Exemple #4
0
        private void LoadSettings()
        {
            settingsFile = new IniFile("SAMSettings.ini");
            accPerRow    = settingsFile.Read("AccountsPerRow", "Settings");

            if (!Regex.IsMatch(accPerRow, @"^\d+$") || Int32.Parse(accPerRow) < 1)
            {
                accPerRow = "1";
            }

            if (settingsFile.KeyExists("Steam", "Settings"))
            {
                steamPath = settingsFile.Read("Steam", "Settings");
            }
            else
            {
                // Find Steam
                Utils.CheckSteamPath();
            }

            // If the recent autolog entry exists and is set to true.
            // else create defualt settings file entry.
            if (settingsFile.KeyExists("Recent", "AutoLog") && settingsFile.Read("Recent", "AutoLog") == "True")
            {
                int tryParseResult = -1;
                Int32.TryParse(settingsFile.Read("RecentAcc", "AutoLog"), out tryParseResult);

                if (tryParseResult != -1)
                {
                    recent    = true;
                    recentAcc = tryParseResult;
                }
                else
                {
                    settingsFile.Write("Recent", "False", "AutoLog");
                }
            }
            else if (!settingsFile.KeyExists("Recent", "AutoLog"))
            {
                settingsFile.Write("Recent", "False", "AutoLog");
                settingsFile.Write("RecentAcc", "-1", "AutoLog");
            }

            // If the selected autolog entry exists and is set to true.
            // else create defualt settings file entry.
            if (settingsFile.KeyExists("Selected", "AutoLog") && settingsFile.Read("Selected", "AutoLog") == "True")
            {
                int tryParseResult = -1;
                Int32.TryParse(settingsFile.Read("SelectedAcc", "AutoLog"), out tryParseResult);

                if (tryParseResult != -1)
                {
                    selected    = true;
                    selectedAcc = tryParseResult;
                }
                else
                {
                    settingsFile.Write("Selected", "False", "AutoLog");
                }
            }
            else if (!settingsFile.KeyExists("Selected", "AutoLog"))
            {
                settingsFile.Write("Selected", "False", "AutoLog");
                settingsFile.Write("SelectedAcc", "-1", "AutoLog");
            }

            if (settingsFile.KeyExists("StartMinimized", "Settings") && settingsFile.Read("StartMinimized", "Settings") == "True")
            {
                WindowState = WindowState.Minimized;
            }
            else if (!settingsFile.KeyExists("StartMinimized", "Settings"))
            {
                settingsFile.Write("StartMinimized", "False", "Settings");
            }

            if (File.Exists("info.dat"))
            {
                StreamReader datReader = new StreamReader("info.dat");
                string       temp      = datReader.ReadLine();
                datReader.Close();

                // If the user is some how using an older info.dat, delete it.
                if (!temp.Contains("xml"))
                {
                    MessageBox.Show("Your info.dat is out of date and must be deleted.\nSorry for the inconvenience!", "Invalid File", MessageBoxButton.OK, MessageBoxImage.Information);

                    try
                    {
                        File.Delete("info.dat");
                    }
                    catch (Exception m)
                    {
                        Console.WriteLine(m.Message);
                    }
                }
            }

            settingsFile.Write("Version", AssemblyVer, "System");
        }