fancy new command palette

This commit is contained in:
Frank Skare
2021-06-22 20:54:14 +02:00
parent bac8b2b96c
commit 55f16d2c53
19 changed files with 69 additions and 305 deletions

View File

@@ -2,9 +2,13 @@
5.4.9.1 (2021-0?-??) 5.4.9.1 (2021-0?-??)
==================== ====================
- Everything search removed to keep the core player lightweight,
it might come back as user script or extension.
- Fancy new command palette implementation, it's now integrated into the main window.
- Playlist is now shown with the new command palette and not using the OSD.
- New media info command: `Ctrl+m script-message mpv.net show-media-info #menu: View > Show Media Info` - New media info command: `Ctrl+m script-message mpv.net show-media-info #menu: View > Show Media Info`
- Context menu font render quality fix. - Context menu font render quality fix.
- Context menu and `cycle-audio` command support external audio and subtitle tracks. - Context menu and `cycle-audio` command supports external audio and subtitle tracks.
- Fix window size not being saved. - Fix window size not being saved.
- libmpv shinchiro 2021-06-06 - libmpv shinchiro 2021-06-06

View File

@@ -29,9 +29,7 @@ namespace DynamicGUI
Link.SetURL(optionSetting.URL); Link.SetURL(optionSetting.URL);
} }
public Theme Theme { public Theme Theme => Theme.Current;
get => Theme.Current;
}
string _SearchableText; string _SearchableText;

View File

@@ -35,9 +35,7 @@ namespace DynamicGUI
LinkTextBlock.Visibility = Visibility.Collapsed; LinkTextBlock.Visibility = Visibility.Collapsed;
} }
public Theme Theme { public Theme Theme => Theme.Current;
get => Theme.Current;
}
string _SearchableText; string _SearchableText;

View File

@@ -12,8 +12,6 @@ namespace mpvnet
{ {
public static class App public static class App
{ {
public static event Action ShowCommandPalette;
public static List<string> TempFiles { get; } = new List<string>(); public static List<string> TempFiles { get; } = new List<string>();
public static string ConfPath { get => Core.ConfigFolder + "mpvnet.conf"; } public static string ConfPath { get => Core.ConfigFolder + "mpvnet.conf"; }

View File

@@ -44,7 +44,6 @@ namespace mpvnet
case "show-input-editor": ShowDialog(typeof(InputWindow)); break; case "show-input-editor": ShowDialog(typeof(InputWindow)); break;
case "show-keys": ShowTextWithEditor("input-key-list", Core.get_property_string("input-key-list").Replace(",", BR)); break; case "show-keys": ShowTextWithEditor("input-key-list", Core.get_property_string("input-key-list").Replace(",", BR)); break;
case "show-media-info": ShowMediaInfo(args); break; case "show-media-info": ShowMediaInfo(args); break;
case "show-media-search": ShowDialog(typeof(EverythingWindow)); break;
case "show-playlist": ShowPlaylist(); break; case "show-playlist": ShowPlaylist(); break;
case "show-profiles": ShowTextWithEditor("profile-list", mpvHelp.GetProfiles()); break; case "show-profiles": ShowTextWithEditor("profile-list", mpvHelp.GetProfiles()); break;
case "show-properties": ShowProperties(); break; case "show-properties": ShowProperties(); break;

View File

@@ -388,7 +388,7 @@ namespace mpvnet
if (LogMessage != null || LogMessageAsync != null) if (LogMessage != null || LogMessageAsync != null)
{ {
string msg = $"[{ConvertFromUtf8(data.prefix)}] {ConvertFromUtf8(data.text)}"; string msg = $"[{ConvertFromUtf8(data.prefix)}] {ConvertFromUtf8(data.text)}";
InvokeAsync<mpv_log_level, string>(LogMessageAsync, data.log_level, msg); InvokeAsync(LogMessageAsync, data.log_level, msg);
LogMessage?.Invoke(data.log_level, msg); LogMessage?.Invoke(data.log_level, msg);
} }
} }

View File

@@ -242,7 +242,14 @@ namespace mpvnet
public static IEnumerable<CommandPaletteItem> GetItems() public static IEnumerable<CommandPaletteItem> GetItems()
{ {
return CommandItem.Items.Select(i => new CommandPaletteItem() { Text = i.Display, SecondaryText = i.Input }); var aaa = CommandItem.Items.ToArray();
return CommandItem.Items
.Where(i => i.Command != "")
.Select(i => new CommandPaletteItem() {
Text = i.Display,
SecondaryText = i.Input,
Action = () => Core.command(i.Command)
});
} }
} }
} }

