コード例 #1
0
        //**********************************************************************************************
        public void QueueDownloadItem(bool IsDir, string source, string destination, string name, int ImageIndex, long size)
        {
            form.currentItem.Text = $"Queueing {source}";

            Cursor.Current = Cursors.WaitCursor;
            QueueItem queue = new QueueItem();

            queue.Download        = true;
            queue.SourceIsdir     = IsDir;
            queue.SourcePath      = source;
            queue.ImageIndex      = ImageIndex;
            queue.Name            = name;
            queue.DestinationPath = Path.Combine(destination, name);
            queue.Status          = QueueStatus.Queue;
            queue.Size            = size;
            InsertOnQueue(queue);

            if (IsDir)
            {
                var task   = Task.Run(async() => await remoteIO.ListDirectory(source));
                var result = task.Result;
                if (result.Success)
                {
                    foreach (XwRemoteIOItem item in result.Items)
                    {
                        int image = ShellImageList.GetFileImageIndex(item.Name, (item.IsDirectory) ? FileAttributes.Directory : FileAttributes.Archive);
                        QueueDownloadItem(item.IsDirectory, item.FullName, queue.DestinationPath, item.Name, image, item.Size);
                    }
                }
                else
                {
                    form.Log(result.Message, Color.Red);
                }
            }
        }
コード例 #2
0
        //********************************************************************************************
        private void DeleteSelectedItems()
        {
            if (MessageBox.Show("Delete the selected items?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                foreach (ListViewItem item in SelectedItems)
                {
                    try
                    {
                        DiskItem diskItem = (DiskItem)item.Tag;

                        if (diskItem.path == "." || diskItem.path == "..")
                        {
                            continue;
                        }

                        if (diskItem.IsDirectory)
                        {
                            Directory.Delete(diskItem.path, true);
                        }
                        else
                        {
                            File.Delete(diskItem.path);
                        }

                        item.Remove();
                    }
                    catch (Exception ex)
                    {
                        form.Log(ex.Message, Color.Red);
                    }
                }

                RealLoadList(CurrentDirectory, true);
            }
        }
コード例 #3
0
        //*************************************************************************************************************
        private async Task DeleteSelectedItems()
        {
            if (MessageBox.Show("Delete the selected items?", "",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                Cursor.Current = Cursors.WaitCursor;

                foreach (ListViewItem item in SelectedItems)
                {
                    try
                    {
                        DiskItem diskItem = (DiskItem)item.Tag;

                        if (diskItem.path == "." || diskItem.path == "..")
                        {
                            continue;
                        }

                        if (diskItem.IsSymlink)
                        {
                            form.Log("Delete Symlinks not implemented yet!", Color.Red);
                            continue;
                        }

                        if (diskItem.IsDirectory)
                        {
                            var result = await remoteIO.DeleteDirectory(diskItem.path);

                            form.Log(result.Message);
                        }
                        else
                        {
                            var result = await remoteIO.DeleteFile(diskItem.path);

                            form.Log(result.Message);
                        }
                    }
                    catch (Exception ex)
                    {
                        form.Log(ex.Message, Color.Red);
                    }

                    item.Remove();
                }

                await LoadList(CurrentDirectory);
            }
        }