Beispiel #1
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            //add a text box to the input grid of the control
            var tb = new DynamoTextBox
            {
                Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF))
            };

            tb.OnChangeCommitted += processTextForNewInputs;

            tb.HorizontalAlignment = HorizontalAlignment.Stretch;
            tb.VerticalAlignment   = VerticalAlignment.Top;

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

            tb.DataContext = this;
            tb.BindToProperty(new System.Windows.Data.Binding("Value")
            {
                Mode = BindingMode.TwoWay,
                //Converter = new StringDisplay(),
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });
        }
Beispiel #2
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            //add a text box to the input grid of the control
            var tb = new DynamoTextBox(Value ?? "0.0")
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Top,
                Background          = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF))
            };

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

            tb.DataContext = this;
            tb.BindToProperty(new System.Windows.Data.Binding("Value")
            {
                Mode      = BindingMode.TwoWay,
                Converter = new DoubleInputDisplay(),
                NotifyOnValidationError = false,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });
        }
Beispiel #3
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            //add an edit window option to the
            //main context window
            var editWindowItem = new System.Windows.Controls.MenuItem();
            editWindowItem.Header = "Edit...";
            editWindowItem.IsCheckable = false;

            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 = System.Windows.HorizontalAlignment.Stretch;
            tb.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            nodeUI.inputGrid.Children.Add(tb);
            System.Windows.Controls.Grid.SetColumn(tb, 0);
            System.Windows.Controls.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 RevitProjectUnitsConverter(),
                //ConverterParameter = Measure,
                NotifyOnValidationError = false,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });

            tb.OnChangeCommitted += delegate { RequiresRecalc = true; };
        }
Beispiel #4
0
        public void SetupCustomUIElements(dynNodeView nodeUI)
        {
            //add a text box to the input grid of the control
            var tb = new DynamoTextBox(Value ?? "0.0")
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Background          =
                    new SolidColorBrush(Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF))
            };

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

            tb.DataContext = this;

            tb.BindToProperty(new Binding("Value")
            {
                Mode      = BindingMode.TwoWay,
                Converter = new DoubleInputDisplay(),
                NotifyOnValidationError = false,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });

            Workspace.DynamoModel.PreferenceSettings.PropertyChanged += Preferences_PropertyChanged;
        }
Beispiel #5
0
        public void SetupCustomUIElements(dynNodeView view)
        {
            var tb = new DynamoTextBox(FormulaString)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Top,
                Background = new SolidColorBrush(Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF))
            };

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

            tb.DataContext = this;
            tb.BindToProperty(new Binding("FormulaString")
            {
                Mode = BindingMode.TwoWay,
                NotifyOnValidationError = false,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });
        }
Beispiel #6
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            //add a text box to the input grid of the control
            DynamoTextBox tb = new DynamoTextBox(InputSymbol)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center,
                Background          = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF))
            };

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

            tb.DataContext = this;
            tb.BindToProperty(new Binding("InputSymbol")
            {
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });
        }
Beispiel #7
0
        public void SetupCustomUIElements(dynNodeView nodeUI)
        {
            //add a text box to the input grid of the control
            var tb = new DynamoTextBox(Symbol)
            {
                DataContext         = nodeUI.ViewModel,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center,
                Background          =
                    new SolidColorBrush(Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF))
            };

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

            tb.BindToProperty(
                new Binding("Symbol")
            {
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });
        }
Beispiel #8
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            //add an edit window option to the
            //main context window
            var editWindowItem = new System.Windows.Controls.MenuItem();

            editWindowItem.Header      = "Edit...";
            editWindowItem.IsCheckable = false;

            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 = System.Windows.HorizontalAlignment.Stretch;
            tb.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
            nodeUI.inputGrid.Children.Add(tb);
            System.Windows.Controls.Grid.SetColumn(tb, 0);
            System.Windows.Controls.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 RevitProjectUnitsConverter(),
                //ConverterParameter = Measure,
                NotifyOnValidationError = false,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });

            tb.OnChangeCommitted += delegate { RequiresRecalc = true; };
        }
Beispiel #9
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            var tb = new DynamoTextBox(FormulaString)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Top,
                Background          = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF))
            };

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

            tb.DataContext = this;
            tb.BindToProperty(new Binding("FormulaString")
            {
                Mode = BindingMode.TwoWay,
                NotifyOnValidationError = false,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });
        }
