/
Index.razor
58 lines (53 loc) · 1.74 KB
/
Index.razor
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
@page "/"
<style>
.my-style {
max-width: 657px;
width: 100%;
}
</style>
<DxFormLayout>
<DxFormLayoutItem ColSpanMd="12" Caption="Select the language of the document to open:">
<DxComboBox Data="@Cultures" Value="@Value" ValueChanged="@((string culture) => SelectedCultureChanged(culture))" CssClass="my-style"/>
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="12">
<DxRichEdit @ref="richEdit" CheckSpelling=true DocumentCulture=@documentCulture />
</DxFormLayoutItem>
</DxFormLayout>
@code {
static IEnumerable<string> Cultures = new List<string>() {
"English",
"French",
"German",
};
DxRichEdit richEdit;
string documentCulture = "en-US";
string Value = Cultures.First();
protected override async Task OnAfterRenderAsync(bool firstRender) {
if (firstRender)
try {
await InitializeDocument();
}
catch (TaskCanceledException) { }
await base.OnAfterRenderAsync(firstRender);
}
async Task InitializeDocument() {
await richEdit.LoadDocumentAsync("Data/English.docx");
}
async Task SelectedCultureChanged(string culture) {
Value = culture;
switch(Value) {
case "French":
await richEdit.LoadDocumentAsync("Data/French.docx");
documentCulture = "fr-FR";
break;
case "German":
await richEdit.LoadDocumentAsync("Data/German.docx");
documentCulture = "de-DE";
break;
default:
await richEdit.LoadDocumentAsync("Data/English.docx");
documentCulture = "en-US";
break;
}
}
}