/// <summary> /// OK /// </summary> public void Ok() { this.TabItems.ForEach(x => x.Validate()); var tabItem = this.TabItems.Where(x => x.HasErrors).FirstOrDefault(); if (tabItem != null) { this.SelectedItem = tabItem; this.SelectedItem.Messenger.Raise(new InteractionMessage(this.SelectedItem.GetErrorProperties().First() + ".Focus")); return; } this.TabItems.ForEach(x => x.Apply()); this.applicationAction.CreateShortcut(); // アクションを再登録する this.applicationAction.DeregisterActions(); if (!this.applicationAction.RegisterActions()) { // ショートカットの登録に失敗した場合、変更確認をして再度設定させる this.SelectedItem = this.ShortcutKey; return; } this.Close(); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="hookService">フックサービス</param> /// <param name="applicationAction">アクションサービス</param> public SettingsWindowViewModel(HookService hookService, ApplicationAction applicationAction) { this.TabItems = new List <SettingsBaseViewModel> { (this.General = new GeneralViewModel().AddTo(this)), (this.Output = new OutputViewModel().AddTo(this)), (this.ShortcutKey = new ShortcutKeyViewModel().AddTo(this)), (this.VersionInfo = new VersionInfoViewModel().AddTo(this)), }; this.SelectedItem = this.TabItems.FirstOrDefault(); this.hookService = hookService; this.applicationAction = applicationAction; }