WPF 应用程序在远程访问会话期间移出屏幕

发布于 2024-08-03 23:36:13 字数 311 浏览 6 评论 0原文

我有一个问题,我希望找到最好和最容易实施的解决方案。

我编写了一个 WPF 应用程序,可以在桌面上拖动,但我通常将其放在屏幕的右上角。

我的问题是,当我从另一个位置远程拨入时(分辨率始终较低),应用程序位于屏幕外,除非我终止进程并重新启动它,否则我无法将其取回。

我想到了一些想法,以使其始终保持可见。

1]每当它运行时,它都会生成一个子线程,用于循环检查可见分辨率。当它超出检测到的范围时,它将更新其位置。

2]当我远程登录时,使用某种消息系统向它发送消息 - 这将触发它重新调整自身。

有人有什么建议吗?

i have a problem in which i am hoping to find the best and easiest to implement solution.

I have written a WPF application which can be dragged around the desktop but i usually put it in the top right hand corner of the screen.

My problem is that when i remote dial in from another location - where the resolution is always lower - the application is offscreen and there is no way for me to get it back unless i kill the process and relaunch it.

I have thought of some ideas in order to always keep it visible.

1] Whenever it is running have it spawn a child thread that checks the visible resolution in a loop. When it is outside the detected bounds it will update its location.

2] Use some sort of messaging system to send it a message when i remote in - and that will trigger it to re-align itself.

Does anyone have any suggestions??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美胚控场 2024-08-10 23:36:13

您可以有一个定期(每隔几秒)触发的 DispatcherTimer 以确保窗口位于可见屏幕之一上。如果不是,它会重新定位,使其保持原来的位置。

即使您使用的是 WPF,您也可以使用 System.Windows.Forms.Screen 类来访问有关用户桌面和屏幕设置的信息。

像这样的东西:

bool isWithin = false;
foreach (Screen screen in Screen.AllScreens)
{
    if (screen.Bounds.Contains(windowLocation))
        isWithin = true;
}

// if !isWithin, move to 0,0

You could have a DispatcherTimer that fires periodically (every few seconds) to ensure that the window is on one of the visible screens. If not, it would reposition so that it is.

You can use the System.Windows.Forms.Screen class to access information about the user's desktop and screen setup, even though you're using WPF.

Something like:

bool isWithin = false;
foreach (Screen screen in Screen.AllScreens)
{
    if (screen.Bounds.Contains(windowLocation))
        isWithin = true;
}

// if !isWithin, move to 0,0
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文