Source

Resharper Spell Checker / ReSpeller / Actions / AddArbitraryWordHelper.cs

Full commit
using System;
using System.Linq;
using System.Windows.Forms;
using JetBrains.Application;
using JetBrains.CommonControls.Validation;
using JetBrains.UI.Application;
using JetBrains.UI.CommonDialogs;
using JetBrains.UI.Components;
using ReSpeller.SpellEngine;

namespace ReSpeller.Actions
{
  static internal class AddArbitraryWordHelper
  {
    public static void ShowWordInput(string defaultWord)
    {
      using (PromptWinForm promptWinForm = new PromptWinForm(null, "Add word to dictionary", "Word:", defaultWord,
                                                             arg =>
                                                               {
                                                                 if (arg.Length == 0)
                                                                   return "Word can not be empty";
                                                                 if (arg.Any(c => !Char.IsLetter(c)))
                                                                   return "Only letters are permitted";
                                                                 return (string) null;
                                                               }, Shell.Instance.GetComponent<IApplicationDescriptor>(),
                                                             Shell.Instance.GetComponent<WindowsMessageHookManager>(),
                                                             Shell.Instance.GetComponent<FormValidators>()
#if RS8
                                                             ,Shell.Instance.GetComponent<UIApplicationEnvironment>()
#endif
                                                             ))
      {
        promptWinForm.FormBorderStyle = FormBorderStyle.FixedDialog;
        if (promptWinForm.ShowDialog())
        {
          Shell.Instance.GetComponent<ISingleLanguageWordStorage>().AddWordToUserDict(promptWinForm.Value);
        }
      }
    }
  }
}