2 bugs fixed
This commit is contained in:
@@ -2,7 +2,8 @@
|
|||||||
5.4.7.5 Beta (not yet released)
|
5.4.7.5 Beta (not yet released)
|
||||||
============
|
============
|
||||||
|
|
||||||
|
- fix in the learn window of input editor, whole day spent :-(
|
||||||
|
- fix black one pixel bar on right side by truncating instead of rounding
|
||||||
|
|
||||||
|
|
||||||
5.4.7.4 Beta (not yet released)
|
5.4.7.4 Beta (not yet released)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace mpvnet
|
namespace mpvnet
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,8 +16,7 @@
|
|||||||
Background="{x:Static mpvnet:Theme.Background}"
|
Background="{x:Static mpvnet:Theme.Background}"
|
||||||
MouseWheel="Window_MouseWheel"
|
MouseWheel="Window_MouseWheel"
|
||||||
MouseUp="Window_MouseUp"
|
MouseUp="Window_MouseUp"
|
||||||
MouseDoubleClick="Window_MouseDoubleClick"
|
MouseDoubleClick="Window_MouseDoubleClick" PreviewKeyDown="Window_PreviewKeyDown">
|
||||||
TextInput="Window_TextInput">
|
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
|
using System.Windows.Forms;
|
||||||
using WinForms = System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace mpvnet
|
namespace mpvnet
|
||||||
{
|
{
|
||||||
@@ -14,13 +14,68 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
public CommandItem InputItem { get; set; }
|
public CommandItem InputItem { get; set; }
|
||||||
string NewKey = "";
|
string NewKey = "";
|
||||||
string KeyChar = "";
|
|
||||||
|
uint MAPVK_VK_TO_VSC = 0;
|
||||||
|
|
||||||
|
int VK_MENU = 0x12;
|
||||||
|
int VK_LMENU = 0xA4;
|
||||||
|
int VK_RMENU = 0xA5;
|
||||||
|
|
||||||
|
int VK_CONTROL = 0x11;
|
||||||
|
int VK_LCONTROL = 0xA2;
|
||||||
|
int VK_RCONTROL = 0xA3;
|
||||||
|
|
||||||
public LearnWindow() => InitializeComponent();
|
public LearnWindow() => InitializeComponent();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||||
|
static extern short GetKeyState(int keyCode);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
static extern uint MapVirtualKey(uint uCode, uint uMapType);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||||
|
static extern int ToUnicode(uint wVirtKey, uint wScanCode, byte[] lpKeyState,
|
||||||
|
StringBuilder pwszBuff, int cchBuff, uint wFlags);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
static extern bool GetKeyboardState(byte[] lpKeyState);
|
||||||
|
|
||||||
|
string ToUnicode(uint vk)
|
||||||
|
{
|
||||||
|
byte[] keys = new byte[256];
|
||||||
|
|
||||||
|
if (!GetKeyboardState(keys))
|
||||||
|
return "";
|
||||||
|
|
||||||
|
if ((keys[VK_CONTROL] & 0x80) != 0 && (keys[VK_MENU] & 0x80) == 0)
|
||||||
|
keys[VK_LCONTROL] = keys[VK_RCONTROL] = keys[VK_CONTROL] = 0;
|
||||||
|
|
||||||
|
uint scanCode = MapVirtualKey(vk, MAPVK_VK_TO_VSC);
|
||||||
|
|
||||||
|
string ret = ToUnicode(vk, scanCode, keys);
|
||||||
|
|
||||||
|
if (ret.Length == 1 && (int)ret[0] < 32)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
if (ret == "" && (keys[VK_MENU] & 0x80) != 0)
|
||||||
|
{
|
||||||
|
keys[VK_LMENU] = keys[VK_RMENU] = keys[VK_MENU] = 0;
|
||||||
|
ret = ToUnicode(vk, scanCode, keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ToUnicode(uint vk, uint scanCode, byte[] keys)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder(10);
|
||||||
|
ToUnicode(vk, scanCode, keys, sb, sb.Capacity, 0);
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||||
{
|
{
|
||||||
WinForms.Message m = new WinForms.Message();
|
Message m = new Message();
|
||||||
m.HWnd = hwnd;
|
m.HWnd = hwnd;
|
||||||
m.Msg = msg;
|
m.Msg = msg;
|
||||||
m.WParam = wParam;
|
m.WParam = wParam;
|
||||||
@@ -29,116 +84,86 @@ namespace mpvnet
|
|||||||
return m.Result;
|
return m.Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnKeyUp(WinForms.KeyEventArgs e)
|
void OnKeyDown(uint vk)
|
||||||
{
|
{
|
||||||
if (e.KeyCode == WinForms.Keys.ControlKey || e.KeyCode == WinForms.Keys.ShiftKey ||
|
Keys key = (Keys)vk;
|
||||||
e.KeyCode == WinForms.Keys.Menu || e.KeyCode == WinForms.Keys.None)
|
|
||||||
|
if (key == Keys.ControlKey || key == Keys.ShiftKey ||
|
||||||
|
key == Keys.Menu || key == Keys.None)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string text = "";
|
string text = ToUnicode(vk);
|
||||||
uint charValue = MapVirtualKey((uint)e.KeyCode, 2);
|
|
||||||
|
|
||||||
if (charValue == 0 || (charValue & 1 << 31) == 1 << 31)
|
if ((int)key > 111 && (int)key < 136)
|
||||||
text = e.KeyCode.ToString().Trim();
|
text = "F" + ((int)key - 111);
|
||||||
else
|
|
||||||
try {
|
|
||||||
text = Convert.ToChar(charValue).ToString().ToLower().Trim();
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
for (int i = 0; i < 13; i++)
|
if ((int)key > 95 && (int)key < 106)
|
||||||
if ("D" + i == text)
|
text = "KP" + ((int)key - 96);
|
||||||
text = text.Substring(1);
|
|
||||||
|
|
||||||
switch (e.KeyCode)
|
switch (text)
|
||||||
{
|
{
|
||||||
case WinForms.Keys.NumPad0:
|
case "#": text = "SHARP"; break;
|
||||||
case WinForms.Keys.NumPad1:
|
case "´´": text = "´"; break;
|
||||||
case WinForms.Keys.NumPad2:
|
case "``": text = "`"; break;
|
||||||
case WinForms.Keys.NumPad3:
|
case "^^": text = "^"; break;
|
||||||
case WinForms.Keys.NumPad4:
|
}
|
||||||
case WinForms.Keys.NumPad5:
|
|
||||||
case WinForms.Keys.NumPad6:
|
switch (key)
|
||||||
case WinForms.Keys.NumPad7:
|
{
|
||||||
case WinForms.Keys.NumPad8:
|
case Keys.Left: text = "LEFT"; break;
|
||||||
case WinForms.Keys.NumPad9:
|
case Keys.Up: text = "UP"; break;
|
||||||
text = "KP" + e.KeyCode.ToString()[6]; break;
|
case Keys.Right: text = "RIGHT"; break;
|
||||||
case WinForms.Keys.Space:
|
case Keys.Down: text = "DOWN"; break;
|
||||||
text = "SPACE"; break;
|
case Keys.Space: text = "SPACE"; break;
|
||||||
case WinForms.Keys.Enter:
|
case Keys.Enter: text = "ENTER"; break;
|
||||||
text = "ENTER"; break;
|
case Keys.Tab: text = "TAB"; break;
|
||||||
case WinForms.Keys.Tab:
|
case Keys.Back: text = "BS"; break;
|
||||||
text = "TAB"; break;
|
case Keys.Delete: text = "DEL"; break;
|
||||||
case WinForms.Keys.Back:
|
case Keys.Insert: text = "INS"; break;
|
||||||
text = "BS"; break;
|
case Keys.Home: text = "HOME"; break;
|
||||||
case WinForms.Keys.Delete:
|
case Keys.End: text = "END"; break;
|
||||||
text = "DEL"; break;
|
case Keys.PageUp: text = "PGUP"; break;
|
||||||
case WinForms.Keys.Insert:
|
case Keys.PageDown: text = "PGDWN"; break;
|
||||||
text = "INS"; break;
|
case Keys.Escape: text = "ESC"; break;
|
||||||
case WinForms.Keys.Home:
|
case Keys.Sleep: text = "SLEEP"; break;
|
||||||
text = "HOME"; break;
|
case Keys.Cancel: text = "CANCEL"; break;
|
||||||
case WinForms.Keys.End:
|
case Keys.PrintScreen: text = "PRINT"; break;
|
||||||
text = "END"; break;
|
case Keys.BrowserFavorites: text = "FAVORITES"; break;
|
||||||
case WinForms.Keys.PageUp:
|
case Keys.BrowserSearch: text = "SEARCH"; break;
|
||||||
text = "PGUP"; break;
|
case Keys.BrowserHome: text = "HOMEPAGE"; break;
|
||||||
case WinForms.Keys.PageDown:
|
case Keys.LaunchMail: text = "MAIL"; break;
|
||||||
text = "PGDWN"; break;
|
case Keys.Play: text = "PLAY"; break;
|
||||||
case WinForms.Keys.Escape:
|
case Keys.Pause: text = "PAUSE"; break;
|
||||||
text = "ESC"; break;
|
case Keys.MediaPlayPause: text = "PLAYPAUSE"; break;
|
||||||
case WinForms.Keys.PrintScreen:
|
case Keys.MediaStop: text = "STOP"; break;
|
||||||
text = "PRINT"; break;
|
case Keys.MediaNextTrack: text = "NEXT"; break;
|
||||||
case WinForms.Keys.Play:
|
case Keys.MediaPreviousTrack: text = "PREV"; break;
|
||||||
text = "PLAY"; break;
|
|
||||||
case WinForms.Keys.Pause:
|
case Keys.VolumeUp:
|
||||||
text = "PAUSE"; break;
|
case Keys.VolumeDown:
|
||||||
case WinForms.Keys.MediaPlayPause:
|
case Keys.VolumeMute:
|
||||||
text = "PLAYPAUSE"; break;
|
|
||||||
case WinForms.Keys.MediaStop:
|
|
||||||
text = "STOP"; break;
|
|
||||||
case WinForms.Keys.MediaNextTrack:
|
|
||||||
text = "NEXT"; break;
|
|
||||||
case WinForms.Keys.MediaPreviousTrack:
|
|
||||||
text = "PREV"; break;
|
|
||||||
case WinForms.Keys.BrowserHome:
|
|
||||||
text = "HOMEPAGE"; break;
|
|
||||||
case WinForms.Keys.LaunchMail:
|
|
||||||
text = "MAIL"; break;
|
|
||||||
case WinForms.Keys.BrowserFavorites:
|
|
||||||
text = "FAVORITES"; break;
|
|
||||||
case WinForms.Keys.BrowserSearch:
|
|
||||||
text = "SEARCH"; break;
|
|
||||||
case WinForms.Keys.Sleep:
|
|
||||||
text = "SLEEP"; break;
|
|
||||||
case WinForms.Keys.Cancel:
|
|
||||||
text = "CANCEL"; break;
|
|
||||||
case WinForms.Keys.VolumeUp:
|
|
||||||
case WinForms.Keys.VolumeDown:
|
|
||||||
case WinForms.Keys.VolumeMute:
|
|
||||||
text = ""; break;
|
text = ""; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wasModified = false;
|
bool isAlt = GetKeyState(18) < 0;
|
||||||
|
bool isShift = GetKeyState(16) < 0;
|
||||||
|
bool isCtrl = GetKeyState(17) < 0;
|
||||||
|
|
||||||
bool isAlt = GetKeyState(18) < (short)0;
|
bool isLetter = (int)key > 64 && (int)key < 91;
|
||||||
bool isShift = GetKeyState(16) < (short)0;
|
|
||||||
bool isCtrl = GetKeyState(17) < (short)0;
|
|
||||||
|
|
||||||
if (text.Length == 1 && KeyChar != text)
|
if (isLetter && isShift)
|
||||||
{
|
text = text.ToUpper();
|
||||||
text = KeyChar;
|
|
||||||
wasModified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (text == "#")
|
string keyString = ToUnicode(vk);
|
||||||
text = "SHARP";
|
|
||||||
|
|
||||||
if (isAlt && !wasModified)
|
if (isAlt && !isCtrl)
|
||||||
text = "ALT+" + text;
|
text = "ALT+" + text;
|
||||||
|
|
||||||
if (isShift && !wasModified)
|
if (isShift && keyString == "")
|
||||||
text = "SHIFT+" + text;
|
text = "SHIFT+" + text;
|
||||||
|
|
||||||
if (isCtrl && !wasModified)
|
if (isCtrl && !(keyString != "" && isCtrl && isAlt))
|
||||||
text = "CTRL+" + text;
|
text = "CTRL+" + text;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(text))
|
if (!string.IsNullOrEmpty(text))
|
||||||
@@ -152,32 +177,14 @@ namespace mpvnet
|
|||||||
KeyTextBlock.Text = key;
|
KeyTextBlock.Text = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
void ProcessKeyEventArgs(ref Message m)
|
||||||
static extern uint MapVirtualKey(uint uCode, uint uMapType);
|
|
||||||
|
|
||||||
public static WinForms.Keys ModifierKeys {
|
|
||||||
get {
|
|
||||||
WinForms.Keys keys = WinForms.Keys.None;
|
|
||||||
|
|
||||||
if (GetKeyState(17) < (short)0)
|
|
||||||
keys |= WinForms.Keys.Control;
|
|
||||||
|
|
||||||
if (GetKeyState(16) < (short)0)
|
|
||||||
keys |= WinForms.Keys.Shift;
|
|
||||||
|
|
||||||
if (GetKeyState(18) < (short)0)
|
|
||||||
keys |= WinForms.Keys.Alt;
|
|
||||||
|
|
||||||
return keys;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessKeyEventArgs(ref WinForms.Message m)
|
|
||||||
{
|
{
|
||||||
int WM_KEYUP = 0x0101, WM_SYSKEYUP = 0x0105, WM_APPCOMMAND = 0x0319;
|
int WM_KEYDOWN = 0x100;
|
||||||
|
int WM_SYSKEYDOWN = 0x104;
|
||||||
|
int WM_APPCOMMAND = 0x319;
|
||||||
|
|
||||||
if (m.Msg == WM_KEYUP || m.Msg == WM_SYSKEYUP)
|
if (m.Msg == WM_KEYDOWN || m.Msg == WM_SYSKEYDOWN)
|
||||||
OnKeyUp(new WinForms.KeyEventArgs((WinForms.Keys)(unchecked((int)(long)m.WParam)) | ModifierKeys));
|
OnKeyDown((uint)m.WParam.ToInt64());
|
||||||
else if (m.Msg == WM_APPCOMMAND)
|
else if (m.Msg == WM_APPCOMMAND)
|
||||||
{
|
{
|
||||||
string value = mpvHelp.WM_APPCOMMAND_to_mpv_key((int)(m.LParam.ToInt64() >> 16 & ~0xf000));
|
string value = mpvHelp.WM_APPCOMMAND_to_mpv_key((int)(m.LParam.ToInt64() >> 16 & ~0xf000));
|
||||||
@@ -187,9 +194,6 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
|
||||||
public static extern short GetKeyState(int keyCode);
|
|
||||||
|
|
||||||
void Window_Loaded(object sender, RoutedEventArgs e)
|
void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
|
HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
|
||||||
@@ -250,9 +254,13 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_TextInput(object sender, TextCompositionEventArgs e)
|
void Window_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||||
{
|
{
|
||||||
KeyChar = e.Text;
|
if (e.Key == Key.Tab)
|
||||||
|
{
|
||||||
|
OnKeyDown((uint)Keys.Tab);
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -321,26 +321,26 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
|
|
||||||
height = Convert.ToInt32(height * scale);
|
height = Convert.ToInt32(height * scale);
|
||||||
int width = Convert.ToInt32(height * videoSize.Width / (double)videoSize.Height);
|
int width = height * videoSize.Width / videoSize.Height;
|
||||||
int maxHeight = screen.WorkingArea.Height - (Height - ClientSize.Height);
|
int maxHeight = screen.WorkingArea.Height - (Height - ClientSize.Height);
|
||||||
int maxWidth = screen.WorkingArea.Width - (Width - ClientSize.Width);
|
int maxWidth = screen.WorkingArea.Width - (Width - ClientSize.Width);
|
||||||
|
|
||||||
if (height < maxHeight * core.AutofitSmaller)
|
if (height < maxHeight * core.AutofitSmaller)
|
||||||
{
|
{
|
||||||
height = Convert.ToInt32(maxHeight * core.AutofitSmaller);
|
height = Convert.ToInt32(maxHeight * core.AutofitSmaller);
|
||||||
width = Convert.ToInt32(height * videoSize.Width / (double)videoSize.Height);
|
width = Convert.ToInt32(height * videoSize.Width / videoSize.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height > maxHeight * core.AutofitLarger)
|
if (height > maxHeight * core.AutofitLarger)
|
||||||
{
|
{
|
||||||
height = Convert.ToInt32(maxHeight * core.AutofitLarger);
|
height = Convert.ToInt32(maxHeight * core.AutofitLarger);
|
||||||
width = Convert.ToInt32(height * videoSize.Width / (double)videoSize.Height);
|
width = Convert.ToInt32(height * videoSize.Width / videoSize.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width > maxWidth)
|
if (width > maxWidth)
|
||||||
{
|
{
|
||||||
width = maxWidth;
|
width = maxWidth;
|
||||||
height = Convert.ToInt32(width * videoSize.Height / (double)videoSize.Width);
|
height = (int)Math.Ceiling(width * videoSize.Height / (double)videoSize.Width);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
|
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
|
||||||
@@ -579,8 +579,18 @@ namespace mpvnet
|
|||||||
s = new Size(16, 9);
|
s = new Size(16, 9);
|
||||||
|
|
||||||
float aspect = s.Width / (float)s.Height;
|
float aspect = s.Width / (float)s.Height;
|
||||||
int d_w = Convert.ToInt32(c_h * aspect - c_w);
|
int d_w = (int)(c_h * aspect - c_w);
|
||||||
int d_h = Convert.ToInt32(c_w / aspect - c_h);
|
int d_h = (int)(c_w / aspect - c_h);
|
||||||
|
|
||||||
|
Debug.WriteLine(d_w);
|
||||||
|
Debug.WriteLine(d_h);
|
||||||
|
|
||||||
|
int d_w2 = (int)(c_h * aspect - c_w);
|
||||||
|
int d_h2 = (int)(c_w / aspect - c_h);
|
||||||
|
|
||||||
|
Debug.WriteLine(d_w2);
|
||||||
|
Debug.WriteLine(d_h2);
|
||||||
|
|
||||||
int[] d_corners = { d_w, d_h, -d_w, -d_h };
|
int[] d_corners = { d_w, d_h, -d_w, -d_h };
|
||||||
int[] corners = { rc.Left, rc.Top, rc.Right, rc.Bottom };
|
int[] corners = { rc.Left, rc.Top, rc.Right, rc.Bottom };
|
||||||
int corner = NativeHelp.GetResizeBorder(m.WParam.ToInt32());
|
int corner = NativeHelp.GetResizeBorder(m.WParam.ToInt32());
|
||||||
|
|||||||
Reference in New Issue
Block a user