コード例 #1
0
        /// <summary>
        /// The exit-with-save button saves the exclusion before closing the window
        /// </summary>
        private void Button_ExitWithSave_Click(object sender, EventArgs e)
        {
            switch (ValidateEntry())
            {
            case ErrorType.DUPLICATE:
                error = new ErrorPrompt(Errors.ERR_DUPL_EXCPTN);
                error.ShowDialog();
                break;

            case ErrorType.MISSING:
                error = new ErrorPrompt(Errors.ERR_MISSING_EXCPTN);
                error.ShowDialog();
                break;

            case ErrorType.VALID:
            default:
                if (isAdding)
                {
                    parent.CreateExclusion(Textbox_Name.Text, Checkbox_IsRecursive.Checked);
                }
                else
                {
                    parent.UpdatedEditedExclusion(Textbox_Name.Text, Checkbox_IsRecursive.Checked);
                }

                Close();
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// Applies globals to existing items unless there are errors
        /// </summary>
        private void Button_ApplyGlobals_Click(object sender, EventArgs e)
        {
            List <ArchivedItem> items = archivedItems.Values.ToList();
            ErrorType           errorType;

            if ((errorType = ValidateGlobalDestination(items, out List <string> duplicates)) != ErrorType.VALID)
            {
                error = new ErrorPrompt(Errors.ERR_GLOBAL_DUPL + string.Join("\n", duplicates));
                error.ShowDialog();
            }

            else
            {
                foreach (ArchivedItem item in items)
                {
                    item.password = Textbox_GlobalPassword.Text;
                    item.type     = (ArchiveType)Enum.Parse(
                        typeof(ArchiveType), Dropdown_GlobalFileType.SelectedItem.ToString());
                    item.compressionMethod = (CompressionMethod)Enum.Parse(
                        typeof(CompressionMethod), Dropdown_GlobalMethod.SelectedItem.ToString());
                    item.compressionLevel = (int)Numeric_CompLevel.Value;
                    item.destinationPath  = Textbox_GlobalDestination.Text;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Opens an error window when there's problems with a user action involving the list
        /// </summary>
        private void HandleListErrors()
        {
            if (List_ArchivedItems.Items.Count == 0)
            {
                error = new ErrorPrompt(Errors.ERR_NO_ITEMS_PRESENT);
            }

            else
            {
                error = new ErrorPrompt(Errors.ERR_NO_ITEM_SEL);
            }

            error.ShowDialog();
        }
コード例 #4
0
        /// <summary>
        /// When the Create Script button is clicked, create a script and display a window showing whether it succeeded or failed
        /// </summary>
        private void Button_CreateScript_Click(object sender, EventArgs e)
        {
            Exception ex = FileManagement.SaveFile(archivedItems.Values.ToList(), Textbox_BatchDestination.Text);

            if (ex != null)
            {
                error = new ErrorPrompt("Error: " + ex.Message);
                error.ShowDialog();
            }

            else
            {
                msg = new GeneralMessageForm("Created script successfully");
                msg.ShowDialog();
            }
        }
コード例 #5
0
        /// <summary>
        /// The exit-with-save button saves an item before closing the item editor as long as there are no errors
        /// </summary>
        private void Button_ExitWithSave_Click(object sender, EventArgs e)
        {
            ErrorType errorType;

            if ((errorType = VerifyRequiredFields(out List <string> invalidItems)) != ErrorType.VALID)
            {
                switch (errorType)
                {
                case ErrorType.DUPLICATE:
                    error = new ErrorPrompt(Errors.ERR_DUPL_ITEMS + string.Join("\n", invalidItems));
                    break;

                case ErrorType.INVALID:
                    error = new ErrorPrompt(Errors.ERR_INVALID_ITEMS + string.Join("\n", invalidItems) + Errors.HINT_INVALID_ITEMS);
                    break;

                case ErrorType.MISSING:
                    error = new ErrorPrompt(Errors.ERR_MISSING_ITEMS + string.Join("\n", invalidItems));
                    break;

                default:
                    break;
                }

                error.ShowDialog();
            }

            else
            {
                if (editingItem == null)
                {
                    ArchivedItem newItem = new ArchivedItem();
                    newItem.itemName        = Textbox_ItemName.Text;
                    newItem.sourcePath      = Textbox_SourcePath.Text;
                    newItem.destinationPath = Textbox_DestinationPath.Text;
                    newItem.fileName        = Textbox_FileName.Text;
                    newItem.password        = Textbox_Password.Text;

                    newItem.exclusions = new List <string>();
                    foreach (object o in List_Exclusions.Items)
                    {
                        newItem.exclusions.Add((string)o);
                    }
                    newItem.exclusionRecursiveDefinitions = exclusionRecursiveDefinitions;

                    newItem.type = (ArchiveType)Enum.Parse(
                        typeof(ArchiveType), Dropdown_FileType.SelectedItem.ToString());
                    newItem.compressionLevel  = (int)Numeric_CompLevel.Value;
                    newItem.compressionMethod = (CompressionMethod)Enum.Parse(
                        typeof(CompressionMethod), Dropdown_Method.SelectedItem.ToString());

                    parent.CreateItem(newItem);
                }

                else
                {
                    editingItem.itemName        = Textbox_ItemName.Text;
                    editingItem.sourcePath      = Textbox_SourcePath.Text;
                    editingItem.destinationPath = Textbox_DestinationPath.Text;
                    editingItem.fileName        = Textbox_FileName.Text;
                    editingItem.password        = Textbox_Password.Text;

                    editingItem.exclusions = new List <string>();
                    foreach (object o in List_Exclusions.Items)
                    {
                        editingItem.exclusions.Add((string)o);
                    }
                    editingItem.exclusionRecursiveDefinitions = exclusionRecursiveDefinitions;

                    editingItem.type = (ArchiveType)Enum.Parse(
                        typeof(ArchiveType), Dropdown_FileType.SelectedItem.ToString());
                    editingItem.compressionLevel  = (int)Numeric_CompLevel.Value;
                    editingItem.compressionMethod = (CompressionMethod)Enum.Parse(
                        typeof(CompressionMethod), Dropdown_Method.SelectedItem.ToString());

                    parent.UpdateEditedItem(editingItem);
                }

                Close();
            }
        }