コード例 #1
0
        private void SetProductData <TProductIm>(ComboBox comboBox, SingleUpDown sizeSingleUpDown, Label sizeLabel, Label priceLabel, List <TProductIm> products, CurrentProduct currentProduct)
            where TProductIm : ProductIm
        {
            comboBox.ItemsSource   = products.Select(im => im.Name);
            comboBox.SelectedIndex = comboBox.Items.IndexOf(currentProduct.Name);

            if (priceLabel != null)
            {
                priceLabel.Content = currentProduct.Price;
            }

            if (sizeLabel == null && sizeSingleUpDown == null)
            {
                return;
            }

            if (sizeSingleUpDown == null)
            {
                sizeLabel.Content = currentProduct.Count;
            }
            else
            {
                sizeSingleUpDown.Value = (float)currentProduct.Count;
            }
        }
コード例 #2
0
        private FrameworkElement GenerateSingleUpDown(PropertyInfo property, Binding binding)
        {
#if !SILVERLIGHT
            SingleUpDown calculatorUpDown = new SingleUpDown()
            {
                Margin = new Thickness(0, 3, 18, 3)
            };
            calculatorUpDown.IsReadOnly = !(bindables[property.Name].Direction == BindingDirection.TwoWay);
            // Binding
            this.bindings.Add(property.Name, calculatorUpDown.SetBinding(SingleUpDown.ValueProperty, binding));
#else
            Border calculatorUpDown = new Border()
            {
                Opacity = 1.0, Background = new SolidColorBrush(Colors.White), Margin = new Thickness(0, 3, 18, 3)
            };
            NumericUpDown n = new NumericUpDown()
            {
            };
            calculatorUpDown.Child = n;
            n.IsEnabled            = (bindables[property.Name].Direction == BindingDirection.TwoWay);

            // Binding
            this.bindings.Add(property.Name, n.SetBinding(NumericUpDown.ValueProperty, binding));
#endif
            return(calculatorUpDown);
        }
コード例 #3
0
ファイル: Vector3Control.cs プロジェクト: ArtReeX/memoria
        public Vector3Control()
        {
            UiGrid grid = new UiGrid();

            grid.SetCols(6);
            grid.ColumnDefinitions[0].Width = GridLength.Auto;
            grid.ColumnDefinitions[2].Width = GridLength.Auto;
            grid.ColumnDefinitions[4].Width = GridLength.Auto;

            TextBlock xLabel = grid.AddUiElement(new TextBlock {
                Text = "x:"
            }, 0, 0);

            xLabel.Margin = new Thickness(3, 3, 5, 3);

            _x               = grid.AddUiElement(new SingleUpDown(), 0, 1);
            _x.Value         = 0;
            _x.Increment     = 0.5f;
            _x.FormatString  = "F3";
            _x.ValueChanged += XChanged;
            _x.Margin        = new Thickness(3);

            TextBlock yLabel = grid.AddUiElement(new TextBlock {
                Text = "y:"
            }, 0, 2);

            yLabel.Margin = new Thickness(10, 3, 5, 3);

            _y               = grid.AddUiElement(new SingleUpDown(), 0, 3);
            _y.Value         = 0;
            _y.Increment     = 0.5f;
            _y.FormatString  = "F3";
            _y.ValueChanged += YChanged;
            _y.Margin        = new Thickness(3);

            TextBlock zLabel = grid.AddUiElement(new TextBlock {
                Text = "z:"
            }, 0, 4);

            zLabel.Margin = new Thickness(10, 3, 5, 3);

            _z               = grid.AddUiElement(new SingleUpDown(), 0, 5);
            _z.Value         = 0;
            _z.Increment     = 0.5f;
            _z.FormatString  = "F3";
            _z.ValueChanged += ZChanged;
            _z.Margin        = new Thickness(3);

            this.Content = grid;
        }
コード例 #4
0
        private void SetAdditionalCrossProfileData(ComboBox comboBox, SingleUpDown sizeSingleUpDown, Label sizeLabel,
                                                   Label priceLabel, List <CrossProfileIm> products, CurrentProduct currentProduct, CheckBox checkBox)
        {
            checkBox.IsChecked = data.ExtraCrossProfileEnabled;

            if (!data.ExtraCrossProfileAllowed)
            {
                comboBox.IsEnabled = false;
                checkBox.IsEnabled = false;
                checkBox.IsChecked = false;
            }
            else
            {
                comboBox.IsEnabled = true;
                checkBox.IsEnabled = true;
            }

            SetProductData(comboBox, sizeSingleUpDown, sizeLabel, priceLabel, products, currentProduct);
        }
