- namespace DevExpress.Utils.Menu
- {
- using System;
- using System.Drawing;
- using System.Runtime.CompilerServices;
- using System.Windows.Forms;
- public class DXMenuItem : IDisposable
- {
- private bool beginGroup;
- private string caption;
- private DXMenuItemCollection collection;
- private bool enabled;
- private System.Drawing.Image image;
- private System.Windows.Forms.Shortcut shortcut;
- private object tag;
- private bool visible;
- public event EventHandler Click;
- public DXMenuItem() : this("")
- {
- }
- public DXMenuItem(string caption) : this(caption, null)
- {
- }
- public DXMenuItem(string caption, EventHandler click) : this(caption, click, null)
- {
- }
- public DXMenuItem(string caption, EventHandler click, System.Drawing.Image image)
- {
- this.enabled = true;
- this.visible = true;
- this.Click = click;
- this.caption = caption;
- this.image = image;
- }
- public virtual void Dispose()
- {
- this.Click = null;
- }
- public void GenerateClickEvent()
- {
- this.OnClick();
- }
- protected virtual void OnChanged()
- {
- if (this.Collection != null)
- {
- this.Collection.OnMenuItemChanged(this);
- }
- }
- protected virtual void OnClick()
- {
- if (this.Click != null)
- {
- this.Click(this, EventArgs.Empty);
- }
- }
- protected internal void SetCollection(DXMenuItemCollection collection)
- {
- this.collection = collection;
- }
- public bool BeginGroup
- {
- get
- {
- return this.beginGroup;
- }
- set
- {
- if (this.BeginGroup != value)
- {
- this.beginGroup = value;
- this.OnChanged();
- }
- }
- }
- public string Caption
- {
- get
- {
- return this.caption;
- }
- set
- {
- if (this.Caption != value)
- {
- this.caption = value;
- this.OnChanged();
- }
- }
- }
- public DXMenuItemCollection Collection
- {
- get
- {
- return this.collection;
- }
- }
- public bool Enabled
- {
- get
- {
- return this.enabled;
- }
- set
- {
- if (this.Enabled != value)
- {
- this.enabled = value;
- this.OnChanged();
- }
- }
- }
- public System.Drawing.Image Image
- {
- get
- {
- return this.image;
- }
- set
- {
- if (this.Image != value)
- {
- this.image = value;
- this.OnChanged();
- }
- }
- }
- public System.Windows.Forms.Shortcut Shortcut
- {
- get
- {
- return this.shortcut;
- }
- set
- {
- if (this.Shortcut != value)
- {
- this.shortcut = value;
- this.OnChanged();
- }
- }
- }
- public object Tag
- {
- get
- {
- return this.tag;
- }
- set
- {
- if (this.Tag != value)
- {
- this.tag = value;
- this.OnChanged();
- }
- }
- }
- public bool Visible
- {
- get
- {
- return this.visible;
- }
- set
- {
- if (this.Visible != value)
- {
- this.visible = value;
- this.OnChanged();
- }
- }
- }
- }
- }
English
