public ViewModelM() { Students = new ObservableCollection <Student>(); xML = new SerializationXML(); foreach (var item in xML.getStudents()) { Students.Add(item); } }
private void SavePlaylist(string path) { Playlist playlist = new Playlist { musicTracks = new List <MusicTrack>() }; foreach (MusicTrack item in MusicController.MusicTracks) { playlist.musicTracks.Add(item); } SerializationXML.SaveFile(path, playlist); }
public async Task LoadPlaylist(string path) { if (!File.Exists(path)) { return; } Playlist playlist = (Playlist)SerializationXML.LoadFile <Playlist>(path); foreach (MusicTrack item in playlist.musicTracks) { await Task.Delay(40); AddFile(item.Path); } }
private void Inventory_Load(object sender, EventArgs e) { Person = new PersonParametrs(250, 300, 100, 25, 30, 32, 15698, 56, 300, 300, 350, "Ульян"); WeaponPanel.BackgroundImage = Image.FromFile(Directory.GetCurrentDirectory() + @"\Resources\img_ak_103.png"); rucksackPanel.BackgroundImage = Image.FromFile(Directory.GetCurrentDirectory() + @"\Resources\img_military_rucksack.png"); BootsPanel.BackgroundImage = Image.FromFile(Directory.GetCurrentDirectory() + @"\Resources\img_military_boots.png"); HelmPanel.BackgroundImage = Image.FromFile(Directory.GetCurrentDirectory() + @"\Resources\img_military_helm.png"); GasMaskPanel.BackgroundImage = Image.FromFile(Directory.GetCurrentDirectory() + @"\Resources\img_gas_mask.png"); Armor ArmorPerson = new Armor("img_armor_gray.png", "ФОРТ Росич", 65, 10.90); //ArmorPanel.BackgroundImage = Image.FromFile(ArmorPerson.PathIcon); SerializationXML serialization = new SerializationXML(); List <Armor> armors1 = new List <Armor>(); serialization.NewSetArmor(armors1); LoadParamsActor(); loadFromXML_Inventory(); }
public MainWindow() { InitializeComponent(); _ = Update(); albumArtPlace = AlbumArtImg; currentSongPlaying = PlayingSongName; MusicController.MusicPlayer.MediaOpened += MediaPlayer_MediaOpened; MusicController.OnPlaySwitch += MusicController_OnPlaySwitch; MusicController.OnLoopSwitch += MusicController_OnLoopSwitch; MusicController.OnRandomizeSwitch += MusicController_OnRandomizeSwitch; if (File.Exists(PathToSettings)) { Settings settings = (Settings)SerializationXML.LoadFile <Settings>(PathToSettings); MusicController.SetupForLoad(settings, VolumeSlider); } ClearPlaylist(); CheckPlayStatus(false); }
public void SerializeXMLTest() { SerializationXML xml = new SerializationXML("toXmlTest.xml"); xml.SerializeXML(service.getContext()); DataContext result = (DataContext)xml.DeserializeXML(); Assert.AreEqual(result.Wypozyczenia.Count, 100); Assert.AreEqual(result.Stan.Count, 499); Assert.AreEqual(result.Ksiazki.Count, 500); Assert.AreEqual(result.Czytelnicy.Count, 100); List <Czytelnik> resCzytelnicy = result.Czytelnicy; List <OpisStanu> resOpis = result.Stan; Dictionary <int, Ksiazka> resKsiazka = result.Ksiazki; ObservableCollection <Wypozyczenie> resWypozyczenie = result.Wypozyczenia; for (int i = 0; i < service.getContext().Czytelnicy.Count; i++) { Assert.IsTrue(resCzytelnicy[i].Equals(service.GetCzytelnik(i))); } for (int i = 0; i < service.getContext().Ksiazki.Count; i++) { Assert.IsTrue(resKsiazka[i].Equals(service.GetKsiazka(i))); } for (int i = 0; i < service.getContext().Stan.Count; i++) { Assert.IsTrue(resOpis[i].Equals(service.GetOpisStanu(i))); } for (int i = 0; i < service.getContext().Wypozyczenia.Count; i++) { Assert.IsTrue(resWypozyczenie[i].Equals(service.GetWypozyczenie(i))); } }
private void Window_Closed(object sender, EventArgs e) { SerializationXML.SaveFile(PathToSettings, new Settings(MusicController)); }