Exemplo n.º 1
0
        private void parametersGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            int rowIndex = e.RowIndex,
                columnIndex = e.ColumnIndex;

            if (rowIndex >= 0 && columnIndex >= 0)
            {
                var row = parametersGridView.Rows[rowIndex];
                ServiceParameter parameter = row.Tag as ServiceParameter;

                if (parameter is ServiceParameterNumber)
                {
                    using (var f = new EditServiceParameterNumberForm(null, parameter.Id))
                    {
                        f.Saved += (s, eventArgs) =>
                        {
                            RenderParametersGridViewRow(row, f.ServiceParameterNumber);
                            f.Close();
                        };

                        f.ShowDialog();
                    }
                }
                else if (parameter is ServiceParameterText)
                {
                    using (var f = new EditServiceParameterTextForm(null, parameter.Id))
                    {
                        f.Saved += (s, eventArgs) =>
                        {
                            RenderParametersGridViewRow(row, f.ServiceParameterText);
                            f.Close();
                        };

                        f.ShowDialog();
                    }
                }
                else if (parameter is ServiceParameterOptions)
                {
                    using (var f = new EditServiceParameterOptionsForm(null, parameter.Id))
                    {
                        f.Saved += (s, eventArgs) =>
                        {
                            RenderParametersGridViewRow(row, f.ServiceParameterOptions);
                            f.Close();
                        };

                        f.ShowDialog();
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void addButton_Click(object sender, EventArgs e)
        {
            DataGridViewRow row = null;

            switch (parameterTypeControl.Selected<ServiceParameterType>())
            {
                case ServiceParameterType.Number:
                    using (var f = new EditServiceParameterNumberForm(service.Id))
                    {
                        f.Saved += (s, eventArgs) =>
                        {
                            if (row == null)
                            {
                                row = parametersGridView.Rows[parametersGridView.Rows.Add()];
                            }
                            RenderParametersGridViewRow(row, f.ServiceParameterNumber);
                            f.Close();
                        };

                        f.ShowDialog();
                    }
                    break;

                case ServiceParameterType.Text:
                    using (var f = new EditServiceParameterTextForm(service.Id))
                    {
                        f.Saved += (s, eventArgs) =>
                        {
                            if (row == null)
                            {
                                row = parametersGridView.Rows[parametersGridView.Rows.Add()];
                            }
                            RenderParametersGridViewRow(row, f.ServiceParameterText);
                            f.Close();
                        };

                        f.ShowDialog();
                    }
                    break;

                case ServiceParameterType.Options:
                    using (var f = new EditServiceParameterOptionsForm(service.Id))
                    {
                        f.Saved += (s, eventArgs) =>
                        {
                            if (row == null)
                            {
                                row = parametersGridView.Rows[parametersGridView.Rows.Add()];
                            }
                            RenderParametersGridViewRow(row, f.ServiceParameterOptions);
                            f.Close();
                        };

                        f.ShowDialog();
                    }
                    break;
            }
        }