Esempio n. 1
0
        /// <param name="focusProperty"> Optional: Sets focus to control of this property.</param>
        private void RefreshProperties(ObsProperty focusProperty = null)
        {
            // prevent properties triggering another refresh when previous refresh is still ongoing
            if (++refreshCount > 0)
                return;

            ScrollableControl parent = (Parent as ScrollableControl);
            var oldScrollPos = parent != null ? parent.VerticalScroll.Value : 0;

            List<Control> controls = new List<Control>();
            Control focusControl = null;

            do
            {
                refreshCount = 0;
                controls.Clear();
                ObsProperty[] propertyList = properties.GetPropertyList();

                foreach (ObsProperty property in propertyList)
                {
                    PropertyControl control = new PropertyControl(this, property, settings)
                    {
                        Enabled = property.Enabled,
                        Visible = property.Visible
                    };

                    if (focusProperty != null && property.GetPointer() == focusProperty.GetPointer())
                        focusControl = control.Controls[1];

                    controls.Add(control);
                }
            }
            while (refreshCount > 0);

            panel.SuspendLayout();

            panel.Controls.Clear();
            panel.Controls.AddRange(controls.ToArray());

            panel.Select();
            panel.Focus();

            // restore last focused control and scroll state
            if (focusControl != null)
            {
                focusControl.Focus();
                focusControl.Select();
            }

            if (parent != null)
                parent.VerticalScroll.Value = oldScrollPos;

            panel.ResumeLayout();
            PerformLayout();

            refreshCount = -1;
        }
Esempio n. 2
0
        /// <param name="focusProperty"> Optional: Sets focus to control of this property.</param>
        private void RefreshProperties(ObsProperty focusProperty = null)
        {
            // prevent properties triggering another refresh when previous refresh is still ongoing
            if (++refreshCount > 0)
            {
                return;
            }

            ScrollableControl parent = (Parent as ScrollableControl);
            var oldScrollPos         = parent != null ? parent.VerticalScroll.Value : 0;

            List <Control> controls     = new List <Control>();
            Control        focusControl = null;

            do
            {
                refreshCount = 0;
                controls.Clear();
                ObsProperty[] propertyList = properties.GetPropertyList();

                foreach (ObsProperty property in propertyList)
                {
                    PropertyControl control = new PropertyControl(this, property, settings)
                    {
                        Enabled = property.Enabled,
                        Visible = property.Visible
                    };

                    if (focusProperty != null && property.GetPointer() == focusProperty.GetPointer())
                    {
                        focusControl = control.Controls[1];
                    }

                    controls.Add(control);
                }
            }while (refreshCount > 0);

            panel.SuspendLayout();

            panel.Controls.Clear();
            panel.Controls.AddRange(controls.ToArray());

            panel.Select();
            panel.Focus();

            // restore last focused control and scroll state
            if (focusControl != null)
            {
                focusControl.Focus();
                focusControl.Select();
            }

            if (parent != null)
            {
                parent.VerticalScroll.Value = oldScrollPos;
            }

            panel.ResumeLayout();
            PerformLayout();

            refreshCount = -1;
        }