How to design GUI for different monitor resolutions? [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm designing and implementing the GUI for special application.
I'm using WPF on C#,
I intend to apply this app for different monitor resolutions (1366x768 or 1920x1080,...).
But I don't have any experience for this. I don't know how to implement the flexible GUI that can display on any resolution well.
Someone can give me the ideas?

1 - Write your XAML by hand and don't use the Visual Studio designer.
The designer produces fixed-size fixed-position UIs (ala winforms) and will not be useful if you need resolution independence.
2 - Do not fix the sizes and positions of the UI elements yourself either.
Don't do things such as <TextBox Width="56" Margin="50,30,10,5"/>. Instead of that, place your UI inside resolution independent layout containers such as Grid or DockPanel. Use Star Sizes in your Grids, too.
Edit: Adding #Viv's comment, which is so important I decided to make it part of the answer:
Like everything else in programming, take point 1 with a grain of salt. Don't make it another statement like "In MVVM ANY code in code-behind is wrong". Using the Designer(VS/Blend) for things like generating Template's, Modifying Storyboards, VSM, Importing Illustrator/Photoshop files is perfectly reasonable. Know what you're dealing with and even if in such cases you get constant dimensions, tweak the xaml accordingly to get rid of it than totally neglect every aspect of it

Firstly, it depends somewhat on the nature of the application, however the resolutions you specify are not MASSIVELY different in the grand scheme of things (if you were comparing 640x480 to 2560x1600, then you might have even bigger concerns!), so likely, if you choose the right components, they will organise themselves (or more aptly, the OS will organise them behind the scenes) for you.
The fact that you've chosen WPF means that you have massive flexibility with how UI elements will render, as WPF is natively a vector based rendering engine, as opposed to Windows Forms (GDI/GDI+) which was a DPI/per-pixel based rendering engine.
But lets delve a little deeper into this shall we?
Say for example you were designing your UI in Windows Forms, and it required a ToolStrip on the form, and then you all 1000 buttons to the ToolStrip. Okay, on a massive monitor, you might just see all 1000 buttons, but on your bog standard 1080p monitor, you might only see 30 of them; so what happens to the rest? - Windows will put these in a sub-menu for you, at the end of the ToolStrip, so that you can still access them, even though they are not on the main (visible) section of the ToolStrip. I'm pretty sure that the same principle will apply to WPF, through you will likely have even greater control over how things render, and appear!
The great thing that WPF brought to the table, through vector rendering, was resolution independence. This gives you the flexibility to decide if you want your elements to render as a "fixed" size (across any resolution, it will always use the same pixels), or, allow the engine to dynamically resize the element according to the resolution (on a low resolution the element will render using less pixels but will suffer with lesser quality, or on a high resolution, will render using more pixels and will have a much higher quality).
To get you started, here's a free WPF eBook from SyncFusion (seriously, check them out, they give away quite a bit of free, decent stuff!)
WPF Succinctly

Related

Moving from WinForms c# [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am writing a game in WinForms, using c#. Well, I absolutely love Visual Studio and WinForms, because coding is very simple, and there is usually no need in any additional content.
The game is text based, but it is also heavily based on UI. But, WinForms has no transparency, and this is something that hurts alot. Interface, labels and pictures are created and positioned dynamically.
I thought about moving to WPF, but I do not know, if i will be able to place controls dynamically in WPF like in WinForms (because WPF is based on grids).
Should I learn more about WPF, or there is any simple WinForms-like analogs, that support transparency and will allow me to create text-based games with UI?
P.S here is image, its QSP game (not mine, but it is something that I want to achieve, but have improved UI, transparent images, and etc.)
Since this is a multi-part question, I will not attempt to address any one specific question but rather provide resources to allow you to embark on learning WPF on your own, and assure you that moving to WPF is a safe choice for converting your application.
I thought about moving to WPF, but I do not know, if i will be able to place controls dynamically in WPF like in WinForms (because WPF is based on grids).
Yes, you can generate, create, and position content dynamically in WPF. See links for example code.
Should I learn more about WPF
Yes, you should learn more about WPF.
or is there any simple WinForms-like analogs, that support transparency and will allow me to create text-based games with UI?
Yes, you can create transparent windows and transparent controls in WPF.
I hope these resources are useful to you.

Windows Forms vs. WPF [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I've developed Windows Forms applications for 5 years now. A lot of people say that I should look into WPF. I have a few questions about WPF vs Windows Forms to determine which one is best. WPF is newer than Windows Forms and many people say it'll be the future. Others say that Windows Forms is older and therefor more secure. I am not sure what will be the future. I have googled advantages and disadvantages, but I hope that you can give me a more in dept answer to these questions:
Which one is better based upon performance?
What are the top advantages of using WPF instead of Windows Forms?
What are the top advantages of using Windows Forms instead of WPF?
Which one is more used/liked by businesses?
How hard is it to switch from Windows Forms to WPF?
Which parts of WPF should I definitely look into?
There is no meaning to say that WPF is better than windows forms or vice versa. It depends on many factors:
What kind of UI you are building.
Obviously, the complexity of the views you are designing will factor in to performance on both platforms. They have different layout and rendering pipelines.
How effectively you optimize for performance on each platform.
Advantages of using WPF instead of Windows forms:
XAML makes it easy to create and edit your GUI, and allows the work to be split between a designer (XAML) and a programmer (C#, VB.NET etc.).
It allows you to make user interfaces for both Windows applications and web applications (Silverlight/XBAP).
Databinding, which allows you to get a more clean separation of data and layout.
Uses hardware acceleration for drawing the GUI, for better performance.
Top advantages of using Windows forms instead of WPF:
WPF's in-box control suite is far more limited than that of WinForms.
There's greater support in the 3rd-party control space for WinForms. (That's changing, but for now by advantage of time, WinForms has greater support in the community.)
The major drawback of WPF is that Mono doesn't really support it for cross-platform (e.g., it doesn't work on Linux and Mac). Originally, Xamarian/Novella said they weren't going to implement it due to the complexity of implementation. I haven't seen anything to the contrary. Not saying it isn't, but their recommendation is to write model classes and then do a OS-specific front end. Even with WPF being open sourced, it may be built on something that isn't easily ported.
https://social.msdn.microsoft.com/Forums/en-US/e134134a-352f-435b-943a-eda7a2b14fc0/wpf-vs-windows-forms-2015?forum=wpf
Depends upon your learning ability.
Which parts of WPF should I definitely look into?
XAML: Learn about XAML and how it is used in WPF applications.
Layout: Learn about layout panels and how they are used to construct user interfaces.
Data binding: Learn how WPF data binding works and how it can be used.
Data templates and triggers: Learn how data templates and triggers work and how they can be used.
Styles: Learn about how UIs can be styled in WPF.
For more information refer below mentioned URL
Windows Form Vs WPF Windows

How exactly is a skin like adobe photoshop cs6 made? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am really trying to figure this one out. How exactly is a skin like adobe photoshop cs6 made?
Is it just an image? Or is it graphically coded to appear like that.
The title bar works exactly like a normal title bar. It resizes, snaps minimizes and maximizes. So could it be an actual theme like aero?
I have always wondered how this works. When you see those cool STEAM and Pandora skins I wonder if it is as simple as creating the image in photoshop and then using it as a form.
How would one do this in vb.net or c#?
Edit: Another part that baffles my mind is the fact that when it is in a normal state the corners are rounded. Then when maximized they are not.
Below is an image of Photoshop cs6 if you are not familiar.
A skin like that is made by a few hundred people over a period of a year or more(including programmers, graphic artists, managers, UI designers etc), custom coding every nuance of Win32 API, ClientArea and NonClientArea, Owner-Drawn drawing, GDI+ and DirectX(on WPF), a custom display engine etc etc etc.
Now, if you have a custom display engine, you can play with SVG to crisply scale up or down, or if you don't have a custom display engine, use repeating 1px width images to handle image resizing on window resize.
See Qt, which is used by Adobe engineers, maya engineers, Google earth engineers etc etc which can help you skin each and every widget on your window.
See Delphi and its cousin C++Builder which have a different display engine on top of regular Win32 that allows skinning your application using drag+drop and configuration
See TCL-Tk which allows you to skin your windows using simple configurations and themes.
Also, if you're using C#, see WPF and Expression Blend that allows you to, not just create and skin your application, but also add animations and other fancy graphics to it.
If you like the old school approach, see http://www.codeproject.com/Articles/254/The-RGN-Generator and using Regions to code custom dialog boxes and windows and buttons etc.
Good luck and may the graphics + programming force be with you.

3d animation - WPF or XNA [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I would like to make a 3d animation of a few dozens of primitives
I read the initial position of each atom and with other parameters I need to draw an animation that describe the ordering. I need to view then of all angles, manipulate the color and alpha channel.
All in all, it narrows to WPF 3D or XNA.
I would choose WPF, because I know it and it is a way much easier to add a TextBox to the app.
Yet I am afraid that WPF won't handle the animation or it would be problematic if I need to add some extra bits.
Which one is better for it? Can you point me to some examples how to manage datastructres and draw the animation? (I am new to 3d animations)
EDIT:
If anyone is interested in here the code and the app http://alloysvisualisation.codeplex.com/ I use Model3DGroup to build a mode from GeometryModel3D. As a result, performance is pretty good.
We use both WPF and XNA for 3D rendering in the projects I'm currently working on. The XNA stuff is used from within a WPF application, so there is no problem using those two combined either.
I would use WPF for the 3D rendering if you have a simple scene since I like the abstraction it gives you. You simply add objects to the scene, set up some cameras and lights and the rest is handled for you. We use WPF for a visual editor containing up to ~500 cylinders without any performance problems. The one performance issue we have had is that it takes a long time to add/remove objects from the scene. So WPF is not a good fit if that is something you need to do a lot of.
However, if you have more complex needs or if the application is performance critical I would go with XNA to get closer to the metal. It gives you a more "classic", OpenGL like approach to rendering.
To summarize:
WPF:
Simple to use
Nice abstraction
Ok performance overall
Poor performance when adding/removing objects
XNA:
Close to the metal
Good performance
Feels more like OpenGL if you are used to that
Works with both WinForms and WPF
A resource that we have used for the WPF side of things is Charles Petzold's writings on the subject. We currently use stuff from his library. It got us started quickly, but we've had some issues, so I would recommend some caution. However, the stuff on his site is worth looking at.
XNA + WPF is the solution. This article will guide you through the process: http://www.codeproject.com/Articles/38301/XNA-integration-inside-WPF
Definetely XNA is faster and more convenient for extensive 3D work. WPF is fine for 3D, but XNA is easier to debug and offers several nice features, such as additive alpha blending and a Camera object. Also, you can find good libraries to support your work.
If you are not sure, then you should without doubt use an XNA object to draw the graphics. WPF will provide you with buttons and text, which, in turn, are a pain in XNA.
Xna will offer easier debugging of the 3d aspects.
You could follow the winforms example to host xna in a windows forms form and then all the familiar controls like drop downs and buttons will work fine and interact with xna.

Relative merits of GDI+ and WPF [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
Whar are the relative merits between GDI+ and WPF?
Also does anyone know the minimum system requirements needed in order to develop/run WPF apps?
GDI+ vs. WPF
What are the benefits of WPF graphics subsystem? Let's see:
Retained Mode Drawing/Composition
Vector Graphics
True Transparency
And more ...
What are the benefits of GDI+? Hmm. That's harder, because I love WPF so much. However, if you were in the position to have to be constantly recreating the geometry of the objects that you are trying to render, then you might need the immediate mode API that GDI+ offers.
Here are two (one, two) really great blog posts on this matter.
(Note that the above blog posts are rather old. They still contain great information, but also be aware that the WPF team has made significant advances in performance and graphics capabilities since the original version of WPF (.NET 3.0)).
System Requirements
They're are really no minimum system requirements for WPF applications other than that the operating system must be at Windows XP SP 2 or greater and that .NET 3.0 (at least) must be installed. However, that being said, the better quality graphics card in the machine the WPF application is running on the better.
What we have noticed ourselves is that WPF performs quite well even on older hardware, especially if you aren't doing anything too tricky or fancy.
What does that mean? Well, in my own experience, watch your performance more closely if you start doing anything with WPF 3D and/or bitmap effects. In fact, I would encourage you to monitor your performance throughout the development of the application.
One final thing I would add ... is that we have seen some very weird graphics issues (this and this) with certain video solutions and in particular with Intel integrated video.
Please check out this other StackOverflow post for more info on hardware limitations, and in particular, check out the information on Rendering Tiers.

Categories