Exemplo n.º 1
0
    private void Create()
    {
        StylesheetForm form = new StylesheetForm();

        form.Icon = PerformanceTestTool.Properties.Resources.page_add;
        DialogResult result = form.ShowDialog();

        if (result.ToString() == "OK")
        {
            Application.DoEvents();
            Stylesheet newItem = form.GetValue();

            int insertNewRowAt = 0;

            if (dataGridView1.SelectedRows.Count > 0)
            {
                insertNewRowAt = dataGridView1.SelectedRows[0].Index;
                insertNewRowAt++;
            }

            CreateNewItem(newItem, insertNewRowAt);

            FillStepColumn();
            PopulateSearchList();
            UpdateStylesheetsTextBox();

            dataGridView1.FirstDisplayedScrollingRowIndex = insertNewRowAt;
            dataGridView1.CurrentCell = dataGridView1["StylesheetName", insertNewRowAt];
            dataGridView1.Rows[insertNewRowAt].Selected = true;

            SetChangesMade(true);
        }

        dataGridView1.Focus();
    }
Exemplo n.º 2
0
    private void Edit()
    {
        List <Stylesheet> newItems = StylesheetHelper.StylesheetCollection.Stylesheets;

        bool save = false;

        foreach (Stylesheet item in newItems)
        {
            if (dataGridView1.SelectedRows[0].Cells["StylesheetName"].Value.ToString() == item.Name)
            {
                StylesheetForm form = new StylesheetForm(item);
                form.Icon = PerformanceTestTool.Properties.Resources.page_edit;
                DialogResult result = form.ShowDialog();

                if (result.ToString() == "OK")
                {
                    Application.DoEvents();

                    Stylesheet newItem = form.GetValue();
                    item.Name         = newItem.Name;
                    item.Description  = newItem.Description;
                    item.Xslt         = newItem.Xslt;
                    item.Enabled      = newItem.Enabled;
                    item.OutputFormat = newItem.OutputFormat;

                    dataGridView1.SelectedRows[0].Cells["StylesheetName"].Value       = newItem.Name;
                    dataGridView1.SelectedRows[0].Cells["StylesheetName"].ToolTipText = newItem.Description;
                    dataGridView1.SelectedRows[0].Cells["OutputFormat"].Value         = newItem.OutputFormat;

                    if (!newItem.Enabled)
                    {
                        dataGridView1.SelectedRows[0].DefaultCellStyle.ForeColor          = Color.Gray;
                        dataGridView1.SelectedRows[0].DefaultCellStyle.SelectionForeColor = Color.Gray;
                    }
                    else
                    {
                        dataGridView1.SelectedRows[0].DefaultCellStyle.ForeColor          = SystemColors.WindowText;
                        dataGridView1.SelectedRows[0].DefaultCellStyle.SelectionForeColor = SystemColors.HighlightText;
                    }

                    save = true;
                }

                break;
            }
        }

        if (save)
        {
            StylesheetHelper.StylesheetCollection.Stylesheets = newItems;
            FillStepColumn();
            PopulateSearchList();
            UpdateStylesheetsTextBox();
            SetChangesMade(true);
        }

        dataGridView1.Focus();
    }