private static void OnInsertRtfContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            XamRichTextEditor editor = (XamRichTextEditor)d;

            editor.DocumentContentChanged -= Document_ContentChanged;
            editor.DocumentContentChanged += Document_ContentChanged;
        }
Ejemplo n.º 2
0
        public MessageReadOnlyView()
        {
            InitializeComponent();

            //workaround for build error
            XamRichTextEditor rte = new XamRichTextEditor();

            rte.Name = "_rte";
            rte.AllowDocumentViewSplitting = false;
            rte.BorderThickness            = new System.Windows.Thickness(0);
            rte.Margin     = new System.Windows.Thickness(10);
            rte.CaretColor = null;
            rte.IsReadOnly = true;
            //rte.ClipboardSerializationProviders.Add(new RtfSerializationProvider());

            RtfDocumentAdapter docAdapter = new RtfDocumentAdapter();

            _rtePlaceholder.Children.Add(docAdapter);
            _rtePlaceholder.Children.Add(rte);

            Binding docBinding = new Binding();

            docBinding.Source = rte;
            docBinding.Path   = new System.Windows.PropertyPath("Document");

            docAdapter.SetBinding(RtfDocumentAdapter.DocumentProperty, docBinding);

            Binding valueBinding = new Binding();

            valueBinding.Source = DataContext;
            valueBinding.Path   = new System.Windows.PropertyPath("Message.Body");

            docAdapter.SetBinding(RtfDocumentAdapter.ValueProperty, valueBinding);
        }
        /// <summary>
        /// Attaches a FormatBar to a RichtextBox
        /// </summary>
        /// <param name="richTextBox">The RichtextBox to attach to.</param>
        /// <param name="formatBar">The Formatbar to attach.</param>
        private void AttachFormatBarToRichtextBox(XamRichTextEditor richTextBox, IRichTextFormatBar formatBar)
        {
            _richTextBox = richTextBox;
            _richTextBox.MouseLeftButtonUp += RichTextBox_MouseLeftButtonUp;
            _richTextBox.PreviewMouseMove  += RichTextBox_PreviewMouseMove;
            _richTextBox.IsVisibleChanged  += RichTextBox_IsVisibleChanged;

            _adorner         = new UIElementAdorner <Control>(_richTextBox);
            formatBar.Target = _richTextBox;
            _toolbar         = formatBar;
        }
