Esempio n. 1
0
        private void StartDelayedTooltipFadeIn(InfoBubbleDataPacket data)
        {
            if (toolTipDelayTimer == null)
            {
                toolTipDelayTimer          = new DispatcherTimer();
                toolTipDelayTimer.Interval = TimeSpan.FromMilliseconds(Configurations.ToolTipFadeInDelayInMS);

                toolTipDelayTimer.Tick += delegate(object sender, EventArgs e)
                {
                    var timer = sender as DispatcherTimer;
                    timer.Stop(); // stop timer after one tick
                    ViewModel.ShowTooltipCommand.Execute((InfoBubbleDataPacket)timer.Tag);
                };
            }

            // Collapse any existing bubble before starting fade in
            if (ViewModel != null)
            {
                ViewModel.HideTooltipCommand.Execute(null);
            }
            else if (dynSettings.Controller != null)
            {
                dynSettings.Controller.DynamoViewModel.HideInfoBubble(null);
            }

            toolTipDelayTimer.Stop();
            toolTipDelayTimer.Tag = data;
            dynSettings.Controller.InfoBubbleViewModel.UpdateContentCommand.Execute(data);
            toolTipDelayTimer.Start();
        }
Esempio n. 2
0
        private void AssertParsedLinkIsEqualTo(string content, string expectedLink)
        {
            var packet = new InfoBubbleDataPacket(
                InfoBubbleViewModel.Style.None,
                new Point(0, 0),
                new Point(0, 0),
                content,
                InfoBubbleViewModel.Direction.Top);

            Assert.AreEqual(expectedLink, packet.Link?.ToString());
        }
        // Collapse he warning bubble for the provided NodeViewModel

        private void HideTooltip(NodeViewModel nvm)
        {
            var data = new InfoBubbleDataPacket();

            data.Style =
                IsWarning(nvm.State) ?
                InfoBubbleViewModel.Style.WarningCondensed :
                InfoBubbleViewModel.Style.ErrorCondensed;
            data.ConnectingDirection = InfoBubbleViewModel.Direction.Bottom;
            nvm.ErrorBubble.ShowCondensedContentCommand.Execute(data);
        }
Esempio n. 4
0
        public void IteratorsDisplayWhenMoreThanOneMessage()
        {
            // Arrange
            OpenModel(@"core\Home.dyn");

            var info1 = "Info 1";
            var info2 = "Info 2";

            var         dummyNode = new DummyNode();
            DynamoModel model     = GetModel();

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(dummyNode, 0, 0, true, true));

            NodeViewModel dummyNodeViewModel = ViewModel.CurrentSpaceViewModel.Nodes
                                               .FirstOrDefault(x => x.NodeModel.GUID == dummyNode.GUID);

            if (dummyNodeViewModel.ErrorBubble == null)
            {
                dummyNodeViewModel.ErrorBubble = new InfoBubbleViewModel(ViewModel);
            }

            NodeModel dummyNodeModel = dummyNodeViewModel.NodeModel;

            var topLeft  = new Point(dummyNodeModel.X, dummyNodeModel.Y);
            var botRight = new Point(dummyNodeModel.X + dummyNodeModel.Width, dummyNodeModel.Y + dummyNodeModel.Height);

            InfoBubbleViewModel infoBubbleViewModel = dummyNodeViewModel.ErrorBubble;

            // The collection of messages the node receives
            ObservableCollection <InfoBubbleDataPacket> nodeMessages = infoBubbleViewModel.NodeMessages;

            // Act
            Assert.IsFalse(infoBubbleViewModel.NodeInfoIteratorVisible);

            InfoBubbleDataPacket infoBubbleDataPacket1 =
                new InfoBubbleDataPacket(InfoBubbleViewModel.Style.Info, topLeft, botRight, info1, InfoBubbleViewModel.Direction.Top);

            nodeMessages.Add(infoBubbleDataPacket1);

            Assert.IsFalse(infoBubbleViewModel.NodeInfoIteratorVisible);

            InfoBubbleDataPacket infoBubbleDataPacket2 =
                new InfoBubbleDataPacket(InfoBubbleViewModel.Style.Info, topLeft, botRight, info2, InfoBubbleViewModel.Direction.Top);

            nodeMessages.Add(infoBubbleDataPacket2);

            Assert.IsTrue(infoBubbleViewModel.NodeInfoIteratorVisible);

            infoBubbleViewModel.DismissMessageCommand.Execute(infoBubbleDataPacket1);

            Assert.IsFalse(infoBubbleViewModel.NodeInfoIteratorVisible);
        }
