static public void LoadCacheData() { var UserCacheData = SQLLiteDB.ReadUserCache(); if (UserCacheData != null) { User.CacheData.FontSize = UserCacheData.FontSize; User.CacheData.BibleName = UserCacheData.BibleName; User.CacheData.Chapter = UserCacheData.Chapter; User.CacheData.Verse = UserCacheData.Verse; User.CacheData.UserName = UserCacheData.UserName; User.CacheData.Passwd = UserCacheData.Passwd; User.CacheData.EnalbeKJV = UserCacheData.EnalbeKJV; } else { #if GLOBAL User.CacheData.BibleName = "Genesis"; #else User.CacheData.BibleName = "창세기"; #endif User.CacheData.Chapter = 1; User.CacheData.Verse = 1; User.CacheData.FontSize = 20; User.CacheData.EnalbeKJV = true; } }
public App() { InitializeComponent(); SQLLiteDB.LoadCacheData(); MainPage = new MainPage(); }
//ui 갱신 public void RefreshData() { #if GLOBAL OldT.Text = "OldT"; NewT.Text = "NewT"; Title.Text = User.CacheData.BibleName + " " + User.CacheData.Chapter.ToString() + "Chapter"; #else OldT.Text = "구약"; NewT.Text = "신약"; Title.Text = User.CacheData.BibleName + " " + User.CacheData.Chapter.ToString() + "장"; #endif MainLayout.Children.Clear(); DrawMainText(MainLayout); SQLLiteDB.Upsert(User.CacheData); GotoFocusLabel(scrollView, User.CacheData.Verse); }
static public void Loop() { if (client.socket == null || client.socket.Connected == false) { return; } CompletePacket data; if (client.PacketQueue.TryDequeue(out data) == true) { try { switch (data.Protocol) { case (int)PROTOCOL.IdPktVersionRes: { VERSION_RES res = new VERSION_RES(); res = VERSION_RES.Parser.ParseFrom(data.Data); var currentVersion = VersionTracking.CurrentVersion; double myversion; if (double.TryParse(currentVersion, out myversion) == false) { } const Double Eps = 0.000000000000001; User.Version = res.VarVersion; if (Math.Abs(res.VarVersion - myversion) > Eps) { //첫 검수라 임시 주석 2번째 패치 부터는 활성화 if (Device.RuntimePlatform == Device.Android && User.OnceVersionNotify == false) { Device.BeginInvokeOnMainThread(() => { User.OnceVersionNotify = true; DependencyService.Get <Toast>().Notification("New Version Updated"); }); } } SQLLiteDB.LoadCacheData(); if (User.CacheData.UserName != null) { NetProcess.SendLogin(User.CacheData.UserName, User.CacheData.Passwd); } } break; case (int)PROTOCOL.IdPktLoginRes: { LOGIN_RES res = new LOGIN_RES(); res = LOGIN_RES.Parser.ParseFrom(data.Data); var mainpage = (MainPage)Application.Current.MainPage; if (res.VarCode == ErrorCode.Success) { User.LoginSuccess = true; SQLLiteDB.Upsert(User.CacheData.FontSize, User.CacheData.BibleName, User.CacheData.Chapter, User.CacheData.Verse, User.CacheData.UserName, User.CacheData.Passwd); Device.BeginInvokeOnMainThread(() => { mainpage.setting.UpdateLoginState("(Success)"); mainpage.setting.UpdateNameEntry(User.CacheData.UserName); var page = mainpage.CurrentView(); var settingview = page as SettingView; if (settingview == null) { mainpage.LoadLobby(); } }); } else { Device.BeginInvokeOnMainThread(() => { mainpage.setting.UpdateLoginState("(Failed)"); }); User.LoginSuccess = false; } } break; case (int)PROTOCOL.IdPktRoomListRes: { ROOM_LIST_RES res = new ROOM_LIST_RES(); res = ROOM_LIST_RES.Parser.ParseFrom(data.Data); Device.BeginInvokeOnMainThread(() => { var mainpage = (MainPage)Application.Current.MainPage; RoomsPageView roompage = mainpage.lobby.roompage as RoomsPageView; roompage?.LoadRoomList(res); }); } break; case (int)PROTOCOL.IdPktNoticeRes: { NOTICE_RES res = new NOTICE_RES(); res = NOTICE_RES.Parser.ParseFrom(data.Data); Device.BeginInvokeOnMainThread(() => { var mainpage = (MainPage)Application.Current.MainPage; mainpage.alarm.LoadList(res); }); } break; case (int)PROTOCOL.IdPktMailListRes: { MAIL_LIST_RES res = new MAIL_LIST_RES(); res = MAIL_LIST_RES.Parser.ParseFrom(data.Data); Device.BeginInvokeOnMainThread(() => { var mainpage = (MainPage)Application.Current.MainPage; mainpage.mail.LoadList(res); }); } break; case (int)PROTOCOL.IdPktPrayMessageRes: { PRAY_MESSAGE_RES res = new PRAY_MESSAGE_RES(); res = PRAY_MESSAGE_RES.Parser.ParseFrom(data.Data); Device.BeginInvokeOnMainThread(() => { var mainpage = (MainPage)Application.Current.MainPage; PrayView prayview = mainpage.lobby.praypage as PrayView; prayview?.LoadPrayList(res); }); } break; case (int)PROTOCOL.IdPktCreateRoomRes: { CREATE_ROOM_RES res = new CREATE_ROOM_RES(); res = CREATE_ROOM_RES.Parser.ParseFrom(data.Data); if (res.VarCode != ErrorCode.Success) { break; } Device.BeginInvokeOnMainThread(() => { var mainpage = (MainPage)Application.Current.MainPage; RoomsPageView roompage = mainpage.lobby.roompage as RoomsPageView; User.RoomIdList.Add(res.VarRoomId); { User.CurrentChatViewNumber = res.VarRoomId; var chatview = new MainChatView(); mainpage.lobby.chatpage.Add(res.VarRoomId, chatview); MainChatView chatpage = chatview; mainpage.LoadView(chatpage); } }); } break; case (int)PROTOCOL.IdPktEnterRoomRes: { ENTER_ROOM_RES res = new ENTER_ROOM_RES(); res = ENTER_ROOM_RES.Parser.ParseFrom(data.Data); if (res.VarCode != ErrorCode.DuplicateEnterRoom && res.VarCode != ErrorCode.Success) { break; } Device.BeginInvokeOnMainThread(() => { try { var mainpage = (MainPage)Application.Current.MainPage; RoomsPageView roompage = mainpage.lobby.roompage as RoomsPageView; User.RoomIdList.Add(res.VarRoomId); { User.CurrentChatViewNumber = res.VarRoomId; MainChatView outivew; mainpage.lobby.chatpage.TryGetValue(res.VarRoomId, out outivew); if (outivew == null) //없으면 새로 만들어서 넣는다. { var chatview = new MainChatView(); mainpage.lobby.chatpage.Add(res.VarRoomId, chatview); mainpage.LoadView(chatview); foreach (var msg in res.VarMessages) { chatview.ReceiveMessage(msg.VarMessage, msg.VarName, msg.VarTime); } chatview.ScrollEnd(); } else //이미 존재하는 방이면 해당 방에 넣는다. { mainpage.LoadView(outivew); outivew.ScrollEnd(); } } } catch (Exception e) { } }); } break; case (int)PROTOCOL.IdPktRoomPassThroughRes: { ROOM_PASS_THROUGH_RES res = new ROOM_PASS_THROUGH_RES(); res = ROOM_PASS_THROUGH_RES.Parser.ParseFrom(data.Data); Device.BeginInvokeOnMainThread(() => { var mainpage = (MainPage)Application.Current.MainPage; MainChatView outivew; mainpage.lobby.chatpage.TryGetValue(res.VarRoomNumber, out outivew); if (outivew == null) { return; } foreach (var msg in res.VarMessages) { outivew.ReceiveMessage(msg.VarMessage, msg.VarName, msg.VarTime); } outivew.ScrollEnd(); }); } break; case (int)PROTOCOL.IdPktLeaveRoomRes: { LEAVE_ROOM_RES res = new LEAVE_ROOM_RES(); res = LEAVE_ROOM_RES.Parser.ParseFrom(data.Data); var mainpage = (MainPage)Application.Current.MainPage; Device.BeginInvokeOnMainThread(() => { MainChatView outivew; mainpage.lobby.chatpage.TryGetValue(res.VarRoomNumber, out outivew); if (outivew == null) { return; } outivew.UserList.Remove(res.VarName); if (res.VarName == User.CacheData.UserName) { User.RoomIdList.Remove(res.VarRoomNumber); mainpage.lobby.chatpage.Remove(res.VarRoomNumber); mainpage.lobby.LoadRoomPageView(); } else { MainChatView chatpage = outivew as MainChatView; chatpage.ReceiveMessage(res.VarName + " leaved.", res.VarName, Message.type.Info); } }); } break; case (int)PROTOCOL.IdPktAudioMessageRes: { AUDIO_MESSAGE_RES res = new AUDIO_MESSAGE_RES(); res = AUDIO_MESSAGE_RES.Parser.ParseFrom(data.Data); foreach (var msg in res.VarMessage) { StreamWrapper wra = new StreamWrapper(); wra.stream = new MemoryStream(msg.ToByteArray()); wra.pos = res.VarPos; AudioStream.Enqueue(wra); } } break; case (int)PROTOCOL.IdPktBitmapMessageRes: { BITMAP_MESSAGE_RES res = new BITMAP_MESSAGE_RES(); res = BITMAP_MESSAGE_RES.Parser.ParseFrom(data.Data); foreach (var msg in res.VarMessage) { StreamWrapper wra = new StreamWrapper(); wra.stream = new MemoryStream(msg.ToByteArray()); wra.pos = res.VarPos; JpegStream.Enqueue(wra); } } break; case (int)PROTOCOL.IdPktNewUserInRoomNty: { NEW_USER_IN_ROOM_NTY res = new NEW_USER_IN_ROOM_NTY(); res = NEW_USER_IN_ROOM_NTY.Parser.ParseFrom(data.Data); var mainpage = (MainPage)Application.Current.MainPage; Device.BeginInvokeOnMainThread(() => { MainChatView outivew; mainpage.lobby.chatpage.TryGetValue(res.VarRoomUser.VarRoomNumber, out outivew); if (outivew == null) { return; } outivew.UserList.Add(res.VarRoomUser.VarName); if (res.VarType == 1) { if (res.VarRoomUser.VarName != User.CacheData.UserName) { outivew.ReceiveMessage(res.VarRoomUser.VarName + " entered.", res.VarRoomUser.VarName, Message.type.Info); } } }); } break; } } catch (Exception ex) { Console.Write(ex.ToString()); } } }
public void DrawMainText(StackLayout MainLayout, BibleType type = BibleType.KRV) #endif { //db에 밑줄 저장 데이터가 있는지 로딩한다. var list = SQLLiteDB.ReadUnderlining(); MainTextLabel.Clear(); var TextLayout = new StackLayout { Orientation = StackOrientation.Vertical, Spacing = 5 }; int verseSize = BibleInfo.GetVerseSize(User.CacheData.BibleName, User.CacheData.Chapter); int verseSizeEng = BibleInfo.GetVerseSize(User.CacheData.BibleName, User.CacheData.Chapter, BibleType.KJV); int size = verseSize > verseSizeEng ? verseSize : verseSizeEng; for (int i = 1; i <= size; i++) { string Text = BibleInfo.GetContextText(type, User.CacheData.BibleName, User.CacheData.Chapter, i); string TextEnglish = BibleInfo.GetContextText(BibleType.KJV, User.CacheData.BibleName, User.CacheData.Chapter, i); var Label = new Label { Text = Text, FontSize = User.CacheData.FontSize, LineBreakMode = LineBreakMode.WordWrap, TextColor = Xamarin.Forms.Color.FromRgb(0, 0, 0) }; var LabelEnglish = new Label { Text = TextEnglish, FontSize = User.CacheData.FontSize, LineBreakMode = LineBreakMode.WordWrap, TextColor = Xamarin.Forms.Color.FromRgb(0, 0, 0) }; //SQL DB에 저장되어 있는 데이터가 존재하면 해당 색으로 배경을 변경한다. CheckUnderLine(list, Label, i); //자동이동을 위해 따로 저장한다. MainTextLabel[i] = Label; // Your label tap event var englishlabeltab = new TapGestureRecognizer(); englishlabeltab.Tapped += async(s, e) => { //try //{ // var labelText = s as Label; // string Context = labelText.Text; // string[] words = Context.Split(' '); // Dictionary<string, string> help = new Dictionary<string, string>(); // if (words != null || words.Length > 0) // { // for (int k = 0; k < words.Length; k++) // { // words[k] = words[k].ToLower(); // string outstr; // if (Dic._dictionary.TryGetValue(words[k], out outstr) == true) // { // help[words[k]] = outstr; // } // else // { // if (words[k].Length > 3) // { // //끝에 하나버림 // string sub1 = words[k].Substring(0, words[k].Length - 1); // if (Dic._dictionary.TryGetValue(sub1, out outstr) == true) // { // help[sub1] = outstr; // } // else // { // //끝에 두개버림 // sub1 = words[k].Substring(0, words[k].Length - 2); // if (Dic._dictionary.TryGetValue(sub1, out outstr) == true) // { // help[sub1] = outstr; // } // } // } // } // } // } // } // string context = ""; // foreach( var str in help) // { // context += str.Key; // context += " : "; // context += str.Value; // context += "\n\n"; // } // await App.Current.MainPage.DisplayAlert("Help", context, "OK"); //} //catch (Exception) //{ //} }; var labeltab = new TapGestureRecognizer(); labeltab.Tapped += async(s, e) => { var labelText = s as Label; try { string action = await App.Current.MainPage.DisplayActionSheet("Line", "cancel", null, "red", "yellow", "blue"); //선택한 라벨의 절수를 가져온다. int iverse = 1; string verse = labelText.Text; if (verse != null) { string[] header = verse.Split(' '); if (header.Length > 0) { iverse = Convert.ToInt32(header[0]); } } switch (action) { case "red": labelText.BackgroundColor = Color.Red; SQLLiteDB.InsertUnderlining(User.CacheData.BibleName, User.CacheData.Chapter, iverse, "빨강"); break; case "yellow": labelText.BackgroundColor = Color.Yellow; SQLLiteDB.InsertUnderlining(User.CacheData.BibleName, User.CacheData.Chapter, iverse, "노랑"); break; case "blue": labelText.BackgroundColor = Color.Green; SQLLiteDB.InsertUnderlining(User.CacheData.BibleName, User.CacheData.Chapter, iverse, "파랑"); break; case "cancel": labelText.BackgroundColor = Color.White; SQLLiteDB.DeleteUnderlining(User.CacheData.BibleName, User.CacheData.Chapter, iverse, ""); break; } } catch (Exception) { } }; Label.GestureRecognizers.Add(labeltab); LabelEnglish.GestureRecognizers.Add(englishlabeltab); TextLayout.Children.Add(Label); if (User.CacheData.EnalbeKJV == true) { TextLayout.Children.Add(LabelEnglish); } } var LabelEndLine0 = new Label { Text = "", FontSize = User.CacheData.FontSize, LineBreakMode = LineBreakMode.WordWrap, TextColor = Xamarin.Forms.Color.FromRgb(0, 0, 0), HorizontalTextAlignment = TextAlignment.Center }; TextLayout.Children.Add(LabelEndLine0); var LabelEndLine1 = new Label { Text = "성경전서 개역한글판의 저작권은", FontSize = User.CacheData.FontSize, LineBreakMode = LineBreakMode.WordWrap, TextColor = Xamarin.Forms.Color.FromRgb(0, 0, 0), HorizontalTextAlignment = TextAlignment.Center }; TextLayout.Children.Add(LabelEndLine1); var LabelEndLine2 = new Label { Text = "( 재 ) 대한성서공회에 있습니다", FontSize = User.CacheData.FontSize, LineBreakMode = LineBreakMode.WordWrap, TextColor = Xamarin.Forms.Color.FromRgb(0, 0, 0), HorizontalTextAlignment = TextAlignment.Center }; TextLayout.Children.Add(LabelEndLine2); var LabelEndLine3 = new Label { Text = "", FontSize = User.CacheData.FontSize, LineBreakMode = LineBreakMode.WordWrap, TextColor = Xamarin.Forms.Color.FromRgb(0, 0, 0) }; TextLayout.Children.Add(LabelEndLine3); MainLayout.Children.Add(TextLayout); }