Пример #1
0
        public virtual void CustomizeView(VariableInputNode nodeModel, NodeView nodeView)
        {
            var addButton = new DynamoNodeButton(nodeView.ViewModel.NodeModel, "AddInPort")
            {
                Content = "+",
                Style   = (Style)SharedDictionaryManager.DynamoModernDictionary["AddRemoveButton"]
            };

            var subButton = new DynamoNodeButton(nodeView.ViewModel.NodeModel, "RemoveInPort")
            {
                Content = "-",
                Style   = (Style)SharedDictionaryManager.DynamoModernDictionary["AddRemoveButton"]
            };

            var wp = new WrapPanel
            {
                VerticalAlignment   = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            wp.Children.Add(addButton);
            wp.Children.Add(subButton);

            nodeView.inputGrid.Children.Add(wp);
        }
Пример #2
0
        public void CustomizeView(Test model, NodeView nodeView)
        {
            StackPanel s = new StackPanel();

            s.Orientation = Orientation.Horizontal;

            //add remove input buttons
            var addButton = new DynamoNodeButton(nodeView.ViewModel.NodeModel, "AddInPort")
            {
                Content = "+", Width = 20
            };
            var subButton = new DynamoNodeButton(nodeView.ViewModel.NodeModel, "RemoveInPort")
            {
                Content = "-", Width = 20
            };

            s.Children.Add(addButton);
            s.Children.Add(subButton);
            nodeView.inputGrid.Children.Add(s);

            _receiver = model;

            //bindings

            _receiver.libraryServices = nodeView.ViewModel.DynamoViewModel.EngineController.LibraryServices;
        }
Пример #3
0
        public void CustomizeView(FileSystemBrowser model, NodeView nodeView)
        {
            //add a button to the inputGrid on the dynElement
            var readFileButton = new DynamoNodeButton
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Top,
                Height = Configurations.PortHeightInPixels
            };

            readFileButton.Click              += readFileButton_Click;
            readFileButton.Content             = Dynamo.Wpf.Properties.Resources.BrowserNodeButtonLabel;
            readFileButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            readFileButton.VerticalAlignment   = VerticalAlignment.Center;

            var tb = new TextBox();

            if (string.IsNullOrEmpty(model.Value))
            {
                model.Value = Dynamo.Wpf.Properties.Resources.BrowserNodeNoFileSelected;
            }

            tb.HorizontalAlignment = HorizontalAlignment.Stretch;
            tb.VerticalAlignment   = VerticalAlignment.Center;
            var backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0));

            tb.Background             = backgroundBrush;
            tb.BorderThickness        = new Thickness(0);
            tb.Foreground             = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 238, 238, 238));
            tb.FontFamily             = new System.Windows.Media.FontFamily("Artifakt Element");
            tb.FontSize               = 16;
            tb.IsReadOnly             = true;
            tb.IsReadOnlyCaretVisible = false;
            tb.TextChanged           += delegate
            {
                tb.ScrollToHorizontalOffset(double.PositiveInfinity);
                nodeView.ViewModel.DynamoViewModel.OnRequestReturnFocusToView();
            };
            tb.Margin = new Thickness(6, 8, 0, 5);

            var sp = new StackPanel();

            sp.Children.Add(readFileButton);
            nodeView.inputGrid.Children.Add(sp);

            nodeView.grid.Children.Add(tb);
            Grid.SetColumn(tb, 1);
            Grid.SetRow(tb, 3);
            Canvas.SetZIndex(tb, 5);

            tb.DataContext = model;
            var bindingVal = new Binding("Value")
            {
                Mode      = BindingMode.TwoWay,
                Converter = new FilePathDisplayConverter()
            };

            tb.SetBinding(TextBox.TextProperty, bindingVal);
        }
Пример #4
0
        public void CustomizeView(FileSystemBrowser model, NodeView nodeView)
        {
            //add a button to the inputGrid on the dynElement
            var readFileButton = new DynamoNodeButton
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Top,
                Height = Configurations.PortHeightInPixels
            };

            readFileButton.Click              += readFileButton_Click;
            readFileButton.Content             = "Browse...";
            readFileButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            readFileButton.VerticalAlignment   = VerticalAlignment.Center;

            var tb = new TextBox();

            if (string.IsNullOrEmpty(model.Value))
            {
                model.Value = "No file selected.";
            }

            tb.HorizontalAlignment = HorizontalAlignment.Stretch;
            tb.VerticalAlignment   = VerticalAlignment.Center;
            var backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0));

            tb.Background             = backgroundBrush;
            tb.BorderThickness        = new Thickness(0);
            tb.IsReadOnly             = true;
            tb.IsReadOnlyCaretVisible = false;
            tb.TextChanged           += delegate
            {
                tb.ScrollToHorizontalOffset(double.PositiveInfinity);
                nodeView.ViewModel.DynamoViewModel.ReturnFocusToSearch();
            };
            tb.Margin = new Thickness(0, 5, 0, 5);

            var sp = new StackPanel();

            sp.Children.Add(readFileButton);
            sp.Children.Add(tb);
            nodeView.inputGrid.Children.Add(sp);

            tb.DataContext = model;
            var bindingVal = new Binding("Value")
            {
                Mode      = BindingMode.TwoWay,
                Converter = new FilePathDisplayConverter()
            };

            tb.SetBinding(TextBox.TextProperty, bindingVal);
        }
