public static List <MsnBackupVersion> GetBackups() { var list = new List <MsnBackupVersion>(); if (!CheckDirectory()) { return(list); } foreach (string dir in Directory.GetDirectories(BackupPath)) { var backup = new MsnBackupVersion(); var titlePath = Path.Combine(dir, "title.msnbackup"); if (File.Exists(titlePath)) { backup.Title = File.ReadAllText(titlePath); } else { backup.Title = "No Title"; } var msgrPath = Path.Combine(dir, "msnmsgr.exe"); if (!File.Exists(msgrPath)) { throw new Exception("Backup is invalid: Directory does exists but WLM (msnmsgr.exe) couldn't be found"); } backup.BuildVersion = GetVersion(msgrPath); backup.Directory = dir; list.Add(backup); } return(list); }
public void ListAllVersions() { VersionPanel.Controls.Clear(); var backups = MsnBackup.GetBackups(); if (backups.Count != 0) { foreach (MsnBackupVersion backup in backups) { var button = new Button() { Text = $" {backup.Title}\n Build {backup.BuildVersion}", TextImageRelation = TextImageRelation.ImageBeforeText, Dock = DockStyle.Top, FlatStyle = FlatStyle.Flat, Tag = backup, Height = 48, TextAlign = ContentAlignment.TopLeft, ImageAlign = ContentAlignment.TopLeft, }; button.Image = backup.BuildVersion.Major > 8 ? Properties.Resources.messenger14 : Properties.Resources.messenger8; button.FlatAppearance.BorderSize = 0; button.FlatAppearance.MouseDownBackColor = Color.Gainsboro; button.FlatAppearance.MouseOverBackColor = Color.WhiteSmoke; button.FlatAppearance.BorderColor = Color.White; button.Click += (s, e) => { CurrentBackup = backup; SwitchTab("progress"); }; VersionPanel.Controls.Add(button); } } else { var label = new Label() { Text = "You don't have any saved versions.", AutoSize = false, TextAlign = ContentAlignment.MiddleCenter, ForeColor = SystemColors.GrayText, Dock = DockStyle.Fill, }; VersionPanel.Controls.Add(label); } }