removal of TaskDialog usage...
This commit is contained in:
@@ -18,16 +18,19 @@ using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
|
||||
using mpvnet;
|
||||
using static mpvnet.Core;
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace RatingExtension // the assembly name must end with 'Extension'
|
||||
namespace RatingExtension // the assembly name must end with 'Extension'!
|
||||
{
|
||||
[Export(typeof(IExtension))]
|
||||
public class RatingExtension : IExtension
|
||||
{
|
||||
//Script script = new Script();
|
||||
|
||||
// dictionory to store the filename and the rating
|
||||
Dictionary<string, int> Dic = new Dictionary<string, int>();
|
||||
|
||||
@@ -36,8 +39,8 @@ namespace RatingExtension // the assembly name must end with 'Extension'
|
||||
|
||||
public RatingExtension() // plugin initialization
|
||||
{
|
||||
core.ClientMessage += ClientMessage; //handles keys defined in input.conf
|
||||
core.Shutdown += Shutdown; // handles MPV_EVENT_SHUTDOWN
|
||||
Core.ClientMessage += ClientMessage; //handles keys defined in input.conf
|
||||
Core.Shutdown += Shutdown; // handles MPV_EVENT_SHUTDOWN
|
||||
}
|
||||
|
||||
// handles MPV_EVENT_SHUTDOWN
|
||||
@@ -48,7 +51,7 @@ namespace RatingExtension // the assembly name must end with 'Extension'
|
||||
string filepath = i.Key;
|
||||
int rating = i.Value;
|
||||
|
||||
if (String.IsNullOrEmpty(filepath) || !File.Exists(filepath))
|
||||
if (string.IsNullOrEmpty(filepath) || !File.Exists(filepath))
|
||||
return;
|
||||
|
||||
string basename = Path.GetFileNameWithoutExtension(filepath);
|
||||
@@ -77,7 +80,7 @@ namespace RatingExtension // the assembly name must end with 'Extension'
|
||||
|
||||
if (int.TryParse(args[1], out int rating))
|
||||
{
|
||||
string path = core.get_property_string("path");
|
||||
string path = Core.get_property_string("path");
|
||||
|
||||
if (!File.Exists(path))
|
||||
return;
|
||||
@@ -87,7 +90,7 @@ namespace RatingExtension // the assembly name must end with 'Extension'
|
||||
else
|
||||
{
|
||||
Dic[path] = rating;
|
||||
core.commandv("show-text", $"Rating: {rating}");
|
||||
Core.commandv("show-text", $"Rating: {rating}");
|
||||
}
|
||||
}
|
||||
else if (args[1] == "about")
|
||||
@@ -99,26 +102,26 @@ namespace RatingExtension // the assembly name must end with 'Extension'
|
||||
{
|
||||
if (rating == 0)
|
||||
{
|
||||
FileToDelete = core.get_property_string("path");
|
||||
FileToDelete = Core.get_property_string("path");
|
||||
DeleteTime = DateTime.Now;
|
||||
core.commandv("show-text", "Press 1 to delete file", "5000");
|
||||
Core.commandv("show-text", "Press 1 to delete file", "5000");
|
||||
}
|
||||
else
|
||||
{
|
||||
TimeSpan ts = DateTime.Now - DeleteTime;
|
||||
string path = core.get_property_string("path");
|
||||
string path = Core.get_property_string("path");
|
||||
|
||||
if (FileToDelete == path && ts.TotalSeconds < 5 && File.Exists(FileToDelete))
|
||||
{
|
||||
core.command("playlist-remove current");
|
||||
int pos = core.get_property_int("playlist-pos");
|
||||
Core.command("playlist-remove current");
|
||||
int pos = Core.get_property_int("playlist-pos");
|
||||
|
||||
if (pos == -1)
|
||||
{
|
||||
int count = core.get_property_int("playlist-count");
|
||||
int count = Core.get_property_int("playlist-count");
|
||||
|
||||
if (count > 0)
|
||||
core.set_property_int("playlist-pos", count - 1);
|
||||
Core.set_property_int("playlist-pos", count - 1);
|
||||
}
|
||||
|
||||
Thread.Sleep(2000);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>C:\Users\frank\OneDrive\Settings\mpv.net\extensions\RatingExtension\</OutputPath>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -24,7 +24,7 @@
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>C:\Users\frank\OneDrive\Settings\mpv.net\extensions\RatingExtension\</OutputPath>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -38,6 +38,7 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
@@ -49,6 +50,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="RatingExtension.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ScriptDevelopment.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\mpv.net.csproj">
|
||||
|
||||
42
src/Extensions/RatingExtension/ScriptDevelopment.cs
Normal file
42
src/Extensions/RatingExtension/ScriptDevelopment.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
//// This script adds dynamic menu items for profile switching.
|
||||
|
||||
//// In input.conf add a menu item called 'Profiles'
|
||||
|
||||
//using mpvnet;
|
||||
//using System.ComponentModel;
|
||||
//using System.Linq;
|
||||
|
||||
//class Script
|
||||
//{
|
||||
// MainForm MainForm;
|
||||
// CorePlayer Core;
|
||||
|
||||
// public Script()
|
||||
// {
|
||||
// Core = Global.Core;
|
||||
// MainForm = MainForm.Instance;
|
||||
// MainForm.ContextMenu.Opening += ContextMenu_Opening;
|
||||
// }
|
||||
|
||||
// void ContextMenu_Opening(object sender, CancelEventArgs e)
|
||||
// {
|
||||
// MenuItem menuItem = MainForm.FindMenuItem("My Menu");
|
||||
|
||||
// if (menuItem == null)
|
||||
// {
|
||||
// Terminal.WriteError("Profiles menu item not found.", "switch-profile-context-menu.cs");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// menuItem.DropDownItems.Clear();
|
||||
// var editionTracks = Core.MediaTracks.Where(track => track.Type == "e");
|
||||
|
||||
// foreach (int i in new[] {1, 2, 3})
|
||||
// {
|
||||
// MenuItem mi = new MenuItem(i.ToString());
|
||||
// mi.Action = () => { Core.commandv("show-text", i.ToString()); };
|
||||
// menuItem.DropDownItems.Add(mi);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user