public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // stylyze FreTrial button
            GuiNotificationButtonBottom.Hidden = true;
            CustomButtonStyles.ApplyStyleInfoButton(GuiNotificationButtonBottom, "", NSImage.ImageNamed("iconStatusModerate"));

            View.WantsLayer = true;
            View.LayerContentsRedrawPolicy = NSViewLayerContentsRedrawPolicy.OnSetNeedsDisplay;

            View.Layer.AddSublayer(__animationLayer);

            View.SetConnectButtonRect(GuiConnectButtonImage);
            View.SetPauseButton(GuiPauseButton);
            View.SetPauseLeftTimeTextField(GuiPauseLeftTimeText);

            View.OnButtonPressed            += View_OnButtonPressed;
            View.OnButtonPausePressed       += View_OnButtonPausePressed;
            View.OnPauseTimeLeftTextPressed += View_OnPauseTimeLeftTextPressed;

            UpdateWiFiInfoGuiData();
            UpdateGuiData();
            InitializeInformationPopover();

            __MainViewModel.AppState.OnAccountStatusChanged += UpdateSessionStatusInfo;
            UpdateSessionStatusInfo(__MainViewModel.AppState.AccountStatus);

            GuiWiFiButton.Activated += GuiWiFiButton_Activated;

            View.OnApperianceChanged += () =>
            {
                UpdateGuiData();
            };
        }
        private void UpdateUI()
        {
            if (__SessionLimitViewModel == null)
            {
                return;
            }

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

            CustomButtonStyles.ApplyStyleNavigationButton(GuiButtonBack, LocalizedStrings.Instance.LocalizedString("Button_Back"));
            if (__SessionLimitViewModel.IsCanUpgrade)
            {
                UIButtonUpgrade.Hidden  = false;
                UIButtonLogOutAll.Frame = __InitialLogoutAllBtnFrame;

                CustomButtonStyles.ApplyStyleMainButton(UIButtonUpgrade, LocalizedStrings.Instance.LocalizedString("Button_SwitchToProPlan", "Switch to IVPN Pro plan"));
                CustomButtonStyles.ApplyStyleSecondaryButton(UIButtonLogOutAll, LocalizedStrings.Instance.LocalizedString("Button_LogOutOtherDevices", "Log out from all other devices"));
            }
            else
            {
                UIButtonLogOutAll.Frame = UIButtonUpgrade.Frame;
                UIButtonUpgrade.Hidden  = true;
                CustomButtonStyles.ApplyStyleMainButton(UIButtonLogOutAll, LocalizedStrings.Instance.LocalizedString("Button_LogOutOtherDevices", "Log out from all other devices"));
            }

            UIButtonLogOutAll.Hidden = !__SessionLimitViewModel.IsCanLogOutAllSessions;
        }
