예제 #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;
            }
        }
예제 #2
0
 private void ImportFromString(string input)
 {
     #region radwordsprocessing-formats-and-conversion-txt-txtformatprovider_1
     TxtFormatProvider provider = new TxtFormatProvider();
     RadFlowDocument   document = provider.Import(input);
     #endregion
 }
예제 #3
0
        private static void OnTextPropertyChanged(DependencyObject re, DependencyPropertyChangedEventArgs e)
        {
            var richEdit = (SpellCheckTextBox)re;

            if ((string)e.NewValue != null)
            {
                _originText       = e.NewValue.ToString();
                richEdit.Document = _txtFormatProvider.Import(_originText);
            }
        }
예제 #4
0
 private void ImportFromFile()
 {
     #region radwordsprocessing-formats-and-conversion-txt-txtformatprovider_0
     TxtFormatProvider provider = new TxtFormatProvider();
     using (Stream input = File.OpenRead("Sample.txt"))
     {
         RadFlowDocument document = provider.Import(input);
     }
     #endregion
 }
예제 #5
0
        private void OpenFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog    ofd            = new OpenFileDialog();
            TxtFormatProvider formatProvider = new TxtFormatProvider();

            ofd.Filter = "Text (tab delimited) (*.txt)|*.txt|All Files (*.*)|*.*";

            if (ofd.ShowDialog() == true)
            {
                using (Stream input = ofd.OpenRead())
                {
                    this.radSpreadsheet.Workbook = formatProvider.Import(input);
                }
            }
        }
예제 #6
0
        private void ImportTxt()
        {
            #region radspreadsheet-model-import-export-txtformatprovider-wpf_0
            string fileName = "SampleFile.txt";
            if (!File.Exists(fileName))
            {
                throw new FileNotFoundException(String.Format("File {0} was not found!", fileName));
            }

            Workbook workbook;
            IWorkbookFormatProvider formatProvider = new TxtFormatProvider();

            using (FileStream input = new FileStream(fileName, FileMode.Open))
            {
                workbook = formatProvider.Import(input);
            }
            #endregion
        }
예제 #7
0
        private void ImportWorkbookFromTxtUsingOpenFileDialog()
        {
            #region radspreadsheet-model-import-export-txtformatprovider-silverlight_1
            Workbook workbook;

            OpenFileDialog          openFileDialog = new OpenFileDialog();
            IWorkbookFormatProvider formatProvider = new TxtFormatProvider();
            openFileDialog.Filter = "TXT (tab delimited) (*.txt)|*.txt|All Files (*.*)|*.*";

            if (openFileDialog.ShowDialog() == true)
            {
                using (Stream input = openFileDialog.File.OpenRead())
                {
                    workbook = formatProvider.Import(input);
                }
            }
            #endregion
        }
예제 #8
0
        private void ImportTxt()
        {
            string fileName = "SampleFile.txt";

            if (!File.Exists(fileName))
            {
                throw new FileNotFoundException(String.Format("File {0} was not found!", fileName));
            }

            #region radspreadprocessing-formats-and-conversion-txt-txtformatprovider_0
            Workbook workbook;
            IWorkbookFormatProvider formatProvider = new TxtFormatProvider();

            using (FileStream input = new FileStream(fileName, FileMode.Open))
            {
                workbook = formatProvider.Import(input);
            }
            #endregion
        }
예제 #9
0
 private void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     TxtFormatProvider formatProvider = new TxtFormatProvider();
     Workbook          workbook       = formatProvider.Import(e.Result);
 }