public PropertyEnableUserControl(ConfigurationItem item, EventHandler valueChangedHandler, int leftOffset, ConfigApiClient configApiClient, string toHaveFocus = null)
        {
            InitializeComponent();

            _item = item;
            _valueChangedHandler = valueChangedHandler;
            _configApiClient     = configApiClient;

            if (item.EnableProperty != null)
            {
                EnabledCheckBox.Checked = item.EnableProperty.Enabled;
                EnabledCheckBox.Text    = item.EnableProperty.DisplayName;
            }
            else
            {
                EnabledCheckBox.Visible = false;
            }

            this.Height = PanelUtils.BuildPropertiesUI(item, 0, leftOffset, panelContent, valueChangedHandler, _configApiClient, toHaveFocus);
        }
Exemple #2
0
        public PropertyListUserControl(ConfigurationItem item, EventHandler valueChangedHandler, int leftOffset, ConfigApiClient configApiClient, string toHaveFocus)
        {
            InitializeComponent();

            _configApiClient     = configApiClient;
            _valueChangedHandler = valueChangedHandler;

            if (item.EnableProperty != null)
            {
                EnabledCheckBox.Visible = true;
                EnabledCheckBox.Checked = item.EnableProperty.Enabled;
                EnabledCheckBox.Text    = item.EnableProperty.DisplayName;
            }
            else
            {
                EnabledCheckBox.Visible = false;
                textBoxName.Location    = EnabledCheckBox.Location;
            }

            textBoxName.Text = item.DisplayName;

            int totalContentHeight = this.Height;            // panelContent.Location.Y;

            totalContentHeight += PanelUtils.BuildPropertiesUI(item, 0, leftOffset, panelContent, valueChangedHandler, _configApiClient, toHaveFocus);

            if (!item.ChildrenFilled)                   //TODO exception stuff, or load elsewhere
            {
                try
                {
                    item.Children       = _configApiClient.GetChildItems(item.Path);
                    item.ChildrenFilled = true;
                } catch (Exception ex)
                {
                    MessageBox.Show(String.Format("GetChildItems({0}) : {1}", item.Path, ex.Message));
                }
            }

            if (item.Children != null)
            {
                leftOffset += Constants.LeftIndentChildControl;
                foreach (ConfigurationItem child in item.Children)
                {
                    if ((child.Children == null || child.Children.Length == 0) && child.EnableProperty != null)
                    {
                        UserControl uc = new PropertyEnableUserControl(child, valueChangedHandler, leftOffset, _configApiClient, toHaveFocus);
                        uc.Width            = panelContent.Width;
                        uc.Location         = new Point(Constants.LeftIndentChildControl, panelContent.Height);
                        uc.Anchor           = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                        this.Height        += uc.Height;
                        totalContentHeight += uc.Height;
                        panelContent.Controls.Add(uc);
                    }
                    else
                    {
                        UserControl uc = new PropertyListUserControl(child, valueChangedHandler, leftOffset, _configApiClient, toHaveFocus);
                        uc.Width            = panelContent.Width;
                        uc.Location         = new Point(Constants.LeftIndentChildControl, panelContent.Height);
                        uc.Anchor           = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                        this.Height        += uc.Height;
                        totalContentHeight += uc.Height;
                        panelContent.Controls.Add(uc);
                    }
                }
                //panelContent.Height = totalContentHeight;
            }
            this.Height = totalContentHeight;
        }