示例#1
0
    /// <summary>
    /// Synchronizes the notes with the online data store.
    /// </summary>
    private void SynchronizeOnlineNotes(bool showUserInterface) {
      if (synchronizer_ != null) return;
      if (preferences_.SynchronizeSettings == null) return;

      // Load the note objects from the note forms
      List<Note> notes = new List<Note>();
      foreach (NoteForm form in noteForms_) {
        // TODO: Copy note to avoid synchronization problems
        notes.Add(form.Note);
      }

      // Synchronize the notes with or without a user interface
      synchronizer_ = new SynchronizeNotesOperation(preferences_.SynchronizeSettings, notes);
      if (showUserInterface) {
        NetworkActivityDialog dialog = new NetworkActivityDialog(Messages.SynchronizationProgress, synchronizer_);
        dialog.StartPosition = FormStartPosition.Manual;
        dialog.Location = Control.MousePosition;
        if (dialog.ShowDialog() == DialogResult.OK) {
          OnSynchronizeNotesComplete(true);
        } else {
          synchronizer_ = null;
        }
      } else {
        synchronizer_.RunAsynchronously(this, new System.Threading.ThreadStart(this.OnSynchronizeNotesComplete));
      }
    }
 private void synchronizationButton__Click(object sender, EventArgs e) {
   synchronizationErrorLabel_.Text = "";
   TestSynchronizationOperation operation = new TestSynchronizationOperation(new SynchronizationSettings(amazonAccessKeyIdTextBox_.Text, amazonSecretAccessKeyTextBox_.Text));
   NetworkActivityDialog dialog = new NetworkActivityDialog(Messages.SynchronizationTesting, operation);
   if (dialog.ShowDialog(this) == DialogResult.OK) {
     if (operation.Exception != null) {
       synchronizationErrorLabel_.Text = operation.Exception.Message;
       synchronizationErrorLabel_.ForeColor = Color.DarkRed;
     } else {
       synchronizationErrorLabel_.Text = Messages.SynchronizationTestSuccess;
       synchronizationErrorLabel_.ForeColor = SystemColors.ControlText;
     }
   }
 }