app: add key Shift+Left/Right to move window between screens

This commit is contained in:
Nguyen Duy
2024-06-06 21:55:00 +07:00
parent 2331de90fc
commit c8f8a286f4
3 changed files with 41 additions and 3 deletions
+3 -3
View File
@@ -6,8 +6,8 @@
<system:String x:Key="lang_name">Tiếng Việt</system:String>
<!--Interface-->
<system:String x:Key="t_add_display">Cắm màn hình</system:String>
<system:String x:Key="t_hint_add_display_first">Hãy cắm màn hình ảo!</system:String>
<system:String x:Key="t_add_display">Thêm màn hình</system:String>
<system:String x:Key="t_hint_add_display_first">Hãy thêm màn hình ảo!</system:String>
<system:String x:Key="t_custom">Tùy chỉnh...</system:String>
<system:String x:Key="t_apply">Áp dụng</system:String>
<system:String x:Key="t_parent_gpu">GPU nguồn</system:String>
@@ -42,7 +42,7 @@
<system:String x:Key="t_msg_custom_access_denied">Không thể áp dụng độ phân giải tùy chỉnh, quyền truy cập bị từ chối!</system:String>
<system:String x:Key="t_msg_custom_invalid_slot">Giá trị không hợp lệ ở slot #{0}.</system:String>
<system:String x:Key="t_msg_exceeded_display_limit">Không thể cắm thêm màn hình ảo, bạn đã đạt đến con số giới hạn ({0}).</system:String>
<system:String x:Key="t_msg_exceeded_display_limit">Không thể thêm thêm màn hình ảo, bạn đã đạt đến con số giới hạn ({0}).</system:String>
<system:String x:Key="t_msg_prompt_leave_all">Tất cả màn hình ảo sẽ bị tháo bỏ.\nBạn có muốn thoát không?.</system:String>
<system:String x:Key="t_msg_driver_status">Trạng thái driver</system:String>
+1
View File
@@ -17,6 +17,7 @@
WindowStartupLocation="CenterScreen"
Loaded="Window_Loaded"
Unloaded="Window_Unloaded"
KeyDown="Window_KeyDown"
>
<Grid MouseDown="Grid_MouseDown">
<Grid.Background>
+37
View File
@@ -169,5 +169,42 @@ namespace ParsecVDisplay
if (e.LeftButton == MouseButtonState.Released)
(sender as TextBlock).ContextMenu.IsOpen = true;
}
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (!e.IsRepeat &&
(Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)))
{
var screen = System.Windows.Forms.Screen.FromHandle(Handle);
if (screen != null)
{
var screens = System.Windows.Forms.Screen.AllScreens;
int index = -1, nextIndex;
for (int i = 0; i < screens.Length; i++)
if (screens[i].Bounds.Contains(screen.Bounds))
index = i;
if (index != -1)
{
if (e.Key == Key.Left)
nextIndex = index - 1;
else if (e.Key == Key.Right)
nextIndex = index + 1;
else return;
if (nextIndex >= screens.Length) nextIndex = 0;
else if (nextIndex < 0) nextIndex = screens.Length - 1;
if (index != nextIndex)
{
var wa = screens[nextIndex].WorkingArea;
Left = wa.Location.X + (wa.Width - RenderSize.Width) / 2;
Top = wa.Location.Y + (wa.Height - RenderSize.Height) / 2;
}
}
}
}
}
}
}