private void MakeClientFromSession(LiveConnectSession session) { // Creates the client. _liveClient = new LiveConnectClient(session); // Adds event handlers. _liveClient.DownloadCompleted += new EventHandler<LiveDownloadCompletedEventArgs>(OnLiveClientDownloadCompleted); _liveClient.BackgroundDownloadCompleted += new EventHandler<LiveOperationCompletedEventArgs>(OnLiveClientBackgroundDownloadCompleted); _liveClient.GetCompleted += new EventHandler<LiveOperationCompletedEventArgs>(OnLiveClientGetCompleted); // Makes the client download even when on battery, or cellular data scheme. _liveClient.BackgroundTransferPreferences = BackgroundTransferPreferences.AllowCellularAndBattery; // Attaches downloads that have been running in the background // while the app was not active. _liveClient.AttachPendingTransfers(); // Notify we're linked. IsLinked = true; }
//evento da sessão do SkyDrive private void signInButton1_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e) { animaProgressBar(true); try { if (e.Status == LiveConnectSessionStatus.Connected) { txtbStatus.Text = "Atualizando informações da conta..."; txtbConectado.Text = "Conectado como:"; txtbInfo.Visibility = Visibility.Collapsed; client = new LiveConnectClient(e.Session); client.AttachPendingTransfers(); client.GetCompleted += new EventHandler<LiveOperationCompletedEventArgs>(client_GetCompleted); client.GetAsync("me"); } else { ContentList.Clear(); lstFolders.ItemsSource = null; txtbConectado.Text = "Desconectado"; txtbInfo.Visibility = Visibility.Visible; txtbStatus.Text = ""; txtbTitulodapágina.Text = "skydrive"; animaProgressBar(false); } } catch (Exception) { animaProgressBar(false); MessageBox.Show("Não conseguimos verificar a conexão com o SkyDrive, tente novamente!"); } }