using System; using System.Collections; using System.Web.UI; using UDDI; namespace UDDI.Web { public class ContextMenu : Control { protected ArrayList menuItems = new ArrayList(); protected static string popupScript = @" "; protected static string contextMenuScript = @" "; public ContextMenu() { } protected override void OnInit( EventArgs e ) { if( !Page.IsClientScriptBlockRegistered( "UDDI.Web.Popup" ) ) Page.RegisterClientScriptBlock( "UDDI.Web.Popup", popupScript ); if( !Page.IsClientScriptBlockRegistered( "UDDI.Web.ContextMenu" ) ) Page.RegisterClientScriptBlock( "UDDI.Web.ContextMenu", contextMenuScript ); } protected override void AddParsedSubObject( object obj ) { if( obj is MenuItem || obj is MenuSeparator ) menuItems.Add( obj ); } protected override void Render( HtmlTextWriter output ) { output.Write( "" ); } } public class MenuItem : Control { protected bool bold = false; protected string imageUrl = null; protected string onClick = null; protected string statusText = null; protected string text = null; protected RoleType requiredRole = RoleType.Anonymous; public bool Bold { get { return bold; } set { bold = value; } } public string ImageUrl { get { return imageUrl; } set { imageUrl = value; } } public string OnClick { get { return onClick; } set { onClick = value; } } public string StatusText { get { return statusText; } set { statusText = value; } } public string Text { get { return text; } set { text = value; } } public RoleType RequiredRole { get { return requiredRole; } set { requiredRole = value; } } public bool AccessAllowed { get { return ( RoleType.Anonymous == requiredRole ) || ( RoleType.User == requiredRole && UDDI.Context.User.IsUser ) || ( RoleType.Publisher == requiredRole && UDDI.Context.User.IsPublisher ) || ( RoleType.Coordinator == requiredRole && UDDI.Context.User.IsCoordinator ) || ( RoleType.Administrator == requiredRole && UDDI.Context.User.IsAdministrator ); } } public MenuItem() { } } public class MenuSeparator : Control { protected RoleType requiredRole = RoleType.Anonymous; public MenuSeparator() { } public RoleType RequiredRole { get { return requiredRole; } set { requiredRole = value; } } public bool AccessAllowed { get { return ( RoleType.Anonymous == requiredRole ) || ( RoleType.User == requiredRole && UDDI.Context.User.IsUser ) || ( RoleType.Publisher == requiredRole && UDDI.Context.User.IsPublisher ) || ( RoleType.Coordinator == requiredRole && UDDI.Context.User.IsCoordinator ) || ( RoleType.Administrator == requiredRole && UDDI.Context.User.IsAdministrator ); } } } }