Skip to content

Commit a78c1ba

Browse files
authored
Merge pull request #725 from benomine/main
feat: dotnet 9, CPM, etc
2 parents 6a97159 + 01477d8 commit a78c1ba

22 files changed

+213
-128
lines changed

src/.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ csharp_style_implicit_object_creation_when_type_is_apparent = true
55

66
# IDE0090: Use 'new(...)'
77
dotnet_diagnostic.IDE0090.severity = silent
8+
9+
# WFO1000: A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method
10+
dotnet_diagnostic.WFO1000.severity = silent

src/Directory.Build.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project>
2+
<PropertyGroup>
3+
<Product>mpv.net</Product>
4+
<Nullable>enable</Nullable>
5+
</PropertyGroup>
6+
</Project>

src/Directory.Packages.props

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.0" />
7+
<PackageVersion Include="NGettext" Version="0.6.7" />
8+
<PackageVersion Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.135" />
9+
</ItemGroup>
10+
</Project>

src/MpvNet.Windows/Conf.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ public static List<ConfSection> Parse(string content)
101101
}
102102
else if (line.Contains('='))
103103
{
104-
string name = line[..line.IndexOf("=")].Trim();
105-
string value = line[(line.IndexOf("=") + 1)..].Trim();
104+
string name = line[..line.IndexOf('=')].Trim();
105+
string value = line[(line.IndexOf('=') + 1)..].Trim();
106106

107107
currentGroup?.Items.Add(new StringPair(name, value));
108108
}

src/MpvNet.Windows/FileAssociation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static void Register(string perceivedType, string[] extensions)
1313
string exeFilename = Path.GetFileName(exePath);
1414
string exeFilenameNoExt = Path.GetFileNameWithoutExtension(exePath);
1515

16-
string[] protocols = { "ytdl", "rtsp", "srt", "srtp" };
16+
string[] protocols = ["ytdl", "rtsp", "srt", "srtp"];
1717