View File

@@ -34,7 +34,6 @@
Alt+s script-message mpv.net load-sub #menu: Open > Load external subtitle files... Alt+s script-message mpv.net load-sub #menu: Open > Load external subtitle files...
_ ignore #menu: Open > - _ ignore #menu: Open > -
_ script-message mpv.net open-files append #menu: Open > Add files to playlist... _ script-message mpv.net open-files append #menu: Open > Add files to playlist...
F3 script-message mpv.net show-media-search #menu: Open > Show media search...
_ ignore #menu: Open > - _ ignore #menu: Open > -
_ ignore #menu: Open > Recent _ ignore #menu: Open > Recent

View File

@@ -16,8 +16,6 @@ namespace mpvnet
protected override void OnPreviewKeyDown(KeyEventArgs e) => Close(); protected override void OnPreviewKeyDown(KeyEventArgs e) => Close();
protected override void OnMouseDown(MouseButtonEventArgs e) => Close(); protected override void OnMouseDown(MouseButtonEventArgs e) => Close();
public Theme Theme { public Theme Theme => Theme.Current;
get => Theme.Current;
}
} }
} }

View File

@@ -13,7 +13,8 @@
> >
<UserControl.InputBindings> <UserControl.InputBindings>
<KeyBinding Gesture="Esc" Command="{Binding EscapeCommand}"/> <KeyBinding Gesture="Esc" Command="{Binding EscapeCommand}"/>
<KeyBinding Gesture="Enter" Command="{Binding ExecuteCommand}"/>
</UserControl.InputBindings> </UserControl.InputBindings>
<Grid> <Grid>

View File

