Presentation is loading. Please wait.

Presentation is loading. Please wait.

Jozef Goetz contribution, 2015 1  2011-14 Pearson Education, Inc. All rights reserved.  2002 Prentice Hall. All rights reserved.

Similar presentations


Presentation on theme: "Jozef Goetz contribution, 2015 1  2011-14 Pearson Education, Inc. All rights reserved.  2002 Prentice Hall. All rights reserved."— Presentation transcript:

1

2 Jozef Goetz contribution, 2015 1  2011-14 Pearson Education, Inc. All rights reserved.  2002 Prentice Hall. All rights reserved.

3 Jozef Goetz contribution, 2015 2  I claim not to have controlled events, but confess plainly that events have controlled me.  Abraham Lincoln  Capture its reality in paint!  Paul Cézanne  An actor entering through the door, you’ve got nothing. But if he enters through the window, you’ve got a situation.  Billy Wilder

4 Jozef Goetz contribution, 2015 3 Chapter 15 – Graphical User Interfaces Part 2 Outline 15.1 Introduction 15.2 Menus 15.3 MonthCalendar 15.4 DateTimePicker 15.5 LinkLabels 15.6 ListBoxes 15.7 CheckedListBoxes 15.8 ComboBoxes 15.9 TreeViews 15.10 ListViews 15.11Tab Control 15.12 Multiple Document Interface (MDI) Windows 15.13Visual Inheritance 15.14 User-Defined Controls

5 Jozef Goetz contribution, 2015 4 Chapter 15: Graphical User Interface Concepts: Part 2: Objectives 1.To be able to create menus, window tabs and multiple- document-interface (MDI) programs. 2.To understand the use of the ListView and TreeView controls for displaying information. 3.To be able to use hyperlinks with the LinkLabel control. 4. To be able to display lists using ListBoxes and ComboBoxes. 5.To create custom controls.

6 Jozef Goetz contribution, 2015 5 15.1 Introduction  Visual Studio provides a large set of GUI components.  Visual Studio also enables you to design custom controls and add them to the ToolBox  Continues study of Graphical User Interface  Explores:  Menus  LinkLabels  ListBox  CheckedListBox  ComboBoxes  TreeView control  Tab controls  Multiple-document interface MDI windows

7 Jozef Goetz contribution, 2015 6  Menus provide groups of related commands (Fig. 15.1).  Menus organize commands without “cluttering” the GUI. Fig. 15.1 | Menus, submenus and menu items. Checked menu item Submenu Separator bar Shortcut key Disabled commands Menu Menu items Menu icons 15.2 Menus

8 Jozef Goetz contribution, 2015 7  To create a menu, open the Toolbox and drag a MenuStrip control onto the Form.  To add menu items to the menu, click the Type Here TextBox (Fig. 15.2) and type the menu item’s name. Fig. 15.2 | Editing menus in Visual Studio. MenuStrip icon Type menu name in TextBox Main menu bar 15.2 Menus

9 Jozef Goetz contribution, 2015 8  After you press the Enter key, the menu item is added.  More Type Here TextBox es allow you to add more items (Fig. 15.3). Fig. 15.3 | Adding ToolStripMenuItems to a MenuStrip. Place & character before a letter to underline it in the menu, so the character can be used as an access shortcut TextBoxes for adding items to the menu 15.2 Menus

10 Jozef Goetz contribution, 2015 9  Menus can have Alt key shortcuts which are accessed by pressing Alt and the underlined letter.  To make the File menu item have a key shortcut, type &File.  The letter F is underlined to indicate that it is a shortcut. 15.2 Menus

11 Jozef Goetz contribution, 2015 10  Menu items can have shortcut keys as well (Ctrl, Shift, Alt, F1, F2, letter keys, and so on).  To add other shortcut keys, set the ShortcutKeys property (Fig. 15.4). Fig. 15.4 | Setting a menu item’s shortcut keys. Select key (modifier and key combination specifies the shortcut key for the menu item) Setting modifier keys 15.2 Menus