Beispiel #10
0
        internal static void BuildSliderUI(dynNodeView nodeUI, NodeModel nodeModel,
                                           double value, string serializedValue, UIElement sliderSettingsControl,
                                           IValueConverter numberDisplayConverter)
        {
            //add a slider control to the input grid of the control
            var tbSlider = new DynamoSlider(nodeModel)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Height        = Configurations.PortHeightInPixels,
                MinWidth      = 150,
                TickPlacement = TickPlacement.None,
                Value         = value
            };

            tbSlider.PreviewMouseUp += delegate
            {
                nodeUI.ViewModel.DynamoViewModel.ReturnFocusToSearch();
            };

            // build grid for input and expander
            var textBoxExpanderGrid = new Grid()
            {
                MinWidth = 150
            };

            textBoxExpanderGrid.ColumnDefinitions.Add(new ColumnDefinition());
            textBoxExpanderGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(29)
            });

            // input value textbox
            var valtb = new DynamoTextBox(serializedValue);

            Grid.SetColumn(valtb, 0);
            textBoxExpanderGrid.Children.Add(valtb);

            var exp = new Expander();

            exp.Padding = new Thickness(4, 0, 0, 0);
            Grid.SetColumn(exp, 1);
            textBoxExpanderGrid.Children.Add(exp);

            var sliderSp = new StackPanel()
            {
                HorizontalAlignment = HorizontalAlignment.Stretch
            };

            sliderSp.Children.Add(textBoxExpanderGrid);

            // min max control
            var minMaxControl = sliderSettingsControl;

            minMaxControl.Visibility = Visibility.Collapsed;
            sliderSp.Children.Add(minMaxControl);

            // expander modifies visibility of min/max
            exp.Expanded += (sender, args) =>
            {
                minMaxControl.Visibility = Visibility.Visible;
            };

            exp.Collapsed += (sender, args) =>
            {
                minMaxControl.Visibility = Visibility.Collapsed;
            };

            nodeUI.inputGrid.Children.Add(tbSlider);
            nodeUI.PresentationGrid.Children.Add(sliderSp);
            nodeUI.PresentationGrid.Visibility = Visibility.Visible;

            tbSlider.DataContext = nodeModel;
            valtb.DataContext    = nodeModel;

            // value input
            valtb.BindToProperty(
                new Binding("Value")
            {
                Mode = BindingMode.TwoWay, Converter = numberDisplayConverter
            });

            // slider value
            var sliderBinding = new Binding("Value")
            {
                Mode = BindingMode.TwoWay, Source = nodeModel
            };

            tbSlider.SetBinding(RangeBase.ValueProperty, sliderBinding);

            // max slider value
            var bindingMaxSlider = new Binding("Max")
            {
                Mode   = BindingMode.OneWay,
                Source = nodeModel,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            tbSlider.SetBinding(RangeBase.MaximumProperty, bindingMaxSlider);

            // min slider value
            var bindingMinSlider = new Binding("Min")
            {
                Mode   = BindingMode.OneWay,
                Source = nodeModel,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            tbSlider.SetBinding(RangeBase.MinimumProperty, bindingMinSlider);
        }
Beispiel #11
0
        /// <summary>
        /// UI is initialized and bindings are setup here.
        /// </summary>
        /// <param name="nodeUI">UI view that we can customize the UI of.</param>
        public override void SetupCustomUIElements(dynNodeView nodeUI)
        {
            //add a slider control to the input grid of the control
            var tbSlider = new DynamoSlider(this)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Center,
                MinWidth = 150,
                TickPlacement = TickPlacement.None,
                Value = Value
            };

            tbSlider.PreviewMouseUp += delegate
            {
                dynSettings.ReturnFocusToSearch();
            };

            var mintb = new DynamoTextBox
            {
                Width = Configurations.DoubleSliderTextBoxWidth,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                Background = new SolidColorBrush(Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF))
            };

            // input value textbox
            var valtb = new DynamoTextBox(SerializeValue())
            {
                Width = Configurations.DoubleSliderTextBoxWidth,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                Margin = new Thickness(0, 0, 10, 0)
            };

            var maxtb = new DynamoTextBox
            {
                Width = Configurations.DoubleSliderTextBoxWidth,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                Background = new SolidColorBrush(Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF))
            };

            var sliderGrid = new Grid();
            sliderGrid.ColumnDefinitions.Add(
                new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) });
            sliderGrid.ColumnDefinitions.Add(
                new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) });
            sliderGrid.ColumnDefinitions.Add(
                new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
            sliderGrid.ColumnDefinitions.Add(
                new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) });

            sliderGrid.Children.Add(valtb);
            sliderGrid.Children.Add(mintb);
            sliderGrid.Children.Add(tbSlider);
            sliderGrid.Children.Add(maxtb);

            Grid.SetColumn(valtb, 0);
            Grid.SetColumn(mintb, 1);
            Grid.SetColumn(tbSlider, 2);
            Grid.SetColumn(maxtb, 3);
            nodeUI.inputGrid.Children.Add(sliderGrid);

            maxtb.DataContext = this;
            tbSlider.DataContext = this;
            mintb.DataContext = this;
            valtb.DataContext = this;

            // value input
            valtb.BindToProperty(
                new Binding("Value") { Mode = BindingMode.TwoWay, Converter = new DoubleDisplay() });

            // slider value 
            var sliderBinding = new Binding("Value") { Mode = BindingMode.TwoWay, Source = this, };
            tbSlider.SetBinding(RangeBase.ValueProperty, sliderBinding);

            // max value
            maxtb.BindToProperty(
                new Binding("Max")
                {
                    Mode = BindingMode.TwoWay,
                    Converter = new DoubleDisplay(),
                    Source = this,
                    UpdateSourceTrigger = UpdateSourceTrigger.Explicit
                });

            // max slider value
            var bindingMaxSlider = new Binding("Max")
            {
                Mode = BindingMode.OneWay,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };
            tbSlider.SetBinding(RangeBase.MaximumProperty, bindingMaxSlider);


            // min value
            mintb.BindToProperty(
                new Binding("Min")
                {
                    Mode = BindingMode.TwoWay,
                    Converter = new DoubleDisplay(),
                    Source = this,
                    UpdateSourceTrigger = UpdateSourceTrigger.Explicit
                });

            // min slider value
            var bindingMinSlider = new Binding("Min")
            {
                Mode = BindingMode.OneWay,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };
            tbSlider.SetBinding(RangeBase.MinimumProperty, bindingMinSlider);
        }
