Exemple #1
0
        private void populateList(ref ComboBox cmb)
        {
            // I have created an empty list called 'items' which is the data source for the combo box world selector.
            cmb.DisplayMember = "Text";
            cmb.ValueMember   = "Value";
            var items = new[] { new { Text = "one", Value = "ONE" } }.ToList();

            items.Remove(items[0]);

            // Read the directories (worlds) of the '%AppData%\.minecraft\saves'
            try
            {
                foreach (var world in Directory.GetDirectories(paths.worldsDirectory))
                {
                    items.Add(new { Text = MyClasses.getCurrentDirectory(world), Value = world });
                }
                cmb.DataSource = items;
                // Select the first world (alphabetically?) as default and set the variables:
                paths.GetWorldPaths(cmbWorld, nmrMax);
                flowPanelHide.Visible = false;
                Text = "Minecraft Autosave - " + paths.startPath;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                //MessageBox.Show("Minecraft save folder not found: " + paths.worldsDirectory);
            }
        }
 public void ParseSavesIni(NumericUpDown nmr) //Parsing savesIni
 {
     // parse the ini file and retrieve the variables:
     if (!Directory.Exists(Path.GetDirectoryName(savesIni)))
     {
         Directory.CreateDirectory(Path.GetDirectoryName(savesIni));
     }
     if (File.Exists(savesIni))
     {
         string contents = File.ReadAllText(savesIni);
         index    = MyClasses.findValue(contents, @"index: *(\d{1,2})") ?? findLastIndex(); // index = [if not null] ?? [if null: search manually]
         maxSaves = MyClasses.findValue(contents, @"maxSaves: *(\d{1,2})") ?? maxSaves;
         File.Delete(savesIni);
     }
     using (StreamWriter sw = File.CreateText(savesIni))
     {
         sw.WriteLine("index: " + (index = findLastIndex()));
         sw.WriteLine("maxSaves: " + (nmr.Value = maxSaves));
     }
 }