Example #1
0
        private void ShowAccountExpireDialog(SessionStatus sessionStatus)
        {
            SessionStatus acc = sessionStatus;

            if (acc == null)
            {
                return;
            }

            if (__SubscriptionExpireWindowCrl != null)
            {
                __SubscriptionExpireWindowCrl.Close();
            }

            __SubscriptionExpireWindowCrl = new SubscriptionWillExpireWindowController(acc, __LogInViewModel.UserName);

            NSWindow mainWindow = AppDelegate.GetMainWindowController()?.Window;

            if (mainWindow != null)
            {
                // Set window position centered to the main window
                CGRect  mainWindowRect = mainWindow.Frame;
                CGRect  infoWindowRect = __SubscriptionExpireWindowCrl.Window.Frame;
                CGPoint wndNewPos      = new CGPoint(mainWindowRect.X + mainWindowRect.Width / 2 - infoWindowRect.Width / 2,
                                                     mainWindowRect.Y + mainWindowRect.Height / 2 - infoWindowRect.Height / 2);
                __SubscriptionExpireWindowCrl.Window.SetFrameOrigin(wndNewPos);
            }

            __SubscriptionExpireWindowCrl.ShowWindow(this);
        }
        private void ShowAccountExpireDialog(AccountStatus sessionStatus)
        {
            AccountStatus acc = sessionStatus;

            if (acc == null)
            {
                return;
            }

            if (!NSThread.IsMain)
            {
                InvokeOnMainThread(() => ShowAccountExpireDialog(sessionStatus));
                return;
            }

            try
            {
                if (__SubscriptionExpireWindowCrl != null)
                {
                    __SubscriptionExpireWindowCrl.Close();
                }

                __SubscriptionExpireWindowCrl = new SubscriptionWillExpireWindowController(acc, __MainViewModel?.AppState?.Session?.AccountID);

                MainWindowController wndController = AppDelegate.GetMainWindowController();
                if (wndController != null && wndController.Window != null)
                {
                    NSWindow mainWindow = wndController.Window;

                    // Set window position centered to the main window
                    CGRect  mainWindowRect = mainWindow.Frame;
                    CGRect  infoWindowRect = __SubscriptionExpireWindowCrl.Window.Frame;
                    CGPoint wndNewPos      = new CGPoint(mainWindowRect.X + mainWindowRect.Width / 2 - infoWindowRect.Width / 2,
                                                         mainWindowRect.Y + mainWindowRect.Height / 2 - infoWindowRect.Height / 2);
                    __SubscriptionExpireWindowCrl.Window.SetFrameOrigin(wndNewPos);
                }

                __SubscriptionExpireWindowCrl.ShowWindow(this);
            }
            catch (Exception ex)
            {
                Logging.Info(string.Format("{0}", ex));
            }
        }