コード例 #1
0
        private void OnMouseUp(NSEvent theEvent)
        {
            if (!__IsMouseDownPressed)
            {
                return;
            }

            ReleaseMouseDownStatus();

            MainWindowController mainWndController = AppDelegate.GetMainWindowController();

            if (mainWndController == null)
            {
                return;
            }

            // Not permitted to do any action during view-change animation in progress
            if (mainWndController.IsAnimationInProgress)
            {
                return;
            }

            if (GuiEntryServerView.Frame.Contains(theEvent.LocationInWindow.X, theEvent.LocationInWindow.Y))
            {
                OnEntryServerClick(this, null);
            }

            if (GuiExitServerView.Frame.Contains(theEvent.LocationInWindow.X, theEvent.LocationInWindow.Y))
            {
                OnExitServerClick(this, null);
            }
        }
コード例 #2
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);
        }
コード例 #3
0
        private void ChangeHopStatus(bool isMultiHop)
        {
            MainWindowController mainWndController = AppDelegate.GetMainWindowController();

            if (mainWndController == null)
            {
                return;
            }

            // Not permitted to do any action during view-change animation in progress
            if (mainWndController.IsAnimationInProgress)
            {
                return;
            }

            // Not possible to change multihop when connected
            if (__MainViewModel.ConnectionState != Models.ServiceState.Disconnected)
            {
                ShowPopoverVPNisConnected();
                return;
            }

            // Cteate task to process the reaction
            // Ne need this to achichive responsive interface
            // (button should be redrawed as 'unpressed' immediately after it was released)
            System.Threading.Tasks.Task.Run(() =>
            {
                __MainViewModel.IsMultiHop = isMultiHop;
            });
        }
コード例 #4
0
        partial void OnGuiPauseDlgOkBtnPressed(Foundation.NSObject sender)
        {
            double seconds = 0;

            try
            {
                string sh      = string.IsNullOrEmpty(GuiPauseDlgHoursTextBlock.StringValue) ? "0" : GuiPauseDlgHoursTextBlock.StringValue;
                string sm      = string.IsNullOrEmpty(GuiPauseDlgMinutesTextBlock.StringValue) ? "0" : GuiPauseDlgMinutesTextBlock.StringValue;
                double hours   = double.Parse(sh);
                double minutes = double.Parse(sm);
                seconds = hours * 60 * 60 + minutes * 60;
            }
            catch
            {
                IVPNAlert.Show(AppDelegate.GetMainWindowController()?.Window, "Please, enter correct values");
                return;
            }

            GuiSetPauseIntervalWindow.Close();

            if (__MainViewModel.PauseStatus == MainViewModel.PauseStatusEnum.Paused)
            {
                __MainViewModel.SetPauseTime(seconds);
            }
            else
            {
                __MainViewModel.PauseCommand.Execute(seconds);
            }
        }
コード例 #5
0
        public void ShowPauseTimeDialog()
        {
            MainWindowController mainWndController = AppDelegate.GetMainWindowController();

            if (mainWndController == null || mainWndController.Window == null)
            {
                return;
            }

            InitializePauseIntervalDialog();
            mainWndController.MakeFront();
            NSApplication.SharedApplication.BeginSheet(GuiSetPauseIntervalWindow, mainWndController.Window);
        }
コード例 #6
0
        public void UpdateWindowSize()
        {
            if (!NSThread.IsMain)
            {
                InvokeOnMainThread(() => UpdateWindowSize());
                return;
            }

            MainWindowController mainWndController = AppDelegate.GetMainWindowController();

            if (mainWndController == null)
            {
                return;
            }

            // Not permitted to do any action during view-change animation in progress
            if (mainWndController.IsAnimationInProgress)
            {
                // Trying to update window size later
                System.Threading.Tasks.Task.Run(() =>
                {
                    System.Threading.Thread.Sleep(10);
                    UpdateWindowSize();
                });
                return;
            }

            nfloat height = GuiButtonsPanel.Frame.Height
                            + __ConnectButtonViewController.View.Frame.Height
                            + __ServerSelectionController.Height
                            + 32;

            if (__Window.Frame.Height == height)
            {
                return;
            }

            __Window.SetFrame(
                UIUtils.UpdateHeight(
                    __Window.Frame,
                    height
                    ),
                true, true);
        }
コード例 #7
0
        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));
            }
        }