Esempio n. 5
0
        private void ShowPreviewBubbleFullContent()
        {
            string content = ViewModel.FullContent;

            InfoBubbleViewModel.Style     style = InfoBubbleViewModel.Style.Preview;
            InfoBubbleViewModel.Direction connectingDirection = InfoBubbleViewModel.Direction.Top;
            Point topLeft             = ViewModel.TargetTopLeft;
            Point botRight            = ViewModel.TargetBotRight;
            InfoBubbleDataPacket data = new InfoBubbleDataPacket(style, topLeft, botRight, content, connectingDirection);

            this.ViewModel.UpdateContentCommand.Execute(data);
            this.ViewModel.ZIndex = 5;
        }
Esempio n. 6
0
        private void ShowPreviewBubbleCondensedContent()
        {
            if (this.IsDisconnected)
            {
                return;
            }

            InfoBubbleDataPacket data = new InfoBubbleDataPacket();

            data.Style = InfoBubbleViewModel.Style.PreviewCondensed;
            data.ConnectingDirection = InfoBubbleViewModel.Direction.Top;

            this.ViewModel.ShowCondensedContentCommand.Execute(data);
        }
Esempio n. 7
0
        private void ShowErrorBubbleFullContent()
        {
            if (this.IsDisconnected)
            {
                return;
            }

            InfoBubbleDataPacket data = new InfoBubbleDataPacket();

            data.Style = InfoBubbleViewModel.Style.Error;
            data.ConnectingDirection = InfoBubbleViewModel.Direction.Bottom;

            this.ViewModel.ShowFullContentCommand.Execute(data);
        }
Esempio n. 8
0
        public void UpdateInfoBubble_ErrorBubble()
        {
            InfoBubbleViewModel infoBubble = new InfoBubbleViewModel(this.ViewModel);
            string content = "This is the test infoBubble";
            InfoBubbleDataPacket inputData_ErrorBubble = new InfoBubbleDataPacket(InfoBubbleViewModel.Style.Error,
                                                                                  new Point(0, 0), new Point(0, 0), content, InfoBubbleViewModel.Direction.Bottom);

            if (infoBubble.UpdateContentCommand.CanExecute(null))
            {
                infoBubble.UpdateContentCommand.Execute(inputData_ErrorBubble);
                Assert.AreEqual(content, infoBubble.Content);
                Assert.AreEqual(InfoBubbleViewModel.Style.Error, infoBubble.InfoBubbleStyle);
                Assert.AreEqual(InfoBubbleViewModel.Direction.Bottom, infoBubble.ConnectingDirection);
            }
        }
Esempio n. 9
0
        public void UpdateInfoBubble_NodeTooltip()
        {
            var    infoBubble            = new InfoBubbleViewModel();
            string content               = "This is the test infoBubble";
            var    inputData_NodeTooltip = new InfoBubbleDataPacket(InfoBubbleViewModel.Style.NodeTooltip,
                                                                    new Point(0, 0), new Point(0, 0), content, InfoBubbleViewModel.Direction.Right);

            if (infoBubble.UpdateContentCommand.CanExecute(null))
            {
                infoBubble.UpdateContentCommand.Execute(inputData_NodeTooltip);
                Assert.AreEqual(content, infoBubble.Content);
                Assert.AreEqual(InfoBubbleViewModel.Style.NodeTooltip, infoBubble.InfoBubbleStyle);
                Assert.AreEqual(InfoBubbleViewModel.Direction.Right, infoBubble.ConnectingDirection);
            }
        }
Esempio n. 10
0
        public void UpdateInfoBubble_LibItem()
        {
            InfoBubbleViewModel infoBubble = new InfoBubbleViewModel();
            string content = "This is the test infoBubble";
            InfoBubbleDataPacket inputData_LibItem = new InfoBubbleDataPacket(InfoBubbleViewModel.Style.LibraryItemPreview,
                                                                              new Point(0, 0), new Point(0, 0), content, InfoBubbleViewModel.Direction.Left);

            if (infoBubble.UpdateContentCommand.CanExecute(null))
            {
                infoBubble.UpdateContentCommand.Execute(inputData_LibItem);
                Assert.AreEqual(content, infoBubble.Content);
                Assert.AreEqual(InfoBubbleViewModel.Style.LibraryItemPreview, infoBubble.InfoBubbleStyle);
                Assert.AreEqual(InfoBubbleViewModel.Direction.Left, infoBubble.ConnectingDirection);
            }
        }
