NSToolbarItem CreateStatusBarToolbarItem() { var bar = new StatusBar(); viewCache.Add(bar); var item = new NSToolbarItem(StatusBarId) { View = bar, // Place some temporary values in there. MinSize = new CGSize(360, 22), MaxSize = new CGSize(360, 22), }; NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidResizeNotification, notif => DispatchService.GuiDispatch(() => { // Skip updates with a null Window. Only crashes on Mavericks. // The View gets updated once again when the window resize finishes. if (bar.Window == null) { return; } double maxSize = Math.Round(bar.Window.Frame.Width * 0.30f); double minSize = Math.Round(bar.Window.Frame.Width * 0.25f); item.MinSize = new CGSize((nfloat)Math.Max(280, minSize), 22); item.MaxSize = new CGSize((nfloat)Math.Min(700, maxSize), 22); bar.RepositionStatusLayers(); })); return(item); }
NSToolbarItem CreateStatusBarToolbarItem() { var bar = new StatusBar(); var item = new NSToolbarItem(StatusBarId) { View = bar, // Place some temporary values in there. MinSize = new CGSize(360, 22), MaxSize = new CGSize(360, 22), }; NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidResizeNotification, notif => { double size = Math.Round(bar.Window.Frame.Width * 0.25f); item.MinSize = new CGSize((nfloat)Math.Max(300, size), 22); item.MaxSize = new CGSize((nfloat)Math.Min(600, size), 22); bar.RepositionStatusLayers(); }); return(item); }
NSToolbarItem CreateStatusBarToolbarItem() { var bar = new StatusBar(); viewCache.Add(bar); var item = new NSToolbarItem(StatusBarId) { View = bar, // Place some temporary values in there. MinSize = new CGSize(360, 22), MaxSize = new CGSize(360, 22), }; Action <NSNotification> resizeAction = notif => DispatchService.GuiDispatch(() => { // Skip updates with a null Window. Only crashes on Mavericks. // The View gets updated once again when the window resize finishes. if (bar.Window == null) { return; } // We're getting notified about all windows in the application (for example, NSPopovers) that change size when really we only care about // the window the bar is in. if (notif.Object != bar.Window) { return; } double maxSize = Math.Round(bar.Window.Frame.Width * 0.30f); double minSize = Math.Round(bar.Window.Frame.Width * 0.25f); item.MinSize = new CGSize((nfloat)Math.Max(220, minSize), 22); item.MaxSize = new CGSize((nfloat)Math.Min(700, maxSize), 22); bar.RepositionStatusLayers(); }); NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidResizeNotification, resizeAction); NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidEndLiveResizeNotification, resizeAction); return(item); }
NSToolbarItem CreateStatusBarToolbarItem () { var bar = new StatusBar (); viewCache.Add (bar); var item = new NSToolbarItem (StatusBarId) { View = bar, // Place some temporary values in there. MinSize = new CGSize (360, 22), MaxSize = new CGSize (360, 22), }; Action<NSNotification> resizeAction = notif => DispatchService.GuiDispatch (() => { // Skip updates with a null Window. Only crashes on Mavericks. // The View gets updated once again when the window resize finishes. if (bar.Window == null) return; // We're getting notified about all windows in the application (for example, NSPopovers) that change size when really we only care about // the window the bar is in. if (notif.Object != bar.Window) return; double maxSize = Math.Round (bar.Window.Frame.Width * 0.30f); double minSize = Math.Round (bar.Window.Frame.Width * 0.25f); item.MinSize = new CGSize ((nfloat)Math.Max (220, minSize), 22); item.MaxSize = new CGSize ((nfloat)Math.Min (700, maxSize), 22); bar.RepositionStatusLayers (); }); NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidResizeNotification, resizeAction); NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidEndLiveResizeNotification, resizeAction); return item; }
NSToolbarItem CreateStatusBarToolbarItem () { var bar = new StatusBar (); viewCache.Add (bar); var item = new NSToolbarItem (StatusBarId) { View = bar, // Place some temporary values in there. MinSize = new CGSize (360, 22), MaxSize = new CGSize (360, 22), }; NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidResizeNotification, notif => DispatchService.GuiDispatch (() => { // Skip updates with a null Window. Only crashes on Mavericks. // The View gets updated once again when the window resize finishes. if (bar.Window == null) return; double maxSize = Math.Round (bar.Window.Frame.Width * 0.30f); double minSize = Math.Round (bar.Window.Frame.Width * 0.25f); item.MinSize = new CGSize ((nfloat)Math.Max (280, minSize), 22); item.MaxSize = new CGSize ((nfloat)Math.Min (700, maxSize), 22); bar.RepositionStatusLayers (); })); return item; }