Exemplo n.º 1
0
        internal static HighlightRitchTextBox GetVerseAsTextBox(int bibleId, BibleVerseModel verse, int column)
        {
            HighlightRitchTextBox result = new HighlightRitchTextBox
            {
                Text        = verse.VerseText,
                Tag         = verse,
                BorderBrush = Brushes.Transparent,
                IsReadOnly  = true,
                Margin      = new Thickness(2, 0, 0, 15)
            };

            List <HighlightVerseModel> verseColours = BiblesData.Database.GetVerseColours(verse.BibleVerseKey);

            foreach (HighlightVerseModel colour in verseColours)
            {
                string[] itemSplit = colour.BibleVerseKeyId.Split(BibleLoader.veseSplitValues);

                result.HighlightText(itemSplit[1].ToInt32(), itemSplit[2].ToInt32(), ColourConverters.GetBrushfromHex(colour.HexColour));
            }

            Grid.SetRow(result, (Formatters.GetVerseFromKey(verse.BibleVerseKey) - 1));

            Grid.SetColumn(result, column);

            return(result);
        }
        private void BackColour_Clicked(object sender, RoutedEventArgs e)
        {
            if (this.selectedKey.IsNullEmptyOrWhiteSpace() ||
                Formatters.GetVerseFromKey(this.selectedKey) <= 0)
            {
                MessageDisplay.Show("Please select a Verse");

                return;
            }

            try
            {
                ColourPicker picker = new ColourPicker();

                if (picker.ShowDialog().IsFalse())
                {
                    return;
                }

                int verseNumber = Formatters.GetVerseFromKey(this.selectedKey);

                HighlightRitchTextBox textBox = this.loadedTextBoxDictionary[verseNumber];

                int start = textBox.GetSelectionStartIndex();

                int length = textBox.GetSelectedTextLength();

                textBox.HighlightText(start, length, picker.SelectedColour);

                string bibleVerseKey = Formatters.IsBiblesKey(this.selectedKey) ?
                                       this.selectedKey
                    :
                                       $"{this.Bible.BibleId}||{this.selectedKey}";


                BiblesData.Database.InsertVerseColour(bibleVerseKey, start, length, ColourConverters.GetHexFromBrush(picker.SelectedColour));
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
        private void LoadSearchResults(BibleVerseModel[] result)
        {
            foreach (BibleVerseModel row in result)
            {
                this.uxResultGrid.RowDefinitions.Add(this.GetRowDefinition());

                if (this.showBibleColumn)
                {
                    int bibleId = Formatters.GetBibleFromKey(row.BibleVerseKey);

                    LableItem bible = new LableItem {
                        Content = this.bibleNames[bibleId]
                    };

                    this.SetUiElementPosition(bible, 0);
                }

                LableItem verse = new LableItem {
                    Content = GlobalStaticData.Intance.GetKeyDescription(row.BibleVerseKey)
                };

                this.SetUiElementPosition(verse, 1);

                HighlightRitchTextBox text = new HighlightRitchTextBox
                {
                    Text        = row.VerseText,
                    Tag         = row,
                    BorderBrush = Brushes.Transparent,
                    IsReadOnly  = true,
                    Margin      = new Thickness(2, 0, 0, 15)
                };

                text.GotFocus += this.Verse_GotFocus;

                text.HighlightText(this.searchSplitResult);

                this.SetUiElementPosition(text, 2);

                ++this.rowIndex;
            }
        }