Пример #1
0
        //private void increaseSize_Click(object sender, RoutedEventArgs e)
        //{
        //	object fontSize = TextEditing.GetRTBValue(TextElement.FontSizeProperty);

        //	if (fontSize != DependencyProperty.UnsetValue)
        //	{
        //		fontSizeBox.IsTextSearchEnabled = true;
        //		fontSizeBox.Text = Converter.PointToPixel((double)(fontSize)).ToString();
        //		fontSizeBox.IsTextSearchEnabled = false;
        //	}
        //	else
        //	{
        //		fontSizeBox.Text = "";
        //		fontSizeBox.SelectedIndex = -1;
        //	}
        //}

        //private void decreaseSize_Click(object sender, RoutedEventArgs e)
        //{
        //	object fontSize = TextEditing.GetRTBValue(TextElement.FontSizeProperty);

        //	if (fontSize != DependencyProperty.UnsetValue)
        //	{
        //		fontSizeBox.IsTextSearchEnabled = true;
        //		fontSizeBox.Text = Converter.PointToPixel((double)(fontSize)).ToString();
        //		fontSizeBox.IsTextSearchEnabled = false;
        //	}
        //	else
        //	{
        //		fontSizeBox.Text = "";
        //		fontSizeBox.SelectedIndex = -1;
        //	}
        //}

        private void UpdateFontSize(bool focusRTB)
        {
            string text = fontSizeBox.Text;

            double value;

            if (double.TryParse(text, out value))
            {
                TextEditing.SetRTBValue(FontSizeProperty, Converter.PixelToPoint(value), focusRTB);

                bool found = false;

                foreach (ComboBoxItem each in fontSizeBox.Items)
                {
                    if (each.Content.ToString() == text)
                    {
                        each.IsSelected = true;
                        found           = true;
                        break;
                    }
                }

                if (!found)
                {
                    fontSizeBox.SelectedIndex = -1;
                    fontSizeBox.Text          = text;
                }
            }
        }
