-
-
Notifications
You must be signed in to change notification settings - Fork 17
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 #142 from OliBomby/dev
fixes and features
- Loading branch information
Showing
21 changed files
with
265 additions
and
151 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
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
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
50 changes: 50 additions & 0 deletions
50
Mapping Tools/Components/Domain/DoubleArrayToStringConverter.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,50 @@ | ||
using Mapping_Tools.Classes.BeatmapHelper; | ||
using Mapping_Tools.Classes.SystemTools; | ||
using System; | ||
using System.Globalization; | ||
using System.Text; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
|
||
namespace Mapping_Tools.Components.Domain { | ||
internal class DoubleArrayToStringConverter : IValueConverter { | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { | ||
if (!(value is double[] beatDivisors)) return string.Empty; | ||
|
||
var builder = new StringBuilder(); | ||
bool first = true; | ||
foreach (var d in beatDivisors) { | ||
if (!first) { | ||
builder.Append(", "); | ||
} | ||
|
||
builder.Append(d.ToInvariant()); | ||
|
||
first = false; | ||
} | ||
|
||
return builder.ToString(); | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { | ||
if (!(value is string str)) return new double[0]; | ||
if (string.IsNullOrWhiteSpace(str)) return new double[0]; | ||
|
||
var vals = str.Split(','); | ||
var beatDivisors = new double[vals.Length]; | ||
|
||
for (int i = 0; i < vals.Length; i++) { | ||
var val = vals[i]; | ||
|
||
var valid = TypeConverters.TryParseDouble(val, out double doubleValue); | ||
if (valid) { | ||
beatDivisors[i] = doubleValue; | ||
} else { | ||
return new ValidationResult(false, "Double format error."); | ||
} | ||
} | ||
|
||
return beatDivisors; | ||
} | ||
} | ||
} |
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.