public NewOrEditVariableDialog(AutomationVariable variable) { InitializeComponent(); variableTypeComboBox.Items.Add(Constants.VariableType.String); variableTypeComboBox.Items.Add(Constants.VariableType.Number); variableTypeComboBox.SelectedValue = Constants.VariableType.String; variableEncryptedComboBox.Items.Add(Constants.EncryptedState.PlainText); variableEncryptedComboBox.Items.Add(Constants.EncryptedState.Encrypted); variableEncryptedComboBox.SelectedValue = Constants.EncryptedState.PlainText; if (variable != null) { if (variable.Encrypted) { if (variable.getValue() != null) { encryptedValueTextbox.Password = variable.getValue().ToString(); } variableEncryptedComboBox.SelectedValue = Constants.EncryptedState.Encrypted; } else { valueTextbox.Text = variable.getValue().ToString(); variableEncryptedComboBox.SelectedValue = Constants.EncryptedState.PlainText; } if (variable.getValue() is String) { variableTypeComboBox.SelectedValue = Constants.VariableType.String; } else if (IsNumber(variable.getValue())) { variableTypeComboBox.SelectedValue = Constants.VariableType.Number; } initialized = true; setEncrypted(variable.Encrypted); // don't allow user to change encrypted status of an existing variable asset variableEncryptedComboBox.IsEnabled = false; variableEncryptedComboBox.IsEditable = false; variableEncryptedComboBox.IsHitTestVisible = false; variableEncryptedComboBox.Focusable = false; this.Title = "Edit Variable Asset"; } else { initialized = true; this.Title = "New Variable Asset"; } }
private void createOrUpdateVariableAsset(string variableAssetName, AutomationVariable variableToEdit) { var dialog = new NewOrEditVariableDialog(variableToEdit); if (dialog.ShowDialog() == true) { var assetsToSave = new List <AutomationAsset>(); var newVariable = new AutomationVariable(variableAssetName, dialog.value, dialog.encrypted); assetsToSave.Add(newVariable); AutomationAssetManager.SaveLocally(iseClient.currWorkspace, assetsToSave, getEncryptionCertificateThumbprint()); refreshAssets(); } }