예제 #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();
        }
예제 #2
0
        internal void Subscribe(DependencyObject o)
        {
            if (o == null)
            {
                return;
            }

            var infoCardHost = InfoCardHost.GetInfoCardHost(o);

            if (infoCardHost != null)
            {
                _popupHosts[infoCardHost.UniqueId] = infoCardHost;
            }
        }
예제 #3
0
        private static void OnLocationPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var newValue = (Point?)e.NewValue;

            if (!newValue.HasValue)
            {
                return;
            }

            var infoCardHost = InfoCardHost.GetInfoCardHost(d);

            if (infoCardHost != null)
            {
                infoCardHost.Location = newValue;
            }
        }
예제 #4
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);
        }