Esempio n. 11
0
        private void LibraryItem_OnMouseEnter(object sender, MouseEventArgs e)
        {
            TreeViewItem treeViewItem = sender as TreeViewItem;
            NodeSearchElement nodeSearchElement = treeViewItem.Header as NodeSearchElement;
            if (nodeSearchElement == null)
                return;

            Point pointToScreen_TopLeft = treeViewItem.PointToScreen(new Point(0, 0));
            Point topLeft = this.PointFromScreen(pointToScreen_TopLeft);
            Point pointToScreen_BotRight = new Point(pointToScreen_TopLeft.X + treeViewItem.ActualWidth, pointToScreen_TopLeft.Y + treeViewItem.ActualHeight);
            Point botRight = this.PointFromScreen(pointToScreen_BotRight);
            string infoBubbleContent = nodeSearchElement.Description;
            InfoBubbleDataPacket data = new InfoBubbleDataPacket(InfoBubbleViewModel.Style.LibraryItemPreview, topLeft,
                botRight, infoBubbleContent, InfoBubbleViewModel.Direction.Left);
            DynamoCommands.ShowLibItemInfoBubbleCommand.Execute(data);
        }
Esempio n. 12
0
        public void NodeWarningBarVisibility()
        {
            OpenModel(@"core\Home.dyn");

            var info = "Information";

            // Arrange
            var         dummyNode = new DummyNode();
            DynamoModel model     = GetModel();

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(dummyNode, 0, 0, true, true));

            NodeViewModel dummyNodeViewModel = ViewModel.CurrentSpaceViewModel.Nodes
                                               .FirstOrDefault(x => x.NodeModel.GUID == dummyNode.GUID);

            NodeModel dummyNodeModel = dummyNodeViewModel.NodeModel;

            if (dummyNodeViewModel.ErrorBubble == null)
            {
                dummyNodeViewModel.ErrorBubble = new InfoBubbleViewModel(ViewModel);
            }

            InfoBubbleViewModel infoBubbleViewModel = dummyNodeViewModel.ErrorBubble;

            ObservableCollection <InfoBubbleDataPacket> nodeMessages = infoBubbleViewModel.NodeMessages;

            // Assert
            Assert.IsFalse(dummyNodeViewModel.NodeWarningBarVisible);

            // Act
            InfoBubbleDataPacket infoBubbleDataPacket = new InfoBubbleDataPacket
                                                        (
                InfoBubbleViewModel.Style.Info,
                new Point(dummyNodeModel.X, dummyNodeModel.Y),
                new Point(dummyNodeModel.X + dummyNodeModel.Width, dummyNodeModel.Y + dummyNodeModel.Height),
                info,
                InfoBubbleViewModel.Direction.Top
                                                        );

            nodeMessages.Add(infoBubbleDataPacket);

            Assert.IsTrue(infoBubbleViewModel.NodeInfoVisible);

            infoBubbleViewModel.DismissMessageCommand.Execute(infoBubbleDataPacket);

            Assert.IsFalse(dummyNodeViewModel.NodeWarningBarVisible);
        }
Esempio n. 13
0
        private void SetupAndShowTooltip(UIElement sender, InfoBubbleViewModel.Direction direction)
        {
            string content      = "";
            double actualWidth  = 0;
            double actualHeight = 0;

            switch (direction)
            {
            case InfoBubbleViewModel.Direction.Bottom:
                TextBlock tb = sender as TextBlock;
                content = ViewModel.Description;
                if (string.IsNullOrWhiteSpace(content))
                {
                    return;
                }

                actualWidth  = tb.ActualWidth * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
                actualHeight = tb.ActualHeight * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
                break;

            case InfoBubbleViewModel.Direction.Left:
            case InfoBubbleViewModel.Direction.Right:
                ContentPresenter nodePort = sender as ContentPresenter;
                content = (nodePort.Content as PortViewModel).ToolTipContent;
                if (string.IsNullOrWhiteSpace(content))
                {
                    return;
                }

                actualWidth  = nodePort.ActualWidth * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
                actualHeight = nodePort.ActualHeight * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
                break;
            }

            UIElement containingWorkspace = WPF.FindUpVisualTree <TabControl>(this);

            InfoBubbleDataPacket data = new InfoBubbleDataPacket();

            data.Text                = content;
            data.Style               = InfoBubbleViewModel.Style.NodeTooltip;
            data.TopLeft             = sender.TranslatePoint(new Point(0, 0), containingWorkspace);
            data.BotRight            = new Point(data.TopLeft.X + actualWidth, data.TopLeft.Y + actualHeight);
            data.ConnectingDirection = direction;

            StartDelayedTooltipFadeIn(data);
        }
