Click here to Skip to main content
Licence 
First Posted 30 Jun 2005
Views 38,150
Bookmarked 36 times

Simplifying GUI development with Actions

By | 30 Jun 2005 | Article
Simplifying GUI development with Actions.

Introduction

Are you a Delphi developer? If so, then you probably miss the useful ActionList component. I decided to code some component that mimics the Delphi component behavior. What's ActionList? It is a collection of actions, which could customize the look and behavior of some GUI elements. For example, an action can define the text shown on a button and the action which this button fires. The advantage of action is that you can use the same action with several components e.g. Print toolbar button and menu item, and you need to define the action (event) only once. You can also centrally enable or disable all the GUI components associated with the action.

How I implemented it?

The ActionList is implemented as an IExtenderProvider (ActionListProvider), which adds to ButtonBase and ToolStripItem successors a new Action property to define the actions. The Action has two properties Enabled and Text. Both will set the same properties of the linked control. There is an event Execute which is fired through the Click event of the control.

Using the ActionListProvider

Using the ActionListProvider is very easy. Follow these steps:

  1. Install the ActionListProvider into VS.NET.
  2. Add an ActionListProvider on the form.
  3. Add some new actions, through ActionListProvider's Action property.
  4. Define the Action's Execute event handler.
  5. Add some Buttons.
  6. Link them with Actions.
  7. Now you can centrally enable and disable all the controls associated with this Action.

Points of interest

The code is written in .NET 2.0 and can be extended according to your needs.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Burkovsky

Web Developer

Germany Germany

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 5 Pinmemberambush_200015:39 8 Dec '10  
GeneralApplication Settings [modified] Pinmembersithiro5:59 10 Feb '07  
QuestionWhy not an Interface ? PinmemberM.Genuini4:51 27 Dec '05  
AnswerRe: Why not an Interface ? Pinmemberdmitry4423:33 1 Apr '06  
GeneralAnother ActionList on Code Project PinmemberPeter Gummer15:34 21 Nov '05  
GeneralRe: Another ActionList on Code Project PinmemberEric Engler6:48 28 Feb '06  
General.NET 1.1 Version PinmemberTylorDurden1:15 1 Jul '05  
GeneralRe: .NET 1.1 Version PinmemberBurkovsky8:32 1 Jul '05  
GeneralRe: .NET 1.1 Version PinsussTylerdurden2k521:55 3 Jul '05  
GeneralRe: .NET 1.1 Version PinmemberBurkovsky23:14 3 Jul '05  
Questionsomething like this can already be done? PinmemberSeveredCross15:29 30 Jun '05  
AnswerRe: something like this can already be done? PinmemberBurkovsky19:43 30 Jun '05  
GeneralRe: something like this can already be done? Pinmemberambush_200015:42 8 Dec '10  
AnswerRe: something like this can already be done? Pinsusstonyt1:47 26 Jul '05  
Actions and ActionLists are more than just a centralized event handler.
 
For example, in most conventional RAD, menu items and toolbar buttons have properties for a glyph (or listview imageindex), a checked/pushed state, enabled/disabled state, and so on.
 
Actions are a way to encapsulate a logical UI item's visual appearance, image/glyph; caption text; and other states like checked/unchecked, enabled/disabled etc., in a single place.
 
So, rather than associating glyphs, captions, enabled/disabled state, pushed state, and other things directly with toolbar buttons and menu items, we associate those things with actions, and then reference the action from a toolbar button or menu item.
 
Hence, if I set a given UI action to disabled, the associated toolbar button and pull down menu item are both disabled.
 
In other words, Actions eliminate a mountain of code. They can also be useful in runtime UI customization too. A user can drag an action out of a listbox, drop it onto a toolbar or a pulldown menu, and you just create the button or menu item, associate it with the action, and you're done.
 


General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120529.1 | Last Updated 30 Jun 2005
Article Copyright 2005 by Burkovsky
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid