예제 #1
0
        /// <summary>
        /// Triggered when the list view needs to display an item.
        /// </summary>
        /// <param name="sender">The list view.</param>
        /// <param name="e">Event argument.</param>
        private void data_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
        {
            IErasureTarget target = task.Targets[e.ItemIndex];

            e.Item = new ListViewItem(PathUtil.GetCompactPath(target.ToString(),
                                                              data.Columns[0].Width, data.Font));
            e.Item.ToolTipText = target.ToString();

            e.Item.SubItems.Add(target.Method == ErasureMethodRegistrar.Default ?
                                S._("(default)") : target.Method.Name);
        }
예제 #2
0
        public bool SaveTo(IErasureTarget target)
        {
            UnusedSpaceErasureTarget unused = target as UnusedSpaceErasureTarget;

            if (unused == null)
            {
                throw new ArgumentException("The provided erasure target type is not " +
                                            "supported by this configurer.");
            }

            unused.Drive            = ((DriveItem)unusedDisk.SelectedItem).Drive;
            unused.EraseClusterTips = unusedClusterTips.Checked;
            return(true);
        }
예제 #3
0
        /// <summary>
        /// Generated when the user double-clicks an item in the list-view.
        /// </summary>
        /// <param name="sender">The list-view which generated this event.</param>
        /// <param name="e">Event argument.</param>
        private void data_ItemActivate(object sender, EventArgs e)
        {
            using (TaskDataSelectionForm form = new TaskDataSelectionForm())
            {
                form.Target = task.Targets[data.SelectedIndices[0]];

                if (form.ShowDialog() == DialogResult.OK)
                {
                    IErasureTarget target = form.Target;
                    task.Targets.RemoveAt(data.SelectedIndices[0]);
                    task.Targets.Insert(data.SelectedIndices[0], target);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Triggered when the user clicks on the Add Data button.
        /// </summary>
        /// <param name="sender">The button.</param>
        /// <param name="e">Event argument.</param>
        private void dataAdd_Click(object sender, EventArgs e)
        {
            using (TaskDataSelectionForm form = new TaskDataSelectionForm())
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    IErasureTarget target = form.Target;
                    task.Targets.Add(target);
                    errorProvider.Clear();

                    ++data.VirtualListSize;
                }
            }
        }
        public bool SaveTo(IErasureTarget target)
        {
            SecureMoveErasureTarget secureMove = target as SecureMoveErasureTarget;

            if (secureMove == null)
            {
                throw new ArgumentException("The provided erasure target type is not " +
                                            "supported by this configurer.");
            }

            secureMove.Path        = fromTxt.Text;
            secureMove.Destination = toTxt.Text;
            return(true);
        }
        public void LoadFrom(IErasureTarget target)
        {
            SecureMoveErasureTarget secureMove = target as SecureMoveErasureTarget;

            if (secureMove == null)
            {
                throw new ArgumentException("The provided erasure target type is not " +
                                            "supported by this configurer.");
            }

            fromTxt.Text = secureMove.Path;
            toTxt.Text   = secureMove.Destination;

            moveFolderRadio.Checked =
                File.Exists(secureMove.Path) || Directory.Exists(secureMove.Path) &&
                (File.GetAttributes(secureMove.Path) & FileAttributes.Directory) != 0;
        }
예제 #7
0
        public void LoadFrom(IErasureTarget target)
        {
            UnusedSpaceErasureTarget unused = target as UnusedSpaceErasureTarget;

            if (unused == null)
            {
                throw new ArgumentException("The provided erasure target type is not " +
                                            "supported by this configurer.");
            }

            foreach (object item in unusedDisk.Items)
            {
                if (((DriveItem)item).Drive == unused.Drive)
                {
                    unusedDisk.SelectedItem = item;
                }
            }
            unusedClusterTips.Checked = unused.EraseClusterTips;
        }
예제 #8
0
        public bool SaveTo(IErasureTarget target)
        {
            DriveErasureTarget partition = target as DriveErasureTarget;

            if (partition == null)
            {
                throw new ArgumentException("The provided erasure target type is not " +
                                            "supported by this configurer.");
            }

            PartitionItem item = (PartitionItem)partitionCmb.SelectedItem;

            //Make sure we don't set both Volume and PhysicalDrive
            partition.PhysicalDrive = null;

            //Then set the proper values.
            partition.Volume        = item.Volume;
            partition.PhysicalDrive = item.PhysicalDrive;
            return(true);
        }
예제 #9
0
        public void LoadFrom(IErasureTarget target)
        {
            DriveErasureTarget partition = target as DriveErasureTarget;

            if (partition == null)
            {
                throw new ArgumentException("The provided erasure target type is not " +
                                            "supported by this configurer.");
            }

            foreach (PartitionItem item in partitionCmb.Items)
            {
                if ((item.PhysicalDrive != null &&
                     item.PhysicalDrive.Equals(partition.PhysicalDrive)) ||
                    (item.Volume != null && item.Volume.Equals(partition.Volume)))
                {
                    partitionCmb.SelectedItem = item;
                    break;
                }
            }
        }
예제 #10
0
 public ErasureType(IErasureTarget target)
 {
     Target = target;
 }
예제 #11
0
        /// <summary>
        /// Parses the command line for erasure targets and returns them as
        /// a Task object.
        /// </summary>
        /// <param name="arguments">The arguments specified on the command line.</param>
        /// <returns>The task represented on the command line.</returns>
        private static Task TaskFromCommandLine(TaskArguments arguments)
        {
            //Create the task
            Task task = new Task();

            //Get the erasure method the user wants to use
            IErasureMethod method = string.IsNullOrEmpty(arguments.ErasureMethod) ?
                                    ErasureMethodRegistrar.Default :
                                    ErasureMethodFromNameOrGuid(arguments.ErasureMethod);

            //Define the schedule
            if (!string.IsNullOrEmpty(arguments.Schedule))
            {
                switch (arguments.Schedule.ToUpperInvariant())
                {
                case "NOW":
                    task.Schedule = Schedule.RunNow;
                    break;

                case "MANUALLY":
                    task.Schedule = Schedule.RunManually;
                    break;

                case "RESTART":
                    task.Schedule = Schedule.RunOnRestart;
                    break;

                default:
                    throw new ArgumentException(
                              S._("Unknown schedule type: {0}", arguments.Schedule), "/schedule");
                }
            }

            //Parse the rest of the command line parameters as target expressions.
            foreach (string argument in arguments.PositionalArguments)
            {
                IErasureTarget selectedTarget = null;

                //Iterate over every defined erasure target
                foreach (IErasureTarget target in Host.Instance.ErasureTargetFactories)
                {
                    //See if this argument can be handled by the target's configurer
                    IErasureTargetConfigurer configurer = target.Configurer;
                    if (configurer.ProcessArgument(argument))
                    {
                        //Check whether a target has been set (implicitly: check whether two
                        //configurers can process the argument)
                        if (selectedTarget == null)
                        {
                            configurer.SaveTo(target);
                            selectedTarget = target;
                        }
                        else
                        {
                            //Yes, it is an ambiguity. Throw an error.
                            throw new ArgumentException(S._("Ambiguous argument: {0} can be " +
                                                            "handled by more than one erasure target.", argument));
                        }
                    }
                }

                //Check whether a target has been made from parsing the entry.
                if (selectedTarget == null)
                {
                    Console.WriteLine(S._("Unknown argument: {0}, skipped.", argument));
                }
                else
                {
                    selectedTarget.Method = method;
                    task.Targets.Add(selectedTarget);
                }
            }

            //Check the number of tasks in the task.
            if (task.Targets.Count == 0)
            {
                throw new ArgumentException(S._("Tasks must contain at least one erasure target."));
            }

            return(task);
        }