public ConnectionFailedLogic(Widget widget, OrderManager orderManager, Action onAbort, Action<string> onRetry) { var panel = widget; var abortButton = panel.Get<ButtonWidget>("ABORT_BUTTON"); var retryButton = panel.Get<ButtonWidget>("RETRY_BUTTON"); abortButton.Visible = onAbort != null; abortButton.OnClick = () => { Ui.CloseWindow(); onAbort(); }; retryButton.Visible = onRetry != null; retryButton.OnClick = () => { var password = passwordField != null && passwordField.IsVisible() ? passwordField.Text : orderManager.Password; Ui.CloseWindow(); onRetry(password); }; widget.Get<LabelWidget>("CONNECTING_DESC").GetText = () => "Could not connect to {0}:{1}".F(orderManager.Host, orderManager.Port); var connectionError = widget.Get<LabelWidget>("CONNECTION_ERROR"); connectionError.GetText = () => orderManager.ServerError; passwordField = panel.GetOrNull<PasswordFieldWidget>("PASSWORD"); if (passwordField != null) { passwordField.Text = orderManager.Password; passwordField.IsVisible = () => orderManager.AuthenticationFailed; var passwordLabel = widget.Get<LabelWidget>("PASSWORD_LABEL"); passwordLabel.IsVisible = passwordField.IsVisible; passwordField.OnEnterKey = () => { retryButton.OnClick(); return true; }; passwordField.OnEscKey = () => { abortButton.OnClick(); return true; }; } passwordOffsetAdjusted = false; var connectionFailedTicker = panel.GetOrNull<LogicTickerWidget>("CONNECTION_FAILED_TICKER"); if (connectionFailedTicker != null) { connectionFailedTicker.OnTick = () => { // Adjust the dialog once the AuthenticationError is parsed. if (passwordField.IsVisible() && !passwordOffsetAdjusted) { var offset = passwordField.Bounds.Y - connectionError.Bounds.Y; abortButton.Bounds.Y += offset; retryButton.Bounds.Y += offset; panel.Bounds.Height += offset; panel.Bounds.Y -= offset / 2; var background = panel.GetOrNull("CONNECTION_BACKGROUND"); if (background != null) background.Bounds.Height += offset; passwordOffsetAdjusted = true; } }; } }
protected PasswordFieldWidget(PasswordFieldWidget widget) : base(widget) { base.PasswordChar = PasswordChar; }
protected PasswordFieldWidget(PasswordFieldWidget widget) : base(widget) { }