Пример #2
0
        private void EditVerse_Cliked(object sender, System.Windows.RoutedEventArgs e)
        {
            if (this.SelectedNote == null)
            {
                MessageDisplay.Show("Please select a Verse Note");

                return;
            }

            try
            {
                if (TextEditing.ShowDialog(this.SelectedNote.Verse, this.uxVerseNotes.Text).IsFalse())
                {
                    return;
                }

                if (TextEditing.Text.IsNullEmptyOrWhiteSpace())
                {
                    this.DeleteSelectedVerse();

                    return;
                }

                BiblesData.Database.InsertVerseNote(new VerseNotesModel {
                    BibleVerseKey = this.SelectedNote.BibleVerseKey, FootNote = TextEditing.Text.ZipFile()
                });

                this.uxVerseNotes.Text = TextEditing.Text;
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
Пример #3
0
 private void fontFamilyBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (e.AddedItems.Count > 0 && fontFamilyBox.SelectedItem != null)
     {
         TextEditing.SetRTBValue(FontFamilyProperty, fontFamilyBox.SelectedItem.ToString(), true);
     }
 }
Пример #4
0
        private static void ExecutedHyperlinkCommand(object sender, ExecutedRoutedEventArgs e)
        {
            MainWindow window = FindWindow(sender);

            if (SpellChecking.FocusedRTB != null)
            {
                TextEditing.Hyperlink(window, SpellChecking.FocusedRTB);
                SpellChecking.FocusedRTB.Focus();
            }
        }
Пример #5
0
        private void clear_Click(object sender, RoutedEventArgs e)
        {
            SpellChecking.FocusedRTB.BeginChange();

            SpellChecking.FocusedRTB.Selection.ClearAllProperties();
            SpellChecking.FocusedRTB.Selection.ApplyPropertyValue(Paragraph.MarginProperty, new Thickness(0));
            TextEditing.ChangeRTBParagraphBackground(SpellChecking.FocusedRTB, null);

            SpellChecking.FocusedRTB.EndChange();

            UpdateFormattingUI();
        }
Пример #6
0
        private void Notes_Cliked(object sender, RoutedEventArgs e)
        {
            try
            {
                string bibleVerseKey = this.SelectedVerseKey;

                if (!Formatters.IsBiblesKey(bibleVerseKey))
                {
                    bibleVerseKey = $"{this.selectedBibleId}||{bibleVerseKey}";
                }

                VerseNotesModel noteModel = BiblesData.Database.GetVerseNotes(bibleVerseKey);

                if (noteModel == null)
                {
                    noteModel = new VerseNotesModel {
                        BibleVerseKey = bibleVerseKey, FootNote = new byte[] { }
                    };
                }

                string footNotes = noteModel.FootNote.UnzipFile().ParseToString();

                if (TextEditing.ShowDialog(GlobalStaticData.Intance.GetKeyDescription(this.SelectedVerseKey), footNotes).IsFalse())
                {
                    return;
                }

                noteModel.FootNote = TextEditing.Text.ZipFile();

                BiblesData.Database.InsertVerseNote(noteModel);

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

                BibleLoader.RefreshVerseNumberPanel
                (
                    this.loadedVerseStackDictionaryLeft[selectedVerse],
                    this.BibleLeft.BibleId,
                    this.versesDictionaryLeft[selectedVerse]
                );

                BibleLoader.RefreshVerseNumberPanel
                (
                    this.loadedVerseStackDictionaryRight[selectedVerse],
                    this.BibleRight.BibleId,
                    this.versesDictionaryRight[selectedVerse]
                );
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
Пример #7
0
        private static void ExecutedUnderlineCommand(object sender, ExecutedRoutedEventArgs e)
        {
            MainWindow window = FindWindow(sender);

            if (window.underline.IsChecked == true)
            {
                TextEditing.AddTextDecoration(TextDecorations.Underline);
            }
            else
            {
                TextEditing.RemoveTextDecoration(TextDecorations.Underline);
            }
        }
Пример #8
0
        private static void ExecutedStrikethroughCommand(object sender, ExecutedRoutedEventArgs e)
        {
            MainWindow window = FindWindow(sender);

            if (window.strikethrough.IsChecked == true)
            {
                TextEditing.AddTextDecoration(TextDecorations.Strikethrough);
            }
            else
            {
                TextEditing.RemoveTextDecoration(TextDecorations.Strikethrough);
            }
        }
Пример #9
0
        private void fontSizeBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count > 0)
            {
                string newSize = (fontSizeBox.SelectedItem as ComboBoxItem).Content as string;

                double value;

                if (double.TryParse(newSize, out value))
                {
                    TextEditing.SetRTBValue(FontSizeProperty, Converter.PixelToPoint(value), true);
                }
            }
        }
Пример #10
0
        private void paragraphSpacingBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count > 0)
            {
                object fontSize = TextEditing.GetRTBValue(FontSizeProperty);

                if (fontSize == DependencyProperty.UnsetValue)
                {
                    fontSize = SpellChecking.FocusedRTB.FontSize;
                }

                TextEditing.SetRTBValue(Paragraph.MarginProperty, new Thickness(0, 0, 0,
                                                                                (double.Parse((e.AddedItems[0] as ComboBoxItem).Content.ToString()) - 1)
                                                                                * (double)fontSize), true);
            }
        }
Пример #11
0
        public ProjectTreeLister(
            ICommandService commandService,
            IControlHostService controlHostService,
            IContextRegistry contextRegistry,
            ISettingsService settings,
            TextEditing.TextEditor textEditor
          )
            : base(commandService)
        {
            this.commandService = commandService;
            m_controlHostService = controlHostService;
            m_contextRegistry = contextRegistry;
            this.settings = settings;
            this.textEditor = textEditor;

            this.TreeControl.ImageList = ResourceUtil.GetImageList16();
        }
Пример #12
0
        public UnitTreeLister(
            ICommandService commandService,
            IControlHostService controlHostService,
            IContextRegistry contextRegistry,
            ISettingsService settings,
            TextEditing.TextEditor textEditor
          )
            : base(commandService)
        {
            m_controlHostService = controlHostService;
            m_contextRegistry = contextRegistry;
            this.settings = settings;

            this.TreeControl.ImageList = ResourceUtil.GetImageList16();

            TreeView = new UnitView();
        }
