예제 #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 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();
            }
        }
예제 #2
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            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  = false;
            tb.Background = new SolidColorBrush(Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF));

            tb.DataContext = this;
            var bindingVal = new Binding("Formula")
            {
                Mode = BindingMode.TwoWay,
                NotifyOnValidationError = false,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            tb.SetBinding(TextBox.TextProperty, bindingVal);
        }
예제 #3
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
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Top,
                IsNumeric           = true,
                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;
            var bindingVal = new System.Windows.Data.Binding("Value")
            {
                Mode      = BindingMode.TwoWay,
                Converter = new DoubleInputDisplay(),
                NotifyOnValidationError = false,
                Source = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            tb.SetBinding(TextBox.TextProperty, bindingVal);

            tb.Text = Value ?? "0.0";
        }
예제 #4
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 dynTextBox();

            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.IsNumeric  = false;
            tb.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0x88, 0xFF, 0xFF, 0xFF));

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

            tb.SetBinding(System.Windows.Controls.TextBox.TextProperty, bindingVal);

            tb.OnChangeCommitted += delegate { RequiresRecalc = true; };
        }
예제 #5
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 Slider();

            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 dynTextBox();

            mintb.Width = double.NaN;

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

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

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

            var maxtb = new dynTextBox();

            maxtb.Width = double.NaN;

            maxtb.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(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
            var inputBinding = new System.Windows.Data.Binding("Value")
            {
                Mode      = BindingMode.TwoWay,
                Converter = new DoubleDisplay()
            };

            valtb.SetBinding(dynTextBox.TextProperty, inputBinding);

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

            tb_slider.SetBinding(Slider.ValueProperty, sliderBinding);

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

            maxtb.SetBinding(dynTextBox.TextProperty, bindingMax);

            // 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
            var bindingMin = new System.Windows.Data.Binding("Min")
            {
                Mode                = BindingMode.TwoWay,
                Converter           = new DoubleDisplay(),
                Source              = this,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            mintb.SetBinding(dynTextBox.TextProperty, bindingMin);

            // 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);
        }