WPFToolbar(ToolBar toolbar) : base(toolbar) { this.toolbar = toolbar; toolbar.ConfigurationMenu.SelectionChanged += (o, e) => { var comboMenu = (ComboMenu <IConfigurationModel>)o; var newModel = e.Added; if (newModel == null) { return; } Runtime.RunInMainThread(() => { ActiveConfiguration = newModel; ConfigurationChanged?.Invoke(o, e); }); }; toolbar.RunConfigurationMenu.SelectionChanged += (o, e) => { var comboMenu = (ComboMenu <IRunConfigurationModel>)o; var newModel = e.Added; if (newModel == null) { return; } Runtime.RunInMainThread(() => { ActiveRunConfiguration = newModel; RunConfigurationChanged?.Invoke(o, e); }); }; toolbar.RuntimeMenu.SelectionChanged += (o, e) => { var newModel = e.Added; if (newModel == null) { return; } using (var mutableModel = newModel.GetMutableModel()) { Runtime.RunInMainThread(() => { ActiveRuntime = newModel; var ea = new MonoDevelop.Components.MainToolbar.HandledEventArgs(); RuntimeChanged?.Invoke(o, ea); if (ea.Handled) { ActiveRuntime = e.Removed; } }); } }; toolbar.RunButton.Click += (o, e) => { if (RunButtonClicked != null) { RunButtonClicked(o, e); } }; toolbar.SearchBar.SearchBar.TextChanged += (o, e) => { if (SearchText == SearchPlaceholderMessage) { return; } if (SearchEntryChanged != null) { SearchEntryChanged(o, e); } }; toolbar.SearchBar.SearchBar.LostKeyboardFocus += (o, e) => { if (SearchEntryLostFocus != null) { SearchEntryLostFocus(o, e); } toolbar.SearchBar.SearchText = toolbar.SearchBar.PlaceholderText; }; toolbar.SearchBar.SearchBar.GotKeyboardFocus += (o, e) => { SearchEntryActivated?.Invoke(o, e); }; toolbar.SearchBar.SearchBar.SizeChanged += (o, e) => { if (SearchEntryResized != null) { SearchEntryResized(o, e); } }; toolbar.SearchBar.SearchBar.PreviewKeyDown += (o, e) => { var ka = new KeyEventArgs(KeyboardUtil.TranslateToXwtKey(e.Key), KeyboardUtil.GetModifiers(), e.IsRepeat, e.Timestamp); SendKeyPress(ka); e.Handled = ka.Handled; }; toolbar.SearchBar.ClearIconClicked += (o, e) => { SendKeyPress(new KeyEventArgs(Xwt.Key.Escape, KeyboardUtil.GetModifiers(), false, 0)); }; }