Ejemplo n.º 1
0
        /// <summary>
        /// <para>Combines this attribute with another attribute of the same type.
        /// This method invokes the virtual <see cref="CombineValuesWith(PropertyGroupAttribute)"/> method to invoke custom combine logic.</para>
        /// <para>All group attributes are combined to one attribute used by a single OdinGroupDrawer.</para>
        /// <para>Example: <code>protected override void CombineValuesWith(PropertyGroupAttribute other) { this.Title = this.Title ?? (other as MyGroupAttribute).Title; }</code></para>
        /// </summary>
        /// <param name="other">The attribute to combine with.</param>
        /// <returns>The instance that the method was invoked on.</returns>
        /// <exception cref="System.ArgumentNullException">The argument 'other' was null.</exception>
        /// <exception cref="System.ArgumentException">
        /// Attributes to combine are not of the same type.
        /// or
        /// PropertyGroupAttributes to combine must have the same group id.
        /// </exception>
        public PropertyGroupAttribute Combine(PropertyGroupAttribute other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            if (other.GetType() != this.GetType())
            {
                throw new ArgumentException("Attributes to combine are not of the same type.");
            }

            if (other.GroupID != this.GroupID)
            {
                throw new ArgumentException("PropertyGroupAttributes to combine must have the same group id.");
            }

            if (this.Order == 0)
            {
                this.Order = other.Order;
            }
            else if (other.Order != 0)
            {
                this.Order = Math.Min(this.Order, other.Order);
            }

            this.CombineValuesWith(other);
            return(this);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Combines the box group with another group.
        /// </summary>
        /// <param name="other">The other group.</param>
        protected override void CombineValuesWith(PropertyGroupAttribute other)
        {
            var attr = other as BoxGroupAttribute;

            if (this.ShowLabel == false || attr.ShowLabel == false)
            {
                this.ShowLabel = false;
                attr.ShowLabel = false;
            }

            this.CenterLabel |= attr.CenterLabel;
        }
Ejemplo n.º 3
0
        /// <summary>Combines the box group with another group.</summary>
        /// <param name="other">The other group.</param>
        protected override void CombineValuesWith(PropertyGroupAttribute other)
        {
            BoxGroupAttribute boxGroupAttribute = other as BoxGroupAttribute;

            if (!this.ShowLabel || !boxGroupAttribute.ShowLabel)
            {
                this.ShowLabel = false;
                boxGroupAttribute.ShowLabel = false;
            }

            this.CenterLabel |= boxGroupAttribute.CenterLabel;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Combines TitleGroup attributes.
        /// </summary>
        protected override void CombineValuesWith(PropertyGroupAttribute other)
        {
            var t = (other as TitleGroupAttribute);

            if (this.Subtitle != null)
            {
                t.Subtitle = this.Subtitle;
            }
            else
            {
                this.Subtitle = t.Subtitle;
            }

            if (this.Alignment != TitleAlignments.Left)
            {
                t.Alignment = this.Alignment;
            }
            else
            {
                this.Alignment = t.Alignment;
            }

            if (this.HorizontalLine != true)
            {
                t.HorizontalLine = this.HorizontalLine;
            }
            else
            {
                this.HorizontalLine = t.HorizontalLine;
            }

            if (this.BoldTitle != true)
            {
                t.BoldTitle = this.BoldTitle;
            }
            else
            {
                this.BoldTitle = t.BoldTitle;
            }

            if (this.Indent == true)
            {
                t.Indent = this.Indent;
            }
            else
            {
                this.Indent = t.Indent;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Combines the tab group with another group.
        /// </summary>
        /// <param name="other">The other group.</param>
        protected override void CombineValuesWith(PropertyGroupAttribute other)
        {
            base.CombineValuesWith(other);

            var otherTab = other as TabGroupAttribute;

            if (otherTab.TabName != null)
            {
                this.UseFixedHeight = this.UseFixedHeight || otherTab.UseFixedHeight;
                if (this.Tabs.Contains(otherTab.TabName) == false)
                {
                    this.Tabs.Add(otherTab.TabName);
                }
            }
        }
        /// <summary>
        /// Combines the ToggleGroup with another ToggleGroup.
        /// </summary>
        /// <param name="other">Another ToggleGroup.</param>
        protected override void CombineValuesWith(PropertyGroupAttribute other)
        {
            var attr = other as ToggleGroupAttribute;

            if (this.ToggleGroupTitle == null)
            {
                this.ToggleGroupTitle = attr.ToggleGroupTitle;
            }
            else if (attr.ToggleGroupTitle == null)
            {
                attr.ToggleGroupTitle = this.ToggleGroupTitle;
            }

            this.CollapseOthersOnExpand = this.CollapseOthersOnExpand || attr.CollapseOthersOnExpand;
            attr.CollapseOthersOnExpand = this.CollapseOthersOnExpand;
        }
        /// <summary>
        /// Combines the foldout property with another.
        /// </summary>
        /// <param name="other">The group to combine with.</param>
        protected override void CombineValuesWith(PropertyGroupAttribute other)
        {
            var attr = other as FoldoutGroupAttribute;

            if (attr.HasDefinedExpanded)
            {
                this.HasDefinedExpanded = true;
                this.Expanded           = attr.Expanded;
            }

            if (this.HasDefinedExpanded)
            {
                attr.HasDefinedExpanded = true;
                attr.Expanded           = this.Expanded;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Combines properties that have been group vertically.
        /// </summary>
        protected override void CombineValuesWith(PropertyGroupAttribute other)
        {
            var a = other as VerticalGroupAttribute;

            if (a != null)
            {
                if (a.PaddingTop != 0)
                {
                    this.PaddingTop = a.PaddingTop;
                }

                if (a.PaddingBottom != 0)
                {
                    this.PaddingBottom = a.PaddingBottom;
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Combines the tab group with another group.
        /// </summary>
        /// <param name="other">The other group.</param>
        protected override void CombineValuesWith(PropertyGroupAttribute other)
        {
            base.CombineValuesWith(other);

            var otherTab = other as TabGroupAttribute;

            if (otherTab.TabName != null)
            {
                this.UseFixedHeight = this.UseFixedHeight || otherTab.UseFixedHeight;
                this.Paddingless    = this.Paddingless || otherTab.Paddingless;
                this.HideTabGroupIfTabGroupOnlyHasOneTab = this.HideTabGroupIfTabGroupOnlyHasOneTab || otherTab.HideTabGroupIfTabGroupOnlyHasOneTab;

                if (this.Tabs.Contains(otherTab.TabName) == false)
                {
                    this.Tabs.Add(otherTab.TabName);
                }
            }
        }
        /// <summary>
        /// Merges the values of this group with another ResponsiveButtonGroupAttribute.
        /// </summary>
        /// <param name="other">The attribute to combine with.</param>
        protected override void CombineValuesWith(PropertyGroupAttribute other)
        {
            var otherAttr = other as ResponsiveButtonGroupAttribute;

            if (other == null)
            {
                return;
            }

            if (otherAttr.DefaultButtonSize != ButtonSizes.Medium)
            {
                this.DefaultButtonSize = otherAttr.DefaultButtonSize;
            }
            else if (this.DefaultButtonSize != ButtonSizes.Medium)
            {
                otherAttr.DefaultButtonSize = this.DefaultButtonSize;
            }

            this.UniformLayout = this.UniformLayout || otherAttr.UniformLayout;
        }
 /// <summary>
 /// Combines the groups togethers.
 /// </summary>
 /// <param name="other">The other group to combine with.</param>
 protected override void CombineValuesWith(PropertyGroupAttribute other)
 {
     this.Title      = this.Title ?? (other as HorizontalGroupAttribute).Title;
     this.LabelWidth = Math.Max(this.LabelWidth, (other as HorizontalGroupAttribute).LabelWidth);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Not yet documented.
        /// </summary>
        /// <returns>Not yet documented.</returns>
        string ISubGroupProviderAttribute.RepathMemberAttribute(PropertyGroupAttribute attr)
        {
            var tabAttr = (TabGroupAttribute)attr;

            return(this.GroupID + "/" + tabAttr.TabName);
        }
Ejemplo n.º 13
0
 /// <summary>
 /// <para>Override this method to add custom combine logic to your group attribute. This method determines how your group's parameters combine when spread across multiple attribute declarations in the same class.</para>
 /// <para>Remember, in .NET, member order is not guaranteed, so you never know which order your attributes will be combined in.</para>
 /// </summary>
 /// <param name="other">The attribute to combine with. This parameter is guaranteed to be of the correct attribute type.</param>
 /// <example>
 /// <para>This example shows how <see cref="BoxGroupAttribute"/> attributes are combined.</para>
 /// <code>
 /// protected override void CombineValuesWith(PropertyGroupAttribute other)
 /// {
 ///     // The given attribute parameter is *guaranteed* to be of type BoxGroupAttribute.
 ///     var attr = other as BoxGroupAttribute;
 ///
 ///     // If this attribute has no label, we the other group's label, thus preserving the label across combines.
 ///     if (this.Label == null)
 ///     {
 ///         this.Label = attr.Label;
 ///     }
 ///
 ///     // Combine ShowLabel and CenterLabel parameters.
 ///     this.ShowLabel |= attr.ShowLabel;
 ///     this.CenterLabel |= attr.CenterLabel;
 /// }
 /// </code>
 /// </example>
 protected virtual void CombineValuesWith(PropertyGroupAttribute other)
 {
 }