/// <summary> /// Gets the popup that matches the proveded type. /// </summary> /// <param name="t">Type to find.</param> /// <returns>Matching instance; otherwise null.</returns> public Control TrackingByType(Type t) { if (IsTracking) { // Is the current popup matching the type? if (CurrentPopup.GetType() == t) { return(CurrentPopup); } // Check the stack items in reverse order for a match VisualPopup[] popups = _stack.ToArray(); for (int i = popups.Length - 1; i >= 0; i--) { if (!popups[i].IsDisposed) { if (popups[i].GetType() == t) { return(popups[i]); } } } } return(null); }
public void Open <T>() where T : Popup { if (CurrentPopup != null && CurrentPopup.GetType() == typeof(T)) { return; } if (_activePopupStack.Any <T>()) { return; } _popups.Get <T>().gameObject.SetActive(false); Popup popup = Instantiate(_popups.Get <T>(), _container); popup.Init(); if (CurrentPopup != null && CurrentPopup.BaseSettings.PriorityLevel > _popups.Get <T>().BaseSettings.PriorityLevel) { _activePopupStack.Push(popup); return; } Register(popup); Open(popup); }
private void DocApply_Click(object sender, RoutedEventArgs e) { Button objButton = (Button)sender; MTApplyMgrModel mgrApply = objButton.Tag as MTApplyMgrModel; MTApplycationUser applyUser = CurrentPopup.FindName("userApplyForm") as MTApplycationUser; applyUser.DataContext = mgrApply; CurrentPopup.PlacementTarget = objButton.Parent as Grid; CurrentPopup.IsOpen = true; (applyUser.FindName("tbSearch") as TextBox).Focus(); }
private void KeydownEventHandler(object sender, IControlHtmlEventArgs e) { if (!Enabled) { return; } LogTo.Debug("Handling key down"); var ev = e?.EventObj; if (ev == null) { return; } if (CurrentPopup == null || !CurrentPopup.IsOpen()) { return; } var info = new HtmlKeyInfo(ev); if (info.Key == Keys.None) { return; } if (info.Key == Keys.Escape) { CurrentPopup?.Hide(); ev.returnValue = false; } else if ((info.Key == Keys.Up && info.Modifiers == KeyModifiers.None) || (info.Key == Keys.K && info.Modifiers == KeyModifiers.Ctrl)) { CurrentPopup?.SelectPreviousItem(); ev.returnValue = false; } else if ((info.Key == Keys.Down && info.Modifiers == KeyModifiers.None) || (info.Key == Keys.J && info.Modifiers == KeyModifiers.Ctrl)) { CurrentPopup?.SelectNextItem(); ev.returnValue = false; } else if ((info.Key == Keys.Right && info.Modifiers == KeyModifiers.None) || info.Key == Keys.Tab) { CurrentPopup?.InsertSelectedItem(); ev.returnValue = false; } }
private void ShowNewAutocompleteWdw(IEnumerable <string> matches, string lastWord) { System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)(() => { try { var wdw = ContentUtils.GetFocusedHtmlWindow() as IHTMLWindow4; var htmlDoc = ((IHTMLWindow2)wdw)?.document; if (wdw == null || htmlDoc == null) { return; } LogTo.Debug("Creating and showing a new Autocomplete popup"); CurrentPopup = wdw.CreatePopup(); CurrentPopup.Show(matches, lastWord); } catch (UnauthorizedAccessException) { } catch (RemotingException) { } })); }
private void OnTabPressed() { if (CurrentPopup == null || !CurrentPopup.IsOpen()) { if (!SelectPlaceholder()) { Svc.SM.UI.ElementWdw.SendKeys(new HotKey(Key.Tab)); } } else if (CurrentPopup.IsOpen() && CurrentPopup.GetSelectedItem() == null) { if (!SelectPlaceholder()) { Svc.SM.UI.ElementWdw.SendKeys(new HotKey(Key.Tab)); return; } CurrentPopup.Hide(); } else { CurrentPopup.InsertSelectedItem(); } }
private void HandleKeyUp(HtmlKeyInfo info) { if (!Enabled) { return; } if (info.Key == Keys.None || info.Modifiers != KeyModifiers.None || info.Key == Keys.Escape) { return; } if ((info.Key == Keys.Up) || info.Key == Keys.Right || info.Key == Keys.Down || (info.Key == Keys.J && info.Modifiers == KeyModifiers.Ctrl) || (info.Key == Keys.K && info.Modifiers == KeyModifiers.Ctrl)) { LogTo.Debug("KeyUp: Ignoring because it was an arrow key."); return; } else if (info.Key == Keys.Escape) { LogTo.Debug("KeyUp: Escape pressed, closing popup"); CurrentPopup?.Hide(); return; } var selObj = ContentUtils.GetSelectionObject(); if (selObj == null || !string.IsNullOrEmpty(selObj.text)) { return; } var lastWord = ContentUtils.GetLastPartialWord(selObj); if (lastWord == null || string.IsNullOrEmpty(lastWord)) { CurrentPopup?.Hide(); return; } var matches = CurrentSuggestions.GetWords(lastWord); if (matches == null || !matches.Any()) { CurrentPopup?.Hide(); return; } if (matches.Count() == 1 && matches.First() == lastWord) { CurrentPopup?.Hide(); return; } if (CurrentPopup == null) { ShowNewAutocompleteWdw(matches, lastWord); } else { CurrentPopup?.Show(matches, lastWord); } }
public void Disable() { Enabled = false; CurrentPopup?.Hide(); }