设计表单以在Windows CE上以不同的分辨率和宽高比工作 [英] Designing forms to work on different resolutions and aspect ratios on Windows CE

查看:95
本文介绍了设计表单以在Windows CE上以不同的分辨率和宽高比工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

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

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.

你们是怎么想的?

推荐答案

我想我已经想好了。由于某些原因,即使在高分辨率设备上,根据WinForms API,DPI仍显示为96,因此自动缩放无法执行任何操作。相反,如果我手动调用 Scale 在我的控件上,我可以使它们精确地按比例缩放。现在,这在我不希望进行任何缩放但如果屏幕的宽高比与最初设计的比例相反的情况下并不能完全解决我的问题。对于这种情况,我想我将考虑使用不同的布局面板(例如 FlowLayoutPanel TableLayoutPanel )来希望适当地组织控件。

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.

希望这对将来的Googler有帮助...

Hopefully this will help any future Googler...

这篇关于设计表单以在Windows CE上以不同的分辨率和宽高比工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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