コード例 #1
0
        public TextualBasicValueEditor(ItemType valueType, IEnumerable<ValueValidatorAttribute> validators, XElement serializedDefaultValue)
            : base(valueType, validators, serializedDefaultValue)
        {
            basicValueType = (BasicItemType)ValueType;

            Grid grid = new Grid {
                ColumnDefinitions = {
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }
                }
            };
            Representation = grid;

            uiText = new TextBox();
            uiText.TextChanged += uiText_TextChanged;
            uiText.KeyDown += uiText_KeyDown;
            uiText.LostFocus += uiText_LostFocus;
            Grid.SetColumn(uiText, 0);
            grid.Children.Add(uiText);

            uiError = new Image {
                Margin = new Thickness(5, 0, 0, 0),
                Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("pack://application:,,,/ObjectConfigurator;component/Resources/error.png")),
                Width = 18
            };
            Grid.SetColumn(uiError, 1);
            grid.Children.Add(uiError);

            CheckError();
        }
コード例 #2
0
        public CollectionValueEditor(ItemType valueType, IEnumerable<ValueValidatorAttribute> validators, XElement serializedDefaultValue)
            : base(valueType, validators, serializedDefaultValue)
        {
            collectionValueType = (CollectionItemType)ValueType;

            xDefaultElementValue = new XElement(XName.Get("defaultValue"));
            collectionValueType.ElementType.WriteDefaultValueToXElement(xDefaultElementValue);

            uiItems = new StackPanel {
            };

            uiAdd = new Button {
                Content = new StackPanel {
                    Orientation = Orientation.Horizontal,
                    Children = {
                        new Image {
                            Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("pack://application:,,,/ObjectConfigurator;component/Resources/plus.png")),
                            Width = 12,
                            Margin = new Thickness(5, 0, 0, 0)
                        },
                        new TextBlock {
                            Margin = new Thickness(5, 0, 5, 0),
                            VerticalAlignment = VerticalAlignment.Center,
                            Text = "Add"
                        }
                    }
                },
                Margin = new Thickness(2, 4, 2, 2),
                HorizontalAlignment = HorizontalAlignment.Left
            };
            uiAdd.Click += uiAdd_Click;

            uiError = new Image {
                Margin = new Thickness(10, 0, 0, 0),
                Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("pack://application:,,,/ObjectConfigurator;component/Resources/error.png")),
                Width = 20,
                VerticalAlignment = VerticalAlignment.Center
            };
            Grid.SetColumn(uiError, 1);

            uiItems.Children.Add(new Grid {
                ColumnDefinitions = {
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) },
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }
                },
                Children = { uiAdd, uiError }
            });

            Representation = new Border {
                Background = Brushes.GhostWhite,
                BorderBrush = Brushes.LightGray,
                BorderThickness = new Thickness(1),
                CornerRadius = new CornerRadius(10),
                Padding = new Thickness(5),
                Child = uiItems
            };

            CheckErrors();
        }
コード例 #3
0
        public CustomValueEditor(ItemType valueType, IEnumerable<ValueValidatorAttribute> validators, XElement serializedDefaultValue)
            : base(valueType, validators, serializedDefaultValue)
        {
            customValueType = (CustomItemType)ValueType;
            customType = customValueType.GetCustomType();
            customEditor = customType.CreateEditor();

            Representation = customEditor.Representation;

            customEditor.ValueChanged += customEditor_ValueChanged;
        }
コード例 #4
0
        public BooleanValueEditor(ItemType valueType, IEnumerable<ValueValidatorAttribute> validators, XElement serializedDefaultValue)
            : base(valueType, validators, serializedDefaultValue)
        {
            basicValueType = (BasicItemType)ValueType;

            uiValue = new CheckBox {
                Margin = new Thickness(3),
                IsChecked = (serializedDefaultValue.Value == true.ToString())
            };
            uiValue.Click += uiValue_Click;

            Representation = new Border { Child = uiValue };
        }
コード例 #5
0
ファイル: EnumValueEditor.cs プロジェクト: bzamecnik/XRouter
        public EnumValueEditor(ItemType valueType, IEnumerable<ValueValidatorAttribute> validators, XElement serializedDefaultValue)
            : base(valueType, validators, serializedDefaultValue)
        {
            enumValueType = (EnumItemType)ValueType;

            uiValue = new ComboBox {
                IsEditable = false,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            uiValue.SelectionChanged += uiValue_SelectionChanged;

            Representation = uiValue;

            foreach (string valueName in enumValueType.ValueNames) {
                ComboBoxItem item = new ComboBoxItem {
                    Content = valueName,
                    Tag = valueName
                };
                uiValue.Items.Add(item);
            }
            uiValue.SelectedIndex = 0;
        }
コード例 #6
0
 public CollectionItemType(Type clrType, ItemType elementType)
     : base(clrType)
 {
     ElementType = elementType;
 }
コード例 #7
0
 public DictionaryItemType(Type clrType, ItemType keyType, ItemType valueType)
     : base(clrType)
 {
     KeyType = keyType;
     ValueType = valueType;
 }