Presentation is loading. Please wait.

Presentation is loading. Please wait.

Toolbars and Status Bars

Similar presentations


Presentation on theme: "Toolbars and Status Bars"— Presentation transcript:

1 Toolbars and Status Bars
By: Ed Friers and Ryan Nugent

2 Toolbar and Status Bar Similarities
Both descended from Control class Both are usually host to smaller items Toolbar : ToolBarButton Status Bar : StatusBarPanel

3 Differences Toolbar Attributes Status Bar Attributes
Contains pictorial buttons that often duplicate menu items. (ToolBarButtons) Control normally docked on the top of the client area. Status Bar Attributes Conveys textual information to the user. (StatusBarPanels) Control normally docked on the bottom of the client area.

4 Something to Keep in Mind
Unlike Menus and Auto-Scroll Bars, Toolbars and Status Bars are controls that sit on their parent form’s client area, so they actually cover a portion of the client area. May need to use a Panel control…

5 Simple Status Bar Notice that the status bar covers the ends of the diagonal lines at the bottom of the form.

6 Status Bar Properties SizingGrip TabStop
The sizing grip is in the bottom right corner, the default is true (as shown). TabStop This gives you the ability to switch between controls while hitting the tab. Default is false because input focus shouldn’t be on the status bar.

7 Status Bar and Auto Scroll

8 That last slide explained…
Using auto scroll for the status bar’s parent form lets the user scroll the status bar. This is not desirable, but here’s how to correct it…

9 Correcting the Scroll Problem
Make a Panel child of that form with DockStyle.Fill for Dock property Aside from the Status Bar, Toolbar and the Panel itself, all other child controls should be children of that Panel, including the scroll-bars Code on page 960

10 Status Bar Properties (selection)
The ShowPanels property false by default, and ignores any panels and displays Text property; if set to true, panels are shown instead of the Text property. Like previous collection types, the Panels property can use methods such as Add, AddRange, Insert and Remove. Example Program on page 962

11 StatusBarPanel Properties (read-only)
The parent property is the only read-only property of StatusBarPanel and just as expected, it pertains to the Status Bar

12 StatusBarPanel Prop. (Text)
These properties involve the display of text in the Panel. For more information on the Owner Draw Style, refer to p in the textbook. The ToolTipText property can be set to a short description for the panel, that appears when mouse cursor is positioned over the panel.

13 StatusBarPanel Prop. (Appearance)
Sunken is default

14 StatusBarPanel Prop. (Appearance Cont’d.)
This property determines the positioning of the text within the panel, not the orientation of the panel.

15 StatusBarPanel Prop. (Appearance Cont’d.)
None is default and is based on the width property. Contents is based on Text string width. Spring Uses remaining space of the Status Bar.

16 StatusBarPanel Prop. (Appearance Cont’d.)
Default for Width property is 100 pixels and is only used when AutoSize set to StatusBarPanelAutoSize.None MinWidth only affects Status Bar panels with AutoSize property Set to StatusBarPanelAutoSize.Spring (default 10 pixels)

17 Date and Time Status This program has three Status Bar Panels: The menu panel is set to spring with no border style, the date and time are sunken (default) and set to context.

18 Date and Time Status The three Status Bar Panels are added to the status bar with the following code: sb.Panels.AddRange(new StatusBarPanel[] {sbpMenu, sbpDate, sbpTime}); sbpMenu, sbpDate, sbpTime are the names of the StatusBarPanels and they are put into an array so they can be added to the Status Bar using Panels.AddRange

19 Menu Help Select is a MenuItem event that occurs whenever the mouse passes over the text or the arrow key is pressed to move among menus. You can use the Select event to display menu help in a Status Bar panel. The only problem with displaying menu help on every Select event is the last menu string remains in the status bar after the user clicks a menu item…….

20 Form Events These signal the beginning and end of a menu operation.
When MenuComplete occurs, you can change the help text to a string that you saved in OnStartMenu

21 First Try Program for Menu Help
This program creates a form with a status bar. The Status Bar displays text dependant on the position of the mouse cursor relative to the menus. Code on page 969.

22 Creating a Menu Item subclass
The only problem with MenuHelpFirstTry is the consolidated code in the case statement in OnSelect. MenuItemHelp subclass is introduced with: HelpText (stores the text string to be displayed) HelpPanel (stores the status bar panel where the text is is displayed)

23 MenuHelpSubclass Doesn’t Need:
Select event handler: EventHandler ehSelect = new EventHandler(MenuOnSelect); After each menu item is created, the select handler is added to the list of triggered delegates: mi.Select += ehSelect; The only problem: Select events are generated even if the menu item is disabled. Code on page

24 Toolbars Toolbars mainly consist of an ImageList and a collection of ToolbarButton objects Recall from chapter 11 that an ImageList is a collection of images of the same size and color depth Default size of images is 16x16 pixels, to use a different size change ImageSize property Each button displays one of the images

25 Bare Essentials Tool Bar Properties (selection)
There is one ImageList for each Toolbar The Buttons property is another collection that can be indexed like an array and the ToolbarButtonCollection has the usual bunch of methods including Add, AddRange, Insert, Remove ShowToolTips must be set to true to use ToolTips

26 ToolbarButton Essentials
ImageIndex contains index of the image in the ImageList That is to be displayed on the button ToolTipText is the string displayed when ShowToolTips is true and the mouse cursor is over the button

27 ImageList, Bitmap Each button can display an
individual bitmap or an image within a bitmap ImageList. The bitmap above was used as the ImageList for the Toolbar in the form at the right For information on creating your own images p. 977

28 Simple Toolbar Code on pages 976-977.
Three properties set: Parent, ImageList, and ShowToolTips The program creates 7 ToolBarButton objects and then adds them to the toolbar.

29 Toolbar Variations Wrappable indicates whether the toolbar wraps the text to two lines or is truncated at the right. The Divider is responsible for the line that separates the toolbar and the menu. It disappears if it is set to false.

30 None Fixed 3D Fixed Single

31 Normal Flat

32 Underneath Right

33 Toolbar Events These events occur when clicking on a button but are handled by the same event handlers for the whole Toolbar The ToolBarButtonClickEventArgs argument has one property, Button, of type ToolBarButton

34 Using this property there are a couple of ways to handle the
buttons distinctly. 1)Save all ToolBarButton objects as fields and compare 2)Use the Tag ToolBarButton property If button has a MenuItem duplicate, this property can be used to simulate the MenuItem being clicked Code p

35 Edit Menu Duplicates Edit Menu items should be disabled at different times and so should there Toolbar duplicates Copy, Cut when no selection Paste when nothing on clipboard This ToolBarButton property lets you do that

36 Toolbar Styles PushButton style is what we’ve seen so far
ToggleButton doesn’t let you see what button is pushed in. DropDownButton will be discussed in the next program, it holds a menu. Separator buttons are usually blank buttons ignoring other properties Pushed and Partial pushed are only used if the style is set to toggle.

37 Drop Down Menu Code on Page 993

38 DropDownMenuButton Derives from the Toggle Button program.
CreateBitmapButton creates the A on the menu and adds it to the image list. For DropDownArrows, the default is true, this displays the arrow that indicate that a menu can be invoked.


Download ppt "Toolbars and Status Bars"

Similar presentations


Ads by Google