Exemplo n.º 1
0
        private void RadRichTextBox_CommandExecuting(object sender, CommandExecutingEventArgs e)
        {
            if (e.Command is SaveCommand)
            {
                e.Cancel = true;
                SaveDocument(); // A custom logic for saving document so you can change the properties of the Save File dialog.
            }

            if (e.Command is PasteCommand)
            {
                // Altering the PasteCommand to ensure only plain text is pasted in RadRichTextBox.
                // Obtain the content from the clipboard.
                RadDocument documentFromClipboard = ClipboardEx.GetDocument().ToDocument();

                TxtFormatProvider provider = new TxtFormatProvider();
                // Convert it to plain text.
                string plainText = provider.Export(documentFromClipboard);

                // Create a RadDocument instance from the plain text.
                RadDocument documentToInsert = provider.Import(plainText);
                // Set this document as a content to the clipboard.
                ClipboardEx.SetDocument(new DocumentFragment(documentToInsert));
            }

            if (e.Command is InsertTableCommand)
            {
                // Disable the possibility to insert tables into the document.
                MessageBox.Show("Inserting tables is not allowed.");
                e.Cancel = true;
            }
        }