This project is read-only.

Drag and Drop

Aug 24, 2012 at 10:42 AM

I've added a drag and drop funtion:

by adding a Panel (DropPanel)

 

private void fileDropPanel_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
                e.Effect = DragDropEffects.All;
            else
                e.Effect = DragDropEffects.None;
        }

        private void fileDropPanel_DragDrop(object sender, DragEventArgs e)
        {
            string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false);
            int i;
            for (i = 0; i < s.Length; i++) ;
            

            var path = this.folderSpecs.Last().Id + "/files";
            var fileName = s[0];
            var stream = default(Stream);

            try
            {
                stream = File.OpenRead(fileName);
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
                return;
            }

            var client = new LiveConnectClient(this.session);

            client.UploadProgressChanged += this.AddFilesProgressChanged;
            client.UploadCompleted += this.AddFilesCompleted;
            client.UploadAsync(path, fileName, stream, stream);

            this.Busy(false);


        }