Ejemplo n.º 1
0
        private void WaitLoadConsole_Tick(object sender, EventArgs e)
        {
            SetStatus("Fetching root directories...");

            foreach (var driveName in FtpExtensions.GetFolderNames("/").ToArray())
            {
                ComboBoxConsoleDrives.Properties.Items.Add(driveName.Replace(@"/", ""));
            }

            if (MainWindow.Settings.SaveConsolePath)
            {
                if (MainWindow.Settings.ConsolePath.Equals(@"/") || string.IsNullOrEmpty(MainWindow.Settings.ConsolePath))
                {
                    LoadConsoleDirectory("/dev_hdd0/");
                }
                else
                {
                    LoadConsoleDirectory(MainWindow.Settings.ConsolePath);
                }
            }
            else
            {
                LoadConsoleDirectory("/dev_hdd0/");
            }

            WaitLoadConsole.Enabled = false;
        }
Ejemplo n.º 2
0
        public void CreateConsoleFolder()
        {
            try
            {
                var folderName = DialogExtensions.ShowTextInputDialog(this, "Add New Folder", "Folder Name: ", "");

                if (folderName != null)
                {
                    string folderPath = FtpDirectoryPath + "/" + folderName;

                    if (FtpClient.DirectoryExists(folderPath))
                    {
                        XtraMessageBox.Show($"A folder with this name already exists.", "Error");
                        return;
                    }
                    else
                    {
                        _ = FtpExtensions.CreateDirectory(folderPath);
                        LoadConsoleDirectory(FtpDirectoryPath);
                    }
                }
            }
            catch (FtpException ex)
            {
                DarkMessageBox.ShowError($"Unable to create new folder. Error: {ex.Message}", "Error");
            }
            catch (Exception ex)
            {
                DarkMessageBox.ShowError($"Unable to create new folder. Error: {ex.Message}", "Error");
            }
        }
