Esempio n. 1
0
        public byte[] DownloadFile(SkydriveContent skydriveContent)
        {
            var uri  = new Uri(string.Format("https://apis.live.net/v5.0/{0}/content?access_token={1}", skydriveContent.Id, AccessToken));
            var json = GetResponse(uri);

            return(GetResponseBytes(uri, skydriveContent.Size));
        }
Esempio n. 2
0
        private void listViewFiles_MouseClick(object sender, MouseEventArgs e)
        {
            if (listViewFiles.SelectedItems.Count < 1)
            {
                return;
            }

            SkydriveContent sc = (SkydriveContent)listViewFiles.SelectedItems[0].Tag;

            if (sc.IsFile)
            {
                comboBoxFileName.Text = sc.Name;
            }
        }
Esempio n. 3
0
        private void listViewFiles_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (listViewFiles.SelectedItems.Count < 1)
            {
                return;
            }

            SkydriveContent sc = (SkydriveContent)listViewFiles.SelectedItems[0].Tag;

            try
            {
                if (listViewFiles.SelectedItems[0].Text == "..")
                {
                    labelInfo.Text = "Loading files...";
                    Cursor         = Cursors.WaitCursor;
                    _roots.Pop();
                    LoadFiles(sc.ParentId);
                    Cursor = Cursors.Default;
                }
                else if (sc.IsFolder)
                {
                    labelInfo.Text = "Loading files...";
                    Cursor         = Cursors.WaitCursor;
                    _roots.Push(sc.ParentId);
                    LoadFiles(sc.Id);
                    Cursor = Cursors.Default;
                }
                else if (sc.IsFile)
                {
                    buttonOK_Click(sender, e);
                    DialogResult = DialogResult.OK;
                }
                Cursor         = Cursors.Default;
                labelInfo.Text = string.Empty;
                this.Refresh();
            }
            catch (Exception exception)
            {
                labelInfo.Text = string.Empty;
                Cursor         = Cursors.Default;
                MessageBox.Show(exception.Message);
            }
        }
Esempio n. 4
0
 private void LoadFiles(string path)
 {
     listViewFiles.Items.Clear();
     if (_roots.Count > 0)
     {
         ListViewItem    item = new ListViewItem("..");
         SkydriveContent sc   = new SkydriveContent();
         sc.Type         = "folder";
         sc.ParentId     = _roots.Peek();
         item.Tag        = sc;
         item.ImageIndex = 1;
         listViewFiles.Items.Add(item);
     }
     comboBoxFileName.Items.Clear();
     foreach (SkydriveContent f in _api.GetFiles(path))
     {
         if (f.IsFile || f.IsFolder)
         {
             ListViewItem item = new ListViewItem(f.Name);
             item.SubItems.Add(f.UpdatedTime.ToShortDateString() + " " + f.UpdatedTime.ToShortTimeString());
             item.SubItems.Add(FormatBytesToDisplayFileSize(f.Size));
             item.Tag = f;
             if (f.IsFile)
             {
                 item.ImageIndex = 0;
                 comboBoxFileName.Items.Add(f.Name);
             }
             else
             {
                 item.ImageIndex = 1;
             }
             listViewFiles.Items.Add(item);
         }
     }
     if (listViewFiles.Items.Count > 0)
     {
         listViewFiles.Items[0].Selected = true;
     }
 }
Esempio n. 5
0
        public List <SkydriveContent> GetFiles(string path)
        {
            var uri  = new Uri(string.Format("https://apis.live.net/v5.0/{0}/files?access_token={1}", path, AccessToken));
            var json = GetResponse(uri);

            Hashtable o = (Hashtable)Nikse.Json.JSON.JsonDecode(json);
            List <SkydriveContent> list = new List <SkydriveContent>();

            foreach (Hashtable ht in (o["data"] as System.Collections.ArrayList))
            {
                SkydriveContent file = new SkydriveContent();
                if (ht.ContainsKey("id"))
                {
                    file.Id          = ht["id"].ToString();
                    file.Name        = ht["name"].ToString();
                    file.Size        = Convert.ToInt64(ht["size"].ToString());
                    file.UpdatedTime = Convert.ToDateTime(ht["updated_time"].ToString());
                    file.ParentId    = ht["parent_id"].ToString();
                    file.Type        = ht["type"].ToString();
                    list.Add(file);
                }
            }
            return(list);
        }