public void DeletePerson(NSWindow window) { // Anything to process? if (SelectedPerson == null) { var alert = new NSAlert () { AlertStyle = NSAlertStyle.Critical, InformativeText = "Please select the person to remove from the collection of people.", MessageText = "Delete Person", }; alert.BeginSheet (window); } else { // Confirm delete var alert = new NSAlert () { AlertStyle = NSAlertStyle.Critical, InformativeText = string.Format ("Are you sure you want to delete person `{0}` from the collection?", SelectedPerson.Name), MessageText = "Delete Person", }; alert.AddButton ("Ok"); alert.AddButton ("Cancel"); alert.BeginSheetForResponse (window, (result) => { // Delete? if (result == 1000) { RemovePerson (View.SelectionIndex); } }); } }
public new void addWindowsItem_title_filename(NSWindow window, NSString title, bool isFileName) { Unused.Value = SuperCall(NSApplication.Class, "addWindowsItem:title:filename:", window, title, isFileName); // Make directory windows bold. NSObject controller = window.windowController(); if (controller.class_().Name == "DirectoryController") { NSMenuItem item = DoGetMenuItem(window); if (item != null) { var dict = NSMutableDictionary.Create(); dict.setObject_forKey(NSFont.menuBarFontOfSize(0.0f), Externs.NSFontAttributeName); dict.setObject_forKey(NSNumber.Create(-5.0f), Externs.NSStrokeWidthAttributeName); var str = NSAttributedString.Alloc().initWithString_attributes(title, dict); str.autorelease(); item.setAttributedTitle(str); } } // I tried making the path component of reversed paths gray, but it didn't always work and, // when it did, it was only for the first window name. Cocoa does adjust the attributes for // the menu item when it does things like underline dirty documents and I think that this // is resetting the foreground color. }
public override void DidFinishLaunching (NSNotification notification) { var menu = new NSMenu (); var menuItem = new NSMenuItem (); menu.AddItem (menuItem); var appMenu = new NSMenu (); var quitItem = new NSMenuItem ("Quit", "q", (s, e) => NSApplication.SharedApplication.Terminate (menu)); appMenu.AddItem (quitItem); menuItem.Submenu = appMenu; NSApplication.SharedApplication.MainMenu = menu; m_window = new NSWindow ( new CGRect (0, 0, 1024, 720), NSWindowStyle.Closable | NSWindowStyle.Miniaturizable | NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.TexturedBackground, NSBackingStore.Buffered, false) { Title = "Bluebird WkBrowser", ReleasedWhenClosed = false, ContentMinSize = new CGSize (1024, 600), CollectionBehavior = NSWindowCollectionBehavior.FullScreenPrimary }; m_window.Center (); m_window.MakeKeyAndOrderFront (null); var viewController = new ViewController (); m_window.ContentView = viewController.View; m_window.ContentViewController = viewController; viewController.View.Frame = m_window.ContentView.Bounds; }
public WarningWindow() { // Interface Builder won't allow us to create a window with no title bar // so we have to create it manually. But we could use IB if we display // the window with a sheet... NSRect rect = new NSRect(0, 0, 460, 105); m_window = NSWindow.Alloc().initWithContentRect_styleMask_backing_defer(rect, 0, Enums.NSBackingStoreBuffered, false); m_window.setHasShadow(false); // Initialize the text attributes. var dict = NSMutableDictionary.Create(); NSFont font = NSFont.fontWithName_size(NSString.Create("Georgia"), 64.0f); dict.setObject_forKey(font, Externs.NSFontAttributeName); NSMutableParagraphStyle style = NSMutableParagraphStyle.Create(); style.setAlignment(Enums.NSCenterTextAlignment); dict.setObject_forKey(style, Externs.NSParagraphStyleAttributeName); m_attrs = dict.Retain(); // Initialize the background bezier. m_background = NSBezierPath.Create().Retain(); m_background.appendBezierPathWithRoundedRect_xRadius_yRadius(m_window.contentView().bounds(), 20.0f, 20.0f); m_color = NSColor.colorWithDeviceRed_green_blue_alpha(250/255.0f, 128/255.0f, 114/255.0f, 1.0f).Retain(); ActiveObjects.Add(this); }
public bool promptForLogin(NSWindow aParentwindow) { done = false; parentWindow = aParentwindow; if (aParentwindow.isVisible()) { NSApp.beginSheet(this.window()) modalForWindow(aParentwindow) modalDelegate(this) didEndSelector(__selector(didEndSheet:returnCode:contextInfo:)) contextInfo(null); try { NSApp.runModalForWindow(this.window()); } finally { NSApp.endSheet(this.window()); this.window().orderOut(parentWindow); } } else { NSModalSession s = NSApp.beginModalSessionForWindow(this.window()); this.window().display(); try { NSApp.runModalForWindow(this.window()); } finally { NSApp.endModalSession(s); this.window().close(); } } return done; }
public static void NSBeginInformationalAlertSheet(NSString title, NSString defaultButton, NSString alternateButton, NSString otherButton, NSWindow docWindow, NSObject modalDelegate, string didEndSelector, string didDismissSelector, IntPtr contextInfo, NSString message) { Selector endSelector = didEndSelector != null ? new Selector(didEndSelector) : null; Selector dismissSelector = didDismissSelector != null ? new Selector(didDismissSelector) : null; NativeMethods.NSBeginInformationalAlertSheet(title, defaultButton, alternateButton, otherButton, docWindow, modalDelegate, endSelector, dismissSelector, contextInfo, message); }
public void DeletePerson(NSWindow window) { if (Table.SelectedRow == -1) { var alert = new NSAlert () { AlertStyle = NSAlertStyle.Critical, InformativeText = "Please select the person to remove from the list of people.", MessageText = "Delete Person", }; alert.BeginSheet (window); } else { // Grab person SelectedPerson = _people.GetItem<PersonModel> ((nuint)Table.SelectedRow); // Confirm delete var alert = new NSAlert () { AlertStyle = NSAlertStyle.Critical, InformativeText = string.Format("Are you sure you want to delete person `{0}` from the table?",SelectedPerson.Name), MessageText = "Delete Person", }; alert.AddButton ("Ok"); alert.AddButton ("Cancel"); alert.BeginSheetForResponse (window, (result) => { // Delete? if (result == 1000) { RemovePerson(Table.SelectedRow); } }); } }
public void showSheetForWindow(NSWindow aWindow) withMessage(NSString aMessage) allowCancel(bool aAllowCancel) { window = aWindow; messageText = aMessage; allowCancel = aAllowCancel; NSApp.beginSheet(window) modalForWindow(window) modalDelegate(this) didEndSelector(__selector(didEndSheet:returnCode:contextInfo:)) contextInfo(null); }
/// <exclude/> public BlockCookie beginSheetModalForWindow_completionHandler(NSWindow window, Action<int> callback) { Action<IntPtr, int> thunk = (IntPtr context, int result) => callback(result); var cookie = new BlockCookie("beginSheetModalForWindow_completionHandler", thunk); Call("beginSheetModalForWindow:completionHandler:", window, cookie.Block); return cookie; }
public static Gtk.Window GetGtkWindow (NSWindow window) { if (window == null) return null; var toplevels = Gtk.Window.ListToplevels (); return toplevels.FirstOrDefault (w => w.IsRealized && (gdk_quartz_window_get_nswindow (w.GdkWindow.Handle) == window.Handle)); }
public static void ShowGenericWindowAsSheet (string content, string title, NSWindow parentWindow) { UIErrorHelper.CheckedExec (delegate () { GenericTextViewWindowController gwc = new GenericTextViewWindowController (content); gwc.Window.Title = title; NSApplication.SharedApplication.BeginSheet (gwc.Window, parentWindow, () => { }); NSApplication.SharedApplication.RunModalForWindow (gwc.Window); parentWindow.EndSheet (gwc.Window); gwc.Dispose (); }); }
public override void DidFinishLaunching(NSNotification notification) { _window = new NSWindow(new CGRect(200, 200, 400, 700), NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled, NSBackingStore.Buffered, false, NSScreen.MainScreen); var setup = new Setup(this, _window); setup.Initialize(); var startup = Mvx.Resolve<IMvxAppStart>(); startup.Start(); _window.MakeKeyAndOrderFront(this); }
partial void goFullScreen (NSObject sender) { isInFullScreenMode = true; // Pause the non-fullscreen view openGLView.StopAnimation (); CGRect mainDisplayRect; CGRect viewRect; // Create a screen-sized window on the display you want to take over // Note, mainDisplayRect has a non-zero origin if the key window is on a secondary display mainDisplayRect = NSScreen.MainScreen.Frame; fullScreenWindow = new NSWindow (mainDisplayRect, NSWindowStyle.Borderless, NSBackingStore.Buffered, true); // Set the window level to be above the menu bar fullScreenWindow.Level = NSWindowLevel.MainMenu + 1; // Perform any other window configuration you desire fullScreenWindow.IsOpaque = true; fullScreenWindow.HidesOnDeactivate = true; // Create a view with a double-buffered OpenGL context and attach it to the window // By specifying the non-fullscreen context as the shareContext, we automatically inherit the // OpenGL objects (textures, etc) it has defined viewRect = new CGRect (0, 0, mainDisplayRect.Size.Width, mainDisplayRect.Size.Height); fullScreenView = new MyOpenGLView (viewRect, openGLView.OpenGLContext); fullScreenWindow.ContentView = fullScreenView; // Show the window fullScreenWindow.MakeKeyAndOrderFront (this); // Set the scene with the full-screen viewport and viewing transformation Scene.ResizeGLScene (viewRect); // Assign the view's MainController to self fullScreenView.MainController = this; if (!isAnimating) { // Mark the view as needing drawing to initalize its contents fullScreenView.NeedsDisplay = true; } else { // Start playing the animation fullScreenView.StartAnimation (); } }
public void EditPerson(NSWindow window) { if (SelectedPerson == null) { var alert = new NSAlert () { AlertStyle = NSAlertStyle.Informational, InformativeText = "Please select the person to edit from the collection of people.", MessageText = "Edit Person", }; alert.BeginSheet (window); } else { // Grab person SelectedPerson = _people.GetItem<PersonModel> ((nuint)View.SelectionIndex); var sheet = new PersonEditorSheetController(SelectedPerson, false); // Display sheet sheet.ShowSheet(window); } }
public void TableViewDoubleClick(NSObject sender) { // NSTableView tv = (NSTableView)sender; // Console.WriteLine("TableView: {0}", tv); ScheduledClass c = scheduleFetcher.ScheduledClasses[(int)tableView.ClickedRow]; // webPanel = new NSPanel(); webPanel = new NSWindow(); webPanel.StyleMask = NSWindowStyle.Resizable | webPanel.StyleMask; webPanel.SetContentSize(new CGSize(Window.ContentView.Frame.Size.Width, 500.0f)); webView = new WebView(new CGRect(0.0f, 50.0f, Window.ContentView.Frame.Size.Width, 450.0f), "", ""); webView.AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable; webPanel.ContentView.AddSubview(webView); webView.WeakResourceLoadDelegate = this; webView.WeakFrameLoadDelegate = this; progressBar = new NSProgressIndicator(new CGRect(25.0f, 12.0f, Window.ContentView.Frame.Size.Width-175.0f, 25.0f)); progressBar.Style = NSProgressIndicatorStyle.Bar; progressBar.Indeterminate = false; progressBar.AutoresizingMask = NSViewResizingMask.WidthSizable; webPanel.ContentView.AddSubview(progressBar); progressBar.MinValue = 0; progressBar.MaxValue = 100; progressBar.DoubleValue = progress; NSButton closebutton = new NSButton(new CGRect(webPanel.Frame.Width - 125.0f, 12.0f, 100.0f, 25.0f)); closebutton.Title = "Close"; closebutton.BezelStyle = NSBezelStyle.Rounded; closebutton.Target = this; closebutton.Action = new Selector("closePanel:"); closebutton.AutoresizingMask = NSViewResizingMask.MinXMargin; webPanel.DefaultButtonCell = closebutton.Cell; webPanel.ContentView.AddSubview(closebutton); webView.MainFrameUrl = c.Href; // Window.BeginSheet(webPanel, (nint) => { // // }); NSApplication.SharedApplication.BeginSheet(webPanel, Window); //NSWorkspace.SharedWorkspace.OpenUrl(new NSUrl(c.Href)); }
public override void DidFinishLaunching(NSNotification notification) { Window = new NSWindow(new CGRect(0, 0, 400, 300), NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.Closable, NSBackingStore.Buffered, false, NSScreen.MainScreen); // how big? Window.Title = "TipCalc"; Window.WillClose += (sender, e) => { NSApplication.SharedApplication.Terminate(this); }; var presenter = new MvxMacViewPresenter(this, Window); var setup = new Setup(this, presenter); setup.Initialize(); var startup = Mvx.Resolve<IMvxAppStart>(); startup.Start(); Window.MakeKeyAndOrderFront(this); }
protected virtual void UpdateWindow(MvxWindowPresentationAttribute attribute, NSWindow window) { var positionX = attribute.PositionX != MvxWindowPresentationAttribute.InitialPositionX ? attribute.PositionX : (float)window.Frame.X; var positionY = attribute.PositionY != MvxWindowPresentationAttribute.InitialPositionY ? attribute.PositionY : (float)window.Frame.Y; var width = attribute.Width != MvxWindowPresentationAttribute.InitialWidth ? attribute.Width : (float)window.Frame.Width; var height = attribute.Height != MvxWindowPresentationAttribute.InitialHeight ? attribute.Height : (float)window.Frame.Height; var newFrame = new CGRect(positionX, positionY, width, height); window.SetFrame(newFrame, false); window.StyleMask = attribute.WindowStyle ?? window.StyleMask; window.BackingType = attribute.BufferingType ?? window.BackingType; window.TitleVisibility = attribute.TitleVisibility ?? window.TitleVisibility; }
public void CreatePanelDidEnd(NSWindow w, int returnCode, IntPtr context) { }
public void Run(NSWindow callerWindow) { _callerWindow = callerWindow; RunModal(); }
public CoreWindow(NSWindow window) { _window = window; }
/// <summary> /// Wraps the specified Cocoa <paramref name="window"/> in an Eto control so it can be used as a parent when showing dialogs, etc. /// </summary> /// <returns>The eto window wrapper around the native Cocoa window.</returns> /// <param name="window">Cocoa Window to wrap.</param> public static Window ToEtoWindow(this NSWindow window) { return(new Form(new NativeFormHandler(window))); }
private void didEndSheet(NSWindow sheet) returnCode(int returnCode) contextInfo(id info)
public WindowDelegate(NSWindow window) { _window = window; }
public WindowFrameBackend(NSWindow window) { Window = window; }
public MvxMacViewPresenter(NSApplicationDelegate applicationDelegate, NSWindow window) { _applicationDelegate = applicationDelegate; _window = window; }
public static void Run(NSWindow mainForm) { MonoMacInit(); NSApplication.Main(new string[] {}); }
protected MvxMacSetup(IMvxApplicationDelegate applicationDelegate, NSWindow window) : this(applicationDelegate) { _window = window; }
public Setup(MvxApplicationDelegate applicationDelegate, NSWindow window) : base(applicationDelegate, window) { }
private void CreateNativeWindow(WindowOptions options) { var rect = new CGRect(0, 0, options.ClientSize.X, options.ClientSize.Y); View = new NSGameView(Application.Input, rect, Platform.GraphicsMode.Default); NSWindowStyle style; if (options.Style == WindowStyle.Borderless) { style = NSWindowStyle.Borderless; } else if (options.Style == WindowStyle.Dialog) { style = NSWindowStyle.Titled | NSWindowStyle.Closable; } else { style = NSWindowStyle.Titled | NSWindowStyle.Closable | NSWindowStyle.Miniaturizable; } if (!options.FixedSize) { style |= NSWindowStyle.Resizable; } window = new NSWindow(rect, style, NSBackingStore.Buffered, false); window.TabbingMode = (NSWindowTabbingMode)options.MacWindowTabbingMode; if (options.Style == WindowStyle.Dialog) { window.StandardWindowButton(NSWindowButton.MiniaturizeButton).Hidden = true; window.StandardWindowButton(NSWindowButton.ZoomButton).Hidden = true; } var contentRect = window.ContentRectFor(rect); titleBarHeight = ((RectangleF)rect).Height - (float)contentRect.Height; if (options.MinimumDecoratedSize != Vector2.Zero) { MinimumDecoratedSize = options.MinimumDecoratedSize; } if (options.MaximumDecoratedSize != Vector2.Zero) { MaximumDecoratedSize = options.MaximumDecoratedSize; } window.Title = options.Title; window.WindowShouldClose += OnShouldClose; window.WillClose += OnWillClose; window.DidResize += (s, e) => { needUpdateGLContext = true; HandleResize(s, e); }; window.WillEnterFullScreen += (sender, e) => { shouldFixFullscreen = !window.StyleMask.HasFlag(NSWindowStyle.Resizable); if (shouldFixFullscreen) { window.StyleMask |= NSWindowStyle.Resizable; } windowedClientSize = ClientSize; }; window.WillExitFullScreen += (sender, e) => { ClientSize = windowedClientSize; }; window.DidExitFullScreen += (sender, e) => { if (shouldFixFullscreen) { window.StyleMask &= ~NSWindowStyle.Resizable; } }; window.DidBecomeKey += (sender, e) => { RaiseActivated(); }; window.DidResignKey += (sender, e) => { // Clearing key state on deactivate is required so no keys will get stuck. // If, for some reason, you need to transfer key state between windows use InputSimulator to hack it. See docking implementation in Tangerine. Input.ClearKeyState(); RaiseDeactivated(); }; window.DidMove += HandleMove; NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.WillStartLiveResizeNotification, OnWillStartLiveResize); NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidEndLiveResizeNotification, OnDidEndLiveResize); window.CollectionBehavior = NSWindowCollectionBehavior.FullScreenPrimary; window.ContentView = View; View.Update += Update; View.RenderFrame += HandleRenderFrame; View.FilesDropped += RaiseFilesDropped; View.DidMouseEnter += () => { Application.WindowUnderMouse = this; }; View.DidMouseExit += () => { if (Application.WindowUnderMouse == this) { Application.WindowUnderMouse = null; } }; }
public WindowFrameBackend(NSWindow window) { Window = window; // don't replace existing delegates hasExternalDelegate = Window.Delegate != null || Window.WeakDelegate != null; }
static void Main(string[] args) { NSApplication.Init(); NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular; var xPos = NSScreen.MainScreen.Frame.Width / 2; // NSWidth([[window screen] frame])/ 2 - NSWidth([window frame])/ 2; var yPos = NSScreen.MainScreen.Frame.Height / 2; // NSHeight([[window screen] frame])/ 2 - NSHeight([window frame])/ 2; var mainWindow = new MacAccInspectorWindow(new CGRect(xPos, yPos, 300, 368), NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.Closable, NSBackingStore.Buffered, false); var stackView = new NSStackView() { Orientation = NSUserInterfaceLayoutOrientation.Vertical }; mainWindow.ContentView = stackView; stackView.AddArrangedSubview(new NSTextField { StringValue = "123" }); stackView.AddArrangedSubview(new NSTextField { StringValue = "45" }); stackView.AddArrangedSubview(new NSTextField { StringValue = "345" }); var button = new NSButton { Title = "Press to show a message" }; stackView.AddArrangedSubview(button); var hotizontalView = new NSStackView() { Orientation = NSUserInterfaceLayoutOrientation.Horizontal }; hotizontalView.AddArrangedSubview(new NSTextField() { StringValue = "test" }); stackView.AddArrangedSubview(hotizontalView); button.Activated += (sender, e) => { var alert = new NSAlert(); alert.MessageText = "You clicked the button!!!"; alert.InformativeText = "Are you sure!?"; alert.AddButton("OK!"); alert.RunModal(); }; var button2 = new NSButton { Title = "Opens Localized text" }; button2.Activated += (sender, e) => { var window = new NSWindow() { StyleMask = NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.Closable }; var stack = NativeViewHelper.CreateHorizontalStackView(); var label = NativeViewHelper.CreateLabel(Strings.HelloText); stack.AddArrangedSubview(label); window.ContentView = stack; window.WillClose += (sender1, e1) => { window.Dispose(); }; window.MakeKeyAndOrderFront(mainWindow); }; stackView.AddArrangedSubview(button2); button2.HeightAnchor.ConstraintEqualToConstant(100).Active = true;; mainWindow.Title = "Example Debug Xamarin.Mac"; //mainWindow.MakeKeyWindow(); mainWindow.MakeKeyAndOrderFront(null); NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); NSApplication.SharedApplication.Run(); //mainWindow.Dispose(); }
/// <summary> /// Initializes a new instance of the <see cref="SourceWriter.EditorWidowDelegate"/> class. /// </summary> /// <param name="window">The <c>NSWindow</c> being managed by the <c>NSWindowController</c> this delegate /// is attached to.</param> public EditorWidowDelegate (NSWindow window) { // Initialize this.Window = window; }
public override bool ShouldZoom(NSWindow window, RectangleF newFrame) { return(_owner.AllowUserResizing); }
public static void Run (NSWindow mainForm) { MonoMacInit(); NSApplication.Main (new string[]{}); }
public MvxWindowController(NSWindow window) : base(window) { }
public static Gtk.Window GetGtkWindow(NSWindow window) { var toplevels = Gtk.Window.ListToplevels(); return(toplevels.FirstOrDefault(w => gdk_quartz_window_get_nswindow(w.GdkWindow.Handle) == window.Handle)); }
public void Close() { if (m_range != null) m_range.Changed -= this.DoRangeChanged; if (m_attrs != null) { if (m_parent != null) { NSNotificationCenter.defaultCenter().removeObserver_name_object( this, Externs.NSWindowWillCloseNotification, m_parent); NSNotificationCenter.defaultCenter().removeObserver_name_object( this, Externs.NSViewFrameDidChangeNotification, m_text.superview()); NSNotificationCenter.defaultCenter().removeObserver_name_object( this, Externs.NSViewBoundsDidChangeNotification, m_text.superview()); if (Visible) Visible = false; m_parent = null; } m_attrs.release(); close(); autorelease(); m_attrs = null; } }
protected MvxMacSetup(MvxApplicationDelegate applicationDelegate, NSWindow window) { this._window = window; this._applicationDelegate = applicationDelegate; }
//largely ported from azure-activedirectory-library-for-objc //ADAuthenticationViewController.m public override void LoadWindow() { var parentWindow = _callerWindow ?? NSApplication.SharedApplication.MainWindow; CGRect windowRect; if (parentWindow != null) { windowRect = parentWindow.Frame; } else { // If we didn't get a parent window then center it in the screen windowRect = NSScreen.MainScreen.Frame; } // Calculate the center of the current main window so we can position our window in the center of it CGRect centerRect = CenterRect(windowRect, new CGRect(0, 0, DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT)); var window = new NSWindow(centerRect, NSWindowStyle.Titled | NSWindowStyle.Closable, NSBackingStore.Buffered, true) { BackgroundColor = NSColor.WindowBackground, WeakDelegate = this, AccessibilityIdentifier = "SIGN_IN_WINDOW" }; var contentView = window.ContentView; contentView.AutoresizesSubviews = true; _webView = new WebView(contentView.Frame, null, null) { FrameLoadDelegate = this, PolicyDelegate = this, AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable, AccessibilityIdentifier = "SIGN_IN_WEBVIEW" }; contentView.AddSubview(_webView); // On macOS there's a noticeable lag between the window showing and the page loading, so starting with the spinner // at least make it looks like something is happening. _progressIndicator = new NSProgressIndicator( new CGRect( (DEFAULT_WINDOW_WIDTH / 2) - 16, (DEFAULT_WINDOW_HEIGHT / 2) - 16, 32, 32)) { Style = NSProgressIndicatorStyle.Spinning, // Keep the item centered in the window even if it's resized. AutoresizingMask = NSViewResizingMask.MinXMargin | NSViewResizingMask.MaxXMargin | NSViewResizingMask.MinYMargin | NSViewResizingMask.MaxYMargin }; _progressIndicator.Hidden = false; _progressIndicator.StartAnimation(null); contentView.AddSubview(_progressIndicator); Window = window; _webView.MainFrameUrl = _url; }
// Used to reload a document for which the file changed. public void reloadSheetDidEnd_returnCode_contextInfo(NSWindow sheet, int returnCode, IntPtr context) { if (returnCode == Enums.NSAlertDefaultReturn ) { Reload(); } }
public EditorWindowDelegate(NSWindow window) { // Initialize this.Window = window; }
public static void ApplyTheme (NSWindow window) { if (!nsWindows.ContainsKey(window)) { nsWindows [window] = NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.WillCloseNotification, OnClose, window); SetTheme (window); } }
public OptionDialogMonobjc(IList <IOptionPage> aOptionPages) { // create a list of option pages iPages = new List <OptionPageMonobjc>(); NSRect windowRect = new NSRect(0, 0, kWidth, kHeight); float division = kWidth / 4; NSRect scrollViewRect = new NSRect(kPadding, kPadding, division - (kPadding * 2), kHeight - (kPadding * 2)); NSRect pageRect = new NSRect(division + kPadding, kPadding, kWidth - division - (kPadding * 2), kHeight - (kPadding * 2)); foreach (IOptionPage page in aOptionPages) { iPages.Add(new OptionPageMonobjc(page, pageRect)); } // create main window for the dialog iWindow = new NSWindow(windowRect, NSWindowStyleMasks.NSClosableWindowMask | NSWindowStyleMasks.NSTitledWindowMask, NSBackingStoreType.NSBackingStoreBuffered, false); iWindow.Title = NSString.StringWithUTF8String("User Options"); iWindow.SetDelegate(d => { d.WindowShouldClose += delegate(Id aSender) { return(true); }; d.WindowWillClose += delegate(NSNotification aNotification) { NSApplication.NSApp.AbortModal(); }; }); iWindow.IsReleasedWhenClosed = false; // create a view for the window content NSView view = new NSView(); iWindow.ContentView = view; NSScrollView scrollView = new NSScrollView(); scrollView.HasVerticalScroller = true; scrollView.HasHorizontalScroller = true; scrollView.AutohidesScrollers = true; NSTableColumn tableColumn = new NSTableColumn(); tableColumn.ResizingMask = NSTableColumnResizingMasks.NSTableColumnAutoresizingMask | NSTableColumnResizingMasks.NSTableColumnUserResizingMask; tableColumn.IsEditable = false; iTableDelegate = new OptionDialogMonobjcDelegate(iPages); iTableDataSource = new OptionDialogMonobjcDataSource(iPages); iTableDelegate.EventSelectedPage += EventSelectedPageHandler; iTableView = new NSTableView(); iTableView.DataSource = iTableDataSource; iTableView.HeaderView = null; iTableView.UsesAlternatingRowBackgroundColors = true; iTableView.AddTableColumn(tableColumn); iTableView.Delegate = iTableDelegate; iTableView.AllowsEmptySelection = false; iTableView.AllowsMultipleSelection = false; scrollView.Frame = scrollViewRect; iTableView.Frame = scrollView.ContentView.Bounds; tableColumn.Width = iTableView.Bounds.Width - 3; scrollView.DocumentView = iTableView; view.AddSubview(scrollView); iTableView.ReloadData(); // view have been added to the window so they can be released view.Release(); tableColumn.Release(); scrollView.Release(); }
public MainToolbar(Gtk.Window window) { gtkWindow = window; widget = new NSToolbar(MainToolbarId) { DisplayMode = NSToolbarDisplayMode.Icon, }; awesomeBar = new AwesomeBar(); awesomeBar.RunButton.Activated += (o, e) => { RunButtonClicked?.Invoke(o, e); }; awesomeBar.RunButton.UnfocusToolbar += (o, e) => { awesomeBar.Window.MakeFirstResponder(null); exitAction(Gtk.DirectionType.TabBackward); }; // Remove the focus from the Gtk system when Cocoa has focus // Fixes BXC #29601 awesomeBar.SearchBar.GainedFocus += (o, e) => IdeApp.Workbench.RootWindow.Focus = null; AttachToolbarEvents(awesomeBar.SearchBar); selectorView.ConfigurationChanged += (sender, e) => { if (ConfigurationChanged != null) { ConfigurationChanged(sender, e); } }; selectorView.RunConfigurationChanged += (sender, e) => { if (RunConfigurationChanged != null) { RunConfigurationChanged(sender, e); } }; selectorView.RuntimeChanged += (sender, ea) => { if (RuntimeChanged != null) { RuntimeChanged(sender, ea); } }; widget.WillInsertItem = (tool, id, send) => { switch (id) { case AwesomeBarId: return(new NSToolbarItem(AwesomeBarId) { View = awesomeBar, MinSize = new CGSize(MacSystemInformation.OsVersion < MacSystemInformation.Mojave ? 1024: 600, AwesomeBar.ToolbarWidgetHeight), MaxSize = new CGSize(float.PositiveInfinity, AwesomeBar.ToolbarWidgetHeight) }); default: throw new NotImplementedException(); } }; // We can't use the events that Xamarin.Mac adds for delegate methods as they will overwrite // the delegate that Gtk has added NSWindow nswin = GtkMacInterop.GetNSWindow(window); // The way how sizing of the NSToolbar is implemented seems to have changen in Mojave. // Previously we had to track the window size and update our MinSize to prevent NSToolbar // from removing the item automatically. Now the same logic has the opposite effect on Mojave. // Additionally AwesomeBar has no active window, after being removed from the NSToolbar, making // the required size calculation much more complex. However letting NSToolbar do the magic // internally works on Mojave correctly. if (MacSystemInformation.OsVersion < MacSystemInformation.Mojave) { Action <NSNotification> resizeAction = notif => Runtime.RunInMainThread(() => { var win = awesomeBar.Window; if (win == null) { return; } var item = widget.Items [0]; var abFrameInWindow = awesomeBar.ConvertRectToView(awesomeBar.Frame, null); var awesomebarHeight = AwesomeBar.ToolbarWidgetHeight; var size = new CGSize(win.Frame.Width - abFrameInWindow.X - 4, awesomebarHeight); if (item.MinSize != size) { item.MinSize = size; } }); NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidResizeNotification, resizeAction, nswin); NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidEndLiveResizeNotification, resizeAction, nswin); } NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.WillEnterFullScreenNotification, (note) => IsFullscreen = true, nswin); NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.WillExitFullScreenNotification, (note) => IsFullscreen = false, nswin); }
public static void ShowWebivew(WebAuthenticator webview) { var app = NSApplication.SharedApplication; var rect = new CoreGraphics.CGRect(0,0,400,600); webview.Frame = rect; window = new NSWindow(rect, NSWindowStyle.Closable | NSWindowStyle.Titled, NSBackingStore.Buffered, false); window.ContentView = webview; window.IsVisible = false; window.Title = webview.Authenticator.Title; app.BeginSheet(window,app.MainWindow); webview.BeginLoadingInitialUrl(); }
/// <summary> /// Initializes an instance for a provided caller window. /// </summary> /// <param name="callerWindow">Caller window. OPTIONAL.</param> public CoreUIParent(NSWindow callerWindow) { CallerWindow = callerWindow; }
public void CreatePanelDidEnd (NSWindow w, int returnCode, IntPtr context) { }
// Shared initialization code void Initialize() { window = new NSWindow(new RectangleF(0, 0, 470, 250), NSWindowStyle.Titled, NSBackingStore.Buffered, false); window.HasShadow = true; NSView content = window.ContentView; window.WindowController = this; NSTextField signInLabel = new NSTextField(new RectangleF(17, 190, 109, 17)); signInLabel.StringValue = "Sign In:"; signInLabel.Editable = false; signInLabel.Bordered = false; signInLabel.BackgroundColor = NSColor.Control; content.AddSubview(signInLabel); // Create our select button selectButton = new NSButton(new RectangleF(358, 12, 96, 32)); selectButton.Title = "Select"; selectButton.SetButtonType(NSButtonType.MomentaryPushIn); selectButton.BezelStyle = NSBezelStyle.Rounded; selectButton.Activated += delegate { profileSelected(); }; selectButton.Enabled = false; content.AddSubview(selectButton); // Setup our table view NSScrollView tableContainer = new NSScrollView(new RectangleF(20, 60, 428, 123)); tableContainer.BorderType = NSBorderType.BezelBorder; tableContainer.AutohidesScrollers = true; tableContainer.HasVerticalScroller = true; tableView = new NSTableView(new RectangleF(0, 0, 420, 123)); tableView.UsesAlternatingRowBackgroundColors = true; NSTableColumn colGamerTag = new NSTableColumn(new NSString("Gamer")); tableView.AddColumn(colGamerTag); colGamerTag.Width = 420; colGamerTag.HeaderCell.Title = "Gamer Profile"; tableContainer.DocumentView = tableView; content.AddSubview(tableContainer); // Create our add button NSButton addButton = new NSButton(new RectangleF(20, 27, 25, 25)); //Console.WriteLine(NSImage.AddTemplate); addButton.Image = NSImage.ImageNamed("NSAddTemplate"); addButton.SetButtonType(NSButtonType.MomentaryPushIn); addButton.BezelStyle = NSBezelStyle.SmallSquare; addButton.Activated += delegate { addLocalPlayer(); }; content.AddSubview(addButton); // Create our remove button NSButton removeButton = new NSButton(new RectangleF(44, 27, 25, 25)); removeButton.Image = NSImage.ImageNamed("NSRemoveTemplate"); removeButton.SetButtonType(NSButtonType.MomentaryPushIn); removeButton.BezelStyle = NSBezelStyle.SmallSquare; removeButton.Activated += delegate { removeLocalPlayer(); }; content.AddSubview(removeButton); gamerList = MonoGameGamerServicesHelper.DeserializeProfiles(); // for (int x= 1; x< 25; x++) { // gamerList.Add("Player " + x); // } tableView.DataSource = new GamersDataSource(this); tableView.Delegate = new GamersTableDelegate(this); }
public void goWindow () { isInFullScreenMode = false; // use OrderOut here instead of Close or nasty things will happen with Garbage Collection and a double free fullScreenWindow.OrderOut (this); fullScreenView.DeAllocate (); fullScreenWindow.Dispose (); fullScreenWindow = null; // Switch to the non-fullscreen context openGLView.OpenGLContext.MakeCurrentContext (); if (!isAnimating) { // Mark the view as needing drawing // The animation has advanced while we were in full-screen mode, so its current contents are stale openGLView.NeedsDisplay = true; } else { // continue playing the animation openGLView.StartAnimation (); } }
public override SizeF WillResize(NSWindow sender, SizeF to_frame_size) { WindowResized(to_frame_size); return(to_frame_size); }
public void ShowSheet(NSWindow inWindow) { NSApplication.SharedApplication.BeginSheet (Window, inWindow); }
public MainToolbar(Gtk.Window window) { gtkWindow = window; widget = new NSToolbar(MainToolbarId) { DisplayMode = NSToolbarDisplayMode.Icon, }; awesomeBar = new AwesomeBar(); awesomeBar.RunButton.Activated += (o, e) => { if (RunButtonClicked != null) { RunButtonClicked(o, e); } }; // Remove the focus from the Gtk system when Cocoa has focus // Fixes BXC #29601 awesomeBar.SearchBar.GainedFocus += (o, e) => IdeApp.Workbench.RootWindow.Focus = null; AttachToolbarEvents(awesomeBar.SearchBar); selectorView.ConfigurationChanged += (sender, e) => { if (ConfigurationChanged != null) { ConfigurationChanged(sender, e); } }; selectorView.RunConfigurationChanged += (sender, e) => { if (RunConfigurationChanged != null) { RunConfigurationChanged(sender, e); } }; selectorView.RuntimeChanged += (sender, ea) => { if (RuntimeChanged != null) { RuntimeChanged(sender, ea); } }; widget.WillInsertItem = (tool, id, send) => { switch (id) { case AwesomeBarId: return(new NSToolbarItem(AwesomeBarId) { View = awesomeBar, MinSize = new CGSize(1024, AwesomeBar.ToolbarWidgetHeight), MaxSize = new CGSize(1024, AwesomeBar.ToolbarWidgetHeight) }); default: throw new NotImplementedException(); } }; Action <NSNotification> resizeAction = notif => Runtime.RunInMainThread(() => { var win = awesomeBar.Window; if (win == null) { return; } var item = widget.Items[0]; var abFrameInWindow = awesomeBar.ConvertRectToView(awesomeBar.Frame, null); var awesomebarHeight = AwesomeBar.ToolbarWidgetHeight; var size = new CGSize(win.Frame.Width - abFrameInWindow.X - 4, awesomebarHeight); item.MinSize = size; item.MaxSize = size; }); // We can't use the events that Xamarin.Mac adds for delegate methods as they will overwrite // the delegate that Gtk has added NSWindow nswin = GtkMacInterop.GetNSWindow(window); NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidResizeNotification, resizeAction, nswin); NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidEndLiveResizeNotification, resizeAction, nswin); NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.WillEnterFullScreenNotification, (note) => IsFullscreen = true, nswin); NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.WillExitFullScreenNotification, (note) => IsFullscreen = false, nswin); }
public void Init(ITextEditor editor, NSTextView text, LiveRange range, AnnotationAlignment alignment) { m_editor = editor; m_text = text; m_range = range; m_view = this["view"].To<AnnotateView>(); m_alignment = alignment; m_parent = m_text.window(); NSNotificationCenter.defaultCenter().addObserver_selector_name_object( this, "parentWillClose:", Externs.NSWindowWillCloseNotification, m_parent); m_text.superview().setPostsBoundsChangedNotifications(true); NSNotificationCenter.defaultCenter().addObserver_selector_name_object( this, "parentBoundsChanged:", Externs.NSViewBoundsDidChangeNotification, m_text.superview()); m_range.Changed += this.DoRangeChanged; }
public void PlatformInitialize(IMvxApplicationDelegate applicationDelegate, NSWindow window) { PlatformInitialize(applicationDelegate); _window = window; }
public override Id InitConnectionType(RoyalConnection data, NSTabViewItem tabViewItem, NSWindow parentWindow) { Data = data; TabViewItem = tabViewItem; return(this); }
async Task SaveExportedData (NSWindow window, nint panelResult, NSUrl url) { if (panelResult != 1 || syncController?.SyncState != SyncState.Finished) return; string error = null; try { if (url == null || url.FilePathUrl == null) { error = url?.ToString () ?? "Invalid file URL"; return; } statusTextField.StringValue = "saving with sadness…"; saveButton.Enabled = false; actionButton.Enabled = false; indeterminateProgressIndicator.Hidden = false; await syncController.CreateExporter ().ExportAsync (url.FilePathUrl.Path); statusTextField.StringValue = "saved your tedious music curation work!"; actionButton.Enabled = true; indeterminateProgressIndicator.Hidden = true; savedExportedDataUrl = url; saveButton.Enabled = true; saveButton.Title = "Reveal in Finder…"; } catch (Exception e) { Console.Error.WriteLine (e); error = e.Message; } finally { if (error != null) new NSAlert { AlertStyle = NSAlertStyle.Critical, MessageText = "Unable to save exported data to file", InformativeText = error }.RunSheetModal (window, NSApplication.SharedApplication); } }
protected virtual MvxWindowController CreateWindowController(NSWindow window) { return(new MvxWindowController(window)); }
static void SetTheme (NSWindow window) { if (IdeApp.Preferences.UserInterfaceSkin == Skin.Light) window.Appearance = NSAppearance.GetAppearance (NSAppearance.NameAqua); else window.Appearance = NSAppearance.GetAppearance (NSAppearance.NameVibrantDark); if (IdeApp.Preferences.UserInterfaceSkin == Skin.Light) { window.StyleMask &= ~NSWindowStyle.TexturedBackground; return; } if (window is NSPanel || window.ContentView.Class.Name != "GdkQuartzView") window.BackgroundColor = MonoDevelop.Ide.Gui.Styles.BackgroundColor.ToNSColor (); else { object[] platforms = Mono.Addins.AddinManager.GetExtensionObjects ("/MonoDevelop/Core/PlatformService"); if (platforms.Length > 0) { var platformService = (MonoDevelop.Ide.Desktop.PlatformService)platforms [0]; var image = Xwt.Drawing.Image.FromResource (platformService.GetType().Assembly, "maintoolbarbg.png"); window.IsOpaque = false; window.BackgroundColor = NSColor.FromPatternImage (image.ToBitmap().ToNSImage()); } } window.StyleMask |= NSWindowStyle.TexturedBackground; }
protected ReactiveWindowController(NSWindow window) : base(window) { setupRxObj(); }