Ejemplo n.º 4
0
        protected virtual void OnRichTextEditorChanged(XamRichTextEditor oldValue, XamRichTextEditor newValue)
        {
            if (oldValue != null)
            {
                newValue.Loaded           -= RichTextEditor_Loaded;
                newValue.SelectionChanged -= RichTextEditor_SelectionChanged;
            }

            if (newValue != null)
            {
                newValue.Loaded           += RichTextEditor_Loaded;
                newValue.SelectionChanged += RichTextEditor_SelectionChanged;
            }
        }
 private void HookEditor(XamRichTextEditor editor, bool hook)
 {
     if (editor != null)
     {
         if (hook)
         {
             editor.DocumentChanged        += OnDocumentChanged;
             editor.DocumentContentChanged += OnDocumentContentChanged;
             editor.SelectionChanged       += OnEditorSelectionChanged;
             editor.IsVisibleChanged       += OnEditorIsVisibleChanged;
         }
         else
         {
             editor.DocumentChanged        -= OnDocumentChanged;
             editor.DocumentContentChanged -= OnDocumentContentChanged;
             editor.SelectionChanged       -= OnEditorSelectionChanged;
             editor.IsVisibleChanged       -= OnEditorIsVisibleChanged;
         }
     }
 }
        public AppointmentView()
        {
            InitializeComponent();

            //date/time inputs
            XamDateTimeInput dti1 = new XamDateTimeInput();

            dti1.Margin = new System.Windows.Thickness(2, 4, 2, 4);
            dti1.DropDownButtonStyle       = (Style)Resources["DropDownButtonStyle"];
            dti1.DropDownButtonDisplayMode = DropDownButtonDisplayMode.Always;

            Binding dtiValueBinding = new Binding();

            dtiValueBinding.Source    = DataContext;
            dtiValueBinding.Path      = new System.Windows.PropertyPath("Activity.Start");
            dtiValueBinding.Converter = new ActivityUtcToLocalTimeConverter();
            dti1.SetBinding(XamDateTimeInput.ValueProperty, dtiValueBinding);

            Grid.SetRow(dti1, 3);
            Grid.SetColumn(dti1, 1);

            _grid.Children.Add(dti1);

            XamDateTimeInput dti2 = new XamDateTimeInput();

            dti2.Margin = new System.Windows.Thickness(2, 4, 2, 4);
            dti2.DropDownButtonStyle       = (Style)Resources["DropDownButtonStyle"];
            dti2.DropDownButtonDisplayMode = DropDownButtonDisplayMode.Always;

            Binding dtiValueBinding2 = new Binding();

            dtiValueBinding2.Source    = DataContext;
            dtiValueBinding2.Path      = new System.Windows.PropertyPath("Activity.End");
            dtiValueBinding2.Converter = new ActivityUtcToLocalTimeConverter();
            dti2.SetBinding(XamDateTimeInput.ValueProperty, dtiValueBinding2);

            Grid.SetRow(dti2, 4);
            Grid.SetColumn(dti2, 1);

            _grid.Children.Add(dti2);

            //RichTextEditor
            RichTextEditor      = new XamRichTextEditor();
            RichTextEditor.Name = "_rte";
            RichTextEditor.AllowDocumentViewSplitting = false;
            //rte.ClipboardSerializationProviders.Add(new RtfSerializationProvider());

            RtfDocumentAdapter docAdapter = new RtfDocumentAdapter();

            docAdapter.RefreshTrigger = Infragistics.Documents.RichText.Serialization.RichTextRefreshTrigger.ContentChanged;

            Binding docBinding = new Binding();

            docBinding.Source = RichTextEditor;
            docBinding.Path   = new System.Windows.PropertyPath("Document");

            docAdapter.SetBinding(RtfDocumentAdapter.DocumentProperty, docBinding);

            Binding valueBinding = new Binding();

            valueBinding.Source = DataContext;
            valueBinding.Path   = new System.Windows.PropertyPath("Activity.Description");

            docAdapter.SetBinding(RtfDocumentAdapter.ValueProperty, valueBinding);

            _rtePlaceholder.Children.Add(docAdapter);
            _rtePlaceholder.Children.Add(RichTextEditor);
        }
        public MeetingView()
        {
            InitializeComponent();

            //ComboEditors
            XamComboEditor cbo1 = new XamComboEditor();

            cbo1.Margin                    = new System.Windows.Thickness(2);
            cbo1.VerticalAlignment         = System.Windows.VerticalAlignment.Center;
            cbo1.AllowMultipleSelection    = true;
            cbo1.MultiSelectValueDelimiter = ';';
            cbo1.AutoComplete              = true;
            cbo1.DisplayMemberPath         = "Email";
            cbo1.SelectedValuePath         = "Email";
            cbo1.Margin                    = new System.Windows.Thickness(2, 4, 2, 4);

            Binding itemsSourceBinding = new Binding();

            itemsSourceBinding.Source = DataContext;
            itemsSourceBinding.Path   = new System.Windows.PropertyPath("Contacts");
            cbo1.SetBinding(XamComboEditor.ItemsSourceProperty, itemsSourceBinding);

            Binding selectedValuesBinding = new Binding();

            selectedValuesBinding.Source = DataContext;
            selectedValuesBinding.Path   = new System.Windows.PropertyPath("Activity.Metadata[To]");
            selectedValuesBinding.Mode   = BindingMode.TwoWay;
            selectedValuesBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            selectedValuesBinding.Converter           = new ObservableCollectionToArrayConverter();
            cbo1.SetBinding(XamComboEditor.SelectedValuesProperty, selectedValuesBinding);

            Grid.SetColumnSpan(cbo1, 10);
            Grid.SetRow(cbo1, 0);
            Grid.SetColumn(cbo1, 2);

            _grid.Children.Add(cbo1);

            //date/time inputs
            XamDateTimeInput dti1 = new XamDateTimeInput();

            dti1.Margin = new System.Windows.Thickness(2, 4, 2, 4);
            dti1.DropDownButtonStyle       = (Style)Resources["DropDownButtonStyle"];
            dti1.DropDownButtonDisplayMode = DropDownButtonDisplayMode.Always;

            Binding dtiValueBinding = new Binding();

            dtiValueBinding.Source    = DataContext;
            dtiValueBinding.Path      = new System.Windows.PropertyPath("Activity.Start");
            dtiValueBinding.Converter = new ActivityUtcToLocalTimeConverter();
            dti1.SetBinding(XamDateTimeInput.ValueProperty, dtiValueBinding);

            Grid.SetRow(dti1, 3);
            Grid.SetColumn(dti1, 2);

            _grid.Children.Add(dti1);

            XamDateTimeInput dti2 = new XamDateTimeInput();

            dti2.Margin = new System.Windows.Thickness(2, 4, 2, 4);
            dti2.DropDownButtonStyle       = (Style)Resources["DropDownButtonStyle"];
            dti2.DropDownButtonDisplayMode = DropDownButtonDisplayMode.Always;

            Binding dtiValueBinding2 = new Binding();

            dtiValueBinding2.Source    = DataContext;
            dtiValueBinding2.Path      = new System.Windows.PropertyPath("Activity.End");
            dtiValueBinding2.Converter = new ActivityUtcToLocalTimeConverter();
            dti2.SetBinding(XamDateTimeInput.ValueProperty, dtiValueBinding2);

            Grid.SetRow(dti2, 4);
            Grid.SetColumn(dti2, 2);

            _grid.Children.Add(dti2);


            //RichTextEditor
            RichTextEditor      = new XamRichTextEditor();
            RichTextEditor.Name = "_rte";
            RichTextEditor.AllowDocumentViewSplitting = false;
            //rte.ClipboardSerializationProviders.Add(new RtfSerializationProvider());

            RtfDocumentAdapter docAdapter = new RtfDocumentAdapter();

            docAdapter.RefreshTrigger = Infragistics.Documents.RichText.Serialization.RichTextRefreshTrigger.ContentChanged;

            Binding docBinding = new Binding();

            docBinding.Source = RichTextEditor;
            docBinding.Path   = new System.Windows.PropertyPath("Document");

            docAdapter.SetBinding(RtfDocumentAdapter.DocumentProperty, docBinding);

            Binding valueBinding = new Binding();

            valueBinding.Source = DataContext;
            valueBinding.Path   = new System.Windows.PropertyPath("Activity.Description");

            docAdapter.SetBinding(RtfDocumentAdapter.ValueProperty, valueBinding);

            _rtePlaceholder.Children.Add(docAdapter);
            _rtePlaceholder.Children.Add(RichTextEditor);
        }
 public static string GetInsertRtfContent(XamRichTextEditor editor)
 {
     return(editor.GetValue(InsertRtfContentProperty) as string);
 }
 public static void SetInsertRtfContent(XamRichTextEditor editor, object value)
 {
     editor.SetValue(InsertRtfContentProperty, value);
 }