Add more options and improve splitting of text
This commit is contained in:
1 parent
3f4f2776be
commit
b634fb98f9
4 files changed
+425
-193
No files matched your search
@@ -19,6 +19,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace VocaluxeLib
|
||||
{
|
||||
@@ -91,28 +92,13 @@ namespace VocaluxeLib
|
||||
return value.IndexOf(other, StringComparison.CurrentCultureIgnoreCase) >= 0;
|
||||
}
|
||||
|
||||
private static Regex _MultipleWhiteSpaceRegEx = new Regex(@" {2,}");
|
||||
|
||||
public static string TrimMultipleWs(this string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return "";
|
||||
int start = 0;
|
||||
int len = value.Length;
|
||||
while (value[start] == ' ')
|
||||
{
|
||||
start++;
|
||||
if (start >= len)
|
||||
return "";
|
||||
}
|
||||
if (start > 0)
|
||||
start--;
|
||||
int end = --len;
|
||||
while (value[end] == ' ')
|
||||
end--;
|
||||
if (end < len)
|
||||
end++;
|
||||
if (end - start < len)
|
||||
value = value.Substring(start, end - start + 1);
|
||||
return value;
|
||||
return _MultipleWhiteSpaceRegEx.Replace(value, " ");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Songs;
|
||||
@@ -48,6 +49,7 @@ namespace VocaluxeLib
|
||||
A = color.A;
|
||||
}
|
||||
|
||||
[Pure]
|
||||
public Color AsColor()
|
||||
{
|
||||
return Color.FromArgb((int)(A * 255), (int)(R * 255), (int)(G * 255), (int)(B * 255));
|
||||
|
||||
Reference in new issue
Block a user