private void loadPicturesLibrary() { try { using (FileStream stream = new FileStream(@"../../library/pictures.xml", FileMode.OpenOrCreate, FileAccess.Read)) { TextReader reader = new StreamReader(stream); XmlSerializer serializer = new XmlSerializer(typeof(List <PictureMedia>)); List <PictureMedia> list = (List <PictureMedia>)serializer.Deserialize(reader); foreach (PictureMedia m in list) { if (m.Title == null) { m.Title = Path.GetFileNameWithoutExtension(m.FileName); } m.Icon = ExtensionStatic.GetIconsFromExtension(Path.GetExtension(m.FileName)); if (m.isDisplayable(_search, _typeFilter)) { ListPictures.Add(m); } } }; } catch (Exception) {} }
private void addPictureCmd() { OpenFileDialog dialog = new OpenFileDialog(); bool? res; dialog.Multiselect = true; dialog.Filter = "Picture Files|*.jpg;*.bmp;*.png"; res = dialog.ShowDialog(); if (res == true) { foreach (string file in dialog.FileNames) { PictureMedia tmp = Media.CreateMedia(false, file, false, ExtensionStatic.GetIconsFromExtension(Path.GetExtension(file))) as PictureMedia; if (tmp != null) { ListPictures.Add(tmp); } } } savePictures(); }