예제 #1
0
        static void Main(string[] args)
        {
            NSApplication.Init();

            // set app version (globally) immadiately after start
            Platform.Version = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleVersion").ToString();

            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                Logging.Info(e.ExceptionObject.ToString());
                ExceptionWindowController.Show(e.ExceptionObject as Exception, false, isModal: true);
            };

//            Logging.SetLogFile("/tmp/ivpn.log", true);
//            Logging.Enable();
//            Logging.OmitDate = true;
//
//            Logging.Info("Application starting...");

#if !DEBUG
            if (!FullUpgradeIfRequired())
            {
                return;
            }
#else
            if (!PartialUpgrade())
            {
                return;
            }
#endif

            try
            {
                // Register MacOS-specified detector of PowerMode change
                // Do not use 'Microsoft.Win32.SystemEvents.PowerModeChanged' event directly in common code
                // Instead, use: 'Platform.PowerModeChanged'
                MacPowerChangeDetectorStatic.Initialize();
                MacPowerChangeDetectorStatic.PowerModeChanged += (object sender, Microsoft.Win32.PowerModeChangedEventArgs e) => { Platform.NotifyPowerModeChanged(sender, e); };
            }
            catch (Exception ex)
            {
                throw new Exception($"Error initialising MacPowerChangeDetector: {ex}");
            }

            if (NSBundle.MainBundle.BundlePath == null)
            {
                throw new Exception("Internal exception: NSBundle.MainBundle.BundlePath is null.");
            }

            Platform.InstallationDirectory = NSBundle.MainBundle.BundlePath;

            NSApplication.Main(args);
        }
예제 #2
0
        private static void InitializeAndShowWindow(ExceptionWindowController obj)
        {
            obj.Window.WillClose += (object sender, EventArgs ev) => {
                if (obj.__IsModalDialog)
                {
                    NSApplication.SharedApplication.StopModal();
                }
            };

            if (obj.__IsModalDialog)
            {
                NSApplication.SharedApplication.RunModalForWindow(obj.Window);
            }
        }