Пример #1
0
        public bool Login(string userName, string pwd, string domainAddress)
        {
            if (CurrentLoginStatus != LoginStatus.NotLogin)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(pwd) || string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(domainAddress))
            {
                return(false);
            }

            EVSdkManager.Instance.EnableSecure(EnableSecure);
            _serverDomainAddress = domainAddress;
            LoginPassword        = pwd;
            CurrentLoginStatus   = LoginStatus.LoggingIn;

            Task.Run(() => {
                // When click button login in login dialog, the LoginWithLocation may block the UI thread and ProgressDialogLogin can not be displayed.
                // So exec LoginWithLocation in another thread.
                EVSdkManager.Instance.LoginWithLocation(domainAddress, ServerPort, userName, pwd);
            });

            Application.Current.Dispatcher.InvokeAsync(() =>
            {
                log.Info("Show ProgressDialogLogin");
                DisplayUtil.SetWindowCenterAndOwner(ProgressDialogLogin.Instance, (IMasterDisplayWindow)LoginWindow);
                ProgressDialogLogin.Instance.ShowDialog();
            });

            return(true);
        }
        public void ShowPromptTip(string prompt, string extraInfo)
        {
            IMasterDisplayWindow masterWindow = GetCurrentMainDisplayWindow();

            if (null == masterWindow)
            {
                log.Info("Can not show error message for master window is null");
                return;
            }

            CloseMessageBoxTip();
            _messageBoxTip       = new MessageBoxTip();
            _messageTipExtraInfo = extraInfo;
            Window tipOwner = null;

            if (
                null != (masterWindow as VideoPeopleWindow) &&
                LayoutBackgroundWindow.Instance.IsLoaded &&
                LayoutBackgroundWindow.Instance.LayoutOperationbarWindow.IsLoaded
                )
            {
                tipOwner = LayoutBackgroundWindow.Instance.LayoutOperationbarWindow;
            }
            log.InfoFormat("ShowPromptTip(MessageBoxTip), hash: {0}, tipOwner is null:{1}, ", _messageBoxTip.GetHashCode(), null == tipOwner);
            DisplayUtil.SetWindowCenterAndOwner(_messageBoxTip, masterWindow, tipOwner);
            _messageBoxTip.SetTitleAndMsg(LanguageUtil.Instance.GetValueByKey("PROMPT"), prompt, LanguageUtil.Instance.GetValueByKey("CONFIRM"));
            _messageBoxTip.ShowDialog();
            _messageBoxTip       = null;
            _messageTipExtraInfo = "";
        }
 public void RefreshSoftwareUpdateWindow()
 {
     if (
         Visibility.Visible == SoftwareUpdateWindow.Instance.Visibility &&
         Visibility.Visible == Application.Current.MainWindow.Visibility
         )
     {
         MainWindow mainWindow = Application.Current.MainWindow as MainWindow;
         DisplayUtil.SetWindowCenterAndOwner(SoftwareUpdateWindow.Instance, mainWindow);
     }
 }
