Пример #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 fontFamilyBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (e.AddedItems.Count > 0 && fontFamilyBox.SelectedItem != null)
     {
         TextEditing.SetRTBValue(FontFamilyProperty, fontFamilyBox.SelectedItem.ToString(), true);
     }
 }
Пример #3
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);
                }
            }
        }
Пример #4
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);
            }
        }
Пример #5
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;
            }
        }
Пример #6
0
 private void borderType_OnSelectedChangedEvent(object sender, EventArgs e)
 {
     TextEditing.SetRTBValue(Block.BorderThicknessProperty, borderType.SelectedBorder, true);
 }
Пример #7
0
 private void highlightColor_OnSelectedChangedEvent(object sender, EventArgs e)
 {
     TextEditing.SetRTBValue(TextElement.BackgroundProperty, highlightColor.SelectedColor, true);
 }
Пример #8
0
 private void fontColor_OnSelectedChangedEvent(object sender, EventArgs e)
 {
     TextEditing.SetRTBValue(ForegroundProperty, fontColor.SelectedColor, true);
 }