public void SetAutocompleteMenu(Control control, AutocompleteMenu menu) { if (menu != null) { var wrapper = menu.CreateWrapper(control); if (wrapper == null) { return; } // menu.SubscribeForm(wrapper); AutocompleteMenuByControls[control] = this; // wrapper.LostFocus += menu.control_LostFocus; wrapper.Scroll += menu.control_Scroll; wrapper.KeyDown += menu.control_KeyDown; wrapper.MouseDown += menu.control_MouseDown; } else { AutocompleteMenuByControls.TryGetValue(control, out menu); AutocompleteMenuByControls.Remove(control); ITextBoxWrapper wrapper = null; WrapperByControls.TryGetValue(control, out wrapper); WrapperByControls.Remove(control); if (wrapper != null && menu != null) { wrapper.LostFocus -= menu.control_LostFocus; wrapper.Scroll -= menu.control_Scroll; wrapper.KeyDown -= menu.control_KeyDown; wrapper.MouseDown -= menu.control_MouseDown; } } }
public void SetAutocompleteMenu(Control control, AutocompleteMenu menu) { if (menu != null) { if (WrapperByControls.ContainsKey(control)) { var wrapper = WrapperByControls[control]; if (wrapper == null) { return; } // if (control.IsHandleCreated) { menu.SubscribeForm(wrapper); } else { control.HandleCreated += (o, e) => menu.SubscribeForm(wrapper); } // AutocompleteMenuByControls[control] = this; // UnsubscribeWrapper(wrapper, menu); SubscribeWrapper(wrapper, menu); } else { var wrapper = menu.CreateWrapper(control); if (wrapper == null) { return; } // if (control.IsHandleCreated) { menu.SubscribeForm(wrapper); } else { control.HandleCreated += (o, e) => menu.SubscribeForm(wrapper); } // AutocompleteMenuByControls[control] = this; // UnsubscribeWrapper(wrapper, menu); SubscribeWrapper(wrapper, menu); } } else { AutocompleteMenuByControls.TryGetValue(control, out menu); AutocompleteMenuByControls.Remove(control); ITextBoxWrapper wrapper = null; WrapperByControls.TryGetValue(control, out wrapper); WrapperByControls.Remove(control); if (wrapper != null && menu != null) { UnsubscribeWrapper(wrapper, menu); } } }
public void SetAutocompleteMenu(Control control, AutocompleteMenu menu) { if (menu != null) { if (WrapperByControls.ContainsKey(control)) { var wrapper = WrapperByControls[control]; if (wrapper == null) return; // if (control.IsHandleCreated) menu.SubscribeForm(wrapper); else control.HandleCreated += (o, e) => menu.SubscribeForm(wrapper); // AutocompleteMenuByControls[control] = this; // wrapper.LostFocus += menu.control_LostFocus; wrapper.Scroll += menu.control_Scroll; wrapper.KeyDown += menu.control_KeyDown; wrapper.MouseDown += menu.control_MouseDown; } else { var wrapper = menu.CreateWrapper(control); if (wrapper == null) return; // if (control.IsHandleCreated) menu.SubscribeForm(wrapper); else control.HandleCreated += (o, e) => menu.SubscribeForm(wrapper); // AutocompleteMenuByControls[control] = this; // wrapper.LostFocus += menu.control_LostFocus; wrapper.Scroll += menu.control_Scroll; wrapper.KeyDown += menu.control_KeyDown; wrapper.MouseDown += menu.control_MouseDown; } } else { AutocompleteMenuByControls.TryGetValue(control, out menu); AutocompleteMenuByControls.Remove(control); ITextBoxWrapper wrapper = null; WrapperByControls.TryGetValue(control, out wrapper); WrapperByControls.Remove(control); if (wrapper != null && menu != null) { wrapper.LostFocus -= menu.control_LostFocus; wrapper.Scroll -= menu.control_Scroll; wrapper.KeyDown -= menu.control_KeyDown; wrapper.MouseDown -= menu.control_MouseDown; } } }