1 Graphical User Interfaces Part 2 Outline Multiple Document Interface (MDI) Windows Visual Inheritance User-Defined Controls.

Slides:



Advertisements
Similar presentations
Chapter 1: An Introduction to Visual Basic 2012
Advertisements

 2006 Pearson Education, Inc. All rights reserved Graphical User Interface Concepts: Part 2.
© by Pearson Education, Inc. All Rights Reserved.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Chapter 1: An Introduction to Visual Basic.NET Programming with Microsoft Visual Basic.NET, Second Edition.
 2007 Dr. Natheer Khasawneh. All rights reserved. 1 Chapter 14 – Graphical User Interfaces Part 2 Outline 14.9 TreeViews ListViews TabControl.
Creating Custom Forms. 2 Design and create a custom form You can create a custom form by modifying an existing form or creating a new form. Either way,
C# Programming: From Problem Analysis to Program Design1 Programming Based on Events C# Programming: From Problem Analysis to Program Design 3 rd Edition.
Multiple-Document-Interface (MDI) Windows MDI programs enable users to edit multiple documents at once. MDI programs enable users to edit multiple documents.
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.
MDI windows Single-document-interface (SDI)
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
Multiple Document Interface (MDI) application
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
1 Multiple Document Interface (MDI) Windows. Single Document Interface (SDI) A program that can only support one open window or a document For Example,
Operating Systems Day 1. Booting a Computer 1.Switch on the UPS electricity supply - green light electricity failure - red light charging – orange light.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
Neal Stublen Practice Solution  Create a new solution  Add a WinForms project  Add a Class Library project  Reference the library.
Visual Basic Chapter 1 Mr. Wangler.
Chapter 3 Working with Symbols and Interactivity.
1- Date TimePicker 2- Month Calendar 3- User Defined Controls.
IE 411/511: Visual Programming for Industrial Applications
Tutorial 1: An Introduction to Visual Basic.NET1 Tutorial 1 An Introduction to Visual Basic.NET.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Typing Application Introducing Keyboard Events, Menus, Dialogs and the Dictionary.
© 2011 Delmar, Cengage Learning Chapter 3 Working with Symbols and Interactivity.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Introduction to MS WORD.
CST238 Week 4 Questions / Concerns? Announcements – Start thinking about project ideas – Test#1 next Monday, 4/28/14 Recap Check-off Take Home Lab#3 New.
Adobe InDesign CS5 – Illustrated Unit E: Using Master Pages Adobe InDesign CS5 – Illustrated Unit E: Using Master Pages.
G RAPHICAL U SER I NTERFACE C ONCEPTS : P ART 1 1 Outline Introduction Windows Forms Event-Handling Model - Basic Event Handling.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 8 Dental Payment Application Introducing CheckBox es and Message Dialogs.
Copyright © 2001 by Wiley. All rights reserved. Chapter 2: Using Visual Basic to Create a First Project Getting Started with VB Development Environment.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 – Graphical User Interfaces Part 2 Outline.
Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
VB.NET Additional Topics
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 3.1 Test-Driving the Welcome Application 3.2.
Visual Basic.NET BASICS Lesson 1 A First Look at Microsoft Visual Basic.NET.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Chapter 2 – Introduction to the Visual Studio .NET IDE
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.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 10 1 Microsoft Office Access 2003 Tutorial 10 – Automating Tasks With Macros.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to the Visual Studio.NET IDE Outline 2.1Introduction 2.2Visual Studio.NET Integrated.
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
Creating Menus Menu Bar – behaves like standard Windows menus Can be used in place of or in addition to buttons to execute a procedure Menu items are controls.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 6 1 Microsoft Office Access 2003 Tutorial 6 – Creating Custom Forms.
TOOLBOX. The Toolbox Intrinsic Controls - always included in the Toolbox ActiveX Controls - separate files with ocx file extension Insertable Objects.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Chapter 7 Multiple Forms, Modules, and Menus. Section 7.2 MODULES A module contains code—declarations and procedures—that are used by other files in a.
Programming with Microsoft Visual Basic 2012 Chapter 1: An Introduction to Visual Basic 2012.
Chapter 3: I Need a Tour Guide (Introduction to Visual Basic 2012)
Chapter 1: An Introduction to Visual Basic .NET
Graphical User Interface
Chapter 1: An Introduction to Visual Basic 2015
Chapter 2 – Introduction to the Visual Studio .NET IDE
Graphical User Interfaces Part 2
1. Introduction to Visual Basic
Chapter 1: An Introduction to Visual Basic 2015
Chapter 2 – Introduction to the Visual Studio .NET IDE
Visual C# - GUI and controls - 1
Chapter 13 Additional Topics in Visual Basic
Chapter 4 Enhancing the Graphical User Interface
Chapter 4 Enhancing the Graphical User Interface
Presentation transcript:

