Beispiel #1
0
 /// <summary>
 /// Constructor of a RichTextBox style cell. You must st a valid Model to use this type of cell with this constructor.
 /// </summary>
 public RichTextBox()
 {
     View = Views.RichTextBox.Default;
     Model.AddModel(new Models.RichTextBox());
     AddController(Controllers.RichTextBox.Default);
     Editor = new Editors.RichTextBox();
 }
Beispiel #2
0
 /// <summary>
 /// Constructor of a RichTextBox style cell. You must st a valid Model to use this type of cell with this constructor.
 /// </summary>
 public RichTextBox()
 {
     View = Views.RichTextBox.Default;
     Model.AddModel(new Models.RichTextBox());
     AddController(Controllers.RichTextBox.Default);
     Editor = new Editors.RichTextBox();
 }
        /// <summary>
        /// If ValueEventArgs is a font, use it to change SelectionFont
        /// If String, assign it as rtf
        /// If Int32, assign it as offset
        /// If HorizontalAlignment, assign as SelectionAlignment
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void OnValueChanging(CellContext sender, ValueChangeEventArgs e)
        {
            base.OnValueChanging(sender, e);

            // only check if event args is of known type if event is not of type rich text
            if (!(e.NewValue is DevAge.Windows.Forms.RichText))
            {
                Editors.RichTextBox richEditor = (Editors.RichTextBox)sender.Cell.Editor;
                DevAge.Windows.Forms.DevAgeRichTextBox richTextBox = richEditor.Control;

                // if editor is not open, assign value and select all text
                if (sender.Cell.Editor.EditCell == null)
                {
                    richTextBox.Value = sender.Value as DevAge.Windows.Forms.RichText;
                    richTextBox.SelectAll();
                }

                if (e.NewValue is Font)
                {
                    richTextBox.SelectionFont = (Font)e.NewValue;
                }
                else if (e.NewValue is Color)
                {
                    richTextBox.SelectionColor = (Color)e.NewValue;
                }
                else if (e.NewValue is Int32)
                {
                    richTextBox.SelectionCharOffset = (int)e.NewValue;
                }
                else if (e.NewValue is HorizontalAlignment)
                {
                    richTextBox.SelectionAlignment = (HorizontalAlignment)e.NewValue;
                }
                else if (e.NewValue is DevAge.Windows.Forms.EffectType)
                {
                    richTextBox.SelectionEffect = (DevAge.Windows.Forms.EffectType)e.NewValue;
                }

                // if editor is not open, use changed value for cell
                if (sender.Cell.Editor.EditCell == null)
                {
                    sender.Value = richTextBox.Value;
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Get real RichTextBox Control
        /// </summary>
        /// <param name="cellContext"></param>
        /// <returns></returns>
        private DevAge.Windows.Forms.DevAgeRichTextBox GetRichTextBoxControl(CellContext cellContext)
        {
            if (cellContext.Cell != null)
            {
                Editors.RichTextBox editorRichTextBox = cellContext.Cell.Editor as Editors.RichTextBox;

                // if editor is not active, value needs to be assigned to prevent
                // using an old editor of another cell
                // as an editor can be used for more than one cell
                if (editorRichTextBox.EditCell == null)
                {
                    editorRichTextBox.Control.Value = cellContext.Value as DevAge.Windows.Forms.RichText;
                }

                return(editorRichTextBox.Control);
            }

            return(null);
        }