Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
5.00/5 (4 votes)
See more:
Hello

I'm busy with a little app for my kiddie to practice math. I'm doing ok with generating some simple add and subtract sums, but the user interface is so not funky or appealing to a kid.

Using VS2010, vb.net, Windows Forms Application - I'm not familiar with much else than this - so guess best to stick with what I know

Any ideas on backgrounds, cool ways to display scores, animations, sounds etc that are easily implemented would be much appreciated (more by my son than me :))

Thanks

Richard
Posted
Comments
Richard C Bishop 6-Aug-12 15:43pm    
Patterncooler has easily adjustable backgrounds you can use.
Richard.Berry100 6-Aug-12 15:58pm    
Ey richcb - that is soooo cool!!! Thanks so much! Already it looks so much better. Sure my kiddie is going to love it!
Richard.Berry100 6-Aug-12 18:56pm    
How risky is it to donate to his website?
Richard C Bishop 7-Aug-12 10:04am    
I have not ever done it personally, but it is legitimate as far as I know. It was recommended to me by an instructor at school.
Sergey Alexandrovich Kryukov 6-Aug-12 15:55pm    
I really appreciate that you want to do it all by yourself, not to buy or download. This is what a real farther does! How else could you earn respect and educate your children on positive model?
My 5 for the question, and best wishes.
--SA

It is in general a lot simpler to design custom user interfaces with WPF than WinForms. Its not that different in code behind, but the possibilityes are endless.

There is also Blend witch were created for designers...

[Edit]
BTW: Blend is designed to work together with WPF, and you can make some applications with is, that would have been extroardinary much work in WinForms. Take a look at these tow applications:

WPF Grand Prix[^]

WPF Rubik's Cube[^]

The last example is actually in VB.NET.

[/Edit]
 
Share this answer
 
v2
Comments
Richard.Berry100 6-Aug-12 16:15pm    
Thanks Kenneth - I suspected there was probably a better way of doing this than Win Forms. I'm not a professional developer, and most of the apps I do are more database related. I've been keen to change to C# instead of vb, but every time I start an app in C#, I end up getting frustrated with syntax and for the sake of getting the job done fast, I end up in vb again. What is the future of WPF? Metro? I know nice looking user interfaces make people think you can write great code, but whats really best? Be interested to hear your opinion!
Sergey Alexandrovich Kryukov 6-Aug-12 16:27pm    
Let me note that, for your purpose, you can afford to ignore questionable future of any library. You got it now, use it. Use your sense of value -- you won't be able to predict crazy market-driven future where some good technologies may arise and some lousy win, and later better approach will be re-created anyway, but not always preserving your investment. Just do it. Nobody will break your instance of the OS you are using right now, after all, and it will continue to work for you on your computer. It's better to be ready for everything.

