旋转Windows窗体倒挂 [英] Rotate Windows form upside down

查看:213
本文介绍了旋转Windows窗体倒挂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#应用程序,有一个现有的WinForm,我现在需要倒置显示。

I have a C# application that has an existing WinForm that I now need to display upside down.

应用程序将被显示在触摸屏的Windows 7设备上。如果两个人都在使用该设备,一人看它右侧向上,而另一个用户会同时看它倒。我需要有一个控制显示右侧向上,而另一个控制显示颠倒,每个重复形式。都需要发挥作用。这是没有必要的标题栏和Windows关闭,最大化,最小化和被旋转。

The application will be displayed on a touchscreen Windows 7 device. If two people are using the device, one person is viewing it right-side-up while another user will be simultaneously viewing it upside-down. I will need to have one control displayed right-side-up while another control is displayed upside-down, each duplicate forms. Both need to be functional. It is not necessary for the title bar and Windows close, maximize, and minimize to be rotated.

有没有一种方法可以轻松地转动这个表格和它的所有内容,而不必从头开始重写一遍?

Is there a way to easily rotate this Form and all of its contents without having to rewrite it from scratch?

推荐答案

不幸的是,旋转控制是不能直接在的WinForms。

Unfortunately, rotating controls is not directly possible in WinForms.

至少,如果你不希望他们保留自己的功能。这将是相对简单的绘制控制成位图,旋转位图,然后绘制该回所需位置的形式。但你显然失去了与控件进行交互的能力。他们也只是其原始的自我静态再presentatives。

At least, not if you want them to retain their functionality. It would be relatively simple to draw the control into a bitmap, rotate the bitmap, and then draw that back to the desired location on the form. But you would obviously lose the ability to interact with the controls. They would just be static representatives of their original selves.

但使功能颠倒控制只是是不会发生的。我的意思是,你可以的尝试的写所有者绘制控件一堆自定义绘制code,但你还是会碰到一堆虫子,角落的情况下,和兼容性问题。在Win32控制着的WinForms基于只是不支持这一点。没有大的惊喜,真的,考虑到他们发明了一些20至25年才有人想到电脑屏幕,你可以随身携带在你的口袋和旋转在任何方向。有一个很好的理由,像WPF UI技术出来了身边的时候了触摸屏和平板电脑做到了。

But making functional upside-down controls just isn't going to happen. I mean, you could try to write a bunch of custom drawing code for owner-drawn controls, but you'll still run into a bunch of bugs, corner cases, and compatibility problems. The Win32 controls that WinForms is based on just don't support this. No big surprise, really, considering they were invented some 20–25 years before anyone thought of computer screens that you could carry around in your pocket and rotate in any direction. There is a good reason that UI technologies like WPF came out around the time that touch screens and tablets did.

目前的的一些可能性,可当谈到翻转整个​​屏幕,但是这不会帮助,当你需要不同的控制将不同的方向进行探讨。 (我猜它背叛了我的制高点作为一个桌面应用程序的人,当我说这一点,但只是听起来像是一个非常混乱的用户界面。)

There are some possibilities that can be explored when it comes to flipping the entire screen, but that's not going to help when you want different controls going different directions. (And I guess it betrays my vantage point as a desktop app guy when I say this, but that just sounds like an incredibly confusing UI.)

如果你绝对有这个,别人将不得不给你另一种途径来破解它,也许沿Dhawalk的评论的行:主机的WPF应用程序,并提供内部的WinForms控制内置支持对于旋转的控制。我不知道有足够的了解这使沿着这条道路的任何具体的建议。从搜索的几分钟,看来的WindowsFormsHost实际上并不支持旋转变换,所以这可能是一个非首发反正

If you absolutely have to have this, someone else is going to have to give you another route to hack it, perhaps along the lines of Dhawalk's comment: hosting the WinForms control inside of a WPF app that does provide built-in support for rotated controls. I don't know enough about this to make any concrete suggestions down that path. From a few minutes of searching, it appears that WindowsFormsHost does not actually support rotation transforms, so this may be a non-starter anyway.

这篇关于旋转Windows窗体倒挂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