コード例 #5
0
        private void SetAdditionalCrossProfileWithGrooveData(ComboBox comboBox, SingleUpDown sizeSingleUpDown, Label sizeLabel,
                                                             Label priceLabel, List <CrossProfileIm> products, CurrentProduct currentProduct, CheckBox checkBox)
        {
            checkBox.IsChecked = data.ExtraCrossProfileWithGrooveEnabled;

            if (!data.ExtraCrossProfileWithGrooveAllowed)
            {
                comboBox.IsEnabled = false;
                checkBox.IsEnabled = false;
                checkBox.IsChecked = false;
            }
            else
            {
                comboBox.IsEnabled = true;
                checkBox.IsEnabled = true;
            }

            DivideCrossProfileForTwoLabel.Visibility = checkBox.IsChecked.Value ? Visibility.Visible : Visibility.Hidden;

            SetProductData(comboBox, sizeSingleUpDown, sizeLabel, priceLabel, products, currentProduct);
        }
コード例 #6
0
        public UiRectPositionControl()
        {
            UiGrid grid = new UiGrid();

            grid.SetCols(4);
            grid.ColumnDefinitions[0].Width = GridLength.Auto;
            grid.ColumnDefinitions[2].Width = GridLength.Auto;

            TextBlock xLabel = grid.AddUiElement(new TextBlock {
                Text = "x:"
            }, 0, 0);

            xLabel.Margin = new Thickness(3, 3, 5, 3);

            _relative               = grid.AddUiElement(new SingleUpDown(), 0, 1);
            _relative.Value         = 0;
            _relative.Increment     = 0.1f;
            _relative.FormatString  = "F3";
            _relative.ValueChanged += RelativeChanged;
            _relative.Margin        = new Thickness(3);

            TextBlock yLabel = grid.AddUiElement(new TextBlock {
                Text = "y:"
            }, 0, 2);

            yLabel.Margin = new Thickness(10, 3, 5, 3);

            _absolute               = grid.AddUiElement(new IntegerUpDown(), 0, 3);
            _absolute.Value         = 0;
            _absolute.Increment     = 1;
            _absolute.FormatString  = "F3";
            _absolute.ValueChanged += AbsoluteChanged;
            _absolute.Margin        = new Thickness(3);

            this.Content = grid;
        }
コード例 #7
0
        public List <WDetailSingleRowViewModel> CustomizeHeader(PropertyInfo property, string display_name, bool is_editable, object source)
        {
            WDetailSingleRowViewModel single_row = new WDetailSingleRowViewModel(display_name);

            SingleUpDown singleupdown = new SingleUpDown();

            singleupdown.IsEnabled = is_editable;

            Binding tbind = new Binding(property.Name)
            {
                Source = source,
                Mode   = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
            };

            singleupdown.SetBinding(SingleUpDown.ValueProperty, tbind);

            single_row.PropertyControl = singleupdown;

            return(new List <WDetailSingleRowViewModel>()
            {
                single_row
            });
        }
