Пример #1
0
        public void HandleDeprecatedSettings()
        {
            // Update Recent and Selected login setting names.
            if (File.KeyExists("Recent", SECTION_AUTOLOG))
            {
                File.Write(LOGIN_RECENT_ACCOUNT, File.Read("Recent", SECTION_AUTOLOG), SECTION_AUTOLOG);
                File.DeleteKey("Recent", SECTION_AUTOLOG);
            }
            if (File.KeyExists("RecentAcc", SECTION_AUTOLOG))
            {
                File.Write(RECENT_ACCOUNT_INDEX, File.Read("RecentAcc", SECTION_AUTOLOG), SECTION_AUTOLOG);
                File.DeleteKey("RecentAcc", SECTION_AUTOLOG);
            }
            if (File.KeyExists("Selected", SECTION_AUTOLOG))
            {
                File.Write(LOGIN_SELECTED_ACCOUNT, File.Read("Selected", SECTION_AUTOLOG), SECTION_AUTOLOG);
                File.DeleteKey("Selected", SECTION_AUTOLOG);
            }
            if (File.KeyExists("SelectedAcc", SECTION_AUTOLOG))
            {
                File.Write(SELECTED_ACCOUNT_INDEX, File.Read("SelectedAcc", SECTION_AUTOLOG), SECTION_AUTOLOG);
                File.DeleteKey("SelectedAcc", SECTION_AUTOLOG);
            }

            // Move Steam file path to it's own section.
            if (File.KeyExists(SECTION_STEAM, SECTION_GENERAL))
            {
                File.Write(STEAM_PATH, File.Read(SECTION_STEAM, SECTION_GENERAL), SECTION_STEAM);
                File.DeleteKey(SECTION_STEAM, SECTION_GENERAL);
            }

            // Move button size to 'Customize' section.
            if (File.KeyExists(BUTTON_SIZE, SECTION_GENERAL))
            {
                File.Write(BUTTON_SIZE, File.Read(BUTTON_SIZE, SECTION_GENERAL), SECTION_CUSTOMIZE);
                File.DeleteKey(BUTTON_SIZE, SECTION_GENERAL);
            }

            // Update developer launch parameter.
            if (File.KeyExists("developer", SECTION_PARAMETERS))
            {
                File.Write(DEVELOPER_PARAMETER, File.Read("developer", SECTION_PARAMETERS), SECTION_PARAMETERS);
                File.DeleteKey("developer", SECTION_PARAMETERS);
            }
        }
Пример #2
0
        public void HandleDeprecatedSettings()
        {
            // Update Recent and Selected login setting names.
            if (File.KeyExists("Recent", "AutoLog"))
            {
                File.Write("LoginRecentAccount", File.Read("Recent", "AutoLog"), "AutoLog");
                File.DeleteKey("Recent", "AutoLog");
            }
            if (File.KeyExists("RecentAcc", "AutoLog"))
            {
                File.Write("RecentAccountIndex", File.Read("RecentAcc", "AutoLog"), "AutoLog");
                File.DeleteKey("RecentAcc", "AutoLog");
            }
            if (File.KeyExists("Selected", "AutoLog"))
            {
                File.Write("LoginSelectedAccount", File.Read("Selected", "AutoLog"), "AutoLog");
                File.DeleteKey("Selected", "AutoLog");
            }
            if (File.KeyExists("SelectedAcc", "AutoLog"))
            {
                File.Write("SelectedAccountIndex", File.Read("SelectedAcc", "AutoLog"), "AutoLog");
                File.DeleteKey("SelectedAcc", "AutoLog");
            }

            // Move Steam file path to it's own section.
            if (File.KeyExists("Steam", "Settings"))
            {
                File.Write("Path", File.Read("Steam", "Settings"), "Steam");
                File.DeleteKey("Steam", "Settings");
            }

            // Move button size to 'Customize' section.
            if (File.KeyExists("ButtonSize", "Settings"))
            {
                File.Write("ButtonSize", File.Read("ButtonSize", "Settings"), "Customize");
                File.DeleteKey("ButtonSize", "Settings");
            }
        }
Пример #3
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");
            }

            // 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");
        }
Пример #4
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);
                }
            }
        }