public DialogResult Show(IWindow?parent) { var window = NativeCast.To <GtkWindow>(parent); IntPtr dialog = IntPtr.Zero; try { using GLibString title = Title; using GLibString message = Message; dialog = Gtk.Dialog.CreateMessageDialog( window?.Handle ?? IntPtr.Zero, GtkDialogFlags.Modal | GtkDialogFlags.DestroyWithParent, GtkMessageType.Other, MapButtons(Buttons), IntPtr.Zero); GLib.SetProperty(dialog, "title", title); GLib.SetProperty(dialog, "text", message); var result = Gtk.Dialog.Run(dialog); return(MapResult(result)); } finally { if (dialog != IntPtr.Zero) { Gtk.Widget.Destroy(dialog); } } }
public void AddItem(IMenuItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } var nativeItem = NativeCast.To <GtkMenuItem>(item); menuItems.Add(nativeItem); }
public void AddItem(IMenuItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } var nativeItem = NativeCast.To <CocoaMenuItem>(item); ObjC.Call(Handle, "addItem:", nativeItem.Handle); }
public void AddItem(IMenuItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } var nativeItem = NativeCast.To <GtkMenuItem>(item); Gtk.Menu.AddItem(Handle, nativeItem.Handle); Gtk.Widget.Show(nativeItem.Handle); }
public DialogResult Show(IWindow?parent) { var window = NativeCast.To <CocoaWindow>(parent); using var alert = NSDialog.CreateAlert(); ObjC.Call(alert.Handle, "setShowsHelp:", IntPtr.Zero); ObjC.Call(alert.Handle, "setAlertStyle:", new UIntPtr((uint)NSAlertStyle.Informational)); ObjC.Call(alert.Handle, "setMessageText:", NSString.Create(Title ?? string.Empty)); ObjC.Call(alert.Handle, "setInformativeText:", NSString.Create(Message ?? string.Empty)); AddButtons(alert.Handle, Buttons); return((DialogResult)alert.Run(window)); }
public DialogResult Show(IWindow parent) { var dialog = GetDialog(); BeforeShow(dialog); var window = NativeCast.To <WinFormsWindow>(parent); var result = dialog.ShowDialog(window); BeforeReturn(dialog); return(WinFormsMapper.MapResult(result)); }
public DialogResult Show(IWindow parent) { var window = NativeCast.To <CocoaWindow>(parent); var dialog = CreateDialog(); ObjC.Call(dialog.Handle, "setTitle:", NSString.Create(Title)); ObjC.Call(dialog.Handle, "setCanCreateDirectories:", true); int result = dialog.Run(window); var mappedResult = MapResult(result); BeforeReturn(dialog, mappedResult); return(mappedResult); }
public void AddItem(IMenuItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (!canAdd) { throw new InvalidOperationException("This menu item cannot have sub-items."); } var nativeItem = NativeCast.To <WinFormsMenuItem>(item); menuItem !.DropDownItems.Add(nativeItem.Item); }
private void PopulateMenu() { if (menu == null) { return; } var nativeMenu = NativeCast.To <GtkMenu>(menu.NativeMenu); nativeMenu.SetAccelGroup(accelGroup); foreach (var menuItem in nativeMenu.GetItems()) { Gtk.Widget.ContainerAdd(menuBarHandle, menuItem.Handle); } }
public void AddItem(IMenuItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (handle == null) { handle = Gtk.Menu.Create(); Gtk.Menu.SetSubmenu(parentMenuItem, handle.Value); } var nativeItem = NativeCast.To <GtkMenuItem>(item); menuItems.Add(nativeItem); Gtk.Menu.AddItem(handle.Value, nativeItem.Handle); Gtk.Widget.Show(nativeItem.Handle); }
private void SetMenu(Menu menu) { shortcutItems.Clear(); MenuStrip mainMenu; if (!hasExistingMenu) { mainMenu = new MenuStrip(); MainMenuStrip = mainMenu; Controls.Add(MainMenuStrip); hasExistingMenu = true; MainMenuStrip.Click += MainMenuStrip_Click; MainMenuStrip.LostFocus += MainMenuStrip_LostFocus; } else { mainMenu = MainMenuStrip; mainMenu.Items.Clear(); } if (menu == null) { return; } var nativeMenu = NativeCast.To <WinFormsMenu>(menu.NativeMenu).Menu; // the native menu behaves strange if you try to iterate over the items and add them to the menu // it almost behaves like a stack, calling mainMenu.Items.AddRange(nativeMenu.Menu.Items) throws because of this var menuItems = new List <ToolStripItem>(); foreach (ToolStripItem i in nativeMenu.Items) { menuItems.Add(i); AddShortcutItems(i); } mainMenu.Items.AddRange(menuItems.ToArray()); }
public DialogResult Show(IWindow parent) { var window = NativeCast.To <WinFormsWindow>(parent); System.Windows.Forms.DialogResult result; if (window == null) { result = WFMessageBox.Show( Message, Title, WinFormsMapper.MapButtons(Buttons)); } else { result = WFMessageBox.Show( window, Message, Title, WinFormsMapper.MapButtons(Buttons)); } return(WinFormsMapper.MapResult(result)); }
private void UpdateMenu(Menu?menu) { var nativeMenu = NativeCast.To <CocoaMenu>(menu?.NativeMenu); ObjC.Call(statusItem, "setMenu:", nativeMenu?.Handle ?? IntPtr.Zero); }
public DialogResult Show(IWindow?parent) { var window = NativeCast.To <GtkWindow>(parent); bool useNative = false && Gtk.Version.IsAtLeast(3, 2, 0); IntPtr dialog = IntPtr.Zero; try { using (GLibString gtitle = Title) { if (useNative) { dialog = Gtk.Dialog.CreateNativeFileDialog( gtitle.Pointer, window?.Handle ?? IntPtr.Zero, Type, IntPtr.Zero, IntPtr.Zero); } else { string acceptString = GetAcceptString(Type); using GLibString acceptButton = acceptString; using GLibString cancelButton = "_Cancel"; dialog = Gtk.Dialog.CreateFileDialog( gtitle.Pointer, window?.Handle ?? IntPtr.Zero, Type, cancelButton, GtkResponseType.Cancel, acceptButton, GtkResponseType.Accept, IntPtr.Zero); } } Gtk.Dialog.SetCanCreateFolder(dialog, true); BeforeShow(dialog); GtkResponseType result; if (useNative) { result = Gtk.Dialog.RunNative(dialog); } else { result = Gtk.Dialog.Run(dialog); } var mappedResult = MapResult(result); BeforeReturn(dialog, mappedResult); return(mappedResult); } finally { if (dialog != IntPtr.Zero) { if (useNative) { GLib.UnrefObject(dialog); } else { Gtk.Widget.Destroy(dialog); } } } }
private void UpdateMenu(Menu menu) { var nativeMenu = NativeCast.To <GtkMenu>(menu?.NativeMenu); AppIndicator.SetMenu(Handle, nativeMenu?.Handle ?? IntPtr.Zero); }
private static void SetAppMenu(Menu menu) { var nativeMenu = NativeCast.To <CocoaMenu>(menu.NativeMenu); ObjC.Call(Handle, "setMainMenu:", nativeMenu?.Handle ?? IntPtr.Zero); }
private void UpdateMenu(Menu menu) { var nativeMenu = NativeCast.To <WinFormsMenu>(menu?.NativeMenu); notifyIcon.ContextMenuStrip = nativeMenu?.Menu; }