public dynWatch() { InPortData.Add(new PortData("", "Node to evaluate.", typeof(object))); OutPortData.Add(new PortData("", "Watch contents.", typeof(string))); NodeUI.RegisterAllPorts(); //take out the left and right margins //and make this so it's not so wide NodeUI.inputGrid.Margin = new Thickness(10, 5, 10, 5); NodeUI.topControl.Width = 300; //set a default height //oldPreferredHeight = NodeUI.PreferredHeight; NodeUI.Height = 200; wt = new WatchTree(); //wt.TreeExpanded += new EventHandler(wt_TreeExpanded); //wt.TreeCollapsed += new EventHandler(wt_TreeCollapsed); NodeUI.inputGrid.Children.Add(wt); wtb = wt.FindResource("Tree") as WatchTreeBranch; foreach (dynPort p in NodeUI.InPorts) { p.PortDisconnected += new PortConnectedHandler(p_PortDisconnected); } }
private void RefreshExpandedDisplay() { // The preview control will not have its content refreshed unless // the content is null. In order to perform real refresh, new data // source needs to be rebound to the preview control by calling // BindToDataSource method. // if (this.cachedLargeContent != null) return; if (largeContentGrid.Children.Count <= 0) { var newWatchTree = new WatchTree(); newWatchTree.DataContext = new WatchViewModel(); largeContentGrid.Children.Add(newWatchTree); } var watchTree = largeContentGrid.Children[0] as WatchTree; var rootDataContext = watchTree.DataContext as WatchViewModel; // Associate the data context to the view before binding. cachedLargeContent = Watch.Process(mirrorData, string.Empty, false); rootDataContext.Children.Add(cachedLargeContent); // Establish data binding between data context and the view. watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty, new Binding("Children") { Mode = BindingMode.TwoWay, Source = rootDataContext }); }
/// <summary> /// Obtain the expanded preview values for this control. Must not be called from /// Scheduler thread or this could cause a live-lock. /// </summary> /// private void RefreshExpandedDisplay(Action refreshDisplay) { // The preview control will not have its content refreshed unless // the content is null. In order to perform real refresh, new data // source needs to be rebound to the preview control by calling // BindToDataSource method. // if (this.cachedLargeContent != null) { // If there are cached contents, simply update the UI and return if (refreshDisplay != null) { refreshDisplay(); } return; } WatchViewModel newViewModel = null; RunOnSchedulerSync( () => { newViewModel = nodeViewModel.DynamoViewModel.WatchHandler.GenerateWatchViewModelForData( mirrorData, null, string.Empty, false); }, (m) => { if (largeContentGrid.Children.Count == 0) { var tree = new WatchTree { DataContext = new WatchViewModel() }; tree.treeView1.ItemContainerGenerator.StatusChanged += WatchContainer_StatusChanged; largeContentGrid.Children.Add(tree); } var watchTree = largeContentGrid.Children[0] as WatchTree; var rootDataContext = watchTree.DataContext as WatchViewModel; cachedLargeContent = newViewModel; rootDataContext.IsOneRowContent = cachedLargeContent.Children.Count == 0; rootDataContext.Children.Clear(); rootDataContext.Children.Add(cachedLargeContent); watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty, new Binding("Children") { Mode = BindingMode.TwoWay, Source = rootDataContext }); if (refreshDisplay != null) { refreshDisplay(); } } ); }
/// <summary> /// Obtain the expanded preview values for this control. Must not be called from /// Scheduler thread or this could cause a live-lock. /// </summary> private void RefreshExpandedDisplay() { // The preview control will not have its content refreshed unless // the content is null. In order to perform real refresh, new data // source needs to be rebound to the preview control by calling // BindToDataSource method. // if (this.cachedLargeContent != null) return; WatchViewModel newViewModel = null; RunOnSchedulerSync(() => { newViewModel = nodeViewModel.DynamoViewModel.WatchHandler.GenerateWatchViewModelForData( mirrorData, null, string.Empty, false); }); if (largeContentGrid.Children.Count == 0) { var tree = new WatchTree(); tree.DataContext = new WatchViewModel(nodeViewModel.DynamoViewModel.VisualizationManager); largeContentGrid.Children.Add(tree); } var watchTree = largeContentGrid.Children[0] as WatchTree; var rootDataContext = watchTree.DataContext as WatchViewModel; cachedLargeContent = newViewModel; rootDataContext.Children.Clear(); rootDataContext.Children.Add(cachedLargeContent); watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty, new Binding("Children") { Mode = BindingMode.TwoWay, Source = rootDataContext }); }
/// <summary> /// Obtain the expanded preview values for this control. Must not be called from /// Scheduler thread or this could cause a live-lock. /// </summary> private void RefreshExpandedDisplay(Action refreshDisplay) { // The preview control will not have its content refreshed unless // the content is null. In order to perform real refresh, new data // source needs to be rebound to the preview control by calling // BindToDataSource method. // if (this.cachedLargeContent != null) { // If there are cached contents, simply update the UI and return if (refreshDisplay != null) { refreshDisplay(); } return; } WatchViewModel newViewModel = null; RunOnSchedulerSync( () => { newViewModel = nodeViewModel.DynamoViewModel.WatchHandler.GenerateWatchViewModelForData( nodeViewModel.NodeModel.CachedValue, null, nodeViewModel.NodeModel.AstIdentifierForPreview.Name, false); }, (m) => { //If newViewModel is not set then no point continuing. if (newViewModel == null) return; if (largeContentGrid.Children.Count == 0) { var tree = new WatchTree { DataContext = new WatchViewModel(nodeViewModel.DynamoViewModel.BackgroundPreviewViewModel.AddLabelForPath) }; tree.treeView1.ItemContainerGenerator.StatusChanged += WatchContainer_StatusChanged; largeContentGrid.Children.Add(tree); } var watchTree = largeContentGrid.Children[0] as WatchTree; if (watchTree != null) { var rootDataContext = watchTree.DataContext as WatchViewModel; cachedLargeContent = newViewModel; if (rootDataContext != null) { rootDataContext.IsOneRowContent = cachedLargeContent.Children.Count == 0; rootDataContext.Children.Clear(); rootDataContext.Children.Add(cachedLargeContent); rootDataContext.CountNumberOfItems(); //count the total number of items in the list if (!rootDataContext.IsOneRowContent) { rootDataContext.CountLevels(); watchTree.listLevelsView.ItemsSource = rootDataContext.Levels; // add listLevelList to the ItemsSource of listlevelsView in WatchTree rootDataContext.Children[0].IsTopLevel = true; } watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty, new Binding("Children") { Mode = BindingMode.TwoWay, Source = rootDataContext }); } } if (refreshDisplay != null) { refreshDisplay(); } } ); }
public override void SetupCustomUIElements(dynNodeView NodeUI) { watchTree = new WatchTree(); NodeUI.inputGrid.Children.Add(watchTree); watchTreeBranch = watchTree.FindResource("Tree") as WatchTreeBranch; }
public override void SetupCustomUIElements(dynNodeView nodeUI) { watchTree = new WatchTree(); //nodeUI.inputGrid.Children.Add(watchTree); nodeUI.grid.Children.Add(watchTree); watchTree.SetValue(Grid.RowProperty,2); watchTree.SetValue(Grid.ColumnSpanProperty,3); watchTree.Margin = new Thickness(5,0,5,5); watchTreeBranch = watchTree.FindResource("Tree") as WatchTreeBranch; }