Skip to content

Commit c7894bb

Browse files
committed
add RichSuggestBox to repo
1 parent 8e2b3af commit c7894bb

11 files changed

+953
-0
lines changed

Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,21 @@
5959
<None Include="$(OutDir)\Design\$(MSBuildProjectName).Design*.dll;$(OutDir)\Design\$(MSBuildProjectName).Design*.pdb" Pack="true" PackagePath="lib\$(TargetFramework)\Design" />
6060
</ItemGroup>
6161

62+
<ItemGroup>
63+
<Page Remove="RichSuggestBox\RichSuggestBox.xaml" />
64+
</ItemGroup>
65+
6266
<ItemGroup>
6367
<PRIResource Include="Strings\en-us\Resources.resw" />
6468
</ItemGroup>
6569

70+
<ItemGroup>
71+
<None Update="RichSuggestBox\RichSuggestBox.xaml">
72+
<SubType>Designer</SubType>
73+
<Generator>MSBuild:Compile</Generator>
74+
</None>
75+
</ItemGroup>
76+
6677
<!-- https://weblogs.asp.net/rweigelt/disable-warnings-in-generated-c-files-of-uwp-app -->
6778
<Target Name="PragmaWarningDisablePrefixer" AfterTargets="MarkupCompilePass2">
6879
<ItemGroup>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Windows.UI.Xaml.Controls;
2+
3+
namespace Microsoft.Toolkit.Uwp.UI.Controls
4+
{
5+
internal class PlainTextCommandBarFlyout : TextCommandBarFlyout
6+
{
7+
public PlainTextCommandBarFlyout()
8+
{
9+
Opening += (sender, o) =>
10+
{
11+
PrimaryCommands.Clear();
12+
13+
// TODO: Limit Pasting to plain-text only
14+
};
15+
}
16+
}
17+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Windows.Foundation;
2+
using Windows.UI.Xaml;
3+
using Windows.UI.Xaml.Controls;
4+
5+
namespace Microsoft.Toolkit.Uwp.UI.Controls
6+
{
7+
public partial class RichSuggestBox
8+
{
9+
public event TypedEventHandler<RichSuggestBox, SuggestionsRequestedEventArgs> SuggestionsRequested;
10+
11+
public event TypedEventHandler<RichSuggestBox, SuggestionChosenEventArgs> SuggestionChosen;
12+
13+
public event TypedEventHandler<RichEditBox, RoutedEventArgs> TextChanged;
14+
}
15+
}
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
using System.Collections.ObjectModel;
2+
using Windows.UI.Text;
3+
using Windows.UI.Xaml;
4+
using Windows.UI.Xaml.Controls;
5+
using Windows.UI.Xaml.Media;
6+
7+
namespace Microsoft.Toolkit.Uwp.UI.Controls
8+
{
9+
public partial class RichSuggestBox
10+
{
11+
public static readonly DependencyProperty PlaceholderTextProperty =
12+
DependencyProperty.Register(
13+
nameof(PlaceholderText),
14+
typeof(string),
15+
typeof(RichSuggestBox),
16+
new PropertyMetadata(string.Empty));
17+
18+
public static readonly DependencyProperty RichEditBoxStyleProperty =
19+
DependencyProperty.Register(
20+
nameof(RichEditBoxStyle),
21+
typeof(Style),
22+
typeof(RichSuggestBox),
23+
new PropertyMetadata(null));
24+
25+
public static readonly DependencyProperty HeaderProperty =
26+
DependencyProperty.Register(
27+
nameof(Header),
28+
typeof(object),
29+
typeof(RichSuggestBox),
30+
new PropertyMetadata(null));
31+
32+
public static readonly DependencyProperty DescriptionProperty =
33+
DependencyProperty.Register(
34+
nameof(Description),
35+
typeof(object),
36+
typeof(RichSuggestBox),
37+
new PropertyMetadata(null));
38+
39+
public static readonly DependencyProperty TextWrappingProperty =
40+
DependencyProperty.Register(
41+
nameof(TextWrapping),
42+
typeof(TextWrapping),
43+
typeof(RichSuggestBox),
44+
new PropertyMetadata(TextWrapping.NoWrap));
45+
46+
public static readonly DependencyProperty ClipboardCopyFormatProperty =
47+
DependencyProperty.Register(
48+
nameof(ClipboardCopyFormat),
49+
typeof(RichEditClipboardFormat),
50+
typeof(RichSuggestBox),
51+
new PropertyMetadata(RichEditClipboardFormat.PlainText));
52+
53+
public static readonly DependencyProperty SuggestionBackgroundProperty =
54+
DependencyProperty.Register(
55+
nameof(SuggestionBackground),
56+
typeof(SolidColorBrush),
57+
typeof(RichSuggestBox),
58+
new PropertyMetadata(null));
59+
60+
public static readonly DependencyProperty SuggestionForegroundProperty =
61+
DependencyProperty.Register(
62+
nameof(SuggestionForeground),
63+
typeof(SolidColorBrush),
64+
typeof(RichSuggestBox),
65+
new PropertyMetadata(null));
66+
67+
public static readonly DependencyProperty PrefixesProperty =
68+
DependencyProperty.Register(
69+
nameof(Prefixes),
70+
typeof(string),
71+
typeof(RichSuggestBox),
72+
new PropertyMetadata("@", OnPrefixesChanged));
73+
74+
public string PlaceholderText
75+
{
76+
get => (string)GetValue(PlaceholderTextProperty);
77+
set => SetValue(PlaceholderTextProperty, value);
78+
}
79+
80+
public Style RichEditBoxStyle
81+
{
82+
get => (Style)GetValue(RichEditBoxStyleProperty);
83+
set => SetValue(RichEditBoxStyleProperty, value);
84+
}
85+
86+
public object Header
87+
{
88+
get => GetValue(HeaderProperty);
89+
set => SetValue(HeaderProperty, value);
90+
}
91+
92+
public object Description
93+
{
94+
get => GetValue(DescriptionProperty);
95+
set => SetValue(DescriptionProperty, value);
96+
}
97+
98+
public TextWrapping TextWrapping
99+
{
100+
get => (TextWrapping)GetValue(TextWrappingProperty);
101+
set => SetValue(TextWrappingProperty, value);
102+
}
103+
104+
public RichEditClipboardFormat ClipboardCopyFormat
105+
{
106+
get => (RichEditClipboardFormat)GetValue(ClipboardCopyFormatProperty);
107+
set => SetValue(ClipboardCopyFormatProperty, value);
108+
}
109+
110+
public SolidColorBrush SuggestionBackground
111+
{
112+
get => (SolidColorBrush)GetValue(SuggestionBackgroundProperty);
113+
set => SetValue(SuggestionBackgroundProperty, value);
114+
}
115+
116+
public SolidColorBrush SuggestionForeground
117+
{
118+
get => (SolidColorBrush)GetValue(SuggestionForegroundProperty);
119+
set => SetValue(SuggestionForegroundProperty, value);
120+
}
121+
122+
public string Prefixes
123+
{
124+
get => (string)GetValue(PrefixesProperty);
125+
set => SetValue(PrefixesProperty, value);
126+
}
127+
128+
/// <summary>
129+
/// Gets object used for lock
130+
/// </summary>
131+
protected object LockObj { get; }
132+
133+
public RichEditTextDocument TextDocument => _richEditBox?.TextDocument;
134+
135+
public ReadOnlyObservableCollection<SuggestionInfo> Tokens { get; }
136+
}
137+
}

0 commit comments

Comments
 (0)