12 Jozef Goetz contribution, 2015 11 Look-and-Feel Observation 15.1  Buttons can have access keyboard shortcuts.  Place the & symbol immediately before the desired character in the Button’s label.  To press the button by using its access key in the running application, the user presses Alt and the underlined character.  You can remove a menu item by selecting it with the mouse and pressing the Delete key.  Menu items can be grouped by separator bars, which are inserted by right clicking and selecting Insert Separator or by typing “ - ” for the text of a menu item.

13 Jozef Goetz contribution, 2015 12 Fig. 15.5 | Menu-item options. Menu item options Visual Studio allows you to add TextBox es and ComboBox es as menu items. Before you enter text for a menu item, you are provided with a drop-down list. – Clicking the down arrow allows you to select the type of item to add (Fig. 15.5). 15.2 Menus

14 Jozef Goetz contribution, 2015 13 Fig. 15.6 | MenuStrip and ToolStripMenuItem properties and an event. (Part 1 of 2.)

15 Jozef Goetz contribution, 2015 14 Fig. 15.6 | MenuStrip and ToolStripMenuItem properties and an event. (Part 2 of 2.)

16 Jozef Goetz contribution, 2015 15 Look-and-Feel Observation 15.2  It is a convention to place an ellipsis ( ) after the name of a menu item that when selected, displays a dialog (e.g. Save As...).  Menu items that produce an immediate action without prompting the user for more information (e.g. Save) should not have an ellipsis following their name.

17 Jozef Goetz contribution, 2015 16  MenuTestForm.cs  (1 of 8) (c)(c) (d)(d) (e)(e) (f)(f) displayLabel.Text is preset manually in class

18 Jozef Goetz contribution, 2015 17 Outline  MenuTestF orm.cs  (3 of 8) (c)(c) (d)(d) (e)(e) (f )

19 Jozef Goetz contribution, 2015 18 Outline  MenuTestF orm.cs  (4 of 8) (c)(c) (d)(d) (e)(e) (f )

20 Jozef Goetz contribution, 2015 19 Outline  MenuTestF orm.cs  (5 of 8) (a) (b)

21 Jozef Goetz contribution, 2015 20 Outline  MenuTestF orm.cs  (6 of 8) (a) (b)

22 Jozef Goetz contribution, 2015 21 (a) (b) Outline  MenuTestF orm.cs  (7 of 8)

23 Jozef Goetz contribution, 2015 22 Outline  MenuTestF orm.cs  (8 of 8) (c) (d) (e) (f)

24 Jozef Goetz contribution, 2015 23 Software Engineering Observation 15.1 The mutual exclusion of menu items is not enforced by the MenuStrip, even when the Checked property is true. You must program this behavior. 15.2 Menus

25 Jozef Goetz contribution, 2015 24  The MonthCalendar control (Fig. 15.8) displays a monthly calendar on the Form.  Multiple dates can be selected by clicking dates on the calendar while holding down the Shift key. Fig. 15.8 | MonthCalendar control. Current day is outlined Selected day is highlighted Fig. 15.8 | MonthCalendar control.

26 Jozef Goetz contribution, 2015 25 Fig. 15.9 | MonthCalendar properties and an event.

27 Jozef Goetz contribution, 2015 26 Fig. 15.10 | DateTimePicker properties and an event. (Part 1 of 2.)  The DateTimePicker control displays a calendar when a down arrow is selected.  The DateTimePicker can be used to retrieve date and time information from the user.

28 Jozef Goetz contribution, 2015 27 Fig. 15.10 | DateTimePicker properties and an event. (Part 2 of 2.)

