Media Info is shown using command palette
This commit is contained in:
@@ -4,6 +4,9 @@
|
|||||||
- Fix opening zip files.
|
- Fix opening zip files.
|
||||||
- The list of available input commands is like before shown
|
- The list of available input commands is like before shown
|
||||||
by the text editor, so it's like everything else searchable.
|
by the text editor, so it's like everything else searchable.
|
||||||
|
- Media Info isn't shown directly, instead the command palette
|
||||||
|
shows several choices. The command palette can be bypassed
|
||||||
|
using the arguments: textbox, editor, full, raw
|
||||||
|
|
||||||
5.7.0.0 Stable (2022-03-09)
|
5.7.0.0 Stable (2022-03-09)
|
||||||
|
|
||||||
|
|||||||
@@ -344,16 +344,16 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static void ShowCommands()
|
public static void ShowCommands()
|
||||||
{
|
{
|
||||||
string json = Core.GetPropertyString("command-list");
|
string jsonString = Core.GetPropertyString("command-list");
|
||||||
var o = json.FromJson<List<Dictionary<string, object>>>().OrderBy(i => i["name"]);
|
var jsonObject = jsonString.FromJson<List<Dictionary<string, object>>>().OrderBy(i => i["name"]);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
foreach (Dictionary<string, object> i in o)
|
foreach (Dictionary<string, object> dic in jsonObject)
|
||||||
{
|
{
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
sb.AppendLine(i["name"].ToString());
|
sb.AppendLine(dic["name"].ToString());
|
||||||
|
|
||||||
foreach (Dictionary<string, object> i2 in i["args"] as List<object>)
|
foreach (Dictionary<string, object> i2 in dic["args"] as List<object>)
|
||||||
{
|
{
|
||||||
string value = i2["name"].ToString() + " <" + i2["type"].ToString().ToLower() + ">";
|
string value = i2["name"].ToString() + " <" + i2["type"].ToString().ToLower() + ">";
|
||||||
|
|
||||||
@@ -386,8 +386,23 @@ namespace mpvnet
|
|||||||
"}${osd-ass-cc/1}" + text + "\" " + duration);
|
"}${osd-ass-cc/1}" + text + "\" " + duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ShowMediaInfo(string[] args)
|
public static void ShowMediaInfo(string[] args) => App.InvokeOnMainThread(() =>
|
||||||
{
|
{
|
||||||
|
if (args == null || args.Length == 0)
|
||||||
|
{
|
||||||
|
(string Name, string Value)[] pairs = {
|
||||||
|
("Show text box", "script-message mpv.net show-media-info default"),
|
||||||
|
("Show text editor", "script-message mpv.net show-media-info editor"),
|
||||||
|
("Show full", "script-message mpv.net show-media-info editor full"),
|
||||||
|
("Show raw", "script-message mpv.net show-media-info editor full raw") };
|
||||||
|
|
||||||
|
var list = pairs.Select(i => new CommandPaletteItem(i.Name, () => Core.Command(i.Value)));
|
||||||
|
CommandPalette.Instance.SetItems(list);
|
||||||
|
MainForm.Instance.ShowCommandPalette();
|
||||||
|
CommandPalette.Instance.SelectFirst();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
string path = Core.GetPropertyString("path");
|
string path = Core.GetPropertyString("path");
|
||||||
|
|
||||||
if (File.Exists(path) && !path.Contains(@"\\.\pipe\"))
|
if (File.Exists(path) && !path.Contains(@"\\.\pipe\"))
|
||||||
@@ -396,14 +411,22 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
bool full = args.Contains("full");
|
bool full = args.Contains("full");
|
||||||
bool raw = args.Contains("raw");
|
bool raw = args.Contains("raw");
|
||||||
|
bool editor = args.Contains("editor");
|
||||||
|
|
||||||
string text = mediaInfo.GetSummary(full, raw);
|
string text = mediaInfo.GetSummary(full, raw);
|
||||||
text = Regex.Replace(text, "Unique ID.+", "");
|
text = Regex.Replace(text, "Unique ID.+", "");
|
||||||
|
|
||||||
|
if (editor)
|
||||||
|
ShowTextWithEditor("media-info", text);
|
||||||
|
else
|
||||||
|
{
|
||||||
MsgBoxEx.MessageBoxEx.MsgFontFamily = new FontFamily("Consolas");
|
MsgBoxEx.MessageBoxEx.MsgFontFamily = new FontFamily("Consolas");
|
||||||
Msg.ShowInfo(text);
|
Msg.ShowInfo(text);
|
||||||
MsgBoxEx.MessageBoxEx.MsgFontFamily = new FontFamily("Segoe UI");
|
MsgBoxEx.MessageBoxEx.MsgFontFamily = new FontFamily("Segoe UI");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
public static void ShowCommandPalette() => App.InvokeOnMainThread(() =>
|
public static void ShowCommandPalette() => App.InvokeOnMainThread(() =>
|
||||||
{
|
{
|
||||||
@@ -636,13 +659,13 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static void ShowSetupDialog() => App.InvokeOnMainThread(() =>
|
public static void ShowSetupDialog() => App.InvokeOnMainThread(() =>
|
||||||
{
|
{
|
||||||
(string, string)[] pairs = {
|
(string Name, string Value)[] pairs = {
|
||||||
("Register video file associations", "script-message mpv.net reg-file-assoc video"),
|
("Register video file associations", "script-message mpv.net reg-file-assoc video"),
|
||||||
("Register audio file associations", "script-message mpv.net reg-file-assoc audio"),
|
("Register audio file associations", "script-message mpv.net reg-file-assoc audio"),
|
||||||
("Register image file associations", "script-message mpv.net reg-file-assoc image"),
|
("Register image file associations", "script-message mpv.net reg-file-assoc image"),
|
||||||
("Unregister file associations", "script-message mpv.net reg-file-assoc unreg") };
|
("Unregister file associations", "script-message mpv.net reg-file-assoc unreg") };
|
||||||
|
|
||||||
var list = pairs.Select(i => new CommandPaletteItem(i.Item1, () => Core.Command(i.Item2)));
|
var list = pairs.Select(i => new CommandPaletteItem(i.Name, () => Core.Command(i.Value)));
|
||||||
CommandPalette.Instance.SetItems(list);
|
CommandPalette.Instance.SetItems(list);
|
||||||
MainForm.Instance.ShowCommandPalette();
|
MainForm.Instance.ShowCommandPalette();
|
||||||
CommandPalette.Instance.SelectFirst();
|
CommandPalette.Instance.SelectFirst();
|
||||||
|
|||||||
@@ -166,6 +166,14 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Alias {
|
||||||
|
get {
|
||||||
|
if (Input.Contains("SHARP") || Input.Contains("sharp") || Input.Contains("Sharp"))
|
||||||
|
return "#";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static ObservableCollection<CommandItem> GetItems(string content)
|
public static ObservableCollection<CommandItem> GetItems(string content)
|
||||||
{
|
{
|
||||||
var items = new ObservableCollection<CommandItem>();
|
var items = new ObservableCollection<CommandItem>();
|
||||||
|
|||||||
@@ -90,11 +90,20 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
string filter = SearchControl.SearchTextBox.Text.ToLower();
|
string filter = SearchControl.SearchTextBox.Text.ToLower();
|
||||||
|
|
||||||
if (filter.Length == 1 && item.CommandItem != null)
|
if (item.CommandItem != null)
|
||||||
|
{
|
||||||
|
if (item.CommandItem.Alias.ContainsEx(filter))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (filter.Length == 1)
|
||||||
return item.CommandItem.Input.ToLower().Replace("ctrl+", "")
|
return item.CommandItem.Input.ToLower().Replace("ctrl+", "")
|
||||||
.Replace("shift+", "")
|
.Replace("shift+", "")
|
||||||
.Replace("alt+", "") == filter.ToLower();
|
.Replace("alt+", "") == filter.ToLower();
|
||||||
|
|
||||||
|
if (item.CommandItem.Command.ToLower().Contains(filter))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (filter == "" || item.Text.ToLower().Contains(filter) ||
|
if (filter == "" || item.Text.ToLower().Contains(filter) ||
|
||||||
item.SecondaryText.ToLower().Contains(filter))
|
item.SecondaryText.ToLower().Contains(filter))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user