1 Graphical User Interfaces Part 2 Outline Multiple Document Interface (MDI) Windows Visual Inheritance User-Defined Controls

2 Introduction Continues study of Graphical User Interface Explores: –Multiple-document interface windows (MDIs) –Examples: PaintShop Pro or Adobe Photoshop

3 Multiple-Document Interface Windows Users can edit multiple documents at once Usually more complex then single-document- interface applications Application window called parent, others child Child windows can be arranged in parent window: –Tiled windows: completely fill parent, no overlap Either horizontal or vertical –Cascaded windows: overlap, same size, display title bar –ArrangeIcons: arranges icons for minimized windows

4 Multiple Document Interface (MDI) Windows MDI parent and MDI child. MDI parent MDI child

5 Multiple Document Interface (MDI) Windows Single Document Interface (SDI) Multiple Document Interface (MDI)

6 Create a Child form –Create a new Form, set its IsMDIContainer property to true –Create a child form class to be added to form Select Project | Add Windows Form … name the file –To add the child form to parent, in a parent’s event handler Set child’s MDIParent property to parent form Call method Show // create new child ChildForm child = new ChildForm( "Child 1", "\\images\\csharphtp1.jpg" ); child.MdiParent = this; // set parent child.Show(); // display child

7 Multiple Document Interface (MDI) Windows

8 Parent’s icons: minimize, maximize and close Maximized child’s icons: minimize, restore and close Minimized child’s icons: restore, maximize and close Parent’s title bar displays maximized child Minimized and maximized child windows.

9 Multiple Document Interface (MDI) Windows Using MenuItem property MdiList. Separator bar and child windows 9 or more child windows enables the More Windows... option Child windows list

10 Multiple Document Interface (MDI) Windows LayoutMdi enumeration values (Part 1). ArrangeIconsCascade

11 Multiple Document Interface (MDI) Windows LayoutMdi enumeration values (Part 2). TileHorizontalTileVertical

12 DEMO!

13 UsingMDI.cs // UsingMDI.cs // Demonstrating use of MDI parent and child windows. private System.Windows.Forms.MainMenu menuStrip1 ; private System.Windows.Forms.MenuItem fileToolStripMenuItem ; private System.Windows.Forms.MenuItem newToolStripMenuItem ; private System.Windows.Forms.MenuItem csToolStripMenuItem ; private System.Windows.Forms.MenuItem cppToolStripMenuItem1 ; private System.Windows.Forms.MenuItem pythonToolStripMenuItem ; private System.Windows.Forms.MenuItem exitToolStripMenuItem ; private System.Windows.Forms.MenuItem windowToolStripMenuItem ; private System.Windows.Forms.MenuItem cascadeToolStripMenuItem ; private System.Windows.Forms.MenuItem tileHorizontalToolStripMenuItem ; private System.Windows.Forms.MenuItem tileVerticalToolStripMenuItem ; File menuNew submenu Exit submenu Format menuCascade option Tiling options

14 // create Child 1 when menu clicked private void csToolStripMenuItem_Click ( object sender, System.EventArgs e ) { // create new child ChildForm child= new ChildForm( “Visual C#", "\\images\\csharphtp1.jpg" ); child.MdiParent = this; // set parent child.Show(); // display child } // set cascade layout private void cascadeToolStripMenuItem_Click ( object sender, System.EventArgs e ) { this.LayoutMdi( MdiLayout.Cascade ); } Creating one of the child windows Cascade

15 // FormChild.cs // Child window of MDI parent. public partial class ChildForm : Form { public Child ( string title, string resourceName ) { // Required for Windows Form Designer support InitializeComponent(); Text = title; // set title text // set image to display in pictureBox pictureBox.Image = Image.FromFile( Directory.GetCurrentDirectory() + resourceName ); } Display title Display picture Child class

