Rework CBackgroundMusic to avoid crash on startup and assure correct behaviour on runtime
This commit is contained in:
1 parent
f9d29b6141
commit
6053102b8f
11 files changed
+354
-461
No files matched your search
+49
-9
@@ -26,6 +26,22 @@ namespace VocaluxeLib
|
||||
{
|
||||
public static class CHelper
|
||||
{
|
||||
private static readonly List<string> _SoundFileTypes = new List<string>
|
||||
{
|
||||
"*.mp3",
|
||||
"*.wma",
|
||||
"*.ogg",
|
||||
"*.wav"
|
||||
};
|
||||
|
||||
private static readonly List<string> _ImageFileTypes = new List<string>
|
||||
{
|
||||
"*.jpg",
|
||||
"*.jpeg",
|
||||
"*.png",
|
||||
"*.gif"
|
||||
};
|
||||
|
||||
public static int CombinationCount(int n, int k)
|
||||
{
|
||||
if (k > n)
|
||||
@@ -61,7 +77,7 @@ namespace VocaluxeLib
|
||||
/// </summary>
|
||||
public static string ListStrings(string[] str)
|
||||
{
|
||||
string result = string.Empty;
|
||||
string result = String.Empty;
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
result += str[i];
|
||||
@@ -95,7 +111,7 @@ namespace VocaluxeLib
|
||||
return 0;
|
||||
}
|
||||
int result;
|
||||
return int.TryParse(value, out result) ? result : 0;
|
||||
return Int32.TryParse(value, out result) ? result : 0;
|
||||
}
|
||||
|
||||
public static void SetRect(RectangleF bounds, out RectangleF rect, float rectAspect, EAspect aspect)
|
||||
@@ -178,9 +194,25 @@ namespace VocaluxeLib
|
||||
return files;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list with all files in the given path that matches at least one of the given patterns
|
||||
/// </summary>
|
||||
/// <param name="path">Path to search for</param>
|
||||
/// <param name="searchPatterns">List of patterns to match</param>
|
||||
/// <param name="recursive">Search directories recursively</param>
|
||||
/// <param name="fullpath">False for just file names, True for full path</param>
|
||||
/// <returns>List of file names</returns>
|
||||
public static List<string> ListFiles(string path, IEnumerable<string> searchPatterns, bool recursive = false, bool fullpath = false)
|
||||
{
|
||||
var files = new List<string>();
|
||||
foreach (string pattern in searchPatterns)
|
||||
files.AddRange(ListFiles(path, pattern, recursive, fullpath));
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list with all image files in the given path
|
||||
/// Searches for: jpg, jpeg, png, gif
|
||||
/// </summary>
|
||||
/// <param name="path">Path to search for</param>
|
||||
/// <param name="recursive">Search directories recursively</param>
|
||||
@@ -188,11 +220,19 @@ namespace VocaluxeLib
|
||||
/// <returns>List of image file names</returns>
|
||||
public static List<string> ListImageFiles(string path, bool recursive = false, bool fullpath = false)
|
||||
{
|
||||
List<string> files = ListFiles(path, "*.jpg", recursive, fullpath);
|
||||
files.AddRange(ListFiles(path, "*.jpeg", recursive, fullpath));
|
||||
files.AddRange(ListFiles(path, "*.png", recursive, fullpath));
|
||||
files.AddRange(ListFiles(path, "*.gif", recursive, fullpath));
|
||||
return files;
|
||||
return ListFiles(path, _ImageFileTypes, recursive, fullpath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list with all image files in the given path
|
||||
/// </summary>
|
||||
/// <param name="path">Path to search for</param>
|
||||
/// <param name="recursive">Search directories recursively</param>
|
||||
/// <param name="fullpath">False for just file names, True for full path</param>
|
||||
/// <returns>List of image file names</returns>
|
||||
public static List<string> ListSoundFiles(string path, bool recursive = false, bool fullpath = false)
|
||||
{
|
||||
return ListFiles(path, _SoundFileTypes, recursive, fullpath);
|
||||
}
|
||||
|
||||
public static bool TryParse<T>(string value, out T result, bool ignoreCase = false)
|
||||
@@ -212,7 +252,7 @@ namespace VocaluxeLib
|
||||
public static bool TryParse(string value, out float result)
|
||||
{
|
||||
value = value.Replace(',', '.');
|
||||
return float.TryParse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, NumberFormatInfo.InvariantInfo, out result);
|
||||
return Single.TryParse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, NumberFormatInfo.InvariantInfo, out result);
|
||||
}
|
||||
|
||||
public static bool IsInBounds(SRectF bounds, SMouseEvent mouseEvent)
|
||||
|
||||
Reference in new issue
Block a user