-
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.
- Added Option to delete/move associated .funscript files
- Huge Code optimization - Cleaned up code - Fixed some bugs
- Loading branch information
Peanutccino
authored and
Peanutccino
committed
Mar 8, 2024
1 parent
ea1f7b6
commit 931b91d
Showing
32 changed files
with
897 additions
and
832 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,50 @@ | ||
using RandomVideoPlayer.Model; | ||
|
||
namespace RandomVideoPlayer.Functions | ||
{ | ||
public class FavFunctions | ||
{ | ||
public static List<string> AddToFavorites(string currentFile) | ||
{ | ||
var favFile = PathHandler.FolderList + @"\Favorites.txt"; | ||
var fromTXT = new List<string>(); | ||
|
||
if (File.Exists(favFile)) | ||
{ | ||
fromTXT = File.ReadLines(favFile).ToList(); | ||
} | ||
if (!fromTXT.Contains(currentFile)) | ||
{ | ||
fromTXT.Add(currentFile); | ||
} | ||
File.WriteAllLines(favFile, fromTXT); | ||
|
||
return fromTXT; | ||
} | ||
|
||
public static List<string> DeleteFromFavorites(string currentFile, List<string> tempFavorites) | ||
{ | ||
string favFile = PathHandler.FolderList + @"\Favorites.txt"; | ||
|
||
tempFavorites.Remove(currentFile); | ||
|
||
File.WriteAllLines(favFile, tempFavorites); | ||
|
||
return tempFavorites; | ||
} | ||
|
||
public static bool IsFavoriteMatched(string currentVideo, List<string> tempFavorites, FontAwesome.Sharp.IconButton ctrl) | ||
{ | ||
if (tempFavorites.Contains(currentVideo)) | ||
{ | ||
ctrl.IconColor = Color.Red; | ||
return true; | ||
} | ||
else | ||
{ | ||
ctrl.IconColor = Color.Black; | ||
return false; | ||
} | ||
} | ||
} | ||
} |
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,82 @@ | ||
namespace RandomVideoPlayer.Functions | ||
{ | ||
public class FileManipulation | ||
{ | ||
/// <summary> | ||
/// Take a filepath and changes the extension to a chosen one | ||
/// </summary> | ||
/// <param name="originalFilePath">String with full filepath</param> | ||
/// <param name="newExtension">Extension to replace the original with</param> | ||
/// <returns>Original filepath with selected extension instead of original</returns> | ||
public static string GetFilePathWithDifferentExtension(string originalFilePath, string newExtension) | ||
{ | ||
string directory = Path.GetDirectoryName(originalFilePath); | ||
|
||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(originalFilePath); | ||
|
||
string newFilePath = Path.Combine(directory, fileNameWithoutExtension + newExtension); | ||
|
||
return newFilePath; | ||
} | ||
/// <summary> | ||
/// Searches for available .funscript variants of the provided file | ||
/// </summary> | ||
/// <param name="originalFilePath">String with full filepath</param> | ||
/// <returns>List with all found funscripts</returns> | ||
public static List<string> GetAssociatedFunscripts(string originalFilePath) | ||
{ | ||
var funscriptList = new List<string>(); | ||
var filePathWithoutExtension = Path.Combine(Path.GetDirectoryName(originalFilePath), Path.GetFileNameWithoutExtension(originalFilePath)); | ||
|
||
var suffixes = new string[] { "", ".pitch", ".roll", ".surge", ".sway", ".twist" }; | ||
|
||
foreach (var suffix in suffixes) | ||
{ | ||
string fullFileName = $"{filePathWithoutExtension}{suffix}.funscript"; | ||
if (File.Exists(fullFileName)) | ||
{ | ||
funscriptList.Add(fullFileName); | ||
} | ||
} | ||
return funscriptList; | ||
} | ||
/// <summary> | ||
/// Get directory path from a string | ||
/// </summary> | ||
/// <param name="filePath">String with full filepath</param> | ||
/// <returns>Path to directory that holds the file</returns> | ||
public static string GetFileDirectory(string filePath) | ||
{ | ||
string directory = Path.GetDirectoryName(filePath); | ||
|
||
if (string.IsNullOrWhiteSpace(directory)) return ""; | ||
return directory; | ||
} | ||
/// <summary> | ||
/// Get Filename with extension from a string | ||
/// </summary> | ||
/// <param name="filePath">String with full filepath</param> | ||
/// <returns>Filename with extension without path</returns> | ||
public static string GetFileName(string filePath) | ||
{ | ||
string fileName = Path.GetFileName(filePath); | ||
|
||
if (string.IsNullOrWhiteSpace(fileName)) return ""; | ||
return fileName; | ||
} | ||
/// <summary> | ||
/// Trim string to length and optionally add string at the end (e.g. "...") | ||
/// </summary> | ||
/// <param name="text">String to trim</param> | ||
/// <param name="length">Trim to length</param> | ||
/// <param name="end">Add string to end of trimmed string</param> | ||
/// <returns>Trimmed text</returns> | ||
public static string TrimText(string text, int length, string end) | ||
{ | ||
int maxLength = length; // Maximum text length. | ||
string truncatedText = text.Length <= maxLength ? text : text.Substring(0, maxLength) + end; | ||
|
||
return truncatedText; | ||
} | ||
} | ||
} |
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
5 changes: 2 additions & 3 deletions
5
RandomVideoPlayerV3/Model/RandomExtension.cs → ...ideoPlayerV3/Functions/RandomExtension.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
Oops, something went wrong.