MenuItem.cs :  » Development » MMC » Ironring » MMC » Core » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Development » MMC 
MMC » Ironring » MMC » Core » MenuItem.cs
using System;
using System.Collections;
using Ironring.MMC.Nodes;

namespace Ironring.MMC.Core{

  /// <summary>
  /// Delegate definition for all menu handlers
  /// </summary>
  public delegate void MenuCommandHandler(object item, BaseNode node);
    
  /// <summary>
  /// Handles menu item features
  /// </summary>
  public class MenuItem
  {
    /// <summary>
    /// Command handler event for revicing notifications fo the menu command
    /// </summary>
    public event MenuCommandHandler Handler;


    ///////////////////////////////////////////////////////////////////////
    //
    // Private vars
    //
    #region
    private CCM_SPECIAL  _specialFlags = 0;
    private MF _flags = 0;
    private string _id;
    private string _name;
    private bool _visible = true;
    private string _statusText;
    private int _nCommandId = 0;

    #endregion

    ///////////////////////////////////////////////////////////////////////
    //
    // Properties
    //
    #region

    /// <summary>
    /// Get or set the unique identifier of this menu item.
    /// </summary>
    public string ID
    {
      get{ return _id; }
      set{ _id = value; }
    }

    /// <summary>
    /// Get or set the menu display name
    /// Name can support mnemonics like &File
    /// </summary>
    public string Name
    {
      get{ return _name; }
      set{ _name = value; }
    }

    // added by Roman Kiss
    /// <summary>
    /// Get or set the flag to control visibility of the menu
    /// </summary>
    public bool Visible
    {
      get{ return _visible; }
      set{ _visible = value; }
    }

    /// <summary>
    /// Get or set the text to display in the MMC status bar when the user hovers over the menu item
    /// </summary>
    public string StatusText
    {
      get{ return _statusText; }
      set{ _statusText = value; }
    }

    /// <summary>
    /// Get or set the integer command that MMC uses when if fires the command
    /// </summary>
    public int CommandId
    {
      get{ return _nCommandId; }
      set{ _nCommandId = value; }
    }

    /// <summary>
    /// Get or set one or more of the flags (see CCM_SPECIAL enum in interfaces.cs)
    /// </summary>
    public CCM_SPECIAL SpecialFlags
    {
      get { return _specialFlags; }
      set { _specialFlags = value; }
    }

    /// <summary>
    /// Get or set one or more of the style flags (see MF enum in interfaces.cs)
    /// </summary>
     public MF Flags
        {
       get { return _flags; }
       set { _flags = value; }
     }
    #endregion

    ///////////////////////////////////////////////////////////////////////
    //
    // Constructors
    //
    #region
    /// <summary>
    /// default ctor
    /// </summary>
    public MenuItem()
    {
    }

    /// <summary>
    /// Common usage ctor to provide the class flields at once
    /// </summary>
    /// <param name="Name"></param>
    /// <param name="StatusText"></param>
    /// <param name="handler"></param>
    public MenuItem(string name, string statusText, MenuCommandHandler handler)
    {
      this.Name = name;
      this.StatusText = statusText;
      Handler += handler;
    }

    public MenuItem(string name, string statusText, MenuCommandHandler handler, MF flags)
      : this(name, statusText, handler)
    {
      _flags = flags;
    }

    ///Added by Greg Arnold
    /// <summary>
    /// Common usage ctor to provide the class flields at once
    /// </summary>
    /// <param name="id"></param>
    /// <param name="Name"></param>
    /// <param name="StatusText"></param>
    /// <param name="handler"></param>
    public MenuItem(string id, string name, string statusText, MenuCommandHandler handler) : this(name,statusText,handler)
    {
      this.ID = id;
    }


    /// <summary>
    /// Common usage ctor to provide the class fields at once
    /// </summary>
    /// <param name="flags"></param>
    public MenuItem(MF flags)
    {
      _flags = flags;
    }
    #endregion

    /// <summary>
    /// Called by the node when a command is fired by MMC
    /// </summary>
    /// <param name="node"></param>
    public void Command(BaseNode node)
    {
      OnCommand(node);
    }

    /// <summary>
    /// Called to handle the command. Consider inheriting from this 
    /// class and overriding this behavior if required.
    /// </summary>
    /// <param name="node"></param>
    protected virtual void OnCommand(BaseNode node)
    {
      if (Handler != null)
        Handler(this, node);
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.