Convert extension method to extension property
This commit is contained in:
@@ -303,20 +303,20 @@ public class GuiCommand
|
||||
|
||||
if (File.Exists(path) && osd)
|
||||
{
|
||||
if (FileTypes.IsAudio(path.Ext()))
|
||||
if (FileTypes.IsAudio(path.Ext))
|
||||
{
|
||||
text = Player.GetPropertyOsdString("filtered-metadata");
|
||||
Player.CommandV("show-text", text, "5000");
|
||||
return;
|
||||
}
|
||||
else if (FileTypes.IsImage(path.Ext()))
|
||||
else if (FileTypes.IsImage(path.Ext))
|
||||
{
|
||||
fileSize = new FileInfo(path).Length;
|
||||
|
||||
text = "Width: " + Player.GetPropertyInt("width") + "\n" +
|
||||
"Height: " + Player.GetPropertyInt("height") + "\n" +
|
||||
"Size: " + Convert.ToInt32(fileSize / 1024.0) + " KB\n" +
|
||||
"Type: " + path.Ext().ToUpper();
|
||||
"Type: " + path.Ext.ToUpper();
|
||||
|
||||
Player.CommandV("show-text", text, "5000");
|
||||
return;
|
||||
|
||||
@@ -556,12 +556,12 @@ public partial class MainForm : Form
|
||||
if (App.AutofitImage > 1)
|
||||
App.AutofitImage = 1;
|
||||
|
||||
bool isAudio = FileTypes.IsAudio(Player.Path.Ext());
|
||||
bool isAudio = FileTypes.IsAudio(Player.Path.Ext);
|
||||
|
||||
if (isAudio)
|
||||
autoFitHeight = Convert.ToInt32(workingArea.Height * App.AutofitAudio);
|
||||
|
||||
if (FileTypes.IsImage(Player.Path.Ext()))
|
||||
if (FileTypes.IsImage(Player.Path.Ext))
|
||||
autoFitHeight = Convert.ToInt32(workingArea.Height * App.AutofitImage);
|
||||
|
||||
if (Player.VideoSize.Height == 0 || Player.VideoSize.Width == 0)
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
|
||||
namespace MpvNet.ExtensionMethod;
|
||||
|
||||
public static class PathStringExtension
|
||||
public static class PathStringExtensions
|
||||
{
|
||||
public static string Ext(this string filepath) => filepath.Ext(false);
|
||||
|
||||
public static string Ext(this string filepath, bool includeDot)
|
||||
extension(string filepath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(filepath))
|
||||
return "";
|
||||
public string Ext => GetExt(filepath, false);
|
||||
|
||||
char[] chars = filepath.ToCharArray();
|
||||
|
||||
for (int x = filepath.Length - 1; x >= 0; x--)
|
||||
static string GetExt(string path, bool includeDot)
|
||||
{
|
||||
if (chars[x] == Path.DirectorySeparatorChar)
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return "";
|
||||
|
||||
if (chars[x] == '.')
|
||||
return filepath.Substring(x + (includeDot ? 0 : 1)).ToLowerInvariant();
|
||||
}
|
||||
char[] chars = path.ToCharArray();
|
||||
|
||||
return "";
|
||||
for (int x = path.Length - 1; x >= 0; x--)
|
||||
{
|
||||
if (chars[x] == Path.DirectorySeparatorChar)
|
||||
return "";
|
||||
|
||||
if (chars[x] == '.')
|
||||
return path[(x + (includeDot ? 0 : 1))..].ToLowerInvariant();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static string FileName(this string instance)
|
||||
@@ -49,5 +49,5 @@ public static class FileTypes
|
||||
IsVideo(exts, ext) || IsAudio(exts, ext) || IsImage(exts, ext);
|
||||
|
||||
public static IEnumerable<string> GetMediaFiles(string[] files) =>
|
||||
files.Where(i => IsMedia(files, i.Ext()));
|
||||
files.Where(i => IsMedia(files, i.Ext));
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ public class MainPlayer : MpvClient
|
||||
|
||||
file = ConvertFilePath(file);
|
||||
|
||||
string ext = file.Ext();
|
||||
string ext = file.Ext;
|
||||
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user