public PrimaryOptionsControl([NotNull] Lifetime lifetime, OptionsSettingsSmartContext settings) { _settings = settings; InitializeComponent(); groupBoxUserDictionary.Text = ResourceAccessor.GetString("UI_UserDictionaryListTitle") ?? "User Dictionary"; groupBoxIgnoredWords.Text = ResourceAccessor.GetString("UI_IgnoredWordListTitle") ?? "Ignored Words"; // Extract the string keys from the settings and apply them to the UI list boxes. UserWords.Initialize( settings.EnumEntryIndices <SpellCheckSettings, string, byte>(x => x.UserEntries) .ToArray() ); IgnoreWords.Initialize( settings.EnumEntryIndices <SpellCheckSettings, string, byte>(x => x.IgnoreEntries) .ToArray() ); // Monitor the changed properties on the UI list boxes and when changed apply the modifications to the settings collection to be saved. var userWordsProperty = WinFormsProperty.Create(lifetime, UserWords, x => x.CurrentItems, true); userWordsProperty.Change.Advise_NoAcknowledgement(lifetime, x => ApplyChanges(settings, UserWords, p => p.UserEntries)); var ignoreWordsProperty = WinFormsProperty.Create(lifetime, IgnoreWords, x => x.CurrentItems, true); ignoreWordsProperty.Change.Advise_NoAcknowledgement(lifetime, x => ApplyChanges(settings, IgnoreWords, p => p.IgnoreEntries)); ResetDictionariesGrid(settings); }
public GistOptionsPage([NotNull] Lifetime lifetime, DataContexts dataContexts, GitHubService gitHubService, OptionsSettingsSmartContext settings) : base(lifetime, Pid) { if (lifetime == null) { throw new ArgumentNullException("lifetime"); } myGitHubService = gitHubService; myEmptyDataContext = dataContexts.Empty; TextBox usernameBox; System.Windows.Forms.TextBox passwordBox; Control = InitView(out usernameBox, out passwordBox); settings.SetBinding(lifetime, (GitHubSettings s) => s.Username, usernameBox, TextBox.TextProperty); settings.SetBinding(lifetime, (GitHubSettings s) => s.Password, WinFormsProperty.Create(lifetime, passwordBox, box => box.Text, true)); }
/// <summary> /// Initializes a new instance of the <see cref="CodeAnnotationsOptionsPage"/> class. /// </summary> /// <param name="lifetime"> /// The lifetime. /// </param> /// <param name="settings"> /// The settings. /// </param> public CodeAnnotationsOptionsPage(Lifetime lifetime, OptionsSettingsSmartContext settings) { this.InitializeComponent(); settings.SetBinding(lifetime, (CodeAnnotationPackSettings s) => s.PublicAssertion, WinFormsProperty.Create(lifetime, this.PublicAssertion, box => box.Text, true)); settings.SetBinding(lifetime, (CodeAnnotationPackSettings s) => s.NonPublicAssertion, WinFormsProperty.Create(lifetime, this.NonPublicAssertion, box => box.Text, true)); settings.SetBinding(lifetime, (CodeAnnotationPackSettings s) => s.AlternativeAssertions, WinFormsProperty.Create(lifetime, this.AlternativeAssertions, box => box.Text, true)); }