Пример #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            if (View != null && View.Frame.IsEmpty == false)
            {
                InitialHeight = View.Frame.Height;
            }

            CustomButtonStyles.ApplyStyleMainButton(GuiButtonLogIn, LocalizedStrings.Instance.LocalizedString("Button_LogIn"));

            CustomButtonStyles.ApplyStyleNavigationButtonV2(GuiButtonStartFreeTrial, LocalizedStrings.Instance.LocalizedString("Button_StartFreeTrial"));

            GuiTextViewUser.PlaceholderString = LocalizedStrings.Instance.LocalizedString("Placeholder_Username");
            GuiTextViewUser.Cell.Title        = __LogInViewModel.UserName ?? "";
            GuiTextViewUser.LineBreakMode     = NSLineBreakMode.TruncatingHead;

            // ACCOUNT ID DESCRIPTION ...
            // Initialize Account ID description text with link to a Client Area
            NSData             descriptionData = NSData.FromString("Your account ID can be found in the <a style=\"text-decoration:none\" href=\"https://www.ivpn.net/clientarea/login\">Client Area</a> of the website");
            NSDictionary       resultDocumentAttributes;
            NSAttributedString nSAttributed = NSAttributedString.CreateWithHTML(descriptionData, out resultDocumentAttributes);

            NSStringAttributes descTextAttributes = new NSStringAttributes();

            descTextAttributes.Font            = GuiTextAccountIdDescription.Font;      // keep using preconfigured TextField font
            descTextAttributes.ForegroundColor = GuiTextAccountIdDescription.TextColor; // keep using preconfigured TextField color
            descTextAttributes.ParagraphStyle  = new NSMutableParagraphStyle {
                Alignment = NSTextAlignment.Center
            };

            NSMutableAttributedString descriptionString = new NSMutableAttributedString(nSAttributed);

            descriptionString.AddAttributes(descTextAttributes, new NSRange(0, nSAttributed.Length));

            GuiTextAccountIdDescription.AllowsEditingTextAttributes = true;        // it is important
            GuiTextAccountIdDescription.Selectable            = true;
            GuiTextAccountIdDescription.AttributedStringValue = descriptionString; // nSAttributed;
            // ... ACCOUNT ID DESCRIPTION

            GuiButtonLogIn.Hidden = false;

            View.OnApperianceChanged += () =>
            {
                CustomButtonStyles.ApplyStyleNavigationButtonV2(GuiButtonStartFreeTrial, LocalizedStrings.Instance.LocalizedString("Button_StartFreeTrial"));
            };
        }
Пример #4
0
        private void UpdateIntroductionApperiance()
        {
            if (Colors.IsDarkMode)
            {
                GuiIntroLogoImage.Image = NSImage.ImageNamed("iconLogoDark");
            }
            else
            {
                GuiIntroLogoImage.Image = NSImage.ImageNamed("iconLogo");
            }

            CustomButtonStyles.ApplyStyleMainButton(GuiIntroBtnWelcomeShowMe, LocalizedStrings.Instance.LocalizedString("Button_Introduction_ShowMe"));
            GuiIntroductionPanelWelcome.BackgroundColor = Colors.IntroductionBackground;
            GuiIntroLabelWelcome.StringValue            = LocalizedStrings.Instance.LocalizedString("Label_IntroWelcome");
            GuiIntroLabelWelcome.TextColor = Colors.IntroductionTextColor;

            CustomButtonStyles.ApplyStyleMainButton(GuiIntroBtnConnect, LocalizedStrings.Instance.LocalizedString("Button_Introduction_Continue"));
            GuiIntroductionPanelConnectBtn.BackgroundColor = Colors.IntroductionBackground;
            GuiIntroLabelConnectTitle.StringValue          = LocalizedStrings.Instance.LocalizedString("Label_IntroConnectTitle");
            GuiIntroLabelConnectText.StringValue           = LocalizedStrings.Instance.LocalizedString("Label_IntroConnectText");
            GuiIntroLabelConnectTitle.TextColor            = Colors.IntroductionTextColor;
            GuiIntroLabelConnectText.TextColor             = Colors.IntroductionTextColor;

            CustomButtonStyles.ApplyStyleMainButton(GuiIntroBtnFirewallContinue, LocalizedStrings.Instance.LocalizedString("Button_Introduction_Continue"));
            GuiIntroBtnFirewallContinue.TitleFont = UIUtils.GetSystemFontOfSize(16f, NSFontWeight.Medium);

            GuiIntroductionPanelFirewall.BackgroundColor = Colors.IntroductionBackground;
            GuiIntroLabelFirewallTitle.StringValue       = LocalizedStrings.Instance.LocalizedString("Label_IntroFirewallTitle");
            GuiIntroLabelFirewallText.StringValue        = LocalizedStrings.Instance.LocalizedString("Label_IntroFirewallText");
            GuiIntroLabelFirewallTitle.TextColor         = Colors.IntroductionTextColor;
            GuiIntroLabelFirewallText.TextColor          = Colors.IntroductionTextColor;

            CustomButtonStyles.ApplyStyleMainButton(GuiIntroBtnServersClose, LocalizedStrings.Instance.LocalizedString("Button_Introduction_Close"));

            GuiIntroductionPanelServers.BackgroundColor = Colors.IntroductionBackground;
            GuiIntroLabelServersTitle.StringValue       = LocalizedStrings.Instance.LocalizedString("Label_IntroServersTitle");
            GuiIntroLabelServersText.StringValue        = LocalizedStrings.Instance.LocalizedString("Label_IntroServersText");
            GuiIntroLabelServersTitle.TextColor         = Colors.IntroductionTextColor;
            GuiIntroLabelServersText.TextColor          = Colors.IntroductionTextColor;
        }
