Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 internal static void SetUnregisterInfoCardOnClose(InfoCard source, bool value)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     source.SetValue(UnregisterInfoCardOnCloseProperty, value);
 }
Esempio n. 4
0
 internal static bool GetUnregisterInfoCardOnClose(InfoCard source)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     return((bool)source.GetValue(UnregisterInfoCardOnCloseProperty));
 }
Esempio n. 5
0
 public static void SetInfoCard(DependencyObject obj, InfoCard value)
 {
     if (obj == null)
     {
         throw new ArgumentNullException("obj");
     }
     obj.SetValue(InfoCardProperty, value);
 }
Esempio n. 6
0
 public bool Matches(InfoCard infoCard)
 {
     if (infoCard == null)
     {
         return(false);
     }
     return(Equals(infoCard.DataContext, Data));
 }
Esempio n. 7
0
        private void RegisterInfoCard(InfoCard infoCard)
        {
            UpdateRegisteredInfoCardSite(infoCard, true);

            if (!_infoCards.Contains(infoCard))
            {
                _infoCards.Add(infoCard);
            }
        }
Esempio n. 8
0
        internal void OpenInfoCard(InfoCard infoCard)
        {
            if ((infoCard == null) || infoCard.IsOpen)
            {
                return;
            }

            RaiseOpeningEvent(infoCard);
            OpenInfoCardCore(infoCard);
            RaiseOpenedEvent(infoCard);
        }
Esempio n. 9
0
        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;
                }
            }
        }
Esempio n. 10
0
        protected virtual void OnActiveInfoCardChanged(InfoCard oldValue, InfoCard newValue)
        {
            if (oldValue != null)
            {
                RaiseInfoCardDeactivatedEvent(oldValue);
            }

            if (newValue != null)
            {
                RaiseInfoCardActivatedEvent(newValue);
            }
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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;
            }
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
 private void RaiseInfoCardDeactivatedEvent(InfoCard oldValue)
 {
     RaiseEvent(new InfoCardEventArgs(oldValue, InfoCardDeactivatedEvent, this));
     oldValue.RaiseDeactivatedEvent();
 }
Esempio n. 15
0
 /// <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;
 }
Esempio n. 16
0
 /// <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)
 {
 }
Esempio n. 17
0
 /// <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)
 {
 }
Esempio n. 18
0
 internal void RaiseOpeningEvent(InfoCard infoCard)
 {
     RaiseEvent(new InfoCardEventArgs(infoCard, InfoCardOpeningEvent, this));
     infoCard.RaiseOpeningEvent();
 }
Esempio n. 19
0
 private void RaiseInfoCardActivatedEvent(InfoCard newValue)
 {
     RaiseEvent(new InfoCardEventArgs(newValue, InfoCardActivatedEvent, this));
     newValue.RaiseActivatedEvent();
 }
Esempio n. 20
0
 public InfoCardHost()
 {
     UniqueId = Guid.NewGuid();
     SetInfoCardHost(this, this);
     InfoCard.SetIsCurrentlyOpen(this, true);
 }
Esempio n. 21
0
        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();
                    }
                }
            }
        }