I created XIB for Splashscreen ( view : NsWindow , ViewContoller : NsWindowcontroller)
and using WillFinishLaunching
public override void WillFinishLaunching(NSNotification notification) { splashScreenController = new SplashScreenWindowController(); if (splashScreenController != null) { if (splashScreenController.Window != null) splashScreenController.Window.OrderFrontRegardless(); } Thread.Sleep(5000); } public override void DidFinishLaunching(NSNotification notification) { splashScreenController.Window.OrderOut(null); } public partial class SplashScreenWindowController : NSWindowController { #region Constructors public SplashScreenWindowController(IntPtr handle) : base(handle) { } // Call to load from the XIB/NIB file public SplashScreenWindowController() : base("SplashScreen") { } #endregion public override void WindowDidLoad() { base.WindowDidLoad(); Window.HasShadow = false; Window.IsOpaque = false; Window.BackgroundColor = NSColor.Clear; Window.Level = NSWindowLevel.Status; } public new SplashScreen Window { get { return (SplashScreen)base.Window; } } } }
I am always getting null reference exception , Window is coming null
Please let us know if it is correct way to implement to Splash screen or if I am missing something
I am still getting null reference exception on WindowDidLoad , Window object is coming null, Below is my WindowController class and Splash window class
public partial class SplashScreenWindowController : NSWindowController
{
#region Constructors
public SplashScreenWindowController(IntPtr handle) : base(handle) { } // Call to load from the XIB/NIB file public SplashScreenWindowController() : base("SplashScreen") { } #endregion public override void WindowDidLoad() { base.WindowDidLoad(); Window.HasShadow = false; Window.IsOpaque = false; Window.BackgroundColor = NSColor.Clear; Window.Level = NSWindowLevel.Status; } public new SplashScreen Window { get { return (SplashScreen)base.Window; } } }
//SplashWindow
public partial class SplashScreen : NSWindow
{
#region Constructors
public SplashScreen(IntPtr handle) : base(handle) { } #endregion }
Answers
Refer to the github sample , i convert it from swift to C#.
I am still getting null reference exception on WindowDidLoad , Window object is coming null, Below is my WindowController class and Splash window class
public partial class SplashScreenWindowController : NSWindowController
{
#region Constructors
//SplashWindow
public partial class SplashScreen : NSWindow
{
#region Constructors
Check my sample below.