internal void OpenInfoCardCore(InfoCard infoCard) { IInfoCardWindow infoCardWindow; var infoCardHost = InfoCardHost.GetInfoCardHost(infoCard); if ((infoCardHost != null) && infoCardHost.IsVisible) { infoCardWindow = infoCardHost.InfoCardWindow; if (infoCardWindow != null) { return; } } if (infoCardHost == null) { infoCardHost = CreateInfoCardHost(); infoCardHost.Location = infoCard.Location; } infoCardHost.Content = infoCard; infoCardWindow = CreateRaftingWindow(infoCardHost); infoCardWindow.SnapToScreen(); infoCardWindow.Show(); infoCardWindow.Activate(); }
internal void StartFade(InfoCard infoCardToFade) { DestroyStoryboard(); var infoCardElement = infoCardToFade as FrameworkElement; if (infoCardElement == null) { return; } var infoCardSite = infoCardToFade.InfoCardSite; if ((infoCardSite == null) || !infoCardSite.IsInactiveInfoCardFadeEnabled || (infoCardSite.InactiveInfoCardFadeOpacity == 1.0)) { return; } _infoCard = infoCardToFade; _storyboard = CreateStoryboard( infoCardSite.InactiveInfoCardFadeDelay, infoCardSite.InactiveInfoCardFadeDuration, infoCardSite.InactiveInfoCardFadeOpacity); _storyboard.Begin(infoCardElement, true); }
internal static void SetUnregisterInfoCardOnClose(InfoCard source, bool value) { if (source == null) { throw new ArgumentNullException("source"); } source.SetValue(UnregisterInfoCardOnCloseProperty, value); }
internal static bool GetUnregisterInfoCardOnClose(InfoCard source) { if (source == null) { throw new ArgumentNullException("source"); } return((bool)source.GetValue(UnregisterInfoCardOnCloseProperty)); }
public static void SetInfoCard(DependencyObject obj, InfoCard value) { if (obj == null) { throw new ArgumentNullException("obj"); } obj.SetValue(InfoCardProperty, value); }
public bool Matches(InfoCard infoCard) { if (infoCard == null) { return(false); } return(Equals(infoCard.DataContext, Data)); }
private void RegisterInfoCard(InfoCard infoCard) { UpdateRegisteredInfoCardSite(infoCard, true); if (!_infoCards.Contains(infoCard)) { _infoCards.Add(infoCard); } }
internal void OpenInfoCard(InfoCard infoCard) { if ((infoCard == null) || infoCard.IsOpen) { return; } RaiseOpeningEvent(infoCard); OpenInfoCardCore(infoCard); RaiseOpenedEvent(infoCard); }
private void RaiseInfoCardClosingEvent(bool reset) { ResetInfoCardTimer(); if (reset) { LastChecked = null; } var lastMouseOver = LastMouseOverWithInfoCard; if ((lastMouseOver != null) && (_currentInfoCard != null)) { var isOpen = _currentInfoCard.IsOpen; if (_currentInfoCard.IsPinned) { return; } try { if (isOpen) { var element = lastMouseOver as IInputElement; if (element != null) { element.RaiseEvent(new RoutedEventArgs(InfoCardClosingEvent, this)); } } } finally { if (isOpen) { var infoCardSite = _currentInfoCard.RegisteredInfoCardSite; if (infoCardSite != null) { infoCardSite.InfoCards.Remove(_currentInfoCard); } _currentInfoCard.Close(); _quickShow = true; InfoCardTimer = new DispatcherTimer(DispatcherPriority.Normal) { Interval = TimeSpan.FromMilliseconds(BetweenShowDelay) }; InfoCardTimer.Tick += OnBetweenShowDelay; InfoCardTimer.Start(); } _currentInfoCard = null; } } }
protected virtual void OnActiveInfoCardChanged(InfoCard oldValue, InfoCard newValue) { if (oldValue != null) { RaiseInfoCardDeactivatedEvent(oldValue); } if (newValue != null) { RaiseInfoCardActivatedEvent(newValue); } }
internal bool Close(InfoCard infoCard, InfoCardCloseReason closeReason, bool force) { if ((infoCard == null) || (!infoCard.IsOpen)) { return(false); } // Raise closing event var closingEventArgs = new InfoCardEventArgs(infoCard, InfoCardClosingEvent, this); RaiseEvent(closingEventArgs); infoCard.RaiseClosingEvent(); if (!force && closingEventArgs.Cancel) { return(false); } var notifier = new EventNotifier(); notifier.Subscribe(infoCard); infoCard.Measure(new Size(0, 0)); infoCard.ClearValue(Expander.IsExpandedProperty); infoCard.ClearValue(InfoCard.IsPinnedProperty); var infoCardHost = InfoCardHost.GetInfoCardHost(infoCard); if (infoCardHost != null) { infoCardHost.Content = null; } notifier.RaiseEvents(); if (InfoCardService.GetUnregisterInfoCardOnClose(infoCard)) { InfoCards.Remove(infoCard); } RaiseEvent(new InfoCardEventArgs(infoCard, InfoCardClosedEvent, this)); infoCard.RaiseClosedEvent(); infoCard.LastCloseReason = closeReason; return(true); }
private void UpdateRegisteredInfoCardSite(InfoCard infoCard, bool register) { if (register) { if (infoCard.RegisteredInfoCardSite != this) { if (infoCard.RegisteredInfoCardSite != null) { throw new InvalidOperationException(SR.InfoCardAlreadyRegistered); } infoCard.RegisteredInfoCardSite = this; } } else if (infoCard.RegisteredInfoCardSite == this) { infoCard.RegisteredInfoCardSite = null; } }
private void RetireInfoCard([NotNull] InfoCard infoCard) { if (infoCard == null) { throw new ArgumentNullException("infoCard"); } infoCard.Closed -= OnInfoCardClosed; infoCard.SubjectChanged -= OnInfoCardSubjectChanged; var infoCardSubject = infoCard.Subject; if (infoCardSubject != null) { _infoCardCache.Remove(infoCard.Subject); } _infoCardCache.RemoveCollectedEntries(); infoCard.ClearValue(InfoCard.SubjectProperty); }
private void RaiseInfoCardDeactivatedEvent(InfoCard oldValue) { RaiseEvent(new InfoCardEventArgs(oldValue, InfoCardDeactivatedEvent, this)); oldValue.RaiseDeactivatedEvent(); }
/// <summary> /// Initializes a new instance of the <c>InfoCardEventArgs</c> class. /// </summary> /// <param name="infoCard">The <see cref="InfoCard"/> that is the focus of this event.</param> /// <param name="routedEvent">The routed event identifier for this event arguments instance.</param> /// <param name="source">An alternate source that will be reported when the event is handled.</param> public InfoCardEventArgs(InfoCard infoCard, RoutedEvent routedEvent, object source) : base(routedEvent, source) { // Initialize parameters _infoCard = infoCard; }
/// <summary> /// Initializes a new instance of the <c>InfoCardEventArgs</c> class. /// </summary> /// <param name="infoCard">The <see cref="InfoCard"/> that is the focus of this event.</param> /// <param name="routedEvent">The routed event identifier for this event arguments instance.</param> public InfoCardEventArgs(InfoCard infoCard, RoutedEvent routedEvent) : this(infoCard, routedEvent, null) { }
/// <summary> /// Initializes a new instance of the <c>InfoCardEventArgs</c> class. /// </summary> /// <param name="infoCard">The <see cref="InfoCard"/> that is the focus of this event.</param> public InfoCardEventArgs(InfoCard infoCard) : this(infoCard, null, null) { }
internal void RaiseOpeningEvent(InfoCard infoCard) { RaiseEvent(new InfoCardEventArgs(infoCard, InfoCardOpeningEvent, this)); infoCard.RaiseOpeningEvent(); }
private void RaiseInfoCardActivatedEvent(InfoCard newValue) { RaiseEvent(new InfoCardEventArgs(newValue, InfoCardActivatedEvent, this)); newValue.RaiseActivatedEvent(); }
public InfoCardHost() { UniqueId = Guid.NewGuid(); SetInfoCardHost(this, this); InfoCard.SetIsCurrentlyOpen(this, true); }
private void RaiseInfoCardOpeningEvent() { ResetInfoCardTimer(); var lastMouseOver = LastMouseOverWithInfoCard; if (lastMouseOver != null) { var showInfoCard = true; var inputElement = lastMouseOver as IInputElement; if (inputElement != null) { // Raise the screen tip opening event var e = new RoutedEventArgs(InfoCardOpeningEvent, this); inputElement.RaiseEvent(e); showInfoCard = !e.Handled; } if (showInfoCard) { if ((_currentInfoCard != null) && !_currentInfoCard.IsOpen) { RetireInfoCard(_currentInfoCard); } _currentInfoCard = CreateInfoCard(lastMouseOver); if (_currentInfoCard != null) { var targetElement = lastMouseOver as UIElement; _currentInfoCard.TargetElement = targetElement; var infoCardPosition = Mouse.GetPosition(inputElement); var infoCardSite = _currentInfoCard.RegisteredInfoCardSite ?? lastMouseOver.FindVisualAncestorByType <InfoCardSite>(); if (infoCardSite == null) { var window = Window.GetWindow(lastMouseOver); if (window != null) { if (!_generatedSites.TryGetValue(window, out infoCardSite)) { infoCardSite = new InfoCardSite(); _generatedSites[window] = infoCardSite; } } else { RetireInfoCard(_currentInfoCard); _currentInfoCard = null; return; } } if (!_currentInfoCard.IsOpen) { if (!infoCardSite.InfoCards.Contains(_currentInfoCard)) { SetUnregisterInfoCardOnClose(_currentInfoCard, true); infoCardSite.InfoCards.Add(_currentInfoCard); } } if (infoCardSite.IsLoaded) { var targetVisual = targetElement; if (targetVisual != null) { var transformToVisual = targetVisual.TransformToVisual(infoCardSite); if (transformToVisual != null) { infoCardPosition = transformToVisual.Transform(infoCardPosition); } } } if (targetElement != null) { var customPlacementCallback = _currentInfoCard.CustomPlacementCallback ?? GetCustomInfoCardPlacementCallback(targetElement); if (customPlacementCallback != null) { _currentInfoCard.UpdateLayout(); infoCardPosition = customPlacementCallback( _currentInfoCard.RenderSize, targetElement, infoCardPosition); } } _currentInfoCard.Location = new Point( DoubleUtil.DoubleToInt(infoCardPosition.X), DoubleUtil.DoubleToInt(infoCardPosition.Y)); if (_currentInfoCard.IsOpen) { var infoCardWindow = InfoCardHost.GetInfoCardWindow(_currentInfoCard); if (infoCardWindow != null) { infoCardWindow.Setup(_currentInfoCard.Location); infoCardWindow.Activate(); } return; } _currentInfoCard.Open(); } } } }