Пример #5
0
        public void SetViewModel(ViewModelLogIn viewModel) 

        {
            
 __LogInViewModel = viewModel;

            __LogInViewModel.OnAccountCredentailsError += __LogInViewModel_OnAccountCredentailsError;

            __LogInViewModel.OnWillExecute += (sender) =>
            {
                EnableView.Disable(View, ignoreControls: new List <NSControl> {
                    GuiButtonLogIn
                });
                CustomButtonStyles.ApplyStyleMainButton(GuiButtonLogIn, LocalizedStrings.Instance.LocalizedString("Button_Cancel"));
                GuiProgressIndicator.Hidden = false;
                GuiProgressIndicator.StartAnimation(this);
            };

            __LogInViewModel.OnDidExecute += (sender) =>
            {
                GuiButtonLogIn.Hidden = false;

                EnableView.Enable(View, ignoreControls: new List <NSControl> {
                    GuiButtonLogIn
                });
                CustomButtonStyles.ApplyStyleMainButton(GuiButtonLogIn, LocalizedStrings.Instance.LocalizedString("Button_LogIn"));
                GuiProgressIndicator.Hidden = true;
                GuiProgressIndicator.StopAnimation(this);
            };

            __LogInViewModel.OnError += __LogInViewModel_OnError;

            __LogInViewModel.OnAccountSuspended += (AccountStatus session) =>
            {
                ShowAccountExpireDialog(session);
            };

            __LogInViewModel.PropertyChanged += (sender, e) =>
            {
                __LogInViewModel_PropertyChanged(sender, e);
            };
        }
        private void InitializePauseIntervalDialog()
        {
            if (__IsPauseIntervalDialogInitialized)
            {
                return;
            }
            __IsPauseIntervalDialogInitialized = true;

            GuiPauseDlgHoursTextBlock.Formatter           = new NumberFormatterForTextField(4, 99);
            GuiPauseDlgMinutesTextBlock.Formatter         = new NumberFormatterForTextField(4, 59);
            GuiPauseDlgHoursTextBlock.PlaceholderString   = "hours";
            GuiPauseDlgMinutesTextBlock.PlaceholderString = "minutes";
            GuiPauseDlgHoursTextBlock.StringValue         = "1";
            GuiPauseDlgMinutesTextBlock.StringValue       = "45";
            GuiPauseDlgHoursTextBlock.Alignment           = NSTextAlignment.Right;
            GuiPauseDlgMinutesTextBlock.Alignment         = NSTextAlignment.Left;

            CustomButtonStyles.ApplyStyleMainButtonV2(GuiPauseDlgOkBtn, "Ok");
            CustomButtonStyles.ApplyStyleSecondaryButton(GuiPauseDlgCancelBtn, "Cancel");

            GuiSetPauseIntervalWindow.WillClose += (object sender, EventArgs e) => { NSApplication.SharedApplication.EndSheet(GuiSetPauseIntervalWindow); };
        }
