So... I want to make a game, and I want to write it in C#. In the past, I've made a mario clone using C++ and OpenGL. I quite like OpenGL, but I don't know how well it's supported inside C#/WPF. Also, it might be beneficial to use an actual game library? I guess XNA is the game library for C#, so maybe I'll invest a bit of time learning that.
However, I want to use WPF form controls for my level editor... is there any way that I can embed an XNA (DirectX?) window inside a WPF app?
Specifically, I don't need any buttons or things inside the XNA/DirectX widget, just around it, so no mixing required...just need to get a graphics widget in my WPF form.
Nick Gravelyn explains how to do it on his blog.
Although, if it's just for an editor, you may find using WinForms is easier and better supported.
First of all, you should ask this on gamedev.stackexchange.com. But I've seen a tutorial embedding XNA.
You should check this question and this page. They are on Windows Forms, but they'll help.
Also check this and this articles.
Keep in mind one thing. XNA is meant to be used for the whole game, integration would be useful on making level editors like you say, but not for a full game.
WPF uses DirectX, and you can do direct "interop" here is a codeProject article on the subject. Here is an article i dug up where the author is using win-forms and WPF controls in an XNA project. Might be worth a look for you.
Related
I am currently developing a 3d game using C#/SlimDX (The target is Direct3D 9). I've been looking for a suitable Game UI toolkit for a while, but I was unable to make up my mind.
The Game UI will be for a roleplaying game, so it'll be fairly complex and will involve quite a few controls (text boxes, inventory grids, list boxes, select boxes, scrollable areas, etc.).
I previously (When i was still using C++/OpenGL) looked at GameSWF and very much liked the idea, but for my current game it's out of the question.
Does anyone know a good GUI toolkit for use with SlimDX?
I would be especially interested in using WPF/Silverlight for this, since there are good IDEs available for both. But a quick google search didn't reveal any information on embedding these.
You can use WPF (but not Silverlight) for this.
The way to go about this is to use SlimDX in conjunction with D3DImage. You then let WPF handle all of your final composition, including overlaying the WPF UI over the top of your SlimDX scene.
SlimDX basically just renders to a brush in this situation, which can be used on any WPF element. (This doesn't work for Silverlight, as Sliverlight doesn't support D3DImage.)
There are some projects that could use WPF at work, for the sake of adopting new technologies.
But the problem is, I can't jump start WPF easily. I recognize the learning curve is steeper than Winforms. Though even with Winforms one can start doing UIs and programmatically customize them in a day.
So the problem is:
I don't have any resource to quickly learn the fundamentals of WPF at work. I can't read a book from cover to cover before I do the simplest of things.
Most tutorials on the net, just does things that excludes the fundamentals. i.e. they post partial xaml code I can't even put into my xaml code correctly (VS highlights them in red).
I can't justify using WPF over Winforms where there is no significant gain for prety much all projects I can think of. And the learning curve just makes things worse.
So I can't suggest my manager to use this tech over the traditional Winforms, but I want to.
Is there a guide or a tutorial on the net, or a video that explains the fundamentals of WPF so I can explore everything else on my own, except the more complicated tasks?
Fundamental of WPF video from Mix07.
Windows Client .NET get started section has lots of WPF Videos.
Channel 9 WPF content.
Windows Presentation Unleashed is a very good book.
MSDN content for WPF.
MSDN magazine articles on WPF.
Well, the basics are there. You can drag and drop controls onto a XAML surface in VS.NET 2008 just about as easily as you can with Windows Forms. Sure, there's the binding syntax stuff, but getting started isn't too bad.
But you DEFINITELY need to buy a good book on it. You don't need to have read it from cover to cover in order to get started. A decent book will have you up and running in a chapter or two, and you can take it from there. Just make sure that whatever book you buy, it was published after .NET 3.5 (and SP1 preferably) came out.
Also, understand WHY you want to use WPF. Is it just because it's new? Then you're right, that's not a good enough answer. WPF does have some big benefits though:
A powerful binding expression syntax that actually works
No need to repaint your own windows in response to WM_PAINT messages
_ (corrollary to the previous point) It's much easier to owner-draw and make your own controls
MS is spending a LOT of effort to actually develop it
MS is spending minimal effort on developing WinForms
If you need 2d/3d data visualisation WPF will pay by itself quickly and it's very evolving...
Personally I've got in that boat because all 3d hardware acceleration (opengl) wrapper in c# are dying so the solution for a maintened 3d looks like wpf or xna...
I'd suggest you get either expression blend or vs2010 beta ... vs2008 just don't speak wpf enough to help someone who doesn't know exactly what he's trying to do.
I am about to write a front end app, which will be used as a media center app. It will plug directly into a high definition TV. Essentially transforming my laptop into a media player. While this concept is not new, I want custom functionality, so this is why I am not reusing existing products.
I'm a C# developer, so the app should ideally be written in C#. And there is 1 other consideration, I need to accept input via the MCE Remote.
I was considering using Silverlight for this. Would you recommend this? Or any other recommendations for frameworks before I begin planning around this.
Thanks in advance.
This is the type of stuff that the Windows Presentation Foundation was meant for. You'll get a lot more access to the hardware than Silverlight would provide (I.E. that MCE remote you mentioned). You mark up your UI with vector graphics/XAML, and then perform the logic with C#.
EDIT: WPF also has support out of the box for animations which can make your UI a lot more interactive.
EDIT 2: Scott Hanselman has written a really cool application called BabySmash and posted the source online. It basically intercepts keyboard input and shows shapes and sounds on the computer. It's a good "child-proofing" method for your PC. The code could provide you with some insight into WPF and how to do the animations and interactivity that you're looking for.
Is this a desktop app? If so I would use WPF. Silverlight is a subset of WPF, so using WPF you could potentially do more.
Silverlight or WPF, if you want some extra power. Both have a similar programming model (with XAML and code-behind) so you might be able to start with Silverlight and move up to WPF if you need.
The VLC api might be useful for playing your media, someone has created a C# wrapper for it:
http://wiki.videolan.org/.Net_Interface_to_VLC
WPF is certainly the way to go, and for playing media check out the excellent WPF MediaKit: http://wpfmediakit.codeplex.com/ I've used it successfully in many projects.
I'm using WINFORMS not WPF.
I just know basic c# .net gui programming. I donot want the traditional windows look. I want to have my own custom look (eg. gtalk, antivirus softwares, media players, google chrome).
Actually I'm inspired by google's PICASA software. Its awesome. I want to do something like that.How can I do that? If there is something I should learn please point me.
Also I may have to write my own custom controls (like modified tree view etc..) I guess. Please give some good learning resources.
This article describes how to draw custom windows. The author also shows how to draw non-rectangular windows.
If you could use WPF instead of Windows Forms, this is a good article about customizing window drawing:
http://www.codeguru.com/csharp/.net/net_wpf/article.php/c16379/
There is also a question with some good answers here on SO:
Creating custom forms in WPF?
Update:
I think that skinning and custom drawing is fun to do from a programmers perspective, but I also think that there is almost no benefit for the user.
The creators of the platform you are developing for might have put a lot of effort into the design of their windowing toolkits.
If you just want to change some visual aspects of your application you also should take into account that you might miss some important other aspects of UI design:
consistency
accessibility
aesthetics (if you are overdoing
effects, gradients, ...)
internationalization
...
As you are developing for Windows, you also lose the skinning ability of the OS itself. And I think that some of the skins that come with newer versions of Windows are pretty good.
You can try any of the following:
telerik
Syncfusion
(source: componentsource.co.jp)
Or other components.
They do make your UI pretty.
Edit: if you want to study how they do it, you can buy the source code-- along with documentation and understand from there.
There are some commercial control libraries available.
I can recommend the Krypton Suite. It consists of the free Krypton Toolkit (which contains a lot of skinnable controls) and other non-free controls (Navigator, Ribbon, Docking, Workspace). It has some built-in palettes and renderers that allow you to make your UI look like Office 2010, Office 2007, Office 2003, ...
You want to look for +winforms +skinning. I haven't tried these, but the first hits don't look bad. Most decent skinning tools will be paid for.
From what you said, you want to develop your own custom controls. You have some frameworks for this like Qt which can use Direct3D for hardware accelerated graphics. It also have a Visual Studio plugin. There is a free LGPL version and a commercial version of it.
I remembered about Qt because you mentioned Picasa and as far as I remember, I heard the Picasa UI has been written through Qt.
You can try using "SetWindowRgn(..)" to set an arbitrary region for your window. This may range from giving a rounded rectangle shape to giving a weird looking shape to the form!
Check this out: Link.
There is another option if you are working in Vista(aero enabled), ie you can check out DwmExtendFrameIntoClientArea(..) function here: link text
You can set the form's border style to 'none' and go on to create your custom form! You then might have to create custom buttons to carry out tasks like close, minimise, maximise etc. You might even need to write code for drag and drop events..
For the background, you might need to have a look at the gradient fills to give a great effect, otherwise you can use great looking pictures as Background..! But the latter option isnt good unless you have really good pic.
I would love to brainstorm with you guys on how to program this game (originally a flash game) in C#. I'm studying C# right now and my knowledge is pretty limited: I know the pretty much the basics of C# but I need your help with the concept.
Here's the game:
http://www.composica.com/product/samples/AstroHops/content/scaler.html
alt text http://img12.imageshack.us/img12/5735/frogim3.jpg
I thought about using imagebutton for each lilypad that would trigger a modal window with question.
I also thought about placing a picture of a frog on each lilypad, set to visible = false. When the a certain lilypad is selected the frog's visibility will be set to true.
Any thoughts, ideas, suggestion on how to this better?
Maybe links to a similar game coded with c#?
Thanks!
ASP.NET (and HTML generally) isn't directly suited to compete with flash - they simply work differently. Perhaps look at Silverlight; that is the MS offering that is closest to flash, and you can use C#.
Marc solution seems like best one, but if you really need it in C# (in ASP.NET Right?)
then you might consider AJAX but yea it is sort of bad approach.
If it is winforms you are talking about, then i would consider using some 2d graphics engine for that. otherwise your idea CAN work with the default .net forms, it just wont look very nice....
you might take a look at this, seems like a nice start point for working with directX and c#
http://www.csharp-home.com/index/tiki-print_article.php?articleId=146
Good luck with your project!