/// <summary>
 ///     Executes the current extension.
 /// </summary>
 /// <param name="shell">The <see cref="IShell" /> object on which the current extension will be executed.</param>
 protected override async void DoExecute(IShell shell)
 {
     try
     {
         var setting = this.SettingProvider.GetExtensionSetting<ImportFromWebSetting>();
         var dialog = new ImportFromWebDialog(setting);
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             var title = HtmlUtilities.ExtractTitle(dialog.HtmlContent);
             if (string.IsNullOrEmpty(title) || shell.ExistingNotesTitle.Contains(title))
             {
                 var titleInputDialog = new TextInputBox(Resources.ImportFromWebInputTitleText,
                     Resources.ImportFromWebInputTitlePrompt, title,
                     new[]
                     {
                         new Tuple<Func<string, bool>, string>(string.IsNullOrEmpty,
                             Resources.ImportFromWebEmptyTitleErrorMsg),
                         new Tuple<Func<string, bool>, string>(shell.ExistingNotesTitle.Contains,
                             Resources.ImportFromWebDuplicatedTitleErrorMsg)
                     });
                 if (titleInputDialog.ShowDialog() == DialogResult.OK)
                 {
                     title = titleInputDialog.InputText;
                 }
                 else
                 {
                     return;
                 }
             }
             await shell.ImportNote(new Note
             {
                 Title = title,
                 Content = dialog.HtmlContent
             });
         }
     }
     catch (Exception ex)
     {
         FrmExceptionDialog.ShowException(ex);
     }
 }
Beispiel #2
0
 /// <summary>
 ///     Executes the current extension.
 /// </summary>
 /// <param name="shell">The <see cref="IShell" /> object on which the current extension will be executed.</param>
 protected override async void DoExecute(IShell shell)
 {
     try
     {
         var setting = this.SettingProvider.GetExtensionSetting <ImportFromWebSetting>();
         var dialog  = new ImportFromWebDialog(setting);
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             var title = HtmlUtilities.ExtractTitle(dialog.HtmlContent);
             if (string.IsNullOrEmpty(title) || shell.ExistingNotesTitle.Contains(title))
             {
                 var titleInputDialog = new TextInputBox(Resources.ImportFromWebInputTitleText,
                                                         Resources.ImportFromWebInputTitlePrompt, title,
                                                         new[]
                 {
                     new Tuple <Func <string, bool>, string>(string.IsNullOrEmpty,
                                                             Resources.ImportFromWebEmptyTitleErrorMsg),
                     new Tuple <Func <string, bool>, string>(shell.ExistingNotesTitle.Contains,
                                                             Resources.ImportFromWebDuplicatedTitleErrorMsg)
                 });
                 if (titleInputDialog.ShowDialog() == DialogResult.OK)
                 {
                     title = titleInputDialog.InputText;
                 }
                 else
                 {
                     return;
                 }
             }
             await shell.ImportNote(new Note
             {
                 Title   = title,
                 Content = dialog.HtmlContent
             });
         }
     }
     catch (Exception ex)
     {
         FrmExceptionDialog.ShowException(ex);
     }
 }