29 Jozef Goetz contribution, 2015 28 Outline  DateTimePickerForm.cs (c)(d) The DateTime structure’s DayOfWeek property determines the day of the week on which the selected date falls. Retrieving the selected date from the Value property. Using DateTime ’s AddDays method to increase the date by two days or three days. the arrival date is always two days after drop-off, or three days if a Sunday is reached.

30 Jozef Goetz contribution, 2015 29 Outline  DateTimePickerForm.cs Fig. 15.11 | Demonstrating DateTimePicker. (Part 4 of 4.) a) Clicking the down arrow b) Selecting a day from the calendar c) The Label updates d) Selecting another day Setting the MinDate and MaxDate properties to keep drop-off sometime in the next year.

31 Jozef Goetz contribution, 2015 30 15.5 LinkLabels  LinkLabel  Displays links to other resources  Files  Web pages  Behavior similar to web page hyperlink  Can change color –New –Previously visited

32 Jozef Goetz contribution, 2015 31 15.5 LinkLabel s Fig. 15.5 LinkLabel control in the design phase and in running program. LinkLabel on a form Hand image displayed when mouse cursor over a LinkLabel

33 Jozef Goetz contribution, 2015 32  The LinkLabel control displays links to other resources, such as files or web pages (Fig. 15.12). Fig. 15.12 | LinkLabel control in running program. Look-and-Feel Observation 15.3 A LinkLabel is the preferred control for indicating that the user can click a link to jump to a resource such as a web page, though other controls can perform similar tasks. LinkLabel on a Form Hand image displays when mouse moves over LinkLabel 15.5 LinkLabel Control

34 Jozef Goetz contribution, 2015 33 15.5 LinkLabel s  Represents a Windows label control that can display hyperlinks.  For a list of all members of this type, see LinkLabel Members.LinkLabel Members  System.Object System.MarshalByRefObject System.ComponentModel.Component System.Windows.Forms.Control System.Windows.Forms.Label System.Windows.Forms.LinkLabel System.ObjectSystem.MarshalByRefObjectSystem.ComponentModel.ComponentSystem.Windows.Forms.ControlSystem.Windows.Forms.Label  like a hyperlink in a Web page  Displays links to other objects  Uses event handlers to link to right file or program  Start method of Process class opens other programs  Derived from class Label, inherits functionality

35 Jozef Goetz contribution, 2015 34 15.5 LinkLabel s

36  2002 Prentice Hall. All rights reserved. Outline 35 LinkLabelTest.cs 1 // Fig. 13.7 ed1 or 15.14 ed5: LinkLabelTest.cs 2 // Using LinkLabels to create hyperlinks. 3 4 using System; 5 using System.Drawing; 6 using System.Collections; 7 using System.ComponentModel; 8 using System.Windows.Forms; 9 using System.Data; 10 11 public class LinkLabelTest : System.Windows.Forms.Form 12 { 13 // linklabels to C: drive, www.deitel.com and Notepad 14 private System.Windows.Forms.LinkLabel driveLinkLabel; 15 private System.Windows.Forms.LinkLabel deitelLinkLabel; 16 private System.Windows.Forms.LinkLabel notepadLinkLabel; 17 18 [STAThread] 19 static void Main() 20 { 21 Application.Run( new LinkLabelTest() ); 22 } 23 24 // browse C:\ drive 25 private void driveLinkLabel_LinkClicked( object sender, 26 System.Windows.Forms.LinkLabelLinkClickedEventArgs e ) 27 { 28 driveLinkLabel.LinkVisited = true; 29 System.Diagnostics.Process.Start( "C:\\" ); //Start( @”C:\”) in ed5 @ indicates that all characters in the string should be interpreted literally – this is known as a verbatim string 30 } 31 C drive linkNotepad linkDeitel website link C drive event handler Start method to open other programs in class

