Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
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);
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
Exemple #6
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);
        }