Skip to content

Commit 7abd125

Browse files
authored
Merge pull request #18 from AkbarAsghari/Dev
Merge Dev into Main
2 parents 248e87e + 05369d6 commit 7abd125

24 files changed

+374
-137
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace IToolKit.API.Enums.Components
2+
{
3+
public enum ImageTypeEnum
4+
{
5+
File,
6+
Base64
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace IToolKit.API.Enums.Tools.Generators
2+
{
3+
public enum QRCodeTypeEnum
4+
{
5+
Text,
6+
URL,
7+
VCard,
8+
Email,
9+
SMS,
10+
Wifi,
11+
Event
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
using QRCoder;
2+
using System.Numerics;
3+
using static QRCoder.PayloadGenerator;
4+
5+
namespace IToolKit.API.Tools.Generators
6+
{
7+
public class QRCodeTools
8+
{
9+
static QRCodeGenerator qrGenerator = new QRCodeGenerator();
10+
11+
public static string TextToBase64(string text)
12+
{
13+
return ToBase64(new TextPayload { Text = text }, new byte[] { 0, 0, 0 }, new byte[] { 255, 255, 255 });
14+
}
15+
16+
public static string ToBase64(Payload payload, byte[] darkColorRgba, byte[] lightColorRgba)
17+
{
18+
QRCodeData qrCodeData = qrGenerator.CreateQrCode(payload.ToString(), QRCodeGenerator.ECCLevel.Q);
19+
PngByteQRCode qrCode = new PngByteQRCode(qrCodeData);
20+
return Convert.ToBase64String(qrCode.GetGraphic(pixelsPerModule: 20, darkColorRgba, lightColorRgba));
21+
}
22+
23+
public class Payload
24+
{
25+
public override string ToString()
26+
{
27+
return String.Empty;
28+
}
29+
}
30+
31+
public class TextPayload : Payload
32+
{
33+
public string Text { get; set; }
34+
35+
public override string ToString()
36+
{
37+
return Text;
38+
}
39+
}
40+
41+
public class WifiPayload : Payload
42+
{
43+
public string SSID { get; set; }
44+
public string Pass { get; set; }
45+
public WiFi.Authentication Authentication { get; set; }
46+
public bool IsHidden { get; set; } = false;
47+
48+
public override string ToString()
49+
{
50+
return new WiFi(SSID, Pass, Authentication, IsHidden).ToString();
51+
}
52+
}
53+
54+
public class MailPayload : Payload
55+
{
56+
public string MailReciver { get; set; }
57+
public string Subject { get; set; }
58+
public string Message { get; set; }
59+
public override string ToString()
60+
{
61+
return new Mail(MailReciver, Subject, Message).ToString();
62+
}
63+
}
64+
public class SMSPayload : Payload
65+
{
66+
public string Number { get; set; }
67+
public string Subject { get; set; }
68+
public override string ToString()
69+
{
70+
return new SMS(Number, Subject).ToString();
71+
}
72+
}
73+
74+
public class ContactDataPayload : Payload
75+
{
76+
public ContactData.ContactOutputType ContactOutput { get; set; }
77+
public string FirstName { get; set; }
78+
public string LastName { get; set; }
79+
public string NickName { get; set; }
80+
public string Phone { get; set; }
81+
public string MobilePhone { get; set; }
82+
public string WorkPhone { get; set; }
83+
public string Email { get; set; }
84+
85+
public override string ToString()
86+
{
87+
return new ContactData(ContactOutput, FirstName, LastName, NickName, Phone, MobilePhone, WorkPhone, Email).ToString();
88+
}
89+
}
90+
91+
public class CalendarEventPayload : Payload
92+
{
93+
public string Subject { get; set; }
94+
public string Description { get; set; }
95+
public string Location { get; set; }
96+
public DateTime? Start { get; set; } = DateTime.Now;
97+
public DateTime? End { get; set; } = DateTime.Now;
98+
public bool AllDayEvent { get; set; }
99+
public override string ToString()
100+
{
101+
return new CalendarEvent(Subject, Description, Location, Start!.Value, End!.Value, AllDayEvent).ToString();
102+
}
103+
}
104+
}
105+
}

IToolKit/IToolKit/Pages/Tools/Cipthers/AES/AES.razor

-9
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,5 @@
1111
<MudSelectItem Value="CipherTypesEnum.Decrypt" />
1212
</MudSelect>
1313
</MudItem>
14-
<MudItem>
15-
<MudCheckBox T="bool" Color="Color.Primary" @bind-Checked="_IsAutoUpdate" Label="Auto Update" />
16-
</MudItem>
17-
<MudItem>
18-
@if (_IsAutoUpdate == false)
19-
{
20-
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="()=> CalcHash()">@CipherType</MudButton>
21-
}
22-
</MudItem>
2314
</MudGrid>
2415
<CustomTextField Lines="10" Variant="Variant.Outlined" Label="@($"{CipherType.ToString()}ed Text")" @bind-Value="@_AESResult" ReadOnly />

IToolKit/IToolKit/Pages/Tools/Cipthers/AES/AES.razor.cs

+2-8
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,22 @@ partial class AES
1313

1414
string _AESResult;
1515

16-
bool _IsAutoUpdate = true;
17-
18-
1916
private async Task OnCipherTypeChangeAsync(CipherTypesEnum cipherType)
2017
{
2118
CipherType = cipherType;
22-
if (_IsAutoUpdate)
23-
await CalcHash();
19+
await CalcHash();
2420
}
2521

2622
private async void OnInputChange(string value)
2723
{
2824
_InputValue = value;
29-
if (_IsAutoUpdate)
3025
await CalcHash();
3126
}
3227

3328
private async void OnSecurityValueChange(string value)
3429
{
3530
_SecurityValue = value;
36-
if (_IsAutoUpdate)
37-
await CalcHash();
31+
await CalcHash();
3832
}
3933

4034
async Task CalcHash()

IToolKit/IToolKit/Pages/Tools/EncodersDecoders/Base32TextEncoderDecoder/Base32TextEncoderDecoder.razor

-11
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,5 @@
1010
<MudSelectItem Value="EncodeDecodeTypeEnum.Decode" />
1111
</MudSelect>
1212
</MudItem>
13-
<MudItem>
14-
<MudCheckBox Color="Color.Primary" T="bool" @bind-Checked="_IsAutoUpdate" Label="Auto Update" />
15-
</MudItem>
16-
<MudItem>
17-
@if (_IsAutoUpdate == false)
18-
{
19-
<MudButton Class="mb-2" Color="Color.Primary" Variant="Variant.Filled" OnClick="()=> Calc(_CurrentValue)">
20-
@_EncodeDecodeType
21-
</MudButton>
22-
}
23-
</MudItem>
2413
</MudGrid>
2514
<CustomTextField Variant="Variant.Outlined" Lines="5" Label="Result" @bind-Value="@_Result" ReadOnly />

IToolKit/IToolKit/Pages/Tools/EncodersDecoders/Base32TextEncoderDecoder/Base32TextEncoderDecoder.razor.cs

-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public partial class Base32TextEncoderDecoder
88
EncodeDecodeTypeEnum _EncodeDecodeType = EncodeDecodeTypeEnum.Encode;
99
string _CurrentValue;
1010
string _Result;
11-
bool _IsAutoUpdate = true;
1211

1312
private void OnHashTypeChange(EncodeDecodeTypeEnum hashType)
1413
{
@@ -20,9 +19,6 @@ private void OnChangeEvent(string value)
2019
{
2120
_CurrentValue = value;
2221

23-
if (!_IsAutoUpdate)
24-
return;
25-
2622
if (String.IsNullOrEmpty(value))
2723
{
2824
_Result = value;

IToolKit/IToolKit/Pages/Tools/EncodersDecoders/Base64TextEncoderDecoder/Base64TextEncoderDecoder.razor

-11
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@
1111
<MudSelectItem Value="EncodeDecodeTypeEnum.Decode" />
1212
</MudSelect>
1313
</MudItem>
14-
<MudItem>
15-
<MudCheckBox Color="Color.Primary" T="bool" @bind-Checked="_IsAutoUpdate" Label="Auto Update" />
16-
</MudItem>
17-
<MudItem>
18-
@if (_IsAutoUpdate == false)
19-
{
20-
<MudButton Class="mb-2" Color="Color.Primary" Variant="Variant.Filled" OnClick="()=> Calc(_CurrentValue)">
21-
@_EncodeDecodeType
22-
</MudButton>
23-
}
24-
</MudItem>
2514
</MudGrid>
2615

2716
<CustomTextField Variant="Variant.Outlined" Lines="5" Label="Result" @bind-Value="@_Result" ReadOnly />

IToolKit/IToolKit/Pages/Tools/EncodersDecoders/Base64TextEncoderDecoder/Base64TextEncoderDecoder.razor.cs

-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public partial class Base64TextEncoderDecoder
88
EncodeDecodeTypeEnum _EncodeDecodeType = EncodeDecodeTypeEnum.Encode;
99
string _CurrentValue;
1010
string _Result;
11-
bool _IsAutoUpdate = true;
1211

1312
private void OnHashTypeChange(EncodeDecodeTypeEnum hashType)
1413
{
@@ -20,9 +19,6 @@ private void OnChangeEvent(string value)
2019
{
2120
_CurrentValue = value;
2221

23-
if (!_IsAutoUpdate)
24-
return;
25-
2622
if (String.IsNullOrEmpty(value))
2723
{
2824
_Result = value;

IToolKit/IToolKit/Pages/Tools/EncodersDecoders/HTML/HTML.razor

-11
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,5 @@
1010
<MudSelectItem Value="EncodeDecodeTypeEnum.Decode" />
1111
</MudSelect>
1212
</MudItem>
13-
<MudItem>
14-
<MudCheckBox Color="Color.Primary" T="bool" @bind-Checked="_IsAutoUpdate" Label="Auto Update" />
15-
</MudItem>
16-
<MudItem>
17-
@if (_IsAutoUpdate == false)
18-
{
19-
<MudButton Class="mb-2" Color="Color.Primary" Variant="Variant.Filled" OnClick="()=> Calc(_CurrentValue)">
20-
@_EncodeDecodeType
21-
</MudButton>
22-
}
23-
</MudItem>
2413
</MudGrid>
2514
<CustomTextField Variant="Variant.Outlined" Lines="5" Label="Result" @bind-Value="@_Result" ReadOnly />

IToolKit/IToolKit/Pages/Tools/EncodersDecoders/HTML/HTML.razor.cs

-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ public partial class HTML
77
EncodeDecodeTypeEnum _EncodeDecodeType = EncodeDecodeTypeEnum.Encode;
88
string _CurrentValue;
99
string _Result;
10-
bool _IsAutoUpdate = true;
1110

1211
private void OnHashTypeChange(EncodeDecodeTypeEnum hashType)
1312
{
@@ -19,9 +18,6 @@ private void OnChangeEvent(string value)
1918
{
2019
_CurrentValue = value;
2120

22-
if (!_IsAutoUpdate)
23-
return;
24-
2521
if (String.IsNullOrEmpty(value))
2622
{
2723
_Result = value;

IToolKit/IToolKit/Pages/Tools/EncodersDecoders/URL/URL.razor

-11
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,5 @@
1010
<MudSelectItem Value="EncodeDecodeTypeEnum.Decode" />
1111
</MudSelect>
1212
</MudItem>
13-
<MudItem>
14-
<MudCheckBox Color="Color.Primary" T="bool" @bind-Checked="_IsAutoUpdate" Label="Auto Update" />
15-
</MudItem>
16-
<MudItem>
17-
@if (_IsAutoUpdate == false)
18-
{
19-
<MudButton Class="mb-2" Color="Color.Primary" Variant="Variant.Filled" OnClick="()=> Calc(_CurrentValue)">
20-
@_EncodeDecodeType
21-
</MudButton>
22-
}
23-
</MudItem>
2413
</MudGrid>
2514
<CustomTextField Variant="Variant.Outlined" Lines="5" Label="Result" @bind-Value="@_Result" ReadOnly />

IToolKit/IToolKit/Pages/Tools/EncodersDecoders/URL/URL.razor.cs

-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public partial class URL
88
EncodeDecodeTypeEnum _EncodeDecodeType = EncodeDecodeTypeEnum.Encode;
99
string _CurrentValue;
1010
string _Result;
11-
bool _IsAutoUpdate = true;
1211

1312
private void OnHashTypeChange(EncodeDecodeTypeEnum hashType)
1413
{
@@ -20,9 +19,6 @@ private void OnChangeEvent(string value)
2019
{
2120
_CurrentValue = value;
2221

23-
if (!_IsAutoUpdate)
24-
return;
25-
2622
if (String.IsNullOrEmpty(value))
2723
{
2824
_Result = value;

IToolKit/IToolKit/Pages/Tools/EncodersDecoders/Unicode/Unicode.razor

-11
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@
1212
<MudSelectItem Value="EncodeDecodeTypeEnum.Decode" />
1313
</MudSelect>
1414
</MudItem>
15-
<MudItem>
16-
<MudCheckBox Color="Color.Primary" T="bool" @bind-Checked="_IsAutoUpdate" Label="Auto Update" />
17-
</MudItem>
18-
<MudItem>
19-
@if (_IsAutoUpdate == false)
20-
{
21-
<MudButton Class="mb-2" Color="Color.Primary" Variant="Variant.Filled" OnClick="()=> Calc(_CurrentValue)">
22-
@_EncodeDecodeType
23-
</MudButton>
24-
}
25-
</MudItem>
2615
</MudGrid>
2716

2817
<CustomTextField Variant="Variant.Outlined" Lines="5" Label="Result" @bind-Value="@_Result" ReadOnly />

IToolKit/IToolKit/Pages/Tools/EncodersDecoders/Unicode/Unicode.razor.cs

-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ partial class Unicode
1010
EncodeDecodeTypeEnum _EncodeDecodeType = EncodeDecodeTypeEnum.Encode;
1111
string _CurrentValue;
1212
string _Result;
13-
bool _IsAutoUpdate = true;
1413

1514
private void OnEncodeDecodeTypeChange(EncodeDecodeTypeEnum hashType)
1615
{
@@ -22,9 +21,6 @@ private void OnChangeEvent(string value)
2221
{
2322
_CurrentValue = value;
2423

25-
if (!_IsAutoUpdate)
26-
return;
27-
2824
if (String.IsNullOrEmpty(value))
2925
{
3026
_Result = value;

IToolKit/IToolKit/Pages/Tools/Generators/Hash/Hash.razor

-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44

55
<CustomTextField Label="Input" Variant="Variant.Outlined" Lines=5 Immediate TextChanged="OnChangeEvent" />
66

7-
<MudCheckBox T="bool" @bind-Checked="@_IsAutoUpdate" Color="Color.Primary" Label="Auto Update"></MudCheckBox>
8-
@if (_IsAutoUpdate == false)
9-
{
10-
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="()=> CalcHash()">Hash</MudButton>
11-
}
127
<MudSwitch Color="Color.Primary" T="bool" CheckedChanged="ChangeTextCase" Label="Uppercase"></MudSwitch>
138
<CustomTextField ReadOnly=true Label="MD5" @bind-Value="@_MD5Result" MonoSpace />
149
<CustomTextField ReadOnly=true Label="SHA1" @bind-Value="@_SHA1Result" MonoSpace />

IToolKit/IToolKit/Pages/Tools/Generators/Hash/Hash.razor.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@ public partial class Hash
1515
string _SHA384Result;
1616
string _SHA512Result;
1717

18-
bool _IsAutoUpdate = true;
1918
bool _IsUpperCase = false;
2019

2120
async Task OnChangeEvent(string value)
2221
{
2322
_CurrentValue = value;
24-
25-
if (_IsAutoUpdate)
26-
await CalcHash();
23+
await CalcHash();
2724
}
2825

2926
async Task CalcHash()

0 commit comments

Comments
 (0)