Example #1
0
        /// <summary>
        /// Update the location of all the <see cref="XPPanel"/> controls
        /// in the <see cref="XPPanelGroup"/> after a particular index
        /// </summary>
        /// <remarks>
        /// Used when a panel is collapsed or expanded to change all the
        /// subsequent panels
        /// </remarks>
        private void UpdatePanelsAfter(XPPanel panel)
        {
            // @@BUGFIX: 1.1
            if (!panel.Visible)
            {
                UpdatePanels();
                return;
            }

            if (isInitializingComponent || updatingPanels)
            {
                return;
            }

            updatingPanels = true;

            // the bottom of the specified panel plus the BorderMargin.Height (which we always need
            // to take into account)
            int lastBottom = panel.Top + panel.Height;

            // map the panel to its index in our panels collection
            int panelIndex = panels.IndexOf(panel) + 1;

            // for each following panel, relocate it
            for (int i = panelIndex; i < panels.Count; i++)
            {
                XPPanel nextPanel = (XPPanel)panels[i];

                // @@BUGFIX: 1.1
                if (!nextPanel.Visible)
                {
                    continue;
                }

                UpdatePanel(nextPanel, lastBottom);
                lastBottom = nextPanel.Top + nextPanel.Height;
            }

            updatingPanels = false;
        }
        /// <summary>
        /// Convert to an <see cref="InstanceDescriptor"/> if requested
        /// </summary>
        /// <param name="context">designer context</param>
        /// <param name="culture">globalization</param>
        /// <param name="value">the instance to convert</param>
        /// <param name="destinationType">The target type</param>
        /// <returns>
        /// An <see cref="InstanceDescriptor"/> if requested, otherwise whatever
        /// the base class returns
        /// </returns>
        public override object ConvertTo(
            ITypeDescriptorContext context,
            System.Globalization.CultureInfo culture,
            object value,
            Type destinationType
            )
        {
            // the designer wants an InstanceDescriptor
            if ((destinationType == typeof(InstanceDescriptor)) && (value is XPPanel))
            {
                XPPanel xpPanel = value as XPPanel;
                // Get our XPPanel(int) constructor
                ConstructorInfo ctorInfo = typeof(XPPanel).GetConstructor(new Type [] { typeof(int) });
                if (ctorInfo != null)
                {
                    // use this constructor and pass in the ExpandedHeight value. Use false to say that
                    // initialization is NOT complete
                    return(new InstanceDescriptor(ctorInfo, new object [] { xpPanel.ExpandedHeight }, false));
                }
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
Example #3
0
 void Awake()
 {
     expPanel = FindObjectOfType <XPPanel>();
 }