设计表单以在 Windows CE 上使用不同的分辨率和宽高比

发布于 2024-08-18 16:57:31 字数 468 浏览 5 评论 0 原文

我有一个在 Compact Framework 上运行的 .NET 2.0 应用程序。它有一堆不同的形式,最初都是为了在具有特定屏幕分辨率的特定设备上运行而设计的。我现在希望让这个应用程序在具有非常不同的屏幕分辨率的其他一些设备上运行(有些设备具有完全相反的宽高比,其中屏幕现在比宽高)。我的问题是如何更改我的表单以使其在其他屏幕上看起来不错?

这与在完整框架上设计表单有点不同,因为屏幕太小,我必须设计这些表单以占据全屏。我考虑过为每种类型的屏幕方向创建单独的表单(例如 MyForm_Wide.cs、MyForm_Tall.cs 等)。我希望能够重用非设计者生成的代码,其中包含大量与 UI 控件相关的业务逻辑。也许我可以以某种方式使用部分类来实现这一点(例如,MyForm.cs 以某种方式编译成 MyForm_Wide.Designer.cs 等)。我真的很想避免为每个屏幕方向专门编译的版本。我考虑过的另一种方法是尝试根据确定的屏幕尺寸在运行时重新排列一些控件。

你们觉得怎么样?

I have a .NET 2.0 application that runs on Compact Framework. It has a bunch of different forms that were all originally designed to run on a specific device with a specific screen resolution. I'm now looking to get this application to run on some other devices that have very different screen resolutions (some have completely opposite aspect ratios where the screen is now taller than it is wide). My question is how can I change my forms to look good on these other screens?

This is a bit different from designing forms on the full framework since I have to design these forms to take up the full screen since the screens are so small. I've thought about creating separate forms for each type of screen orientation (e.g. MyForm_Wide.cs, MyForm_Tall.cs, etc). I'd like to be able to reuse the non-designer generated code that contains a lot of business logic that is tied to the UI controls. Maybe I could somehow use partial classes to make this happen (e.g. MyForm.cs somehow gets compiled into MyForm_Wide.Designer.cs, etc). I'd really like to avoid specifically compiled versions for each screen orientation. Another approach I've thought about is trying to rearrange some controls at runtime based on the determined screen size.

What do you guys think?

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

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

发布评论

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

