Пример #1
0
        public void Updates(bool password = false)
        {
            metroGrid1.DataSource = null;
            metroGrid1.Rows.Clear();
            using RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\SteamProfiles\");
            if (key != null)
            {
                string[] subkeys = key.GetSubKeyNames();
                if (subkeys.Length > 0)
                {
                    metroGrid1.Rows.Add(subkeys.Length + 1);
                    for (int i = 0; i < subkeys.Length; i++)
                    {
                        using RegistryKey k = Registry.CurrentUser.OpenSubKey($@"Software\SteamProfiles\{subkeys[i]}");
                        string[] subvalues = k.GetValueNames();
                        if (subvalues.Length > 0)
                        {
                            metroGrid1.Rows[i].Cells["UserName"].Value = Encriptor.Decypter(k.GetValue(subvalues.Where(x => x.Contains("UserName")).FirstOrDefault()).ToString());

                            metroGrid1.Rows[i].Cells["Login"].Value = Encriptor.Decypter(k.GetValue(subvalues.Where(x => x.Contains("Login")).FirstOrDefault()).ToString());
                            if (password)
                            {
                                metroGrid1.Rows[i].Cells["Password"].Value = Encriptor.Decypter(k.GetValue(subvalues.Where(x => x.Contains("Password")).FirstOrDefault()).ToString());
                            }
                            else
                            {
                                metroGrid1.Rows[i].Cells["Password"].Value = new string('*', Encriptor.Decypter(k.GetValue(subvalues.Where(x => x.Contains("Password")).FirstOrDefault()).ToString()).Length);
                            }
                            CreateSubMenu(Encriptor.Decypter(k.GetValue(subvalues.Where(x => x.Contains("Login")).FirstOrDefault()).ToString()),
                                          Encriptor.Decypter(k.GetValue(subvalues.Where(x => x.Contains("Password")).FirstOrDefault()).ToString()));
                        }
                    }
                    for (int i = 0; i < metroGrid1.RowCount - 1; i++)
                    {
                        for (int j = 0; j < metroGrid1.ColumnCount; j++)
                        {
                            if (i < 0)
                            {
                                break;
                            }
                            if (metroGrid1.Rows[i].Cells[j].Value == null || metroGrid1.Rows[i].Cells[j].Value.ToString() == "")
                            {
                                metroGrid1.Rows.RemoveAt(i);
                                i--;
                            }
                        }
                    }
                    UpdateValue();
                }
            }
            else
            {
                Registry.CurrentUser.CreateSubKey($@"Software\SteamProfiles");
                SteamPath();
            }
        }
Пример #2
0
        public void Arguments()
        {
            for (int i = 0; i < Environment.GetCommandLineArgs().Length; i++)
            {
                switch (Environment.GetCommandLineArgs()[i])
                {
                case "-silent":
                    this.WindowState    = FormWindowState.Minimized;
                    notifyIcon1.Visible = true;
                    ShowInTaskbar       = false;
                    Hide();
                    break;

                case "-h":
                    try
                    {
                        int.TryParse(Environment.GetCommandLineArgs()[i + 1], out int height);
                        Height = height;
                    }
                    catch (Exception) { }
                    break;

                case "-w":
                    try
                    {
                        int.TryParse(Environment.GetCommandLineArgs()[i + 1], out int width);
                        Width = width;
                    }
                    catch (Exception) { }
                    break;

                case "-language":
                    try
                    {
                        using (RegistryKey lang = Registry.CurrentUser.OpenSubKey(@"Software\SteamProfiles", true))
                        {
                            lang.SetValue("Language", Environment.GetCommandLineArgs()[i + 1]);
                        }
                    }
                    catch (Exception) { }
                    break;

                case "-fullscreen":
                    this.WindowState = FormWindowState.Maximized;
                    break;

                case "-remove":
                    try
                    {
                        Registry.CurrentUser.DeleteSubKey($@"Software\SteamProfiles\{Environment.GetCommandLineArgs()[i + 1]}");
                    }
                    catch (Exception) { }
                    break;

                case "-add":
                    string user = "", login = "", password = "";
                    if (Environment.GetCommandLineArgs()[i + 1][0] != '-')
                    {
                        user = Environment.GetCommandLineArgs()[i + 1];
                    }
                    else
                    {
                        break;
                    }
                    if (Environment.GetCommandLineArgs()[i + 2][0] != '-')
                    {
                        login = Environment.GetCommandLineArgs()[i + 2];
                    }
                    else
                    {
                        break;
                    }
                    if (Environment.GetCommandLineArgs()[i + 3][0] != '-')
                    {
                        password = Environment.GetCommandLineArgs()[i + 3];
                    }
                    else
                    {
                        break;
                    }
                    using (RegistryKey key = Registry.CurrentUser.CreateSubKey($@"Software\SteamProfiles\{login}"))
                    {
                        user     = Encriptor.Encypter(user);
                        login    = Encriptor.Encypter(login);
                        password = Encriptor.Encypter(password);
                        key.SetValue("UserName", user);

                        key.SetValue("Login", login);

                        key.SetValue("Password", password);
                    }
                    i += 3;
                    break;

                case "-theme":
                    string input_theme = Environment.GetCommandLineArgs()[i + 1];
                    foreach (AvaibleThemes item in Enum.GetValues(typeof(AvaibleThemes)))
                    {
                        if (item.ToString().ToLower() == input_theme.ToLower())
                        {
                            using (RegistryKey key = Registry.CurrentUser.CreateSubKey($@"Software\SteamProfiles"))
                            {
                                key.SetValue("Mode", item);
                                ThemeMode();
                            }
                            break;
                        }
                    }
                    break;

                default:
                    break;
                }
            }
        }