Code:
using System;
using System****;
using System.Diagnostics;
using System.Windows.Forms;
using System.Drawing;
using Microsoft.Win32;
using System.Text;
using System.Net;
using System****.Compression;
using IWshRuntimeLibrary;
using MetroFramework;
using System.Data;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Security.Cryptography;
using System.Linq;
namespace Steam_Account_Manager
{
public partial class form_main : MetroFramework.Forms.MetroForm
{
// Main Form
public form_main()
{
this.ShowInTaskbar = true;
InitializeComponent();
ListAccounts1.Items.Clear();
read_settings();
this.StyleManager = msmMain;
metroTabControl1.StyleManager = msmMain;
GetStyle();
}
// Kill Steam.exe Process
void kill_steam()
{
try
{
Process[] proc = Process.GetProcessesByName("Steam");
proc[0].Kill();
listBox1.Items.Add(" - Killed Steam.exe Process");
}
catch { }
}
//Log Into Steam
void login_steam(string steam_location, string username, string password)
{
Process.Start(steam_location, " -login " + username + " " + Decrypt(password));
listBox1.Items.Add(" - Attempted Steam Login Under Account Name '" + username + "'");
}
//Write Settings
public void write_settings()
{
string output = "";
foreach (ListViewItem item in ListAccounts1.Items)
{
for (int i = 0; i < item.SubItems.Count; i++)
output += item.SubItems[i].Text.Replace("|", "/") + "|";
output += Environment.NewLine;
}
System****.File.WriteAllText(Properties.Settings.D efault.AccountLocation + "/SasData.dat", output);
listBox1.Items.Add(" - Wrote Settings");
}
// Read Settings File
public void read_settings()
{
ListAccounts1.Items.Clear();
if (!System****.File.Exists(Properties.Settings.Defau lt.AccountLocation + "/SasData.dat"))
return;
var file = new StreamReader(Properties.Settings.Default.AccountLo cation + "/SasData.dat");
string line;
while ((line = file.ReadLine()) != null)
{
string[] data = line.Split('|');
var item = new ListViewItem(data);
ListAccounts1.Items.Add(item);
}
file.Close();
listBox1.Items.Add(" - Read Settings");
}
// Get Style
public void GetStyle()
{
msmMain.Theme = Properties.Settings.Default.Theme;
msmMain.Style = Properties.Settings.Default.Style;
}
// ListColor
public void ListColor()
{
if (msmMain.Style == MetroColorStyle.Black)
{
ListAccounts1.ForeColor = Color.Black;
listBox1.ForeColor = Color.Black;
listBox1.Refresh();
ListAccounts1.Refresh();
}
if (msmMain.Style == MetroColorStyle.White)
{
ListAccounts1.ForeColor = Color.White;
listBox1.ForeColor = Color.White;
listBox1.Refresh();
ListAccounts1.Refresh();
}
if (msmMain.Style == MetroColorStyle.Blue)
{
ListAccounts1.ForeColor = Color.FromArgb(0, 174, 219);
listBox1.ForeColor = Color.FromArgb(0, 174, 219);
listBox1.Refresh();
ListAccounts1.Refresh();
}
if (msmMain.Style == MetroColorStyle.Brown)
{
ListAccounts1.ForeColor = Color.FromArgb(165, 81, 0);
listBox1.ForeColor = Color.FromArgb(165, 81, 0);
listBox1.Refresh();
ListAccounts1.Refresh();
}
if (msmMain.Style == MetroColorStyle.Green)
{
ListAccounts1.ForeColor = Color.FromArgb(0, 177, 89);
listBox1.ForeColor = Color.FromArgb(0, 177, 89);
listBox1.Refresh();
ListAccounts1.Refresh();
}
if (msmMain.Style == MetroColorStyle.Lime)
{
ListAccounts1.ForeColor = Color.FromArgb(131, 188, 0);
listBox1.ForeColor = Color.FromArgb(131, 188, 0);
listBox1.Refresh();
ListAccounts1.Refresh();
}
if (msmMain.Style == MetroColorStyle.Magenta)
{
ListAccounts1.ForeColor = Color.FromArgb(255, 0, 148);
listBox1.ForeColor = Color.FromArgb(255, 0, 148);
listBox1.Refresh();
ListAccounts1.Refresh();
}
if (msmMain.Style == MetroColorStyle.Orange)
{
ListAccounts1.ForeColor = Color.FromArgb(243, 119, 53);
listBox1.ForeColor = Color.FromArgb(243, 119, 53);
listBox1.Refresh();
ListAccounts1.Refresh();
}
if (msmMain.Style == MetroColorStyle.Pink)
{
ListAccounts1.ForeColor = Color.FromArgb(231, 113, 189);
listBox1.ForeColor = Color.FromArgb(231, 113, 189);
listBox1.Refresh();
ListAccounts1.Refresh();
}
if (msmMain.Style == MetroColorStyle.Purple)
{
ListAccounts1.ForeColor = Color.FromArgb(124, 65, 153);
listBox1.ForeColor = Color.FromArgb(124, 65, 153);
listBox1.Refresh();
ListAccounts1.Refresh();
}
if (msmMain.Style == MetroColorStyle.Red)
{
ListAccounts1.ForeColor = Color.FromArgb(209, 17, 65);
listBox1.ForeColor = Color.FromArgb(209, 17, 65);
listBox1.Refresh();
ListAccounts1.Refresh();
}
if (msmMain.Style == MetroColorStyle.Silver)
{
ListAccounts1.ForeColor = Color.FromArgb(85, 85, 85);
listBox1.ForeColor = Color.FromArgb(85, 85, 85);
listBox1.Refresh();
ListAccounts1.Refresh();
}
if (msmMain.Style == MetroColorStyle.Teal)
{
ListAccounts1.ForeColor = Color.FromArgb(0, 170, 173);
listBox1.ForeColor = Color.FromArgb(0, 170, 173);
listBox1.Refresh();
ListAccounts1.Refresh();
}
if (msmMain.Style == MetroColorStyle.Yellow)
{
ListAccounts1.ForeColor = Color.FromArgb(255, 196, 37);
listBox1.ForeColor = Color.FromArgb(255, 196, 37);
listBox1.Refresh();
ListAccounts1.Refresh();
}
}
// Apply All
public void ApplyAll()
{
if (Properties.Settings.Default.Theme == MetroThemeStyle.Dark)
{
ListAccounts1.BackColor = Color.FromArgb(17, 17, 17);
listBox1.BackColor = Color.FromArgb(17, 17, 17);
listBox1.Refresh();
ListAccounts1.Refresh();
}
if (Properties.Settings.Default.Theme == MetroThemeStyle.Light)
{
ListAccounts1.BackColor = Color.White;
listBox1.BackColor = Color.White;
listBox1.Refresh();
ListAccounts1.Refresh();
}
ListColor();
metroLabel2.Theme = msmMain.Theme;
metroLabel4.Theme = msmMain.Theme;
metroLabel12.Theme = msmMain.Theme;
metroLabel10.Theme = msmMain.Theme;
metroLabel12.Theme = msmMain.Theme;
metroLabel11.Theme = msmMain.Theme;
metroLabel16.Theme = msmMain.Theme;
metroLabel10.Theme = msmMain.Theme;
metroToolTip1.Theme = msmMain.Theme;
this.Theme = msmMain.Theme;
metroTabControl1.Theme = msmMain.Theme;
metroTabPage1.Theme = msmMain.Theme;
metroTabPage3.Theme = msmMain.Theme;
metroTabPage4.Theme = msmMain.Theme;
metroContextMenu1.Theme = msmMain.Theme;
// Apply Style
this.Style = msmMain.Style;
metroTabControl1.Style = msmMain.Style;
metroLabel2.Style = msmMain.Style;
//metroLabel3.Style = msmMain.Style;
metroContextMenu1.Style = msmMain.Style;
metroLabel4.Style = msmMain.Style;
metroLabel12.Style = msmMain.Style;
metroLabel16.Style = msmMain.Style;
metroLabel11.Style = msmMain.Style;
metroLabel10.Style = msmMain.Style;
metroTile2.Style = msmMain.Style;
metroTile3.Style = msmMain.Style;
metroTile5.Style = msmMain.Style;
metroTile6.Style = msmMain.Style;
metroTile7.Style = msmMain.Style;
Refresh();
}
// Load Form
void MainFormLoad(object sender, System.EventArgs e)
{
this.Hide();
if (Properties.Settings.Default.MasterPasswordPasswor d.Length > 0)
{
var MasterPassword = new MasterPassword();
if (MasterPassword.ShowDialog(this) == DialogResult.OK)
{
if (Properties.Settings.Default.FirstUse1 == true)
{
Properties.Settings.Default.FirstUse1 = false;
this.TopMost = false;
var FirstUse = new Setup();
if (FirstUse.ShowDialog(this) == DialogResult.OK)
{
metroTabControl1.SelectedTab = metroTabPage1;
Properties.Settings.Default.AccountLocation = Environment.GetFolderPath(Environment.SpecialFolde r.MyDocuments) + "/SteamAccountManager";
Properties.Settings.Default.SteamLocation = @"C:\Program Files (x86)\Steam\Steam.exe";
Properties.Settings.Default.Save();
read_settings();
listBox1.Items.Add(" - Successfully Executed First Launch");
this.TopLevel = true;
string version = Assembly.GetExecutingAssembly().GetName().Version. ToString();
metroLabel4.Text = "Version " + version;
this.ShowInTaskbar = true;
listBox1.Items.Clear();
listBox1.Items.Add("| Steam Account Manager Activity Log |");
listBox1.Items.Add(" Build " + version);
listBox1.Items.Add(" Date " + DateTime.Now);
listBox1.Items.Add(" ");
pictureBox1.Image = Properties.Resources.SelectAccount;
this.Show();
}
}
else
{
metroTabControl1.SelectedTab = metroTabPage1;
string version = Assembly.GetExecutingAssembly().GetName().Version. ToString();
metroLabel4.Text = "Version " + version;
this.ShowInTaskbar = true;
listBox1.Items.Clear();
listBox1.Items.Add("| Steam Account Manager Activity Log |");
listBox1.Items.Add(" Build " + version);
listBox1.Items.Add(" Date " + DateTime.Now);
listBox1.Items.Add(" ");
read_settings();
pictureBox1.Image = Properties.Resources.SelectAccount;
this.Show();
}
GetStyle();
ApplyAll();
Refresh();
this.Opacity = Properties.Settings.Default.Opacity;
}
}
if (Properties.Settings.Default.MasterPasswordPasswor d.Length == 0)
{
if (Properties.Settings.Default.FirstUse1 == true)
{
Properties.Settings.Default.FirstUse1 = false;
this.TopMost = false;
var FirstUse = new Setup();
if (FirstUse.ShowDialog(this) == DialogResult.OK)
{
metroTabControl1.SelectedTab = metroTabPage1;
Properties.Settings.Default.AccountLocation = Environment.GetFolderPath(Environment.SpecialFolde r.MyDocuments) + "/SteamAccountManager";
Properties.Settings.Default.SteamLocation = @"C:\Program Files (x86)\Steam\Steam.exe";
Properties.Settings.Default.Save();
read_settings();
listBox1.Items.Add(" - Successfully Executed First Launch");
this.TopLevel = true;
string version = Assembly.GetExecutingAssembly().GetName().Version. ToString();
metroLabel4.Text = "Version " + version;
this.ShowInTaskbar = true;
listBox1.Items.Clear();
listBox1.Items.Add("| Steam Account Manager Activity Log |");
listBox1.Items.Add(" Build " + version);
listBox1.Items.Add(" Date " + DateTime.Now);
listBox1.Items.Add(" ");
pictureBox1.Image = Properties.Resources.SelectAccount;
this.Enabled = true;
this.Show();
}
}
else
{
metroTabControl1.SelectedTab = metroTabPage1;
string version = Assembly.GetExecutingAssembly().GetName().Version. ToString();
metroLabel4.Text = "Version " + version;
this.ShowInTaskbar = true;
listBox1.Items.Clear();
listBox1.Items.Add("| Steam Account Manager Activity Log |");
listBox1.Items.Add(" Build " + version);
listBox1.Items.Add(" Date " + DateTime.Now);
listBox1.Items.Add(" ");
read_settings();
pictureBox1.Image = Properties.Resources.SelectAccount;
this.Enabled = true;
this.Show();
}
GetStyle();
ApplyAll();
Refresh();
this.Opacity = Properties.Settings.Default.Opacity;
}
}
// Steam Login
void LoginToolStripMenuItemClick(object sender, System.EventArgs e)
{
if (ListAccounts1.SelectedItems.Count == 1)
{
foreach (var process in Process.GetProcessesByName("Steam.exe"))
{
process.Kill();
}
ListAccounts1.SelectedItems[0].SubItems[2].Text = DateTime.Now.ToString("dd/MM/yyyy");
kill_steam();
login_steam(Properties.Settings.Default.SteamLocat ion, ListAccounts1.SelectedItems[0].SubItems[0].Text, ListAccounts1.SelectedItems[0].SubItems[1].Text);
}
write_settings();
if(Properties.Settings.Default.CloseCheck == true)
{
this.Close();
}
}
// Save Log
private void metroTile5_Click(object sender, EventArgs e)
{
try
{
System****.StreamWriter SaveFile = new System****.StreamWriter(Environment.GetFolderPath( Environment.SpecialFolder.MyDocuments) + "/SteamAccountManager/ExportedLog.txt");
foreach (var item in listBox1.Items)
{
SaveFile.WriteLine(item);
}
SaveFile.Close();
MetroMessageBox.Show(this, "Log Successfully Exported!", "Steam Account Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch
{
MetroMessageBox.Show(this, "There was an error exporting the log!", "Steam Account Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
// Message Spam Launch
private void metroTile6_Click(object sender, EventArgs e)
{
MessageSpam frm = new MessageSpam();
frm.Show();
}
// Change Selected Account
private void ListAccounts1_SelectedIndexChanged(object sender, EventArgs e)
{
GetInfo();
}
// Get ListAccounts1 Info
void GetInfo()
{
if (ListAccounts1.SelectedItems.Count > 0)
{
if (ListAccounts1.SelectedItems[0].SubItems[3].Text == "Main")
{
pictureBox1.Image = Properties.Resources.MainBig;
}
if (ListAccounts1.SelectedItems[0].SubItems[3].Text == "Smurf")
{
pictureBox1.Image = Properties.Resources.SmurfBig;
}
if (ListAccounts1.SelectedItems[0].SubItems[3].Text == "Other")
{
pictureBox1.Image = Properties.Resources.OtherBig;
}
metroLabel10.Text = "Username: " + ListAccounts1.SelectedItems[0].SubItems[0].Text;
metroLabel12.Text = "Password: " + ListAccounts1.SelectedItems[0].SubItems[1].Text;
metroLabel11.Text = "Last Login: " + ListAccounts1.SelectedItems[0].SubItems[2].Text;
metroTile2.Enabled = true;
}
else
{
metroTile2.Enabled = false;
}
}
// Login Button
private void metroTile2_Click(object sender, EventArgs e)
{
if (ListAccounts1.SelectedItems.Count == 1)
{
foreach (var process in Process.GetProcessesByName("Steam.exe"))
{
process.Kill();
}
ListAccounts1.SelectedItems[0].SubItems[2].Text = DateTime.Now.ToString("dd/MM/yyyy");
kill_steam();
login_steam(Properties.Settings.Default.SteamLocat ion, ListAccounts1.SelectedItems[0].SubItems[0].Text, ListAccounts1.SelectedItems[0].SubItems[1].Text);
}
write_settings();
if (Properties.Settings.Default.CloseCheck == true)
{
this.Close();
}
}
// Launch Game Commands
private void metroTile7_Click(object sender, EventArgs e)
{
GameCommands frm = new GameCommands();
frm.Show();
}
// Launch Settings
private void pictureBox2_Click(object sender, EventArgs e)
{
Settings frm2 = new Settings();
frm2.ShowDialog();
}
// Launch Steam Backup Manager
private void metroTile3_Click(object sender, EventArgs e)
{
SteamBackup frm = new SteamBackup();
frm.Show();
}
private void pictureBox3_Click(object sender, EventArgs e)
{
Help frm = new Help();
frm.Show();
}
private void testToolStripMenuItem_Click(object sender, EventArgs e)
{
var form_account = new form_account();
if (form_account.ShowDialog(this) == DialogResult.OK)
{
string[] row = { form_account.username, Encrypt(form_account.password), "", form_account.account };
var item = new ListViewItem(row);
ListAccounts1.Items.Add(item);
write_settings();
listBox1.Items.Add(" - Added Account " + form_account.username);
this.TopMost = true;
this.TopMost = false;
}
this.TopMost = true;
this.TopMost = false;
}
private void removeAccountToolStripMenuItem_Click(object sender, EventArgs e)
{
foreach (ListViewItem item in ListAccounts1.SelectedItems)
{
item.Remove();
listBox1.Items.Add(" - Removed " + ListAccounts1.SelectedItems);
metroLabel10.Text = "Username: Waiting...";
metroLabel11.Text = "Last Login: Waiting...";
metroLabel12.Text = "Password: Waiting...";
metroTile2.Enabled = false;
pictureBox1.Image = Properties.Resources.SelectAccount;
}
write_settings();
}
private void closeSteamToolStripMenuItem_Click(object sender, EventArgs e)
{
kill_steam();
listBox1.Items.Add(" - Stopped Steam.exe process");
}
private void importAccountsToolStripMenuItem_Click(object sender, EventArgs e)
{
openFileDialog1.FileName = ("SasData.dat");
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
if (!System****.File.Exists(openFileDialog1.FileName) )
return;
var file = new StreamReader(openFileDialog1.FileName);
string line;
while ((line = file.ReadLine()) != null)
{
string[] data = line.Split('|');
var item = new ListViewItem(data);
ListAccounts1.Items.Add(item);
}
file.Close();
listBox1.Items.Add(" - Read Settings");
write_settings();
}
}
private void editAccountsToolStripMenuItem_Click(object sender, EventArgs e)
{
var form_edit = new form_edit();
if (form_edit.ShowDialog(this) == DialogResult.OK)
{
string[] row = { form_edit.username, Encrypt(form_edit.password), "", form_edit.account };
var item = new ListViewItem(row);
ListAccounts1.Items.Add(item);
write_settings();
listBox1.Items.Add(" - Added Account " + form_edit.username);
this.TopMost = true;
this.TopMost = false;
foreach (ListViewItem item1 in ListAccounts1.SelectedItems)
{
item1.Remove();
listBox1.Items.Add(" - Removed " + ListAccounts1.SelectedItems);
metroLabel10.Text = "Username: Waiting...";
metroLabel11.Text = "Last Login: Waiting...";
metroLabel12.Text = "Password: Waiting...";
metroTile2.Enabled = false;
pictureBox1.Image = Properties.Resources.SelectAccount;
}
write_settings();
}
this.TopMost = true;
this.TopMost = false;
}
}
}