private static void OpenAutomaticToolTip(object sender, EventArgs e) { ToolTipService._openTimer.Stop(); Debug.Assert(ToolTipService._owner != null, "ToolTip owner was not set prior to starting the open timer"); ToolTipService._currentToolTip = (ToolTip)ToolTipService._owner.GetValue(AssignedToolTipProperty); if (ToolTipService._currentToolTip != null) { ToolTipService._currentToolTip.PlacementOverride = ToolTipService.GetPlacement(_owner); ToolTipService._currentToolTip.PlacementTargetOverride = ToolTipService.GetPlacementTarget(_owner) ?? _owner; ToolTipService._currentToolTip.IsOpen = true; // start the timer which closes the ToolTip if (ToolTipService._closeTimer == null) { ToolTipService._closeTimer = new DispatcherTimer(); ToolTipService._closeTimer.Tick += new EventHandler(CloseAutomaticToolTip); } ToolTipService._closeTimer.Interval = new TimeSpan(0, 0, 0, 0, TOOLTIPSERVICE_showDuration); ToolTipService._closeTimer.Start(); } }
private void InspectElementForToolTip(DependencyObject o) { DependencyObject lastChecked = o; if (this.LocateNearestToolTip(ref o)) { if (o != null) { if (this.LastMouseOverWithToolTip != null) { this.RaiseToolTipClosingEvent(true); } this.LastChecked = lastChecked; this.LastMouseOverWithToolTip = o; bool arg_3E_0 = this._quickShow; this.ResetToolTipTimer(); if (arg_3E_0) { this._quickShow = false; this.RaiseToolTipOpeningEvent(); return; } this.ToolTipTimer = new DispatcherTimer(DispatcherPriority.Normal); this.ToolTipTimer.Interval = TimeSpan.FromMilliseconds((double)ToolTipService.GetInitialShowDelay(o)); this.ToolTipTimer.Tag = BooleanBoxes.TrueBox; this.ToolTipTimer.Tick += new EventHandler(this.OnRaiseToolTipOpeningEvent); this.ToolTipTimer.Start(); return; } } else { this.RaiseToolTipClosingEvent(true); this.LastMouseOverWithToolTip = null; } }
private void RaiseToolTipClosingEvent(bool reset) { this.ResetToolTipTimer(); if (reset) { this.LastChecked = null; } DependencyObject lastMouseOverWithToolTip = this.LastMouseOverWithToolTip; if (lastMouseOverWithToolTip != null && this._currentToolTip != null) { bool isOpen = this._currentToolTip.IsOpen; try { if (isOpen) { IInputElement inputElement = lastMouseOverWithToolTip as IInputElement; if (inputElement != null) { inputElement.RaiseEvent(new ToolTipEventArgs(false)); } } } finally { if (isOpen) { this._currentToolTip.IsOpen = false; if (this._currentToolTip != null) { this._forceCloseTimer = new DispatcherTimer(DispatcherPriority.Normal); this._forceCloseTimer.Interval = Popup.AnimationDelayTime; this._forceCloseTimer.Tick += new EventHandler(this.OnForceClose); this._forceCloseTimer.Tag = this._currentToolTip; this._forceCloseTimer.Start(); } this._quickShow = true; this.ToolTipTimer = new DispatcherTimer(DispatcherPriority.Normal); this.ToolTipTimer.Interval = TimeSpan.FromMilliseconds((double)ToolTipService.GetBetweenShowDelay(lastMouseOverWithToolTip)); this.ToolTipTimer.Tick += new EventHandler(this.OnBetweenShowDelay); this.ToolTipTimer.Start(); } else { this._currentToolTip.ClearValue(PopupControlService.OwnerProperty); if (this._ownToolTip) { BindingOperations.ClearBinding(this._currentToolTip, ContentControl.ContentProperty); } } this._currentToolTip = null; } } }
/// <summary> /// Closes the current tooltip, firing a Closing event if necessary. /// </summary> /// <param name="reset"> /// When false, will continue to treat input as if the tooltip were open so that /// the tooltip of the current element won't re-open. Example: Clicking on a button /// will hide the tooltip, but when the mouse is released, the tooltip should not /// appear unless the mouse is moved off and then back on the button. /// </param> private void RaiseToolTipClosingEvent(bool reset) { ResetToolTipTimer(); if (reset) { LastChecked = null; } DependencyObject o = LastObjectWithToolTip; if (o != null) { if (_currentToolTip != null) { bool isOpen = _currentToolTip.IsOpen; try { if (isOpen) { IInputElement element = o as IInputElement; if (element != null) { element.RaiseEvent(new ToolTipEventArgs(false)); } } } finally { // Raising an event calls out to app code, which // could cause a re-entrant call to this method that // sets _currentToopTip to null. If that happens, // there's no need to do the work again. if (_currentToolTip != null) { if (isOpen) { _currentToolTip.IsOpen = false; // Setting IsOpen makes call outs to app code. So it is possible that // the _currentToolTip is destroyed as a result of an action there. If that // were the case we do not need to set off the timer to close the tooltip. if (_currentToolTip != null) { // Keep references and owner set for the fade out or slide animation // Owner is released when animation completes _forceCloseTimer = new DispatcherTimer(DispatcherPriority.Normal); _forceCloseTimer.Interval = Popup.AnimationDelayTime; _forceCloseTimer.Tick += new EventHandler(OnForceClose); _forceCloseTimer.Tag = _currentToolTip; _forceCloseTimer.Start(); } _quickShow = true; ToolTipTimer = new DispatcherTimer(DispatcherPriority.Normal); ToolTipTimer.Interval = TimeSpan.FromMilliseconds(ToolTipService.GetBetweenShowDelay(o)); ToolTipTimer.Tick += new EventHandler(OnBetweenShowDelay); ToolTipTimer.Start(); } else { // Release owner now _currentToolTip.ClearValue(OwnerProperty); if (_ownToolTip) { BindingOperations.ClearBinding(_currentToolTip, ToolTip.ContentProperty); } } if (_currentToolTip != null) { _currentToolTip.FromKeyboard = false; _currentToolTip = null; } } } } } }
/// <summary> /// Initiates the process of opening the tooltip popup. /// </summary> /// <param name="fromKeyboard"> /// Whether this particular event is caused by keyboard focus. /// This is passed down to the tooltip and the popup to determine its placement. /// </param> private void RaiseToolTipOpeningEvent(bool fromKeyboard = false) { ResetToolTipTimer(); if (_forceCloseTimer != null) { OnForceClose(null, EventArgs.Empty); } DependencyObject o = LastObjectWithToolTip; if (o != null) { bool show = true; IInputElement element = o as IInputElement; if (element != null) { ToolTipEventArgs args = new ToolTipEventArgs(true); element.RaiseEvent(args); show = !args.Handled; } if (show) { object tooltip = ToolTipService.GetToolTip(o); ToolTip tip = tooltip as ToolTip; if (tip != null) { _currentToolTip = tip; _ownToolTip = false; } else if ((_currentToolTip == null) || !_ownToolTip) { _currentToolTip = new ToolTip(); _ownToolTip = true; _currentToolTip.SetValue(ServiceOwnedProperty, BooleanBoxes.TrueBox); // Bind the content of the tooltip to the ToolTip attached property Binding binding = new Binding(); binding.Path = new PropertyPath(ToolTipService.ToolTipProperty); binding.Mode = BindingMode.OneWay; binding.Source = o; _currentToolTip.SetBinding(ToolTip.ContentProperty, binding); } if (!_currentToolTip.StaysOpen) { // The popup takes capture in this case, which causes us to hit test to the wrong window. // We do not support this scenario. Cleanup and then throw and exception. throw new NotSupportedException(SR.Get(SRID.ToolTipStaysOpenFalseNotAllowed)); } _currentToolTip.SetValue(OwnerProperty, o); _currentToolTip.Opened += OnToolTipOpened; _currentToolTip.Closed += OnToolTipClosed; _currentToolTip.FromKeyboard = fromKeyboard; _currentToolTip.IsOpen = true; ToolTipTimer = new DispatcherTimer(DispatcherPriority.Normal); ToolTipTimer.Interval = TimeSpan.FromMilliseconds(ToolTipService.GetShowDuration(o)); ToolTipTimer.Tick += new EventHandler(OnRaiseToolTipClosingEvent); ToolTipTimer.Start(); } } }
/// <summary> /// Inspects the given element in search of an enabled tooltip, depending on the user /// action triggering this search this method will result in the tooltip showing for /// the first time, closing, or remaining open if the tooltip was already showing. /// </summary> /// <param name="o">The element to be inspected.</param> /// <param name="triggerAction">The user action that triggered this search.</param> /// <returns>True if the method found a tooltip and acted upon it.</returns> /// <remarks> /// Mouse only shows the tooltip the first time it moves over an element, as long as the mouse keeps moving inside that element, the tooltip stays. /// When the keyboard focus lands on an element with a tooltip the tooltip shows unless it was already being shown by the mouse. /// If the user presses the keyboard shortcut while focusing an element with a tooltip, the tooltip state will toggle from open to closed or viceversa. /// </remarks> private bool InspectElementForToolTip(DependencyObject o, ToolTip.ToolTipTrigger triggerAction) { DependencyObject origObj = o; bool foundToolTip = false; bool showToolTip = false; bool fromKeyboard = triggerAction == ToolTip.ToolTipTrigger.KeyboardFocus || triggerAction == ToolTip.ToolTipTrigger.KeyboardShortcut; foundToolTip = LocateNearestToolTip(ref o, triggerAction, ref showToolTip); if (showToolTip) { // Show the ToolTip on "o" or keep the current ToolTip active if (o != null) { // A ToolTip value was found and is enabled, proceed to firing the event if (LastObjectWithToolTip != null) { // If a ToolTip is active, don't show it anymore RaiseToolTipClosingEvent(true /* reset */); LastMouseOverWithToolTip = null; } LastChecked = origObj; LastObjectWithToolTip = o; if (!fromKeyboard) { LastMouseOverWithToolTip = o; } // When showing tooltips from keyboard focus, do not allow quickshow. // A user tabbing through elements quickly doesn't need to see all the tooltips, only when it has settled on an element. bool quickShow = fromKeyboard ? false : _quickShow; // ResetToolTipTimer may reset _quickShow ResetToolTipTimer(); if (quickShow) { _quickShow = false; RaiseToolTipOpeningEvent(fromKeyboard); } else { ToolTipTimer = new DispatcherTimer(DispatcherPriority.Normal); ToolTipTimer.Interval = TimeSpan.FromMilliseconds(ToolTipService.GetInitialShowDelay(o)); ToolTipTimer.Tag = BooleanBoxes.TrueBox; // should open ToolTipTimer.Tick += new EventHandler((s, e) => { RaiseToolTipOpeningEvent(fromKeyboard); }); ToolTipTimer.Start(); } } } // If we are moving focus to an element that does not have a tooltip, // and the mouse is still on a tooltip element, keep showing the tooltip under the mouse. else if (LastMouseOverWithToolTip == null || triggerAction != ToolTip.ToolTipTrigger.KeyboardFocus) { // If a ToolTip is active, don't show it anymore RaiseToolTipClosingEvent(true /* reset */); //Only cleanup the LasMouseOverWithToolTip property if it is the mouse that is moving away. if (triggerAction == ToolTip.ToolTipTrigger.Mouse) { // No longer over an item with a tooltip LastMouseOverWithToolTip = null; } LastObjectWithToolTip = null; } return(foundToolTip); }
public void InvalidateForm() { if (partGrid != null) { partGrid.Children.Clear(); this.DiscoverObject(); Grid grid1 = new Grid(); grid1.Margin = new Thickness(5); grid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); grid1.ColumnDefinitions.Add(new ColumnDefinition());// {Width = new GridLength(1, GridUnitType.Auto)}); //grid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); int row = 0; var listProperties = from p in this.displays orderby(p.Value.GetOrder() ?? 0) select this.properties[p.Key]; foreach (PropertyInfo property in listProperties) { var nm = displays[property.Name].GetName(); if (string.IsNullOrEmpty(nm)) { nm = property.Name; } var tooltip = displays[property.Name].GetDescription(); var lbl = GetLabelTextBlock(nm, tooltip); // Binding Creation Binding binding = new Binding(property.Name); binding.Source = this.CurrentItem; binding.ConverterCulture = CultureInfo.CurrentCulture; binding.Mode = (bindables[property.Name].Direction == BindingDirection.TwoWay ? BindingMode.TwoWay : BindingMode.OneWay); binding.ValidatesOnDataErrors = true; binding.ValidatesOnExceptions = true; binding.NotifyOnValidationError = true; binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; #if !SILVERLIGHT //binding.NotifyOnTargetUpdated = true; //binding.NotifyOnSourceUpdated = true; //binding.IsAsync = true; #endif #if !SILVERLIGHT foreach (ValidationAttribute attribs in this.validations[property.Name]) { ValidationRule rule = new AttributeValidationRule(attribs, property.Name); binding.ValidationRules.Add(rule); if (!this.rules.ContainsKey(property.Name)) { this.rules.Add(property.Name, new List <ValidationRule>()); } this.rules[property.Name].Add(rule); } #endif // Control creation FrameworkElement editorControl = this.GetControlFromProperty(property, binding); if (editorControl == null) { continue; } var df = new DataField() { Content = editorControl, Label = lbl }; DataFormAutoGeneratingFieldEventArgs e = new DataFormAutoGeneratingFieldEventArgs(property.Name, property.PropertyType, df); EventHandler <DataFormAutoGeneratingFieldEventArgs> eventHandler = this.AutoGeneratingField; if (eventHandler != null) { eventHandler(this, e); } if (e.Cancel) { continue; } ToolTipService.SetToolTip(df.Content, displays[property.Name].GetDescription()); #if !SILVERLIGHT Validation.SetErrorTemplate(df.Content, ErrorTemplate); #endif //df.Content.HorizontalAlignment = Windows.HorizontalAlignment.Stretch; // Add to view RowDefinition newRow = new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }; grid1.RowDefinitions.Add(newRow); if (df.Content.Height.CompareTo(Double.NaN) != 0) { newRow.Height = new GridLength(df.Content.Height); } Grid.SetColumn(df.Label, 0); Grid.SetRow(df.Label, row); Grid.SetColumn(df.Content, 1); Grid.SetRow(df.Content, row); grid1.Children.Add(df.Label); grid1.Children.Add(df.Content); this.controls.Add(property.Name, df.Content); row++; } partGrid.Children.Add(grid1); } }
// Token: 0x060053DB RID: 21467 RVA: 0x00173CAC File Offset: 0x00171EAC private bool InspectElementForToolTip(DependencyObject o, ToolTip.ToolTipTrigger triggerAction) { DependencyObject lastChecked = o; bool flag = false; bool fromKeyboard = triggerAction == ToolTip.ToolTipTrigger.KeyboardFocus || triggerAction == ToolTip.ToolTipTrigger.KeyboardShortcut; bool result = this.LocateNearestToolTip(ref o, triggerAction, ref flag); if (flag) { if (o != null) { if (this.LastObjectWithToolTip != null) { this.RaiseToolTipClosingEvent(true); this.LastMouseOverWithToolTip = null; } this.LastChecked = lastChecked; this.LastObjectWithToolTip = o; if (!fromKeyboard) { this.LastMouseOverWithToolTip = o; } bool flag2 = !fromKeyboard && this._quickShow; this.ResetToolTipTimer(); if (flag2) { this._quickShow = false; this.RaiseToolTipOpeningEvent(fromKeyboard); } else { this.ToolTipTimer = new DispatcherTimer(DispatcherPriority.Normal); this.ToolTipTimer.Interval = TimeSpan.FromMilliseconds((double)ToolTipService.GetInitialShowDelay(o)); this.ToolTipTimer.Tag = BooleanBoxes.TrueBox; this.ToolTipTimer.Tick += delegate(object s, EventArgs e) { this.RaiseToolTipOpeningEvent(fromKeyboard); }; this.ToolTipTimer.Start(); } } } else if (this.LastMouseOverWithToolTip == null || triggerAction != ToolTip.ToolTipTrigger.KeyboardFocus) { this.RaiseToolTipClosingEvent(true); if (triggerAction == ToolTip.ToolTipTrigger.Mouse) { this.LastMouseOverWithToolTip = null; } this.LastObjectWithToolTip = null; } return(result); }