Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 4: Intro to GUIs and the.

Slides:



Advertisements
Similar presentations
6. WinForms: GUI Programming in.NET. 2 Microsoft Objectives.NET supports two types of form-based apps, WinForms and WebForms. WinForms are the traditional,
Advertisements

Computer Programming and Basic Software Engineering 9 Building Graphical User Interface Developing a Simple Graphical User Interface (GUI)
C#: Data Types Based on slides by Joe Hummel. 2 UCN Technology: Computer Science Content: “.NET is designed around the CTS, or Common Type System.
Chapter 1: An Introduction to Visual Basic.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Graphical User Interface (GUI) A GUI allows user to interact with a program visually. GUIs are built from GUI components. A GUI component is an object.
Outline Review Visual Basic.NET Environment Review Visual Basic.NET Environment First Visual Basic Planning and Programming First Visual Basic Planning.
C#/.NET Jacob Lewallen. C# vs.NET.NET is a platform. Many languages compile to.NET: –VB.NET –Python.NET –Managed C++ –C#
Slide 1 ICS 012 Visual Programming I Ahmed Esmat Second.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
C# Programming: From Problem Analysis to Program Design1 Introduction to Windows Programming C# Programming: From Problem Analysis to Program Design 3.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Introduction to Visual Basic. What is Visual Basic? An environment for developing Windows applications Components –A GUI (Graphical User Interface - gooey)
CIS 115 Lecture 2.  Visual Studio 2005 Professional Edition (Requires Windows XP Pro)  MSDN Library for Visual Studio 2005 Available from MSDNAA.
Chapter 3 Introduction to Event Handling and Windows Forms Applications.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 8: WebForms — Web-based.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Not in Text CP212 Winter No VBA Required “Regular” Programming traditional programming is sequential in nature o one command executed after another.
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
Microsoft Visual Basic 2005: Reloaded Second Edition
Neal Stublen Class Objectives  Develop an understanding of the.NET Framework  Gain proficiency using Visual Studio  Begin learning.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
1 Visual Basic for Applications (VBA) for Excel Prof. Yitzchak Rosenthal.
An Introduction to Visual Basic
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Chapter 8: Writing Graphical User Interfaces
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Chapter 3 – Fundamentals of Programming in VB.NET VB.NET Controls VB.NET Events Numbers Strings Input and Output.
Chapter 8: Writing Graphical User Interfaces Visual Basic.NET Programming: From Problem Analysis to Program Design.
Introduction to Visual Basic.NET Chapter 2 Introduction to Controls, Events.
Basic Controls & Properties Chapter 2. Overview u VB-IDE u Basic Controls  Command Button  Label  Text Box  Picture Box u Program Editor  Setting.
COS240 O-O Languages AUBG, COS dept Lecture 33 Title: C# vs. Java (GUI Programming) Reference: COS240 Syllabus.
Windows Forms. Architecture Wrapper around WIN32API Part of the.NET Framework Code can be in C# or VB Toolbox has forms elements (buttons, etc.) Dragging.
Lecture 6: Introduction to Graphical User Interfaces (GUIs)
Introduction to Windows Programming
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Introduction to Visual Studio & GUI Programming Prepared by: Ahmad Ramin Rahimee Assistant Professor ICTI.
C# GUI - Basics. Objectives.NET supports two types: WinForms, traditional, desktop GUI apps. WebForms – newer, for Web apps. Visual Studio.NET supports.
Applications Development
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
What is Visual Basic.NET? 110 B-1 e.g. a word processor doesn’t do anything until the user clicks on a button, types text... A programming language that.
3.2 VB.NET Events An Event Procedure Properties and Event Procedures of the Form Tab Order of Controls Exercises.
MS Visual Basic 6 Walter Milner. VB 6 0 Introduction –background to VB, A hello World program 1 Core language 1 –Projects, data types, variables, forms,
1 Advanced Computer Programming Lab Calculator Project.
Chapter 3 - VB.NET by Schneider1 Chapter 3 – Fundamentals of Programming in VB.NET Part I VB.NET Controls VB.NET Events.
Created by Alia Al-Abdulkarim 2008 Visual Basic Vs. Java.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
INTRODUCTION CHAPTER #1 Visual Basic.NET. VB.Net General features It is an object oriented language  In the past VB had objects but focus was not placed.
Week 1 Lecture 1 Slide 1 CP2028 Visual Basic Programming 2 “The VB Team” Copyright © University of Wolverhampton CP2028 Visual Basic Programming 2 v Week.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Chapter 2 - VB 2008 by Schneider1 Chapter 2 –Visual Basic, Controls, and Events 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual.
Computer Science Up Down Controls, Decisions and Random Numbers.
GUI Programming Prepared by: Ahmad Ramin Rahimee Assistant Professor ICTI.
.NET MCQs MULTIPLE CHOICE QUESTION
Visual Basic Fundamental Concepts
Chapter 1: An Introduction to Visual Basic .NET
Reference: COS240 Syllabus
Computer Programming and Basic Software Engineering 9 Building Graphical User Interface Developing a Simple Graphical User Interface (GUI)
Variables and Arithmetic Operations
VISUAL BASIC.
Visual Basic..
Building an Application in the Visual Basic .NET Environment
6. WinForms 2003 C# GUI - Basics.
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Setting Properties of Objects
Presentation transcript:

Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 4: Intro to GUIs and the other.NET Languages

