protected internal override void OnThemeChange()
        {
            // Update base if not auto size mode
            if (!AutoSize)
            {
                base.OnThemeChange();
            }

            // Recalculate size
            RecalculateSize();

            // Update ContainerView
            ContainerView.OnThemeChange();

            // Update all cilds
            foreach (var child in Children)
            {
                child.OnThemeChange();
            }
        }
示例#2
0
        internal override void RecalculateAlignOffsets()
        {
            // Calculate the align offset for each control
            var currentHeight    = 0;
            var previousCheckBox = false;
            var previousKeyBind  = false;
            var previousLabel    = false;

            for (var i = 0; i < Children.Count; i++)
            {
                var child = Children[i];
                if (child is CheckBox)
                {
                    if (previousCheckBox)
                    {
                        // Align check box in 2nd row
                        child.AlignOffset = new Vector2(Size.X / 2f - ContainerView.ScrollbarWidth / 2f, currentHeight);
                        currentHeight    += Padding + (int)child.Size.Y;
                        previousCheckBox  = false;
                    }
                    else
                    {
                        // Mark check box for next loop
                        child.AlignOffset = new Vector2(0, currentHeight);
                        previousCheckBox  = true;
                    }

                    // Update helper markers
                    previousKeyBind = false;
                    previousLabel   = false;
                }
                else
                {
                    if (previousCheckBox)
                    {
                        // Increase height because it was not increased with the last checkbox
                        currentHeight   += Padding + (int)Children[i - 1].Size.Y;
                        previousCheckBox = false;
                    }

                    // KeyBind
                    var keyBind = child as KeyBind;
                    if (keyBind != null)
                    {
                        if (!previousKeyBind)
                        {
                            // Set key bind to draw the header
                            keyBind.DrawHeader = true;

                            if (previousLabel)
                            {
                                // Shorten the height
                                currentHeight -= KeyBind.HeaderHeight;

                                // Adjust width of the previous label
                                ((Label)Children[i - 1]).TextWidthMultiplier = (KeyBind.KeyButtonHandle.WidthMultiplier * 2 * ValueBase.DefaultWidth) / ValueBase.DefaultWidth;
                            }
                        }
                        else
                        {
                            // Set key bind to not draw the header as there is a previous key bind
                            keyBind.DrawHeader = false;
                        }
                    }
                    else if (previousLabel)
                    {
                        // Set the text width multiplier back to default (1)
                        ((Label)Children[i - 1]).TextWidthMultiplier = 1;
                    }

                    // Set align offset and increase height
                    child.AlignOffset = new Vector2(0, currentHeight);
                    currentHeight    += Padding + (int)child.Size.Y;

                    // Update helper markers
                    previousKeyBind = child is KeyBind;
                    previousLabel   = child is Label;
                }
            }

            // Recalculate Bounding
            RecalculateBounding();

            // Recalculate Cropping
            ContainerView.UpdateChildrenCropping();
        }