Getting Started with Banjos4Hire

Similar documents
Lecture # 6 Engr. Ali Javed 11th March, 2014

CPSC Tutorial 5 WPF Applications

CPSC Tutorial 6

CPSC Tutorial 5

This tutorial is designed for software developers who want to learn how to develop quality applications with clean structure of code.

Yes, this is still a listbox!

1) ItemsSource: it point to collection which has all the objects that will be shown in the list

CS3240 Human-Computer Interaction Lab Sheet Lab Session 3 Designer & Developer Collaboration

Step4: Now, Drag and drop the Textbox, Button and Text block from the Toolbox.

This walkthrough assumes you have completed the Getting Started walkthrough and the first lift and shift walkthrough.

--Microsoft-- --Windows Phone--

Lesson 9: Exercise: Tip Calculator

Microsoft CSharp

WPF and MVVM Study Guides

Week 6: First XAML Control Exercise

ROUTED EVENTS. Chapter 5 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. of Babylon

Advanced Programming C# Lecture 3. dr inż. Małgorzata Janik

Lab - 1. Solution : 1. // Building a Simple Console Application. class HelloCsharp. static void Main() System.Console.WriteLine ("Hello from C#.

CHAPTER 1: INTRODUCING C# 3

S A M P L E C H A P T E R

Learn to Love Lambdas

Week 8: Data Binding Exercise (Bookstore)

Variable Scope The Main() Function Struct Functions Overloading Functions Using Delegates Chapter 7: Debugging and Error Handling Debugging in Visual

Weather forecast ( part 2 )

C# Programming: From Problem Analysis to Program Design. Fourth Edition

Note that each button has a label, specified by the Text property of the button. The Text property of the group box is also visible as its title.

9.3 Launchers and Choosers. Fast Application Switching and Design. Forcing a Program to be removed from memory

Lesson Plan. Subject: OBJECT ORIENTED PROGRAMMING USING C++ :15 weeks (From January, 2018 to April,2018)

Exam Name: TS: Windows Applications Development with Microsoft.NET Framework 4

Lab 4: Adding a Windows User-Interface

RadPDFViewer For Silverlight and WPF

Learning C# 3.0. Jesse Liberty and Brian MacDonald O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo

To start we will be using visual studio Start a new C# windows form application project and name it motivational quotes viewer

CS3240 Human-Computer Interaction Lab Sheet Lab Session 4 Media, Ink, & Deep Zoom

IAP C# Lecture 5 XAML and the Windows Presentation Foundation. Geza Kovacs

Introduction to Data Templates and Value Converters in Silverlight

A SharePoint Developer Introduction. Hands-On Lab. Lab Manual HOL5 Using Client OM and REST from.net App C#

Building Extensible XAML Client Apps

BUILDING A COM/ATL C# CLIENT

Silverlight memory board ( Part 2 )

ComponentOne. PdfViewer for WPF and Silverlight

Accurate study guides, High passing rate! IT TEST BOOK QUESTION & ANSWER. Ittestbook provides update free of charge in one year!

CPSC Tutorial 9 Blend & Animations

Copyright Soyatec. Licensed under the Eclipse Public License 1.0

Manipulating Web Application Interfaces a New Approach to Input Validation Testing. AppSec DC Nov 13, The OWASP Foundation

Exam sell. Higher Quality Better Service! Certified IT practice exam authority.

Menus. You ll find MenuStrip listed in the Toolbox. Drag one to your form. Where it says Type Here, type Weather. Then you ll see this:

CS111: PROGRAMMING LANGUAGE II

Developing Windows Applications with Microsoft Visual Studio 2010

Problem 1. Multiple Choice (choose only one answer)

sharpcorner.com/uploadfile/37db1d/4958/default.aspx?articleid=cb0b291c-52ae-4b80-a95c- 438d76fa1145

ComponentOne. HyperPanel for WPF

Preliminary 1: Download and install the Certificate Authority (CA) certificate

visual studio vs#d express windows desktop

In-Class Worksheet #4

Survey #2. Programming Assignment 3. Final Exam. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu.

Q&A. DEMO Version

Software Systems Development Unit AS1: Introduction to Object Oriented Development

MFC One Step At A Time By: Brandon Fogerty

KillTest. 半年免费更新服务

var xdoc = XDocument.Load(inStream);

Note: many examples in this section taken or adapted from Pro WPF 4.5 C#, Matthew MacDonald, apress, 2012, pp

STYLES AND BEHAVIORS

Java Programming Lecture 6

T, Earl Grey, Hot: Generics in.net