37  2002 Prentice Hall. All rights reserved. Outline 36 32 // load www.deitel.com in Web broswer 33 private void deitelLinkLabel_LinkClicked( object sender, 34 System.Windows.Forms.LinkLabelLinkClickedEventArgs e ) 35 { 36 deitelLinkLabel.LinkVisited = true; 37 System.Diagnostics.Process.Start( 38 "IExplore", "http://www.deitel.com" ); // or just the 2 nd parameter 39 } 40 41 // run application Notepad 42 private void notepadLinkLabel_LinkClicked( 43 object sender, 44 System.Windows.Forms.LinkLabelLinkClickedEventArgs e ) 45 { 46 notepadLinkLabel.LinkVisited = true; 47 48 // program called as if in run 49 // menu and full path not needed 50 System.Diagnostics.Process.Start( "notepad" ); 51 } 52 53 } // end class LinkLabelTest Deitel website event handler Notepad event handler System.Diagnostics.Process - Provides access to local and remote processes and enables you to start and stop local system processes. System.Object System.MarshalByRefObject System.ComponentModel.Component System.Diagnostics.Process 1.Process.Start(ProcessStartInfo) - Starts the process resource that is specified by the parameter containing process start information (for example, the file name of the process to start) and associates the resource with a new Process component. 2.Process.Start(String) - Starts a process resource by specifying the name of a document or application file and associates the resource with a new Process component. 3.Process.Start(String, String) - Starts a process resource by specifying the name of an application and a set of command line arguments, and associates the resource with a new Process component.

38 Jozef Goetz contribution, 2015 37 Outline Fig. 15.14 | LinkLabel s used to link to a drive, a web page and an application. (Part 4 of 6.) Click first LinkLabel to look at contents of C: drive LinkLabelTest Form.cs (4 of 6 )

39 Jozef Goetz contribution, 2015 38 Outline Fig. 15.14 | LinkLabel s used to link to a drive, a web page and an application. (Part 5 of 6.) Click second LinkLabel to go to Deitel website LinkLabelTest Form.cs (5 of 6 )

40 Jozef Goetz contribution, 2015 39 Outline Fig. 15.14 | LinkLabel s used to link to a drive, a web page and an application. (Part 6 of 6.) Click on third LinkLabel to open Notepad LinkLabelTest Form.cs (6 of 6 )

41 Jozef Goetz contribution, 2015 40 15.6 ListBox es and CheckListBox es Fig. 15.15 ListBox and CheckedListBox on a form. ListBox Selected Items Checked item CheckedListBox Scroll bars appear if necessary Extends ListBox by placing check boxes next to items Can select more than one object at one time allows the user to view and select from multiple items in a list

42 Jozef Goetz contribution, 2015 41 15.6 ListBox es  ListBoxe s  Allow users to view and select from items on a list  Static objects – static GUI entities  SelectionMode property determines number of items that can be selected  Property Items returns all objects in list  Property SelectedItem returns current selected item  Property SelectedIndex returns index of selected item  Property GetSelected returns true if property at given index is selected  Event: SelectedIndexChanged – generated when selected index changes For a list of all members of this type, see ListBox Members.ListBox Members System.Object System.Object System.MarshalByRefObject System.ComponentModel.Component System.Windows.Forms.Control System.Windows.Forms.ListControl System.Windows.Forms.ListBox System.Windows.Forms.CheckedListBoxSystem.MarshalByRefObjectSystem.ComponentModel.ComponentSystem.Windows.Forms.ControlSystem.Windows.Forms.ListControlSystem.Windows.Forms.CheckedListBox

43 Jozef Goetz contribution, 2015 42 15.6 ListBox es

44 Jozef Goetz contribution, 2015 43 Fig. 15.16 | ListBox properties, methods and an event. (Part 2 of 2.)

45 Jozef Goetz contribution, 2015 44 15.6 ListBox es Fig. 15.17 String Collection Editor. Use Add method to add to Items collection myListBox.Items.Add(“myListItem”) or Using the Items property by clicking the ellipsis we can add as the following editor is open up A Collection is a data structure, similar to an array and can be used with a foreach statement.