Пример #5
0
        public override void SetupCustomUIElements(dynNodeView view)
        {
            //add a button to the inputGrid on the dynElement
            var readFileButton = new DynamoNodeButton
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Top,
                Height = Configurations.PortHeightInPixels
            };

            readFileButton.Click              += readFileButton_Click;
            readFileButton.Content             = "Browse...";
            readFileButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            readFileButton.VerticalAlignment   = VerticalAlignment.Center;

            var tb = new TextBox
            {
                HorizontalAlignment    = HorizontalAlignment.Stretch,
                VerticalAlignment      = VerticalAlignment.Center,
                Background             = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0)),
                BorderThickness        = new Thickness(0),
                IsReadOnly             = true,
                IsReadOnlyCaretVisible = false,
                Margin = new Thickness(0, 5, 0, 5)
            };

            tb.TextChanged += delegate {
                tb.ScrollToHorizontalOffset(double.PositiveInfinity);
                view.ViewModel.DynamoViewModel.ReturnFocusToSearch();
            };

            var sp = new StackPanel();

            sp.Children.Add(readFileButton);
            sp.Children.Add(tb);
            view.inputGrid.Children.Add(sp);

            tb.DataContext = this;
            var bindingVal = new Binding("Value")
            {
                Mode      = BindingMode.TwoWay,
                Converter = new FilePathDisplayConverter()
            };

            tb.SetBinding(TextBox.TextProperty, bindingVal);
        }
Пример #6
0
        public void CustomizeView(Sender model, NodeView nodeView)
        {
            var ui = new SenderUi();

            model.DocumentGuid = nodeView.ViewModel.DynamoViewModel.CurrentSpace.Guid.ToString();
            model.DocumentName = nodeView.ViewModel.DynamoViewModel.CurrentSpace.Name;
            if (Version.Parse(nodeView.ViewModel.DynamoViewModel.Version).CompareTo(new Version(2, 0)) < 0)
            {
                model.Error("Dynamo 2.0 or greater is required to run this package");
                return;
            }
            _sender = model;

            //bindings
            ui.DataContext      = _sender;
            ui.Loaded          += _sender.AddedToDocument;
            ui.ForceSend.Click += _sender.ForceSendClick;

            //add remove input buttons
            var addButton = new DynamoNodeButton(nodeView.ViewModel.NodeModel, "AddInPort")
            {
                Content = "+", Width = 20
            };
            var subButton = new DynamoNodeButton(nodeView.ViewModel.NodeModel, "RemoveInPort")
            {
                Content = "-", Width = 20
            };

            ui.DynamoButtons.Children.Add(addButton);
            ui.DynamoButtons.Children.Add(subButton);

            nodeView.inputGrid.Children.Add(ui);
            nodeView.grid.ContextMenu.Items.Add(new Separator());
            var mi = new MenuItem {
                Header = "Rename Inputs..."
            };
            var inputs = new ContextMenuItem();

            inputs.DataContext = _sender;
            mi.Items.Add(inputs);
            nodeView.grid.ContextMenu.Items.Add(mi);
        }
