dt265-2 object oriented software development 2 lecture 3 : windows programming lecturer pat browne...

21
DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne [email protected]

Upload: lenard-hardy

Post on 24-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

DT265-2 Object Oriented Software Development 2

Lecture 3 : Windows Programming

Lecturer Pat [email protected]

Page 2: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

Windows Dialogs

Page 3: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

Components

From Windows Forms Programming with C# by Erik Brown

Page 4: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

Menu Class

From Windows Forms Programming with C# by Erik Brown

Page 5: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

Status Bar Class

From Windows Forms Programming with C# by Erik Brown

Page 6: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

Windows Dialogs

From Windows Forms Programming with C# by Erik Brown

Page 7: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

Using C# in easy steps

1. Getting Started2. Controls explained3. C# language essentials4. Object essentials5. Visual studio tools6. C# techniques7. Creating database programs8. Running C# on the internet

Page 8: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

C# in easy steps : 1 Getting Started

IntroductionC# and other languagesInstalling C#Making Sense of the IDEYour First ApplicationFirst look at ToolboxFirst Look at Property EditorGetting to know C# formsPlacing a buttonFirst look at eventsYour First line of codeSetting properties in codeA C# adding machineDealing with errorsHelpFirst look at solution ExplorerSaving your projectReopen Application

Page 9: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

C# in easy steps : 2 Controls Explained

Controls and MethodsUsing buttons and labelsUsing TextBoxesUsing Picture BoxesUsing CheckBoxesUsing RadioButtonsUsing ListBoxesUsing ComboBoxesThe OpenFileDialog ControlUsing the timerUsing the TabControlUsing the SplitterControlUsing Toolbar and RichTextBox (paste data from Word Document)Using MonthCalendar ControlSetting tab orderSome other controlsUsing Anchor and Dock properties

Page 10: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

C# in easy steps : 3 C# Language Essentials

IntroductionStart at the beginningThe parts of a C# fileIntroduction to data typesDoing sumsCurly brackets and semicolonsFunctions and parametersGiving variables a valueVariables and scopeUsing if .. else..Using do and whileUsing for loopsUsing SwitchArrays: dealing with a set of values.Using structsUsing enums for a range of valuesUnderstanding reference typesWorking with parametersMore about casting

Page 11: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

C# in easy steps : 4 Object Essentials

Object essentialsA first objectClasses and objectsConstructors and destructorsUsing Add Field and Add PropertyA list of booksWorking with collectionsInheritanceEncapsulation and interfaceOverloading and overridingStatic membersProtected and internal membersUnderstanding NamespacesThe using directiveObject lifetimeThe using statement

Page 12: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

C# in easy steps : 5 Visual Studio Tools

Creating a Menu, customizing & popupMaking a menu workWorking with the code editorUsing Clipboard RingUsing FindIntroducing the debuggerUsing BreakpointsThe locals and watch windowsTracking down errorsCustomizing the ToolboxUsing the Add-in ManagerExplaining the Reference ManagerSetting Visual C# optionsSetting project propertiesCreating a standalone applicationsWhere Help comes from

Page 13: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

GUI events

Page 14: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

C# Windows application

Page 15: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

Mouse Events

• The mouse is a primary interface for doing graphics in Visual C# Express. A program needs to recognize mouse events in controls.

• Many controls recognize mouse events.

Page 16: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

Mouse Events• private void panel1_MouseDown(object sender,• MouseEventArgs e)• {• switch (e.Button)• {• case MouseButtons.Left:• label1.Text = "Left";• break;• case MouseButtons.Middle:• label1.Text = "Middle";• break;• case MouseButtons.Right:• label1.Text = "Right";• break;• }• label2.Text = Convert.ToString(e.X) + "," +• Convert.ToString(e.Y);• }

Page 17: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

Mouse Events

Page 18: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

Write Windows version of Location Quotient program

• Make Windows version of LQ program• Invoke from menu, button or any other way.• Read file.• Perform LQ computation.• Print results in list box.

Page 19: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

SharpMap-0.9-Trunk-2012.04.17

• Download and install Sharpmap from• http://sharpmap.codeplex.com/releases/view/87500• http://sharpmap.codeplex.com/downloads/get/376940

• SharpMap-0.9-AnyCPU-Trunk-2012.04.17• Place with your other VisualStuidio projects.

• Download and run SharpmapDemo from• http://spatialhorizons.com/category/sharpmap/

• Download

Page 20: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

Generating Irish Grid letterThe Irish National Grid is a coordinate reference system for Ireland. It is measured in metres with a range (0,0) to (500,000,500,000). For ease of reference a set of labelled grid squares are used. These are A to Z with no I. The code below accepts an ING coordinate and returns the grid square that contains the coordinate.

Page 21: DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne patrick.browne@dit.ie

Generating Irish Grid letter

• See• http://www.gridreference.ie/

• http://www.dorcus.co.uk/carabus//ll_ngr.html

• http://www.simonstewart.ie/position/irishgrid.htm

• See code in notes section• Tasks

– Get input data from a CSV file– Write results to a CSV file– Prompt used for input/output files– Allow user to enter number specifying the number of digits in the

output (0-6)