From 0ee46db2f96f0feaa09c7813e1d1dab77bdccf15 Mon Sep 17 00:00:00 2001 From: Tig Date: Sun, 9 Jun 2024 08:09:15 -0600 Subject: [PATCH] Menu event args -> One class per file --- .../Views/Menu/MenuClosingEventArgs.cs | 31 ++++++++ Terminal.Gui/Views/Menu/MenuEventArgs.cs | 73 ------------------- .../Views/Menu/MenuOpenedEventArgs.cs | 20 +++++ .../Views/Menu/MenuOpeningEventArgs.cs | 24 ++++++ 4 files changed, 75 insertions(+), 73 deletions(-) create mode 100644 Terminal.Gui/Views/Menu/MenuClosingEventArgs.cs delete mode 100644 Terminal.Gui/Views/Menu/MenuEventArgs.cs create mode 100644 Terminal.Gui/Views/Menu/MenuOpenedEventArgs.cs create mode 100644 Terminal.Gui/Views/Menu/MenuOpeningEventArgs.cs diff --git a/Terminal.Gui/Views/Menu/MenuClosingEventArgs.cs b/Terminal.Gui/Views/Menu/MenuClosingEventArgs.cs new file mode 100644 index 000000000..b578e755c --- /dev/null +++ b/Terminal.Gui/Views/Menu/MenuClosingEventArgs.cs @@ -0,0 +1,31 @@ +namespace Terminal.Gui; + +/// An which allows passing a cancelable menu closing event. +public class MenuClosingEventArgs : EventArgs +{ + /// Initializes a new instance of . + /// The current parent. + /// Whether the current menu will reopen. + /// Indicates whether it is a sub-menu. + public MenuClosingEventArgs (MenuBarItem currentMenu, bool reopen, bool isSubMenu) + { + CurrentMenu = currentMenu; + Reopen = reopen; + IsSubMenu = isSubMenu; + } + + /// + /// Flag that allows the cancellation of the event. If set to in the event handler, the + /// event will be canceled. + /// + public bool Cancel { get; set; } + + /// The current parent. + public MenuBarItem CurrentMenu { get; } + + /// Indicates whether the current menu is a sub-menu. + public bool IsSubMenu { get; } + + /// Indicates whether the current menu will reopen. + public bool Reopen { get; } +} \ No newline at end of file diff --git a/Terminal.Gui/Views/Menu/MenuEventArgs.cs b/Terminal.Gui/Views/Menu/MenuEventArgs.cs deleted file mode 100644 index f7437db05..000000000 --- a/Terminal.Gui/Views/Menu/MenuEventArgs.cs +++ /dev/null @@ -1,73 +0,0 @@ -namespace Terminal.Gui; - -/// -/// An which allows passing a cancelable menu opening event or replacing with a new -/// . -/// -public class MenuOpeningEventArgs : EventArgs -{ - /// Initializes a new instance of . - /// The current parent. - public MenuOpeningEventArgs (MenuBarItem currentMenu) { CurrentMenu = currentMenu; } - - /// - /// Flag that allows the cancellation of the event. If set to in the event handler, the - /// event will be canceled. - /// - public bool Cancel { get; set; } - - /// The current parent. - public MenuBarItem CurrentMenu { get; } - - /// The new to be replaced. - public MenuBarItem NewMenuBarItem { get; set; } -} - -/// Defines arguments for the event -public class MenuOpenedEventArgs : EventArgs -{ - /// Creates a new instance of the class - /// - /// - public MenuOpenedEventArgs (MenuBarItem parent, MenuItem menuItem) - { - Parent = parent; - MenuItem = menuItem; - } - - /// Gets the being opened. - public MenuItem MenuItem { get; } - - /// The parent of . Will be null if menu opening is the root. - public MenuBarItem Parent { get; } -} - -/// An which allows passing a cancelable menu closing event. -public class MenuClosingEventArgs : EventArgs -{ - /// Initializes a new instance of . - /// The current parent. - /// Whether the current menu will reopen. - /// Indicates whether it is a sub-menu. - public MenuClosingEventArgs (MenuBarItem currentMenu, bool reopen, bool isSubMenu) - { - CurrentMenu = currentMenu; - Reopen = reopen; - IsSubMenu = isSubMenu; - } - - /// - /// Flag that allows the cancellation of the event. If set to in the event handler, the - /// event will be canceled. - /// - public bool Cancel { get; set; } - - /// The current parent. - public MenuBarItem CurrentMenu { get; } - - /// Indicates whether the current menu is a sub-menu. - public bool IsSubMenu { get; } - - /// Indicates whether the current menu will reopen. - public bool Reopen { get; } -} diff --git a/Terminal.Gui/Views/Menu/MenuOpenedEventArgs.cs b/Terminal.Gui/Views/Menu/MenuOpenedEventArgs.cs new file mode 100644 index 000000000..7bdc9df43 --- /dev/null +++ b/Terminal.Gui/Views/Menu/MenuOpenedEventArgs.cs @@ -0,0 +1,20 @@ +namespace Terminal.Gui; + +/// Defines arguments for the event +public class MenuOpenedEventArgs : EventArgs +{ + /// Creates a new instance of the class + /// + /// + public MenuOpenedEventArgs (MenuBarItem parent, MenuItem menuItem) + { + Parent = parent; + MenuItem = menuItem; + } + + /// Gets the being opened. + public MenuItem MenuItem { get; } + + /// The parent of . Will be null if menu opening is the root. + public MenuBarItem Parent { get; } +} \ No newline at end of file diff --git a/Terminal.Gui/Views/Menu/MenuOpeningEventArgs.cs b/Terminal.Gui/Views/Menu/MenuOpeningEventArgs.cs new file mode 100644 index 000000000..d7f23d36f --- /dev/null +++ b/Terminal.Gui/Views/Menu/MenuOpeningEventArgs.cs @@ -0,0 +1,24 @@ +namespace Terminal.Gui; + +/// +/// An which allows passing a cancelable menu opening event or replacing with a new +/// . +/// +public class MenuOpeningEventArgs : EventArgs +{ + /// Initializes a new instance of . + /// The current parent. + public MenuOpeningEventArgs (MenuBarItem currentMenu) { CurrentMenu = currentMenu; } + + /// + /// Flag that allows the cancellation of the event. If set to in the event handler, the + /// event will be canceled. + /// + public bool Cancel { get; set; } + + /// The current parent. + public MenuBarItem CurrentMenu { get; } + + /// The new to be replaced. + public MenuBarItem NewMenuBarItem { get; set; } +} \ No newline at end of file