Beispiel #1
0
        /// <summary>
        /// Adds the <see cref="PropertiesListElement"/> to the current layou or reuses the previous one. Used to inject properties.
        /// </summary>
        /// <param name="name">The property label name.</param>
        /// <param name="tooltip">The property label tooltip text.</param>
        /// <returns>The element.</returns>
        public PropertiesListElement AddPropertyItem(string name, string tooltip = null)
        {
            PropertiesListElement element = AddPropertyItem();

            element.OnAddProperty(name, tooltip);
            return(element);
        }
Beispiel #2
0
        /// <summary>
        /// Adds the <see cref="PropertiesListElement"/> to the current layou or reuses the previous one. Used to inject properties.
        /// </summary>
        /// <param name="label">The property label.</param>
        /// <param name="tooltip">The property label tooltip text.</param>
        /// <returns>The element.</returns>
        public PropertiesListElement AddPropertyItem(PropertyNameLabel label, string tooltip = null)
        {
            if (label == null)
            {
                throw new ArgumentNullException();
            }

            PropertiesListElement element = AddPropertyItem();

            element.OnAddProperty(label, tooltip);
            return(element);
        }
Beispiel #3
0
        /// <summary>
        /// Spawns the property for the given item.
        /// </summary>
        /// <param name="itemLayout">The item layout.</param>
        /// <param name="itemValues">The item values.</param>
        /// <param name="item">The item.</param>
        protected virtual void SpawnProperty(LayoutElementsContainer itemLayout, ValueContainer itemValues, ItemInfo item)
        {
            int labelIndex = 0;

            if ((item.IsReadOnly || item.VisibleIf != null) &&
                itemLayout.Children.Count > 0 &&
                itemLayout.Children[itemLayout.Children.Count - 1] is PropertiesListElement propertiesListElement)
            {
                labelIndex = propertiesListElement.Labels.Count;
            }

            itemLayout.Property(item.DisplayName, itemValues, item.OverrideEditor, item.TooltipText);

            if (item.IsReadOnly && itemLayout.Children.Count > 0)
            {
                PropertiesListElement list  = null;
                int  firstChildControlIndex = 0;
                bool disableSingle          = true;
                var  control = itemLayout.Children[itemLayout.Children.Count - 1];
                if (control is GroupElement group && group.Children.Count > 0)
                {
                    list          = group.Children[0] as PropertiesListElement;
                    disableSingle = false; // Disable all nested editors
                }
                else if (control is PropertiesListElement list1)
                {
                    list = list1;
                    firstChildControlIndex = list.Labels[labelIndex].FirstChildControlIndex;
                }

                if (list != null)
                {
                    // Disable controls added to the editor
                    var count = list.Properties.Children.Count;
                    for (int j = firstChildControlIndex; j < count; j++)
                    {
                        var child = list.Properties.Children[j];
                        if (disableSingle && child is PropertyNameLabel)
                        {
                            break;
                        }

                        if (child != null)
                        {
                            child.Enabled = false;
                        }
                    }
                }
            }
Beispiel #4
0
        private PropertiesListElement AddPropertyItem()
        {
            // Try to reuse previous control
            PropertiesListElement element;

            if (Children.Count > 0 && Children[Children.Count - 1] is PropertiesListElement propertiesListElement)
            {
                element = propertiesListElement;
            }
            else
            {
                element = new PropertiesListElement();
                OnAddElement(element);
            }
            return(element);
        }