Skip to content

Commit

Permalink
Added culture support
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisThe0ne committed Nov 21, 2023
1 parent 6950f01 commit bc66004
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 25 deletions.
50 changes: 28 additions & 22 deletions OnlineMatrixCalculator/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@

<PageTitle>OnlineMatrixCalculator</PageTitle>

<MudContainer MaxWidth="MaxWidth.ExtraLarge">
@*<MudContainer MaxWidth="MaxWidth.ExtraLarge">*@

<div class="d-flex flex-column">
<div class="d-flex flex-column">

<MudText>Columns:</MudText>
<MudNumericField Min="0" Max="26" Value="columns" T="int" ValueChanged="(args) => ColumnChange(args)" Variant="Variant.Outlined"></MudNumericField>
<MudText Class="mt-2">Columns:</MudText>
<MudNumericField Min="0" Max="26" Value="columns" T="int" ValueChanged="(args) => ColumnChange(args)" Variant="Variant.Outlined"></MudNumericField>

<MudText>Rows:</MudText>
<MudNumericField Min="0" Max="26" Value="rows" T="int" ValueChanged="(args) => RowChange(args)" Variant="Variant.Outlined"></MudNumericField>
<MudText Class="mt-2">Rows:</MudText>
<MudNumericField Min="0" Max="26" Value="rows" T="int" ValueChanged="(args) => RowChange(args)" Variant="Variant.Outlined"></MudNumericField>

</div>

<div class="container d-flex justify-center align-center py-3 pe-0">
<div style="overflow: scroll;">

<table style="overflow: scroll;">
<MudText Class="mt-2">Use following culture for number Input:</MudText>
<MudSelect Variant="Variant.Outlined" T="bool" @bind-Value="useUsCulture">
<MudSelectItem T="bool" Value="false">de</MudSelectItem>
<MudSelectItem T="bool" Value="true">en</MudSelectItem>
</MudSelect>
</div>
<div>
<div class="py-3 pe-0 d-flex" style="width: 100%;">
<div class="overflow-scroll d-flex">
<table class="flex-grow-1 ">
<tr>
@for (int j = 0; j < columns; j++)
{
Expand All @@ -37,30 +41,32 @@
int columnArrayIndex = columnIndex;
int rowArrayIndex = rowIndex;
<td>
<MudNumericField Value="inputValues[rowArrayIndex, columnArrayIndex]" Style="min-width: 6em;" Min="0" T="double" ValueChanged="(args) => MatrixValue_OnChanged(args, rowArrayIndex, columnArrayIndex)" Variant="Variant.Outlined"></MudNumericField>
<MudNumericField Culture="@(useUsCulture ? _us : _de)" Value="inputValues[rowArrayIndex, columnArrayIndex]" Style="min-width: 6em;" Min="0" T="double" ValueChanged="(args) => MatrixValue_OnChanged(args, rowArrayIndex, columnArrayIndex)" Variant="Variant.Outlined"></MudNumericField>
</td>
}
</tr>
}
</table>

</div>

</div>

<div class="d-flex flex-column">
<MudButton Size="Size.Large" Variant="Variant.Outlined" OnClick="Button_OnClick">Calculate</MudButton>
<MudText style="font-size: large; color: red;">@errorMsg</MudText>
</div>
<div class="d-flex flex-column">
<MudButton Size="Size.Large" Variant="Variant.Outlined" OnClick="Button_OnClick">Calculate</MudButton>
<MudText style="font-size: large; color: red;">@errorMsg</MudText>
</div>

<MudText Typo="Typo.h5">Results:</MudText>

@if (result.Count() != 0)
{
for (int x = 0; x < result.Count(); x++)
{
for (int x = 0; x < result.Count(); x++)
{
int arrayIndex = x;
<MudText style="font-size: large;">@(letters[arrayIndex] + ": " + result[arrayIndex])</MudText>
}
int arrayIndex = x;
<MudText style="font-size: large;">@(letters[arrayIndex] + ": " + result[arrayIndex])</MudText>
}
}

</MudContainer>
@*</MudContainer>*@
6 changes: 5 additions & 1 deletion OnlineMatrixCalculator/Pages/Index.razor.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
using System.Globalization;

namespace OnlineMatrixCalculator.Pages
{
public partial class Index
{
CultureInfo _de = CultureInfo.GetCultureInfo("de-DE");
CultureInfo _us = CultureInfo.GetCultureInfo("en-US");
bool useUsCulture = false;
double[,]? inputValues;
const int additionalColumns = 1;
int privateColumns = 2;
Expand Down Expand Up @@ -74,7 +79,6 @@ int totalColumns
protected override async Task OnInitializedAsync()
{
ChangeArray();

}

private void ChangeArray()
Expand Down
6 changes: 4 additions & 2 deletions OnlineMatrixCalculator/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

<div class="page">
<main>
<article class="content px-4">
@Body
<article class="content" style="height: 100vh; width: 100vw;">
<div class="px-4">
@Body
</div>
</article>
</main>
</div>
9 changes: 9 additions & 0 deletions OnlineMatrixCalculator/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,13 @@

</html>
<style>
html {
padding: 0px;
margin: 0px;
}

body {
padding: 0px;
margin: 0px;
}
</style>

0 comments on commit bc66004

Please sign in to comment.