Пример #7
0
        public virtual void CustomizeView(VariableInputNode nodeModel, NodeView nodeView)
        {
            var addButton = new DynamoNodeButton(nodeView.ViewModel.NodeModel, "AddInPort")
            {
                Content = "+", Width = 20
            };
            var subButton = new DynamoNodeButton(nodeView.ViewModel.NodeModel, "RemoveInPort")
            {
                Content = "-", Width = 20
            };

            var wp = new WrapPanel
            {
                VerticalAlignment   = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            wp.Children.Add(addButton);
            wp.Children.Add(subButton);

            nodeView.inputGrid.Children.Add(wp);
        }
Пример #8
0
        public void CustomizeView(Sender model, NodeView nodeView)
        {
            var ui = new SenderUi();

            _sender = model;

            //bindings
            ui.DataContext      = _sender;
            ui.Loaded          += _sender.AddedToDocument;
            ui.ForceSend.Click += _sender.ForceSendClick;

            //add remove input buttons
            var addButton = new DynamoNodeButton(nodeView.ViewModel.NodeModel, "AddInPort")
            {
                Content = "+", Width = 20
            };
            var subButton = new DynamoNodeButton(nodeView.ViewModel.NodeModel, "RemoveInPort")
            {
                Content = "-", Width = 20
            };

            ui.DynamoButtons.Children.Add(addButton);
            ui.DynamoButtons.Children.Add(subButton);

            nodeView.inputGrid.Children.Add(ui);
            nodeView.grid.ContextMenu.Items.Add(new Separator());
            var mi = new MenuItem {
                Header = "Rename Inputs..."
            };
            var inputs = new ContextMenuItem();

            inputs.DataContext = _sender;
            mi.Items.Add(inputs);
            nodeView.grid.ContextMenu.Items.Add(mi);

            //wModel.InPorts.
        }
Пример #9
0
        public void CustomizeView(Sender model, NodeView nodeView)
        {
            var ui = new SenderUi();

            model.DocumentGuid = nodeView.ViewModel.DynamoViewModel.CurrentSpace.Guid.ToString();
            model.DocumentName = nodeView.ViewModel.DynamoViewModel.CurrentSpace.Name;
            if (Version.Parse(nodeView.ViewModel.DynamoViewModel.Version).CompareTo(new Version(2, 0)) < 0)
            {
                model.Error("Dynamo 2.0 or greater is required to run this package");
                return;
            }
            _sender = model;

            //bindings
            ui.DataContext      = _sender;
            ui.Loaded          += _sender.AddedToDocument;
            ui.ForceSend.Click += _sender.ForceSendClick;

            //add remove input buttons
            var addButton = new DynamoNodeButton(nodeView.ViewModel.NodeModel, "AddInPort")
            {
                Content = "+", Width = 20
            };
            var subButton = new DynamoNodeButton(nodeView.ViewModel.NodeModel, "RemoveInPort")
            {
                Content = "-", Width = 20
            };

            ui.DynamoButtons.Children.Add(addButton);
            ui.DynamoButtons.Children.Add(subButton);

            nodeView.inputGrid.Children.Add(ui);
            nodeView.grid.ContextMenu.Items.Add(new Separator());
            //rename layers
            var mi = new MenuItem {
                Header = "Rename Layers (Inputs)..."
            };

            mi.Click += (s, e) =>
            {
                var rl = new RenameLayers(_sender.InPorts.Select(x => x.Name));
                rl.Owner = Window.GetWindow(nodeView);
                rl.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                rl.Title = _sender.Name + " | Rename Layers";
                var result = rl.ShowDialog();
                if (result.HasValue && result.Value)
                {
                    _sender.RenameLayers(rl.Layers.Select(x => x.Name).ToList());
                }
            };

            //stream view
            var viewStream = new MenuItem {
                Header = "View stream online"
            };

            viewStream.Click += (s, e) =>
            {
                if (_sender.StreamId == null)
                {
                    return;
                }
                System.Diagnostics.Process.Start(_sender.RestApi.Replace("api/v1", "view") + @"/?streams=" + _sender.StreamId);
            };
            var viewStreamData = new MenuItem {
                Header = "(API) View stream data"
            };

            viewStreamData.Click += (s, e) =>
            {
                if (_sender.StreamId == null)
                {
                    return;
                }
                System.Diagnostics.Process.Start(_sender.RestApi + @"/streams/" + _sender.StreamId);
            };
            var viewObjectsData = new MenuItem {
                Header = "(API) View objects data"
            };

            viewObjectsData.Click += (s, e) =>
            {
                if (_sender.StreamId == null)
                {
                    return;
                }
                System.Diagnostics.Process.Start(_sender.RestApi + @"/streams/" + _sender.StreamId + @"/objects?omit=displayValue,base64");
            };

            var addToHistory = new MenuItem {
                Header = "Save current stream as a version"
            };

            addToHistory.Click += (s, e) =>
            {
                if (_sender.StreamId == null)
                {
                    return;
                }
                var cloneResult = _sender.mySender.StreamCloneAsync(_sender.StreamId).Result;
                _sender.mySender.Stream.Children.Add(cloneResult.Clone.StreamId);

                _sender.mySender.BroadcastMessage("stream", _sender.StreamId, new { eventType = "update-children" });

                System.Windows.MessageBox.Show("Stream version saved. CloneId: " + cloneResult.Clone.StreamId);
            };



            nodeView.grid.ContextMenu.Items.Add(mi);
            nodeView.grid.ContextMenu.Items.Add(viewStream);
            nodeView.grid.ContextMenu.Items.Add(viewStreamData);
            nodeView.grid.ContextMenu.Items.Add(viewObjectsData);
            nodeView.grid.ContextMenu.Items.Add(addToHistory);
        }