Ejemplo n.º 1
0
        /// <summary>
        ///     Gets the currently set task sequence variables and populates the user interface.
        /// </summary>
        private void VariablesDictionaryViewUpdate()
        {
            //_UpdateDictionaryListView();
            dgvTaskSequenceVariables.Rows.Clear();
            dgvTaskSequenceVariables.Rows.AddRange(
                _taskSequenceDictionary.OrderBy(kvp => kvp.Key).Select(
                    kvp =>
            {
                var row = new DataGridViewRow();

                if (string.IsNullOrEmpty(kvp.Key) || !TaskSequence.IsPasswordVariable(kvp.Key))
                {
                    row.CreateCells(dgvTaskSequenceVariables, kvp.Key, kvp.Value);
                }
                else
                {
                    row.CreateCells(dgvTaskSequenceVariables, kvp.Key, @"******** (Password removed)");
                }

                // Make readonly variables readonly rows
                if (!_taskSequenceVariablesAllowEdit || kvp.Key.StartsWith("_"))
                {
                    row.ReadOnly         = true;
                    row.DefaultCellStyle = _rowStyleReadOnly;
                }

                return(row);
            }).ToArray());

            // Scroll to the first non-readonly variable
            foreach (DataGridViewRow row in dgvTaskSequenceVariables.Rows)
            {
                if (row.Cells[0].Value != null && row.Cells[0].Value.ToString().StartsWith("_") == false)
                {
                    int rowIndex = row.Index;
                    dgvTaskSequenceVariables.CurrentCell = dgvTaskSequenceVariables.Rows[rowIndex].Cells[0];
                    break;
                }
            }
        }