Exemplo n.º 1
0
        /// <summary>
        /// Useses reflection to search for all properties of
        /// this class that have the EditProp attribute and
        /// create and bind the appropriate generated control
        /// for the Edit Properties panel.
        /// </summary>
        protected virtual void BindEditProps()
        {
            Type type = this.GetType();

            PropertyInfo[] propInfo = type.GetProperties();

            Dictionary <int, List <UIElement> > templateGroups = new Dictionary <int, List <UIElement> >();
            Dictionary <int, List <UIElement> > instanceGroups = new Dictionary <int, List <UIElement> >();

            foreach (PropertyInfo prop in propInfo)
            {
                object[] attrs = prop.GetCustomAttributes(true);
                foreach (object attr in attrs)
                {
                    EditPropAttribute editPropAttr = attr as EditPropAttribute;
                    if (editPropAttr != null)
                    {
                        //makes the controls and bind them to the property in question
                        StackPanel stack = BindEditPropHelper(editPropAttr, prop);

                        if (templateGroups.ContainsKey(editPropAttr.GroupID))
                        {
                            templateGroups[editPropAttr.GroupID].Add(stack);
                        }
                        else
                        {
                            List <UIElement> list = new List <UIElement>();
                            list.Add(stack);
                            templateGroups.Add(editPropAttr.GroupID, list);
                        }
                    }
                }
            }

            //sort by group id and add properties in-order
            List <int> sortedList = templateGroups.Keys.ToList();

            sortedList.Sort();
            foreach (int group in sortedList)
            {
                foreach (UIElement element in templateGroups[group])
                {
                    EditableProperties.Add(element);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Extends baseclass implmentation to add custom controls.
        /// </summary>
        protected override void BindEditProps()
        {
            base.BindEditProps();

            //Create a button that handles getting the image filename
            Button file = new Button();

            file.Width               = 80;
            file.Content             = "Image...";
            file.Click              += OnChooseImageButton;
            file.Margin              = new Thickness(2);
            file.HorizontalAlignment = HorizontalAlignment.Left;

            TextBox fileBlock = new TextBox();

            fileBlock.IsEnabled           = false;
            fileBlock.Width               = 150;
            fileBlock.Margin              = new Thickness(2);
            fileBlock.HorizontalAlignment = HorizontalAlignment.Left;
            Binding bind = new Binding("FileName");

            bind.Source = _Content;
            bind.Mode   = BindingMode.OneWay;
            bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            fileBlock.SetBinding(TextBox.TextProperty, bind);

            StackPanel stack = new StackPanel();

            stack.Orientation         = Orientation.Horizontal;
            stack.FlowDirection       = FlowDirection.LeftToRight;
            stack.Margin              = new Thickness(2);
            stack.HorizontalAlignment = HorizontalAlignment.Left;
            stack.Children.Add(file);
            stack.Children.Add(fileBlock);

            EditableProperties.Add(stack as UIElement);
        }
 public EditableSubProperties(String name, EditableProperties parent)
 {
     _name = name;
     _parent = parent;
 }
Exemplo n.º 4
0
 public EditableSubProperties(String name, EditableProperties parent)
 {
     _name   = name;
     _parent = parent;
 }