예제 #1
0
 internal void HandleChangeAcronymAction(CellValueChangedEventArgs eventArgs)
 {
     if (AcronymManager.IsTypeNode(eventArgs.Node))
     {
         _variablesForm.PerformAction(new ChangeAcronymTypeAction(_variablesForm, eventArgs));
     }
     else if (AcronymManager.IsLevelNode(eventArgs.Node))
     {
         _variablesForm.PerformAction(new ChangeAcronymLevelAction(_variablesForm, eventArgs));
     }
     else if (AcronymManager.IsAcronymNode(eventArgs.Node))
     {
         _variablesForm.PerformAction(new ChangeAcronymAction(_variablesForm, eventArgs));
     }
 }
        internal void HandleEndVariableEdit(DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == _variablesForm.dgvVariables.Columns.IndexOf(_variablesForm.colVariableName))
            {
                VarConfig.VariableRow variableRow = _variablesForm.dgvVariables.Rows[e.RowIndex].Tag as VarConfig.VariableRow;
                object val             = _variablesForm.dgvVariables[e.ColumnIndex, e.RowIndex].Value;
                string newVariableName = val == null ? string.Empty : val.ToString();

                if (variableRow.Name == newVariableName)
                {
                    return; //do nothing if not actually changed
                }
                string errorText = string.Empty;
                if (!_varConfigFacade.IsNewRow(variableRow.ID))
                {
                    errorText += "You are changing the name of a variable that might be used in country implementations. Please consider using the 'clean variables' option to check usage.\n\n";
                }

                //set automatic label
                string automaticLabel       = _variablesForm._acronymManager.GetAutomaticLabel(newVariableName);
                int    autoLabelColumnIndex = _variablesForm.dgvVariables.Columns.IndexOf(_variablesForm.colAutomaticLabel);
                _variablesForm.dgvVariables[autoLabelColumnIndex, e.RowIndex].Value = automaticLabel;

                //set whether is categorical or not
                int categColumnIndex = _variablesForm.dgvVariables.Columns.IndexOf(_variablesForm.colCategorical);
                var bkupIsCateg      = _variablesForm.dgvVariables[categColumnIndex, e.RowIndex].Value;
                _variablesForm.dgvVariables[categColumnIndex, e.RowIndex].Value = IsCateg(newVariableName);

                //check if valid
                errorText += IsValidVariableName(newVariableName, automaticLabel, e.RowIndex);
                if (errorText != string.Empty)
                {
                    if (Tools.UserInfoHandler.GetInfo(errorText + "Undo change?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        _variablesForm.dgvVariables[e.ColumnIndex, e.RowIndex].Value        = variableRow.Name;
                        _variablesForm.dgvVariables[categColumnIndex, e.RowIndex].Value     = bkupIsCateg;
                        _variablesForm.dgvVariables[autoLabelColumnIndex, e.RowIndex].Value = variableRow.AutoLabel;
                    }
                }
            }

            //write to dataset
            _variablesForm.PerformAction(new ChangeVariableAction(_variablesForm, e));
        }