Ejemplo n.º 1
0
        /// <summary>
        /// Initialize Components and UI.
        /// </summary>



        /// <summary>
        /// Login to SkyDrive account
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void signInButton_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            infoTextBlock.Text = skyDriveController.SignIn_SessionChanged(sender, e);
            // set the current client and session
            client  = skyDriveController.Client;
            session = skyDriveController.Session;
        }
Ejemplo n.º 2
0
        private void btnLogin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            //若连接上了,则显示已登陆
            if (e.Status == LiveConnectSessionStatus.Connected)
            {
                session             = e.Session;
                client              = new LiveConnectClient(session);
                infoTextBlock.Text  = txtnote.Resources.StringLibrary.shareInfo_2;
                infoTextBlock2.Text = txtnote.Resources.StringLibrary.shareInfo_2;
                infoTextBlock3.Text = txtnote.Resources.StringLibrary.shareInfo_2;

                //读取skydrive根目录的文件和文件夹,由btnSignin_GetCompleted处理
                client.GetCompleted +=
                    new EventHandler <LiveOperationCompletedEventArgs>(btnSignin_GetCompleted);
                client.GetAsync("me/skydrive/files?filter=folders");
            }
            else
            {
                //未登录,请点击sign in
                infoTextBlock.Text  = txtnote.Resources.StringLibrary.shareInfo_1;
                infoTextBlock2.Text = txtnote.Resources.StringLibrary.shareInfo_1;
                infoTextBlock3.Text = txtnote.Resources.StringLibrary.shareInfo_1;
                client = null;
            }
        }
Ejemplo n.º 3
0
 void OneDriveSignInButton_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == LiveConnectSessionStatus.Connected)
     {
         OneDriveSession.Login(e.Session);
     }
     else
     {
         OneDriveSession.Logout();
     }
 }
Ejemplo n.º 4
0
 private void signInButton_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == LiveConnectSessionStatus.Connected)
     {
         viewModel.Client = new LiveConnectClient(e.Session);
     }
     else
     {
         this.infoTextBlock.Text = "not signed in";
     }
 }
Ejemplo n.º 5
0
 private void SignInButton_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Session != null && e.Status == LiveConnectSessionStatus.Connected)
     {
         App.Session = e.Session;
         this.pivotControl.SelectedItem = this.albumPivot;
         if (!App.ViewModel.IsDataLoaded)
         {
             App.ViewModel.LoadData();
         }
     }
 }
        private void bLiveSignIn_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            if (e.Status != LiveConnectSessionStatus.Connected)
            {
                return;
            }

            _client         = new LiveConnectClient(e.Session);
            App.LiveSession = e.Session;

            GetMeAndFileListing();
        }
Ejemplo n.º 7
0
 private void signInButton_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == LiveConnectSessionStatus.Connected)
     {
         MainPage.session = e.Session;
         this.NavigationService.Navigate(new Uri("/Index.xaml", UriKind.Relative));
     }
     else
     {
         MainPage.session = null;
     }
 }
Ejemplo n.º 8
0
 private void SignInButton_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Session != null && e.Status == LiveConnectSessionStatus.Connected)
     {
         App.LiveConnectSession = e.Session;
         App.ViewModelLocator.Main.HasSignedIntoCloudService = true;
     }
     else
     {
         App.ViewModelLocator.Main.HasSignedIntoCloudService = false;
     }
 }
Ejemplo n.º 9
0
 private async void ButtonSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == LiveConnectSessionStatus.Connected && settingManager.skydrive_login)
     {
         client = new LiveConnectClient(e.Session);
         liveConnectSessionChangedEventArgs = e;
         var result = await client.GetAsync("me");
     }
     else
     {
         client = null;
     }
 }
Ejemplo n.º 10
0
        private void OnSessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message);
                return;
            }

            if (e.Status == LiveConnectSessionStatus.Connected)
            {
                ((App)App.Current).Session = e.Session;
                this.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            }
        }
Ejemplo n.º 11
0
 public void LoginCompleted(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Session != null && e.Status == LiveConnectSessionStatus.Connected)
     {
         App.Session = e.Session;
         if (dataFullName != null && dataPhoto != null)
         {
             GetProfileData();
         }
     }
     else if (e.Error != null)
     {
         MessageBox.Show("Error logging in.");
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        ///     Event handler for SignInButton.SessionChanged event.
        /// </summary>
        private void btnLogin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            if (e.Status == LiveConnectSessionStatus.Connected)
            {
                this.liveClient = new LiveConnectClient(e.Session);
                this.GetMe();
            }
            else
            {
                this.liveClient      = null;
                this.tbResponse.Text = e.Error != null?e.Error.ToString() : string.Empty;

                this.imgMe.Source = null;
            }
        }