Course 2D_WPF: 2D-Computer Graphics with C# + WPF Chapter C1a: The Intro Project Written in XAML and C#

C# 2008 and.net Programming for Electronic Engineers - Elektor - ISBN

WPF Viewer for Reporting Services 2008/2012 Getting Started

WPF Debugging and Performance Succinctly

In this lecture we will briefly examine a few new controls, introduce the concept of scope, random numbers, and drawing simple graphics.

Your First Windows Form

Java Programming Lecture 7

This exam is open book. Each question is worth 3 points.

Lesson 13 Transcript: User-Defined Functions

Abstract Class. Lecture 21. Based on Slides of Dr. Norazah Yusof

Building Responsive Apps for Windows 10 Greg Lutz. GrapeCity

Windows Presentation Foundation

COMP1406 Tutorial 5. Objectives: Getting Started: Tutorial Problems:

Index. Windows 10 running, 199 suspended state, 199 terminate apps,

Computer Science AP 2017 Summer Assignment Mrs. McFarland

CSC 415 ONLINE PHOTOALBUM: THE SEQUEL ASP.NET VERSION

Getting Started with ExcelMVC

Learning VB.Net. Tutorial 19 Classes and Inheritance

Developing Windows Applications with Microsoft Visual Studio 2010 (MS 10262)

ComponentOne. Bitmap for WPF

4/25/ Xamarin. All rights reserved.

MCS 2514 Fall 2012 Programming Assignment 3 Image Processing Pointers, Class & Dynamic Data Due: Nov 25, 11:59 pm.

PESIT- Bangalore South Campus Hosur Road (1km Before Electronic city) Bangalore

BM214E Object Oriented Programming Lecture 8

Quick Guide for the ServoWorks.NET API 2010/7/13

Name of Experiment: Student Database

Introduction. Part I: Silverlight Fundamentals for ASP.NET Developers 1

C# Crash Course Dimitar Minchev

Developing Rich Internet Applications Using Microsoft Silverlight 4

Chapter 13. Object Oriented Programming

Fundamentals of XAML and Microsoft Expression Blend

Object Oriented Programming 2012

Sparkline for WPF 1. ComponentOne. Sparkline for WPF

EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University. Overview (Review)

Expressions and Casting

Transcription:

Getting Started with Banjos4Hire Rob Miles Department of Computer Science Data Objects There are a number of objects that you will need to keep track of in the program Banjo Customer Rental You can use the Account and Bank classes from the course and Yellow Book as good starting points Make sure that you have included all the required behaviours One way is to check them off the specification as you complete them 2 How to get started You don t create the entire application all in one The best approach is to build up the behaviours, one simple step at a time This is how we can create any kind of complex software system So, to start you must decide the sequence of items you are going to build 3 1

My Suggested Sequence 1. Create the Banjo class 2. Make the Load and Save behaviours for a single Banjo 3. Create the Shop class 4. Make the Load and Save behaviours for a Shop 5. Make the User Interface to find a particular Banjo in the Shop (use a ListView) 6. Make the User Interface to allow the Banjo to be manipulated 7. Repeat the process for Customer and Rental objects 8. Add the search behaviours 4 1. Create the Banjo Class 1. Read through the specification and identify the properties that the banjo should have: A description of the banjo as a string of text The price per day of hiring that banjo The value of the banjo The state of the banjo (either in the shop, being repaired or out on hire) A unique banjo ID 2. Add these to the Banjo class that you are building Create a constructor 3. Identify how the properties should be used Create methods for each change 5 2. Make the Load and Save behaviours 1. Create a Save method that will save the Banjo to a stream There is some sample code to do this in the lecture materials 2. Create a Load method that will fetch the Banjo from a stream 3. Create Load and Save methods that will work with files 4. Test these methods by loading and saving banjos 6 2

3. Create the Shop class 1. Create a Shop class that will contain everything in the shop 2. Initially just put a collection of banjos in the shop. 3. This can be a List or an array 4. Add methods to allow a program to add new banjos and search the shop for banjos There is some sample code to do this in the lecture materials for Accounts 7 4. Make Save and Load behaviours for the Shop 1. Write the Save behaviour To save the banjos the shop must write out the number of banjos and then write out each in turn 2. Write the Load behaviour To load the banjos the shop must read in how many banjos and then read each one in The Shop will use the Load behaviour from the Banjo to load each one There is some sample code in the lecture notes 8 5. Make the User Interface to find a Banjo 1. Create the code to find a banjo It can do this from the description of the banjo The user will enter the search information and then trigger a search of the banjos 2. Populate the display with the banjo information when it is found 3. Alternatively you can use a ListView to show all the items and then detect when one is selected 9 3

