Пример #1
0
		protected override void OnClick(EventArgs e) {
			if (sender != null && !(sender is MenuBase))
				sender.Focused = true;
			base.OnClick(e);
			timer = 0;

			MouseEventArgs ex = (e is MouseEventArgs) ? (MouseEventArgs)e : new MouseEventArgs();

			if (ex.Button == EMouseButton.Left || ex.Button == EMouseButton.None) {
				if (ItemIndex >= 0 && Items[ItemIndex].Enabled) {
					if (ItemIndex >= 0 && Items[ItemIndex].Items != null && Items[ItemIndex].Items.Count > 0) {
						if (ChildMenu == null) {
							ChildMenu = new ContextMenu(Manager);
							(ChildMenu as ContextMenu).RootMenu = this.RootMenu;
							(ChildMenu as ContextMenu).ParentMenu = this;
							(ChildMenu as ContextMenu).sender = sender;
							ChildMenu.Items.AddRange(Items[ItemIndex].Items);
							(ChildMenu as ContextMenu).AutoSize();
						}
						int y = AbsoluteTop + Skin.Layers["Control"].ContentMargins.Top + (ItemIndex * LineHeight());
						(ChildMenu as ContextMenu).Show(sender, AbsoluteLeft + Width - 1, y);
						if (ex.Button == EMouseButton.None)
							(ChildMenu as ContextMenu).ItemIndex = 0;
					} else {
						if (ItemIndex >= 0) {
							Items[ItemIndex].ClickInvoke(ex);
						}
						if (RootMenu is ContextMenu)
							(RootMenu as ContextMenu).HideMenu(true);
						else if (RootMenu is MainMenu) {
							(RootMenu as MainMenu).HideMenu();
						}
					}
				}
			}
		}
Пример #2
0
		protected override void OnClick(EventArgs e) {
			base.OnClick(e);

			MouseEventArgs ex = (e is MouseEventArgs) ? (MouseEventArgs)e : new MouseEventArgs();

			if (ex.Button == EMouseButton.Left || ex.Button == EMouseButton.None) {
				if (ItemIndex >= 0 && Items[ItemIndex].Enabled) {
					if (ItemIndex >= 0 && Items[ItemIndex].Items != null && Items[ItemIndex].Items.Count > 0) {
						if (ChildMenu != null) {
							ChildMenu.Dispose();
							ChildMenu = null;
						}
						ChildMenu = new ContextMenu(Manager);
						(ChildMenu as ContextMenu).RootMenu = this;
						(ChildMenu as ContextMenu).ParentMenu = this;
						(ChildMenu as ContextMenu).Sender = this.Root;
						ChildMenu.Items.AddRange(Items[ItemIndex].Items);

						int y = Root.AbsoluteTop + rs[ItemIndex].Bottom + 1;
						(ChildMenu as ContextMenu).Show(this.Root, Root.AbsoluteLeft + rs[ItemIndex].Left, y);
						if (ex.Button == EMouseButton.None)
							(ChildMenu as ContextMenu).ItemIndex = 0;
					} else {
						if (ItemIndex >= 0) {
							Items[ItemIndex].ClickInvoke(ex);
						}
					}
				}
			}
		}