Beispiel #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);
                }
            }
        }
Beispiel #2
0
        //*************************************************************************************************************
        public async Task LoadList(string path)
        {
            Cursor.Current = Cursors.WaitCursor;
            BackColor      = Color.FromArgb(240, 240, 240);

            try
            {
                if (!remoteIO.IsConnected)
                {
                    await remoteIO.Reconnect();
                }

                if (path == ".")
                {
                    path = "/";
                }
                if (path == "..")
                {
                    path = CurrentDirectory.GetUnixParentPath();
                }

                var result = await remoteIO.ListDirectory(path);

                if (result.Success)
                {
                    form.Log(result.Message);

                    BeginUpdate();
                    Items.Clear();

                    ListViewItem item1 = Items.Add(".", ShellImageList.GetFileImageIndex("c:", FileAttributes.Device));
                    item1.Tag       = new DiskItem(true, false, ".", "");
                    item1.BackColor = Color.FromArgb(240, 240, 240);
                    ListViewItem item2 = Items.Add("..", ShellImageList.GetFileImageIndex("Folder", FileAttributes.Directory));
                    item2.Tag       = new DiskItem(true, false, "..", "");
                    item2.BackColor = Color.FromArgb(230, 230, 230);

                    ListViewItem.ListViewSubItem[] subItems;
                    ListViewItem item = null;

                    foreach (XwRemoteIOItem remoteItem in result.Items)
                    {
                        if (!remoteItem.IsDirectory)
                        {
                            continue;
                        }

                        item     = new ListViewItem(remoteItem.Name, 0);
                        subItems = new ListViewItem.ListViewSubItem[]
                        {
                            new ListViewItem.ListViewSubItem(item, " - - - "),
                            new ListViewItem.ListViewSubItem(item,
                                                             (remoteItem.Modified == DateTime.MinValue)
                        ? "- - -"
                        : remoteItem.Modified.ToString("yyyy-MM-dd HH:mm:ss"))
                        };

                        item.SubItems.AddRange(subItems);
                        item.Tag = new DiskItem(remoteItem.IsDirectory,
                                                remoteItem.IsSymlink, remoteItem.FullName, remoteItem.Name);
                        item.ImageIndex = ShellImageList.GetFileImageIndex(remoteItem.Name,
                                                                           FileAttributes.Directory | ((remoteItem.IsSymlink) ? FileAttributes.Compressed : 0));

                        Items.Add(item);
                    }

                    foreach (XwRemoteIOItem remoteItem in result.Items)
                    {
                        if (remoteItem.IsDirectory)
                        {
                            continue;
                        }

                        item     = new ListViewItem(remoteItem.Name, 0);
                        subItems = new ListViewItem.ListViewSubItem[]
                        {
                            new ListViewItem.ListViewSubItem(item, string.Format("{0:0,0}", remoteItem.Size)),
                            new ListViewItem.ListViewSubItem(item,
                                                             (remoteItem.Modified == DateTime.MinValue)
                        ? "- - -"
                        : remoteItem.Modified.ToString("yyyy-MM-dd HH:mm:ss"))
                        };

                        item.SubItems.AddRange(subItems);
                        item.Tag = new DiskItem(remoteItem.IsDirectory, remoteItem.IsSymlink,
                                                remoteItem.FullName, remoteItem.Name, remoteItem.Size);
                        item.ImageIndex = ShellImageList.GetFileImageIndex(remoteItem.Name,
                                                                           FileAttributes.Normal | ((remoteItem.IsSymlink) ? FileAttributes.Compressed : 0));

                        Items.Add(item);
                    }

                    EndUpdate();

                    form.statusRemoteCount.Text = string.Format("{0} Items", (Items.Count > 2) ? Items.Count - 2 : 0);

                    CurrentDirectory     = path;
                    form.RemotePath.Text = CurrentDirectory;
                    CheckPin();
                }
                else
                {
                    if (form.splitContainerStatus.Visible) //connecting
                    {
                        form.Log($"An error occurred while retrieving the directory list.\nReason: {result.Message}",
                                 Color.Red);
                    }
                    else
                    {
                        form.loadingCircle1.Active  = true;
                        form.loadingCircle1.Visible = false;
                        form.SetStatusText(result.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                form.Log(ex.Message, Color.Red);
                Enabled = true;
            }

            Cursor.Current = Cursors.Default;
            BackColor      = SystemColors.Window;
        }