private void AddComputerButtonOnClick(object sender, EventArgs eventArgs) { var dialogBuilder = new MaterialDialog.Builder(this) .Title(Resource.String.app_addcomputer_title) .CustomView(Resource.Layout.dialog_addcomputer, true) .PositiveText(Resource.String.app_addcomputer_connect) .NegativeText(Resource.String.app_addcomputer_cancel) .OnPositive((dialog, w) => { IpAddresses.Add(new ComputerModel( dialog.CustomView.FindViewById <EditText>(Resource.Id.ipAddress).Text, dialog.CustomView.FindViewById <EditText>(Resource.Id.password).Text)); BlobCache.UserAccount.InsertObject("ipaddresses", IpAddresses); }).Build(); var positiveAction = dialogBuilder.GetActionButton(DialogAction.Positive); var ipControl = dialogBuilder.CustomView.FindViewById <EditText>(Resource.Id.ipAddress); var token = new CancellationTokenSource(); positiveAction.Enabled = false; ipControl.TextChanged += (o, args) => { token.Cancel(); token = new CancellationTokenSource(); if (ValidateIPv4(ipControl.Text) && IpAddresses.All(i => i.Ip != ipControl.Text)) { Task.Factory.StartNew( async() => positiveAction.Enabled = await Scanner.CheckHostForVlc(ipControl.Text), token.Token); } else { positiveAction.Enabled = false; } }; dialogBuilder.Show(); }
public void ShowCustomView(object sender, EventArgs e) { MaterialDialog dialog = new MaterialDialog.Builder(this) .Title(Resource.String.googleWifi) .CustomView(Resource.Layout.dialog_customview, true) .PositiveText(Resource.String.connect) .NegativeText(Android.Resource.String.Cancel) .OnPositive((dialog1, which) => ShowToast("Password: " + _passwordInput.Text)) .Build(); _positiveAction = dialog.GetActionButton(DialogAction.Positive); _passwordInput = dialog.CustomView.FindViewById <EditText>(Resource.Id.password); _passwordInput.TextChanged += (s, ev) => { _positiveAction.Enabled = String.Concat(ev.Text.Select(c => c.ToString())).Trim().Length > 0; }; CheckBox checkbox = dialog.CustomView.FindViewById <CheckBox>(Resource.Id.showPassword); checkbox.CheckedChange += (s, ev) => { _passwordInput.InputType = (!ev.IsChecked) ? InputTypes.TextVariationPassword : InputTypes.ClassText; _passwordInput.TransformationMethod = (!ev.IsChecked) ? PasswordTransformationMethod.Instance : null; }; int widgetColor = ThemeSingleton.Get().WidgetColor; MDTintHelper.SetTint(checkbox, widgetColor == 0 ? ContextCompat.GetColor(this, Resource.Color.accent) : widgetColor); MDTintHelper.SetTint(_passwordInput, widgetColor == 0 ? ContextCompat.GetColor(this, Resource.Color.accent) : widgetColor); dialog.Show(); _positiveAction.Enabled = false; }