Ejemplo n.º 13
0
 private void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == LiveConnectSessionStatus.Connected)
     {
         client               = new LiveConnectClient(e.Session);
         infoTextBlock.Text   = "Signed in.";
         client.GetCompleted +=
             new EventHandler <LiveOperationCompletedEventArgs>(OnGetCompleted);
         client.GetAsync("me", null);
     }
     else
     {
         infoTextBlock.Text = "Not signed in.";
         client             = null;
     }
 }
Ejemplo n.º 14
0
        private void skydrive_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            if (e != null && e.Status == LiveConnectSessionStatus.Connected)
            {
                this.client = new LiveConnectClient(e.Session);
                this.GetAccountInformations();
            }
            else
            {
                this.client = null;

                MessageBoxResult result =
                    MessageBox.Show(e.Error != null ? e.Error.ToString() : string.Empty,
                                    "SkyDrive Not Signed-in", MessageBoxButton.OK);
            }
        }
Ejemplo n.º 15
0
        private void skydrive_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            if (e != null && e.Status == LiveConnectSessionStatus.Connected)
            {
                this.client = new LiveConnectClient(e.Session);
                this.GetAccountInformations();

                // small files but via 3G and on Battery
                this.client.BackgroundTransferPreferences = BackgroundTransferPreferences.AllowCellularAndBattery;
            }
            else
            {
                this.client     = null;
                textOutput.Text = e.Error != null?e.Error.ToString() : string.Empty;
            }
        }
Ejemplo n.º 16
0
        private void OnSessionChanged(Object sender, LiveConnectSessionChangedEventArgs args)
        {
            if (args != null && args.Session != null && args.Status == LiveConnectSessionStatus.Connected)
            {
                this.client = new LiveConnectClient(args.Session);

                if (notes == null)
                {
                    signedInUser();
                }
            }
            else
            {
                signedOutUser();
            }
        }
        private void SignInButton_OnSessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            // As soon as user is logged in, passing her AuthenticationToken to the ViewModel to enable interaction with the service
            App.ViewModel.SetAuthenticationToken
            (
                e.Status == LiveConnectSessionStatus.Connected
                ?
                e.Session.AuthenticationToken
                :
                string.Empty
            );

            if (e.Error != null)
            {
                Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
            }
        }
Ejemplo n.º 18
0
 public string SignIn_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == LiveConnectSessionStatus.Connected)
     {
         session              = e.Session;
         client               = new LiveConnectClient(e.Session);
         message              = "Signed in.";
         client.GetCompleted +=
             new EventHandler <LiveOperationCompletedEventArgs>(OnSignIn_GetCompleted);
         client.GetAsync("me", null);
     }
     else
     {
         message = "Not signed in.";
         client  = null;
     }
     return(message);
 }
        public bool RegisterSessionChange(object sender, LiveConnectSessionChangedEventArgs e)
        {
            lock (_syncRoot)
            {
                if (e.Status == LiveConnectSessionStatus.Connected)
                {
                    LiveClient = new LiveConnectClient(e.Session);
                    LiveClient.GetCompleted    += LiveClient_GetCompleted;
                    LiveClient.UploadCompleted += new EventHandler <LiveOperationCompletedEventArgs>(LiveClient_UploadCompleted);

                    Logged = true;
                }
                else
                {
                    Logged = false;
                }
            }
            return(Logged);
        }
Ejemplo n.º 20
0
        private async void SignInButton_OnSessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            if (e.Error == null && e.Status == LiveConnectSessionStatus.Connected)
            {
                _client = new LiveConnectClient(e.Session);

                try
                {
                    var meResult = await _client.GetAsync(LiveSdkConstants.MyDetails);

                    var myDetails = JsonConvert.DeserializeObject <MeDetails>(meResult.RawResult);

                    SignedInAs.Text = string.Format("Signed in as {0}", myDetails.Name);
                }
                catch
                {
                    MessageBox.Show("Something went wrong");
                }
            }
        }
