private void CopyFastKeyOnClick(object sender, RoutedEventArgs e) { string newPath = (_isFirstFocused ? SecondPanelPath : FirstPanelPath).Text; List <Item> items = (_isFirstFocused ? FirstPanel : SecondPanel).Items.Cast <Item>() .Where(item => item.IsChecked).ToList(); OperationWindow operationWindow = new OperationWindow("Copying"); operationWindow.OnFinish += (o, s) => { UpdatePanels(); operationWindow.Close(); }; operationWindow.Show(); operationWindow.Copy(items, newPath); }
private void PanelOnKeyDown(object sender, KeyEventArgs keyEventArgs) { ListView listView = (ListView)sender; _isFirstFocused = listView.Name == FirstPanel.Name; CheckPanelFocus(); if (Keyboard.IsKeyDown(Key.LeftCtrl)) { switch (keyEventArgs.Key) { case Key.C: _buffer = new List <Item>(); foreach (object firstPanelItem in FirstPanel.Items) { if (((Item)firstPanelItem).IsChecked && !(firstPanelItem is BackItem)) { _buffer.Add((Item)firstPanelItem); } } break; case Key.V: if (_buffer.Count >= 1) { OperationWindow operationWindow = new OperationWindow("Copying"); operationWindow.OnFinish += (o, s) => { UpdatePanels(); operationWindow.Close(); }; operationWindow.Show(); operationWindow.Copy(_buffer, _isFirstFocused ? FirstPanelPath.Text : SecondPanelPath.Text); } break; } } Item item = null; try { item = (Item)((ListViewItem)keyEventArgs.OriginalSource).Content; //fails here if any error //flag = true; } catch (Exception) { ChangeFocus(); } //if (!flag) // return; CheckPanelFocus(); switch (keyEventArgs.Key) { case Key.Back: string path = (_isFirstFocused ? FirstPanelPath.Text : SecondPanelPath.Text) + @"\.."; if (Directory.Exists(path)) { FillTable(_isFirstFocused, path); } else { MessageBox.Show("Can't go to parent folder"); } break; case Key.Enter: PanelOnMouseDoubleClick(sender, null); break; case Key.Right: ChangeFocus(); break; case Key.Left: ChangeFocus(); break; case Key.F2: Rename(item, _isFirstFocused); break; case Key.F5: UpdatePanels(); break; case Key.F11: WindowState = WindowState.Maximized; break; } }