-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
using local ValueConverters instead of community toolkit ones
- Loading branch information
1 parent
2159125
commit 89ee546
Showing
7 changed files
with
72 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Globalization; | ||
|
||
namespace LMKitMaestro.Converters; | ||
|
||
internal sealed class EqualToZeroConverter : IValueConverter | ||
{ | ||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
if (value != null && value is int integer) | ||
{ | ||
return integer == 0; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,40 @@ | ||
using System.Globalization; | ||
|
||
namespace LMKitMaestro.Converters | ||
namespace LMKitMaestro.Converters; | ||
|
||
internal sealed class FileSizeConverter : IValueConverter | ||
{ | ||
class FileSizeConverter : IValueConverter | ||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
if (value != null) | ||
{ | ||
if (value != null) | ||
{ | ||
Type type = value.GetType(); | ||
Type type = value.GetType(); | ||
|
||
if (value is long bytes) | ||
{ | ||
return FormatFileSize(bytes); | ||
} | ||
if (value is long bytes) | ||
{ | ||
return FormatFileSize(bytes); | ||
} | ||
|
||
return string.Empty; | ||
} | ||
|
||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
private static string FormatFileSize(long bytes) | ||
{ | ||
var unit = 1024; | ||
return string.Empty; | ||
} | ||
|
||
if (bytes < unit) | ||
{ | ||
return $"{bytes} B"; | ||
} | ||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
var exp = (int)(Math.Log(bytes) / Math.Log(unit)); | ||
private static string FormatFileSize(long bytes) | ||
{ | ||
var unit = 1024; | ||
|
||
return $"{bytes / Math.Pow(unit, exp):F2} {("KMGTPE")[exp - 1]}B"; | ||
if (bytes < unit) | ||
{ | ||
return $"{bytes} B"; | ||
} | ||
|
||
var exp = (int)(Math.Log(bytes) / Math.Log(unit)); | ||
|
||
return $"{bytes / Math.Pow(unit, exp):F2} {("KMGTPE")[exp - 1]}B"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Globalization; | ||
|
||
namespace LMKitMaestro.Converters; | ||
|
||
internal sealed class GreaterThanZeroConverter : IValueConverter | ||
{ | ||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
if (value != null && value is int integer) | ||
{ | ||
return integer > 0; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters