public override nuint GetNativeHash() { nuint hashValue = (MenuItem is null) ? 0 : MenuItem.GetNativeHash(); hashValue = hashValue ^ (nuint)Quantity.GetHashCode(); hashValue = hashValue ^ (MenuItemOptions is null ? 0 : MenuItemOptions.GetNativeHash()); return(hashValue); }
override public bool IsEqual(NSObject anObject) { var other = anObject as Order; if (other is null) { return(false); } if (ReferenceEquals(other, this)) { return(true); } // MenuItem check if (MenuItem is null) { if (!(other.MenuItem is null)) { return(false); } } else { if (!MenuItem.IsEqual(other.MenuItem)) { return(false); } } // Quantity check if (Quantity != other.Quantity) { return(false); } // MenuItemOptions check if (MenuItemOptions is null) { if (!(other.MenuItemOptions is null)) { return(false); } } else { if (!MenuItemOptions.IsEqualToSet(other.MenuItemOptions)) { return(false); } } return(true); }
async Task CreateTray(string __dirname) { if (IsWindows) { tray = await Tray.Create($"{__dirname}/assets/icons/appicon.ico"); } else { tray = await Tray.Create($"{__dirname}/assets/icons/[email protected]"); } // Sets the hover text for this tray icon. await tray.SetToolTip("MinimizeToTray Sample Program"); // Sets the title displayed aside of the tray icon in the status bar. //await tray.SetTitle("MinimizeToTray"); // Create a context menu to be displayed on the Tray var menuItemOptions = new MenuItemOptions[] { new MenuItemOptions() { Label = "Show App", Click = new ScriptObjectCallback <MenuItem, BrowserWindow, Event> ( async(ar) => { //await console.Log("Show App"); if (mainWindow != null) { if (await mainWindow.IsMinimized()) { await mainWindow.Restore(); } if (!await mainWindow.IsVisible()) { await mainWindow.Show(); } await mainWindow.Focus(); } } ) }, new MenuItemOptions() { Label = "Quit App", Click = new ScriptObjectCallback <MenuItem, BrowserWindow, Event> ( async(ar) => { //await console.Log("Quit App"); // Notify the close event that we will be quitting the app IsShouldQuit = true; mainWindow = null; await app.Quit(); } ) }, }; var contextMenu = await Menu.BuildFromTemplate(menuItemOptions); // Set our tray context menu await tray.SetContextMenu(contextMenu); // Allow the user to click on the tray icon to show the context menu. await tray.On("click", new ScriptObjectCallback ( async(sr) => { if (mainWindow != null) { await tray.PopUpContextMenu(); } }) ); }