/// <inheritdoc />
        public override void AwakeFromNib()
        {
            var commandProviders = SingleInstanceApplication.Instance.CommandProviders;

            Window.AddCommandsToMainWindow(commandProviders.Select(c => c.Value));

            string[] desiredToolbarOrder =
            {
                DownloadCommandGroup.DownloadAndPlayCommand.UniqueId,
                "_0",
                RomListCommandGroup.AddRomFilesCommand.UniqueId,
                RomListCommandGroup.AddRomFoldersCommand.UniqueId,
                MenuLayoutCommandGroup.AddRomsToMenuCommand.UniqueId,
                DownloadCommandGroup.SyncHostToDeviceCommand.UniqueId,
                "_1",
                DeviceCommandGroup.SearchForDevicesCommand.UniqueId,
                DeviceCommandGroup.DisconnectDeviceCommand.UniqueId,
                "_2",
                MenuLayoutCommandGroup.NewDirectoryCommand.UniqueId,
                MenuLayoutCommandGroup.DeleteItemsCommand.UniqueId,
            };

            var toolbar = RootCommandGroup.RootCommand.Visual as NSToolbar;

            foreach (var toolbarItemId in desiredToolbarOrder.Reverse())
            {
                var           items       = toolbar.Items.ToList();
                var           index       = items.FindIndex(i => i.Identifier == toolbarItemId);
                NSToolbarItem toolbarItem = null;
                if (index > 0)
                {
                    toolbarItem = items[index];
                    toolbar.RemoveItem(index);
                }
                else if (toolbarItemId[0] == '_')
                {
                    toolbarItem = new NSToolbarItem(NSToolbar.NSToolbarSpaceItemIdentifier); // separator has been deprecated
                }
                if (index != 0)
                {
                    var prevWillAdd = toolbar.WillInsertItem;
                    toolbar.WillInsertItem = (t, i, b) => toolbarItem;
                    toolbar.InsertItem(toolbarItemId, 0);
                    toolbar.WillInsertItem = prevWillAdd;
                }
            }

            RomListController = new INTV.Shared.View.RomListViewController();
            NSViewController viewController = RomListController;
            var romListView = (RomListView)viewController.View;

            romListView.DataContext = Window.ViewModel.RomList;
            romListView.Frame       = RomListSplitView.Frame;
            SplitView.ReplaceSubviewWith(RomListSplitView, romListView);
            RomListSplitView = romListView;

            viewController = new INTV.LtoFlash.View.MenuLayoutViewController();
            ((MenuLayoutViewController)viewController).LtoFlashViewModel = Window.ViewModel.LtoFlash;
            var menuLayoutView = (MenuLayoutView)viewController.View;

            menuLayoutView.DataContext = Window.ViewModel.MenuLayout;
            Window.ViewModel.MenuLayout.PropertyChanged += HandleMenuLayoutPropertyChanged;
            menuLayoutView.Frame = MenuLayoutSplitView.Frame;
            SplitView.ReplaceSubviewWith(MenuLayoutSplitView, menuLayoutView);
            MenuLayoutSplitView = menuLayoutView;

            Window.LayoutIfNeeded(); // Ensure that we get a refresh of layout after tinkering with the visual tree.
#if ENABLE_DEBUG_SPAM
            Window.DidBecomeMain += (object sender, EventArgs e) => System.Diagnostics.Debug.WriteLine("**** BECAME MAIN");
            Window.DidResignMain += (object sender, EventArgs e) => System.Diagnostics.Debug.WriteLine("**** RESIGNED MAIN");
#endif // ENABLE_DEBUG_SPAM
        }