@@ -14,6 +14,7 @@ namespace mpvnet
{ {
public ICollectionView CollectionView { get; set; } public ICollectionView CollectionView { get; set; }
public ICommand EscapeCommand { get; } public ICommand EscapeCommand { get; }
public ICommand ExecuteCommand { get; }
public CollectionViewSource CollectionViewSource { get; } public CollectionViewSource CollectionViewSource { get; }
public ObservableCollection<CommandPaletteItem> Items { get; } = new ObservableCollection<CommandPaletteItem>(); public ObservableCollection<CommandPaletteItem> Items { get; } = new ObservableCollection<CommandPaletteItem>();
@@ -27,7 +28,8 @@ namespace mpvnet
MainListView.ItemsSource = CollectionView; MainListView.ItemsSource = CollectionView;
EscapeCommand = new RelayCommand(OnEscapeCommand); EscapeCommand = new RelayCommand(OnEscapeCommand);
SearchControl.SearchTextBox.PreviewKeyDown += SearchControl_PreviewKeyDown; ExecuteCommand = new RelayCommand(OnExecuteCommand);
SearchControl.SearchTextBox.PreviewKeyDown += SearchTextBox_PreviewKeyDown;
SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged; SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged;
SearchControl.SearchTextBox.BorderBrush = Theme.Background; SearchControl.SearchTextBox.BorderBrush = Theme.Background;
SearchControl.HideClearButton = true; SearchControl.HideClearButton = true;
@@ -39,7 +41,7 @@ namespace mpvnet
SelectFirst(); SelectFirst();
} }
void SearchControl_PreviewKeyDown(object sender, KeyEventArgs e) void SearchTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
{ {
switch (e.Key) switch (e.Key)
{ {
@@ -66,16 +68,18 @@ namespace mpvnet
MainListView.ScrollIntoView(MainListView.SelectedItem); MainListView.ScrollIntoView(MainListView.SelectedItem);
} }
break; break;
case Key.Enter:
Execute();
break;
} }
} }
void OnEscapeCommand(object param) void MainListView_SizeChanged(object sender, SizeChangedEventArgs e) => AdjustHeight();
{
MainForm.Instance.HideCommandPalette(); void MainListView_MouseUp(object sender, MouseButtonEventArgs e) => Execute();
}
void OnEscapeCommand(object param) => MainForm.Instance.HideCommandPalette();
void OnExecuteCommand(object param) => Execute();
void OnLoaded(object sender, RoutedEventArgs e) => Keyboard.Focus(SearchControl.SearchTextBox);
public Theme Theme => Theme.Current; public Theme Theme => Theme.Current;
@@ -94,7 +98,10 @@ namespace mpvnet
public void SelectFirst() public void SelectFirst()
{ {
if (MainListView.Items.Count > 0) if (MainListView.Items.Count > 0)
{
MainListView.SelectedIndex = 0; MainListView.SelectedIndex = 0;
MainListView.ScrollIntoView(MainListView.SelectedItem);
}
} }
void Execute() void Execute()
@@ -104,14 +111,10 @@ namespace mpvnet
CommandPaletteItem item = MainListView.SelectedItem as CommandPaletteItem; CommandPaletteItem item = MainListView.SelectedItem as CommandPaletteItem;
MainForm.Instance.HideCommandPalette(); MainForm.Instance.HideCommandPalette();
item.Action.Invoke(); item.Action.Invoke();
MainForm.Instance.Voodoo();
} }
} }
void OnLoaded(object sender, RoutedEventArgs e)
{
Keyboard.Focus(SearchControl.SearchTextBox);
}
public void SetItems(IEnumerable<CommandPaletteItem> items) public void SetItems(IEnumerable<CommandPaletteItem> items)
{ {
Items.Clear(); Items.Clear();
@@ -120,21 +123,11 @@ namespace mpvnet
Items.Add(i); Items.Add(i);
} }
void MainListView_SizeChanged(object sender, SizeChangedEventArgs e)
{
AdjustHeight();
}
public void AdjustHeight() public void AdjustHeight()
{ {
double actualHeight = SearchControl.ActualHeight + MainListView.ActualHeight; double actualHeight = SearchControl.ActualHeight + MainListView.ActualHeight;
int dpi = Native.GetDPI(MainForm.Instance.Handle); int dpi = Native.GetDPI(MainForm.Instance.Handle);
MainForm.Instance.CommandPaletteHost.Height = (int)(actualHeight / 96.0 * dpi); MainForm.Instance.CommandPaletteHost.Height = (int)(actualHeight / 96.0 * dpi);
} }
void MainListView_MouseUp(object sender, MouseButtonEventArgs e)
{
Execute();
}
} }
} }

View File

