1 / 31

Object Orientated Programming using C#

Object Orientated Programming using C#. Module 201 Object Oriented Programming Lecture 1 – Introduction. Objectives. What is the .NET Framework? Introduction to C# Visual Studio Forms Controls Naming conventions. .NET Framework. The .NET Framework is

kynan
Download Presentation

Object Orientated Programming using 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. Object Orientated Programming using C# Module 201 Object Oriented Programming Lecture 1 – Introduction

  2. Objectives • What is the .NET Framework? • Introduction to C# • Visual Studio • Forms • Controls • Naming conventions

  3. .NET Framework • The .NET Framework is • A software development environment • A runtime engine for Managed Code • A platform designed for Internet-Distributed software • The .NET Framework is an exciting new computing platform

  4. .NET Framework • Microsoft’s vision to introduce an improved programming experience • Installed on Windows Operating Systems • A software development environment • A runtime engine for Managed Code

  5. Architecture • Common Language Infrastructure (CLI) • .NET libraries are provided as a language-neutral platform • Common Language Runtime • A runtime provides services from the operating system and hardware • The CLR Provides: • Memory management • Thread management • Exception handling • Garbage collection • Security • The CLR allows users to ignore specifics for the CPU and get on with programming the task

  6. .NET Platform Architecture

  7. C# Language • Why C# • Uses .NET framework • Works with common editors • Intuitive syntax • Powerful features • Close syntax to Java

  8. Visual Studio • Development tool for the programmer • Includes • Graphical User Interface (GUI) • code editor supporting IntelliSense • Syntax • building GUI applications • web designer • class designer • database schema designer

  9. Visual Studio Cost • Download free version • Search for Visual Studio Express 2008 • Download C# version • 30 days free trial – register to continue usage • Or make use of DreamSpark Version

  10. Load Visual Studio Menus Solution Explorer Toolbox Code Area Properties Messages Area

  11. Create a Simple Project • File -> New

  12. Solution Explorer • Displays all projects in solution • Shows all files in project • Files organisation • Project references

  13. Resources Files • .resx • Efficient and secure method of storing objects within application • Images (PNG, BMP, GIF, JPEG, TIFF) • Audio • Text • Strings • Icons • Access resources programmatically

  14. Window Docking • Floating • Dockable • Tabbed Document • Auto hide • Hide http://blogs.msdn.com/b/saraford/archive/2004/05/14/132065.aspx

  15. Project Properties

  16. Building Projects • Build project (F6) • Complies code for platform • Creates executable file • File locations • EXE file

  17. Visual Studio Help

  18. Forms • A Form is for the creation of a Graphical User Interface • Provides user interaction with the code • Positioning of user controls • A program can have one or more forms • Forms can be various sizes

  19. Form Controls and Properties • Form Controls include • Buttons • Textboxes • Radio buttons • Check boxes • Labels • Sliders • Tabs • List boxes

  20. Form Controls and Properties • Properties • All controls have a unique name for identification within the code • Control size X & Y • Colour • Screen position • All controls don’t necessarily have the same properties

  21. Properties • Define the control’s properties • Writes code for you

  22. Form Properties • Name – String • AcceptButton – String • CancelButton - String • Icon – Windows icon • BackColor - RGB • Enabled – True/False • Font – Style, Size, Colour • Location – X,Y • MaximizeSize – X/Y • MinimizeSize – X/Y • Size – X,Y • WindowState – Maximize, Minimize, Normal

  23. Button Properties • Name – String • Text - String • BackColor - RGB • DialogResult – OK, Cancel, Abort, Retry, Yes, No • Enabled – True/False • Font – Style, Size, Colour • Location – X,Y • Size – X,Y • TextAlign – Left, Right, Centre, Top, Middle, Bottom • TabIndex – int • Visable – True/False

  24. Add Controls • Add the following controls • Label • Button • ListBox • TextBox • PictureBox • Change some properties

  25. Aligning Controls • Use this control to align controls on a form • In most cases you will need to select two or more controls to align • Use the shift key to select multiple controls

  26. Coding in C# and Visual Studio • IntelliSense • Microsoft's implementation of auto-completion • Code is separated into several files • AssemblyInfo.cs – Assembly information • Author • Company • Version/build • Form.Designer.cs - Form controls • Program.cs – application code

  27. Control Naming • Controls using in your programs require appropriate naming • This aids the developer by: • Providing a description of the control • Reduces naming conflicts • Use a naming convention • Modified Hungarian Notation

  28. Simple Naming Conventions • [prefixes][Basename] • Prefixes - A Prefix is created to mnemonically represent the word it abbreviates, such as "frm" for "form" • Basename - The base name is the your own name for the particular object • btnOK • txtTitle • lstNames

  29. Modified Hungarian Notation

  30. Summary • What is the .NET Framework? • Introduction to C# • Visual Studio • Forms • Controls • Naming conventions

  31. Next Time • Primitive data types • Maths operators

More Related