Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
UserFormCommandManager.cs
Package: WebUserForms.zip [view]
Upload User: husern
Upload Date: 2022-03-24
Package Size: 534k
Code Size: 4k
Category:
Editor
Development Platform:
C#
- // -- FILE ------------------------------------------------------------------
- // name : UserFormCommandManager.cs
- // project : Itenso Web User Forms
- // created : Jani Giannoudis - 2008.10.30
- // language : c#
- // environment: .NET 2.0
- // copyright : (c) 2008 by Itenso GmbH, Switzerland
- // --------------------------------------------------------------------------
- using System;
- using System.Collections.Generic;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace Itenso.WebUserForms.Controls
- {
- // ------------------------------------------------------------------------
- public class UserFormCommandManager
- {
- // ----------------------------------------------------------------------
- public event CommandEventHandler Command;
- // ----------------------------------------------------------------------
- public UserFormCommandManager( UserControl userControl )
- {
- if ( userControl == null )
- {
- throw new ArgumentNullException( "userControl" );
- }
- this.userControl = userControl;
- RegisterEvents();
- } // UserFormCommandManager
- // ----------------------------------------------------------------------
- public UserControl UserControl
- {
- get { return this.userControl; }
- } // UserControl
- // ----------------------------------------------------------------------
- public bool HasCommand( string commandName )
- {
- if ( string.IsNullOrEmpty( commandName) )
- {
- throw new ArgumentNullException( "commandName" );
- }
- if ( this.formCommands == null || this.formCommands.Count == 0 )
- {
- return false;
- }
- foreach ( IUserFormCommand formCommand in formCommands )
- {
- if ( commandName.Equals( formCommand.CommandName ) )
- {
- return true;
- }
- }
- return false;
- } // HasCommand
- // ----------------------------------------------------------------------
- public void EnableCommand( string commandName, bool enabled )
- {
- if ( string.IsNullOrEmpty( commandName ) )
- {
- throw new ArgumentNullException( "commandName" );
- }
- if ( this.formCommands == null || this.formCommands.Count == 0 )
- {
- return;
- }
- commandName = commandName.ToLower();
- foreach ( IUserFormCommand formCommand in formCommands )
- {
- if ( commandName.Equals( formCommand.CommandName.ToLower() ) )
- {
- formCommand.Enabled = enabled;
- }
- }
- } // EnableCommand
- // ----------------------------------------------------------------------
- protected virtual void OnCommand( IUserFormCommand formCommand, CommandEventArgs e )
- {
- if ( Command != null )
- {
- Command( formCommand, e );
- }
- } // OnCommand
- // ----------------------------------------------------------------------
- private void RegisterEvents()
- {
- this.formCommands = CommandCollector.Collect( this.userControl );
- if ( this.formCommands == null || this.formCommands.Count == 0 )
- {
- return;
- }
- foreach ( IUserFormCommand formCommand in formCommands )
- {
- formCommand.Command += new CommandEventHandler(FormCommandCommand);
- }
- } // RegisterEvents
- // ----------------------------------------------------------------------
- private void UnregisterEvents()
- {
- if ( this.formCommands == null || this.formCommands.Count == 0 )
- {
- return;
- }
- foreach ( IUserFormCommand formCommand in formCommands )
- {
- formCommand.Command -= new CommandEventHandler( FormCommandCommand );
- }
- } // UnregisterEvents
- // ----------------------------------------------------------------------
- private void FormCommandCommand( object sender, CommandEventArgs e )
- {
- IUserFormCommand formCommand = sender as IUserFormCommand;
- if ( formCommand == null )
- {
- return;
- }
- OnCommand( formCommand, e );
- } // RegisterEvents
- // ----------------------------------------------------------------------
- // members
- private readonly UserControl userControl;
- private List<IUserFormCommand> formCommands;
- } // class UserFormCommandManager
- } // namespace Itenso.WebUserForms.Controls
- // -- EOF -------------------------------------------------------------------