private void Window_Loaded(object sender, RoutedEventArgs e) { //SerializSettingClass(setting); setting = DeserializSettingClass(); ColorFromSetting = setting.WordColor; CPB.DataContext = this; CPB.Color = setting.WordColor; InitialTray(); GetNewMusicFromList(); // mp.Open(new Uri(@"Music\Ina Wroldsen - I wanted you.mp3", UriKind.Relative)); // mp.Play(); //mp.MediaEnded += delegate { mp.Position = TimeSpan.FromSeconds(0); mp.Play(); }; mp.MediaEnded += delegate { GetNewMusicFromList(); }; Start(PetalBackground); String[] data; //String data = "我一直在等待你的出现^" + //"谢谢你的出现^" + //"此生不换^" + //"执子之手,与子偕老^" + //"携手到永远……"; string path = AppDomain.CurrentDomain.BaseDirectory + "/Data/Word.txt"; if (File.Exists(path)) { data = File.ReadAllLines(path); StartTextAsync(data); } }
private void SerializSettingClass(Class_Setting setting) { FileStream stream = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "/Data/Setting.ini", FileMode.Create); XmlSerializer xmlserilize = new XmlSerializer(typeof(Class_Setting)); xmlserilize.Serialize(stream, setting); stream.Close(); }
private Class_Setting DeserializSettingClass() { Class_Setting setting = new Class_Setting(); FileStream stream = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "/Data/Setting.ini", FileMode.Open); XmlSerializer xmlserilize = new XmlSerializer(typeof(Class_Setting)); setting = (Class_Setting)xmlserilize.Deserialize(stream); stream.Close(); return(setting); }