public MainForm() { InitializeComponent(); picLoading.Hide(); _fhs = new FamilyHistorySource(FamilyHistorySource.SourceType.FamilySearchService); HELPER_EnableOutputUI(false); HELPER_EnableStartUI(true); txtOutput.Text = "Welcome to the '3D Family Tree File Utility'." + System.Environment.NewLine + "This utility will help you create the Family History data file needed for 3D Family Tree."; btnStart.Focus(); _myAppDataStorage = AppDataStorage.Read(); if (string.IsNullOrEmpty(_myAppDataStorage.FamilyInfoFileName)) { _myAppDataStorage.FamilyInfoFileName = Path.GetFullPath("..\\MyFamilyInfo.xml"); // first time in, so wait until we have a FILE SAVE (or opened) before letting them play it this.btnPlay3DFT.Enabled = false; txtOutput.AppendText(System.Environment.NewLine + System.Environment.NewLine + "--> Create or open a file, so that you can play it."); } txtPlayFile.Text = _myAppDataStorage.FamilyInfoFileName; _myAppDataStorage.Save(); }
public static AppDataStorage Read() { AppDataStorage retAppDataStorage = new AppDataStorage(); var appDataFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "3DFT", "3DFT.xml"); if (File.Exists(appDataFile)) { // Construct an instance of the XmlSerializer with the type // of object that is being deserialized. XmlSerializer serializer = new XmlSerializer(typeof (AppDataStorage)); // To read the file, create a FileStream. using (FileStream myFileStream = new FileStream(appDataFile, FileMode.Open)) { // Call the Deserialize method and cast to the object type. return (AppDataStorage) serializer.Deserialize(myFileStream); } } return retAppDataStorage; }