blob: b32ebf22474e4b431c637c5b1e5ccee3b2dd1039 (
plain)
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
63
64
65
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Diagnostics;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;
using System.Windows.Controls;
using Tango.Scripting.Editors.Utils;
namespace Tango.Scripting.Editors
{
/// <summary>
/// Exposes <see cref="TextEditor"/> to automation.
/// </summary>
public class TextEditorAutomationPeer : FrameworkElementAutomationPeer, IValueProvider
{
/// <summary>
/// Creates a new TextEditorAutomationPeer instance.
/// </summary>
public TextEditorAutomationPeer(TextEditor owner) : base(owner)
{
Debug.WriteLine("TextEditorAutomationPeer was created");
}
private TextEditor TextEditor {
get { return (TextEditor)base.Owner; }
}
void IValueProvider.SetValue(string value)
{
this.TextEditor.Text = value;
}
string IValueProvider.Value {
get { return this.TextEditor.Text; }
}
bool IValueProvider.IsReadOnly {
get { return this.TextEditor.IsReadOnly; }
}
/// <inheritdoc/>
public override object GetPattern(PatternInterface patternInterface)
{
if (patternInterface == PatternInterface.Value)
return this;
if (patternInterface == PatternInterface.Scroll) {
ScrollViewer scrollViewer = this.TextEditor.ScrollViewer;
if (scrollViewer != null)
return UIElementAutomationPeer.CreatePeerForElement(scrollViewer);
}
return base.GetPattern(patternInterface);
}
internal void RaiseIsReadOnlyChanged(bool oldValue, bool newValue)
{
RaisePropertyChangedEvent(ValuePatternIdentifiers.IsReadOnlyProperty, Boxes.Box(oldValue), Boxes.Box(newValue));
}
}
}
|