Compare commits
No commits in common. "16e364b133ebbc9661e9a409fbadc4330ca0497f" and "808299c61b734f319091493d83073db414c51958" have entirely different histories.
16e364b133
...
808299c61b
14 changed files with 30 additions and 160 deletions
|
@ -10,7 +10,6 @@ namespace CCharLearn
|
|||
{
|
||||
public class Program
|
||||
{
|
||||
|
||||
public static int CCharsLeft = 0;
|
||||
public static Action UpdateUiEvent;
|
||||
|
||||
|
@ -25,7 +24,7 @@ namespace CCharLearn
|
|||
{
|
||||
config.SnackbarConfiguration.ShowTransitionDuration = 100;
|
||||
config.SnackbarConfiguration.HideTransitionDuration = 100;
|
||||
config.SnackbarConfiguration.VisibleStateDuration = 3000;
|
||||
config.SnackbarConfiguration.VisibleStateDuration = 5000;
|
||||
config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.TopCenter;
|
||||
});
|
||||
builder.Services.AddBlazoredLocalStorage();
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<MudSelectItem T="int" Value="@i" />
|
||||
}
|
||||
</MudSelect>
|
||||
<MudContainer Class="justify-center d-flex pt-4" Style="width:300px">
|
||||
<MudContainer Class="justify-center d-flex pt-4">
|
||||
<MudButton Variant="Variant.Filled" OnClick=StartLearning Color="Color.Primary">@((!continueDataExists) ? "Start learning!" : "Start new!")</MudButton>
|
||||
<MudStack Spacing="0" Class="pa-0 pl-2 ma-0">
|
||||
@if (continueDataExists)
|
||||
|
@ -27,7 +27,7 @@
|
|||
<MudIconButton Class="pa-0 ma-0" OnClick="DeleteContinueData" Variant=Variant.Filled Color="Color.Error" Icon="@Icons.Material.Filled.Close"></MudIconButton>
|
||||
</MudStack>
|
||||
</MudContainer>
|
||||
<MudProgressLinear Class="pa-0 ma-0" Color="Color.Warning" Size="Size.Small" Value="@(((float)continueCharectersLeft/(float)chunkSize))" />
|
||||
<MudProgressLinear Class="pa-0 ma-0" Color="Color.Warning" Size="Size.Small" Value="@(((float)chunkSize/(float)continueCharectersLeft)*100)" />
|
||||
</MudStack>
|
||||
</MudButton>
|
||||
}
|
||||
|
@ -35,20 +35,14 @@
|
|||
</MudContainer>
|
||||
|
||||
<MudContainer Class="justify-center d-flex">
|
||||
<MudStack Class="pt-4 " Spacing="0">
|
||||
<MudContainer Class="pa-4">
|
||||
<MudText Typo="Typo.h6" Class="fw-bold">Modifiers:</MudText>
|
||||
<MudCheckBox Class="mr-6" @bind-Checked="@IgnoreTone" Label="Ignore pinyin tones" Color="Color.Primary"></MudCheckBox>
|
||||
<MudCheckBox Class="mr-6" @bind-Checked="@UseChangingFonts" Label="Changing fonts" Color="Color.Primary"></MudCheckBox>
|
||||
</MudContainer>
|
||||
</MudStack>
|
||||
<MudCheckBox @bind-Checked="@IsEasyMode" Label="Easy mode" Color="Color.Primary"></MudCheckBox>
|
||||
</MudContainer>
|
||||
|
||||
<MudContainer Class="pt-4 justify-center d-flex">
|
||||
<MudContainer Class="pt-16 justify-center d-flex">
|
||||
@if (Charecters != null)
|
||||
{
|
||||
<MudPaper Class="overflow-scroll rounded-lg" Style="height: 40vh;" Elevation="1">
|
||||
<MudDataGrid Style="" SortMode="SortMode.None" Height="500" FixedHeader=true Items="@Charecters" Breakpoint="Breakpoint.None">
|
||||
<MudPaper Class="overflow-scroll rounded-0" Style="height: 50vh;" Elevation="1">
|
||||
<MudDataGrid FixedHeader=true Items="@Charecters">
|
||||
<Columns>
|
||||
<PropertyColumn Property="x => x.charcter" Title="CChar" />
|
||||
<PropertyColumn Property="x => x.pinyin" Title="Pinyin" />
|
||||
|
@ -96,30 +90,18 @@
|
|||
bool continueDataExists = false;
|
||||
int continueCharectersLeft = -1;
|
||||
|
||||
private bool ignoreTone;
|
||||
private bool isEasyMode;
|
||||
|
||||
public bool IgnoreTone
|
||||
public bool IsEasyMode
|
||||
{
|
||||
get { return ignoreTone; }
|
||||
get { return isEasyMode; }
|
||||
set
|
||||
{
|
||||
ignoreTone = value;
|
||||
SetIgnoreTone();
|
||||
isEasyMode = value;
|
||||
SetEasyMode();
|
||||
}
|
||||
}
|
||||
|
||||
private bool useChangingFonts;
|
||||
|
||||
public bool UseChangingFonts
|
||||
{
|
||||
get { return useChangingFonts; }
|
||||
set
|
||||
{
|
||||
useChangingFonts = value;
|
||||
SetChangingFonts();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected async override Task OnInitializedAsync()
|
||||
|
@ -127,8 +109,6 @@
|
|||
if (await localStorage.ContainKeyAsync("Normalized_chunk_001.json"))
|
||||
isSavedLocally = true;
|
||||
|
||||
continueDataExists = await localStorage.ContainKeyAsync("ContinueData");
|
||||
|
||||
SelectedChunk();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
@ -171,14 +151,9 @@
|
|||
StateHasChanged();
|
||||
}
|
||||
|
||||
async void SetIgnoreTone()
|
||||
async void SetEasyMode()
|
||||
{
|
||||
await localStorage.SetItemAsync("IgnoreTone", ignoreTone);
|
||||
}
|
||||
|
||||
async void SetChangingFonts()
|
||||
{
|
||||
await localStorage.SetItemAsync("ChangingFonts", UseChangingFonts);
|
||||
await localStorage.SetItemAsync("EasyMode", isEasyMode);
|
||||
}
|
||||
|
||||
async Task LoadAllChunksIntoLocalStorage()
|
||||
|
@ -230,7 +205,7 @@
|
|||
{
|
||||
if (firstRender)
|
||||
{
|
||||
|
||||
continueDataExists = await localStorage.ContainKeyAsync("ContinueData");
|
||||
}
|
||||
|
||||
if (continueDataExists)
|
||||
|
@ -238,14 +213,9 @@
|
|||
continueCharectersLeft = await localStorage.GetItemAsync<int>("ContinueCharectersLeft");
|
||||
}
|
||||
|
||||
if (await localStorage.ContainKeyAsync("IgnoreTone"))
|
||||
if (await localStorage.ContainKeyAsync("EasyMode"))
|
||||
{
|
||||
ignoreTone = await localStorage.GetItemAsync<bool>("IgnoreTone");
|
||||
}
|
||||
|
||||
if (await localStorage.ContainKeyAsync("ChangingFonts"))
|
||||
{
|
||||
UseChangingFonts = await localStorage.GetItemAsync<bool>("ChangingFonts");
|
||||
isEasyMode = await localStorage.GetItemAsync<bool>("EasyMode");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -42,14 +42,7 @@
|
|||
<MudContainer Style="width: 100px; height: 100px" Class="pa-8 ma-4 d-flex justify-center align-center">
|
||||
@if (!Answers.Any(x => x == null))
|
||||
{
|
||||
if (useChagingFonts)
|
||||
{
|
||||
<p class="LargeCharecter" style="font-family: '@currentFont';">@GetDisplayChar()</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="LargeCharecter">@GetDisplayChar()</p>
|
||||
}
|
||||
<p class="LargeCharecter">@GetDisplayChar()</p>
|
||||
}
|
||||
</MudContainer>
|
||||
</MudPaper>
|
||||
|
@ -62,7 +55,7 @@
|
|||
@for (int i = 0; i < Answers.Length; i++)
|
||||
{
|
||||
int buttonIndex = i;
|
||||
<MudButton Class="PinyinButtons ma-3"
|
||||
<MudButton Class="PinyinButtons ma-3"
|
||||
Variant="Variant.Outlined"
|
||||
@onclick="() => SelectButton(buttonIndex)"
|
||||
Color="@(Answers[buttonIndex].isSelected ? Color.Primary : Color.Default)">
|
||||
|
@ -87,39 +80,21 @@
|
|||
{
|
||||
<MudButton Disabled="@(!(Answers.Any(x=>x.isSelected)))" OnClick="Submit" Class="px-8 py-3" Variant="Variant.Filled" Size="Size.Large" Color="Color.Success" Style="font-size: 20px;"> Submit</MudButton>
|
||||
}
|
||||
@if (ignoreTone)
|
||||
@if (isEasyMode)
|
||||
{
|
||||
<MudText Typo="Typo.caption">• Easy mode enabled</MudText>
|
||||
}
|
||||
@if (useChagingFonts)
|
||||
{
|
||||
<MudText Typo="Typo.caption">• Changing fonts enabled</MudText>
|
||||
}
|
||||
</MudStack>
|
||||
</MudContainer>
|
||||
</MudStack>
|
||||
</MudContainer>
|
||||
|
||||
@*Used to load all fonts into memory instead of loading from http each time*@
|
||||
@if (useChagingFonts && !hasLoadedFontsToMemory)
|
||||
{
|
||||
@for (int i = 0; i < extraFonts.Length; i++)
|
||||
{
|
||||
<p style="font-family: '@extraFonts[i]';">i</p>
|
||||
}
|
||||
}
|
||||
|
||||
@code {
|
||||
bool isSavedLocally = false;
|
||||
bool ignoreTone = false;
|
||||
bool isEasyMode = false;
|
||||
|
||||
bool selectedCorrect = false;
|
||||
|
||||
bool useChagingFonts = false;
|
||||
string? currentFont = null;
|
||||
string[] extraFonts = { "HanyiSentyRubber", "mini-jian-caocuyuan", "myoungheihk", "UnboundedSans", "wt064", "XiaolaiSC-Regular", "chinese1", "chinese2" };
|
||||
bool hasLoadedFontsToMemory = false;
|
||||
|
||||
public Answer[] Answers = new Answer[4];
|
||||
public void SelectButton(int selectedIndex)
|
||||
{
|
||||
|
@ -154,14 +129,9 @@
|
|||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Program.UpdateUiEvent += OnUiUpdate;
|
||||
if (await localStorage.ContainKeyAsync("IgnoreTone"))
|
||||
if (await localStorage.ContainKeyAsync("EasyMode"))
|
||||
{
|
||||
ignoreTone = await localStorage.GetItemAsync<bool>("IgnoreTone");
|
||||
}
|
||||
|
||||
if (await localStorage.ContainKeyAsync("ChangingFonts"))
|
||||
{
|
||||
useChagingFonts = await localStorage.GetItemAsync<bool>("ChangingFonts");
|
||||
isEasyMode = await localStorage.GetItemAsync<bool>("EasyMode");
|
||||
}
|
||||
|
||||
bool continueLast =
|
||||
|
@ -178,21 +148,13 @@
|
|||
await LoadCharectersFromChunk();
|
||||
}
|
||||
|
||||
if (ignoreTone)
|
||||
if (isEasyMode)
|
||||
DontSkipTheseCChar.ForEach(x => x.cchar.pinyin = x.cchar.pinyin.Unidecode());
|
||||
|
||||
if (useChagingFonts)
|
||||
{
|
||||
ChangeFont();
|
||||
}
|
||||
|
||||
Program.CCharsLeft = DontSkipTheseCChar.Count;
|
||||
Program.InvokeUiUpdate();
|
||||
|
||||
GenerateQuestion();
|
||||
|
||||
await Task.Delay(100);
|
||||
hasLoadedFontsToMemory = true;
|
||||
}
|
||||
|
||||
async Task LoadCharectersFromChunk()
|
||||
|
@ -272,12 +234,6 @@
|
|||
navigator.NavigateTo("");
|
||||
}
|
||||
|
||||
async void ChangeFont()
|
||||
{
|
||||
int randomIndex = Random.Shared.Next(0, extraFonts.Length);
|
||||
currentFont = extraFonts[randomIndex];
|
||||
}
|
||||
|
||||
async void Submit()
|
||||
{
|
||||
bool isCorrect = Answers.Any(x => x.isCorrect && x.isSelected);
|
||||
|
@ -288,7 +244,6 @@
|
|||
{
|
||||
Snackbar.Add($"<b>Definition:</b> {correctCChar.definition}", Severity.Success, config => { config.VisibleStateDuration = 1000; });
|
||||
increaseCCharStat(GetCorrectCCharStats(), StatType.NumOfCorrects);
|
||||
ChangeFont();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -317,18 +272,7 @@
|
|||
|
||||
await SaveContinueData();
|
||||
|
||||
if (isCorrect)
|
||||
{
|
||||
GenerateQuestion();
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var anwser in Answers)
|
||||
{
|
||||
anwser.isSelected = false;
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
GenerateQuestion();
|
||||
}
|
||||
|
||||
async Task SaveContinueData()
|
||||
|
@ -419,7 +363,7 @@
|
|||
|
||||
public void ShowMeaning()
|
||||
{
|
||||
Snackbar.Add($"<b>Definition:</b> {GetCorrectCChar().definition}", Severity.Info, conf => conf.VisibleStateDuration = 1000);
|
||||
Snackbar.Add($"<b>Definition:</b> {GetCorrectCChar().definition}", Severity.Info);
|
||||
}
|
||||
|
||||
public void ShowPinyin()
|
||||
|
@ -434,7 +378,7 @@
|
|||
if (firstRender)
|
||||
{
|
||||
// Gets chinese voice on windows or iphone.
|
||||
this.SpeechVoice = ((IEnumerable<SpeechSynthesisVoice>)(await this.SpeechSynthesis.GetVoicesAsync())).FirstOrDefault(v => v.Name.Contains("Yaoyao") || v.Name.Contains("Ting-Ting") || v.Name.ToLower().Contains("cn"));
|
||||
this.SpeechVoice = ((IEnumerable<SpeechSynthesisVoice>)(await this.SpeechSynthesis.GetVoicesAsync())).FirstOrDefault(v => v.Name.Contains("Yaoyao") || v.Name.Contains("Ting-Ting"));
|
||||
this.StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
@ -443,7 +387,7 @@
|
|||
{
|
||||
if (SpeechVoice == null)
|
||||
{
|
||||
Snackbar.Add("Couldn't play sound.\nLikely reason: Chinese speech not installed", Severity.Error);
|
||||
Snackbar.Add("Couldn't play sound", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
|
|
@ -96,46 +96,4 @@ a, .btn-link {
|
|||
}
|
||||
.loading-progress-text:after {
|
||||
content: var(--blazor-load-percentage-text, "Loading");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'HanyiSentyRubber';
|
||||
src: url(../fonts/HanyiSentyRubber.ttf) format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'mini-jian-caocuyuan';
|
||||
src: url(../fonts/mini-jian-caocuyuan.ttf) format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'myoungheihk';
|
||||
src: url(../fonts/myoungheihk.ttf) format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'UnboundedSans';
|
||||
src: url(../fonts/UnboundedSans.ttf) format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'wt064';
|
||||
src: url(../fonts/wt064.ttf) format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'XiaolaiSC-Regular';
|
||||
src: url(../fonts/XiaolaiSC-Regular.ttf) format('truetype');
|
||||
}
|
||||
|
||||
/*优设标题黑*/
|
||||
@font-face {
|
||||
font-family: 'chinese1';
|
||||
src: url(../fonts/chinese1.ttf) format('truetype');
|
||||
}
|
||||
|
||||
/*站酷仓耳渔阳体*/
|
||||
@font-face {
|
||||
font-family: 'chinese2';
|
||||
src: url(../fonts/chinese2.ttf) format('truetype');
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -31,7 +31,7 @@
|
|||
</div>
|
||||
<script src="_framework/blazor.webassembly.js"></script>
|
||||
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
|
||||
<!--<script>navigator.serviceWorker.register('service-worker.js');</script>-->
|
||||
<script>navigator.serviceWorker.register('service-worker.js');</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue