Merge pull request #725 from benomine/main

feat: dotnet 9, CPM, etc
This commit is contained in:
stax76
2025-05-05 14:30:44 +02:00
committed by GitHub
22 changed files with 213 additions and 128 deletions

View File

@@ -101,8 +101,8 @@ public class ConfParser
}
else if (line.Contains('='))
{
string name = line[..line.IndexOf("=")].Trim();
string value = line[(line.IndexOf("=") + 1)..].Trim();
string name = line[..line.IndexOf('=')].Trim();
string value = line[(line.IndexOf('=') + 1)..].Trim();
currentGroup?.Items.Add(new StringPair(name, value));
}

View File

@@ -13,7 +13,7 @@ public static class FileAssociation
string exeFilename = Path.GetFileName(exePath);
string exeFilenameNoExt = Path.GetFileNameWithoutExtension(exePath);
string[] protocols = { "ytdl", "rtsp", "srt", "srtp" };
string[] protocols = ["ytdl", "rtsp", "srt", "srtp"];
if (perceivedType != "unreg")
{

View File

@@ -198,11 +198,13 @@ public class GuiCommand
else
{
string clipboard = System.Windows.Forms.Clipboard.GetText();
List<string> files = new List<string>();
List<string> files = [];
foreach (string i in clipboard.Split(BR.ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
{
if (i.Contains("://") || File.Exists(i))
files.Add(i);
}
if (files.Count == 0)
{
@@ -227,9 +229,13 @@ public class GuiCommand
dialog.Multiselect = true;
if (dialog.ShowDialog() == DialogResult.OK)
foreach (string i in dialog.FileNames)
Player.CommandV("audio-add", i);
if (dialog.ShowDialog() != DialogResult.OK)
return;
foreach (string i in dialog.FileNames)
{
Player.CommandV("audio-add", i);
}
}
void RegisterFileAssociations(IList<string> args)
@@ -313,9 +319,11 @@ public class GuiCommand
var items = new List<Item>();
foreach (string file in App.Settings.RecentFiles)
{
items.Add(new Item() { title = Path.GetFileName(file),
value = new string []{ "loadfile", file },
hint = file});
value = ["loadfile", file],
hint = file});
}
o.items = items.ToArray();
string json = JsonSerializer.Serialize(o);
@@ -326,12 +334,12 @@ public class GuiCommand
{
public string title { get; set; } = "";
public int selected_index { get; set; } = 0;
public Item[] items { get; set; } = Array.Empty<Item>();
public Item[] items { get; set; } = [];
}
class Item
{
public string[] value { get; set; } = Array.Empty<string>();
public string[] value { get; set; } = [];
public string title { get; set; } = "";
public string hint { get; set; } = "";
}
@@ -393,15 +401,21 @@ public class GuiCommand
}
if (App.MediaInfo && !osd && File.Exists(path) && !path.Contains(@"\\.\pipe\"))
using (MediaInfo mediaInfo = new MediaInfo(path))
text = Regex.Replace(mediaInfo.GetSummary(full, raw), "Unique ID.+", "");
{
using MediaInfo mediaInfo = new MediaInfo(path);
text = Regex.Replace(mediaInfo.GetSummary(full, raw), "Unique ID.+", "");
}
else
{
Player.UpdateExternalTracks();
text = "N: " + Player.GetPropertyString("filename") + BR;
lock (Player.MediaTracksLock)
{
foreach (MediaTrack track in Player.MediaTracks)
{
text += track.Text + BR;
}
}
}
text = text.TrimEx();
@@ -426,7 +440,7 @@ public class GuiCommand
{
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)!;
if (path.ToLower().Contains(Folder.Startup.TrimEnd(Path.DirectorySeparatorChar).ToLower()))
if (path.Contains(Folder.Startup.TrimEnd(Path.DirectorySeparatorChar), StringComparison.CurrentCultureIgnoreCase))
{
Msg.ShowWarning(_("mpv.net is already in the Path environment variable."));
return;

View File

@@ -1,49 +1,47 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<RootNamespace>MpvNet.Windows</RootNamespace>
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net9.0-windows</TargetFramework>
<RootNamespace>MpvNet.Windows</RootNamespace>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<PublishSingleFile>true</PublishSingleFile>
<AssemblyName>mpvnet</AssemblyName>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>mpv-icon.ico</ApplicationIcon>
<Product>mpv.net</Product>
<FileVersion>7.1.1.3</FileVersion>
<AssemblyVersion>7.1.1.3</AssemblyVersion>
<AssemblyName>mpvnet</AssemblyName>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>mpv-icon.ico</ApplicationIcon>
<FileVersion>7.1.1.3</FileVersion>
<AssemblyVersion>7.1.1.3</AssemblyVersion>
<InformationalVersion>7.1.1.3</InformationalVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Misc\**" />
<EmbeddedResource Remove="Misc\**" />
<None Remove="Misc\**" />
<Page Remove="Misc\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Misc\**" />
<EmbeddedResource Remove="Misc\**" />
<None Remove="Misc\**" />
<Page Remove="Misc\**" />
</ItemGroup>
<ItemGroup>
<Content Include="mpv-icon.ico" />
</ItemGroup>
<ItemGroup>
<Content Include="mpv-icon.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MpvNet\MpvNet.csproj" />
<ProjectReference Include="..\NGettext.Wpf\NGettext.Wpf.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MpvNet\MpvNet.csproj" />
<ProjectReference Include="..\NGettext.Wpf\NGettext.Wpf.csproj" />
</ItemGroup>
<ItemGroup>
<Page Update="WPF\Views\AboutWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<XamlRuntime>Wpf</XamlRuntime>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="WPF\Views\AboutWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<XamlRuntime>Wpf</XamlRuntime>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" />
</ItemGroup>
</Project>