several improvements
This commit is contained in:
@@ -31,6 +31,7 @@ namespace mpvnet
|
||||
case "open-files": OpenFiles(args); break;
|
||||
case "open-optical-media": Open_DVD_Or_BD_Folder(); break;
|
||||
case "open-url": OpenURL(); break;
|
||||
case "play-pause": PlayPause(); break;
|
||||
case "playlist-first": PlaylistFirst(); break;
|
||||
case "playlist-last": PlaylistLast(); break;
|
||||
case "reg-file-assoc": RegisterFileAssociations(args[0]); break;
|
||||
@@ -117,6 +118,25 @@ namespace mpvnet
|
||||
Core.SetPropertyInt("playlist-pos", count - 1);
|
||||
}
|
||||
|
||||
public static void PlayPause()
|
||||
{
|
||||
int count = Core.GetPropertyInt("playlist-count");
|
||||
|
||||
if (count > 0)
|
||||
Core.Command("cycle pause");
|
||||
else if (App.Settings.RecentFiles.Count > 0)
|
||||
{
|
||||
foreach (string i in App.Settings.RecentFiles)
|
||||
{
|
||||
if (i.Contains("://") || File.Exists(i))
|
||||
{
|
||||
Core.LoadFiles(new[] { i }, true, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowHistory()
|
||||
{
|
||||
if (File.Exists(Core.ConfigFolder + "history.txt"))
|
||||
@@ -217,16 +237,24 @@ namespace mpvnet
|
||||
public static void OpenURL()
|
||||
{
|
||||
App.InvokeOnMainThread(new Action(() => {
|
||||
string clipboard = System.Windows.Forms.Clipboard.GetText();
|
||||
|
||||
if (string.IsNullOrEmpty(clipboard) || (!clipboard.Contains("://") && !File.Exists(clipboard)) ||
|
||||
clipboard.Contains("\n"))
|
||||
if (WinForms.Clipboard.ContainsFileDropList())
|
||||
{
|
||||
App.ShowError("No URL found, the clipboard does not contain a valid URL or file.");
|
||||
return;
|
||||
string[] files = WinForms.Clipboard.GetFileDropList().Cast<string>().ToArray();
|
||||
Core.LoadFiles(files, false, Control.ModifierKeys.HasFlag(Keys.Control));
|
||||
}
|
||||
else
|
||||
{
|
||||
string clipboard = WinForms.Clipboard.GetText();
|
||||
|
||||
Core.LoadFiles(new [] { clipboard }, false, Control.ModifierKeys.HasFlag(Keys.Control));
|
||||
if (string.IsNullOrEmpty(clipboard) || (!clipboard.Contains("://") && !File.Exists(clipboard)) ||
|
||||
clipboard.Contains("\n"))
|
||||
{
|
||||
App.ShowError("No URL found, the clipboard does not contain a valid URL or file.");
|
||||
return;
|
||||
}
|
||||
|
||||
Core.LoadFiles(new [] { clipboard }, false, Control.ModifierKeys.HasFlag(Keys.Control));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -449,7 +477,7 @@ namespace mpvnet
|
||||
|
||||
public static void ShowRecent() => App.InvokeOnMainThread(ShowRecentInternal);
|
||||
|
||||
public static void ShowRecentInternal()
|
||||
static void ShowRecentInternal()
|
||||
{
|
||||
List<CommandPaletteItem> items = new List<CommandPaletteItem>();
|
||||
|
||||
@@ -468,6 +496,7 @@ namespace mpvnet
|
||||
|
||||
CommandPalette.Instance.SetItems(items);
|
||||
MainForm.Instance.ShowCommandPalette();
|
||||
CommandPalette.Instance.SelectFirst();
|
||||
}
|
||||
|
||||
public static void RegisterFileAssociations(string perceivedType)
|
||||
|
||||
@@ -713,7 +713,8 @@ namespace mpvnet
|
||||
if (App.Settings.RecentFiles.Contains(path))
|
||||
App.Settings.RecentFiles.Remove(path);
|
||||
|
||||
App.Settings.RecentFiles.Insert(0, path);
|
||||
if (path != @"bd://" && path != @"dvd://")
|
||||
App.Settings.RecentFiles.Insert(0, path);
|
||||
|
||||
while (App.Settings.RecentFiles.Count > App.RecentCount)
|
||||
App.Settings.RecentFiles.RemoveAt(App.RecentCount);
|
||||
@@ -1138,8 +1139,7 @@ namespace mpvnet
|
||||
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
Core.LoadFiles(e.Data.GetData(DataFormats.FileDrop) as String[], true, ModifierKeys.HasFlag(Keys.Control));
|
||||
|
||||
if (e.Data.GetDataPresent(DataFormats.Text))
|
||||
else if (e.Data.GetDataPresent(DataFormats.Text))
|
||||
Core.LoadFiles(new[] { e.Data.GetData(DataFormats.Text).ToString() }, true, ModifierKeys.HasFlag(Keys.Control));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user