コード例 #1
0
        private void RenderUIComponents(IfrmCommandEditor editorForm, ICommandControls commandControls)
        {
            if (Command == null)
            {
                throw new InvalidOperationException("Command cannot be null!");
            }

            UIControls = new List <Control>();

            var renderedControls = Command.Render(editorForm, commandControls);

            foreach (var ctrl in renderedControls)
            {
                UIControls.Add(ctrl);
            }

            //generate Private Checkbox (Control) if user did not add it
            var privateCheckBoxControlExists  = renderedControls.Any(f => f.Name == "v_IsPrivate");
            var continueComboBoxControlExists = renderedControls.Any(f => f.Name == "v_ErrorHandling");

            if (!privateCheckBoxControlExists)
            {
                //TODO: when using a layoutpanel, checkbox is resetting when form closes
                //FlowLayoutPanel flpCheckBox = new FlowLayoutPanel();
                //flpCheckBox.Height = 30;
                //flpCheckBox.FlowDirection = FlowDirection.LeftToRight;
                UIControls.Add(commandControls.CreateDefaultLabelFor("v_IsPrivate", Command));
                UIControls.Add(commandControls.CreateCheckBoxFor("v_IsPrivate", Command));
                //UIControls.Add(flpCheckBox);
            }

            if (!continueComboBoxControlExists)
            {
                UIControls.Add(commandControls.CreateDefaultLabelFor("v_ErrorHandling", Command));
                ComboBox continueBox = commandControls.CreateDropdownFor("v_ErrorHandling", Command);
                continueBox.Items.Add("None");
                continueBox.Items.Add("Report Error");
                continueBox.Items.Add("Ignore Error");
                UIControls.Add(continueBox);
            }

            //generate comment command if user did not generate it
            var commentControlExists = renderedControls.Any(f => f.Name == "v_Comment");

            if (!commentControlExists)
            {
                UIControls.Add(commandControls.CreateDefaultLabelFor("v_Comment", Command));
                UIControls.Add(commandControls.CreateDefaultNoValidationInputFor("v_Comment", Command, 100, 300));
            }
        }