-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathRequestExtensions.cs
64 lines (48 loc) · 2.92 KB
/
RequestExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using Avalonia;
using Avalonia.Controls;
using System;
using System.Diagnostics;
namespace AvRichTextBox;
public static class RequestExtensions
{
//public static readonly AttachedProperty<FlowDocument> FlowDocumentProperty = AvaloniaProperty.RegisterAttached<RichTextBox, FlowDocument>("FlowDocument", typeof(RequestExtensions));
//public static void SetFlowDocument(AvaloniaObject element, FlowDocument value) => element.SetValue(FlowDocumentProperty, value);
//public static FlowDocument GetFlowDocument(AvaloniaObject element) => (FlowDocument)element.GetValue(FlowDocumentProperty);
public static readonly AttachedProperty<bool> TextBoxFocusRequestedProperty = AvaloniaProperty.RegisterAttached<EditableParagraph, bool>("TextBoxFocusRequested", typeof(RequestExtensions));
public static void SetTextBoxFocusRequested(AvaloniaObject element, bool value) => element.SetValue(TextBoxFocusRequestedProperty, value);
public static bool GetTextBoxFocusRequested(AvaloniaObject element) => (bool)element.GetValue(TextBoxFocusRequestedProperty);
public static readonly AttachedProperty<bool> IsInlineUpdateRequestedProperty = AvaloniaProperty.RegisterAttached<EditableParagraph, bool>("IsInlineUpdateRequested", typeof(RequestExtensions));
public static void SetIsInlineUpdateRequested(AvaloniaObject element, bool value) => element.SetValue(IsInlineUpdateRequestedProperty, value);
public static bool GetIsInlineUpdateRequested(AvaloniaObject element) => (bool)element.GetValue(IsInlineUpdateRequestedProperty);
public static readonly AttachedProperty<bool> InvalidateVisualRequestedProperty = AvaloniaProperty.RegisterAttached<EditableParagraph, bool>("InvalidateVisualRequested", typeof(RequestExtensions));
public static void SetInvalidateVisualRequested(AvaloniaObject element, bool value) => element.SetValue(InvalidateVisualRequestedProperty, value);
public static bool GetInvalidateVisualRequested(AvaloniaObject element) => (bool)element.GetValue(InvalidateVisualRequestedProperty);
static RequestExtensions()
{
TextBoxFocusRequestedProperty.Changed.Subscribe(args =>
{
if (args.Sender is EditableParagraph edPar && (bool)args.NewValue.Value)
{
edPar.Focus();
edPar.SetValue(TextBoxFocusRequestedProperty, false);
}
});
IsInlineUpdateRequestedProperty.Changed.Subscribe(args =>
{
if (args.Sender is EditableParagraph edPar && (bool)args.NewValue.Value)
{
edPar.UpdateInlines();
edPar.SetValue(IsInlineUpdateRequestedProperty, false);
}
});
InvalidateVisualRequestedProperty.Changed.Subscribe(args =>
{
if (args.Sender is EditableParagraph edPar && (bool)args.NewValue.Value)
{
edPar.UpdateLayout();
edPar.InvalidateVisual();
edPar.SetValue(InvalidateVisualRequestedProperty, false);
}
});
}
}