btnEditTarget_Click( object sender, RoutedEventArgs e) { if (lbTargets.SelectedItem != null) { TargetCollection tc = configuration.CopyGroupInstance.CopyOperation.Targets; Target t = tc.Targets[lbTargets.SelectedValue.ToString()]; Regex r = new Regex("^ftp://.*/$"); AddTarget at = new AddTarget(AddTarget.Mode.Edit, r.IsMatch(t.Location) ? AddTarget.Type.Ftp : AddTarget.Type.Local); at.TargetName = t.Name; at.TargetLocation = t.Location; at.TargetAuthenticationCredential = t.AuthorizationCredential; if ((at.ShowDialog()).Value) { tc.RemoveTarget(t.Name); lbTargets.Items.RemoveAt(lbTargets.SelectedIndex); tc.AddTarget(at.TargetName, at.TargetLocation, at.TargetAuthenticationCredential); lbTargets.Items.Add(at.TargetName); } } }
btnAddFtpTarget_Click( object sender, RoutedEventArgs e) { AddTarget at = new AddTarget(AddTarget.Mode.Edit, AddTarget.Type.Ftp); if (at.ShowDialog().Value) { TargetCollection tc = configuration.CopyGroupInstance.CopyOperation.Targets; tc.AddTarget(at.TargetName, at.TargetLocation, at.TargetAuthenticationCredential); lbTargets.Items.Add(at.TargetName); } }