Ejemplo n.º 1
0
 private void DuplicateRemover_Load(object sender, EventArgs e)
 {
     txtDirectory.Text     = RedudantHelper.GetDefaultDirectory();
     ttRegions.IsBalloon   = true;
     ttDirectory.IsBalloon = true;
     ttRegions.SetToolTip(lbRegions, "Write the priority of certain regions, whatever is not written will fall under the same priority level.\nExample: (USA), (Europe), (Japan)\nKeep in mind that some regions might be written as [U] instead.");
     ttDirectory.SetToolTip(lbDirectory, "Put the root directory of the roms that will be checked for duplicates, subdirectories will also be checked. \nCurrently checking across multiple emulators at the same time will yield results undesired.");
 }
Ejemplo n.º 2
0
 private void CompressRom_Load(object sender, EventArgs e)
 {
     txtDirectory.Text     = RedudantHelper.GetDefaultDirectory();
     ttDirectory.IsBalloon = true;
     ttef.IsBalloon        = true;
     tte.IsBalloon         = true;
     tte.SetToolTip(lbEmulator, "These systems have at least one emulator that supports zip files.");
     ttDirectory.SetToolTip(lbDirectory, "Put the root directory of the roms that will be zip'd.");
     ttef.SetToolTip(cbExtract,
                     "Roms that are already zip'd up will be extracted and then zip'd up using this program's algorithm.\nThis is only to see if this program's algorithm can help you save some extra space.");
 }
Ejemplo n.º 3
0
        private void BtnMove_Click(object sender, EventArgs e)
        {
            var reader = txtDirectory.Text;

            if (!RedudantHelper.DirectoryCheck(reader))
            {
                return;
            }

            var files      = from f in Directory.GetFiles(reader, "*.*", SearchOption.AllDirectories) where !Path.GetDirectoryName(f).EndsWith(new DirectoryInfo(reader).Name) select f;
            var failfolder = new ArrayList();

            if (cbRename.Checked)
            {
                foreach (var file in files)
                {
                    var newfile = Path.GetDirectoryName(file) + @"\" + new FileInfo(file).Directory.Name + Path.GetExtension(file);
                    if (!File.Exists(newfile))
                    {
                        File.Move(file, newfile);
                    }
                    else
                    {
                        failfolder.Add(newfile);
                    }
                }
            }

            RedudantHelper.FileMaker(failfolder, "FileFolderRenamer");

            if (!reader.EndsWith(@"\"))
            {
                reader = reader + @"\";
            }

            files = from f in Directory.GetFiles(reader, "*.*", SearchOption.AllDirectories) where !Path.GetDirectoryName(f).EndsWith(new DirectoryInfo(reader).Name) select f;
            var fail = new ArrayList();

            foreach (var file in files)
            {
                var newfile = reader + Path.GetFileName(file);
                if (!File.Exists(newfile))
                {
                    File.Move(file, newfile);
                }
                else
                {
                    fail.Add(newfile);
                }
            }

            RedudantHelper.FileMaker(fail, "MoveToRootFolder");
        }
Ejemplo n.º 4
0
        private void BtnSubmit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtRegions.Text) && !_revision)
            {
                MessageBox.Show(@"Revision field cannot be empty");
                return;
            }
            var reader = txtDirectory.Text;

            if (!RedudantHelper.DirectoryCheck(reader))
            {
                return;
            }

            _deleteList = new ArrayList();

            var files    = Directory.GetFiles(reader, "*.*", SearchOption.AllDirectories);
            var priority = new List <string>();

            if (_revision)
            {
                var alphabet = new[]
                {
                    "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
                    "U", "V", "W", "X", "Y", "Z"
                }.Reverse();
                priority.AddRange(alphabet);
            }
            else
            {
                priority = txtRegions.Text.Replace(" ", string.Empty).Split(',').ToList();
            }

            var regionMap = new Dictionary <string, ArrayList>();
            var regex     = new Regex(@"\s*?(?:\(.*?\)|\[.*?\]|\{.*?\})");

            foreach (var file in files)
            {
                var region = regex.Matches(file).Cast <Match>().Aggregate("", (current, match) => current + match.Value);
                var title  = Path.GetFileName(string.IsNullOrWhiteSpace(region) ? file : file.Replace(region, string.Empty));

                region = region.Trim();

                if (regionMap.ContainsKey(title))
                {
                    if (!_revision)
                    {
                        regionMap[title].Add(region);
                    }
                    else if (region.Contains("Rev"))
                    {
                        regionMap[title].Add(region);
                    }
                }
                else
                {
                    regionMap[title] = new ArrayList {
                        region
                    }
                };
            }

            foreach (var file in files)
            {
                var region = regex.Matches(file).Cast <Match>().Aggregate("", (current, match) => current + match.Value);
                var title  = Path.GetFileName(string.IsNullOrWhiteSpace(region) ? file : file.Replace(region, string.Empty));
                region = region.Trim();

                if (regionMap[title].Count < 2)
                {
                    continue;
                }

                if (region.Contains("Rev") && _revision)
                {
                    region = region.Substring(region.IndexOf("(R"));

                    region = region.Any(char.IsDigit) ? priority[Convert.ToInt32(new string(region.Where(char.IsDigit).ToArray())) - 1] : region.Replace("(", "").Replace(")", "").Last().ToString();
                }

                var number = priority.IndexOf(region);

                if (number == -1)
                {
                    _deleteList.Add(file);
                    continue;
                }

                var list = new ArrayList();
                foreach (string rank in regionMap[title])
                {
                    var temp = rank;
                    if (_revision && rank.Contains("Rev"))
                    {
                        temp = rank.Substring(rank.IndexOf("Rev"));
                        temp = temp.Any(char.IsDigit) ? priority[Convert.ToInt32(new string(temp.Where(char.IsDigit).ToArray())) - 1] : temp.Replace("(", "").Replace(")", "").Last().ToString();
                    }
                    if (!(priority.IndexOf(temp) < 0))
                    {
                        list.Add(priority.IndexOf(temp));
                    }
                }

                list.Sort();

                if (_revision)
                {
                    list.Reverse();
                }

                if (list.IndexOf(number) != 0)
                {
                    _deleteList.Add(file);
                }
            }

            if (_deleteList.Count > 0)
            {
                RedudantHelper.FileMaker(_deleteList, "RetroManagerDuplicates");
                btnDelete.Enabled = true;
            }
            else
            {
                MessageBox.Show(@"No duplicate found");
            }
        }
