public FrmEditEnvVar(ref EnvironmentSnapshot snapshot, EnvironmentVariable variable) { InitializeComponent(); this.snapshot = snapshot; this.variable = variable; this.MinimumSize = new Size(327, 439); dgvValuesList.TabIndex = 0; LoadSettings(); txtVariableName.CausesValidation = false; dgvHandler = new DgvHandler(ref dgvValuesList); // set default icon dgvValuesList_UserAddedRow(null, null); this.txtVariableName.Text = variable.Name; this.validator = new EnvironmentValueValidator(); if (txtVariableName.Text.Length != 0) { // Check if we are editing variable LoadEnvironmentVariableValues(); } // Set form title this.Text = (txtVariableName.Text.Length != 0 ? "Edit" : "New") + " " + (this.snapshot.Target == EnvironmentVariableTarget.Machine ? "System" : "User") + " Variable"; #region Create DgvHandler Commands commandsList = new CommandStack(); dgvHandler.SetCurrentCell(0); editVarNameCommand = new EditVarNameCommand(txtVariableName); #endregion DgvHandler Commands // disable buttons SetBtnState(); txtVariableName.CausesValidation = true; isVarNameChanged = false; // Open/Save File dialogs openFileDialog.Filter = FILE_FILTER; openFileDialog.DefaultExt = DEFAULT_FILTER_EXTENSION; saveFileDialog.Filter = FILE_FILTER; saveFileDialog.DefaultExt = DEFAULT_FILTER_EXTENSION; if (EnvironmentVariableManager.IsElevated) { btnSave.Image = Resources.Save; } else { btnSave.Image = Resources.shield_uac; } }
public FrmEditEnvVar(string variableName, EnvironmentVariableTarget variableType) { InitializeComponent(); this.MinimumSize = new Size(327, 439); dgvValuesList.TabIndex = 0; LoadSettings(); txtVariableName.CausesValidation = false; dgvHandler = new DgvHandler(ref dgvValuesList); // set default icon dgvValuesList_UserAddedRow(null, null); this.txtVariableName.Text = variableName; // remember current name this.variableName = variableName; this.variableType = variableType; validator = new EnvVarValueValidator(); if (txtVariableName.Text.Length != 0) { // Check if we are editing variable LoadEnvironmentVariableValues(); } // Set form title this.Text = (txtVariableName.Text.Length != 0 ? "Edit" : "New") + " " + (this.variableType == EnvironmentVariableTarget.Machine ? "System" : "User") + " Variable"; #region Create DgvHandler Commands commandsList = new UndoRedoCommandList(); dgvHandler.SetCurrentCell(0); editVarNameCommand = new EditVarNameCommand(txtVariableName); #endregion DgvHandler Commands // disable buttons SetBtnState(); txtVariableName.CausesValidation = true; isVarNameChanged = false; // Open/Save File dialogs openFileDialog.Filter = FILE_FILTER; openFileDialog.DefaultExt = DEFAULT_FILTER_EXTENSION; saveFileDialog.Filter = FILE_FILTER; saveFileDialog.DefaultExt = DEFAULT_FILTER_EXTENSION; }