/// <summary> /// Handles the OverwriteOlder button's Click event. /// </summary> /// <param name="sender">The button object.</param> /// <param name="e">The event arguments.</param> private void btnOverwriteOlder_Click(object sender, System.EventArgs e) { _args.NextAction = TransferConfirmNextActions.CheckAndOverwriteOlderFiles; _overwriteOlder = true; _args = null; Close(); }
/// <summary> /// Shows the form. /// </summary> /// <param name="parent">The parent form.</param> /// <param name="evt">The event arguments.</param> public void Show(Form parent, TransferConfirmEventArgs evt) { // If it's in the skipped type list, skip it. if (_skipTypes.ContainsKey(evt.ConfirmReason)) { evt.NextAction = TransferConfirmNextActions.Skip; return; } // If the problem is file already exists? if (evt.ConfirmReason == TransferConfirmReason.FileAlreadyExists) { // Overwrite all? if (_overwriteAll) { evt.NextAction = TransferConfirmNextActions.Overwrite; return; } // Overwrite if files have different sizes? if (_overwriteDifferentSize) { evt.NextAction = TransferConfirmNextActions.CheckAndOverwriteFilesWithDifferentSizes; return; } // Overwrite older files? if (_overwriteOlder) { evt.NextAction = TransferConfirmNextActions.CheckAndOverwriteOlderFiles; return; } // format the text according to TransferState (Downloading or Uploading) const string messageFormat = Messages.OverwriteFileConfirm; txtMessage.Text = string.Format(messageFormat, evt.DestinationFileInfo.FullName, evt.DestinationFileInfo.Length, evt.DestinationFileInfo.LastWriteTime, evt.SourceFileInfo.FullName, evt.SourceFileInfo.Length, evt.SourceFileInfo.LastWriteTime); } else { Exception ex = evt.Exception; while (ex.InnerException != null) { ex = ex.InnerException; } // Show the exception message. txtMessage.Text = evt.Message + "\r\nReason: " + ex.Message; } _args = evt; // Only show available action buttons. ArrangeButtons(evt); ShowDialog(parent); }
/// <summary> /// Handles the OverwriteDiffSize button's Click event. /// </summary> /// <param name="sender">The button object.</param> /// <param name="e">The event arguments.</param> private void btnOverwriteDiffSize_Click(object sender, System.EventArgs e) { _args.NextAction = TransferConfirmNextActions.CheckAndOverwriteFilesWithDifferentSizes; _overwriteDifferentSize = true; _args = null; Close(); }
private void btnFollowLinkAll_Click(object sender, System.EventArgs e) { _args.NextAction = TransferConfirmNextActions.FollowLink; _followAllLinks = true; _args = null; // Release mem Close(); }
/// <summary> /// Handles the OverwriteAll button's Click event. /// </summary> /// <param name="sender">The button object.</param> /// <param name="e">The event arguments.</param> private void btnOverwriteAll_Click(object sender, System.EventArgs e) { _args.NextAction = TransferConfirmNextActions.Overwrite; _overwriteAll = true; _args = null; Close(); }
private void btnResumeAll_Click(object sender, System.EventArgs e) { _args.NextAction = TransferConfirmNextActions.ResumeFileTransfer; _resumeAll = true; _args = null; // Release mem Close(); }
private void btnCancel_Click(object sender, System.EventArgs e) { _args.NextAction = TransferConfirmNextActions.Cancel; _cancelAll = true; _args = null; // Release mem Close(); }
/// <summary> /// Handles the Skip All button's Click event. /// </summary> /// <param name="sender">The button object.</param> /// <param name="e">The event arguments.</param> private void btnSkipAll_Click(object sender, System.EventArgs e) { _skipTypes.Add(_args.ConfirmReason, null); _args.NextAction = TransferConfirmNextActions.Skip; _args = null; Close(); }
/// <summary> /// Handles the Rename button's Click event. /// </summary> /// <param name="sender">The button object.</param> /// <param name="e">The event arguments.</param> private void btnRename_Click(object sender, System.EventArgs e) { string oldName = _args.DestinationFileSystem.GetFileName(_args.DestinationFileInfo.Name); NewNamePrompt formNewName = new NewNamePrompt(oldName); DialogResult result = formNewName.ShowDialog(this); string newName = formNewName.NewName; if (result != DialogResult.OK || newName.Length == 0 || newName == oldName) { return; } _args.NextAction = TransferConfirmNextActions.Rename; _args.NewName = newName; _args = null; Close(); }
/// <summary> /// Arranges buttons. /// </summary> /// <param name="evt">The event arguments.</param> private void ArrangeButtons(TransferConfirmEventArgs evt) { int buttonHeight = 0; int y = txtMessage.Top; foreach (KeyValuePair <System.Windows.Forms.Button, TransferConfirmNextActions> en in _btns) { bool b = evt.CanPerform(en.Value); en.Key.Visible = b; if (buttonHeight == 0) { buttonHeight = en.Key.Height; } if (!b) { continue; } en.Key.Top = y; y += buttonHeight + 3; } }
private void ArrangeButtons(TransferConfirmEventArgs evt) { const int buttonHeight = 24; const int buttonWidth = 128; const int gap = 3; int buttons = 0; foreach (KeyValuePair <System.Windows.Forms.Button, TransferConfirmNextActions> en in _btns) { bool b = evt.CanPerform(en.Value); en.Key.Visible = b; if (b) { buttons++; } } int count = this.ClientSize.Width / (buttonWidth + gap); int y = this.ClientSize.Height - (buttonHeight + gap) * ((buttons / count) + ((buttons % count) == 0 ? 0 : 1)) - 4; int x = (this.ClientSize.Width - count * buttonWidth - gap) / 2; int i = 0; foreach (KeyValuePair <System.Windows.Forms.Button, TransferConfirmNextActions> en in _btns) { bool b = evt.CanPerform(en.Value); en.Key.Visible = b; if (b) { en.Key.Left = x + (buttonWidth + gap) * (i % count); en.Key.Top = y + (buttonHeight + gap) * (i / count); i++; } } }
private void client_TransferConfirm(object sender, TransferConfirmEventArgs e) { _view.AskOverwrite(e); }
/// <summary> /// Handles the Follow Link button's Click event. /// </summary> /// <param name="sender">The button object.</param> /// <param name="e">The event arguments.</param> private void btnFollowLink_Click(object sender, System.EventArgs e) { _args.NextAction = TransferConfirmNextActions.FollowLink; _args = null; Close(); }
/// <summary> /// Handles the Retry button's Click event. /// </summary> /// <param name="sender">The button object.</param> /// <param name="e">The event arguments.</param> private void btnRetry_Click(object sender, System.EventArgs e) { _args.NextAction = TransferConfirmNextActions.Retry; _args = null; Close(); }
public void Show(Form parent, TransferConfirmEventArgs evt) { if (_skipTypes.ContainsKey(evt.ConfirmReason)) { evt.NextAction = TransferConfirmNextActions.Skip; return; } if (evt.ConfirmReason == TransferConfirmReason.FileAlreadyExists) { if (_overwriteAll) { evt.NextAction = TransferConfirmNextActions.Overwrite; return; } if (_overwriteDifferentSize) { evt.NextAction = TransferConfirmNextActions.CheckAndOverwriteFilesWithDifferentSizes; return; } if (_overwriteOlder) { evt.NextAction = TransferConfirmNextActions.CheckAndOverwriteOlderFiles; return; } if (_resumeAll && (evt.PossibleNextActions & TransferConfirmNextActions.ResumeFileTransfer) != 0) { evt.NextAction = TransferConfirmNextActions.ResumeFileTransfer; return; } // format the text according to TransferState (Downloading or Uploading) const string messageFormat = "Are you sure you want to overwrite file: {0}\r\n{1} Bytes, {2}\r\n\r\nWith file: {3}\r\n{4} Bytes, {5}"; lblMessage.Text = string.Format(messageFormat, evt.DestinationFileInfo.FullName, evt.DestinationFileInfo.Length, evt.DestinationFileInfo.LastWriteTime, evt.SourceFileInfo.FullName, evt.SourceFileInfo.Length, evt.SourceFileInfo.LastWriteTime); Text = "File already exists"; } else { if (evt.Exception != null) { lblMessage.Text = evt.Exception.Message; if (evt.Exception.InnerException != null) { lblMessage.Text += "\r\nReason: " + evt.Exception.InnerException.Message; } } else { if (_followAllLinks && (evt.PossibleNextActions & TransferConfirmNextActions.FollowLink) != 0) { evt.NextAction = TransferConfirmNextActions.FollowLink; return; } lblMessage.Text = evt.Message; } Text = "An error occurred"; } _oldEvt = evt; ArrangeButtons(evt); this.ShowDialog(parent); }
private void btnOverwrite_Click(object sender, System.EventArgs e) { _args.NextAction = TransferConfirmNextActions.Overwrite; _args = null; // Release mem Close(); }