Ejemplo n.º 5
0
 private void BtnBrowse_Click(object sender, EventArgs e)
 {
     txtDirectory.Text = RedudantHelper.Browse(txtDirectory.Text);
     RedudantHelper.DirectoryCheck(txtDirectory.Text);
 }
Ejemplo n.º 6
0
        private void BtnStart_Work(object sender, EventArgs e)
        {
            var reader = txtDirectory.Text;

            if (!RedudantHelper.DirectoryCheck(reader))
            {
                return;
            }
            int percentage;

            if (cbExtract.Checked)
            {
                var extract = new List <string>();
                extract.AddRange(Directory.GetFiles(reader, "*.zip", SearchOption.AllDirectories));
                extract.AddRange(Directory.GetFiles(reader, "*.7z", SearchOption.AllDirectories));
                var i = 0;

                foreach (var rom in extract)
                {
                    Compressor.DecompressFile(rom, reader);

                    percentage = (i + 1) * 100 / extract.Count;
                    i++;
                    _bw.ReportProgress(percentage);
                }

                extract.Clear();
            }

            var extensions =
                new Dictionary <string, ArrayList>
            {
                { "nes", new ArrayList {
                      "nes", "smc", "sfc", "fig", "swc", "mgd", "fds"
                  } },
                { "sg-1000", new ArrayList {
                      "sg"
                  } },
                { "snes", new ArrayList {
                      "smc", "sfc", "fig", "swc"
                  } },
                { "gb", new ArrayList {
                      "gb"
                  } },
                { "gbc", new ArrayList {
                      "gbc"
                  } },
                { "gba", new ArrayList {
                      "gba"
                  } },
                { "ds", new ArrayList {
                      "nds"
                  } },
                { "32x", new ArrayList {
                      "32x", "smd", "bin", "md"
                  } },
                { "genesis", new ArrayList {
                      "smd", "bin", "md", "iso", "gen"
                  } },
                { "n64", new ArrayList {
                      "z64", "n64", "v64"
                  } },
                { "mastersystem", new ArrayList {
                      "sms"
                  } },
                { "atari2600", new ArrayList {
                      "bin", "a26", "rom", "gz"
                  } },
                { "lynx", new ArrayList {
                      "lnx"
                  } },
                { "gamegear", new ArrayList {
                      "gg"
                  } },
                { "ngp", new ArrayList {
                      "ngp"
                  } },
                { "ngc", new ArrayList {
                      "ngc"
                  } },
                { "pcengine", new ArrayList {
                      "pce", "cue"
                  } },
                { "z-machine", new ArrayList {
                      "dat", "z1", "z2", "z3", "z4", "z5", "z6", "z7", "z8"
                  } }
            };

            var emulators = new ArrayList();

            foreach (var c in gbEmulator.Controls.OfType <CheckBox>().Where(x => x.Checked))
            {
                emulators.Add(c.Text.Replace(" ", string.Empty).ToLower());
            }

            var mode = 0;

            if (rad7z.Checked)
            {
                mode = 1;
            }

            try
            {
                foreach (string emu in emulators)
                {
                    foreach (var ext in extensions[emu])
                    {
                        var roms = Directory.GetFiles(reader, "*." + ext, SearchOption.AllDirectories);
                        var i    = 0;

                        foreach (var rom in roms)
                        {
                            Compressor.CompressFile(rom, reader, mode);
                            percentage = (i + 1) * 100 / roms.Length;
                            i++;
                            _bw.ReportProgress(percentage);
                        }
                    }
                }
            }

            catch
            {
                //ignored since an emulator was probably checked that the user doesn't have games for
            }
        }