introduction to visual programming c#
DESCRIPTION
Introduction to visual programming C#. Learning Outcomes. In this chapter, you will learn about : Event-Based Programming The Event Based Model Application Programming Interface (API) Different types of programs The first program with visual C#. Event Based Programming. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/1.jpg)
Introduction to visual programmi
ngC#
![Page 2: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/2.jpg)
Learning OutcomesLearning Outcomes
In this chapter, you will learn about :
Event-Based Programming
The Event Based Model
Application Programming Interface (API)
Different types of programs
The first program with visual C#
![Page 3: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/3.jpg)
Event Based Programming Event-based programs provide fully functioning
GUIs
An event is initiated by a user action
A program must:
– Correctly assess which specific event has occurred
– Provide the appropriate code to perform an action based on the identified event
![Page 4: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/4.jpg)
Event Based Programming
![Page 5: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/5.jpg)
Event Based Programming Actions that trigger events include:
– Placing the mouse pointer over a button and clicking the left mouse button
– Using the TAB key until the desired button is highlighted with a dotted line then pushing the Enter key
– Pressing an accelerator key
The sequence of events in a program are controlled by the user
![Page 6: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/6.jpg)
Operating system:– Has total control of computer
– Never relinquishes control to any executing programs
Most executing programs spend the majority of their time in a sleep type of mode
When an event occurs:– The operating system passes event information to
the appropriate application
– Permits the application to take action
The Event-Based Model
![Page 7: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/7.jpg)
Visual Studio .NetVisual Studio .Net
controls
designer
Properties,events
![Page 8: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/8.jpg)
GUI Tree StructureGUI Tree Structure
Panel
Button
Form
Label
GUI Internal structure
containers
Panel Button
Form
Label
![Page 9: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/9.jpg)
Components APIComponents API
PropertiesLike member fieldsGet, set E.g. Button1.Text = “Press Me”
MethodsLike member functionsTell component to do somethingE.g. Button1.Show( )
EventsLike callback functionsReceive notifications from componentE.g. Button1.Click(e)
![Page 10: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/10.jpg)
• Non-interactive
• Linear execution
program:
main(){
code;code;code;code;code;code;code;code;code;code;code;code;
}
Typical command line programTypical command line program
![Page 11: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/11.jpg)
Interactive command line program User input commands
Non-linear execution Unpredictable order
program:
main(){
decl data storage;initialization code;
loop{
get command;switch(command){
command1:code;
command2:code;
…}
}}
![Page 12: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/12.jpg)
User input commands
Non-linear execution Unpredictable order
Event callback procs
Typical GUI programGUI program:
main(){
decl data storage;initialization code;
create GUI;register callbacks;
main event loop;}
Callback1() //button1 press{ code;}Callback2() //button2 press{ code;}…
![Page 13: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/13.jpg)
C Sharp (C#)C Sharp (C#) C# was designed specifically for the .NET platform
as a language that would enable programmers to migrate easily to .NET.
C# is object oriented and has access to a powerful class library of prebuilt components.
It has roots in C, C++ and Java, adapting the best features of each.
Microsoft introduced C# along with its .NET strategy in 2000.
The .NET platform allows applications to be distributed to a variety of devices.
![Page 14: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/14.jpg)
The first program
![Page 15: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/15.jpg)
The first program
![Page 16: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/16.jpg)
The purpose of the code is so that you can add your own methods to handle the logic for your application, such as what happens when the user clicks the OK button
The first program
![Page 17: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/17.jpg)
Double click the ok Button on the form. A new method has been added called ok_click. We add the code to the ok_click method
The firstThe first program
![Page 18: Introduction to visual programming C#](https://reader033.vdocument.in/reader033/viewer/2022061420/56813066550346895d963eae/html5/thumbnails/18.jpg)
The firstThe first program