1818
if (perceivedType != "unreg")
1919
{

src/MpvNet.Windows/GuiCommand.cs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,13 @@ void OpenFromClipboard(IList<string> args)
198198
else
199199
{
200200
string clipboard = System.Windows.Forms.Clipboard.GetText();
201-
List<string> files = new List<string>();
201+
List<string> files = [];
202202

203203
foreach (string i in clipboard.Split(BR.ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
204+
{
204205
if (i.Contains("://") || File.Exists(i))
205206
files.Add(i);
207+
}
206208

207209
if (files.Count == 0)
208210
{
@@ -227,9 +229,13 @@ void LoadAudio(IList<string> args)
227229

228230
dialog.Multiselect = true;
229231

230-
if (dialog.ShowDialog() == DialogResult.OK)
231-
foreach (string i in dialog.FileNames)
232-
Player.CommandV("audio-add", i);
232+
if (dialog.ShowDialog() != DialogResult.OK)
233+
return;
234+
235+
foreach (string i in dialog.FileNames)
236+
{
237+
Player.CommandV("audio-add", i);
238+
}
233239
}
234240

235241
void RegisterFileAssociations(IList<string> args)
@@ -313,9 +319,11 @@ void ShowRecentFilesInCommandPalette()
313319
var items = new List<Item>();
314320

315321
foreach (string file in App.Settings.RecentFiles)
322+
{
316323
items.Add(new Item() { title = Path.GetFileName(file),
317-
value = new string []{ "loadfile", file },
318-
hint = file});
324+
value = ["loadfile", file],
325+
hint = file});
326+
}
319327

320328
o.items = items.ToArray();
321329
string json = JsonSerializer.Serialize(o);
@@ -326,12 +334,12 @@ class Obj
326334
{
327335
public string title { get; set; } = "";
328336
public int selected_index { get; set; } = 0;
329-
public Item[] items { get; set; } = Array.Empty<Item>();
337+
public Item[] items { get; set; } = [];
330338
}
331339

332340
class Item
333341
{
334-
public string[] value { get; set; } = Array.Empty<string>();
342+
public string[] value { get; set; } = [];
335343
public string title { get; set; } = "";
336344
public string hint { get; set; } = "";
337345
}
@@ -393,15 +401,21 @@ void ShowMediaInfo(IList<string> args)
393401
}
394402

395403
if (App.MediaInfo && !osd && File.Exists(path) && !path.Contains(@"\\.\pipe\"))
396-
using (MediaInfo mediaInfo = new MediaInfo(path))
397-
text = Regex.Replace(mediaInfo.GetSummary(full, raw), "Unique ID.+", "");
404+
{
405+
using MediaInfo mediaInfo = new MediaInfo(path);
406+
text = Regex.Replace(mediaInfo.GetSummary(full, raw), "Unique ID.+", "");
407+
}
398408
else
399409
{
400410
Player.UpdateExternalTracks();
401411
text = "N: " + Player.GetPropertyString("filename") + BR;
402412
lock (Player.MediaTracksLock)
413+
{
403414
foreach (MediaTrack track in Player.MediaTracks)
415+
{
404416
text += track.Text + BR;
417+
}
418+
}
405419
}
406420

407421
text = text.TrimEx();
@@ -426,7 +440,7 @@ void AddToPath()
426440
{
427441
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)!;
428442

429-
if (path.ToLower().Contains(Folder.Startup.TrimEnd(Path.DirectorySeparatorChar).ToLower()))
443+
if (path.Contains(Folder.Startup.TrimEnd(Path.DirectorySeparatorChar), StringComparison.CurrentCultureIgnoreCase))
430444
{
431445
Msg.ShowWarning(_("mpv.net is already in the Path environment variable."));
432446
return;
Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,47 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<OutputType>WinExe</OutputType>
5-
<TargetFramework>net6.0-windows</TargetFramework>
6-
<RootNamespace>MpvNet.Windows</RootNamespace>
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net9.0-windows</TargetFramework>
6+
<RootNamespace>MpvNet.Windows</RootNamespace>
77
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
88
<PublishSingleFile>true</PublishSingleFile>
9-
<AssemblyName>mpvnet</AssemblyName>
10-
<UseWPF>true</UseWPF>
11-
<UseWindowsForms>true</UseWindowsForms>
12-
<ApplicationIcon>mpv-icon.ico</ApplicationIcon>
13-
<Product>mpv.net</Product>
14-
<FileVersion>7.1.1.3</FileVersion>
15-
<AssemblyVersion>7.1.1.3</AssemblyVersion>
9+
<AssemblyName>mpvnet</AssemblyName>
10+
<UseWPF>true</UseWPF>
11+
<UseWindowsForms>true</UseWindowsForms>
12+
<ApplicationIcon>mpv-icon.ico</ApplicationIcon>
13+
<FileVersion>7.1.1.3</FileVersion>
14+
<AssemblyVersion>7.1.1.3</AssemblyVersion>
1615
<InformationalVersion>7.1.1.3</InformationalVersion>
17-
<Nullable>enable</Nullable>
18-
</PropertyGroup>
16+
</PropertyGroup>
1917

20-
<ItemGroup>
21-
<Compile Remove="Misc\**" />
22-
<EmbeddedResource Remove="Misc\**" />
23-
<None Remove="Misc\**" />
24-
<Page Remove="Misc\**" />
25-
</ItemGroup>
18+
<ItemGroup>
19+
<Compile Remove="Misc\**" />
20+
<EmbeddedResource Remove="Misc\**" />
21+
<None Remove="Misc\**" />
22+
<Page Remove="Misc\**" />
23+
</ItemGroup>
2624

27-
<ItemGroup>
28-
<Content Include="mpv-icon.ico" />
29-
</ItemGroup>
25+
<ItemGroup>
26+
<Content Include="mpv-icon.ico" />
27+
</ItemGroup>
3028

31-
<ItemGroup>
32-
<ProjectReference Include="..\MpvNet\MpvNet.csproj" />
33-
<ProjectReference Include="..\NGettext.Wpf\NGettext.Wpf.csproj" />
34-
</ItemGroup>
29+
<ItemGroup>
30+
<ProjectReference Include="..\MpvNet\MpvNet.csproj" />
31+
<ProjectReference Include="..\NGettext.Wpf\NGettext.Wpf.csproj" />
32+
</ItemGroup>
3533

36-
<ItemGroup>
37-
<Page Update="WPF\Views\AboutWindow.xaml">
38-
<Generator>MSBuild:Compile</Generator>
39-
<XamlRuntime>Wpf</XamlRuntime>
40-
<SubType>Designer</SubType>
41-
</Page>
42-
</ItemGroup>
34+
<ItemGroup>
35+
<Page Update="WPF\Views\AboutWindow.xaml">
36+
<Generator>MSBuild:Compile</Generator>
37+
<XamlRuntime>Wpf</XamlRuntime>
38+
<SubType>Designer</SubType>
39+
</Page>
40+
</ItemGroup>
4341

44-
<ItemGroup>
45-
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
46-
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
47-
</ItemGroup>
42+
<ItemGroup>
43+
<PackageReference Include="CommunityToolkit.Mvvm" />
44+
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" />
45+
</ItemGroup>
4846

4947
</Project>

src/MpvNet.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ EndProject
1313
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2F97C77E-32E3-46FA-8D7C-3940FD9AA384}"
1414
ProjectSection(SolutionItems) = preProject
1515
.editorconfig = .editorconfig
16+
Directory.Build.props = Directory.Build.props
1617
EndProjectSection
1718
EndProject
1819
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NGettext.Wpf", "NGettext.Wpf\NGettext.Wpf.csproj", "{0B7958FD-2138-482A-A21B-481AE7A0F851}"

src/MpvNet/Chapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public string TimeDisplay
1919
_timeDisplay = TimeSpan.FromSeconds(Time).ToString();
2020

2121
if (_timeDisplay.ContainsEx("."))
22-
_timeDisplay = _timeDisplay[.._timeDisplay.LastIndexOf(".")];
22+
_timeDisplay = _timeDisplay[.._timeDisplay.LastIndexOf('.')];
2323
}
2424

2525
return _timeDisplay;

src/MpvNet/Command.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void PlayPause(IList<string> args)
4242
{
4343
if (i.Contains("://") || File.Exists(i))
4444
{
45-
Player.LoadFiles(new[] { i }, true, false);
45+
Player.LoadFiles([i], true, false);
4646
break;
4747
}
4848
}

0 commit comments

Comments
 (0)