6. Add the Banjo User Interface 1. Add TextBoxes and Buttons to allow the required functions to be performed The functions will all be selected from the single page This will keep the user interface simple All the actions will be performed on the currently active banjo the one that has been selected 2. Test each action, and make sure that the changes that are made are persisted in the stored version of the banjo 10 A Simple Banjo Class class Banjo string Description; public Banjo(string indescription) Description = indescription; public override string ToString() return Description ; The Banjo class holds information about a banjo This version just holds the description 11 Banjos and Bank Accounts You can treat a Banjo just like we treat Bank Accounts You need to be able to add a banjo to the store and find a banjo by its ID (the banjo ID is just like an account number) You also need to save and load the banjo data to a file You can use the same save and load behaviours that you created for accounts 12 4

A Simple Shop Class class Shop string ShopName; public List<Banjo> Banjos; public Shop(string inname) ShopName = inname; Banjos = new List<Banjo>(); The Shop class holds all the shop information This includes a list of banjos 13 Making Test Data public void MakeTestData() Random r = new Random(1); AddBanjo("The Strummer", r.next(500, 10000)); AddBanjo("The Woodsman", r.next(500, 10000)); AddBanjo("Deep Twang", r.next(500, 10000)); AddBanjo("Clawhammer Grip", r.next(500, 10000)); This method is held in the Shop class It makes a few banjos and stores them The AddBanjo method accepts a name and a value for the banjo This is much easier for testing than typing them in 14 Create some Test Banjos string[] banjonames = new string[] "The Strummer", "The Woodsman", "Deep Twang", "Clawhammer Grip", "Beard Tangler", "Old Smokey", "Vera", "Front Porch Special", "Plain White", "The Trumpet", "Mr Parse", "Big Earl" ; This is an array of banjo names that you can use in your program if you like We could write a loop that creates a set of banjos with those names and random values If you want to you can add more names to the list 15 5

The Rental class A customer will contain a list of rentals that the customer has made Each rental will contain the start and end of the rental and the banjo that was rented The relationship between Rental and Customer is very similar to the one between BanjoStore and Banjo One contains a collection of the other 16 Designing your Solution You may be wondering where does the data live when the program is running? When the program is active the main page will hold a reference to the shop that holds the data the program is working on When the program starts the shop data will be loaded, and when the program ends the shop data will be stored 17 Events in Windows Presentation Foundation (WPF) In a WPF application parts of the program run in response to events that are produced by the WPF framework We have seen that we can make buttons on the screen cause events in the program There are also events that fire when the program starts and when it ends The program will use these events to trigger when the data is loaded and saved 18 6

Window Loaded Event Visual Studio will connect window events to methods for us This event occurs when the program loads the main window and displays it That is when we want to load our data 19 Setting up the Shop in Window_Loaded public partial class MainWindow : Window public MainWindow() InitializeComponent(); Shop ActiveShop; private void Window_Loaded(object sender, RoutedEventArgs e) ActiveShop = new Shop("Test Shop"); ActiveShop.MakeTestData(); This makes a new shop when the program starts In the finished program it will load the data from a file 20 Saving in the Window Closing event There is a corresponding event which is fired when the user leaves the program This is when your application should save the data to a file Note that this means the user never actually saves and loads the information The data is automatically saved and loaded when the program is started and stopped This makes the program much easier to use 21 7

Showing Lists using the ListBox component <ListBox Height="109" HorizontalAlignment="Left" Margin="87,142,0,0" Name="BanjosListView" VerticalAlignment="Top" Width="326" /> BanjosListView.ItemsSource = ActiveShop.Banjos; The ListBox is a XAML component that can display lists We can add it to the XAML in our page very easily It will display a collection of items if we set the ItemsSource property to the collection we want to see 22 ItemsSource in ListView The ListView uses the ToString method of the object to get the string to display in the box In my Banjo class this returns all the banjo details 23 Selection Changed Events Our program can connect to an event which fires when the user selects a different item in the ListView This is how we can get our users to select banjos from the list 24 8

Dealing with Selection Changed Events private void BanjosListView_SelectionChanged(object sender, SelectionChangedEventArgs e) MessageBox.Show(e.AddedItems[0].ToString() + " was selected"); The event handler for the selection changed event is given a list of items that were selected We can use this in our program identify which items is required 25 Problem Solving Keep each individual step a small one so that it is easy to debug Don t run away from problems you can t solve to other problems that you can t solve either Get help when you are stuck, but make sure that you ask How do I do this? rather that What do I do? 26 9