Esempio n. 14
0
        public void CanDismissUserFacingMessages()
        {
            OpenModel(@"core\Home.dyn");

            var info1 = "Dismissed Info 1";

            // Arrange
            var         dummyNode = new DummyNode();
            DynamoModel model     = GetModel();

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(dummyNode, 0, 0, true, true));

            NodeViewModel dummyNodeViewModel = ViewModel.CurrentSpaceViewModel.Nodes
                                               .FirstOrDefault(x => x.NodeModel.GUID == dummyNode.GUID);

            NodeModel dummyNodeModel = dummyNodeViewModel.NodeModel;

            var topLeft  = new Point(dummyNodeModel.X, dummyNodeModel.Y);
            var botRight = new Point(dummyNodeModel.X + dummyNodeModel.Width, dummyNodeModel.Y + dummyNodeModel.Height);

            if (dummyNodeViewModel.ErrorBubble == null)
            {
                dummyNodeViewModel.ErrorBubble = new InfoBubbleViewModel(ViewModel);
            }

            InfoBubbleViewModel infoBubbleViewModel = dummyNodeViewModel.ErrorBubble;

            // The collection of messages the node receives
            ObservableCollection <InfoBubbleDataPacket> nodeMessages = infoBubbleViewModel.NodeMessages;

            // Act
            InfoBubbleDataPacket infoBubbleDataPacket = new InfoBubbleDataPacket(InfoBubbleViewModel.Style.Info, topLeft, botRight, info1, InfoBubbleViewModel.Direction.Top);

            nodeMessages.Add(infoBubbleDataPacket);

            Assert.AreEqual(1, infoBubbleViewModel.NodeInfoToDisplay.Count);
            Assert.AreEqual(0, infoBubbleViewModel.DismissedMessages.Count);
            Assert.IsTrue(infoBubbleViewModel.NodeInfoVisible);

            infoBubbleViewModel.DismissMessageCommand.Execute(infoBubbleDataPacket);

            // Assert
            Assert.AreEqual(0, infoBubbleViewModel.NodeInfoToDisplay.Count);
            Assert.AreEqual(1, infoBubbleViewModel.DismissedMessages.Count);
            Assert.AreEqual(info1, infoBubbleViewModel.DismissedMessages.First().Message);
        }
Esempio n. 15
0
        private void ShowErrorBubbleCondensedContent()
        {
            if (this.IsDisconnected)
            {
                return;
            }

            InfoBubbleDataPacket data = new InfoBubbleDataPacket();

            if (ViewModel.InfoBubbleStyle == InfoBubbleViewModel.Style.Error)
            {
                data.Style = InfoBubbleViewModel.Style.ErrorCondensed;
            }
            else if (ViewModel.InfoBubbleStyle == InfoBubbleViewModel.Style.Warning)
            {
                data.Style = InfoBubbleViewModel.Style.WarningCondensed;
            }
            data.ConnectingDirection = InfoBubbleViewModel.Direction.Bottom;

            this.ViewModel.ShowCondensedContentCommand.Execute(data);
        }
Esempio n. 16
0
        public void CanTriggerDocumentationLinkEvent()
        {
            // Arrange
            InfoBubbleViewModel infoBubble        = new InfoBubbleViewModel(this.ViewModel);
            const string        documentationFile = "dynamo.html";
            string content = $"This is the test infoBubble href={documentationFile}";
            InfoBubbleDataPacket infoBubbleDataPacket = new InfoBubbleDataPacket(InfoBubbleViewModel.Style.Error,
                                                                                 new Point(0, 0), new Point(0, 0), content, InfoBubbleViewModel.Direction.Bottom);
            var docEventArgs = new OpenDocumentationLinkEventArgs(infoBubbleDataPacket.Link);

            // register an extra handler for documentation events so we can confirm
            // the Dynamo ViewModel event gets triggered from the InfoBubble viewmodel
            RequestOpenDocumentationLinkHandler handler = (OpenDocumentationLinkEventArgs e) =>
            {
                Assert.IsNotNull(e);
                Assert.AreEqual(documentationFile, e.Link.ToString());
            };

            this.ViewModel.RequestOpenDocumentationLink += handler;

            // Act
            // test we can pass in content with a link and it gets set
            if (infoBubble.UpdateContentCommand.CanExecute(null))
            {
                infoBubble.UpdateContentCommand.Execute(infoBubbleDataPacket);
            }
            // test the InfoBubbleViewModel raises the right DynamoViewModel event
            if (infoBubble.OpenDocumentationLinkCommand.CanExecute(null))
            {
                infoBubble.OpenDocumentationLinkCommand.Execute(docEventArgs.Link);
            }

            // Assert
            Assert.IsNotNull(infoBubble.DocumentationLink);
            Assert.AreEqual(documentationFile, infoBubble.DocumentationLink.ToString());
            this.ViewModel.RequestOpenDocumentationLink -= handler;
        }