Пример #4
0
        public bool Login(string userName, string pwd, string domainAddress, bool isPasswdEncrypted = false)
        {
            log.InfoFormat("Login, domainAddress: {0}, username: {1}, password: {2}: isPasswordEncrypted: {3}", domainAddress, userName, pwd, isPasswdEncrypted);
            if (CurrentLoginStatus != LoginStatus.NotLogin)
            {
                log.InfoFormat("Can not login for login status is: {0}", CurrentLoginStatus);
                return(false);
            }

            if (string.IsNullOrEmpty(pwd) || string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(domainAddress))
            {
                log.Info("Can not login for login status is not invalid login parameters");
                return(false);
            }

            IsUrlLoginMode = isPasswdEncrypted;

            EVSdkManager.Instance.EnableSecure(EnableSecure);
            _serverDomainAddress = domainAddress;
            LoginPassword        = pwd;
            CurrentLoginStatus   = LoginStatus.LoggingIn;

            Task.Run(() => {
                // When click button login in login dialog, the LoginWithLocation may block the UI thread and ProgressDialogLogin can not be displayed.
                // So exec LoginWithLocation in another thread.
                if (isPasswdEncrypted)
                {
                    EVSdkManager.Instance.LoginWithLocationByEncPasswd(domainAddress, ServerPort, userName, pwd);
                }
                else
                {
                    EVSdkManager.Instance.LoginWithLocation(domainAddress, ServerPort, userName, pwd);
                }
            });

            Application.Current.Dispatcher.InvokeAsync(() =>
            {
                log.Info("Show ProgressDialogLogin");
                DisplayUtil.SetWindowCenterAndOwner(ProgressDialogLogin.Instance, (IMasterDisplayWindow)LoginWindow);
                ProgressDialogLogin.Instance.ShowDialog();
            });

            return(true);
        }
        public void CheckSoftwareUpdate(bool showPrompt)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(Properties.Settings.Default.SoftwareUpdateAddress)
            .Append("/")
            .Append(Properties.Settings.Default.SoftwareUpdateFlag)
            .Append("/")
            .Append(Properties.Settings.Default.SoftwareUpdateBundleId)
            .Append("/");
            if (!string.IsNullOrEmpty(Properties.Settings.Default.SoftwareUpdateAppInfoPrefix))
            {
                sb.Append(Properties.Settings.Default.SoftwareUpdateAppInfoPrefix).Append(".");
            }
            sb.Append(Properties.Settings.Default.SoftwareUpdateAppInfo);
            string swUpdateUrl = sb.ToString();

            log.InfoFormat("Software update url:{0}", swUpdateUrl);
            WaitingWindow waitingWindow = null;

            if (showPrompt)
            {
                Application.Current.Dispatcher.InvokeAsync(() => {
                    waitingWindow = new WaitingWindow(LanguageUtil.Instance.GetValueByKey("CHECKING_UPDATE"));
                    IMasterDisplayWindow masterWindow = ((MainWindow)Application.Current.MainWindow).GetCurrentMainDisplayWindow();
                    if (null != masterWindow)
                    {
                        waitingWindow.Owner = masterWindow.GetWindow();
                    }
                    waitingWindow.ShowDialog();
                });
            }
            Task.Run(() => {
                RestClient restClient = new RestClient();
                RestResponse response = null;
                try
                {
                    response = restClient.GetObject(swUpdateUrl);
                    if (response.StatusCode >= HttpStatusCode.BadRequest)
                    {
                        log.InfoFormat("Failed to get app info for software update, status code: {0}", response.StatusCode);
                        if (showPrompt)
                        {
                            Application.Current.Dispatcher.InvokeAsync(() => {
                                if (null != waitingWindow)
                                {
                                    waitingWindow.Close();
                                }
                                ShowNotFoundNewVersion();
                            });
                        }

                        return;
                    }

                    Rest.SoftwareUpdateRest.AppInfoRest appInfo = JsonConvert.DeserializeObject <Rest.SoftwareUpdateRest.AppInfoRest>(response.Content);
                    log.InfoFormat("Software update info, version:{0}, url:{1}", appInfo.VERSION, appInfo.DOWNLOAD_URL);
                    string currentVersion = Utils.GetEdition();
                    log.InfoFormat("Current app version: {0}", currentVersion);
                    string[] arrAppInfo        = appInfo.VERSION.Split('.');
                    string[] arrCurrentVersion = currentVersion.Split('.');
                    int len = arrAppInfo.Length > arrCurrentVersion.Length ? arrAppInfo.Length : arrCurrentVersion.Length;
                    bool newVersionFound = false;
                    for (int i = 0; i < len; ++i)
                    {
                        int newItem     = int.Parse(arrAppInfo[i]);
                        int currentItem = int.Parse(arrCurrentVersion[i]);
                        if (newItem > currentItem)
                        {
                            newVersionFound = true;
                            break;
                        }
                        else if (newItem < currentItem)
                        {
                            break;
                        }
                    }

                    if (!newVersionFound)
                    {
                        if (showPrompt)
                        {
                            Application.Current.Dispatcher.InvokeAsync(() => {
                                if (null != waitingWindow)
                                {
                                    waitingWindow.Close();
                                }
                                ShowNotFoundNewVersion();
                            });
                        }
                        return;
                    }

                    Application.Current.Dispatcher.InvokeAsync(() => {
                        if (null != waitingWindow)
                        {
                            waitingWindow.Close();
                        }
                        SoftwareUpdateWindow.Instance.Reset(appInfo.VERSION, appInfo.DOWNLOAD_URL);
                        IMasterDisplayWindow masterWindow = ((MainWindow)Application.Current.MainWindow).GetCurrentMainDisplayWindow();
                        DisplayUtil.SetWindowCenterAndOwner(SoftwareUpdateWindow.Instance, masterWindow);
                        if (null != masterWindow)
                        {
                            log.InfoFormat("Set soft update window owner to window:{0}", masterWindow.GetHashCode());
                        }

                        SoftwareUpdateWindow.Instance.Show();
                        if (null != SoftwareUpdateWindow.Instance.Owner)
                        {
                            // set the owner active or the owner will hide when cancel the software update window.
                            SoftwareUpdateWindow.Instance.Owner.Activate();
                        }
                    });
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("Failed to get app info for software update, exception:{0}", ex);
                    if (showPrompt)
                    {
                        Application.Current.Dispatcher.InvokeAsync(() => {
                            if (null != waitingWindow)
                            {
                                waitingWindow.Close();
                            }
                            ShowNotFoundNewVersion();
                        });
                    }
                }
            });
        }
        private void UpdateWindowVisibility()
        {
            LoginStatus loginStatus = LoginManager.Instance.CurrentLoginStatus;
            CallStatus  callStatus  = CallController.Instance.CurrentCallStatus;

            log.InfoFormat("Update window visibility, login status: {0}, call status: {1}", loginStatus, callStatus);
            bool isInCall = CallStatus.Dialing == callStatus ||
                            CallStatus.ConfIncoming == callStatus ||
                            CallStatus.P2pIncoming == callStatus ||
                            CallStatus.P2pOutgoing == callStatus ||
                            CallStatus.Connected == callStatus;
            bool isLoginWindowVisible =
                LoginStatus.NotLogin == loginStatus ||
                LoginStatus.LoggingIn == loginStatus ||
                LoginStatus.LoginFailed == loginStatus ||
                LoginStatus.AnonymousLoggingIn == loginStatus ||
                (LoginStatus.AnonymousLoggedIn == loginStatus && !isInCall);
            bool isMainWindowVisible        = (LoginStatus.LoggedIn == loginStatus) && !isInCall;
            bool isVideoPeopleWindowVisible = isInCall;

            Application.Current.Dispatcher.InvokeAsync(() => {
                if (null != LoginManager.Instance.LoginWindow)
                {
                    log.InfoFormat("Login window visible:{0}", isLoginWindowVisible);
                    Visibility visibility = isLoginWindowVisible ? Visibility.Visible : Visibility.Collapsed;
                    if (visibility != LoginManager.Instance.LoginWindow.Visibility)
                    {
                        LoginManager.Instance.LoginWindow.Visibility = visibility;
                        if (
                            Visibility.Visible == SoftwareUpdateWindow.Instance.Visibility &&
                            Visibility.Visible == LoginManager.Instance.LoginWindow.Visibility
                            )
                        {
                            LoginWindow loginWindow = LoginManager.Instance.LoginWindow as LoginWindow;
                            DisplayUtil.SetWindowCenterAndOwner(SoftwareUpdateWindow.Instance, loginWindow);
                            log.Info("Set soft update window owner to login window");
                        }
                    }
                    else
                    {
                        log.InfoFormat("Login window has been visibility: {0}", visibility);
                    }
                }

                if (null != Application.Current.MainWindow)
                {
                    log.InfoFormat("Main window visible:{0}", isMainWindowVisible);
                    Visibility visibility = isMainWindowVisible ? Visibility.Visible : Visibility.Collapsed;
                    if (visibility != Application.Current.MainWindow.Visibility)
                    {
                        Application.Current.MainWindow.Visibility = visibility;
                        if (
                            Visibility.Visible == SoftwareUpdateWindow.Instance.Visibility &&
                            Visibility.Visible == Application.Current.MainWindow.Visibility &&
                            Application.Current.MainWindow.IsLoaded
                            )
                        {
                            MainWindow mainWindow = Application.Current.MainWindow as MainWindow;
                            DisplayUtil.SetWindowCenterAndOwner(SoftwareUpdateWindow.Instance, mainWindow);
                            log.Info("Set soft update window owner to main window");
                        }
                    }
                    else
                    {
                        log.InfoFormat("Main window has been visibility: {0}", visibility);
                    }
                }

                if (null != VideoPeopleWindow.Instance)
                {
                    log.InfoFormat("Video people window visible:{0}", isVideoPeopleWindowVisible);
                    Visibility visibility = isVideoPeopleWindowVisible ? Visibility.Visible : Visibility.Collapsed;
                    if (visibility != VideoPeopleWindow.Instance.Visibility)
                    {
                        log.InfoFormat(
                            "Update VideoPeopleWindow visible, FirstShow:{0}, ActualWidth:{1}, ActualHeight:{2}, WindowState: {3}"
                            , VideoPeopleWindow.Instance.FirstShow
                            , VideoPeopleWindow.Instance.ActualWidth
                            , VideoPeopleWindow.Instance.ActualHeight
                            , VideoPeopleWindow.Instance.WindowState
                            );
                        Visibility currentStatus = VideoPeopleWindow.Instance.Visibility;
                        if (Visibility.Visible == currentStatus && !isVideoPeopleWindowVisible && WindowState.Minimized == VideoPeopleWindow.Instance.WindowState)
                        {
                            // in the case: sending content and the window is minimized, then disconnect it in remote. it should be resume to preseting state and then hidden.
                            VideoPeopleWindow.Instance.Set2PresettingState();
                        }
                        VideoPeopleWindow.Instance.Visibility = isVideoPeopleWindowVisible ? Visibility.Visible : Visibility.Collapsed;
                        if (isVideoPeopleWindowVisible &&
                            (VideoPeopleWindow.Instance.FirstShow || 0 == VideoPeopleWindow.Instance.ActualWidth || 0 == VideoPeopleWindow.Instance.ActualHeight)
                            )
                        {
                            log.Info("Reset initial size for VideoPeopleWindow");
                            // resume window size and center the screen on first show
                            VideoPeopleWindow.Instance.FirstShow = false;
                            VideoPeopleWindow.Instance.ResetInitialSize();
                            DisplayUtil.CenterWindowOnMasterWindowScreen(View.VideoPeopleWindow.Instance, LoginManager.Instance.LoginWindow as LoginWindow);
                        }
                        //VideoPeopleWindow.Instance.Visibility = isVideoPeopleWindowVisible ? Visibility.Visible : Visibility.Collapsed;
                        if (Visibility.Visible == VideoPeopleWindow.Instance.Visibility && currentStatus != Visibility.Visible)
                        {
                            VideoPeopleWindow.Instance.AdjustWindowSize();
                        }
                        log.InfoFormat("VideoPeopleWindow, left: {0}, top: {1}", VideoPeopleWindow.Instance.Left, VideoPeopleWindow.Instance.Top);
                        if (
                            Visibility.Visible == SoftwareUpdateWindow.Instance.Visibility &&
                            Visibility.Visible == VideoPeopleWindow.Instance.Visibility
                            )
                        {
                            DisplayUtil.SetWindowCenterAndOwner(SoftwareUpdateWindow.Instance, VideoPeopleWindow.Instance);
                            log.Info("Set soft update window owner to video people window");
                        }
                    }
                    else
                    {
                        log.InfoFormat("Video people window has been visibility: {0}", visibility);
                    }
                }
            });
        }