Ejemplo n.º 1
0
        private void connectServerBtn_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            ConnectionManager.Instance.ConnectionInfo.CurrentServer.AccessCode = Convert.ToInt16(accessCodeTxtBox.Text.Trim());
            ConnectionManager.Instance.ConnectServer(
                SettingManager.Instance.SettingInfo.DeviceType,
                new CallbackHandler((object serverExtraInfo) =>
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    if (ConnectionManager.Instance.IsConnected)
                    {
                        AppStateUtils.Set(Constant.KEY_SERVER_EXTRA_INFO, serverExtraInfo);
                        this.NavigationService.RemoveBackEntry();
                        this.NavigationService.GoBack();
                    }
                    else
                    {
                        //프로그레스바 숨김
                        UIUtils.SetVisibility(connectProgressBar, false);
                        UIUtils.SetVisibility(labelProgressBar, false);

                        MessageBox.Show(I18n.GetString("AppMessageAccessCodeIncorrect"), I18n.GetString("AppMessageNotification"), MessageBoxButton.OK);
                        accessCodeTxtBox.Text = string.Empty;
                        //역시 시간차 공격..
                        bgWorker.RunWorkerAsync();
                    }
                });
            }));
            //프로그레스바 표시
            UIUtils.SetVisibility(connectProgressBar, true);
            UIUtils.SetVisibility(labelProgressBar, true);
        }
Ejemplo n.º 2
0
        private void connectAppbarIconBtn_Click(object sender, EventArgs e)
        {
            //네트워크 연결체크
            if (!NetworkUtils.IsNetworkAvailable)
            {
                NetworkUtils.ShowWiFiSettingPage(I18n.GetString("AppMessageRequiredDataNetwork"), I18n.GetString("AppMessageNotification"));
                return;
            }

            //현재 접속되어 있는 서버가 있다면 종료시킴.
            if (ConnectionManager.Instance.IsConnected)
            {
                ConnectionManager.Instance.DisconnectServer(null);
            }

            //선택된 서버 정보를 현재 서버로 변경
            ServerInfo serverInfo = (ServerInfo)historyItemViewOnPage.SelectedItem;

            ConnectionManager.Instance.ConnectionInfo.CurrentServer = serverInfo;

            ConnectionManager.Instance.ConnectServer(
                SettingManager.Instance.SettingInfo.DeviceType,
                new CallbackHandler((object serverExtraInfo) =>
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    if (serverExtraInfo is ServerExtraInfo)
                    {
                        ServerExtraInfo svrExtInfo = serverExtraInfo as ServerExtraInfo;
                        AppStateUtils.Set(Constant.KEY_SERVER_EXTRA_INFO, svrExtInfo);
                        this.NavigationService.GoBack();
                    }
                    else if (serverExtraInfo is SocketError)
                    {
                        if ((SocketError)serverExtraInfo == SocketError.TimedOut)
                        {
                            MessageBox.Show(I18n.GetString("AppMessageNotAbleConnectPC"));
                            (SearchPivot.Parent as Pivot).SelectedIndex = 0;
                        }
                    }
                    else
                    {
                        MessageBox.Show(I18n.GetString("AppMessageAccessCodeIncorrect"));
                        //접속코드 입력 화면으로 이동
                        this.NavigationService.Navigate(new Uri(string.Format(Constant.PAGE_SERVER_CONNECT, serverInfo.ServerName), UriKind.Relative));
                    }
                });
            }));
        }