Ejemplo n.º 21
0
 /// <summary>
 /// btnSignin_SessionChanged tregar signin button clicked.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Session != null && e.Status == LiveConnectSessionStatus.Connected)
     {
         App.Session          = e.Session;
         client               = new LiveConnectClient(e.Session);
         client.GetCompleted +=
             new EventHandler <LiveOperationCompletedEventArgs>(OnGetCompleted);
         client.GetAsync("me", null);
     }
     else
     {
         // remove all live profile informaion.
         client               = null;
         App.Session          = null;
         gotoAlbum.Visibility = Visibility.Collapsed;
         ProfileName.Text     = "";
         ProfilePic.Source    = null;
     }
 }
Ejemplo n.º 22
0
 private void Signin_Get_Session(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == LiveConnectSessionStatus.Connected)
     {
         session = e.Session;
         client  = new LiveConnectClient(session);
         textBlockStatus.Text = "Informations...";
         client.GetCompleted += Signin_Get_Infos;
         client.GetAsync("me", null);
         client.DownloadCompleted += new EventHandler <LiveDownloadCompletedEventArgs>(Signin_Get_Picture);
         client.DownloadAsync("me/picture");
     }
     else
     {
         textBlockStatus.Text           = "Déconnecté";
         ListBox_SkyContent.ItemsSource = "";
         client             = null;
         session            = null;
         sky_base_folder_id = null;
     }
 }
Ejemplo n.º 23
0
        public void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            if (_skyDriveManager.RegisterSessionChange(sender, e))
            {
                FolderPath     = "/SkyDrive/";
                SignInRequired = false;
                NoFolders      = false;
                _skyDriveManager.GetFolderAsync("/me/skydrive", GetFolderCallback);
                _currentFolderID = "/me/skydrive";
            }
            else
            {
                _navHistory.Clear();

                RestartNavInfo();
                FolderPath = "/SkyDrive/";
                Folders.Clear();
                SignInRequired = true;
                NoFolders      = false;
            }
        }
Ejemplo n.º 24
0
        private async void ButtonSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs ent)
        {
            if (ent.Status == LiveConnectSessionStatus.Connected)
            {
                client = new LiveConnectClient(ent.Session);
                this.SkyDriveTextBlock.Text = "已经登录";
                var e = await client.GetAsync("me");

                if (e.Result.ContainsKey("first_name") &&
                    e.Result.ContainsKey("last_name"))
                {
                    if (e.Result["first_name"] != null &&
                        e.Result["last_name"] != null)
                    {
                        string name = e.Result["first_name"] + " " + e.Result["last_name"];
                        if (name.Length >= 14)
                        {
                            name = name.Substring(0, 12) + "...";
                        }
                        this.SkyDriveTextBlock.Text = name;
                    }
                }
                else
                {
                    this.SkyDriveTextBlock.Text = "已经登录";
                }

                if (settingManager.skydrive_login == false)
                {
                    Dispatcher.BeginInvoke(() => AppUtils.ToastPromptShow("阅FM", "绑定成功,若此次不能使用上传请重启本应用"));
                }
                settingManager.skydrive_login = true;
            }
            else
            {
                this.SkyDriveTextBlock.Text = "尚未登录";

                settingManager.skydrive_login = false;
            }
        }
Ejemplo n.º 25
0
        private async void signInButton_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            try
            {
                if (e.Status == LiveConnectSessionStatus.Connected)
                {
                    client = new LiveConnectClient(e.Session);
                    LiveOperationResult operationResult = await client.GetAsync("me");

                    App.ViewModel.LoadUserInfo((dynamic)operationResult.Result);
                }
                else
                {
                    App.ViewModel.ResetUserInfo();
                }
            }
            catch (LiveConnectException exception)
            {
                App.ViewModel.ResetUserInfo();
                MessageBox.Show("An error occurred signing in: " + exception.Message);
            }
        }
Ejemplo n.º 26
0
 private void SignInButton_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Error == null)
     {
         if (e.Status == LiveConnectSessionStatus.Connected)
         {
             client      = new LiveConnectClient(e.Session);
             App.Session = e.Session;
             this.txtLoginResult.Text = "Zalogowany.";
             client.GetCompleted     += new EventHandler <LiveOperationCompletedEventArgs>(OnGetCompleted);
             client.GetAsync("me");
         }
         else
         {
             App.Session        = null;
             client             = null;
             btBackup.IsEnabled = false;
         }
     }
     else
     {
         MessageBox.Show("SkyDrive problem: " + e.Error.Message);
     }
 }
Ejemplo n.º 27
0
 private void loginButton_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
 }
Ejemplo n.º 28
0
 private void OnSessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     this.liveClient = (e.Status == LiveConnectSessionStatus.Connected) ? new LiveConnectClient(e.Session) : null;
 }