As to WPF and the future, let me tell you one important thing: the main drive is going out of Windows. WPF is almost not related to Windows API. And Microsoft and third parties actively work at post-Windows OS (Microsoft's code name "Midory"), where .NET (SLR, more exactly) will be the only platforms, right on top of HAL. I don't consider Windows 8 as anything serious, not even mentioning Metro (they can blow it as everything to make it a commercial success, but it won't make it serious).

From the other hand, these days only the Forms is multi-platform. I can run some of my Forms application on Linux, Mac OS X and more, because SLR is implemented for them (this is mostly Mono), and Forms is not standard, but ported, too, as well as ADO.NET and some other non-standard libraries.

That's why I described both Forms and WPF approach in my answer. WPF is easier to develop, in your case. You decide...
--SA
Sergey Alexandrovich Kryukov 6-Aug-12 16:17pm    
You are right, but I dedicate a more detailed answer on both Forms and WPF. Please see.
--SA
Sergey Alexandrovich Kryukov 6-Aug-12 16:39pm    
Nice sample applications referenced, a 5.
--SA
Kenneth Haugland 6-Aug-12 16:42pm    
Thanks :)
First and foremost, teach you kids to take interest in non-funky stuff. This way, you will send an important message: most interesting things lie much deeper then the outer shell. Make your application really interesting, not due to funky colors and shapes. If you need to educate good taste, first learn good taste by yourself. This is not easy, but when you get it (I don't know hot to tell you are ready though, many never ever come to it :-)), you will know yourself what you can do.

Now, back to technical issues. This is a pretty big topic. All graphics is rendered in handling of the Windows message WM_PAINT. The window does not store any information on the graphics, so if a part of a form is closed by the other window, and then shown again, it will send you the message again. To handle it, you need to override the method OnPaint or handle the event Paint. Don't repeat the common mistake: use the instance of System.Drawing.Graphics passed to you in the event arguments, don't create an instance.

For animated or interactive behavior, you need to change data used in rendering and invalidate the scene using Control.Invalidate. You can use Invalidate with parameters (Region or Rectangle) to invalidate only a part of the scene and avoid excessive redrawing, to improve performance.

Using these techniques, you can render arbitrary image in custom controls (including Form) and implement animation.

Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^].

For animation, you will need to develop a moving scenario using a separate thread. Basically, you need to have some data representing the scene or its parameters. In the thread, you should change this data step by step. On each step, you need to notify the UI thread on the change, so the scene could be fully or partially re-drawn, via a call to Invalidate. The problem is that you cannot call anything related to UI from non-UI thread. Instead, you need to use the method Invoke or BeginInvoke of System.Windows.Threading.Dispatcher (for both Forms or WPF) or System.Windows.Forms.Control (Forms only).

You will find detailed explanation of how it works and code samples in my past answers:
Control.Invoke() vs. Control.BeginInvoke()[^],
Problem with Treeview Scanner And MD5[^].

See also more references on threading:
How to get a keydown event to operate on a different thread in vb.net[^],
Control events not firing after enable disable + multithreading[^].

To avoid flicker in animated or interactive rendering, always use double buffering:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.doublebuffered.aspx[^].

There is one more interesting thing you can use: non-rectangular controls, including forms. To have them, you simply need to assign its property Region to some non-rectangular Region instance. Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.region.aspx[^].

This is not so simple and will need some practice. I would advise not to afraid it. Speaking of your "more by my son than me": you would never interest your son in this stuff you are not really interested by yourself. So, huge perseverance and perfectionism is not a bad thing at all.

There is a simpler alternative though, if you switch to WPF from Forms. There are different levels of imagine in WPF, but almost everything I mentioned before is already done for you: animation, rendering, zooming/panning and a lot more. Basically, instead of handling events, you can simply have an instance of the Canvas, put all kinds of objects on it and move them around. Please see:
http://msdn.microsoft.com/en-us/library/system.windows.controls.canvas.aspx[^].

On top of it, you could have animations. Please see:
http://msdn.microsoft.com/en-us/library/ms752312.aspx[^].

Of course, you can always do self-made animation, to model more complex motion, with thread. You need to do it the same way I described above, with UI thread invocation mechanism.

This is just one WPF approach, but it looks like it's the closest to what you want.

Now, it leaves for sounds. You see, my answer is already too big for this forum. Consider this first, ask you follow-up questions. Sounds are easier and do not depend on the UI library. Let me find some more time later, to write about them…

—SA
 
Share this answer
 
v3
Comments
Richard.Berry100 6-Aug-12 17:01pm    
WOW! I dont think if I went to University I would get so much excellent knowledge offered to me in a matter of minutes! My son does appreciate simple things - we walk in the bush, and make a simple bow and arrow from a tree branch and a string - he loves it more than all these fancy toys full of bling and fancy noises! He's not doing great in math at school, so I'm gonna start with something basic for the beta version :) I will (thanks only to your answers, try a WPF app :) - and you make a good point - work with whats available now, but as a non-professional, whats quick to learn, and not going to be obsolete in a year's time means a lot to me..
Ok... I just opened a new WPF project and I get a window called MainWindow.xaml - Now what! (I dont expect you to answer that - just wanted to show my level of (or lack thereof) development expertise :)
Kenneth Haugland 6-Aug-12 17:05pm    
There would be a toolbox, and you can draw controls just like you did in WinForms.
Sergey Alexandrovich Kryukov 6-Aug-12 17:38pm    
That is true, but using Canvas is more high level, where the developer works immediately with visual UI elements, no need to pay attention for rendering detail and a lot more...
--SA
Richard.Berry100 6-Aug-12 19:07pm    
LOL - ok found it - looks a lil different - thanks!
Sergey Alexandrovich Kryukov 6-Aug-12 17:37pm    
First of all, let me express how much I appreciate your bow and arrow thing. This is much more important and useful for development than all that computing, especially in early age. Knife, modeling clay, paper, rope, thread, needle, wooden sticks, paintbrush -- those things are the best and will always be the best.

And computer games can be just plain harmful; I know too many sad cases... But prohibition can cause the opposite effect, so it makes no sense. The only remedy I know it to attract attention to "real things". And the real things are simpler and deeper at the same time. And of course, "the real thing" is something which takes effort and requires creative approach. This way, few hours in a row spend at, say, a a single sand castle, maybe a simple one, can bring a lot more skills development and -- important -- the sense of accomplishment, than months dying behind a keyboard in attempts to pass idiotic game "levels".

