1 / 18

Introduction to visual programming C#

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.

Télécharger la présentation

Introduction to visual programming C#

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to visual programming C#

  2. 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#

  3. 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

  4. Event Based Programming

  5. 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

  6. The Event-Based Model • 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

  7. Visual Studio .Net designer controls Properties, events

  8. GUI Tree Structure GUI Internal structure Form Form Button containers Panel Panel Button Label Label

  9. Components API Properties Like member fields Get, set E.g. Button1.Text = “Press Me” Methods Like member functions Tell component to do something E.g. Button1.Show( ) Events Like callback functions Receive notifications from component E.g. Button1.Click(e)

  10. Typical command line program • Non-interactive • Linear execution program: main() { code; code; code; code; code; code; code; code; code; code; code; code; }

  11. 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; … } } }

  12. User input commands Non-linear execution Unpredictable order Event callback procs Typical GUI program GUI program: main() { decl data storage; initialization code; create GUI; register callbacks; main event loop; } Callback1() //button1 press { code; } Callback2() //button2 press { code; } …

  13. 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 .NETplatform allows applications to be distributed to a variety of devices.

  14. The first program

  15. The first program

  16. The first program 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

  17. The first program 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

  18. The first program

More Related