コード例 #8
0
        public bool ShowContextWindow(string text, object table)
        {
            if (table is LuaTable t)
            {
                ScriptContextWindow scw = new ScriptContextWindow();
                scw.Label_Description.Content = text;
                Dictionary <object, string> reverseLookup = new Dictionary <object, string>();
                string[] allKeys = new string[t.Keys.Count];
                t.Keys.CopyTo(allKeys, 0);
                foreach (string key in allKeys)
                {
                    object value = t[key];
                    if (key is string title)
                    {
                        UIElement elem = null;
                        if (value is bool bo)
                        {
                            elem = new CheckBox()
                            {
                                IsChecked           = bo,
                                VerticalAlignment   = VerticalAlignment.Top,
                                HorizontalAlignment = HorizontalAlignment.Left,
                            };
                        }
                        else
                        {
                            if (value is string s)
                            {
                                elem = new TextBox()
                                {
                                    VerticalAlignment   = VerticalAlignment.Top,
                                    HorizontalAlignment = HorizontalAlignment.Left,
                                    Width = 300,
                                    Text  = s
                                };
                            }
                            else
                            {
                                if (value is int i)
                                {
                                    elem = new NumericUpDown()
                                    {
                                        VerticalAlignment   = VerticalAlignment.Top,
                                        HorizontalAlignment = HorizontalAlignment.Left,
                                        Value = i
                                    };
                                }
                                else
                                {
                                    float v = 0f;
                                    switch (value)
                                    {
                                    case long l:
                                        v = l;
                                        break;

                                    case ulong ul:
                                        v = ul;
                                        break;

                                    case float f:
                                        v = f;
                                        break;

                                    case double d:
                                        v = (float)d;
                                        break;
                                    }

                                    elem = new SingleUpDown()
                                    {
                                        VerticalAlignment   = VerticalAlignment.Top,
                                        HorizontalAlignment = HorizontalAlignment.Left,
                                        MaxHeight           = 128,
                                        MaxWidth            = 64,
                                        Value = v
                                    };
                                }
                            }
                        }

                        if (elem != null)
                        {
                            reverseLookup.Add(elem, title);
                            WrapPanel wp = new WrapPanel()
                            {
                                HorizontalAlignment = HorizontalAlignment.Left,
                                VerticalAlignment   = VerticalAlignment.Top,
                                Width = scw.Width
                            };

                            wp.Children.Add(new Label()
                            {
                                HorizontalAlignment = HorizontalAlignment.Left,
                                VerticalAlignment   = VerticalAlignment.Top,
                                Content             = title
                            });

                            wp.Children.Add(elem);
                            scw.WrapPanel_Content.Children.Add(wp);
                        }
                    }
                }

                bool b = scw.ShowDialog() ?? false;
                if (b)
                {
                    foreach (KeyValuePair <object, string> kv in reverseLookup)
                    {
                        if (kv.Key is CheckBox cb)
                        {
                            t[kv.Value] = cb.IsChecked ?? false;
                        }
                        else
                        {
                            if (kv.Key is TextBox tb)
                            {
                                t[kv.Value] = tb.Text;
                            }
                            else
                            {
                                if (kv.Key is NumericUpDown iud)
                                {
                                    t[kv.Value] = iud.Value;
                                }
                                else
                                {
                                    t[kv.Value] = ((SingleUpDown)kv.Key).Value;
                                }
                            }
                        }
                    }
                }

                return(b);
            }

            return(false);
        }
コード例 #9
0
        public RectControl()
        {
            UiGrid grid = new UiGrid();

            grid.SetCols(8);
            grid.ColumnDefinitions[0].Width = GridLength.Auto;
            grid.ColumnDefinitions[2].Width = GridLength.Auto;
            grid.ColumnDefinitions[4].Width = GridLength.Auto;
            grid.ColumnDefinitions[6].Width = GridLength.Auto;

            TextBlock xLabel = grid.AddUiElement(new TextBlock {
                Text = "x:"
            }, 0, 0);

            xLabel.Margin = new Thickness(3, 3, 5, 3);

            _x               = grid.AddUiElement(new SingleUpDown(), 0, 1);
            _x.Value         = 0;
            _x.Increment     = 0.5f;
            _x.FormatString  = "F3";
            _x.ValueChanged += XChanged;
            _x.Margin        = new Thickness(3);

            TextBlock yLabel = grid.AddUiElement(new TextBlock {
                Text = "y:"
            }, 0, 2);

            yLabel.Margin = new Thickness(10, 3, 5, 3);

            _y               = grid.AddUiElement(new SingleUpDown(), 0, 3);
            _y.Value         = 0;
            _y.Increment     = 0.5f;
            _y.FormatString  = "F3";
            _y.ValueChanged += YChanged;
            _y.Margin        = new Thickness(3);

            TextBlock wLabel = grid.AddUiElement(new TextBlock {
                Text = "width:"
            }, 0, 6);

            wLabel.Margin = new Thickness(10, 3, 5, 3);

            _w               = grid.AddUiElement(new SingleUpDown(), 0, 7);
            _w.Value         = 0;
            _w.Increment     = 0.5f;
            _w.FormatString  = "F3";
            _w.ValueChanged += WChanged;
            _w.Margin        = new Thickness(3);

            TextBlock hLabel = grid.AddUiElement(new TextBlock {
                Text = "height:"
            }, 0, 4);

            hLabel.Margin = new Thickness(10, 3, 5, 3);

            _h               = grid.AddUiElement(new SingleUpDown(), 0, 5);
            _h.Value         = 0;
            _h.Increment     = 0.5f;
            _h.FormatString  = "F3";
            _h.ValueChanged += HChanged;
            _h.Margin        = new Thickness(3);

            this.Content = grid;
        }