However, computer work is also very creative and can be introduced when a child can read from screen (I am not talking watching pictures or animated cartoon which can come very early), and as a distinct step, when a child gets close enough in motoric skill to handle a keyboard. (I would prefer if it comes as a result of exercise with a rope, a pencil, a piece of paper though.) The same sense of accomplishment would come from making computer drawing (by the way, buy a pressure sensitive tablet -- modest investment more valuable then 100 timer more powerful computer), and, eventually... programming. (If your son ever comes to it, you will be competing, it looks like... :-). I have one simple criterion for creative and useful activity -- if it creates some artifacts. For example, drawing can result into a drawing file, which you both would like to store and preserve. If you create something you want to preserve -- even something simple -- you are doing right thing.

Now, you are more then welcome to ask further questions, but I'll probably answer later. You should understand the volume of attention I can devote to each question is limited, but of course I prefer answer interesting questions, and yours are interesting to me, because I appreciate your interest in your activities with children. To answer your "now what?" question, the answer will be: "it depends on what do you want". The activity is very similar to Forms: you add some objects to the window or XAML code. You give the object some names (adding "Name" attributes in XAML elements, manually; this is what is different from Forms; as objects are not created as named members by default), and it would generate code to make those objects accessible for your code. You can add handlers ("+=") to object events to handle them (clicks, mouse moved, keyboard presses, etc.) That's it, basically. Perhaps you need from looking at some simple samples and read some overviews. Almost nothing is too difficult. Besides, you are the one who can afford giving up difficult problems and base your work on what you can certainly do -- it makes perfect sense.

You should understand that real "professionals" did exactly that -- nobody taught them (or us) Forms, WPF, etc. We just look on what is available on the platform. These days, documentation is much, much better than it was a decade or two ago.

And, as I gave you two answers, please consider accepting them formally (green button). If won't limit you on asking additional questions, on this page or separately. Just remember, if you want me to attend to some of your post, you will need to notify me by commenting on any of my post using "Reply".

Good luck,
--SA
Now, about the sounds. There are many layers for that.

First, this is very simple and useful interface people rarely use: sound a fixed frequency for a fixed period of time. This is enough to make a simple simulated musical instrument or something like that (but you will need to play sound in a separate thread, which is not a problem in this case). This is done via System.Console.Beep(int frequency, int duration); please see:
http://msdn.microsoft.com/en-us/library/4fe3hdb1.aspx[^].

As to the musical instruments, you can play a predefined set of those using MIDI. Now, this is already polyphonic. To use it with .NET, you will need a MIDI wrapper. CodeProject is a good source:
C# MIDI Toolkit[^],
Wrapper Library for Windows MIDI API[^],
Developing MIDI applications with DirectMusic[^].

Now, you can play a sound file:
http://msdn.microsoft.com/en-us/library/system.media.soundplayer.aspx[^].

Ultimately, you can create any waveform dynamically and play it. Please see:

C# Synth Toolkit - Part I[^],
C# Synth Toolkit - Part II[^],
recording and play using Waveform audio interface[^],
Using MCI to control multimedia[^].

This is a very interesting application where you can "play" an image you can draw in screen — really interesting:
Draw into sound[^].

And the last but not least — you can synthesize the human voice, which is quite easy, as you have a ready-to-use engine. Please see:
http://msdn.microsoft.com/en-us/library/system.speech.synthesis.aspx[^].

You will find a code sample in the MSDN help article referenced above.

Best wishes,
—SA
 
Share this answer
 
Comments
Kenneth Haugland 6-Aug-12 17:00pm    
Well, small question turned large. I like this :) a 5.
Sergey Alexandrovich Kryukov 6-Aug-12 17:05pm    
Thank you, Kenneth. Well, quite naturally it turns large. If one want to get anything good, especially for children...
--SA
Kenneth Haugland 6-Aug-12 17:08pm    
Ill guess he/she would be a little too young to deal with complex numbers:
http://www.codeproject.com/Articles/199800/Evaluate-complex-and-real-math-calculator

But it is also in WPF :)
Sergey Alexandrovich Kryukov 6-Aug-12 17:52pm    
Did you do it from scratch? Just from parsing the expression from screen? If so, I don't like it, because there is a much more fruitful way: to use CodeDOM and C#/VB.NET (more exactly, .NET language) code as a ready-do-use calculator. It takes just Reflection with dynamically compiled assemblies and -- the difficult part -- using Application Domains and hence IPC, because you cannot unload a loaded assembly, only a whole application domain; but they are isolated, so IPC is needed to communication. This is yet another unwritten article I have the code ready.
--SA
Kenneth Haugland 6-Aug-12 17:59pm    
"Did you do it from scratch? Just from parsing the expression from screen?"
All the coding is done from scratch, I did know about CodeDom, but looks interestig.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900