public MainWindow() { InitializeComponent(); showView(ViewKind.StartupView); recent = RecentMangas.Load(); RecentItems.ItemsSource = recent.Recent; _resizeEnding.Tick += resizeEnding_Tick; }
public static RecentMangas Load() { var result = new RecentMangas(); try { using (var stream = new FileStream(ConfigurationPath(), FileMode.Open, FileAccess.ReadWrite)) { XmlSerializer xser = new XmlSerializer(typeof(RecentMangas)); result = xser.Deserialize(stream) as RecentMangas; stream.Close(); fixupDeserialized(result); } } catch (FileNotFoundException) { /* Do not load anything */ } catch (InvalidOperationException) { /* data corrupted -- too bad */ } return result; }
private static void fixupDeserialized(RecentMangas result) { result.PinnedCount = result.Recent.Where((x) => x.Pinned).Count(); foreach (var item in result.Recent) { result.bindState(item); } }