Пример #13
0
        private static void VerseNote_Selected(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Image item = (Image)sender;

                string bibleVerseKey = item.Tag.ParseToString();

                VerseNotesModel noteModel = BiblesData.Database.GetVerseNotes(bibleVerseKey);

                if (noteModel == null)
                {
                    noteModel = new VerseNotesModel {
                        BibleVerseKey = bibleVerseKey
                    };
                }

                string footNotes = noteModel.FootNote.UnzipFile().ParseToString();

                if (TextEditing.ShowDialog(GlobalStaticData.Intance.GetKeyDescription(bibleVerseKey), footNotes).IsFalse())
                {
                    return;
                }

                if (TextEditing.Text.IsNullEmptyOrWhiteSpace())
                {
                    BiblesData.Database.DeleteVerseNote(bibleVerseKey);

                    StackPanel parentpanel = item.Parent.To <StackPanel>();

                    parentpanel.Children.Remove(item);

                    return;
                }

                noteModel.FootNote = TextEditing.Text.ZipFile();

                item.ToolTip = TextEditing.Text;

                BiblesData.Database.InsertVerseNote(noteModel);
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
        private void BookmarkModel_Browse(object sender, object model, string buttonKey)
        {
            try
            {
                ModelsBookmark bookmark = (ModelsBookmark)model;

                if (TextEditing.ShowDialog("Bookmark Description", bookmark.Description).IsFalse())
                {
                    return;
                }

                bookmark.Description = TextEditing.Text;
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
Пример #15
0
        private void UpdateFontFamily(bool focusRTB)
        {
            string text = fontFamilyBox.Text;

            TextEditing.SetRTBValue(FontFamilyProperty, text, focusRTB);

            bool found = false;

            for (int i = 0; i < fontFamilyBox.Items.Count; i++)
            {
                if (fontFamilyBox.Items[i].ToString() == text)
                {
                    fontFamilyBox.SelectedIndex = i;
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                fontFamilyBox.SelectedIndex = -1;
                fontFamilyBox.Text          = text;
            }
        }
Пример #16
0
 private void highlightColor_OnSelectedChangedEvent(object sender, EventArgs e)
 {
     TextEditing.SetRTBValue(TextElement.BackgroundProperty, highlightColor.SelectedColor, true);
 }
 /// <summary>
 /// Raises the <see cref="TextEditing"/> event.
 /// </summary>
 /// <param name="window">The window that raised the event.</param>
 protected virtual void OnTextEditing(IUltravioletWindow window)
 {
     TextEditing?.Invoke(window, this);
 }
Пример #18
0
 private void fontColor_OnSelectedChangedEvent(object sender, EventArgs e)
 {
     TextEditing.SetRTBValue(ForegroundProperty, fontColor.SelectedColor, true);
 }
Пример #19
0
        private void UpdateFormattingUI()
        {
            object font = TextEditing.GetRTBValue(TextElement.FontFamilyProperty);

            if (font != DependencyProperty.UnsetValue)
            {
                fontFamilyBox.IsTextSearchEnabled = true;
                fontFamilyBox.Text = font.ToString();
                fontFamilyBox.IsTextSearchEnabled = false;
            }
            else
            {
                fontFamilyBox.Text          = "";
                fontFamilyBox.SelectedIndex = -1;
            }

            object fontSize = TextEditing.GetRTBValue(TextElement.FontSizeProperty);

            if (fontSize != DependencyProperty.UnsetValue)
            {
                fontSizeBox.IsTextSearchEnabled = true;
                fontSizeBox.Text = Converter.PointToPixel((double)(fontSize)).ToString();
                fontSizeBox.IsTextSearchEnabled = false;
            }
            else
            {
                fontSizeBox.Text          = "";
                fontSizeBox.SelectedIndex = -1;
            }

            object fontWeight = TextEditing.GetRTBValue(FontWeightProperty);

            bold.IsChecked = fontWeight != DependencyProperty.UnsetValue ? (FontWeight)fontWeight == FontWeights.Bold : false;

            object fontStyle = TextEditing.GetRTBValue(FontStyleProperty);

            italic.IsChecked = fontStyle != DependencyProperty.UnsetValue ? (FontStyle)fontStyle == FontStyles.Italic : false;

            object textdecoration = TextEditing.GetRTBValue(TextBlock.TextDecorationsProperty);

            underline.IsChecked     = TextEditing.ContainsTextDecoration(textdecoration, TextDecorations.Underline);
            strikethrough.IsChecked = TextEditing.ContainsTextDecoration(textdecoration, TextDecorations.Strikethrough);

            object variants = TextEditing.GetRTBValue(Typography.VariantsProperty);

            if (variants != DependencyProperty.UnsetValue)
            {
                switch ((FontVariants)variants)
                {
                case FontVariants.Subscript:
                    subscript.IsChecked = true;
                    break;

                case FontVariants.Superscript:
                    superscript.IsChecked = true;
                    break;

                default:
                    subscript.IsChecked   = false;
                    superscript.IsChecked = false;
                    break;
                }
            }
            else
            {
                subscript.IsChecked   = false;
                superscript.IsChecked = false;
            }

            object color = TextEditing.GetRTBValue(ForegroundProperty);

            if (color != DependencyProperty.UnsetValue)
            {
                fontColor.ActiveColor = (Brush)color;
            }

            object highlight = TextEditing.GetRTBValue(TextElement.BackgroundProperty);

            if (highlight != DependencyProperty.UnsetValue)
            {
                highlightColor.ActiveColor = (Brush)highlight;
            }

            UpdateSelectionListType();

            object alignment = TextEditing.GetRTBValue(TextBlock.TextAlignmentProperty);

            if (alignment != DependencyProperty.UnsetValue)
            {
                switch ((TextAlignment)alignment)
                {
                case TextAlignment.Center:
                    alignCenter.IsChecked = true;
                    break;

                case TextAlignment.Justify:
                    alignJustify.IsChecked = true;
                    break;

                case TextAlignment.Left:
                    alignLeft.IsChecked = true;
                    break;

                case TextAlignment.Right:
                    alignRight.IsChecked = true;
                    break;
                }
            }
            else
            {
                alignLeft.IsChecked    = false;
                alignCenter.IsChecked  = false;
                alignRight.IsChecked   = false;
                alignJustify.IsChecked = false;
            }

            object margin   = TextEditing.GetRTBValue(Paragraph.MarginProperty);
            double pSpacing = margin != DependencyProperty.UnsetValue ? ((Thickness)margin).Bottom : -1;

            if (fontSize == DependencyProperty.UnsetValue)
            {
                fontSize = SpellChecking.FocusedRTB.FontSize;
            }

            bool foundIndex = false;

            foreach (ComboBoxItem each in paragraphSpacingBox.Items)
            {
                if ((double.Parse(each.Content.ToString()) - 1) * (double)fontSize == pSpacing)
                {
                    each.IsSelected = true;
                    foundIndex      = true;
                    break;
                }
            }

            if (!foundIndex)
            {
                paragraphSpacingBox.SelectedIndex = -1;
            }

            object border = TextEditing.GetRTBValue(Block.BorderThicknessProperty);

            if (border != DependencyProperty.UnsetValue)
            {
                borderType.ActiveBorder = (Thickness)border;
            }

            object background = TextEditing.GetSelectionParagraphPropertyValue(SpellChecking.FocusedRTB.Selection, TextElement.BackgroundProperty);

            if (background != DependencyProperty.UnsetValue)
            {
                backgroundColor.ActiveColor = (Brush)background;
            }
        }
Пример #20
0
 private void backgroundColor_OnSelectedChangedEvent(object sender, EventArgs e)
 {
     SpellChecking.FocusedRTB.BeginChange();
     TextEditing.ChangeRTBParagraphBackground(SpellChecking.FocusedRTB, backgroundColor.SelectedColor);
     SpellChecking.FocusedRTB.EndChange();
 }
Пример #21
0
 private void Hyperlink_Click(object sender, RoutedEventArgs e)
 {
     TextEditing.Hyperlink_Click(sender, e);
 }
Пример #22
0
        protected override void TextEditingPropertyChanged()
        {
            base.TextEditingPropertyChanged();

            if (TextEditing.Length < 150)
            {
                (SolidColorBrush colorBrush, int strength)result = CoreHelper.DeterminePasswordStrength(TextEditing.ToUnsecureString());
                StrengthBrush = result.colorBrush;
                Strength      = result.strength;
            }
        }
Пример #23
0
 private void Hyperlink_MouseLeave(object sender, MouseEventArgs e)
 {
     TextEditing.Hyperlink_MouseLeave(sender, e);
 }
Пример #24
0
 private void borderType_OnSelectedChangedEvent(object sender, EventArgs e)
 {
     TextEditing.SetRTBValue(Block.BorderThicknessProperty, borderType.SelectedBorder, true);
 }