コード例 #1
0
        public void OpenDirectory(string path)
        {
            lvDropboxFiles.Items.Clear();

            DropboxDirectoryInfo directory = null;

            AsyncHelper.AsyncJob(() =>
            {
                directory = dropbox.GetFilesList(path);
            },
                                 () =>
            {
                if (directory != null)
                {
                    lvDropboxFiles.Tag = directory;

                    ListViewItem lvi = GetParentFolder(directory.Path);

                    if (lvi != null)
                    {
                        lvDropboxFiles.Items.Add(lvi);
                    }

                    foreach (DropboxContentInfo content in directory.Contents.OrderBy(x => !x.Is_dir))
                    {
                        string filename = Path.GetFileName(content.Path);
                        lvi             = new ListViewItem(filename);
                        lvi.SubItems.Add(content.Size);
                        lvi.SubItems.Add(content.Modified);
                        lvi.ImageKey = ilm.AddImage(content.Icon);
                        lvi.Tag      = content;
                        lvDropboxFiles.Items.Add(lvi);
                    }

                    CurrentFolderPath = directory.Path.Trim('/');
                    Text = "Dropbox - " + CurrentFolderPath;
                }
                else
                {
                    MessageBox.Show("Path not exist: " + path, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            });
        }
コード例 #2
0
        private void TestCustomUploader(CustomUploaderInfo cui)
        {
            UploadResult ur = null;

            AsyncHelper.AsyncJob(() =>
            {
                try
                {
                    using (Stream stream = Resources.ZScreen_256.GetStream())
                    {
                        CustomUploader cu = new CustomUploader(cui);
                        ur        = cu.Upload(stream, "Test.png");
                        ur.Errors = cu.Errors;
                    }
                }
                catch { }
            },
                                 () =>
            {
                if (ur != null)
                {
                    if (!string.IsNullOrEmpty(ur.URL))
                    {
                        txtCustomUploaderLog.AppendText("URL: " + ur.URL + Environment.NewLine);
                    }
                    else if (ur.IsError)
                    {
                        txtCustomUploaderLog.AppendText("Error: " + ur.ErrorsToString() + Environment.NewLine);
                    }
                    else
                    {
                        txtCustomUploaderLog.AppendText("Error: Result is empty." + Environment.NewLine);
                    }

                    txtCustomUploaderLog.ScrollToCaret();
                }

                btnCustomUploaderTest.Enabled = true;
            });
        }