forked from Tewr/BlazorFileReader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDragnDropCommon.razor
60 lines (49 loc) · 1.65 KB
/
DragnDropCommon.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
@using System.IO;
@inject IFileReaderService fileReaderService
<h1>Hello, dropped files!</h1>
Welcome to your new filestreaming app.
<br />
This demo reads files that was dropped in without doing anything particular with it.
<br />
<br />
<div class="btn-group btn-group-toggle">
@foreach (var item in possibleOptions)
{
<label class="@defaultClasses @(item.IsActive() ? "active":"")" @key="item.Id">
<input type="radio" name="options" id="@item.Id" autocomplete="off" checked="@(item.IsActive() ? "checked":"")" @onclick="_ => OnChange(item.Id)"> @item.Description
</label>
}
</div>
<br />
<br />
@if (currentOption == "DragnDropDivCommon")
{
<DragnDropDivCommon />
}
else if (currentOption == "DragnDropInputCommon")
{
<DragnDropInputCommon />
}
@code {
private class PossibleOption { public string Id { get; set; } public string Description { get; set; } public Func<bool> IsActive { get; set; } }
List<PossibleOption> possibleOptions = new List<PossibleOption> {
new PossibleOption { Id = "DragnDropDivCommon", Description= "Drag and Drop on Element" },
new PossibleOption { Id = "DragnDropInputCommon", Description= "Drag and Drop on Hidden input" },
};
string defaultClasses = "btn btn-primary";
string currentOption;
protected override void OnInitialized()
{
currentOption = possibleOptions.First().Id;
foreach (var item in possibleOptions)
{
item.IsActive = () => currentOption == item.Id;
}
base.OnInitialized();
}
public void OnChange(string id)
{
currentOption = id;
StateHasChanged();
}
}