评论(5

戏剧牡丹亭 2024-08-25 16:57:32

由于 C# 设计者非常“面向像素”,因此没有简单的方法来转换表单。

我不知道你想为此付出多少努力,但如果你有很多时间并且想要一个真正灵活的解决方案,我建议你应该使用某种支持流布局、边框布局等的布局管理器。

当然最初的 C# 设计者不会对设计这些灵活的布局管理表单有太大帮助。

但使用布局管理器可能会减慢表单的初始显示速度。如果您想要真正高速的表单显示,则必须在显示表单之前计算表单上所有控件的所有位置。重新排列控件并显示您的表单 - 然而,这需要大量编码,并且对于 gui 更改来说不是很灵活。

Since the c# designers are very 'pixel-orientated' there is no easy way to convert your forms.

I don't know how much effort you want to put into this, but if you have a lot of time and want a really flexible solution I suggest you should use some kind of layout manager that supports flow layouts, border layouts etc.

Of course the original c# designers won't be much help designing these flexible layout-managed forms.

But using a layout manager might slow down the initial display of your form. If you want really high speed form display you will have to calculate all positions of all controls on your form before you show the form. Rearrange the controls and display your form - this is however a lot of coding and not very flexible regarding gui changes.

与之呼应 2024-08-25 16:57:32

您可能应该将主窗体的“AutoScaleMode”属性设置为“DPI”。

然后,就是使用锚点并停靠在表单上的特定控件上。如果您这样做,紧凑的框架将使事情保持在您想要的位置。

此外,还可以更改表单的“Form Factor”属性,以查看表单在不同尺寸和形状的移动设备上的外观。

You should probably set your main forms 'AutoScaleMode' property to 'DPI'.

Then, its a matter of using anchors and docking on your particular controls on the forms. If you do it this way, the compact framework will keep things where you thought they'd be.

Also, can change the 'Form Factor' property of the form to see how your form would look on mobile devices of different sizes and shapes.

请爱~陌生人 2024-08-25 16:57:32

我想我已经弄清楚我想做什么了。由于某种原因,即使在我的高分辨率设备上,根据 WinForms API,DPI 仍然显示为 96,因此自动缩放没有执行任何操作。相反,如果我手动调用 Scale在我的控件上,我可以让它们按照我想要的方式进行扩展。现在,这并不能完全解决我不想进行任何缩放的情况下的问题,但如果屏幕的宽高比与我最初设计的相反,我确实想重新组织我的控件。对于这种情况,我想我将考虑使用不同的布局面板(例如 FlowLayoutPanelTableLayoutPanel)希望能够适当地组织控件。

希望这对未来的 Google 员工有所帮助...

I think I've figured out what I want to do. For some reason even on my high res devices the DPI still shows up as 96 according to the WinForms API so the auto scaling isn't doing anything. Instead, if I manually call Scale on my controls I get them to scale out exactly how I want. Now, this doesn't completely solve my problem in scenarios where I don't want to do any scaling but I do want to reorganize my controls if the screen is in the opposite aspect ratio than what I originally designed for. For that case, I think I'm going to look at using different layout panels (e.g. FlowLayoutPanel and TableLayoutPanel) to hopefully organize the controls appropriately.

Hopefully this will help any future Googler...

寄居人 2024-08-25 16:57:32

在外形尺寸之间切换时,标签上的“自动大小”属性也会变得混乱 - 顺便说一句 - 所以我将其设置为 false。

The 'Auto Size' property on labels messes up when switching between form factors too - btw - so I keep it set to false.

耀眼的星火 2024-08-25 16:57:31

我们使用 Clarius 的 方向感知控制 框架。它不仅解决了外形尺寸的问题,还解决了支持它的设备上方向变化(屏幕旋转)的问题。

与传统桌面开发相比,移动开发最独特的方面也许是需要支持不断增加的设备外形尺寸。

对于专业的移动开发人员来说,设计支持多种外形尺寸、分辨率和屏幕方向的移动应用程序是一项艰巨、耗时且具有挑战性的工作,这已不是什么新闻。通常还明显的是,.NET Compact Framework v2.0 中的内置对接和锚定功能还远远不够。

方向感知控件允许设计和编码具有多个布局或皮肤的单个控件或表单,这些布局或皮肤根据可用的形状因数、分辨率和方向在运行时(和设计时)自动应用。其出色的 Visual Studio 表单和用户控件设计器集成以及零代码自适应 UI 行为使方向感知控件成为任何针对多个设备的移动商店的必备伴侣,从而恢复您专注于发展业务所需的生产力。

We use the Orientation Aware Control framework by Clarius. It solves the problem of not only form factor, but also on devices that support it, change of orientation (screen rotation).

Perhaps the most distinctive aspect of mobile development with regards to traditional desktop development is the need to support an ever increasing range of device form factors.

For expert mobile developers it's no news that designing mobile applications that support multiple form factors, resolutions and screen orientations is a non-trivial, time-consuming and challenging endeavor. It's also generally evident that the built-in docking and anchoring features in .NET Compact Framework v2.0 is far from being sufficient.

The Orientation Aware Control allows designing and coding a single control or form with multiple layouts or skins that are automatically applied at run-time (and design-time) according to the available form factor, resolution and orientation. Its outstanding Visual Studio forms and user control designer integration and zero-code adaptive UI behavior make the Orientation Aware Control a must-have companion for any mobile shop targeting multiple devices, bringing back the productivity you need to focus on growing your business.

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