/// <summary>
        /// Initializes a new instance of the <see cref="HoverPopup"/> class and sets up its child UI elements.
        /// </summary>
        /// <param name="hoverObject">The hover object.</param>
        /// <param name="artifactViewer">The artifact viewer.</param>
        internal HoverPopup(HoverObject hoverObject, ArtifactViewer artifactViewer)
        {
            this.hoverObject = hoverObject;
            this.artifactViewer = artifactViewer;

            this.StaysOpen = false;
            this.AllowsTransparency = true;
            this.Placement = PlacementMode.Mouse;
            this.PopupAnimation = PopupAnimation.Fade;
            this.MaxWidth = 300;
            this.MouseMove += this.HoverPopupMouseMove;

            this.awayTimer = new DispatcherTimer();
            this.awayTimer.Interval = TimeSpan.FromMilliseconds(50);
            this.awayTimer.Tick += this.AwayTimerTick;

            this.layoutGrid = new Grid();
            this.layoutGrid.Margin = new Thickness(0, 0, 8, 8);
            this.Child = this.layoutGrid;

            DropShadowBitmapEffect dropShadowEffect = new DropShadowBitmapEffect();
            dropShadowEffect.ShadowDepth = 5;
            this.layoutGrid.BitmapEffect = dropShadowEffect;

            Border border = new Border();
            border.Background = Brushes.White;
            border.Padding = new Thickness(5);
            border.CornerRadius = new CornerRadius(5);
            this.layoutGrid.Children.Add(border);

            this.layoutStackPanel = new StackPanel();
            border.Child = this.layoutStackPanel;

            this.AddTitle();
        }
Exemple #2
0
        // TODO:
        internal void PerformHoverHitTest()
        {
            HoverObject newHoverObject = this.HoverHitTest();

            if (this.hoverObject != newHoverObject)
            {
                if (this.hoverObject != null)
                {
                    this.hoverObject.IsHovered = false;
                }
                this.hoverObject = newHoverObject;
                if (this.hoverObject != null)
                {
                    this.hoverObject.IsHovered = true;
                }
            }

            if (this.hoverObject != null)
            {
                this.hoverStartTime = DateTime.Now;
                this.hoverTimer.Start();
            }
            else
            {
                this.hoverTimer.Stop();
                this.hoverStartTime = null;
            }
        }
Exemple #3
0
        private ContextMenu CreateContextMenu()
        {
            this.contextMenuHoverObject = this.hoverObject;

            ContextMenu contextMenu = new ContextMenu();

            this.ConfigureContextMenu(contextMenu);

            return(contextMenu.Items.Count > 0 ? contextMenu : null);
        }
        private void CaptureMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (this.pdbViewer.ActionType == PdbActionType.Rotate ||
                this.pdbViewer.ActionType == PdbActionType.Select ||
                this.pdbViewer.ActionType == PdbActionType.Deselect)
            {
                if (this.pdbViewer.ActionType == PdbActionType.Select ||
                    this.pdbViewer.ActionType == PdbActionType.Deselect)
                {
                    if (this.selectionRectangle.Visibility == Visibility.Hidden)
                    {
                        HoverObject hoverObject = this.HoverHitTest();

                        if (hoverObject is Atom)
                        {
                            ((Atom)hoverObject).IsSelected = this.pdbViewer.ActionType ==
                                                             PdbActionType.Select;
                        }

                        if (hoverObject is Residue)
                        {
                            ((Residue)hoverObject).Selection = this.pdbViewer.ActionType ==
                                                               PdbActionType.Select ? Residue.SelectionType.Full :
                                                               Residue.SelectionType.None;
                        }
                    }
                    else
                    {
                        this.selectionRectangle.Visibility = Visibility.Hidden;

                        foreach (Atom atom in this.Molecule.Atoms)
                        {
                            atom.IsSelected = atom.ShowAsSelected;
                        }
                    }
                }

                this.pdbViewer.ActionType = PdbActionType.None;
                this.CaptureElement.ReleaseMouseCapture();
            }
        }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HoverPopup"/> class and sets up its child UI elements.
        /// </summary>
        /// <param name="hoverObject">The hover object.</param>
        /// <param name="artifactViewer">The artifact viewer.</param>
        internal HoverPopup(HoverObject hoverObject, ArtifactViewer artifactViewer)
        {
            this.hoverObject    = hoverObject;
            this.artifactViewer = artifactViewer;

            this.StaysOpen          = false;
            this.AllowsTransparency = true;
            this.Placement          = PlacementMode.Mouse;
            this.PopupAnimation     = PopupAnimation.Fade;
            this.MaxWidth           = 300;
            this.MouseMove         += this.HoverPopupMouseMove;

            this.awayTimer          = new DispatcherTimer();
            this.awayTimer.Interval = TimeSpan.FromMilliseconds(50);
            this.awayTimer.Tick    += this.AwayTimerTick;

            this.layoutGrid        = new Grid();
            this.layoutGrid.Margin = new Thickness(0, 0, 8, 8);
            this.Child             = this.layoutGrid;

            DropShadowBitmapEffect dropShadowEffect = new DropShadowBitmapEffect();

            dropShadowEffect.ShadowDepth = 5;
            this.layoutGrid.BitmapEffect = dropShadowEffect;

            Border border = new Border();

            border.Background   = Brushes.White;
            border.Padding      = new Thickness(5);
            border.CornerRadius = new CornerRadius(5);
            this.layoutGrid.Children.Add(border);

            this.layoutStackPanel = new StackPanel();
            border.Child          = this.layoutStackPanel;

            this.AddTitle();
        }
        private ContextMenu CreateContextMenu()
        {
            this.contextMenuHoverObject = this.hoverObject;

            ContextMenu contextMenu = new ContextMenu();

            this.ConfigureContextMenu(contextMenu);

            return contextMenu.Items.Count > 0 ? contextMenu : null;
        }
        // TODO:
        internal void PerformHoverHitTest()
        {
            HoverObject newHoverObject = this.HoverHitTest();

            if (this.hoverObject != newHoverObject)
            {
                if (this.hoverObject != null) this.hoverObject.IsHovered = false;
                this.hoverObject = newHoverObject;
                if (this.hoverObject != null) this.hoverObject.IsHovered = true;
            }

            if (this.hoverObject != null)
            {
                this.hoverStartTime = DateTime.Now;
                this.hoverTimer.Start();
            }
            else
            {
                this.hoverTimer.Stop();
                this.hoverStartTime = null;
            }
        }