removal of TaskDialog usage...

This commit is contained in:
Frank Skare
2021-05-23 19:30:21 +02:00
parent 0b28770d1a
commit eaa8a3ca6c
59 changed files with 1035 additions and 7065 deletions

View File

@@ -0,0 +1,63 @@
// C# Script that deletes the current file
// In input.conf add:
// KP0 script-message delete-current-file ask #menu: Script > Delete current file > Ask
// KP1 script-message delete-current-file confirm #menu: Script > Delete current file > Confirm
using System;
using System.IO;
using System.Threading;
using Microsoft.VisualBasic.FileIO;
using mpvnet;
class Script
{
string FileToDelete;
DateTime DeleteTime;
CorePlayer Core;
public Script()
{
Core = Global.Core;
Core.ClientMessage += ClientMessage;
}
void ClientMessage(string[] args)
{
if (args == null || args.Length != 2 || args[0] != "delete-current-file")
return;
if (args[1] == "ask")
{
FileToDelete = Core.get_property_string("path");
DeleteTime = DateTime.Now;
Core.commandv("show-text", "Press 1 to delete file", "5000");
}
else if (args[1] == "confirm")
{
TimeSpan ts = DateTime.Now - DeleteTime;
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");
if (pos == -1)
{
int count = Core.get_property_int("playlist-count");
if (count > 0)
Core.set_property_int("playlist-pos", count - 1);
}
Thread.Sleep(2000);
FileSystem.DeleteFile(FileToDelete, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
}
}
}
}

View File

@@ -11,7 +11,7 @@ class Script
{
string content = "ctrl+w script-message my-message-1 my-argument-1";
string sectionName = Assembly.GetExecutingAssembly().GetName().Name;
Core core = Core.core;
CorePlayer core = Global.Core;
core.commandv("define-section", sectionName, content, "force");
core.commandv("enable-section", sectionName);
core.ClientMessage += ClientMessage;
@@ -22,7 +22,7 @@ class Script
switch (args[0])
{
case "my-message-1":
Msg.Show(args[1]);
Msg.ShowInfo(args[1]);
break;
}
}

View File

@@ -6,16 +6,16 @@ using mpvnet;
class Script
{
Core core;
CorePlayer Core;
public Script()
{
core = Core.core;
core.observe_property_bool("fullscreen", FullscreenChange);
Core = Global.Core;
Core.observe_property_bool("fullscreen", FullscreenChange);
}
void FullscreenChange(bool value)
{
core.commandv("show-text", "fullscreen: " + value);
Core.commandv("show-text", "fullscreen: " + value);
}
}

View File

@@ -8,28 +8,28 @@ using mpvnet;
class Script
{
MainForm Form;
Core core;
MainForm MainForm;
CorePlayer Core;
bool WasPlaying;
bool WasPaused;
public Script()
{
core = Core.core;
Form = MainForm.Instance;
Form.Resize += Form_Resize;
Core = Global.Core;
MainForm = MainForm.Instance;
MainForm.Resize += Form_Resize;
}
private void Form_Resize(object sender, EventArgs e)
void Form_Resize(object sender, EventArgs e)
{
if (Form.WindowState == FormWindowState.Minimized)
if (MainForm.WindowState == FormWindowState.Minimized)
{
WasPlaying = !core.get_property_bool("pause");
WasPlaying = !Core.get_property_bool("pause");
if (WasPlaying)
{
core.set_property_bool("pause", true, true);
Core.set_property_bool("pause", true, true);
WasPaused = true;
}
}
@@ -37,7 +37,7 @@ class Script
{
if (WasPaused)
{
core.set_property_bool("pause", false, true);
Core.set_property_bool("pause", false, true);
WasPaused = false;
}
}

View File

@@ -0,0 +1,84 @@
// This script writes a rating to the filename of rated videos when mpv.net shuts down.
// In input.conf add:
// KP0 script-message rate-file 0 #menu: Extensions > Rating > 0stars
// KP1 script-message rate-file 1 #menu: Extensions > Rating > 1stars
// KP2 script-message rate-file 2 #menu: Extensions > Rating > 2stars
// KP3 script-message rate-file 3 #menu: Extensions > Rating > 3stars
// KP4 script-message rate-file 4 #menu: Extensions > Rating > 4stars
// KP5 script-message rate-file 5 #menu: Extensions > Rating > 5stars
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using mpvnet;
class Script
{
// dictionory to store the filename and the rating
Dictionary<string, int> Dic = new Dictionary<string, int>();
CorePlayer Core;
public Script() // plugin initialization
{
Core = Global.Core;
Core.ClientMessage += ClientMessage; //handles keys defined in input.conf
Core.Shutdown += Shutdown; // handles MPV_EVENT_SHUTDOWN
}
// handles MPV_EVENT_SHUTDOWN
void Shutdown()
{
foreach (var i in Dic)
{
string filepath = i.Key;
int rating = i.Value;
if (string.IsNullOrEmpty(filepath) || !File.Exists(filepath))
return;
string basename = Path.GetFileNameWithoutExtension(filepath);
for (int x = 0; x < 6; x++)
if (basename.Contains(" (" + x + "stars)"))
basename = basename.Replace(" (" + x + "stars)", "");
basename += " (" + rating + "stars)";
string newPath = Path.Combine(Path.GetDirectoryName(filepath),
basename + Path.GetExtension(filepath));
if (filepath.ToLower() != newPath.ToLower())
File.Move(filepath, newPath);
File.SetLastWriteTime(newPath, DateTime.Now);
}
}
//handles keys defined in input.conf
void ClientMessage(string[] args)
{
if (args[0] != "rate-file")
return;
int rating;
if (int.TryParse(args[1], out rating))
{
string path = Core.get_property_string("path");
if (!File.Exists(path))
return;
Dic[path] = rating;
Core.commandv("show-text", "Rating: " + rating);
}
else if (args[1] == "about")
MessageBox.Show("This extension writes a rating to the filename of rated videos when mpv.net shuts down.",
"Rating Extension");
}
}

View File

@@ -8,12 +8,12 @@ using System.Linq;
class Script
{
MainForm MainForm;
Core core;
CorePlayer Core;
public Script()
{
core = Core.core;
MainForm = mpvnet.MainForm.Instance;
Core = Global.Core;
MainForm = MainForm.Instance;
MainForm.ContextMenu.Opening += ContextMenu_Opening;
}
@@ -26,13 +26,13 @@ class Script
return;
menuItem.DropDownItems.Clear();
var editionTracks = core.MediaTracks.Where(track => track.Type == "e");
var editionTracks = Core.MediaTracks.Where(track => track.Type == "e");
foreach (MediaTrack track in editionTracks)
{
MenuItem mi = new MenuItem(track.Text);
mi.Action = () => { core.commandv("set", "edition", track.ID.ToString()); };
mi.Checked = core.Edition == track.ID;
mi.Action = () => { Core.commandv("set", "edition", track.ID.ToString()); };
mi.Checked = Core.Edition == track.ID;
menuItem.DropDownItems.Add(mi);
}
}