123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using InABox.Core;
- using System.Windows;
- using System.Windows.Media;
- namespace InABox.DynamicGrid
- {
- public class RichTextEditorControl : DynamicEditorControl<string>
- {
- private RichTextEditor Editor;
- public override int DesiredHeight()
- {
- return int.MaxValue;
- }
- public override int DesiredWidth()
- {
- return int.MaxValue;
- }
- public override void SetColor(Color color)
- {
- Editor.SetColor(IsEnabled ? color : Colors.WhiteSmoke);
- }
- public override void SetEnabled(bool enabled)
- {
- Editor.Editor.IsReadOnly = !enabled;
- Editor.HideToolbar = !enabled;
- Editor.ZoomFactor = 100;
- SetColor(enabled ? Color : Colors.WhiteSmoke);
- }
- public override void SetFocus()
- {
- Editor.Focus();
- }
- protected override FrameworkElement CreateEditor()
- {
- using var profiler = new Profiler(true);
- MinHeight = 250;
- Editor = new RichTextEditor
- {
- VerticalAlignment = VerticalAlignment.Stretch,
- //VerticalContentAlignment = VerticalAlignment.Top,
- HorizontalAlignment = HorizontalAlignment.Stretch
- //VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
- //TextWrapping = TextWrapping.Wrap,
- //AcceptsReturn = true,
- };
- Editor.OnChanged += o => { CheckChanged(); };
- return Editor;
- }
- protected override string RetrieveValue()
- {
- return Editor.Text;
- }
- protected override void UpdateValue(string value)
- {
- Editor.Text = value;
- }
- }
- }
|