16 Visual Inheritance Create Form by inheriting from another Form –Derived Form inherits functionality of base Form –Derived Form inherits visual aspects of base Form –Visual Inheritance enables developers to achieve visual consistency across applications by reusing code.

17 Visual Inheritance A base form VisualInheritance.cs Program Output

18 // VisualInheritanceBaseForm.cs // Base Form for use with visual inheritance private System.Windows.Forms.Label bugsLabel ; private System.Windows.Forms.Button learnMoreButton ; private System.Windows.Forms.Label label1 ; public partial class VisualInheritanceBaseForm : Form { private void learnMoreButton_Click ( object sender, System.EventArgs e ) { MessageBox.Show ( " Bugs, Bugs, Bugs is a product of Bug2Bug.com", "Learn More", MessageBoxButtons.OK, MessageBoxIcon.Information ); } Learn More display method

19 Before deriving a form from this base class, must produce a.dll. –Right click on the project in Solution Explorer, select Properties, then choose Application tab. In OutputType drop-down list, change to ClassLibrary, then build to produce a.dll To create the derived form, create an empty project. From Project menu, select Add Reference Click Browse, select the. dll file, add using statement. Modify the line that defines the class to indicate that the application’s Form inherits from class VisualInheritanceBaseForm You’ll see next screen

20 Visual Inheritance

21 VisualInheritanceTestForm.cs Program Output Derived class cannot modify these controls Derived class can modify this control

22 // VisualInheritanceTestForm.cs // Derived Form using visual inheritance. public class VisualInheritanceTestForm : VisualInheritanceBase.VisualInheritanceBaseForm { private System.Windows.Forms.Button learnProgramButton ; // invoke when user clicks Learn the Program Button private void learnProgramButton_Click ( object sender, System.EventArgs e ) { MessageBox.Show( "This program was created by C. Stringfellow "Learn the Program", MessageBoxButtons.OK, MessageBoxIcon.Information ); } VisualInheritanceTestForm class is derived from VisualInheritanceBaseForm class Display message box

23 User-Defined Controls Custom controls that inherit from other classes –Example: can change appearance of a label Custom controls appear in the user’s Toolbox and can be added to Forms, Panels or GroupBoxes the way we add other controls

24 Creating User-Defined Controls 1.Derive a class from an existing Windows Form Control –Easiest way –Add functionality to preexisting control. –To add to the control’s appearance, override method OnPaint (call base class OnPaint ) 2.Create UserControl composed of existing controls –Use class UserControl –Acts as a container for controls added to it –Cannot override OnPaint for constituent controls: their appearance modified only by adding code to each control’s Paint event.

25 Creating User-Defined Controls Inherit from class Control –Defines a brand-new control –Override OnPaint, call base class OnPaint and include methods to draw the control. –Can customize control appearance and functionality

26 User-Defined Controls

27 Creating A Clock Control Select Project > Add User Control –Displays a dialog from which we select type of control to add –Select User Control Name the file (and class) ClockUserControl UserControl composed of –Label –Timer Invisible component Tick event Set Timer interval to 1000 milliseconds Enabled property set to true –Whenever timer generates a tick event, label is updated Once created, our control appears as an item on the ToolBox

28 private System.Windows.Forms.Timer clockTimer ; private System.Windows.Forms.Label displayLabel ; // User-defined control with a timer and a label. public class ClockUserControl : UserControl { // update label at every tick private void clockTimer_Tick ( object sender, System.EventArgs e ) { // get current time (Now), convert to string displayLabel.Text = DateTime.Now.ToLongTimeString(); } // end method clockTimer_Tick } // end class ClockUserControl TimerLabelUpdate label method Display current time

29 Designing User-Defined Controls 1.Create a new Class Library project 2.Delete Class1.cs initially provided with the application 3.Right click project in Solution Explorer and select Add > User Control … 4.Name the User control and click Add 5.Add controls and functionality to UserControl 6.Build the project (.dll)

30 Using User-Defined Controls 1.Create a new windows app 2.Import UserControl 1.Right click ToolBox, select Choose Items… 2.Browse for.dll file, 3.Check item 4.Click ok 3.UserControl appears on the ToolBox

31 User-Defined Controls Custom control added to the ToolBox.

32 User-Defined Controls Custom control added to a Form. New Toolbox icon Newly inserted control