Exemple #1
0
        private void AddMarkWord()
        {
            try
            {
                Helper.RemoveRowGrid(main_grid, UnderliningPos);

                var list = SQLLiteDB.ReadUnderlining();
                if (list != null)
                {
                    int startpos = UnderliningPos;
                    foreach (var data in list)
                    {
                        var contexttext = BibleInfo.GetContextText(BibleType.KRV, data.BibleName, data.Chapter, data.Verse);

                        int    __verse;
                        string line;
                        Helper.SpliteVerseText(contexttext, out __verse, out line);

                        var text = data.BibleName + " " + data.Chapter + " 장" + " " + data.Verse + "절 \n" + line;

                        var labelText = new Label {
                            Text = text, LineBreakMode = LineBreakMode.WordWrap, TextColor = Xamarin.Forms.Color.FromRgb(0, 0, 0)
                        };

                        var stackLayout = new StackLayout();

                        stackLayout.Children.Add(labelText);
                        var frame = new Frame {
                            BorderColor = Color.Black, Padding = new Thickness(3, 3, 3, 3)
                        };
                        frame.Content = stackLayout;

                        main_grid.Children.Add(frame, 0, startpos++);
                        Grid.SetColumnSpan(frame, 2);
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
Exemple #2
0
        public void DrawMainText(StackLayout MainLayout, BibleType type = BibleType.KRV)
        {
            //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
                    {
                        if (User.Username != "강병욱")
                        {
                            return;
                        }

                        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 DisplayAlert("Help", context, "OK");
                    }
                    catch (Exception)
                    {
                    }
                };

                var labeltab = new TapGestureRecognizer();
                labeltab.Tapped += async(s, e) =>
                {
                    var labelText = s as Label;

                    try
                    {
                        string action = await DisplayActionSheet("줄긋기", "안하기", null, "빨강", "노랑", "파랑");

                        //선택한 라벨의 절수를 가져온다.
                        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 "빨강":
                            labelText.BackgroundColor = Color.Red;
                            SQLLiteDB.InsertUnderlining(User.CacheData.BibleName, User.CacheData.Chapter, iverse, "빨강");
                            break;

                        case "노랑":
                            labelText.BackgroundColor = Color.Yellow;
                            SQLLiteDB.InsertUnderlining(User.CacheData.BibleName, User.CacheData.Chapter, iverse, "노랑");
                            break;

                        case "파랑":
                            labelText.BackgroundColor = Color.Green;
                            SQLLiteDB.InsertUnderlining(User.CacheData.BibleName, User.CacheData.Chapter, iverse, "파랑");
                            break;

                        case "안하기":
                            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);
                }
            }
            MainLayout.Children.Add(TextLayout);
        }