Esempio n. 1
0
        private PropertyGrid(TreeStyle style, string category, Record parentProperty, PropertyGrid parentGrid = null)
        {
            _parentGrid   = parentGrid;
            InternalChild = new Grid();

            _parentProperty             = parentProperty;
            InternalChild.ColumnSpacing = 8;
            InternalChild.RowSpacing    = 8;
            InternalChild.ColumnsProportions.Add(new Proportion(ProportionType.Pixels, 150));
            InternalChild.ColumnsProportions.Add(new Proportion(ProportionType.Fill));

            Category = category;

            if (style != null)
            {
                ApplyPropertyGridStyle(style);
            }

            HorizontalAlignment = HorizontalAlignment.Stretch;
            VerticalAlignment   = VerticalAlignment.Stretch;
        }
Esempio n. 2
0
            public SubGrid(PropertyGrid parent, object value, string header, string category, string filter, Record parentProperty)
            {
                InternalChild = new Grid
                {
                    ColumnSpacing = 4,
                    RowSpacing    = 4
                };

                InternalChild.ColumnsProportions.Add(new Proportion(ProportionType.Auto));
                InternalChild.ColumnsProportions.Add(new Proportion(ProportionType.Fill));
                InternalChild.RowsProportions.Add(new Proportion(ProportionType.Auto));
                InternalChild.RowsProportions.Add(new Proportion(ProportionType.Auto));

                _propertyGrid = new PropertyGrid(parent.PropertyGridStyle, category, parentProperty, parent)
                {
                    Object = value,
                    Filter = filter,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    GridColumn          = 1,
                    GridRow             = 1
                };

                // Mark
                _mark = new ImageButton(null)
                {
                    Toggleable          = true,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Center
                };
                _mark.ApplyImageButtonStyle(parent.PropertyGridStyle.MarkStyle);

                InternalChild.Widgets.Add(_mark);

                _mark.PressedChanged += (sender, args) =>
                {
                    if (_mark.IsPressed)
                    {
                        InternalChild.Widgets.Add(_propertyGrid);
                        parent._expandedCategories.Add(category);
                    }
                    else
                    {
                        InternalChild.Widgets.Remove(_propertyGrid);
                        parent._expandedCategories.Remove(category);
                    }
                };

                var expanded = true;

                if (parentProperty != null && parentProperty.FindAttribute <DesignerFoldedAttribute>() != null)
                {
                    expanded = false;
                }

                if (expanded)
                {
                    _mark.IsPressed = true;
                }

                var label = new Label(null)
                {
                    Text       = header,
                    GridColumn = 1
                };

                label.ApplyLabelStyle(parent.PropertyGridStyle.LabelStyle);

                InternalChild.Widgets.Add(label);

                HorizontalAlignment = HorizontalAlignment.Stretch;
                VerticalAlignment   = VerticalAlignment.Stretch;
            }
Esempio n. 3
0
        public CollectionEditor(IList collection, Type type)
        {
            Width  = 500;
            Height = 400;

            _collection = collection;
            _type       = type;

            InternalChild = new Grid
            {
                PaddingLeft   = 8,
                PaddingRight  = 8,
                PaddingBottom = 8,
                PaddingTop    = 8,
                ColumnSpacing = 8,
                RowSpacing    = 8
            };

            InternalChild.ColumnsProportions.Add(new Proportion(ProportionType.Auto));
            InternalChild.ColumnsProportions.Add(new Proportion(ProportionType.Fill));

            InternalChild.RowsProportions.Add(new Proportion(ProportionType.Fill));
            InternalChild.RowsProportions.Add(new Proportion(ProportionType.Auto));

            _listItems = new ListBox
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch
            };

            _listItems.SelectedIndexChanged += ListItemsOnSelectedIndexChanged;

            // Add initial items
            foreach (var item in _collection)
            {
                _listItems.Items.Add(new ListItem(BuildItemText(item), null, item));
            }

            InternalChild.Widgets.Add(_listItems);

            _propertyGrid = new PropertyGrid {
                GridColumn = 1
            };
            _propertyGrid.PropertyChanged += PropertyGridOnPropertyChanged;

            InternalChild.Widgets.Add(_propertyGrid);

            var buttonsGrid = new Grid
            {
                GridRow       = 1,
                ColumnSpacing = 4
            };

            buttonsGrid.ColumnsProportions.Add(new Proportion(ProportionType.Auto));
            buttonsGrid.ColumnsProportions.Add(new Proportion(ProportionType.Auto));
            buttonsGrid.ColumnsProportions.Add(new Proportion(ProportionType.Auto));
            buttonsGrid.ColumnsProportions.Add(new Proportion(ProportionType.Auto));

            var buttonNew = new ImageTextButton {
                Text = "New"
            };

            buttonNew.Click += ButtonNewOnUp;
            buttonsGrid.Widgets.Add(buttonNew);

            _buttonDelete = new ImageTextButton
            {
                Text       = "Delete",
                GridColumn = 1
            };
            _buttonDelete.Click += ButtonDeleteOnUp;
            buttonsGrid.Widgets.Add(_buttonDelete);

            _buttonMoveUp = new ImageTextButton
            {
                Text       = "Up",
                GridColumn = 2
            };
            _buttonMoveUp.Click += ButtonMoveUpOnUp;
            buttonsGrid.Widgets.Add(_buttonMoveUp);

            _buttonMoveDown = new ImageTextButton
            {
                Text       = "Down",
                GridColumn = 3
            };
            _buttonMoveDown.Click += ButtonMoveDownOnUp;
            buttonsGrid.Widgets.Add(_buttonMoveDown);

            InternalChild.Widgets.Add(buttonsGrid);

            UpdateButtonsEnabled();
        }