public override void ViewWillAppear() { base.ViewWillAppear(); if (_aggregator != null) { return; } _aggregator = TinyIoC.TinyIoCContainer.Current.Resolve <IRepositoryInformationAggregator>(); var actionProvider = TinyIoC.TinyIoCContainer.Current.Resolve <IRepositoryActionProvider>(); _monitor = TinyIoC.TinyIoCContainer.Current.Resolve <IRepositoryMonitor>(); _monitor.OnScanStateChanged += _monitor_OnScanStateChanged; _stringCommandHandler.Define(new string[] { "help", "man", "?" }, ShowCommandReference, "Shows this help page"); _stringCommandHandler.Define(new string[] { "scan" }, async() => await _monitor.ScanForLocalRepositoriesAsync(), "Scans this Mac for git repositories"); _stringCommandHandler.Define(new string[] { "reset" }, _monitor.Reset, "Resets the repository cache"); _stringCommandHandler.Define(new string[] { "info", "stats" }, ShowStats, "Shows process informations"); _stringCommandHandler.Define(new string[] { "quit", "close", "exit" }, () => NSApplication.SharedApplication.Terminate(this), "Closes the application"); // Do any additional setup after loading the view. var datasource = new RepositoryTableDataSource(_aggregator.Repositories); RepoTab.DataSource = datasource; datasource.CollectionChanged += Datasource_CollectionChanged; RepoTab.Delegate = new RepositoryTableDelegate(RepoTab, datasource, actionProvider); SetControlVisibilityByRepositoryAvailability(); RepoTab.BackgroundColor = NSColor.Clear; RepoTab.EnclosingScrollView.DrawsBackground = false; SearchBox.FinishInput += SearchBox_FinishInput; SearchBox.NextKeyView = RepoTab; }
private void CreateMenu() { if (MenuButton.Menu != null) { return; } MenuButton.Menu = new NSMenu(); var topLevelItems = new NSMenuItem[] { new NSMenuItem("Manage repositories") { Tag = MENU_MANAGE }, new NSMenuItem("Auto fetch") { Tag = MENU_AUTOFETCH }, NSMenuItem.SeparatorItem, new NSMenuItem("Ping back ♥︎") { Tag = MENU_PINGBACK }, NSMenuItem.SeparatorItem, new NSMenuItem("Help", (s, e) => ShowHelp()), new NSMenuItem("Quit", (s, e) => Quit()) }; foreach (var item in topLevelItems) { MenuButton.Menu.AddItem(item); } var manageItems = new NSMenuItem[] { new NSMenuItem("Scan mac", async(s, e) => await _monitor.ScanForLocalRepositoriesAsync()), new NSMenuItem("Clear", (s, e) => _monitor.Reset()), NSMenuItem.SeparatorItem, new NSMenuItem("Reset ignore rules", (s, e) => _repositoryIgnoreStore.Reset()) }; var autoFetchItems = new NSMenuItem[] { new NSMenuItem(nameof(AutoFetchMode.Off), HandleAutoFetchChange) { Identifier = AutoFetchMode.Off.ToString() }, new NSMenuItem(nameof(AutoFetchMode.Discretely), HandleAutoFetchChange) { Identifier = AutoFetchMode.Discretely.ToString() }, new NSMenuItem(nameof(AutoFetchMode.Adequate), HandleAutoFetchChange) { Identifier = AutoFetchMode.Adequate.ToString() }, new NSMenuItem(nameof(AutoFetchMode.Aggresive), HandleAutoFetchChange) { Identifier = AutoFetchMode.Aggresive.ToString() } }; var manageRepositoriesItem = MenuButton.Menu.ItemWithTag(MENU_MANAGE); manageRepositoriesItem.Submenu = new NSMenu(); foreach (var item in manageItems) { manageRepositoriesItem.Submenu.AddItem(item); } var autoFetchItem = MenuButton.Menu.ItemWithTag(MENU_AUTOFETCH); autoFetchItem.Submenu = new NSMenu(); foreach (var item in autoFetchItems) { autoFetchItem.Submenu.AddItem(item); } var pingbackItems = new NSMenuItem[] { new NSMenuItem("Star RepoZ on GitHub", (s, e) => Navigate("https://github.com/awaescher/RepoZ")) { }, new NSMenuItem("Follow @Waescher", (s, e) => Navigate("https://twitter.com/Waescher")), NSMenuItem.SeparatorItem, new NSMenuItem("Buy me a coffee", (s, e) => Navigate("https://www.buymeacoffee.com/awaescher")) }; var pingbackItem = MenuButton.Menu.ItemWithTag(MENU_PINGBACK); pingbackItem.Submenu = new NSMenu(); foreach (var item in pingbackItems) { pingbackItem.Submenu.AddItem(item); } }