private void button1_Click(object sender, EventArgs e) { DictionaryPropertyGridAdapter <string, object> data = propertyGrid1.SelectedObject as DictionaryPropertyGridAdapter <string, object>; if (data != null) { Dictionary <string, object> mapped = data.GetDictionary(); Dictionary <string, Tuple <Config.Type, object> > unmapped = ReverseConfigMap(mapped); DataHolder.GetConfig(lstConfigs.SelectedItem.ToString()).SetAll(unmapped); } }
private void btnLoginInfo_Click(object sender, EventArgs e) { if (!DataHolder.HasLoginInfo) { string name = txtLoginName.Text; string password = txtLoginPassword.Text; DataHolder.SetLoginInfo(new LoginInfo(name, password)); } else { DataHolder.DeleteLoginInfo(); } }
public void CheckLoginInfo() { if (DataHolder.HasLoginInfo) { btnLoginInfo.Text = "Delete saved"; lblLoginInfo.Text = "Stored info: \r\nusername: "******"\r\npassword (encrypted): " + DataHolder.GetLoginInfo().GetPassword(); } else { btnLoginInfo.Text = "Store"; lblLoginInfo.Text = "No stored information"; } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (cbxNewBackup.SelectedIndex != 0) { IBackup backup = BackupLoader.formats[cbxNewBackup.SelectedIndex - 1].CreateBackup(); if (backup != null) { DataHolder.AddBackup(backup); } UpdateBackupList(); cbxNewBackup.SelectedIndex = 0; } }
private void UpdateBackupList() { treeView1.Nodes.Clear(); foreach (IBackupFormat format in BackupLoader.formats) { TreeNode node = new TreeNode(format.GetType().Name); foreach (IBackup backup in DataHolder.GetBackups()) { if (backup.GetFormat().GetType() == format.GetType()) { node.Nodes.Add(backup.GetName()); } } treeView1.Nodes.Add(node); } }
private void button1_Click(object sender, EventArgs e) { string param = ""; if (DataHolder.HasLoginInfo) { param += DataHolder.GetLoginInfo().GetName() + " " + DataHolder.GetLoginInfo().GetDecryptedPassword(); } if (checkBox1.Checked) { Directory.Delete(Data.minecraftbin, true); } else { } Process.Start(Data.minecraftexe, param); }
public void StartMinecraftWithoutLauncher() { LoginInfo li; if (DataHolder.HasLoginInfo) { li = DataHolder.GetLoginInfo(); } else { li = LoginInput.Show(); if (li == null) { MessageBox.Show("Please type in username and password!", "Login Error"); return; } } try { WebClient wc = new WebClient(); string loginURI = String.Format("http://login.minecraft.net/?user={0}&password={1}&version=14", li.GetName(), li.GetDecryptedPassword()); string str = wc.DownloadString(loginURI); if (str != "Bad login") { string[] args = str.Split(':'); Process mc = new Process(); mc.StartInfo.FileName = "java.exe"; mc.StartInfo.Arguments = String.Format("-Xincgc -Xmx1024m -cp \"" + Data.minecraftbin + "minecraft.jar;" + Data.minecraftbin + "lwjgl.jar;" + Data.minecraftbin + "lwjgl_util.jar;" + Data.minecraftbin + "jinput.jar\" -Djava.library.path=\"" + Data.minecraftbin + "natives\" net.minecraft.client.Minecraft {0} {1}", args[2], args[3]); mc.Start(); } else { MessageBox.Show("Invalid Login! try again..."); } } catch (WebException ex) { MessageBox.Show("Can't connect to login.minecraft.net, try again later or start with launcher to play offline\r\nMore information: " + ex.ToString()); } }
private void Form1_Load(object sender, EventArgs e) { DataHolder.StartPlugins(this); cbxNewBackup.Items.Clear(); cbxNewBackup.Items.Add("New Backup"); foreach (IBackupFormat format in BackupLoader.formats) { cbxNewBackup.Items.Add(format.GetFormatName()); } cbxNewBackup.SelectedIndex = 0; cbxMCStart.SelectedIndex = 0; cbxMCLoaded = true; UpdateBackupList(); UpdatePluginList(); UpdateConfigList(); foreach (string line in changelog.loglines) { richTextBox1.AppendText(" - " + line); } }
public void StartMinecraftWithLauncher() { Process[] javas; bool start = true; if ((javas = Process.GetProcessesByName("javaw")).Length > 0) { foreach (Process p in javas) { if (p.MainWindowTitle.Equals("minecraft", StringComparison.CurrentCultureIgnoreCase)) { start = false; if (MessageBox.Show("Minecraft is allready running, do you want to close it before restarting. \r\nIf no minecraft will not start a second time.", "Minecraft is allready running", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { p.Kill(); start = true; } break; } } } if (start) { string param = ""; if (DataHolder.HasLoginInfo) { param += DataHolder.GetLoginInfo().GetName() + " " + DataHolder.GetLoginInfo().GetDecryptedPassword(); } if (checkBox1.Checked) { Directory.Delete(Data.minecraftbin, true); } else { } Process.Start(Data.minecraftexe, param); } }
private static void Main() { Data.CheckStartupFolders(); PluginLoader.LoadPlugins(); if (File.Exists(Data.logininfo)) { DataHolder.SetLoginInfo(LoginInfo.Load(Data.logininfo)); } DataHolder.SetBackups(BackupLoader.LoadBackups()); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); BackupLoader.SaveBackups(DataHolder.GetBackups()); if (DataHolder.HasLoginInfo) { DataHolder.GetLoginInfo().Save(Data.logininfo); } else { File.Delete(Data.logininfo); } }
public void UpdateBackupList() { treeView1.Nodes.Clear(); foreach (IBackupFormat format in BackupLoader.formats) { TreeNode node = new TreeNode(format.GetFormatName()); node.ToolTipText = format.GetFormatName(); int i = 0; foreach (IBackup backup in DataHolder.GetBackups()) { if (backup.GetFormat().GetType() == format.GetType()) { TreeNode n = new TreeNode(backup.GetName()); n.Tag = DataHolder.GetBackups().IndexOf(backup); n.ToolTipText = backup.GetDescription(); n.Tag = i; n.ImageKey = format.GetImageName(); node.Nodes.Add(n); } i++; } treeView1.Nodes.Add(node); } }
public static void LoadPlugin(string file) { Assembly assembly = Assembly.LoadFile(file); foreach (Type t in assembly.GetTypes()) { if (typeof(IBackupFormat).IsAssignableFrom(t)) { IBackupFormat format = Activator.CreateInstance(t) as IBackupFormat; BackupLoader.formats.Add(format); } if (typeof(IUpdater).IsAssignableFrom(t)) { IUpdater updater = Activator.CreateInstance(t) as IUpdater; updater.SetPath(file); DataHolder.AddUpdater(updater); } if (typeof(IPlugin).IsAssignableFrom(t)) { IPlugin plugin = Activator.CreateInstance(t) as IPlugin; DataHolder.AddPlugin(plugin); } } }
private void button4_Click(object sender, EventArgs e) { DataHolder.RemoveBackup(treeView1.SelectedNode.Text); UpdateBackupList(); }
private void btnRestoreBackup_Click(object sender, EventArgs e) { DataHolder.GetBackups().FindAll(b => treeView1.SelectedNode.Text == b.GetName()).ForEach(b => b.Extract()); }
private static void Main() { //Init windows visuals Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Init data & load plugins Data.CheckStartupFolders(); PluginLoader.LoadPlugins(); DataHolder.LoadConfigs(); DataHolder.LoadImages(); //Check for updates if (!DataHolder.GetConfig().Has("autoupdate")) { DataHolder.GetConfig().Set("autoupdate", Plugin_API.Config.Type.Bool, false); } if ((bool)DataHolder.GetConfig().Get("autoupdate")) { Thread updateThread = new Thread(() => { Data.CheckForUpdate(); DataHolder.UpdatePlugins(); Data.PreformUpdate(); if (Data.updateData.ToString() != "") { DialogResult r = MessageBox.Show("New Update Available! Download?", "Update", MessageBoxButtons.YesNo); if (r == DialogResult.Yes) { Process.Start(Data.updaterExe); Thread.Sleep(100); Application.Exit(); } } }); updateThread.Start(); } if (File.Exists(Data.logininfo)) { DataHolder.SetLoginInfo(LoginInfo.Load(Data.logininfo)); } DataHolder.SetBackups(BackupLoader.LoadBackups()); //try //{ DataHolder.mainWindow = new MainWindow(); Application.Run(DataHolder.mainWindow); DataHolder.StopPlugins(); //} //catch (Exception ex) //{ // ErrorPage ep = new ErrorPage(ex.ToString()); // Application.Run(ep); //} BackupLoader.SaveBackups(DataHolder.GetBackups()); if (DataHolder.HasLoginInfo) { DataHolder.GetLoginInfo().Save(Data.logininfo); } else { if (File.Exists(Data.logininfo)) { File.Delete(Data.logininfo); } } DataHolder.SaveConfigs(); }
private void btnRestoreBackup_Click(object sender, EventArgs e) { DataHolder.GetBackups()[(int)treeView1.SelectedNode.Tag].Extract(); MessageBox.Show("Backup restored"); }
public MainWindow() { InitializeComponent(); Size = new Size(404, 390); treeView1.ImageList = DataHolder.GetBackupImages(); }