private static void GetNextPos(string BibleName, int Chapter, out string outbible, out int chapter) { outbible = "종료"; chapter = 0; int CurrentMaxChapter = BibleInfo.GetChapterSize(BibleName); if (Chapter + 1 <= CurrentMaxChapter) { Chapter += 1; outbible = BibleName; chapter = Chapter; } else { //다음 성경 string NextBible = BibleName; int currentPos = 0; foreach (var bible in BibleInfo.List) { if (bible.Name == BibleName) { break; } currentPos++; } if (BibleInfo.List.Count > currentPos + 1) { outbible = BibleInfo.List[currentPos + 1].Name; chapter = 1; } } }
public void RefreshData() { int idInc = 0; if (LoadInfo.Count == 0) { foreach (var data in BibleInfo.ListOldTestament) { BibleTableInfo info = new BibleTableInfo(); info.Id = idInc++; info.Name = data; info.MaxChapterSize = BibleInfo.GetChapterSize(data); LoadInfo.Add(info); } foreach (var data in BibleInfo.ListNewTestament) { BibleTableInfo info = new BibleTableInfo(); info.Id = idInc++; info.Name = data; info.MaxChapterSize = BibleInfo.GetChapterSize(data); LoadInfo.Add(info); } } listView.ItemsSource = LoadInfo; listView.ItemSelected += OnItemSelected; var plan = SQLLiteDB.ReadBibleReadPlan(); if (plan != null) { ReadChapterCount.Text = plan.Count.ToString(); var search = LoadInfo.Find(e => e.Name == plan.BibleName); if (search != null) { listView.SelectedItem = search; listView.TabIndex = search.Id; } StartTime.Date = plan.StartTime; ShowInfomation(StartTime.Date, plan.Count); } }
void Handle_ItemSelected(object sender, Xamarin.Forms.SelectedItemChangedEventArgs e) { //선택된 아이템을 Contact 타입으로 변환 var contact = e.SelectedItem as BibleTableInfo; User.CacheData.BibleName = contact.Name; var parentPage = this.Parent as TabbedPage; int MaxChapterSize = BibleInfo.GetChapterSize(contact.Name); parentPage.Children[1] = new Chapter(MaxChapterSize); parentPage.CurrentPage = parentPage.Children[1]; }
//이전 성경 가져오기 async void Handle_Clicked_Prev(object sender, System.EventArgs e) { int CurrentMaxChapter = BibleInfo.GetChapterSize(User.CacheData.BibleName); //최소 1장보다 커야한다. if (User.CacheData.Chapter - 1 < 0) { User.CacheData.Chapter -= 1; RefreshData(); } else { //다음 성경 string NextBible = User.CacheData.BibleName; int currentPos = 0; foreach (var bible in BibleInfo.List) { if (bible.Name == User.CacheData.BibleName) { break; } currentPos++; } if (0 <= (currentPos - 1) && User.CacheData.Chapter == 1) { User.CacheData.BibleName = BibleInfo.List[currentPos - 1].Name; User.CacheData.Chapter = BibleInfo.GetChapterSize(User.CacheData.BibleName); User.CacheData.Verse = 1; } else { int chapter = User.CacheData.Chapter - 1; if (chapter < 1) { chapter = 1; } User.CacheData.BibleName = BibleInfo.List[currentPos].Name; User.CacheData.Chapter = chapter; User.CacheData.Verse = 1; } RefreshData(); } }
public BibleList(BibleSplite _type) { InitializeComponent(); var assembly = IntrospectionExtensions.GetTypeInfo(typeof(BibleList)).Assembly; List <BibleTableInfo> LoadInfo = new List <BibleTableInfo>(); int idInc = 0; if (_type == BibleSplite.NewTestament) { foreach (var data in BibleInfo.ListNewTestament) { BibleTableInfo info = new BibleTableInfo(); info.Id = idInc++; info.Name = data; info.MaxChapterSize = BibleInfo.GetChapterSize(data); LoadInfo.Add(info); } } else { foreach (var data in BibleInfo.ListOldTestament) { BibleTableInfo info = new BibleTableInfo(); info.Id = idInc++; info.Name = data; info.MaxChapterSize = BibleInfo.GetChapterSize(data); LoadInfo.Add(info); } } listView.ItemsSource = LoadInfo; }
//다음 성경 가져오기 async void Handle_Clicked_Next(object sender, System.EventArgs e) { int CurrentMaxChapter = BibleInfo.GetChapterSize(User.CacheData.BibleName); if (User.CacheData.Chapter + 1 <= CurrentMaxChapter) { User.CacheData.Chapter += 1; User.CacheData.Verse = 1; RefreshData(); } else { //다음 성경 string NextBible = User.CacheData.BibleName; int currentPos = 0; foreach (var bible in BibleInfo.List) { if (bible.Name == User.CacheData.BibleName) { break; } currentPos++; } if (BibleInfo.List.Count > currentPos + 1) { User.CacheData.BibleName = BibleInfo.List[currentPos + 1].Name; User.CacheData.Chapter = 1; User.CacheData.Verse = 1; RefreshData(); } } }
private MyPosToBibleRead CalculateTodayBibleChapter(int addDay = 0) { MyPosToBibleRead readpos = new MyPosToBibleRead(); var data = SQLLiteDB.ReadBibleReadPlan(); if (data == null) { return(null); } DateTime BeginTime = data.StartTime; DateTime MondayTime = WeekDateTime(DateTime.Now, DayOfWeek.Monday); MondayTime = MondayTime.AddDays(addDay); if (data.StartTime > MondayTime) { return(null); } int DiffDay = (MondayTime - BeginTime).Days; var search = BibleInfo.List.Find(e => e.Name == data.BibleName); if (search == null) { return(null); } int accChapterSize = 0; foreach (var bible in BibleInfo.List) { if (search.Id > bible.Id) { continue; } int chapter = BibleInfo.GetChapterSize(bible.Name); int currChapter = DiffDay * data.Count; accChapterSize += chapter; if (currChapter + 1 <= accChapterSize) { readpos.begin_bibleName = bible.Name; readpos.begin_chapter = Math.Abs((accChapterSize - currChapter) - chapter) + 1; string outbible = ""; int outchapter = 1; string inbible = readpos.begin_bibleName; int inchapter = readpos.begin_chapter; for (int i = 0; i < data.Count - 1; i++) { GetNextPos(inbible, inchapter, out outbible, out outchapter); inbible = outbible; inchapter = outchapter; } readpos.end_bibleName = outbible; readpos.end_chapter = outchapter; break; } } return(readpos); }