public void Init(ActionsManager actionsManager, string creator, IValueHelper<string> connectionStringValueHelper) { System.Diagnostics.Debug.Assert( Creator == null, "Init() should be called only once!" ); Creator = creator; ActionsManager = actionsManager; IsConnectionOkHelper = new ValueHelper<bool>{ Value = false }; ConnectionString_ValueChangedActionDelayer = new ActionHelper(); bool hadInitialConnectionString; if( string.IsNullOrEmpty(connectionStringValueHelper.Value) ) { // Fill control with initial values connectionStringValueHelper.Value = ConnectionStringHelper.SampleConnectionString; hadInitialConnectionString = false; } else { hadInitialConnectionString = true; } ConnectionStringHelper = new Utils.Event.ConnectionStringHelper( connectionStringValueHelper ); // Link Show Password CheckBox cbShowPassword.Checked += ES.Routed( cbShowPassword_Changed ); cbShowPassword.Unchecked += ES.Routed( cbShowPassword_Changed ); cbShowPassword_Changed(); // Link TextBoxes to ConnectionStringHelper txtServer.Text = Server; ConnectionStringHelper.ServerHelper.ValueChanged += ()=>{ txtServer.Text = Server; }; txtServer.TextChanged += ES.TextChanged( ()=>{ Server = txtServer.Text; } ); txtDatabase.Text = Database; ConnectionStringHelper.DatabaseHelper.ValueChanged += ()=>{ txtDatabase.Text = Database; }; txtDatabase.TextChanged += ES.TextChanged( ()=>{ Database = txtDatabase.Text; } ); txtUser.Text = User; ConnectionStringHelper.UserHelper.ValueChanged += ()=>{ txtUser.Text = User; }; txtUser.TextChanged += ES.TextChanged( ()=>{ User = txtUser.Text; } ); txtPasswordClear.Text = txtPasswordHidden.Password = txtPasswordConfirm.Password = Password; ConnectionStringHelper.PasswordHelper.ValueChanged += ()=> { var password = Password; txtPasswordClear.Text = password; if( txtPasswordHidden.Password != password ) txtPasswordHidden.Password = password; if( txtPasswordConfirm.Password != password ) txtPasswordConfirm.Password = password; }; txtPasswordClear.TextChanged += (sender,e)=>{ Password = txtPasswordClear.Text; }; txtPasswordHidden.PasswordChanged += ES.Routed( txtPasswordHiddenConfirm_PasswordChanged ); txtPasswordConfirm.PasswordChanged += ES.Routed( txtPasswordHiddenConfirm_PasswordChanged ); // Monitor ConnectionString changes txtConnectionString.Text = ConnectionStringHelper.GetConnectionStringWithoutPassword( PasswordHideString ); ConnectionString_ValueChangedActionDelayer.Action = ConnectionString_ValueChangedDelayed; ConnectionStringHelper.ValueHelper.ValueChanged += ConnectionString_ValueChanged; if( hadInitialConnectionString ) // Try connection right now if a ConnectionString is already available ConnectionString_ValueChangedActionDelayer.Trigger(); // Set delay on the ConnectionString's ActionHelper ConnectionString_ValueChangedActionDelayer.DelaySeconds = 1; }
public NoDelayHolder(ActionHelper helper) { ActionHelper = helper; OriginalDelaySecons = helper.DelaySeconds; helper.DelaySeconds = 0; }