forked from LykosAI/StabilityMatrix
-
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.
Merge pull request LykosAI#622 from ionite34/fix-inference-lora
Fix Inference Lora resetting due to slider maximums & Add number format setting
- Loading branch information
Showing
10 changed files
with
262 additions
and
66 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
36 changes: 36 additions & 0 deletions
36
StabilityMatrix.Avalonia/Converters/NumberFormatModeSampleConverter.cs
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,36 @@ | ||
using System; | ||
using System.Globalization; | ||
using Avalonia.Data.Converters; | ||
using StabilityMatrix.Core.Models.Settings; | ||
|
||
namespace StabilityMatrix.Avalonia.Converters; | ||
|
||
/// <summary> | ||
/// Converts a <see cref="NumberFormatMode"/> to a sample number string | ||
/// </summary> | ||
public class NumberFormatModeSampleConverter : IValueConverter | ||
{ | ||
/// <inheritdoc /> | ||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
if (value is not NumberFormatMode mode) | ||
return null; | ||
|
||
const double sample = 12345.67; | ||
|
||
// Format the sample number based on the number format mode | ||
return mode switch | ||
{ | ||
NumberFormatMode.Default => sample.ToString("N2", culture), | ||
NumberFormatMode.CurrentCulture => sample.ToString("N2", culture), | ||
NumberFormatMode.InvariantCulture => sample.ToString("N2", CultureInfo.InvariantCulture), | ||
_ => throw new ArgumentOutOfRangeException() | ||
}; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.