Moving from WinForms c# [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 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.

Related

What is the most suitable control to use for 3D rendering and animation programming in Windows Forms? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I am researching 3D and 2D rendering animation. I found the PictureBox control
is pretty okay for this purpose, but I feel I have only very beginner level knowledge. I am curious to know if it is possible to make a moderately complex level of rendering applications with the PictureBox control. In short, which is the best control in the Windows application tool box to be selected for my intended purpose?
I am making a Windows Forms application with C#.
I'm not sure what exactly you are doing with the PictureBox control for this purpose. But if you're using Windows Forms, then you may want to consider making your own Control subclass with all of your drawing operations handled using GDI+ calls in the OnPaint method. You could pair this with a Timer object called every so often to determine when to refresh.
This is an approach I have personally used for drawing previews of simulated mechanical objects in 2D, so this might work for your purposes as well.
Unless you can tell us what exactly you are trying to draw or provide some existing code for us to look at, it will be hard to give you a precise answer. But MSDN has some pages covering this topic, which you can take a look at to get started and for further reading:
Custom Control Painting and Rendering
Rendering a Windows Forms Control
User-Drawn Controls
Control.OnPaint Method (PaintEventArgs)
Graphics Class
The latest libraries you can use are from Xamarin,
SkiaSharp
UrhoSharp
They wrap over Skia and Urho engine so that you can render 2D or 3D contents in WinForms or WPF or any other kind of applications.

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

Creating a Windows desktop app not a metro/store app [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 8 years ago.
Improve this question
I realize this may be a misplaced question on this forum but most other forums are less that useless!
I've been searching for tutorials on creating a Windows Desktop program, not a Windows Metro/Store app. All I can find is metro and store.
Can someone point me in the right direction for getting started on this? This is what I have chosen in VS2012:
vs2012 new windows empty project
I will eventually be importing an API but for now I want to get working on a GUI layout. Any pointers/clarification would be great.
If you want to create a Windows GUI app, you should use either Windows Forms Application or WPF Application. These are the primary two ways in which Windows desktop applications are created in C#. Note that the controls offered through these are different from one another, and the basic fashion in which the UI is constructed is totally different as well.
Windows Forms is fairly simple, and uses a visual designer to add controls to the form. WPF relies much more strongly on a complex markup based language, XAML, in which the UI is written in code. WPF offers a great deal more options as far as customizing controls and their appearances, but in order to use it to its greatest potential you have to spend a decent amount of time and frustration understanding how binding works within XAML.

What is new since Family.Show? [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 8 years ago.
Improve this question
I am relatively new to WPF and have been looking at Family.Show. It looks like a great reference application, but it has not been updated since February 2009. When I am looking through this code, are there any outdated techniques in here or improvements in the platform that I should be aware of?
[Edit] I have gotten a number of responses about PRISM and MVVM. I can now see how this question was not clear. Family.Show is one of the few WPF applications that I think really looks like a nice WPF application. I would like to use it as a model, but am concerned that the XAML and controls that they use might have been replaced with newer elements. Would someone give me some guidance in this respect?
[Edit] I should mention that I have read WPF 4 almost in its entirety, but not having much experience actually writing WPF applications, it is not easy for me to spot old or outdated technologies in something like Family.Show.
On the WPF side of things, not much has changed since 2009.
There are still DataTemplates, Styles, Data binding etc. They are used just like they have been used back then.
In the current version of the .NET framework a few more controls are present out of the box, so you might find some user controls in that example that are no longer necessary. However, the existing controls haven't changed as far as I know.
However, that application doesn't make any use of MVVM, which I personally find a big drawback.
So, you can use the application as a means to study WPF, but you shouldn't adept its architecture style in your own applications.
I think Prism is a very good framework to build enterprise(bigger) applications but at first sight it could be a little difficult. If you are new to WPF but want to get to know the WPF and MVVM better, check http://caliburnmicro.codeplex.com/ or http://waf.codeplex.com/. (With them it is a little easer to understand the principles.) You can get the source too and it is a good documentation to both, so you can learn a lot.
I think it is important to be familiar with the MVVM principles as a WPF developer.
I can suggest to you to watch the following two video from MIX conferences too:
http://channel9.msdn.com/events/MIX/MIX10/EX14
http://channel9.msdn.com/events/MIX/MIX11/OPN03
I would have a look at prism - its a great way to build WPF apps.

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.

Categories