46  2002 Prentice Hall. All rights reserved. Outline 45 in class 1 // Fig 13.11:ed1 or 15.18 ed5 ListBoxTest.cs 2 // Program to add, remove and clear list box items. 3 4 using System; 5 using System.Drawing; 6 using System.Collections; 7 using System.ComponentModel; 8 using System.Windows.Forms; 9 using System.Data; 10 11 public class ListBoxTest : System.Windows.Forms.Form 12 { 13 // contains user-input list of elements 15 private System.Windows.Forms.ListBox displayListBox; 15 16 // user input textbox 17 private System.Windows.Forms.TextBox inputTextBox; 18 19 // add, remove, clear and exit command buttons 20 private System.Windows.Forms.Button addButton; 21 private System.Windows.Forms.Button removeButton; 22 private System.Windows.Forms.Button clearButton; 23 private System.Windows.Forms.Button exitButton; 24 25 [STAThread] 26 static void Main() 27 { 28 Application.Run( new ListBoxTest() ); 29 } 30 Display ListBoxText field for inputAdd button Remove Button Clear button Exit button Below developed Class ListBoxTest Allows users to add and remove items from ListBox Uses event handlers to add to, remove from and clear list

47  2002 Prentice Hall. All rights reserved. Outline 46 ListBoxTest.cs 31 // add new item (text from input box) 32 // and clear input box 33 private void addButton_Click( 34 object sender, System.EventArgs e ) 35 { 36 displayListBox.Items.Add( inputTextBox.Text ); 37 inputTextBox.Clear(); 38 } 39 40 // remove item if one selected 41 private void removeButton_Click( 42 object sender, System.EventArgs e ) 43 { 44 // remove only if item selected 45 if ( displayListBox.SelectedIndex != -1 ) 46 displayListBox.Items.RemoveAt( 47 displayListBox.SelectedIndex ); 48 } 49 50 // clear all items 51 private void clearButton_Click( 52 object sender, System.EventArgs e ) 53 { 54 displayListBox.Items.Clear(); 55 } 56 57 // exit application 58 private void exitButton_Click( 59 object sender, System.EventArgs e ) 60 { 61 Application.Exit(); 62 } 63 64 } // end class ListBoxTest Add event handler Add method Remove methodClear methodTest if item is selected Exit

48  2002 Prentice Hall. All rights reserved. Outline 47 ListBoxTest.cs Program Output

49 Jozef Goetz contribution, 2015 48 15.7 CheckedListBox es  Displays a ListBox in which a check box is displayed to the left of each item.ListBox  For a list of all members of this type, see CheckedListBox Members.CheckedListBox Members  System.Object System.MarshalByRefObject System.ComponentModel.Component System.Windows.Forms.Control System.Windows.Forms.ListControl System.Windows.Forms.ListBox System.Windows.Forms.CheckedListBox System.ObjectSystem.MarshalByRefObjectSystem.ComponentModel.ComponentSystem.Windows.Forms.ControlSystem.Windows.Forms.ListControlSystem.Windows.Forms.ListBox  CheckedListBox derives from class ListBox  Can add to, remove from or clear list  Can select multiple items from the list  Properties CurrentValue and NewValue return state of object selected  Properties CheckedItems and CheckedIndices return the objects and indices of selected items respectively

50 Jozef Goetz contribution, 2015 49 15.7 CheckListBox es

51 Jozef Goetz contribution, 2015 50 15.7 CheckListBox es  System.Windows.Forms Namespace has  public enum CheckState.Checked  Specifies the state of a control, such as a check box, that can be checked, unchecked, or set to an indeterminate state.

