コード例 #1
0
        //**********************************************************************************************
        private void this_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop)) //from explorer
            {
                //TODO
                String[] filePaths = (String[])e.Data.GetData("FileDrop");
            }
            else //from listview
            {
                System.Windows.Forms.ListView.SelectedListViewItemCollection items =
                    (System.Windows.Forms.ListView.SelectedListViewItemCollection)e.Data.GetData(
                        typeof(System.Windows.Forms.ListView.SelectedListViewItemCollection));

                foreach (ListViewItem item in items)
                {
                    DiskItem disk = (DiskItem)item.Tag;
                    form.QueueList.QueueDownloadItem(disk.IsDirectory, disk.path, form.LocalList.CurrentDirectory, disk.name, item.ImageIndex, disk.size);
                }

                form.QueueList.StartQueue();
            }

            AllowDrop = true;
            form.RemoteList.AllowDrop = true;
        }
コード例 #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
ファイル: LocalList.cs プロジェクト: maxsnts/XwRemote
        //*************************************************************************************************************
        private void this_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            if (e.Label != null)
            {
                if (Regex.IsMatch(e.Label, @"[:\*\\/\?""<>|]"))
                {
                    MessageBox.Show("The provided name has some invalid characters", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Items[e.Item].BeginEdit();
                    return;
                }

                LabelEdit    = false;
                e.CancelEdit = true;

                string newDir = Path.Combine(CurrentDirectory, e.Label);

                if (Items[e.Item].Tag == null) //new folder
                {
                    if (!Directory.Exists(newDir))
                    {
                        Directory.CreateDirectory(newDir);
                    }
                }
                else
                {
                    DiskItem disk = (DiskItem)Items[e.Item].Tag;

                    if (disk.IsDirectory)
                    {
                        if (Directory.Exists(newDir))
                        {
                            MessageBox.Show("There is already a folder with that name", "Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            Directory.Move(disk.path, newDir);
                        }
                    }
                    else
                    {
                        if (File.Exists(newDir))
                        {
                            MessageBox.Show("There is already a file with that name", "Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            File.Move(disk.path, newDir);
                        }
                    }
                }
            }

            RealLoadList(CurrentDirectory, true);
        }
コード例 #4
0
        //*************************************************************************************************************
        private async void this_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            string CurDir = CurrentDirectory;

            try
            {
                if (e.Label != null)
                {
                    if (Regex.IsMatch(e.Label, @"[:\*\\/\?""<>|]"))
                    {
                        MessageBox.Show("The provided name has some invalid characters", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Items[e.Item].BeginEdit();
                        return;
                    }

                    LabelEdit    = false;
                    e.CancelEdit = true;

                    string newDir = Path.Combine(CurrentDirectory, e.Label);

                    if (Items[e.Item].Tag == null) //new folder
                    {
                        if (!await remoteIO.Exists(newDir))
                        {
                            var result = await remoteIO.CreateDirectory(newDir);

                            form.Log(result.Message);
                        }
                    }
                    else
                    {
                        DiskItem disk = (DiskItem)Items[e.Item].Tag;
                        if (await remoteIO.Exists(newDir))
                        {
                            MessageBox.Show(string.Format("There is already a {0} with that name",
                                                          (disk.IsDirectory) ? "folder" : "file"), "Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            var result = await remoteIO.Rename(disk.path, newDir);

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

            await LoadList(CurDir);
        }
コード例 #5
0
        //**********************************************************************************************
        private void Menu_Upload_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.ListView.SelectedListViewItemCollection items = SelectedItems;
            foreach (ListViewItem item in items)
            {
                DiskItem disk = (DiskItem)item.Tag;
                form.QueueList.QueueUploadItem(disk.IsDirectory, disk.path, form.RemoteList.CurrentDirectory, disk.name, item.ImageIndex, disk.size);
            }

            form.QueueList.StartQueue();
        }
コード例 #6
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);
            }
        }
コード例 #7
0
        //*************************************************************************************************************
        private void this_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop)) //from explorer
            {
                string[] filePaths = (string[])e.Data.GetData("FileDrop");
                Cursor.Current = Cursors.WaitCursor;
                foreach (string path in filePaths)
                {
                    DiskItem disk;
                    int      imageIndex = 0;

                    if (Directory.Exists(path))
                    {
                        disk       = new DiskItem(true, false, path, Path.GetFileName(path));
                        imageIndex = ShellImageList.GetFileImageIndex(disk.path, FileAttributes.Directory);
                    }
                    else
                    {
                        FileInfo f = new FileInfo(path);
                        disk       = new DiskItem(false, false, path, Path.GetFileName(path), f.Length);
                        imageIndex = ShellImageList.GetFileImageIndex(disk.path, File.GetAttributes(path));
                    }
                    form.QueueList.QueueUploadItem(disk.IsDirectory, disk.path,
                                                   CurrentDirectory, disk.name, imageIndex, disk.size);
                }
            }
            else //from listview
            {
                System.Windows.Forms.ListView.SelectedListViewItemCollection items =
                    (System.Windows.Forms.ListView.SelectedListViewItemCollection)e.Data.GetData(
                        typeof(System.Windows.Forms.ListView.SelectedListViewItemCollection));
                Cursor.Current = Cursors.WaitCursor;
                foreach (ListViewItem item in items)
                {
                    DiskItem disk = (DiskItem)item.Tag;
                    form.QueueList.QueueUploadItem(disk.IsDirectory, disk.path,
                                                   CurrentDirectory, disk.name, item.ImageIndex, disk.size);
                }
            }

            form.QueueList.StartQueue();

            form.LocalList.AllowDrop = true;
            AllowDrop = true;
        }
コード例 #8
0
        //*************************************************************************************************************
        private async void this_DoubleClick(object sender, EventArgs e)
        {
            if (SelectedItems.Count == 0)
            {
                return;
            }

            DiskItem di = ((DiskItem)(SelectedItems[0]).Tag);

            if (di.IsDirectory)
            {
                await LoadList(di.path);
            }
            else
            {
                Menu_Download_Click(sender, e);
            }
        }
コード例 #9
0
        //********************************************************************************************
        private void this_DoubleClick(object sender, EventArgs e)
        {
            if (SelectedItems.Count == 0)
            {
                return;
            }

            DiskItem di = ((DiskItem)(SelectedItems[0]).Tag);

            if (di.IsDirectory)
            {
                if (di.path == ".")
                {
                    int li = CurrentDirectory.Replace("\\\\", "").IndexOf("\\");
                    if (CurrentDirectory.Contains("\\\\"))
                    {
                        li += 2;
                    }

                    if (li > 0)
                    {
                        string path = CurrentDirectory.Substring(0, li + 1);

                        if (path.Contains("\\\\"))
                        {
                            if (path.EndsWith("\\"))
                            {
                                path = path.Remove(path.Length - 1, 1);
                            }
                        }

                        LoadList(path);
                    }
                    return;
                }

                if (di.path == "..")
                {
                    int li = CurrentDirectory.LastIndexOf("\\");
                    if (li > 0)
                    {
                        string path = CurrentDirectory.Substring(0, li);
                        if (!path.Contains("\\"))
                        {
                            path += "\\";
                        }
                        LoadList(path);
                    }
                    return;
                }

                if (di.IsDirectory == true)
                {
                    LoadList(di.path);
                }
            }
            else
            {
                Menu_Upload_Click(sender, e);
            }
        }