GUIs and Languages 4.1 Intro to GUIs Graphical User Interfaces Event-driven programming WinForms

GUIs and Languages A Simple GUI Application Consider a Calculator app for performing addition:

GUIs and Languages GUIs are Event-driven Idea is very simple: –individual user actions are translated into “events” by OS — mouse click, mouse move, keypress, window activation, etc. –events are passed, 1 by 1, to application for processing –this is how most GUIs are programmed (Java, X,.NET, etc.)… GUI App

GUIs and Languages Code-behind Events are handled by methods that live behind visual interface –known as "code-behind" –our job is to handle the events we care about…

GUIs and Languages GUIs in.NET In.NET you can build two types of GUI applications –WinForms: this is a traditional desktop Windows GUI application –WebForms: this is a web-based GUI application It’s incredibly easy and intuitive –approach made famous by Visual Basic in the 1990's…

GUIs and Languages Example — Let's Create Calculator App Step-by-step…

GUIs and Languages (1) Create Project Create a new project of type “Windows Application” –a blank form (window) will be created for you automatically –inherits default behavior from System.Windows.Forms.Form

GUIs and Languages (2) Configure Form The Properties window is your friend Form properties to consider: –Text, StartPosition, Font, FormBorderStyle, MaximizeBox, …

GUIs and Languages (3) Design UI Select desired controls from Toolbox… –Hover mouse over Toolbox to reveal –Drag-and-drop onto form –Position, resize, set properties

GUIs and Languages (4) Naming Conventions Control’s programmatic name is set via (Name) property Naming convention is a 3-letter prefix –lbl, txt, cmd, etc.

GUIs and Languages public partial class Form1 : Form { private void cmdAdd_Click(object sender, EventArgs e) { int i, j, k; i = System.Convert.ToInt32(this.txtNumber1.Text); j = System.Convert.ToInt32(this.txtNumber2.Text); k = i + j; string msg; msg = "Sum = " + k; System.Windows.Forms.MessageBox.Show(msg); } public partial class Form1 : Form { private void cmdAdd_Click(object sender, EventArgs e) { int i, j, k; i = System.Convert.ToInt32(this.txtNumber1.Text); j = System.Convert.ToInt32(this.txtNumber2.Text); k = i + j; string msg; msg = "Sum = " + k; System.Windows.Forms.MessageBox.Show(msg); } (5) Code Events of Interest Double-click on object to reveal default event handler Example: –Double-click on button to reveal Click event…

GUIs and Languages (6) Run! Press F5 at any time to run what you have… static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run( new Form1() ); } static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run( new Form1() ); }

GUIs and Languages 4.2 The Other.NET Languages VB C++ J#

GUIs and Languages The.NET Languages Microsoft provides four languages for.NET: –C# –VB.NET friendlier syntax, case-insensitive, equivalent in power to C# –J#: Java 1.4 syntax, Java 1.2 class library +.NET class library –C++: 99% ANSI C++ generates managed (.NET) code or unmanaged (native x86) code It's about the concepts, not the language! –in.NET, the language really doesn't matter… –the standard languages have essentially the same.NET power –really just a matter of preference…

