Esempio n. 1
0
        // ComboBox
        private void leftDriveSelect_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (cbActive)
                {
                    var    currentCB = sender as ComboBox;
                    string newPath   = ((Drive)currentCB.SelectedItem).Name;
                    if (currentPathLeft != null)
                    {
                        leftHistory.Add(currentPathLeft);
                    }

                    List <Item> tmpLV = Operations.LoadDirectory(currentPathLeft, newPath);
                    if (tmpLV != null)
                    {
                        leftDirectory.ItemsSource = tmpLV;
                        leftDirectory.Items.Refresh();
                        currentPathLeft = newPath;
                    }
                    leftDirectoryPathLabel.Content = currentPathLeft;
                    leftDirectoryPathTextBox.Text  = currentPathLeft;
                    holdLeftIndex = currentCB.SelectedIndex;
                    DeactivatePanel();
                }
                cbActive = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                leftDrive.SelectedIndex = holdLeftIndex;
            }
        }
Esempio n. 2
0
        private void ChangeDirectory(string targetPath)
        {
            try
            {
                if (activePanel == -1)
                {
                    leftHistory.Add(currentPathLeft);
                    var    currentLV    = leftDirectory;
                    Item   selectedItem = ((Item)currentLV.SelectedItem);
                    string newPath      = System.IO.Path.GetFullPath(System.IO.Path.Combine(currentPathLeft, targetPath));

                    List <Item> tmpLV = Operations.LoadDirectory(currentPathLeft, newPath);
                    if (tmpLV != null)
                    {
                        leftDirectory.ItemsSource = tmpLV;
                        leftDirectory.Items.Refresh();
                        currentPathLeft = newPath;
                    }
                    leftDirectoryPathLabel.Content = currentPathLeft;
                    leftDirectoryPathTextBox.Text  = currentPathLeft;
                    leftDirectory.SelectedIndex    = 0;
                    //DeactivatePanel();
                }
                else if (activePanel == 1)
                {
                    rightHistory.Add(currentPathRight);
                    var         currentLV    = rightDirectory;
                    Item        selectedItem = ((Item)currentLV.SelectedItem);
                    string      newPath      = System.IO.Path.GetFullPath(System.IO.Path.Combine(currentPathRight, targetPath));
                    List <Item> tmpLV;
                    if (isFTP)
                    {
                        tmpLV = client.DirectoryListDetailed(newPath);
                    }
                    else
                    {
                        tmpLV = Operations.LoadDirectory(currentPathRight, newPath);
                    }
                    if (tmpLV != null)
                    {
                        rightDirectory.ItemsSource = tmpLV;
                        rightDirectory.Items.Refresh();
                        currentPathRight = newPath;
                    }
                    rightDirectoryPathLabel.Content = currentPathRight;
                    rightDirectoryPathTextBox.Text  = currentPathRight;
                    rightDirectory.SelectedIndex    = 0;
                    //DeactivatePanel();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 3
0
        private void FTPDisconnectButton(object sender, RoutedEventArgs e)
        {
            isFTP                = false;
            FTPCon.IsEnabled     = true;
            FTPDiscon.IsEnabled  = false;
            rightDrive.IsEnabled = rightDirectoryPathTextBox.IsEnabled = true;
            currentPathRight     = ((Drive)rightDrive.SelectedItem).Name;
            List <Item> tmpLV = Operations.LoadDirectory("", currentPathRight);

            if (tmpLV != null)
            {
                rightDirectory.ItemsSource = tmpLV;
                rightDirectory.Items.Refresh();
            }
            rightDirectoryPathLabel.Content = currentPathRight;
            rightDirectoryPathTextBox.Text  = currentPathRight;
            DeactivatePanel();
        }
Esempio n. 4
0
 private void RefreshDirectiories()
 {
     try
     {
         if (isFTP)
         {
             leftDirectory.ItemsSource = Operations.LoadDirectory(currentPathLeft, currentPathLeft);
             leftDirectory.Items.Refresh();
             rightDirectory.ItemsSource = client.DirectoryListDetailed(currentPathRight);
             rightDirectory.Items.Refresh();
         }
         else
         {
             leftDirectory.ItemsSource = Operations.LoadDirectory(currentPathLeft, currentPathLeft);
             leftDirectory.Items.Refresh();
             rightDirectory.ItemsSource = Operations.LoadDirectory(currentPathRight, currentPathRight);
             rightDirectory.Items.Refresh();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Esempio n. 5
0
        private void Back_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Parameter.ToString() == "Left")
            {
                //string newPath = System.IO.Path.GetFullPath(System.IO.Path.Combine(currentPathLeft, ".."));
                string newPath = leftHistory[leftHistory.Count - 1];
                leftDirectory.ItemsSource = Operations.LoadDirectory(currentPathLeft, newPath);
                leftDirectory.Items.Refresh();
                currentPathLeft = newPath;
                leftDirectoryPathLabel.Content = newPath;
                leftHistory.RemoveAt(leftHistory.Count - 1);

                if (System.IO.Path.GetPathRoot(currentPathLeft) != ((Drive)leftDrive.SelectedItem).Name)
                {
                    int i = 0;
                    foreach (Drive drive in leftDrive.Items)
                    {
                        if (drive.Name == System.IO.Path.GetPathRoot(currentPathLeft))
                        {
                            cbActive = false;
                            leftDrive.SelectedIndex = i;
                            break;
                        }
                        else
                        {
                            i++;
                        }
                    }
                }
                DeactivatePanel();
            }
            else if (e.Parameter.ToString() == "Right")
            {
                //string newPath = System.IO.Path.GetFullPath(System.IO.Path.Combine(currentPathLeft, ".."));
                string newPath = rightHistory[rightHistory.Count - 1];
                if (isFTP)
                {
                    rightDirectory.ItemsSource = client.DirectoryListDetailed(newPath);
                }
                else
                {
                    rightDirectory.ItemsSource = Operations.LoadDirectory(currentPathRight, newPath);
                }
                rightDirectory.Items.Refresh();
                currentPathRight = newPath;
                rightDirectoryPathLabel.Content = newPath;
                rightHistory.RemoveAt(rightHistory.Count - 1);
                if (isFTP)
                {
                    return;
                }
                else if (System.IO.Path.GetPathRoot(currentPathRight) != ((Drive)rightDrive.SelectedItem).Name)
                {
                    int i = 0;
                    foreach (Drive drive in rightDrive.Items)
                    {
                        if (drive.Name == System.IO.Path.GetPathRoot(currentPathRight))
                        {
                            cbActive = false;
                            rightDrive.SelectedIndex = i;
                            break;
                        }
                        else
                        {
                            i++;
                        }
                    }
                }
                DeactivatePanel();
            }
        }
Esempio n. 6
0
        private void EnterKeyHanlder()
        {
            try
            {
                if (leftDirectoryPathTextBox.Visibility == Visibility.Visible)
                {
                    leftHistory.Add(currentPathLeft);
                    leftDirectory.ItemsSource = Operations.LoadDirectory(currentPathLeft, leftDirectoryPathTextBox.Text);
                    leftDirectory.Items.Refresh();
                    currentPathLeft = leftDirectoryPathTextBox.Text;
                    leftDirectoryPathLabel.Content      = currentPathLeft;
                    leftDirectoryPathLabel.Visibility   = Visibility.Visible;
                    leftDirectoryPathTextBox.Visibility = Visibility.Hidden;

                    int i = 0;
                    foreach (Drive drive in leftDrive.Items)
                    {
                        if (drive.Name == System.IO.Path.GetPathRoot(currentPathLeft))
                        {
                            cbActive = false;
                            leftDrive.SelectedIndex = i;
                            break;
                        }
                        else
                        {
                            i++;
                        }
                    }
                    DeactivatePanel();
                }
                else if (rightDirectoryPathTextBox.Visibility == Visibility.Visible)
                {
                    rightHistory.Add(currentPathRight);
                    rightDirectory.ItemsSource = Operations.LoadDirectory(currentPathRight, rightDirectoryPathTextBox.Text);
                    rightDirectory.Items.Refresh();
                    currentPathRight = rightDirectoryPathTextBox.Text;
                    rightDirectoryPathLabel.Content      = currentPathRight;
                    rightDirectoryPathLabel.Visibility   = Visibility.Visible;
                    rightDirectoryPathTextBox.Visibility = Visibility.Hidden;
                    int i = 0;
                    foreach (Drive drive in rightDrive.Items)
                    {
                        if (drive.Name == System.IO.Path.GetPathRoot(currentPathRight))
                        {
                            cbActive = false;
                            rightDrive.SelectedIndex = i;
                            break;
                        }
                        else
                        {
                            i++;
                        }
                    }
                    DeactivatePanel();
                }
                else
                {
                    ChangeDirectory();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }