private async void SetPageTitle() { data myData = new data(); string displayName = await myData.GetDisplayNameByIndex(currentIndex); chpTitle.Text = displayName; }
public async Task <bool> LoadSettingData() { bool isComplete = false; // init all static variables int[] tasksIndex = new int[] { 1, 3 }; int[] maliSettings = new int[] { 3, 0, 1, 0, 0 }; // init the Setting.xml file in local folder data myData = new data(); bool fileExist = await myData.IsFileExist(); if (!fileExist) { bool fileSaved = await myData.InitSetting(); while (!fileSaved) { fileSaved = await myData.InitSetting(); } } try { maliSettings = await myData.GetMaliSetting(); tasksIndex = await myData.GetTasksIndex(); } catch (Exception ex) { bool isFileCompleteness = await myData.CheckFileCompleteness(); if (!isFileCompleteness) { bool fileSaved = await myData.InitSetting(); } } //finally //{ // //maliSettings = await myData.GetMaliSetting(); // //tasksIndex = await myData.GetTasksIndex(); //} int chpsPerEach = maliSettings[0]; int allPass = maliSettings[1]; int fontSize = maliSettings[2]; int toast = maliSettings[3]; int language = maliSettings[4]; if (toast == 0) { App.EnableToast = false; } else { App.EnableToast = true; } App.ChpsPerEach = chpsPerEach; App.ContentFontSize = (CustomFontSize)fontSize; App.AllPassBible = allPass; App.CurrentTasks = tasksIndex; App.SystemLanguage = language; myData = new data(); // finished chapter index of last time string a = await myData.GetDisplayNameByIndex(tasksIndex[0] - 1); if (a == string.Empty) { if (App.SystemLanguage == 0) { current.Text = "还未开始阅读!"; } else if (App.SystemLanguage == 1) { current.Text = "Not Started yet!"; } } else if (a == "Err") { current.Text = "Oops, Error Occur!"; } else { current.Text = a; } // for this time, the start chapter and stop chapter from.Text = await myData.GetDisplayNameByIndex(tasksIndex[0]); to.Text = await myData.GetDisplayNameByIndex(tasksIndex[1]); isComplete = true; return(isComplete); }