Esempio n. 1
0
        public override List <Control> Render(IfrmCommandEditor editor, ICommandControls commandControls)
        {
            base.Render(editor, commandControls);

            //create file path and helpers
            RenderedControls.Add(commandControls.CreateDefaultLabelFor("v_taskPath", this));
            var taskPathControl = commandControls.CreateDefaultInputFor("v_taskPath", this);

            RenderedControls.AddRange(commandControls.CreateUIHelpersFor("v_taskPath", this, new Control[] { taskPathControl }, editor));
            RenderedControls.Add(taskPathControl);
            taskPathControl.TextChanged += TaskPathControl_TextChanged;

            _passParameters           = new CheckBox();
            _passParameters.AutoSize  = true;
            _passParameters.Text      = "Assign Variables";
            _passParameters.Font      = new Font("Segoe UI Light", 12);
            _passParameters.ForeColor = Color.White;
            _passParameters.DataBindings.Add("Checked", this, "v_AssignVariables", false, DataSourceUpdateMode.OnPropertyChanged);
            _passParameters.CheckedChanged += (sender, e) => PassParametersCheckbox_CheckedChanged(sender, e, editor);
            commandControls.CreateDefaultToolTipFor("v_AssignVariables", this, _passParameters);
            RenderedControls.Add(_passParameters);

            RenderedControls.Add(commandControls.CreateDefaultLabelFor("v_VariableAssignments", this));
            RenderedControls.AddRange(commandControls.CreateUIHelpersFor("v_VariableAssignments", this, new Control[] { _assignmentsGridViewHelper }, editor));
            RenderedControls.Add(_assignmentsGridViewHelper);

            return(RenderedControls);
        }
        public override List <Control> Render(IfrmCommandEditor editor, ICommandControls commandControls)
        {
            base.Render(editor, commandControls);

            RenderedControls.AddRange(commandControls.CreateDefaultInputGroupFor("v_InstanceName", this, editor));

            CommandItemControl buildConnectionStringControl = new CommandItemControl("connectionString", Resources.command_database, "Build Connection String");

            buildConnectionStringControl.Click += (sender, e) => BuildConnectionString(sender, e);

            CommandItemControl testConnectionControl = new CommandItemControl("connectionTest", Resources.command_database, "Test Connection");

            testConnectionControl.Click += async(sender, e) => await TestConnection(sender, e, editor);

            _connectionString = commandControls.CreateDefaultInputFor("v_ConnectionString", this);
            RenderedControls.Add(commandControls.CreateDefaultLabelFor("v_ConnectionString", this));
            RenderedControls.Add(buildConnectionStringControl);
            RenderedControls.Add(testConnectionControl);
            RenderedControls.AddRange(commandControls.CreateUIHelpersFor("v_ConnectionString", this, new[] { _connectionString }, editor));
            RenderedControls.Add(_connectionString);

            RenderedControls.AddRange(commandControls.CreateDefaultInputGroupFor("v_ConnectionStringPassword", this, editor));
            RenderedControls.AddRange(commandControls.CreateDefaultDropdownGroupFor("v_TestConnection", this, editor));

            return(RenderedControls);
        }
        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.CreateDefaultInputFor("v_Comment", Command, 100, 300));
            }
        }
Esempio n. 4
0
        public override List <Control> Render(IfrmCommandEditor editor, ICommandControls commandControls)
        {
            base.Render(editor, commandControls);

            //create file path and helpers
            RenderedControls.Add(commandControls.CreateDefaultLabelFor("v_TaskPath", this));
            var taskPathControl = commandControls.CreateDefaultInputFor("v_TaskPath", this);

            RenderedControls.AddRange(commandControls.CreateUIHelpersFor("v_TaskPath", this, new Control[] { taskPathControl }, editor));
            RenderedControls.Add(taskPathControl);
            taskPathControl.TextChanged += TaskPathControl_TextChanged;

            _passParameters           = new CheckBox();
            _passParameters.AutoSize  = true;
            _passParameters.Text      = "Assign Arguments";
            _passParameters.Font      = new Font("Segoe UI Light", 12);
            _passParameters.ForeColor = Color.White;
            _passParameters.DataBindings.Add("Checked", this, "v_AssignArguments", false, DataSourceUpdateMode.OnPropertyChanged);
            _passParameters.CheckedChanged += async(sender, e) => await PassParametersCheckbox_CheckedChanged(sender, e, editor);

            commandControls.CreateDefaultToolTipFor("v_AssignArguments", this, _passParameters);
            RenderedControls.Add(_passParameters);

            RenderedControls.Add(commandControls.CreateDefaultLabelFor("v_ArgumentAssignments", this));
            _assignmentsGridViewHelper = commandControls.CreateDefaultDataGridViewFor("v_ArgumentAssignments", this);
            _assignmentsGridViewHelper.AllowUserToAddRows    = false;
            _assignmentsGridViewHelper.AllowUserToDeleteRows = false;
            //refresh gridview
            _assignmentsGridViewHelper.MouseEnter += async(sender, e) => await PassParametersCheckbox_CheckedChanged(_passParameters, null, editor, true);

            if (!_passParameters.Checked)
            {
                _assignmentsGridViewHelper.Hide();
            }

            RenderedControls.AddRange(commandControls.CreateUIHelpersFor("v_ArgumentAssignments", this, new Control[] { _assignmentsGridViewHelper }, editor));
            RenderedControls.Add(_assignmentsGridViewHelper);

            return(RenderedControls);
        }
