示例#1
0
        public void CustomizeView(DoubleInput nodeModel, NodeView nodeView)
        {
            //add a text box to the input grid of the control
            var tb = new DynamoTextBox(nodeModel.Value ?? "0.0")
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Background          =
                    new SolidColorBrush(Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF))
            };

            nodeView.inputGrid.Children.Add(tb);
            Grid.SetColumn(tb, 0);
            Grid.SetRow(tb, 0);

            tb.DataContext = nodeModel;
            var textToValueBinding = new Binding("Value")
            {
                Mode      = BindingMode.TwoWay,
                Converter = new DoubleInputDisplay(),
                NotifyOnValidationError = false,
                Source = nodeModel,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };
            var numericalValidation = new NumericValidationRule();

            numericalValidation.ValidationStep = ValidationStep.ConvertedProposedValue;
            textToValueBinding.ValidationRules.Add(numericalValidation);
            tb.BindToProperty(textToValueBinding);
            Validation.SetErrorTemplate(tb, null);
        }
示例#2
0
        public void CustomizeView(MeasurementInputBase model, NodeView nodeView)
        {
            this.mesBaseModel    = model;
            this.dynamoViewModel = nodeView.ViewModel.DynamoViewModel;

            //add an edit window option to the
            //main context window
            var editWindowItem = new MenuItem()
            {
                Header      = Properties.Resources.EditHeader,
                IsCheckable = false,
                Tag         = nodeView.ViewModel.DynamoViewModel
            };

            nodeView.MainContextMenu.Items.Add(editWindowItem);

            editWindowItem.Click += editWindowItem_Click;

            //add a text box to the input grid of the control
            this.tb = new DynamoTextBox();
            tb.HorizontalAlignment = HorizontalAlignment.Stretch;
            tb.VerticalAlignment   = VerticalAlignment.Center;
            nodeView.inputGrid.Children.Add(tb);
            Grid.SetColumn(tb, 0);
            Grid.SetRow(tb, 0);
            tb.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF));

            tb.DataContext = model;
            tb.BindToProperty(new Binding("Value")
            {
                Mode                    = BindingMode.TwoWay,
                Converter               = new MeasureConverter(),
                ConverterParameter      = model.Measure,
                NotifyOnValidationError = false,
                Source                  = model,
                UpdateSourceTrigger     = UpdateSourceTrigger.Explicit
            });

            tb.OnChangeCommitted += () => model.OnNodeModified();

            (nodeView.ViewModel.DynamoViewModel.Model.PreferenceSettings).PropertyChanged += PreferenceSettings_PropertyChanged;
        }
示例#3
0
        public void CustomizeView(Formula model, NodeView nodeView)
        {
            var tb = new DynamoTextBox(model.FormulaString)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Top,
                Background          = new SolidColorBrush(Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF))
            };

            nodeView.inputGrid.Children.Add(tb);
            Grid.SetColumn(tb, 0);
            Grid.SetRow(tb, 0);

            tb.DataContext = model;
            tb.BindToProperty(new Binding("FormulaString")
            {
                Mode = BindingMode.TwoWay,
                NotifyOnValidationError = false,
                Source = model,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });
        }
示例#4
0
        public void SetupCustomUIElements(dynNodeView nodeUI)
        {
            //add an edit window option to the
            //main context window
            var editWindowItem = new System.Windows.Controls.MenuItem()
            {
                Header      = "Edit...",
                IsCheckable = false,
                Tag         = nodeUI.ViewModel.DynamoViewModel
            };

            nodeUI.MainContextMenu.Items.Add(editWindowItem);

            editWindowItem.Click += new RoutedEventHandler(editWindowItem_Click);
            //add a text box to the input grid of the control
            var tb = new DynamoTextBox();

            tb.HorizontalAlignment = HorizontalAlignment.Stretch;
            tb.VerticalAlignment   = VerticalAlignment.Center;
            nodeUI.inputGrid.Children.Add(tb);
            Grid.SetColumn(tb, 0);
            Grid.SetRow(tb, 0);
            tb.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF));

            tb.DataContext = this;
            tb.BindToProperty(new System.Windows.Data.Binding("Value")
            {
                Mode                    = BindingMode.TwoWay,
                Converter               = new MeasureConverter(),
                ConverterParameter      = _measure,
                NotifyOnValidationError = false,
                Source                  = this,
                UpdateSourceTrigger     = UpdateSourceTrigger.Explicit
            });

            tb.OnChangeCommitted += delegate { RequiresRecalc = true; };

            (nodeUI.ViewModel.DynamoViewModel.Model.PreferenceSettings).PropertyChanged += PreferenceSettings_PropertyChanged;
        }
        public void CustomizeView(Nodes.Output outputNodeModel, NodeView nodeView)
        {
            //add a text box to the input grid of the control
            var tb = new DynamoTextBox(outputNodeModel.Symbol)
            {
                DataContext         = outputNodeModel,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center,
                Background          =
                    new SolidColorBrush(Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF))
            };

            nodeView.inputGrid.Children.Add(tb);
            Grid.SetColumn(tb, 0);
            Grid.SetRow(tb, 0);

            tb.BindToProperty(
                new Binding("Symbol")
            {
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });
        }