/// <summary> /// ファイルにセーブ /// </summary> public static void SaveFile() { try { if (cached_instances.Count == 0) { return; } lock (_sync) { using (var stream = new FileStream(SettingPath.Current, FileMode.Create, FileAccess.ReadWrite)) using (var writer = new StreamWriter(stream, Encoding.UTF8)) { SettingsRoot root = new SettingsRoot { Keys = cached_instances.Keys.ToArray(), Values = cached_instances.Values.ToArray() }; var serializer = new XmlSerializer(typeof(SettingsRoot)); serializer.Serialize(writer, root); writer.Flush(); } } } catch (Exception ex) { DebugModel.WriteLine(ex); } }
public void Initialize() { DebugModel.WriteLine("KanburaLike Init"); SettingsHost.LoadFile(); infovm = new ViewModels.InformationWindowViewModel(nameof(Views.InformationWindow)); info = new Views.InformationWindow { DataContext = infovm }; }
public void Dispose() { if (info.IsVisible == true) { info.Close(); } SettingsHost.SaveFile(); //DebugModel.Dump(infovm.Info.Brilliant.Ships.FirstOrDefault().Ship, nameof(infovm.Info.Brilliant)); DebugModel.WriteLine("KanburaLike Dispose"); }
/// <summary> /// 艦これが始まったときに呼ばれる /// </summary> private void Register() { Messenger.Raise(new InteractionMessage("InfoShow")); //母港情報 this.Homeport = new HomeportViewModel(); RaisePropertyChanged(nameof(Homeport)); //任務 this.Quests = new QuestsViewModel(); RaisePropertyChanged(nameof(Quests)); DebugModel.WriteLine("艦これ Start"); }