@@ -35,9 +35,7 @@ namespace mpvnet
FilterListBox.SelectedItem = SearchControl.Text.TrimEnd(':'); FilterListBox.SelectedItem = SearchControl.Text.TrimEnd(':');
} }
public Theme Theme { public Theme Theme => Theme.Current;
get => Theme.Current;
}
void LoadSettings() void LoadSettings()
{ {
@@ -75,10 +73,10 @@ namespace mpvnet
{ {
base.OnClosed(e); base.OnClosed(e);
App.Settings.ConfigEditorSearch = SearchControl.Text; App.Settings.ConfigEditorSearch = SearchControl.Text;
if (InitialContent == GetCompareString()) if (InitialContent == GetCompareString())
return; return;
File.WriteAllText(Core.ConfPath, GetContent("mpv")); File.WriteAllText(Core.ConfPath, GetContent("mpv"));
File.WriteAllText(App.ConfPath, GetContent("mpvnet")); File.WriteAllText(App.ConfPath, GetContent("mpvnet"));
@@ -89,7 +87,7 @@ namespace mpvnet
if (item.File == "mpv") if (item.File == "mpv")
{ {
Core.ProcessProperty(item.Name, item.Value); Core.ProcessProperty(item.Name, item.Value);
try try
{ {
Core.set_property_string(item.Name, item.Value, true); Core.set_property_string(item.Name, item.Value, true);

View File

@@ -1,49 +0,0 @@
<Window
x:Class="mpvnet.EverythingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Media File Search"
FontSize="13"
Height="300"
Width="600"
ResizeMode="NoResize"
WindowStartupLocation="CenterOwner"
Loaded="Window_Loaded"
>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBox
Name="FilterTextBox"
Foreground="{Binding Theme.Foreground}"
Background="{Binding Theme.Background}"
PreviewKeyDown="FilterTextBox_PreviewKeyDown"
TextChanged="FilterTextBox_TextChanged"
/>
<ListView
Name="ListView"
Foreground="{Binding Theme.Foreground}"
Background="{Binding Theme.Background}"
Grid.Row="1"
MouseUp="ListView_MouseUp"
PreviewKeyDown="ListView_PreviewKeyDown"
>
<ListView.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</Grid>
</Window>

View File

@@ -1,169 +0,0 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using static mpvnet.Global;
namespace mpvnet
{
public partial class EverythingWindow : Window
{
public EverythingWindow()
{
InitializeComponent();
DataContext = this;
}
public Theme Theme {
get => Theme.Current;
}
const int EVERYTHING_REQUEST_FILE_NAME = 0x00000001;
const int EVERYTHING_REQUEST_PATH = 0x00000002;
[DllImport("Everything.dll", CharSet = CharSet.Unicode)]
public static extern int Everything_SetSearch(string lpSearchString);
[DllImport("Everything.dll")]
public static extern void Everything_SetRequestFlags(UInt32 dwRequestFlags);
[DllImport("Everything.dll")]
public static extern void Everything_SetSort(UInt32 dwSortType);
[DllImport("Everything.dll", CharSet = CharSet.Unicode)]
public static extern bool Everything_Query(bool bWait);
[DllImport("Everything.dll", CharSet = CharSet.Unicode)]
public static extern void Everything_GetResultFullPathName(UInt32 nIndex, StringBuilder lpString, UInt32 nMaxCount);
[DllImport("Everything.dll")]
public static extern bool Everything_GetResultSize(UInt32 nIndex, out long lpFileSize);
[DllImport("Everything.dll")]
public static extern UInt32 Everything_GetNumResults();
void Window_Loaded(object sender, RoutedEventArgs e)
{
HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
source.AddHook(new HwndSourceHook(WndProc));
Keyboard.Focus(FilterTextBox);
}
void SelectFirst()
{
if (ListView.Items.Count > 0)
ListView.SelectedIndex = 0;
}
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (msg == 0x200 /*WM_MOUSEMOVE*/ && Mouse.LeftButton != MouseButtonState.Pressed)
handled = true;
return IntPtr.Zero;
}
void FilterTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
switch (e.Key)
{
case Key.Up:
{
int index = ListView.SelectedIndex;
if (--index < 0)
index = 0;
ListView.SelectedIndex = index;
ListView.ScrollIntoView(ListView.SelectedItem);
}
break;
case Key.Down:
{
int index = ListView.SelectedIndex;
if (++index > ListView.Items.Count - 1)
index = ListView.Items.Count - 1;
ListView.SelectedIndex = index;
ListView.ScrollIntoView(ListView.SelectedItem);
}
break;
case Key.Escape: Close(); break;
case Key.Enter: Execute(); break;
}
}
void ListView_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
Close();
if (e.Key == Key.Enter)
Execute();
}
void Execute()
{
if (ListView.SelectedItem != null)
Core.LoadFiles(new[] { ListView.SelectedItem as string }, true, Keyboard.Modifiers == ModifierKeys.Control);
Keyboard.Focus(FilterTextBox);
}
void ListView_MouseUp(object sender, MouseButtonEventArgs e) => Execute();
void FilterTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
string searchtext = FilterTextBox.Text;
App.RunTask(() => Search(searchtext));
}
object LockObject = new object();
void Search(string searchText)
{
lock (LockObject)
{
try
{
List<string> items = new List<string>();
StringBuilder sb = new StringBuilder(500);
Everything_SetSearch(searchText);
Everything_SetRequestFlags(EVERYTHING_REQUEST_FILE_NAME | EVERYTHING_REQUEST_PATH);
Everything_Query(true);
uint count = Everything_GetNumResults();
for (uint i = 0; i < count; i++)
{
Everything_GetResultFullPathName(i, sb, (uint)sb.Capacity);
string ext = sb.ToString().Ext();
if (CorePlayer.AudioTypes.Contains(ext) || CorePlayer.VideoTypes.Contains(ext) || CorePlayer.ImageTypes.Contains(ext))
items.Add(sb.ToString());
if (items.Count > 100)
break;
}
Application.Current.Dispatcher.Invoke(() => {
ListView.ItemsSource = items;
SelectFirst();
});
}
catch (Exception)
{
Msg.ShowError("Search query failed.",
"The search feature depends on [Everything](https://www.voidtools.com) being installed.");
}
}
}
}
}

View File

@@ -26,14 +26,11 @@ namespace mpvnet
DataGrid.SelectionMode = DataGridSelectionMode.Single; DataGrid.SelectionMode = DataGridSelectionMode.Single;
CollectionViewSource collectionViewSource = new CollectionViewSource() { Source = CommandItem.Items }; CollectionViewSource collectionViewSource = new CollectionViewSource() { Source = CommandItem.Items };
CollectionView = collectionViewSource.View; CollectionView = collectionViewSource.View;
var yourCostumFilter = new Predicate<object>(item => Filter((CommandItem)item)); CollectionView.Filter = new Predicate<object>(item => Filter((CommandItem)item));
CollectionView.Filter = yourCostumFilter;
DataGrid.ItemsSource = CollectionView; DataGrid.ItemsSource = CollectionView;
} }
public Theme Theme { public Theme Theme => Theme.Current;
get => Theme.Current;
}
void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e) void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
{ {

View File

@@ -30,9 +30,7 @@ namespace mpvnet
DataContext = this; DataContext = this;
} }
public Theme Theme { public Theme Theme => Theme.Current;
get => Theme.Current;
}
[DllImport("user32.dll", CharSet = CharSet.Auto)] [DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern short GetKeyState(int keyCode); static extern short GetKeyState(int keyCode);

View File

@@ -19,9 +19,7 @@ namespace mpvnet
DataContext = this; DataContext = this;
} }
public Theme Theme { public Theme Theme => Theme.Current;
get => Theme.Current;
}
static BitmapSource _ShieldIcon; static BitmapSource _ShieldIcon;
@@ -45,7 +43,7 @@ namespace mpvnet
using (Process proc = new Process()) using (Process proc = new Process())
{ {
proc.StartInfo.FileName = WinForms.Application.ExecutablePath; proc.StartInfo.FileName = WinForms.Application.ExecutablePath;
proc.StartInfo.Arguments = "--reg-file-assoc " + String.Join(" ", extensions); proc.StartInfo.Arguments = "--reg-file-assoc " + string.Join(" ", extensions);
proc.StartInfo.Verb = "runas"; proc.StartInfo.Verb = "runas";
proc.StartInfo.UseShellExecute = true; proc.StartInfo.UseShellExecute = true;
proc.Start(); proc.Start();

View File

@@ -29,7 +29,7 @@ namespace mpvnet
int TaskbarButtonCreatedMessage; int TaskbarButtonCreatedMessage;
int ShownTickCount; int ShownTickCount;
Taskbar Taskbar; Taskbar Taskbar;
bool WasMaximized; bool WasMaximized;
public MainForm() public MainForm()
@@ -52,7 +52,7 @@ namespace mpvnet
Core.observe_property("window-maximized", PropChangeWindowMaximized); Core.observe_property("window-maximized", PropChangeWindowMaximized);
Core.observe_property("window-minimized", PropChangeWindowMinimized); Core.observe_property("window-minimized", PropChangeWindowMinimized);
Core.observe_property_bool("pause", PropChangePause); Core.observe_property_bool("pause", PropChangePause);
Core.observe_property_bool("fullscreen", PropChangeFullscreen); Core.observe_property_bool("fullscreen", PropChangeFullscreen);
Core.observe_property_bool("ontop", PropChangeOnTop); Core.observe_property_bool("ontop", PropChangeOnTop);
@@ -65,7 +65,7 @@ namespace mpvnet
Core.observe_property_string("title", PropChangeTitle); Core.observe_property_string("title", PropChangeTitle);
Core.observe_property_int("edition", PropChangeEdition); Core.observe_property_int("edition", PropChangeEdition);
if (Core.GPUAPI != "vulkan") if (Core.GPUAPI != "vulkan")
Core.ProcessCommandLine(false); Core.ProcessCommandLine(false);
@@ -73,7 +73,7 @@ namespace mpvnet
Application.ThreadException += (sender, e) => App.ShowException(e.Exception); Application.ThreadException += (sender, e) => App.ShowException(e.Exception);
TaskbarButtonCreatedMessage = RegisterWindowMessage("TaskbarButtonCreated"); TaskbarButtonCreatedMessage = RegisterWindowMessage("TaskbarButtonCreated");
ContextMenu = new ContextMenuStripEx(components); ContextMenu = new ContextMenuStripEx(components);
ContextMenu.Opened += ContextMenu_Opened; ContextMenu.Opened += ContextMenu_Opened;
ContextMenu.Opening += ContextMenu_Opening; ContextMenu.Opening += ContextMenu_Opening;
@@ -99,7 +99,7 @@ namespace mpvnet
FormBorderStyle = FormBorderStyle.None; FormBorderStyle = FormBorderStyle.None;
Point pos = App.Settings.WindowPosition; Point pos = App.Settings.WindowPosition;
if ((pos.X != 0 || pos.Y != 0) && App.RememberWindowPosition) if ((pos.X != 0 || pos.Y != 0) && App.RememberWindowPosition)
{ {
Left = pos.X - Width / 2; Left = pos.X - Width / 2;
@@ -168,6 +168,8 @@ namespace mpvnet
bool IsFullscreen => WindowState == FormWindowState.Maximized && FormBorderStyle == FormBorderStyle.None; bool IsFullscreen => WindowState == FormWindowState.Maximized && FormBorderStyle == FormBorderStyle.None;
bool IsCommandPaletteVissible() => CommandPaletteHost != null && CommandPaletteHost.Visible;
bool IsMouseInOSC() bool IsMouseInOSC()
{ {
Point pos = PointToClient(MousePosition); Point pos = PointToClient(MousePosition);
@@ -179,8 +181,6 @@ namespace mpvnet
return pos.Y > ClientSize.Height * 0.85 || pos.Y < top; return pos.Y > ClientSize.Height * 0.85 || pos.Y < top;
} }
bool IsCommandPaletteVissible() => CommandPaletteHost != null && CommandPaletteHost.Visible;
void ContextMenu_Opening(object sender, CancelEventArgs e) void ContextMenu_Opening(object sender, CancelEventArgs e)
{ {
lock (Core.MediaTracks) lock (Core.MediaTracks)
@@ -273,7 +273,7 @@ namespace mpvnet
foreach (string path in App.Settings.RecentFiles) foreach (string path in App.Settings.RecentFiles)
MenuItem.Add(recent.DropDownItems, path, () => Core.LoadFiles(new[] { path }, true, Control.ModifierKeys.HasFlag(Keys.Control))); MenuItem.Add(recent.DropDownItems, path, () => Core.LoadFiles(new[] { path }, true, Control.ModifierKeys.HasFlag(Keys.Control)));
recent.DropDownItems.Add(new ToolStripSeparator()); recent.DropDownItems.Add(new ToolStripSeparator());
MenuItem mi = new MenuItem("Clear List"); MenuItem mi = new MenuItem("Clear List");
mi.Action = () => App.Settings.RecentFiles.Clear(); mi.Action = () => App.Settings.RecentFiles.Clear();
@@ -316,7 +316,7 @@ namespace mpvnet
if (mi.DropDownItems.Count > 0) if (mi.DropDownItems.Count > 0)
{ {
MenuItem val = FindMenuItem(text, mi.DropDownItems); MenuItem val = FindMenuItem(text, mi.DropDownItems);
if (val != null) if (val != null)
return val; return val;
} }
@@ -338,7 +338,7 @@ namespace mpvnet
return; return;
} }
} }
Screen screen = Screen.FromControl(this); Screen screen = Screen.FromControl(this);
int autoFitHeight = Convert.ToInt32(screen.WorkingArea.Height * Core.Autofit); int autoFitHeight = Convert.ToInt32(screen.WorkingArea.Height * Core.Autofit);
@@ -348,7 +348,7 @@ namespace mpvnet
Core.VideoSize = new Size((int)(autoFitHeight * (16 / 9f)), autoFitHeight); Core.VideoSize = new Size((int)(autoFitHeight * (16 / 9f)), autoFitHeight);
Size videoSize = Core.VideoSize; Size videoSize = Core.VideoSize;
int height = videoSize.Height; int height = videoSize.Height;
int width = videoSize.Width; int width = videoSize.Width;
@@ -626,6 +626,12 @@ namespace mpvnet
void SetTitle() => BeginInvoke(new Action(() => Text = Core.expand(Title))); void SetTitle() => BeginInvoke(new Action(() => Text = Core.expand(Title)));
public void Voodoo()
{
Message m = new Message() { Msg = 0x0202 }; // WM_LBUTTONUP
SendMessage(Handle, m.Msg, m.WParam, m.LParam);
}
void SaveWindowProperties() void SaveWindowProperties()
{ {
if (WindowState == FormWindowState.Normal) if (WindowState == FormWindowState.Normal)
@@ -677,8 +683,6 @@ namespace mpvnet
protected override void WndProc(ref Message m) protected override void WndProc(ref Message m)
{ {
//Debug.WriteLine(m);
switch (m.Msg) switch (m.Msg)
{ {
case 0x100: // WM_KEYDOWN case 0x100: // WM_KEYDOWN
@@ -916,8 +920,7 @@ namespace mpvnet
protected override void OnActivated(EventArgs e) protected override void OnActivated(EventArgs e)
{ {
base.OnActivated(e); base.OnActivated(e);
Message m = new Message() { Msg = 0x0202 }; // WM_LBUTTONUP Voodoo();
SendMessage(Handle, m.Msg, m.WParam, m.LParam);
} }
protected override void OnShown(EventArgs e) protected override void OnShown(EventArgs e)
@@ -1044,6 +1047,12 @@ namespace mpvnet
base.OnKeyDown(e); base.OnKeyDown(e);
} }
protected override void OnLayout(LayoutEventArgs args)
{
base.OnLayout(args);
AdjustCommandPaletteLeftAndWidth();
}
public void ShowCommandPalette() public void ShowCommandPalette()
{ {
if (CommandPaletteHost == null) if (CommandPaletteHost == null)
@@ -1082,11 +1091,5 @@ namespace mpvnet
CommandPaletteHost.Left = (ClientSize.Width - CommandPaletteHost.Size.Width) / 2; CommandPaletteHost.Left = (ClientSize.Width - CommandPaletteHost.Size.Width) / 2;
} }
protected override void OnLayout(LayoutEventArgs args)
{
base.OnLayout(args);
AdjustCommandPaletteLeftAndWidth();
}
} }
} }

View File

@@ -104,10 +104,6 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="WPF\EverythingWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="WPF\Resources.xaml"> <Page Include="WPF\Resources.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -163,9 +159,6 @@
<Compile Include="WPF\SetupWindow.xaml.cs"> <Compile Include="WPF\SetupWindow.xaml.cs">
<DependentUpon>SetupWindow.xaml</DependentUpon> <DependentUpon>SetupWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="WPF\EverythingWindow.xaml.cs">
<DependentUpon>EverythingWindow.xaml</DependentUpon>
</Compile>
<Compile Include="WPF\ConfWindow.xaml.cs"> <Compile Include="WPF\ConfWindow.xaml.cs">
<DependentUpon>ConfWindow.xaml</DependentUpon> <DependentUpon>ConfWindow.xaml</DependentUpon>
</Compile> </Compile>