public static void RespondToSnap() { int flag = 0; double fadeTime = 0.75; //obtain the node view to fade _nodeViews = loadedParams.DynamoWindow.FindVisualChildren <NodeView>().ToList(); //loop through the nodes while delaying the time each loop while (flag < _fiftyPercent.Count()) { _currentNode = _fiftyPercent[flag]; var nodeView = _nodeViews.First(n => n.ViewModel.Id.ToString().Equals(_currentNode.GUID.ToString())); if (flag == _fiftyPercent.Count() - 1) { //future info bubble display _infoBubble = nodeView.ViewModel.ErrorBubble; nodeView.ViewModel.ErrorBubble.InfoBubbleState = InfoBubbleViewModel.State.Pinned; nodeView.ViewModel.ErrorBubble.InfoBubbleStyle = InfoBubbleViewModel.Style.Warning; nodeView.ViewModel.ErrorBubble.Content = "i don't feel so good...."; nodeView.ViewModel.ErrorBubble.FullContent = nodeView.Uid; } DoubleAnimation animation = new DoubleAnimation(0, TimeSpan.FromSeconds(fadeTime)); nodeView.BeginAnimation(Control.OpacityProperty, animation); flag++; fadeTime = fadeTime + 0.75; } DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(fadeTime); timer.Tick += TimerOnTick; timer.Start(); }
public void Collapse() { InfoBubbleViewModel infoBubble = new InfoBubbleViewModel(this.ViewModel); infoBubble.OnRequestAction(new InfoBubbleEventArgs(InfoBubbleEventArgs.Request.Hide)); //Assert.AreEqual(0, infoBubble.Opacity); }
public void Collapse() { InfoBubbleViewModel infoBubble = new InfoBubbleViewModel(); infoBubble.InstantCollapseCommand.Execute(null); Assert.AreEqual(0, infoBubble.Opacity); }
public void CollapsedGroupDisplaysWarningIfNodeInWarningState() { // Adding a dummy node to the workspace 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); ViewModel.Model.CurrentWorkspace.AddAndRegisterNode(dummyNode, false); //verify the node was created Assert.AreEqual(1, ViewModel.Model.CurrentWorkspace.Nodes.Count()); //Select the node for group DynamoSelection.Instance.Selection.Add(dummyNode); //Create a Group around that node ViewModel.AddAnnotationCommand.Execute(null); var annotation = ViewModel.Model.CurrentWorkspace.Annotations.FirstOrDefault(); var annotationViewModel = ViewModel.CurrentSpaceViewModel.Annotations.FirstOrDefault(); //Check if the group is created Assert.IsNotNull(annotation); //Clear the selection DynamoSelection.Instance.ClearSelection(); // Collapses the group annotationViewModel.IsExpanded = false; NodeModel dummyNodeModel = dummyNodeViewModel.NodeModel; var topLeft = new Point(dummyNodeViewModel.X, dummyNodeViewModel.Y); var botRight = new Point(dummyNodeViewModel.X + dummyNodeModel.Width, dummyNodeViewModel.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; nodeMessages.Add(new InfoBubbleDataPacket(InfoBubbleViewModel.Style.Warning, topLeft, botRight, "Warning", InfoBubbleViewModel.Direction.Top)); Assert.AreEqual(ElementState.Warning, annotationViewModel.AnnotationModel.GroupState); }
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); }
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); } }
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); } }
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); } }
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); }
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); }
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; }
/// <summary> /// Class constructor /// </summary> public DynamoController(string context, IUpdateManager updateManager, ILogger logger, IWatchHandler watchHandler, IPreferences preferences) { IsCrashing = false; DynamoLogger = logger; dynSettings.Controller = this; Context = context; //Start heartbeat reporting InstrumentationLogger.Start(); PreferenceSettings = preferences; ((PreferenceSettings)PreferenceSettings).PropertyChanged += PreferenceSettings_PropertyChanged; BaseUnit.LengthUnit = PreferenceSettings.LengthUnit; BaseUnit.AreaUnit = PreferenceSettings.AreaUnit; BaseUnit.VolumeUnit = PreferenceSettings.VolumeUnit; BaseUnit.NumberFormat = PreferenceSettings.NumberFormat; UpdateManager = updateManager; UpdateManager.UpdateDownloaded += updateManager_UpdateDownloaded; UpdateManager.ShutdownRequested += updateManager_ShutdownRequested; UpdateManager.CheckForProductUpdate(new UpdateRequest(new Uri(Configurations.UpdateDownloadLocation), dynSettings.Controller.DynamoLogger, UpdateManager.UpdateDataAvailable)); WatchHandler = watchHandler; //create the model DynamoModel = new DynamoModel(); DynamoModel.AddHomeWorkspace(); DynamoModel.CurrentWorkspace = DynamoModel.HomeSpace; DynamoModel.CurrentWorkspace.X = 0; DynamoModel.CurrentWorkspace.Y = 0; // custom node loader string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string pluginsPath = Path.Combine(directory, "definitions"); CustomNodeManager = new CustomNodeManager(pluginsPath); SearchViewModel = new SearchViewModel(); dynSettings.PackageLoader = new PackageLoader(); dynSettings.PackageLoader.DoCachedPackageUninstalls(); dynSettings.PackageLoader.LoadPackages(); DisposeLogic.IsShuttingDown = false; //This is necessary to avoid a race condition by causing a thread join //inside the vm exec //TODO(Luke): Push this into a resync call with the engine controller ResetEngine(); dynSettings.Controller.DynamoLogger.Log(String.Format( "Dynamo -- Build {0}", Assembly.GetExecutingAssembly().GetName().Version)); DynamoLoader.ClearCachedAssemblies(); DynamoLoader.LoadNodeModels(); InfoBubbleViewModel = new InfoBubbleViewModel(); MigrationManager.Instance.MigrationTargets.Add(typeof(WorkspaceMigrations)); evaluationWorker.DoWork += RunThread; }
public void CanAddUserFacingMessagesToNode() { // Arrange OpenModel(@"core\Home.dyn"); var info1 = "Info 1"; var warning1 = "Warning 1"; var error1 = "Error 1"; 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; // The collections of messages the node displays to the user ObservableCollection <InfoBubbleDataPacket> userFacingInfo = infoBubbleViewModel.NodeInfoToDisplay; ObservableCollection <InfoBubbleDataPacket> userFacingWarnings = infoBubbleViewModel.NodeWarningsToDisplay; ObservableCollection <InfoBubbleDataPacket> userFacingErrors = infoBubbleViewModel.NodeErrorsToDisplay; // Act Assert.AreEqual(0, userFacingInfo.Count); Assert.AreEqual(0, userFacingWarnings.Count); Assert.AreEqual(0, userFacingErrors.Count); Assert.IsFalse(infoBubbleViewModel.NodeInfoVisible); Assert.IsFalse(infoBubbleViewModel.NodeWarningsVisible); Assert.IsFalse(infoBubbleViewModel.NodeErrorsVisible); nodeMessages.Add(new InfoBubbleDataPacket(InfoBubbleViewModel.Style.Info, topLeft, botRight, info1, InfoBubbleViewModel.Direction.Top)); nodeMessages.Add(new InfoBubbleDataPacket(InfoBubbleViewModel.Style.Warning, topLeft, botRight, warning1, InfoBubbleViewModel.Direction.Top)); nodeMessages.Add(new InfoBubbleDataPacket(InfoBubbleViewModel.Style.Error, topLeft, botRight, error1, InfoBubbleViewModel.Direction.Top)); // Assert Assert.AreEqual(1, userFacingInfo.Count); Assert.AreEqual(1, userFacingWarnings.Count); Assert.AreEqual(1, userFacingErrors.Count); Assert.IsTrue(infoBubbleViewModel.NodeInfoVisible); Assert.IsTrue(infoBubbleViewModel.NodeWarningsVisible); Assert.IsTrue(infoBubbleViewModel.NodeErrorsVisible); Assert.IsFalse(infoBubbleViewModel.NodeInfoIteratorVisible); Assert.IsFalse(infoBubbleViewModel.NodeWarningsIteratorVisible); Assert.IsFalse(infoBubbleViewModel.NodeErrorsIteratorVisible); Assert.IsFalse(infoBubbleViewModel.NodeInfoShowMoreButtonVisible); Assert.IsFalse(infoBubbleViewModel.NodeWarningsShowMoreButtonVisible); Assert.IsFalse(infoBubbleViewModel.NodeErrorsShowMoreButtonVisible); Assert.AreEqual(info1, userFacingInfo.First().Message); Assert.AreEqual(warning1, userFacingWarnings.First().Message); Assert.AreEqual(error1, userFacingErrors.First().Message); }