public static void HandleGetDirectoryResponse(Client client, GetDirectoryResponse packet)
        {
            if (client.Value == null || client.Value.FrmFm == null)
                return;

            new Thread(() =>
            {
                if (client.Value.ProcessingDirectory) return;
                client.Value.ProcessingDirectory = true;

                client.Value.FrmFm.ClearFileBrowser();
                client.Value.FrmFm.AddItemToFileBrowser("..", "", PathType.Back, 0);

                if (packet.Folders != null && packet.Folders.Length != 0 && client.Value.ProcessingDirectory)
                {
                    for (int i = 0; i < packet.Folders.Length; i++)
                    {
                        if (packet.Folders[i] != DELIMITER)
                        {
                            if (client.Value == null || client.Value.FrmFm == null || !client.Value.ProcessingDirectory)
                                break;

                            client.Value.FrmFm.AddItemToFileBrowser(packet.Folders[i], "", PathType.Directory, 1);
                        }
                    }
                }

                if (packet.Files != null && packet.Files.Length != 0 && client.Value.ProcessingDirectory)
                {
                    for (int i = 0; i < packet.Files.Length; i++)
                    {
                        if (packet.Files[i] != DELIMITER)
                        {
                            if (client.Value == null || client.Value.FrmFm == null || !client.Value.ProcessingDirectory)
                                break;

                            client.Value.FrmFm.AddItemToFileBrowser(packet.Files[i],
                                FileHelper.GetDataSize(packet.FilesSize[i]), PathType.File,
                                FileHelper.GetFileIcon(Path.GetExtension(packet.Files[i])));
                        }
                    }
                }

                if (client.Value != null)
                {
                    client.Value.ReceivedLastDirectory = true;
                    client.Value.ProcessingDirectory = false;
                    if (client.Value.FrmFm != null)
                        client.Value.FrmFm.SetStatus("Ready");
                }
            }).Start();
        }
Exemple #2
0
        public static void HandleGetDirectoryResponse(Client client, GetDirectoryResponse packet)
        {
            if (client.Value == null || client.Value.FrmFm == null)
                return;

            new Thread(() =>
            {
                lock (_isAddingLock)
                {
                    if (_isAdding) return;
                    _isAdding = true;
                }

                client.Value.FrmFm.ClearFileBrowser();

                ListViewItem lviBack = new ListViewItem(new string[] { "..", "", "" })
                {
                    Tag = PathType.Back,
                    ImageIndex = 0
                };

                client.Value.FrmFm.AddItemToFileBrowser(lviBack);

                if (packet.Folders != null && packet.Folders.Length != 0)
                {
                    for (int i = 0; i < packet.Folders.Length; i++)
                    {
                        if (packet.Folders[i] != DELIMITER)
                        {
                            ListViewItem lvi = new ListViewItem(new string[] { packet.Folders[i], "", PathType.Directory.ToString() })
                            {
                                Tag = PathType.Directory,
                                ImageIndex = 1
                            };

                            if (client.Value == null || client.Value.FrmFm == null)
                                break;

                            client.Value.FrmFm.AddItemToFileBrowser(lvi);
                        }
                    }
                }

                if (packet.Files != null && packet.Files.Length != 0)
                {
                    for (int i = 0; i < packet.Files.Length; i++)
                    {
                        if (packet.Files[i] != DELIMITER)
                        {
                            ListViewItem lvi =
                                new ListViewItem(new string[] { packet.Files[i], FileHelper.GetDataSize(packet.FilesSize[i]), PathType.File.ToString() })
                                {
                                    Tag = PathType.File,
                                    ImageIndex = FileHelper.GetFileIcon(Path.GetExtension(packet.Files[i]))
                                };

                            if (client.Value == null || client.Value.FrmFm == null)
                                break;

                            client.Value.FrmFm.AddItemToFileBrowser(lvi);
                        }
                    }
                }

                if (client.Value != null)
                {
                    client.Value.LastDirectorySeen = true;
                    if (client.Value.FrmFm != null)
                        client.Value.FrmFm.SetStatus("Ready");
                }

                lock (_isAddingLock)
                {
                    _isAdding = false;
                }
            }).Start();
        }