Exemplo n.º 1
0
        //System.Windows.Controls.Button button;

        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            //add a text box to the input grid of the control
            var button = new dynNodeButton();

            button.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            button.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
            //inputGrid.RowDefinitions.Add(new RowDefinition());
            nodeUI.inputGrid.Children.Add(button);
            System.Windows.Controls.Grid.SetColumn(button, 0);
            System.Windows.Controls.Grid.SetRow(button, 0);
            button.Content = "Continue";

            Enabled = false;

            button.Click += new RoutedEventHandler(button_Click);

            var bindingVal = new System.Windows.Data.Binding("Enabled")
            {
                Mode = BindingMode.TwoWay,
                NotifyOnValidationError = false,
                Source = this
            };

            button.SetBinding(UIElement.IsEnabledProperty, bindingVal);
        }
Exemplo n.º 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 dynTextBox
            {
                Background = new SolidColorBrush(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;
            var bindingVal = new System.Windows.Data.Binding("Value")
            {
                Mode = BindingMode.TwoWay,
                //Converter = new StringDisplay(),
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            tb.SetBinding(TextBox.TextProperty, bindingVal);

            if (Value != "")
            {
                tb.Commit();
            }
        }
Exemplo n.º 3
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            //add a text box to the input grid of the control
            tb = new TextBox();
            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);

            //turn off the border
            SolidColorBrush backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0));

            tb.Background      = backgroundBrush;
            tb.BorderThickness = new Thickness(0);

            tb.DataContext = this;
            var bindingSymbol = new System.Windows.Data.Binding("Symbol")
            {
                Mode = BindingMode.TwoWay
            };

            tb.SetBinding(TextBox.TextProperty, bindingSymbol);

            tb.TextChanged += new TextChangedEventHandler(tb_TextChanged);
        }
Exemplo n.º 4
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            base.SetupCustomUIElements(nodeUI);

            //add a text box to the input grid of the control
            var tb = new dynStringTextBox
            {
                AcceptsReturn     = true,
                AcceptsTab        = true,
                TextWrapping      = TextWrapping.Wrap,
                MaxWidth          = 200,
                VerticalAlignment = VerticalAlignment.Top
            };

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

            tb.DataContext = this;
            var bindingVal = new System.Windows.Data.Binding("Value")
            {
                Mode                = BindingMode.TwoWay,
                Converter           = new StringDisplay(),
                Source              = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            tb.SetBinding(TextBox.TextProperty, bindingVal);
        }
Exemplo n.º 5
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 dynTextBox();

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

            tb.DataContext = this;
            var bindingVal = new System.Windows.Data.Binding("Value")
            {
                Mode      = BindingMode.TwoWay,
                Converter = new RadianToDegreesConverter(),
                NotifyOnValidationError = false,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            tb.SetBinding(TextBox.TextProperty, bindingVal);

            //tb.Text = "0.0";
        }
Exemplo n.º 6
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            //add a text box to the input grid of the control
            var rbTrue  = new System.Windows.Controls.RadioButton();
            var rbFalse = new System.Windows.Controls.RadioButton();

            rbTrue.VerticalAlignment  = System.Windows.VerticalAlignment.Center;
            rbFalse.VerticalAlignment = System.Windows.VerticalAlignment.Center;

            //use a unique name for the button group
            //so other instances of this element don't get confused
            string groupName = Guid.NewGuid().ToString();

            rbTrue.GroupName  = groupName;
            rbFalse.GroupName = groupName;

            rbTrue.Content  = "1";
            rbTrue.Padding  = new Thickness(5, 0, 12, 0);
            rbFalse.Content = "0";
            rbFalse.Padding = new Thickness(5, 0, 0, 0);

            var wp = new WrapPanel {
                HorizontalAlignment = HorizontalAlignment.Center
            };

            wp.Children.Add(rbTrue);
            wp.Children.Add(rbFalse);
            nodeUI.inputGrid.Children.Add(wp);

            //rbFalse.IsChecked = true;
            rbTrue.Checked  += new System.Windows.RoutedEventHandler(rbTrue_Checked);
            rbFalse.Checked += new System.Windows.RoutedEventHandler(rbFalse_Checked);

            rbFalse.DataContext = this;
            rbTrue.DataContext  = this;

            var rbTrueBinding = new System.Windows.Data.Binding("Value")
            {
                Mode = BindingMode.TwoWay,
            };

            rbTrue.SetBinding(System.Windows.Controls.RadioButton.IsCheckedProperty, rbTrueBinding);

            var rbFalseBinding = new System.Windows.Data.Binding("Value")
            {
                Mode      = BindingMode.TwoWay,
                Converter = new InverseBoolDisplay()
            };

            rbFalse.SetBinding(System.Windows.Controls.RadioButton.IsCheckedProperty, rbFalseBinding);
        }
Exemplo n.º 7
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            base.SetupCustomUIElements(nodeUI);

            //add a drop down list to the window
            var combo = new ComboBox
            {
                Width = 300,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
                VerticalAlignment   = System.Windows.VerticalAlignment.Center
            };

            nodeUI.inputGrid.Children.Add(combo);
            System.Windows.Controls.Grid.SetColumn(combo, 0);
            System.Windows.Controls.Grid.SetRow(combo, 0);

            combo.DropDownOpened   += new EventHandler(combo_DropDownOpened);
            combo.SelectionChanged += delegate
            {
                if (combo.SelectedIndex != -1)
                {
                    RequiresRecalc = true;
                }
            };

            combo.DataContext = this;
            //bind this combo box to the selected item hash

            var bindingVal = new System.Windows.Data.Binding("Items")
            {
                Mode   = BindingMode.TwoWay,
                Source = this
            };

            combo.SetBinding(ComboBox.ItemsSourceProperty, bindingVal);

            //bind the selected index to the
            var indexBinding = new System.Windows.Data.Binding("SelectedIndex")
            {
                Mode   = BindingMode.TwoWay,
                Source = this
            };

            combo.SetBinding(ComboBox.SelectedIndexProperty, indexBinding);
        }
Exemplo n.º 8
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            //add a button to the inputGrid on the dynElement
            var readFileButton = new dynNodeButton();

            //readFileButton.Margin = new System.Windows.Thickness(4);
            readFileButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            readFileButton.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
            readFileButton.Click              += new System.Windows.RoutedEventHandler(readFileButton_Click);
            readFileButton.Content             = "Browse...";
            readFileButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            readFileButton.VerticalAlignment   = System.Windows.VerticalAlignment.Center;

            var tb = new TextBox();

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

            tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            tb.VerticalAlignment   = System.Windows.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); dynSettings.ReturnFocusToSearch(); };

            StackPanel sp = new StackPanel();

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

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

            tb.SetBinding(TextBox.TextProperty, bindingVal);
        }
Exemplo n.º 9
0
        public override void editWindowItem_Click(object sender, RoutedEventArgs e)
        {
            var editWindow = new EditWindow {
                DataContext = this
            };

            var bindingVal = new System.Windows.Data.Binding("Value")
            {
                Mode      = BindingMode.TwoWay,
                Converter = new StringDisplay(),
                NotifyOnValidationError = false,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            editWindow.editText.SetBinding(TextBox.TextProperty, bindingVal);

            if (editWindow.ShowDialog() != true)
            {
                return;
            }
        }
Exemplo n.º 10
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);
        }