Beispiel #12
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            //add a slider control to the input grid of the control
            var tb_slider = new DynamoSlider(this);

            tb_slider.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            tb_slider.VerticalAlignment   = System.Windows.VerticalAlignment.Center;

            tb_slider.MinWidth = 150;

            tb_slider.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.None;

            tb_slider.PreviewMouseUp += delegate
            {
                dynSettings.ReturnFocusToSearch();
            };

            var mintb = new DynamoTextBox();

            mintb.Width = double.NaN;

            mintb.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF));

            // input value textbox
            var valtb = new DynamoTextBox();

            valtb.Width  = double.NaN;
            valtb.Margin = new Thickness(0, 0, 10, 0);

            var maxtb = new DynamoTextBox();

            maxtb.Width = double.NaN;

            maxtb.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF));

            var sliderGrid = new Grid();

            sliderGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            sliderGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            sliderGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            sliderGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Auto)
            });

            sliderGrid.Children.Add(valtb);
            sliderGrid.Children.Add(mintb);
            sliderGrid.Children.Add(tb_slider);
            sliderGrid.Children.Add(maxtb);

            Grid.SetColumn(valtb, 0);
            Grid.SetColumn(mintb, 1);
            Grid.SetColumn(tb_slider, 2);
            Grid.SetColumn(maxtb, 3);
            nodeUI.inputGrid.Children.Add(sliderGrid);

            maxtb.DataContext     = this;
            tb_slider.DataContext = this;
            mintb.DataContext     = this;
            valtb.DataContext     = this;

            // value input
            valtb.BindToProperty(new System.Windows.Data.Binding("Value")
            {
                Mode      = BindingMode.TwoWay,
                Converter = new DoubleDisplay()
            });

            // slider value
            var sliderBinding = new System.Windows.Data.Binding("Value")
            {
                Mode   = BindingMode.TwoWay,
                Source = this,
            };

            tb_slider.SetBinding(Slider.ValueProperty, sliderBinding);

            // max value
            maxtb.BindToProperty(new System.Windows.Data.Binding("Max")
            {
                Mode                = BindingMode.TwoWay,
                Converter           = new DoubleDisplay(),
                Source              = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });

            // max slider value
            var bindingMaxSlider = new System.Windows.Data.Binding("Max")
            {
                Mode   = BindingMode.OneWay,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            tb_slider.SetBinding(Slider.MaximumProperty, bindingMaxSlider);


            // min value
            mintb.BindToProperty(new System.Windows.Data.Binding("Min")
            {
                Mode                = BindingMode.TwoWay,
                Converter           = new DoubleDisplay(),
                Source              = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });

            // min slider value
            var bindingMinSlider = new System.Windows.Data.Binding("Min")
            {
                Mode   = BindingMode.OneWay,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            tb_slider.SetBinding(Slider.MinimumProperty, bindingMinSlider);
        }
Beispiel #13
0
        /// <summary>
        /// UI is initialized and bindings are setup here.
        /// </summary>
        /// <param name="nodeUI">UI view that we can customize the UI of.</param>
        public override void SetupCustomUIElements(dynNodeView nodeUI)
        {
            //add a slider control to the input grid of the control
            var tbSlider = new DynamoSlider(this)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Height        = Configurations.PortHeightInPixels,
                MinWidth      = 150,
                TickPlacement = TickPlacement.None,
                Value         = Value
            };

            tbSlider.PreviewMouseUp += delegate
            {
                dynSettings.ReturnFocusToSearch();
            };

            // input value textbox
            var valtb = new DynamoTextBox(SerializeValue())
            {
                MinWidth = Configurations.DoubleSliderTextBoxWidth,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
            };

            var sliderSp = new StackPanel()
            {
                HorizontalAlignment = HorizontalAlignment.Stretch
            };

            sliderSp.Children.Add(valtb);

            sliderSp.Children.Add(new DoubleSliderSettingsControl()
            {
                DataContext = this
            });
            nodeUI.inputGrid.Children.Add(tbSlider);
            nodeUI.PresentationGrid.Children.Add(sliderSp);
            nodeUI.PresentationGrid.Visibility = Visibility.Visible;

            tbSlider.DataContext = this;
            valtb.DataContext    = this;

            // value input
            valtb.BindToProperty(
                new Binding("Value")
            {
                Mode = BindingMode.TwoWay, Converter = new DoubleDisplay()
            });

            // slider value
            var sliderBinding = new Binding("Value")
            {
                Mode = BindingMode.TwoWay, Source = this,
            };

            tbSlider.SetBinding(RangeBase.ValueProperty, sliderBinding);

            // max slider value
            var bindingMaxSlider = new Binding("Max")
            {
                Mode   = BindingMode.OneWay,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            tbSlider.SetBinding(RangeBase.MaximumProperty, bindingMaxSlider);

            // min slider value
            var bindingMinSlider = new Binding("Min")
            {
                Mode   = BindingMode.OneWay,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            tbSlider.SetBinding(RangeBase.MinimumProperty, bindingMinSlider);
        }
Beispiel #14
0
        internal static void BuildSliderUI(dynNodeView nodeUI, NodeModel nodeModel,
            double value, string serializedValue, UIElement sliderSettingsControl, 
            IValueConverter numberDisplayConverter  )
        {
            //add a slider control to the input grid of the control
            var tbSlider = new DynamoSlider(nodeModel)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                Height = Configurations.PortHeightInPixels,
                MinWidth = 150,
                TickPlacement = TickPlacement.None,
                Value = value
            };

            tbSlider.PreviewMouseUp += delegate
            {
                nodeUI.ViewModel.DynamoViewModel.ReturnFocusToSearch();
            };

            // build grid for input and expander
            var textBoxExpanderGrid = new Grid()
            {
                MinWidth = 150
            };

            textBoxExpanderGrid.ColumnDefinitions.Add(new ColumnDefinition());
            textBoxExpanderGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(29)
            });

            // input value textbox
            var valtb = new DynamoTextBox(serializedValue);

            Grid.SetColumn(valtb, 0);
            textBoxExpanderGrid.Children.Add(valtb);

            var exp = new Expander();
            exp.Padding = new Thickness(4, 0, 0, 0);
            Grid.SetColumn(exp, 1);
            textBoxExpanderGrid.Children.Add(exp);

            var sliderSp = new StackPanel()
            {
                HorizontalAlignment = HorizontalAlignment.Stretch
            };
            sliderSp.Children.Add(textBoxExpanderGrid);

            // min max control
            var minMaxControl = sliderSettingsControl;
            minMaxControl.Visibility = Visibility.Collapsed;
            sliderSp.Children.Add(minMaxControl);

            // expander modifies visibility of min/max
            exp.Expanded += (sender, args) =>
            {
                minMaxControl.Visibility = Visibility.Visible;
            };

            exp.Collapsed += (sender, args) =>
            {
                minMaxControl.Visibility = Visibility.Collapsed;
            };

            nodeUI.inputGrid.Children.Add(tbSlider);
            nodeUI.PresentationGrid.Children.Add(sliderSp);
            nodeUI.PresentationGrid.Visibility = Visibility.Visible;

            tbSlider.DataContext = nodeModel;
            valtb.DataContext = nodeModel;

            // value input
            valtb.BindToProperty(
                new Binding("Value") { Mode = BindingMode.TwoWay, Converter = numberDisplayConverter });

            // slider value 
            var sliderBinding = new Binding("Value") { Mode = BindingMode.TwoWay, Source = nodeModel };
            tbSlider.SetBinding(RangeBase.ValueProperty, sliderBinding);

            // max slider value
            var bindingMaxSlider = new Binding("Max")
            {
                Mode = BindingMode.OneWay,
                Source = nodeModel,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };
            tbSlider.SetBinding(RangeBase.MaximumProperty, bindingMaxSlider);

            // min slider value
            var bindingMinSlider = new Binding("Min")
            {
                Mode = BindingMode.OneWay,
                Source = nodeModel,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };
            tbSlider.SetBinding(RangeBase.MinimumProperty, bindingMinSlider);
        }
