Beispiel #1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            DocumentWriterViewModel vm = this.DataContext as DocumentWriterViewModel;

            if ((vm.Description == null) || (vm.Description.Trim() == ""))
            {
                iRadiate.Desktop.Common.DesktopApplication.ShowDialog("Error", "Cannot save document without description");
                return;
            }
            var content = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd);

            if (content.CanSave(DataFormats.Rtf))
            {
                using (var stream = new MemoryStream())
                {
                    content.Save(stream, DataFormats.Rtf);
                    iRadiate.DataModel.Common.File f = new DataModel.Common.File();

                    f.Data        = stream.ToArray();
                    f.Extension   = "rtf";
                    f.Study       = vm.Study;
                    f.Description = vm.Description;
                    iRadiate.Desktop.Common.DesktopApplication.GetLibrarian().SaveItem(f);
                }
            }
        }
Beispiel #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            IStudyDataProvider provider = DataProviderComboBox.SelectedItem as IStudyDataProvider;

            if (provider.IsFormattable)
            {
                string format = "{0:" + ((ComboBoxItem)FormatSelectorComboBox.SelectedValue).Content.ToString() + "}";
                rtb.CaretPosition.InsertTextInRun(String.Format(format, provider.GetData()));
            }
            else
            {
                DocumentWriterViewModel vm = this.DataContext as DocumentWriterViewModel;

                rtb.CaretPosition.InsertTextInRun(vm.CurrentProvider.GetData().ToString());
            }

            rtb.Focus();
        }