Пример #7
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            // Disable title-bar (but keep close/minimize/expand buttons on content-view)
            Window.TitleVisibility            = NSWindowTitleVisibility.Hidden;
            Window.TitlebarAppearsTransparent = true;
            Window.StyleMask |= NSWindowStyle.FullSizeContentView;

            // set window background color
            //if (!Colors.IsDarkMode)
            //    Window.BackgroundColor = NSColor.FromRgba (255, 255, 255, 0.95f);

            //Stylyze buttons
            CustomButtonStyles.ApplyStyleGreyButtonV2(GuiBtnCopy, LocalizedStrings.Instance.LocalizedString("Button_PrivateEmail_Copy"));
            CustomButtonStyles.ApplyStyleGreyButtonV2(GuiBtnDelete, LocalizedStrings.Instance.LocalizedString("Button_PrivateEmail_Discard"));
            CustomButtonStyles.ApplyStyleMainButton(GuiBtnOk, LocalizedStrings.Instance.LocalizedString("Button_OK"));

            // set padding for Notes control
            GuiNotesField.TextContainerInset = new CoreGraphics.CGSize(5, 5);

            __Model.GenerateNewEmail();
        }
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            // Disable title-bar (but keep close/minimize/expand buttons on content-view)
            Window.TitleVisibility            = NSWindowTitleVisibility.Hidden;
            Window.TitlebarAppearsTransparent = true;
            Window.StyleMask |= NSWindowStyle.FullSizeContentView;

            // set window background color
            //if (!Colors.IsDarkMode)
            //    Window.BackgroundColor = NSColor.FromRgba (255, 255, 255, 0.95f);

            // Stylyze buttons
            CustomButtonStyles.ApplyStyleGreyButtonV2(GuiBtnEdit, LocalizedStrings.Instance.LocalizedString("Button_PrivateEmail_Notes"));
            CustomButtonStyles.ApplyStyleGreyButtonV2(GuiBtnCopy, LocalizedStrings.Instance.LocalizedString("Button_PrivateEmail_Copy"));
            CustomButtonStyles.ApplyStyleGreyButtonV2(GuiBtnAdd, LocalizedStrings.Instance.LocalizedString("Button_PrivateEmail_Create"));
            CustomButtonStyles.ApplyStyleGreyButtonV2(GuiBtnDelete, LocalizedStrings.Instance.LocalizedString("Button_PrivateEmail_Delete"));

            GuiProgressSpiner.StopAnimation(this);
            GuiProgressSpiner.Hidden = true;
            GuiBtnRefresh.Hidden     = false;

            // Model event handlers
            __Model.OnError += (errorText, errorDescription) =>
            {
                if (Window.IsVisible)
                {
                    if (string.IsNullOrEmpty(errorDescription))
                    {
                        IVPNAlert.Show(errorText);
                    }
                    else
                    {
                        IVPNAlert.Show(errorText, errorDescription);
                    }
                }
            };

            __Model.OnWillExecute += (sender) =>
            {
                InvokeOnMainThread(() => {
                    __IsUpdateInProgress = true;
                    SetEnableButtons();

                    GuiInfoLabel.StringValue = LocalizedStrings.Instance.LocalizedString("Label_PrivateEmail_UdpatingProgress");
                    GuiProgressSpiner.Hidden = false;
                    GuiBtnRefresh.Hidden     = true;
                    GuiProgressSpiner.StartAnimation(this);

                    EnableView.Disable(this.GuiTableScrollView);
                });
            };

            __Model.OnDidExecute += (sender) =>
            {
                InvokeOnMainThread(() => {
                    __IsUpdateInProgress = false;
                    SetEnableButtons();

                    GuiProgressSpiner.Hidden = true;
                    GuiBtnRefresh.Hidden     = false;
                    GuiInfoLabel.StringValue = LocalizedStrings.Instance.LocalizedString("Label_PrivateEmail_Title");
                    EnableView.Enable(this.GuiTableScrollView);
                });
            };

            __Model.PropertyChanged    += __Model_PropertyChanged;
            GuiTableEmails.DoubleClick += (sender, e) => OnEdit(null);

            UpdateGui();
        }
        private void UpdateSessionStatusInfo(AccountStatus sessionStatus)
        {
            InvokeOnMainThread(() =>
            {
                try
                {
                    GuiNotificationButtonBottom.Hidden = true;
                    if (sessionStatus == null)
                    {
                        return;
                    }

                    if (!sessionStatus.IsActive)
                    {
                        string part1 = LocalizedStrings.Instance.LocalizedString("Label_SubscriptionExpired");
                        if (sessionStatus.IsOnFreeTrial)
                        {
                            part1 = LocalizedStrings.Instance.LocalizedString("Label_FreeTrialExpired");
                        }
                        string part2 = LocalizedStrings.Instance.LocalizedString("Label_AccountExpiredUpgradeNow");

                        string title = part1 + " " + part2;
                        CustomButtonStyles.ApplyStyleInfoButton(GuiNotificationButtonBottom, title, NSImage.ImageNamed("iconStatusBad"));

                        NSMutableAttributedString attrTitle = new NSMutableAttributedString(title);

                        NSStringAttributes stringAttributes0 = new NSStringAttributes();
                        stringAttributes0.Font            = GuiNotificationButtonBottom.TitleFont;
                        stringAttributes0.ForegroundColor = GuiNotificationButtonBottom.TitleForegroundColor;
                        stringAttributes0.ParagraphStyle  = new NSMutableParagraphStyle {
                            Alignment = NSTextAlignment.Center
                        };

                        NSStringAttributes stringAttributes1 = new NSStringAttributes();
                        stringAttributes1.ForegroundColor    = NSColor.FromRgb(59, 159, 230);

                        attrTitle.AddAttributes(stringAttributes0, new NSRange(0, title.Length));
                        attrTitle.AddAttributes(stringAttributes1, new NSRange(title.Length - part2.Length, part2.Length));

                        GuiNotificationButtonBottom.TitleTextAttributedString = attrTitle;

                        GuiNotificationButtonBottom.Hidden = false;
                    }
                    else
                    {
                        if (sessionStatus.WillAutoRebill)
                        {
                            return;
                        }

                        if ((sessionStatus.ActiveUtil - DateTime.Now).TotalMilliseconds < TimeSpan.FromDays(4).TotalMilliseconds)
                        {
                            int daysLeft = (int)(sessionStatus.ActiveUtil - DateTime.Now).TotalDays;
                            if (daysLeft < 0)
                            {
                                daysLeft = 0;
                            }

                            string notificationString;

                            if (daysLeft == 0)
                            {
                                notificationString = LocalizedStrings.Instance.LocalizedString("Label_AccountDaysLeft_LastDay");
                                if (sessionStatus.IsOnFreeTrial)
                                {
                                    notificationString = LocalizedStrings.Instance.LocalizedString("Label_FreeTrialDaysLeft_LastDay");
                                }
                            }
                            else if (daysLeft == 1)
                            {
                                notificationString = LocalizedStrings.Instance.LocalizedString("Label_AccountDaysLeft_OneDay");
                                if (sessionStatus.IsOnFreeTrial)
                                {
                                    notificationString = LocalizedStrings.Instance.LocalizedString("Label_FreeTrialDaysLeft_OneDay");
                                }
                            }
                            else
                            {
                                notificationString = LocalizedStrings.Instance.LocalizedString("Label_AccountDaysLeft_PARAMETRIZED");
                                if (sessionStatus.IsOnFreeTrial)
                                {
                                    notificationString = LocalizedStrings.Instance.LocalizedString("Label_FreeTrialDaysLeft_PARAMETRIZED");
                                }

                                notificationString = string.Format(notificationString, daysLeft);
                            }
                            CustomButtonStyles.ApplyStyleInfoButton(GuiNotificationButtonBottom, notificationString, NSImage.ImageNamed("iconStatusModerate"));

                            GuiNotificationButtonBottom.Hidden = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logging.Info(string.Format("{0}", ex));
                    GuiNotificationButtonBottom.Hidden = true;
                }
            });
        }