Ejemplo n.º 3
0
        public void DeleteConsoleItem()
        {
            try
            {
                if (DarkMessageBox.Show(this, "Do you really want to delete the selected item?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    var type = DgvConsoleFiles.CurrentRow.Cells[0].Value.ToString();
                    var name = DgvConsoleFiles.CurrentRow.Cells[2].Value.ToString();

                    var itemPath = TextBoxConsolePath.Text + name;

                    if (type.Equals("folder"))
                    {
                        SetConsoleStatus($"Deleting folder: {itemPath}");

                        FtpExtensions.DeleteDirectory(FtpClient, itemPath);

                        SetConsoleStatus("Successfully deleted folder.");
                    }
                    else if (type.Equals("file"))
                    {
                        SetConsoleStatus($"Deleting file: {itemPath}");
                        FtpExtensions.DeleteFile(FtpClient, itemPath);
                        SetConsoleStatus("Successfully deleted file.");
                    }

                    DgvConsoleFiles.Rows.RemoveAt(DgvConsoleFiles.CurrentRow.Index);
                }
            }
            catch (Exception ex)
            {
                SetConsoleStatus($"Unable to delete item. Error: {ex.Message}", ex);
            }
        }
Ejemplo n.º 4
0
        private void ContextMenuItemConsoleRenameFolder_Click(object sender, EventArgs e)
        {
            try
            {
                var oldFolderName = DgvConsoleFiles.CurrentRow.Cells[2].Value.ToString();
                var folderPath    = TextBoxConsolePath.Text + oldFolderName;

                var newFolderName = DialogExtensions.ShowTextInputDialog(this, "Rename Folder", "Folder Name:", oldFolderName);

                var newFolderPath = TextBoxConsolePath.Text + newFolderName;

                if (newFolderName != null && !newFolderName.Equals(oldFolderName))
                {
                    if (FtpClient.DirectoryExists(folderPath))
                    {
                        SetConsoleStatus($"A folder with this name already exists.");
                        return;
                    }
                    else
                    {
                        SetConsoleStatus($"Renaming folder: {folderPath} to: {newFolderName}");
                        FtpExtensions.RenameFileOrFolder(FtpConnection, folderPath, newFolderName);
                        SetConsoleStatus($"Successfully renamed folder to: {newFolderName}");
                        LoadConsoleDirectory(FtpDirectoryPath);
                    }
                }
            }
            catch (Exception ex)
            {
                SetConsoleStatus($"Unable to rename folder. Error: {ex.Message}", ex);
            }
        }
Ejemplo n.º 5
0
        private void WaitLoadConsole_Tick(object sender, EventArgs e)
        {
            WaitLoadConsole.Enabled = false;

            SetStatus("Fetching root directories...");

            if (ConsoleType == ConsoleTypePrefix.PS3)
            {
                foreach (string driveName in FtpExtensions.GetFolderNames("/", false).ToArray())
                {
                    ComboBoxConsoleDrives.Properties.Items.Add(driveName.Replace(@"/", ""));
                }
            }
            else if (ConsoleType == ConsoleTypePrefix.XBOX)
            {
                ComboBoxConsoleDrives.Properties.Items.AddRange(MainWindow.XboxConsole.Drives.Split(','));
            }

            if (Settings.SaveLocalPath)
            {
                switch (ConsoleType)
                {
                case ConsoleTypePrefix.PS3:
                    if (Settings.ConsolePathPS3.Equals(@"\") || Settings.ConsolePathPS3.IsNullOrWhiteSpace())
                    {
                        LoadConsoleDirectory("/" + ComboBoxConsoleDrives.Properties.Items[0].ToString() + "/");
                    }
                    else
                    {
                        LoadConsoleDirectory(Settings.ConsolePathPS3);
                    }
                    break;

                case ConsoleTypePrefix.XBOX:
                    if (Settings.ConsolePathXBOX.Equals(@"\") || Settings.ConsolePathXBOX.IsNullOrWhiteSpace())
                    {
                        LoadConsoleDirectory("/" + ComboBoxConsoleDrives.Properties.Items[0].ToString() + "/");
                    }
                    else
                    {
                        LoadConsoleDirectory(Settings.ConsolePathXBOX);
                    }
                    break;
                }
            }
            else
            {
                LoadConsoleDirectory("/" + ComboBoxConsoleDrives.Properties.Items[0].ToString() + "/");
            }

            WaitLoadConsole.Enabled = false;
        }
Ejemplo n.º 6
0
        public void UploadLocalFile()
        {
            try
            {
                string type = GridViewLocalFiles.GetRowCellValue(GridViewLocalFiles.FocusedRowHandle, "Type").ToString();
                string name = GridViewLocalFiles.GetRowCellValue(GridViewLocalFiles.FocusedRowHandle, "Name").ToString();

                if (type.Equals("file"))
                {
                    string localPath   = TextBoxLocalPath.Text + name;
                    string consolePath = TextBoxConsolePath.Text + name;

                    if (File.Exists(localPath))
                    {
                        SetLocalStatus($"Uploading file to {consolePath}...");

                        if (ConsoleType == ConsoleTypePrefix.PS3)
                        {
                            FtpExtensions.UploadFile(localPath, consolePath);
                        }
                        else
                        {
                            XboxConsole.SendFile(localPath, consolePath);
                        }

                        SetLocalStatus($"Successfully uploaded file: {Path.GetFileName(localPath)}");
                        LoadConsoleDirectory(DirectoryPathConsole);
                    }
                    else
                    {
                        SetLocalStatus("Unable to upload file as it doesn't exist on your computer.");
                    }
                }
                else if (type.Equals("folder"))
                {
                    string localPath   = TextBoxLocalPath.Text + name + @"\";
                    string consolePath = TextBoxConsolePath.Text + name;

                    SetLocalStatus($"Uploading folder to {consolePath}...");
                    //FtpClient.UploadDirectory(localPath, consolePath, FtpFolderSyncMode.Update, FtpRemoteExists.Overwrite);
                    SetLocalStatus($"Successfully uploaded folder: {localPath}");
                    LoadConsoleDirectory(DirectoryPathConsole);
                }
            }
            catch (Exception ex)
            {
                SetLocalStatus($"Unable to upload to console. Error: {ex.Message}", ex);
            }
        }
Ejemplo n.º 7
0
        public void DownloadFromConsole()
        {
            try
            {
                var type = DgvConsoleFiles.CurrentRow.Cells[0].Value.ToString();
                var name = DgvConsoleFiles.CurrentRow.Cells[2].Value.ToString();

                if (type.Equals("file"))
                {
                    var consoleFile = TextBoxConsolePath.Text + DgvConsoleFiles.CurrentRow.Cells[2].Value;
                    var localFile   = TextBoxLocalPath.Text + DgvConsoleFiles.CurrentRow.Cells[2].Value;

                    if (File.Exists(localFile))
                    {
                        File.Delete(localFile);
                    }

                    SetConsoleStatus($"Downloading file: {Path.GetFileName(localFile)}");
                    FtpExtensions.DownloadFile(localFile, consoleFile);
                    //_ = MainWindow.FtpClient.DownloadFile(localFile, consoleFile);
                    SetConsoleStatus($"Successfully downloaded file: {Path.GetFileName(localFile)}");
                }
                else if (type.Equals("folder"))
                {
                    var consolePath = TextBoxConsolePath.Text + DgvConsoleFiles.CurrentRow.Cells[2].Value + "/";
                    var localPath   = TextBoxLocalPath.Text + DgvConsoleFiles.CurrentRow.Cells[2].Value;

                    if (Directory.Exists(localPath))
                    {
                        Directory.Delete(localPath, true);
                    }

                    SetConsoleStatus($"Downloading folder: {consolePath}");
                    //FtpExtensions.DownloadDirectory(consolePath, localPath);
                    FtpClient.DownloadDirectory(localPath, consolePath, FtpFolderSyncMode.Mirror, FtpLocalExists.Overwrite);
                    SetConsoleStatus($"Successfully downloaded folder to: {localPath}");
                }
            }
            catch (Exception ex)
            {
                SetConsoleStatus($"Error downloading console file. {ex.Message}", ex);
            }

            LoadLocalDirectory(LocalDirectoryPath);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Upload a selected package file from the computer to console's packages folder.
        /// </summary>
        private void InstallPackage()
        {
            string localFilePath = DialogExtensions.ShowOpenFileDialog(this, "Choose Package File", "PKG Files (*.pkg)|*.pkg");

            if (!string.IsNullOrWhiteSpace(localFilePath))
            {
                string fileName        = Path.GetFileName(localFilePath);
                string installFilePath = PackageFilesPath + "/" + fileName;

                if (FtpClient.FileExists(installFilePath))
                {
                    DarkMessageBox.ShowError("Package file with this name already exists on your console.", "Package File Exists");
                    return;
                }

                UpdateStatus("Installing package file: " + fileName);
                FtpExtensions.UploadFile(localFilePath, installFilePath);
                UpdateStatus("Successfully installed package file.");
                LoadPackages();
            }
        }
Ejemplo n.º 9
0
        public void UploadLocalFile()
        {
            try
            {
                var type      = DgvLocalFiles.CurrentRow.Cells[0].Value.ToString();
                var localName = DgvLocalFiles.CurrentRow.Cells[2].Value.ToString();

                if (type.Equals("file"))
                {
                    var localPath   = TextBoxLocalPath.Text + localName;
                    var consolePath = TextBoxConsolePath.Text + localName;

                    if (File.Exists(localPath))
                    {
                        SetLocalStatus($"Uploading file to {consolePath}...");
                        FtpExtensions.UploadFile(MainWindow.FtpConnection, localPath, consolePath);
                        SetLocalStatus($"Successfully uploaded file: {Path.GetFileName(localPath)}");
                        LoadConsoleDirectory(FtpDirectoryPath);
                    }
                    else
                    {
                        SetLocalStatus("Unable to upload file as it doesn't exist on your computer.");
                    }
                }
                else if (type.Equals("folder"))
                {
                    var localPath   = TextBoxLocalPath.Text + localName + @"\";
                    var consolePath = TextBoxConsolePath.Text + localName;

                    SetLocalStatus($"Uploading folder to {consolePath}...");
                    //MainWindow.FtpClient.UploadDirectory(localPath, consolePath, FtpFolderSyncMode.Update, FtpRemoteExists.Overwrite);
                    SetLocalStatus($"Successfully uploaded folder: {localPath}");
                    LoadConsoleDirectory(FtpDirectoryPath);
                }
            }
            catch (Exception ex)
            {
                SetLocalStatus($"Unable to upload to console. Error: {ex.Message}", ex);
            }
        }
Ejemplo n.º 10
0
        private void ToolStripConsoleNewFolder_Click(object sender, EventArgs e)
        {
            try
            {
                var folderName = DialogExtensions.ShowTextInputDialog(this, "Add New Folder", "Folder Name: ", "");

                if (folderName != null)
                {
                    _ = FtpExtensions.CreateDirectory(FtpDirectoryPath + "/" + folderName);
                    LoadConsoleDirectory(FtpDirectoryPath);
                }
            }
            catch (FtpException ex)
            {
                _ = DarkMessageBox.Show(this, $"Unable to create new folder. Error: {ex.Message}", "Error",
                                        MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                _ = DarkMessageBox.Show(this, $"Unable to create new folder. Error: {ex.Message}", "Error",
                                        MessageBoxIcon.Error);
            }
        }