コード例 #1
0
        private void UpdateToolWindowInfoCardLocations()
        {
            var infoCard = InfoCardSite.GetInfoCardFromHost(this);

            if (infoCard != null)
            {
                infoCard.Location = Location;
            }
        }
コード例 #2
0
        protected override void OnDeactivated(EventArgs e)
        {
            base.OnDeactivated(e);

            var popup = InfoCardSite.GetInfoCardFromHost(InfoCardHost);

            if ((popup != null) && !popup.IsPinned)
            {
                popup.Close();
            }
        }
コード例 #3
0
 internal static void SetInfoCardSite(DependencyObject o, InfoCardSite value)
 {
     if (o == null)
     {
         throw new ArgumentNullException("o");
     }
     o.SetValue(InfoCardSitePropertyKey, value);
     if (o is InfoCard)
     {
         o.CoerceValue(InfoCard.CanPinProperty);
     }
 }
コード例 #4
0
        protected override void OnDeactivated(RoutedEventArgs e)
        {
            base.OnDeactivated(e);

            ClearValue(DropShadowColorProperty);

            if (!IsVisible)
            {
                return;
            }

            var popup = InfoCardSite.GetInfoCardFromHost(InfoCardHost);

            if ((popup != null) && !popup.IsPinned)
            {
                popup.Close();
            }
        }
コード例 #5
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();
                    }
                }
            }
        }