private void Bind(WatchTree watchTree, NodeView nodeView) { // The WatchTree Control is bound to the WatchViewModel watchTree.DataContext = rootWatchViewModel; // Add binding for TreeView var sourceBinding = new Binding("Children") { Mode = BindingMode.TwoWay, Source = rootWatchViewModel, }; watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty, sourceBinding); // Add binding for "Show Raw Data" in context menu var checkedBinding = new Binding("ShowRawData") { Mode = BindingMode.TwoWay, Source = rootWatchViewModel }; var rawDataMenuItem = new MenuItem { Header = "Show Raw Data", IsCheckable = true, }; rawDataMenuItem.SetBinding(MenuItem.IsCheckedProperty, checkedBinding); nodeView.MainContextMenu.Items.Add(rawDataMenuItem); }
public override void SetupCustomUIElements(object ui) { var nodeUI = ui as dynNodeView; watchTree = new WatchTree(); nodeUI.grid.Children.Add(watchTree); watchTree.SetValue(Grid.RowProperty, 2); watchTree.SetValue(Grid.ColumnSpanProperty, 3); watchTree.Margin = new Thickness(5, 0, 5, 5); if (Root == null) { Root = new WatchNode(); } watchTree.DataContext = Root; this.RequestBindingUnhook += new EventHandler(delegate { BindingOperations.ClearAllBindings(watchTree.treeView1); }); this.RequestBindingRehook += new EventHandler(delegate { var sourceBinding = new Binding("Children") { Mode = BindingMode.TwoWay, Source = Root, }; watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty, sourceBinding); }); }
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 }); }
public void CustomizeView(Watch nodeModel, NodeView nodeView) { this.dynamoViewModel = nodeView.ViewModel.DynamoViewModel; this.watch = nodeModel; this.syncContext = new DispatcherSynchronizationContext(nodeView.Dispatcher); var watchTree = new WatchTree(); watchTree.BorderThickness = new Thickness(1, 1, 1, 1); watchTree.BorderBrush = new SolidColorBrush(Color.FromRgb(220, 220, 220)); watchTree.SetWatchNodeProperties(); // make empty watchViewModel rootWatchViewModel = new WatchViewModel(dynamoViewModel.BackgroundPreviewViewModel.AddLabelForPath); nodeView.PresentationGrid.Children.Add(watchTree); nodeView.PresentationGrid.Visibility = Visibility.Visible; // disable preview control nodeView.TogglePreviewControlAllowance(); Bind(watchTree, nodeView); Subscribe(); ResetWatch(); }
/// <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 { Margin = (System.Windows.Thickness) this.Resources["PreviewContentMargin"], DataContext = new WatchViewModel() }; 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 }); if (refreshDisplay != null) { refreshDisplay(); } } ); }
public void SetupCustomUIElements(dynNodeView nodeUI) { this.dynamoViewModel = nodeUI.ViewModel.DynamoViewModel; watchTree = new WatchTree(); // MAGN-2446: Fixes the maximum width/height of watch node so it won't // go too crazy on us. Note that this is only applied to regular watch // node so it won't be limiting the size of image/3D watch nodes. // nodeUI.PresentationGrid.MaxWidth = Configurations.MaxWatchNodeWidth; nodeUI.PresentationGrid.MaxHeight = Configurations.MaxWatchNodeHeight; nodeUI.PresentationGrid.Children.Add(watchTree); nodeUI.PresentationGrid.Visibility = Visibility.Visible; if (Root == null) { Root = new WatchViewModel(this.dynamoViewModel.VisualizationManager); } watchTree.DataContext = Root; RequestBindingUnhook += delegate { BindingOperations.ClearAllBindings(watchTree.treeView1); }; RequestBindingRehook += delegate { var sourceBinding = new Binding("Children") { Mode = BindingMode.TwoWay, Source = Root, }; watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty, sourceBinding); }; var checkedBinding = new Binding("ShowRawData") { Mode = BindingMode.TwoWay, Source = Root }; var rawDataMenuItem = new MenuItem { Header = "Show Raw Data", IsCheckable = true, }; rawDataMenuItem.SetBinding(MenuItem.IsCheckedProperty, checkedBinding); nodeUI.MainContextMenu.Items.Add(rawDataMenuItem); ((PreferenceSettings)this.Workspace.DynamoModel.PreferenceSettings).PropertyChanged += PreferenceSettings_PropertyChanged; Root.PropertyChanged += Root_PropertyChanged; }
private void Bind(WatchTree watchTree, NodeView nodeView) { // The WatchTree Control is bound to the WatchViewModel watchTree.DataContext = rootWatchViewModel; // Add binding for TreeView var sourceBinding = new Binding("Children") { Mode = BindingMode.TwoWay, Source = rootWatchViewModel, }; watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty, sourceBinding); // add binding for ItemCount var numItemsBinding = new Binding("NumberOfItems") { Mode = BindingMode.TwoWay, Source = rootWatchViewModel, }; watchTree.ListItems.SetBinding(ItemsControl.ItemsSourceProperty, numItemsBinding); // add binding for depth of list var listlevelBinding = new Binding("Levels") { Mode = BindingMode.TwoWay, Source = rootWatchViewModel, }; watchTree.listLevelsView.SetBinding(ItemsControl.ItemsSourceProperty, listlevelBinding); // Add binding for "Show Raw Data" in context menu var checkedBinding = new Binding("ShowRawData") { Mode = BindingMode.TwoWay, Source = rootWatchViewModel }; var rawDataMenuItem = new MenuItem { Header = Dynamo.Wpf.Properties.Resources.WatchNodeRawDataMenu, IsCheckable = true, }; rawDataMenuItem.SetBinding(MenuItem.IsCheckedProperty, checkedBinding); nodeView.MainContextMenu.Items.Add(rawDataMenuItem); var copyToClipboardMenuItem = new MenuItem { Header = Dynamo.Wpf.Properties.Resources.ContextMenuCopy }; copyToClipboardMenuItem.Click += OnCopyToClipboardClick; nodeView.MainContextMenu.Items.Add(copyToClipboardMenuItem); }
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; }
/// <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 }); }
public void CustomizeView(Watch nodeModel, NodeView nodeView) { this.dynamoViewModel = nodeView.ViewModel.DynamoViewModel; this.watch = nodeModel; var watchTree = new WatchTree(); // make empty watchViewModel rootWatchViewModel = new WatchViewModel(this.dynamoViewModel.VisualizationManager); // Fix the maximum width/height of watch node. nodeView.PresentationGrid.MaxWidth = Configurations.MaxWatchNodeWidth; nodeView.PresentationGrid.MaxHeight = Configurations.MaxWatchNodeHeight; nodeView.PresentationGrid.Children.Add(watchTree); nodeView.PresentationGrid.Visibility = Visibility.Visible; Bind(watchTree, nodeView); Subscribe(); }
public dynWatch() { InPortData.Add(new PortData("", "Node to evaluate.", typeof(object))); OutPortData = new PortData("", "Watch contents, passed through", typeof(object)); base.RegisterInputsAndOutputs(); //take out the left and right margins //and make this so it's not so wide this.inputGrid.Margin = new Thickness(10, 5, 10, 5); this.topControl.Width = 300; this.topControl.Height = 200; wt = new WatchTree(); this.inputGrid.Children.Add(wt); wtb = wt.FindResource("Tree") as WatchTreeBranch; foreach (dynPort p in this.InPorts) { p.PortDisconnected += new PortConnectedHandler(p_PortDisconnected); } }
public void CustomizeView(Watch nodeModel, NodeView nodeView) { this.dynamoViewModel = nodeView.ViewModel.DynamoViewModel; this.watch = nodeModel; this.syncContext = new DispatcherSynchronizationContext(nodeView.Dispatcher); var watchTree = new WatchTree(); // make empty watchViewModel rootWatchViewModel = new WatchViewModel(dynamoViewModel.BackgroundPreviewViewModel.AddLabelForPath); // Fix the maximum width/height of watch node. nodeView.PresentationGrid.MaxWidth = Configurations.MaxWatchNodeWidth; nodeView.PresentationGrid.MaxHeight = Configurations.MaxWatchNodeHeight; nodeView.PresentationGrid.Children.Add(watchTree); nodeView.PresentationGrid.Visibility = Visibility.Visible; // disable preview control nodeView.TogglePreviewControlAllowance(); Bind(watchTree, nodeView); Subscribe(); ResetWatch(); }
/// <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 (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); 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(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( () => { IEnumerable <string> preferredDictionaryOrdering; if (nodeViewModel.NodeModel is DSFunction dsFunction) { preferredDictionaryOrdering = dsFunction.Controller.ReturnKeys; } else { preferredDictionaryOrdering = nodeViewModel.NodeModel.OutPorts.Select(p => p.Name).Where(n => !string.IsNullOrEmpty(n)); } newViewModel = nodeViewModel.DynamoViewModel.WatchHandler.GenerateWatchViewModelForData( nodeViewModel.NodeModel.CachedValue, preferredDictionaryOrdering, 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 void CustomizeView(Nodes.Watch nodeModel, NodeView nodeView) { this.dynamoViewModel = nodeView.ViewModel.DynamoViewModel; // TODO(Peter): Watch should not know about the ViewModel layer MAGN-5590 nodeModel.DynamoViewModel = this.dynamoViewModel; this.watchNodeModel = nodeModel; watchTree = new WatchTree(); // MAGN-2446: Fixes the maximum width/height of watch node so it won't // go too crazy on us. Note that this is only applied to regular watch // node so it won't be limiting the size of image/3D watch nodes. // nodeView.PresentationGrid.MaxWidth = Configurations.MaxWatchNodeWidth; nodeView.PresentationGrid.MaxHeight = Configurations.MaxWatchNodeHeight; nodeView.PresentationGrid.Children.Add(watchTree); nodeView.PresentationGrid.Visibility = Visibility.Visible; if (watchNodeModel.Root == null) { watchNodeModel.Root = new WatchViewModel(this.dynamoViewModel.VisualizationManager); } watchTree.DataContext = watchNodeModel.Root; watchNodeModel.RequestBindingUnhook += delegate { BindingOperations.ClearAllBindings(watchTree.treeView1); }; watchNodeModel.RequestBindingRehook += delegate { var sourceBinding = new Binding("Children") { Mode = BindingMode.TwoWay, Source = watchNodeModel.Root, }; watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty, sourceBinding); }; var checkedBinding = new Binding("ShowRawData") { Mode = BindingMode.TwoWay, Source = watchNodeModel.Root }; var rawDataMenuItem = new MenuItem { Header = "Show Raw Data", IsCheckable = true, }; rawDataMenuItem.SetBinding(MenuItem.IsCheckedProperty, checkedBinding); nodeView.MainContextMenu.Items.Add(rawDataMenuItem); nodeView.ViewModel.DynamoViewModel.Model.PreferenceSettings.PropertyChanged += PreferenceSettings_PropertyChanged; watchNodeModel.Root.PropertyChanged += Root_PropertyChanged; DataBridge.Instance.RegisterCallback(watchNodeModel.GUID.ToString(), EvaluationCompleted); }