public TaskDialog(MirrorTask task) { if (task == null) { throw new ArgumentNullException("task"); } _task = task; InitializeComponent(); var boldFont = new System.Drawing.Font(Font, System.Drawing.FontStyle.Bold); sourceLabel.Font = boldFont; targetLabel.Font = boldFont; var sourceFileDropTargetWrapper = new FileDropTargetWrapper(sourceFolderTextBox, FileDropMode.Folder); sourceFileDropTargetWrapper.FilesDropped += (s, e) => { sourceFolderTextBox.Text = e.Paths[0]; }; var targetFileDropTargetWrapper = new FileDropTargetWrapper(targetFolderTextBox, FileDropMode.Folder); targetFileDropTargetWrapper.FilesDropped += (s, e) => { targetFolderTextBox.Text = e.Paths[0]; }; // set up the source if (!string.IsNullOrEmpty(_task.Source)) { sourceFolderTextBox.Text = _task.Source; } vscCheckBox.Checked = _task.UseVolumeShadowCopy; // set up the target if (!string.IsNullOrEmpty(_task.Target)) { targetFolderTextBox.Text = _task.Target; } if (!string.IsNullOrEmpty(_task.ExtendedAttributes)) { if (_task.ExtendedAttributes == "S") { aclsOnlyRadioButton.Checked = true; } else if (_task.ExtendedAttributes.Length == 3) { allRadioButton.Checked = true; } } overwriteNewerFilesCheckBox.Checked = _task.OverwriteNewerFiles; deleteExtraItemsCheckBox.Checked = _task.DeleteExtraItems; if (!string.IsNullOrEmpty(_task.CustomRobocopySwitches)) { robocopySwitchesCheckBox.Checked = true; robocopySwitchesTextBox.Text = _task.CustomRobocopySwitches; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (DesignMode) { return; } if (string.IsNullOrEmpty(BaseFolder)) { throw new InvalidOperationException("The BaseFolder property has not been set yet."); } var fileDropTargetWrapper = new FileDropTargetWrapper(listBox, Mode == ExcludedItemsMode.Folders ? FileDropMode.Folders : FileDropMode.Files); fileDropTargetWrapper.FilesDropped += (s, ea) => { if (!TryAddItems(ea.Paths)) { MessageBox.Show(this, "A dropped item is not contained in the source folder.", "Invalid item", MessageBoxButtons.OK, MessageBoxIcon.Error); } }; toolTip.SetToolTip(browseButton, Mode == ExcludedItemsMode.Folders ? "Add a specific subfolder to be excluded with all of its contents." : "Add specific files to be excluded."); toolTip.SetToolTip(wildcardTextBox, Mode == ExcludedItemsMode.Folders ? "Enter a wildcard, e.g. \"temp*\" or \"obj\"." : "Enter a wildcard, e.g. \"*.tmp\" or \"thumbs.db\"."); toolTip.SetToolTip(addWildcardButton, Mode == ExcludedItemsMode.Folders ? "Add the wildcard above to the list.\nAll subfolders with a matching name will be excluded with all of their contents." : "Add the wildcard above to the list.\nAll files with a matching name will be excluded from each folder."); // add a wildcard by pressing Enter wildcardTextBox.KeyPress += (s, ea) => { if (ea.KeyChar == 13 && wildcardTextBox.TextLength > 0) { addWildcardButton.PerformClick(); } }; }