GUIs and Languages VB Let's rewrite the calculator in VB… Option Strict On Private Sub cmdAdd_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles cmdAdd.Click Dim i, j, k As Integer i = System.Convert.ToInt32(Me.txtNumber1.Text) j = System.Convert.ToInt32(Me.txtNumber2.Text) k = i + j Dim msg As String msg = "Sum = " & k System.Windows.Forms.MessageBox.Show(msg) 'A comment in VB End Sub Option Strict On Private Sub cmdAdd_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles cmdAdd.Click Dim i, j, k As Integer i = System.Convert.ToInt32(Me.txtNumber1.Text) j = System.Convert.ToInt32(Me.txtNumber2.Text) k = i + j Dim msg As String msg = "Sum = " & k System.Windows.Forms.MessageBox.Show(msg) 'A comment in VB End Sub

GUIs and Languages C++ And now let's rewrite in C++… –With C++, you have 3 type systems to worry about — C, C++, and.NET private: System::Void cmdAdd_Click(System::Object^ sender, System::EventArgs^ e) { int i, j, k; i = System::Convert::ToInt32( this->txtNumber1->Text ); j = System::Convert::ToInt32( this->txtNumber2->Text ); k = i + j; System::String^ msg; msg = "Sum = " + k; System::Windows::Forms::MessageBox::Show(msg); } private: System::Void cmdAdd_Click(System::Object^ sender, System::EventArgs^ e) { int i, j, k; i = System::Convert::ToInt32( this->txtNumber1->Text ); j = System::Convert::ToInt32( this->txtNumber2->Text ); k = i + j; System::String^ msg; msg = "Sum = " + k; System::Windows::Forms::MessageBox::Show(msg); }

GUIs and Languages J# And finally, in J#… –In J#, you can use Java's class library and.NET's class library private void cmdAdd_Click(Object sender, System.EventArgs e) { int i, j, k; i = System.Convert.ToInt32( this.txtNumber1.get_Text() ); j = System.Convert.ToInt32( this.txtNumber2.get_Text() ); k = i + j; String msg; msg = "Sum = " + k; System.Windows.Forms.MessageBox.Show(msg); } private void cmdAdd_Click(Object sender, System.EventArgs e) { int i, j, k; i = System.Convert.ToInt32( this.txtNumber1.get_Text() ); j = System.Convert.ToInt32( this.txtNumber2.get_Text() ); k = i + j; String msg; msg = "Sum = " + k; System.Windows.Forms.MessageBox.Show(msg); }

GUIs and Languages 4.3 The CTS The Common Type System

GUIs and Languages The Underlying.NET Type System CTS = Common Type System –there is ONE set of types shared by.NET languages –each type is represented by a.NET class –this set of classes underlie *all* the languages –language keywords map to these underlying classes… Dim s As String ' VB String s; // J# string s; // C# System::String s; // C++ Dim i As Integer ' VB int i; // J#,C#,C++ Dim s As String ' VB String s; // J# string s; // C# System::String s; // C++ Dim i As Integer ' VB int i; // J#,C#,C++ System.String System.Int32

GUIs and Languages CTS design CTS is based on a hierarchy of classes defined in FxCL –all types inherit from Object (all except interface types)

GUIs and Languages Value vs. Reference Types.NET (like Java) separates data types into two categories Value types: –variable represents a value ("bits") Reference types: –variable represents a reference to a heap-based object –actual data resides in the object int i; i = 10; int i; i = 10; 10 string s; s = "calico"; string s; s = "calico"; "calico"

GUIs and Languages Objects vs. Object References It's critical to understand the difference between objects, and references to objects — how many objects below? refs? Student s1; Student s2; Student s3; s1 = new Student("Jim", "Bag", …); s2 = new Student("Kim", "Lee", …); s3 = s2; registrar.CheckGradRequirements(s3); Student s1; Student s2; Student s3; s1 = new Student("Jim", "Bag", …); s2 = new Student("Kim", "Lee", …); s3 = s2; registrar.CheckGradRequirements(s3); public void CheckGradRequirements(Student s) {. s.CanGraduate = true; // all checks passed! } public void CheckGradRequirements(Student s) {. s.CanGraduate = true; // all checks passed! } how many objects? object references? refs to where?

GUIs and Languages 4.4 What's Next? Lab exercise #4…