コード例 #1
0
        async private void copyBut_Click(object sender, RoutedEventArgs e)
        {
            IEnumerable <IFileObject> selectedItems = GetSelectedItemsData();

            if (selectedItems.Count() == 0)
            {
                MessageBox.Show("No elements selected", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            File_Containers.FileContainer receiver = FileOperator.ActiveDirectory == FileOperator.Side.Left ? File_Containers.FileDualContainer.ChooseContainer(FileOperator.Side.Right) :
                                                     File_Containers.FileDualContainer.ChooseContainer(FileOperator.Side.Left);
            Task delTask = Task.Run(() => DeletePreviouslyCreated(receiver, selectedItems));

            delTask.Wait();
            if (MessageBox.Show($"{selectedItems.Count()} items will be copied. Continue?", "Information", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                try
                {
                    NotifyAboutFileOperations($"Copy files to {receiver}");
                    await FileOperator.CopyFiles(selectedItems, receiver);

                    ClearNotifyAboutFileOperations();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to copy in this directory", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }
            await Task.Run(() => UpdateView(FileOperator.ActiveDirectory == FileOperator.Side.Left ? FileOperator.Side.Right : FileOperator.Side.Left));
        }
コード例 #2
0
        async private Task DropHandler(object _sender, object _e, FileOperator.Side _side)
        {
            ListBox parent = (ListBox)_sender;

            if (parent == dragSource)
            {
                return;
            }
            String             data      = (String)(((DragEventArgs)_e).Data.GetData(typeof(String)));
            List <IFileObject> objToMove = ((IList <IFileObject>)dragSource.ItemsSource).Where((item) => item.Info.FullName == data).ToList();

            File_Containers.FileContainer receiver = File_Containers.FileDualContainer.ChooseContainer(_side);
            try
            {
                await Task.Run(() => FileOperator.CopyFiles(objToMove, receiver));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to copy in this directory", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            ((IList <IFileObject>)dragSource.ItemsSource).Remove(objToMove[0]);
            await Task.Run(() => UpdateView(_side));
        }