52  2002 Prentice Hall. All rights reserved. Outline 51 CheckedListBoxTe st.cs 1 // Fig. 13.13 ed1 or 15.20 ed3: CheckedListBoxTest.cs 2 // Using the checked list boxes to add items to a list box 3 4 using System; 5 using System.Drawing; 6 using System.Collections; 7 using System.ComponentModel; 8 using System.Windows.Forms; 9 using System.Data; 10 11 public class CheckedListBoxTest : System.Windows.Forms.Form 12 { 13 // list of available book titles 14 private System.Windows.Forms.CheckedListBox 15 inputCheckedListBox; 16 17 // user selection list 18 private System.Windows.Forms.ListBox displayListBox; 19 20 [STAThread] 21 static void Main() 22 { 23 Application.Run( new CheckedListBoxTest() ); 24 } 25 26 // item about to change, 27 // add or remove from displayListBox 28 private void inputCheckedListBox_ItemCheck( 29 object sender, 30 System.Windows.Forms.ItemCheckEventArgs e ) 31 { // public class ItemCheckEventArgs : EventArgs 32 // get reference of selected item 33 string item = 34 inputCheckedListBox.SelectedItem.ToString(); 35 CheckedListBoxListBoxItemCheck event handler

53  2002 Prentice Hall. All rights reserved. Outline 52 36 // if item checked add to listbox 37 // otherwise remove from listbox 38 if ( e.NewValue == CheckState.Checked )// check a new state 39 displayListBox.Items.Add( item ); // Items collection inherited 40 else// from ListBox 41 displayListBox.Items.Remove( item ); 42 43 } // end method inputCheckedListBox_Click 44 45 } // end class CheckedListBox System.Windows.Forms Namespace has public enum CheckState.Checked - specifies the state of a control, such as a check box, that can be checked, unchecked, or set to an indeterminate state.

54 Jozef Goetz contribution, 2015 53 15.8 ComboBox es Fig. 15.21 Demonstrating a ComboBox. Combine TextBox and drop-down list Add method adds object to collection Properties: DropDownStyle: determines type of ComboBox: Simple text is always visible and editable, doesn’t display a drop-down arrow button but has a scroll bar DropDown the default means that the text portion is editable but an arrow button must be clicked to see the list portion. DropDownList the text portion is not editable and the arrow button must be clicked to see the list portion.

55 Jozef Goetz contribution, 2015 54 15. 8 ComboBoxes  ComboBox  Combines TextBox features with drop-down list  Drop-down list  Contains a list from which a value can be selected  Scrollbar appears if necessary Common Properties: Items: returns objects in the list SelectedItem: returns object selected SelectedIndex: returns index of selected item

56 Jozef Goetz contribution, 2015 55 15. 8 ComboBox es  Represents a Windows combo box control.  For a list of all members of this type, see ComboBox Members.ComboBox Members  System.Object System.MarshalByRefObject System.ComponentModel.Component System.Windows.Forms.Control System.Windows.Forms.ListControl System.Windows.Forms.ComboBox System.ObjectSystem.MarshalByRefObjectSystem.ComponentModel.ComponentSystem.Windows.Forms.ControlSystem.Windows.Forms.ListControl

57 Jozef Goetz contribution, 2015 56 15. 8 ComboBox es  Encapsulates a GDI+ drawing surface. This class cannot be inherited.  For a list of all members of this type, see Graphics Members.Graphics Members  System.Object System.MarshalByRefObject System.Drawing.Graphics System.ObjectSystem.MarshalByRefObject  Defines an object used to draw lines and curves. This class cannot be inherited.  For a list of all members of this type, see Pen Members.Pen Members  System.Object System.MarshalByRefObject System.Drawing.Pen System.ObjectSystem.MarshalByRefObject  Defines a brush of a single color. Brushes are used to fill graphics shapes, such as rectangles, ellipses, pies, polygons, and paths. This class cannot be inherited.  For a list of all members of this type, see SolidBrush Members.SolidBrush Members  System.Object System.MarshalByRefObject System.Drawing.Brush System.Drawing.SolidBrush System.ObjectSystem.MarshalByRefObjectSystem.Drawing.Brush