Esempio n. 5
0
        public override List <Control> Render(IfrmCommandEditor editor, ICommandControls commandControls)
        {
            base.Render(editor, commandControls);

            RenderedControls.AddRange(commandControls.CreateDefaultInputGroupFor("v_InstanceName", this, editor));

            CommandItemControl helperControl = new CommandItemControl();

            helperControl.Padding        = new Padding(10, 0, 0, 0);
            helperControl.ForeColor      = Color.AliceBlue;
            helperControl.Font           = new Font("Segoe UI Semilight", 10);
            helperControl.Name           = "connection_helper";
            helperControl.CommandImage   = Resources.command_database2;
            helperControl.CommandDisplay = "Build Connection String";
            helperControl.Click         += (sender, e) => Button_Click(sender, e);

            _connectionString = (TextBox)commandControls.CreateDefaultInputFor("v_ConnectionString", this);

            var connectionLabel   = commandControls.CreateDefaultLabelFor("v_ConnectionString", this);
            var connectionHelpers = commandControls.CreateUIHelpersFor("v_ConnectionString", this, new[] { _connectionString }, editor);
            CommandItemControl testConnectionControl = new CommandItemControl();

            testConnectionControl.Padding        = new Padding(10, 0, 0, 0);
            testConnectionControl.ForeColor      = Color.AliceBlue;
            testConnectionControl.Font           = new Font("Segoe UI Semilight", 10);
            testConnectionControl.Name           = "connection_helper";
            testConnectionControl.CommandImage   = Resources.command_database2;
            testConnectionControl.CommandDisplay = "Test Connection";
            testConnectionControl.Click         += (sender, e) => TestConnection(sender, e);

            RenderedControls.Add(connectionLabel);
            RenderedControls.AddRange(connectionHelpers);
            RenderedControls.Add(helperControl);
            RenderedControls.Add(testConnectionControl);
            RenderedControls.Add(_connectionString);

            _connectionStringPassword = (TextBox)commandControls.CreateDefaultInputFor("v_ConnectionStringPassword", this);

            var connectionPassLabel   = commandControls.CreateDefaultLabelFor("v_ConnectionStringPassword", this);
            var connectionPassHelpers = commandControls.CreateUIHelpersFor("v_ConnectionStringPassword", this, new[] { _connectionStringPassword }, editor);

            RenderedControls.Add(connectionPassLabel);
            RenderedControls.AddRange(connectionPassHelpers);

            CommandItemControl passwordHelperControl = new CommandItemControl();

            passwordHelperControl.Padding        = new Padding(10, 0, 0, 0);
            passwordHelperControl.ForeColor      = Color.AliceBlue;
            passwordHelperControl.Font           = new Font("Segoe UI Semilight", 10);
            passwordHelperControl.Name           = "show_pass_helper";
            passwordHelperControl.CommandImage   = Resources.command_password;
            passwordHelperControl.CommandDisplay = "Show Password";
            passwordHelperControl.Click         += (sender, e) => TogglePasswordChar(passwordHelperControl, e);
            RenderedControls.Add(passwordHelperControl);

            CommandItemControl encryptHelperControl = new CommandItemControl();

            encryptHelperControl.Padding        = new Padding(10, 0, 0, 0);
            encryptHelperControl.ForeColor      = Color.AliceBlue;
            encryptHelperControl.Font           = new Font("Segoe UI Semilight", 10);
            encryptHelperControl.Name           = "show_pass_helper";
            encryptHelperControl.CommandImage   = Resources.command_password;
            encryptHelperControl.CommandDisplay = "Encrypt Password";
            encryptHelperControl.Click         += (sender, e) => EncryptPassword(passwordHelperControl, e);
            RenderedControls.Add(encryptHelperControl);

            var label = new Label();

            label.AutoSize  = true;
            label.Font      = new Font("Segoe UI Semilight", 9);
            label.ForeColor = Color.White;
            label.Text      = "NOTE: If storing the password in the textbox below, please ensure the connection string " +
                              "above contains a database-specific placeholder with #pwd to be replaced at runtime. (;Password=#pwd)";
            RenderedControls.Add(label);

            RenderedControls.Add(_connectionStringPassword);
            _connectionStringPassword.PasswordChar = '*';

            RenderedControls.AddRange(commandControls.CreateDefaultDropdownGroupFor("v_TestConnection", this, editor));

            return(RenderedControls);
        }