context: #region GPL statement
  /*Epic Edit is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, version 3 of the License.
  
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.*/
  #endregion
  
  using EpicEdit.Properties;
  using System;
  using System.ComponentModel;
  using System.Drawing;
  using System.Reflection;
  using System.Windows.Forms;
  
  namespace EpicEdit.UI
  {
      /// <summary>
      /// Represents the application menu bar.
      /// </summary>
      internal partial class MenuBar : UserControl
      {
          #region Events
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> OpenRomDialogRequested;
  
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> SaveRomDialogRequested;
  
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> TrackImportDialogRequested;
  
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> TrackExportDialogRequested;
  
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> TrackImportAllDialogRequested;
  
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> TrackExportAllDialogRequested;
  
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> UndoRequested;
  
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> RedoRequested;
  
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> ZoomInRequested;
  
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> ZoomOutRequested;
  
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> ZoomResetRequested;
  
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> ToggleScreenModeRequested;
  
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> PaletteEditorRequested;
  
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> BackgroundEditorRequested;
  
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> SettingEditorRequested;
  
          [Browsable(true), Category("Action")]
          public event EventHandler<EventArgs> CodecRequested;
          #endregion Events
  
          #region Constructor
          public MenuBar()
          {
              InitializeComponent();
          }
          #endregion Constructor
  
          #region Menu items
  
          #region Auto-focus
          private void MenuToolStripMouseMove(object sender, MouseEventArgs e)
          {
              // Force focus, so that when another form is focused,
              // it doesn't take 2 clicks to call a menu item
              menuToolStrip.Focus();
          }
          #endregion Auto-focus
  
          #region Open ROM
          private void OpenRomToolStripButtonClick(object sender, EventArgs e)
          {
              OpenRomDialogRequested(this, EventArgs.Empty);
          }
  
          public void EnableControls()
          {
              saveRomToolStripButton.Enabled = true;
              importTrackToolStripButton.Enabled = true;
              exportTrackToolStripButton.Enabled = true;
              importAllTrackToolStripButton.Enabled = true;
              exportAllTracksTooltipButton.Enabled = true;
  
              zoomOutToolStripButton.Enabled = true;
              zoomInToolStripButton.Enabled = true;
              paletteToolStripButton.Enabled = true;
              backgroundToolStripButton.Enabled = true;
              settingToolStripButton.Enabled = true;
              codecToolStripButton.Enabled = true;
  
              // Enable key shortcuts
              saveRomToolStripMenuItem.Enabled = true;
              saveRomAsToolStripMenuItem.Enabled = true;
              importTrackToolStripMenuItem.Enabled = true;
              exportTrackToolStripMenuItem.Enabled = true;
              zoomInToolStripMenuItem.Enabled = true;
              zoomOutToolStripMenuItem.Enabled = true;
              resetZoomToolStripMenuItem.Enabled = true;
              resetZoomNumToolStripMenuItem.Enabled = true;
          }
          #endregion Open ROM
  
          #region Save ROM
          private void SaveRomToolStripButtonClick(object sender, EventArgs e)
          {
              SaveRomDialogRequested(this, EventArgs.Empty);
          }
          #endregion Save ROM
  
          #region Import / Export tracks
          private void ImportTrackToolStripButtonClick(object sender, EventArgs e)
          {
              TrackImportDialogRequested(this, EventArgs.Empty);
          }
  
          private void ExportTrackToolStripButtonClick(object sender, EventArgs e)
          {
              TrackExportDialogRequested(this, EventArgs.Empty);
          }
  
          private void ImportAllTrackToolStripButton_Click(object sender, EventArgs e)
          {
              TrackImportAllDialogRequested(this, EventArgs.Empty);
          }
  
          private void ExportAllTracksTooltipButton_Click(object sender, EventArgs e)
          {
              TrackExportAllDialogRequested(this, EventArgs.Empty);
          }
          #endregion Import / Export tracks
  
          #region Undo / Redo
          private void Undo()
          {
              UndoRequested(this, EventArgs.Empty);
          }
  
          private void Redo()
          {
              RedoRequested(this, EventArgs.Empty);
          }
  
          private void TryToUndo()
          {
              if (undoToolStripButton.Enabled)
              {
                  Undo();
              }
          }
  
          private void TryToRedo()
          {
              if (redoToolStripButton.Enabled)
              {
                  Redo();
              }
          }
  
          private void UndoToolStripButtonClick(object sender, EventArgs e)
          {
              Undo();
          }
  
          private void RedoToolStripButtonClick(object sender, EventArgs e)
          {
              Redo();
          }
  
          public bool UndoEnabled
          {
              get => undoToolStripButton.Enabled;
              set => undoToolStripButton.Enabled = value;
          }
  
          public bool RedoEnabled
          {
              get => redoToolStripButton.Enabled;
  
gt:             set => redoToolStripButton.Enabled = value;