Пример #1
0
        public NewCommand(SfRichTextBoxAdv editor)
        {
            Header  = UIText.CommandHeaderNew;
            ToolTip = UIText.CommandToolTipNew;
            var command = SfRichTextBoxAdv.NewDocumentCommand;

            command.InputGestures.Add(new KeyGesture(Key.N, ModifierKeys.Control));
            Command       = command;
            CommandTarget = editor;
        }
Пример #2
0
        public PrintCommand(SfRichTextBoxAdv editor)
        {
            Header  = UIText.CommandHeaderPrint;
            ToolTip = UIText.CommandToolTipPrint;
            var command = SfRichTextBoxAdv.PrintDocumentCommand;

            command.InputGestures.Add(new KeyGesture(Key.P, ModifierKeys.Control));
            Command       = command;
            CommandTarget = editor;
        }
        private static Control OpenWord(string path)
        {
            var editor = new SfRichTextBoxAdv
            {
                IsReadOnly        = true,
                Background        = Brushes.Transparent,
                EnableMiniToolBar = false
            };

            editor.LoadAsync(path);

            return(editor);
        }
        public static SectionAdv GetCurrentSection(this SfRichTextBoxAdv editor)
        {
            var hierarchicalIndex = editor.Selection.Start.HierarchicalIndex;

            var index = hierarchicalIndex
                        .Split(';')
                        .Select(int.Parse)
                        .ToList();

            var sectionIndex   = index[0];
            var currentSection = editor.Document.Sections[sectionIndex];

            return(currentSection);
        }
        public static void InsertBlock(this SfRichTextBoxAdv editor, Node table)
        {
            var hierarchicalIndex = editor.Selection.Start.HierarchicalIndex;

            var indexes = hierarchicalIndex
                          .Split(';')
                          .Select(int.Parse)
                          .ToList();

            var sectionIndex = indexes[0];
            var blockIndex   = indexes[1];

            var currentSection = editor.Document.Sections[sectionIndex];

            currentSection.Blocks.Insert(blockIndex, table);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FontFormatGrid"/> class.
        /// </summary>
        public FontFormatGrid(SfRichTextBoxAdv richTextBox)
        {
            this.InitializeComponent();
            fontFamilyBox.ItemsSource = richTextBox.FontNames;
            fontFamilyBox.SetBinding(ComboBox.SelectedValueProperty, new Binding()
            {
                Source = richTextBox, Path = new PropertyPath("Selection.CharacterFormat.FontFamily"), Mode = BindingMode.TwoWay, Converter = new FontFamilyStringConverter()
            });
            Binding binding = new Binding()
            {
                Source = richTextBox, Path = new PropertyPath("Selection.CharacterFormat.FontSize"), Mode = BindingMode.TwoWay, Converter = new DoubleStringConverter()
            };

            fontSizeBox.SetBinding(ComboBox.SelectedValueProperty, binding);
            boldButton.SetBinding(ToggleButton.IsCheckedProperty, new Binding()
            {
                Source = richTextBox, Path = new PropertyPath("Selection.CharacterFormat.Bold"), Mode = BindingMode.TwoWay
            });
            italicButton.SetBinding(ToggleButton.IsCheckedProperty, new Binding()
            {
                Source = richTextBox, Path = new PropertyPath("Selection.CharacterFormat.Italic"), Mode = BindingMode.TwoWay
            });
            underlineButton.SetBinding(ToggleButton.IsCheckedProperty, new Binding()
            {
                Source = richTextBox, Path = new PropertyPath("Selection.CharacterFormat.Underline"), Mode = BindingMode.TwoWay, Converter = new UnderlineToggleConverter()
            });
            singleStrikeThroughButton.SetBinding(ToggleButton.IsCheckedProperty, new Binding()
            {
                Source = richTextBox, Path = new PropertyPath("Selection.CharacterFormat.StrikeThrough"), Mode = BindingMode.TwoWay, Converter = new SingleStrikeThroughToggleConverter()
            });
            doubleStrikeThroughButton.SetBinding(ToggleButton.IsCheckedProperty, new Binding()
            {
                Source = richTextBox, Path = new PropertyPath("Selection.CharacterFormat.StrikeThrough"), Mode = BindingMode.TwoWay, Converter = new DoubleStrikeThroughToggleConverter()
            });
            subscriptButton.SetBinding(ToggleButton.IsCheckedProperty, new Binding()
            {
                Source = richTextBox, Path = new PropertyPath("Selection.CharacterFormat.BaselineAlignment"), Mode = BindingMode.TwoWay, Converter = new SubscriptToggleConverter()
            });
            superscriptButton.SetBinding(ToggleButton.IsCheckedProperty, new Binding()
            {
                Source = richTextBox, Path = new PropertyPath("Selection.CharacterFormat.BaselineAlignment"), Mode = BindingMode.TwoWay, Converter = new SuperscriptToggleConverter()
            });
        }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CustomizedEditor"/> class.
 /// </summary>
 public ParaFormatGrid(SfRichTextBoxAdv richTextBox)
 {
     this.InitializeComponent();
     leftAlignButton.SetBinding(ToggleButton.IsCheckedProperty, new Binding()
     {
         Source = richTextBox, Path = new PropertyPath("Selection.ParagraphFormat.TextAlignment"), Mode = BindingMode.TwoWay, Converter = new LeftAlignmentToggleConverter()
     });
     centerAlignButton.SetBinding(ToggleButton.IsCheckedProperty, new Binding()
     {
         Source = richTextBox, Path = new PropertyPath("Selection.ParagraphFormat.TextAlignment"), Mode = BindingMode.TwoWay, Converter = new CenterAlignmentToggleConverter()
     });
     rightAlignButton.SetBinding(ToggleButton.IsCheckedProperty, new Binding()
     {
         Source = richTextBox, Path = new PropertyPath("Selection.ParagraphFormat.TextAlignment"), Mode = BindingMode.TwoWay, Converter = new RightAlignmentToggleConverter()
     });
     justifyAlignButton.SetBinding(ToggleButton.IsCheckedProperty, new Binding()
     {
         Source = richTextBox, Path = new PropertyPath("Selection.ParagraphFormat.TextAlignment"), Mode = BindingMode.TwoWay, Converter = new JustifyAlignmentToggleConverter()
     });
     increaseIndentButton.Command = richTextBox.IncreaseIndentCommand;
     decreaseIndentButton.Command = richTextBox.DecreaseIndentCommand;
 }
        public void InsertSelectedItem(SfRichTextBoxAdv richTextBoxAdv, object selectedItem)
        {
            NameSuggestionItem nameSuggestionItem = selectedItem as NameSuggestionItem;

            richTextBoxAdv.Selection.InsertText(MentionCharacter + nameSuggestionItem.Name);
        }