public int CompareTo(object obj) { RomItem other = obj as RomItem; int compareTo = other != null ? 0 : -1; if (compareTo == 0) { compareTo = Path.CompareTo(other.Path); } return(compareTo); }
public void RefreshRomsList(object o, EventArgs args) { //First clear the roms foreach (Widget child in romListBox.Children) { romListBox.Remove(child); } //The fetch roms list, if the search path isn't valid set it to null if (!string.IsNullOrWhiteSpace(Program.settings.RomsSearchPath)) { try { romsList = Directory.GetFiles(Program.settings.RomsSearchPath); } catch { romsList = null; } } else { romsList = null; } //If there are no roms, create a list entry that opens the settings if (romsList == null || romsList.Length == 0) { RomItem romItem = new RomItem("Roms List Empty"); romItem.OnButtonPress += OpenSettings; romListBox.Add(romItem); return; } //Populate the roms list with valid roms for (int i = 0; i < romsList.Length; i++) { if (!romsList[i].EndsWith(".gbc")) { continue; } RomItem romItem = new RomItem(romsList[i]); romItem.OnButtonPress += SelectRom; romItem.OnButtonDoublePress += LoadRom; romListBox.Add(romItem); } }
private void btnAbrir_Click(object sender = null, RoutedEventArgs e = null) { RomItem romItem; OpenFileDialog opnFile = new OpenFileDialog(); opnFile.Filter = $"Aceptados|*.gba;*.bak;*.{FORMATOXSE};*.raw|GBA|*.gba;*.bak|XSE Script|*.{FORMATOXSE}|GBA Bytes Exported|*.raw|Todos|*.*"; if (opnFile.ShowDialog().GetValueOrDefault()) { try { if (opnFile.FileName.EndsWith("raw")) {//empieza por un script así que no hace falta añadir el inicio :) txtScript.Text = new Script(File.ReadAllBytes(opnFile.FileName)).ToXSEOrdenadoPorBloques(); } else if (!opnFile.FileName.EndsWith(FORMATOXSE)) { romItem = new RomItem() { Path = opnFile.FileName }; if (lstRoms.IndexOf(romItem) < 0) { lstRoms.Add(romItem); Refresh(); } cmbRomsCargadas.SelectedIndex = lstRoms.IndexOf(romItem); } else { txtScript.Text = File.ReadAllText(opnFile.FileName); } } catch (Exception ex) { MessageBox.Show("Ha habido un problema al cargar :" + ex.Message); } } }