Starting out as a beginner programmer I always wanted to make a real world application, something different from a command line application. I was just looking for a blog created by someone who keeps things simply stupid, some people think that programming is really easy, but the fact is "programming is a complex
thing you will ever get into as such it should be kept very simple for beginners like us"
I made this post to show you how simple it is to control what a button does when it is clicked, so whether you are a beginner that doesn't know anything about programming, you will be getting the real idea of what happens when a button is clicked on the Graphical User Interface of your program.
So, for you to get this idea, we are going to be developing a real WPF application that says "Hello Word!" when a button is clicked.
We will be doing this with Visual Studio 2012.
Features of our simple program includes:
Now lets add Speech Technology.
Right click Add Reference in solution explorer,
look for System.Speech,
check the box next to it and click ok.
Add the following using Statement
Add this before the the constructor:
and this inside the event method of the talkingButton:
Run your program and click the talking button. notice what happens when you clicked the button.
This is what we call event handling, there are other complex event you can handle, I suggest you play around with something.
Please ask your questions in the comment section along side your criticism.
Thanks for reading.
thing you will ever get into as such it should be kept very simple for beginners like us"
I made this post to show you how simple it is to control what a button does when it is clicked, so whether you are a beginner that doesn't know anything about programming, you will be getting the real idea of what happens when a button is clicked on the Graphical User Interface of your program.
So, for you to get this idea, we are going to be developing a real WPF application that says "Hello Word!" when a button is clicked.
We will be doing this with Visual Studio 2012.
Features of our simple program includes:
- speech technology: We will make our program speak the "Hello World" and as well print the text.
- and will try to make it look good.
- Start a new Visual studio project and name it TalkingButton.
- After the the project designer loads, resize the MainWindow so that the width becomes 525 and the Height 90.
- Drag a button from the tool window on the inner grid of the the MainWindow.
- Enter talkButton as the name and Talk as the Content.
- Add a textbox on the space that remains on the grid. and name it textView.
- Position the button so that it looks like this:
- Change the background color of the textbox to black and the foreground to any color you want.
- double click the button and program what the button does, in this case the button will force the textblock to print hello world on the screen. So our code will look like this:
private void talkingButton_click(object sender, RoutedEventArgs e)
{
textView.Text="Hello World";
}
Right click Add Reference in solution explorer,
look for System.Speech,
check the box next to it and click ok.
Add the following using Statement
using System.Speech.Synthesis;
Add this before the the constructor:
SpeechSynthesizer ss=new SpeechSynthesizer();
and this inside the event method of the talkingButton:
ss.SpeakAsync("Hello World");
Run your program and click the talking button. notice what happens when you clicked the button.
This is what we call event handling, there are other complex event you can handle, I suggest you play around with something.
Please ask your questions in the comment section along side your criticism.
Thanks for reading.
Comments
Post a Comment