Beispiel #15
0
        /// <summary>
        /// UI is initialized and bindings are setup here.
        /// </summary>
        /// <param name="nodeUI">UI view that we can customize the UI of.</param>
        public override void SetupCustomUIElements(dynNodeView nodeUI)
        {
            //add a slider control to the input grid of the control
            var tbSlider = new DynamoSlider(this)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center,
                MinWidth            = 150,
                TickPlacement       = TickPlacement.None,
                Value = Value
            };

            tbSlider.PreviewMouseUp += delegate
            {
                dynSettings.ReturnFocusToSearch();
            };

            var mintb = new DynamoTextBox
            {
                Width = Configurations.DoubleSliderTextBoxWidth,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                Background = new SolidColorBrush(Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF))
            };

            // input value textbox
            var valtb = new DynamoTextBox(SerializeValue())
            {
                Width = Configurations.DoubleSliderTextBoxWidth,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                Margin = new Thickness(0, 0, 10, 0)
            };

            var maxtb = new DynamoTextBox
            {
                Width = Configurations.DoubleSliderTextBoxWidth,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                Background = new SolidColorBrush(Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF))
            };

            var sliderGrid = new Grid();

            sliderGrid.ColumnDefinitions.Add(
                new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            sliderGrid.ColumnDefinitions.Add(
                new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            sliderGrid.ColumnDefinitions.Add(
                new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            sliderGrid.ColumnDefinitions.Add(
                new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Auto)
            });

            sliderGrid.Children.Add(valtb);
            sliderGrid.Children.Add(mintb);
            sliderGrid.Children.Add(tbSlider);
            sliderGrid.Children.Add(maxtb);

            Grid.SetColumn(valtb, 0);
            Grid.SetColumn(mintb, 1);
            Grid.SetColumn(tbSlider, 2);
            Grid.SetColumn(maxtb, 3);
            nodeUI.inputGrid.Children.Add(sliderGrid);

            maxtb.DataContext    = this;
            tbSlider.DataContext = this;
            mintb.DataContext    = this;
            valtb.DataContext    = this;

            // value input
            valtb.BindToProperty(
                new Binding("Value")
            {
                Mode = BindingMode.TwoWay, Converter = new DoubleDisplay()
            });

            // slider value
            var sliderBinding = new Binding("Value")
            {
                Mode = BindingMode.TwoWay, Source = this,
            };

            tbSlider.SetBinding(RangeBase.ValueProperty, sliderBinding);

            // max value
            maxtb.BindToProperty(
                new Binding("Max")
            {
                Mode                = BindingMode.TwoWay,
                Converter           = new DoubleDisplay(),
                Source              = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });

            // max slider value
            var bindingMaxSlider = new Binding("Max")
            {
                Mode   = BindingMode.OneWay,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            tbSlider.SetBinding(RangeBase.MaximumProperty, bindingMaxSlider);


            // min value
            mintb.BindToProperty(
                new Binding("Min")
            {
                Mode                = BindingMode.TwoWay,
                Converter           = new DoubleDisplay(),
                Source              = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });

            // min slider value
            var bindingMinSlider = new Binding("Min")
            {
                Mode   = BindingMode.OneWay,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            tbSlider.SetBinding(RangeBase.MinimumProperty, bindingMinSlider);
        }
Beispiel #16
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;
        }