58 Jozef Goetz contribution, 2015 57 15. 8 ComboBox es

59  2002 Prentice Hall. All rights reserved. Outline 58 ComboBoxTest.cs 1 // Fig. 13.16 ed1 or 15.20 ed5: ComboBoxTest.cs 2 // Using ComboBox to select shape to draw 3 4 using System; 5 using System.Drawing; 6 using System.Collections; 7 using System.ComponentModel; 8 using System.Windows.Forms; 9 using System.Data; 10 11 public class ComboBoxTest : System.Windows.Forms.Form 12 { 13 // contains shape list (circle, square, ellipse, pie) 14 private System.Windows.Forms.ComboBox imageComboBox; 15 16 [STAThread] 17 static void Main() 18 { 19 Application.Run( new ComboBoxTest() ); 20 } 21 22 // get selected index, draw shape 23 private void imageComboBox_SelectedIndexChanged( 24 object sender, System.EventArgs e ) 25 { 26 // create graphics object, pen and brush 27 Graphics myGraphics = base.CreateGraphics(); 28 29 // create Pen using color DarkRed 30 Pen myPen = new Pen( Color.DarkRed ); 31 32 // create SolidBrush using color DarkRed 33 SolidBrush mySolidBrush = 34 new SolidBrush( Color.DarkRed ); 35 Create ComboBoxSelectedIndexChanged event handler Create graphics objectCreate penCreate brush

60  2002 Prentice Hall. All rights reserved. Outline 59 ComboBoxTest.cs 36 // clear drawing area setting it to color White 37 myGraphics.Clear( Color.White ); 38 39 // find index, draw proper shape 40 switch ( imageComboBox.SelectedIndex ) 41 { 42 case 0: // case circle is selected 43 myGraphics.DrawEllipse( 44 myPen, 50, 50, 150, 150 ); //x,y – center, width, high 45 break; // in this case circle 46 case 1: // case rectangle is selected 47 myGraphics.DrawRectangle( 48 myPen, 50, 50, 150, 150 ); //x,y – upper-left of //the rectangle, width, hight 49 break; 50 case 2: // case ellipse is selected 51 myGraphics.DrawEllipse( 52 myPen, 50, 85, 150, 115 ); //x,y – center, width, hight 53 break; 54 case 3: // case pie as a portion of an ellipse: 55 // x,y – upper-left of the rectangle, width, // high, the start angle (in degrees), the sweep angle of pie 55 myGraphics.DrawPie( 56 myPen, 50, 50, 150, 150, 0, 45 ); 57 break; 58 case 4: // case filled circle is selected 59 myGraphics.FillEllipse( 60 mySolidBrush, 50, 50, 150, 150 ); 61 break; 62 case 5: // case filled rectangle is selected 63 myGraphics.FillRectangle( 64 mySolidBrush, 50, 50, 150, 150 ); 65 break; 66 case 6: // case filled ellipse is selected 67 myGraphics.FillEllipse( 68 mySolidBrush, 50, 85, 150, 115 ); 69 break; Switch statement to determine correct object to draw Draw object

61  2002 Prentice Hall. All rights reserved. Outline 60 ComboBoxTest.cs Program Output 70 case 7: // case filled pie is selected 71 myGraphics.FillPie( 72 mySolidBrush, 50, 50, 150, 150, 0, 45 ); 73 break; 74 75 } // end switch 76 77 } // end method imageComboBox_SelectedIndexChanged 78 79 } // end class ComboBoxTest

62  2002 Prentice Hall. All rights reserved. Outline 61 ComboBoxTest.cs Program Output


Download ppt "Jozef Goetz contribution, 2015 1  2011-14 Pearson Education, Inc. All rights reserved.  2002 Prentice Hall. All rights reserved."

Similar presentations


Ads by Google