예제 #1
0
 public override void EventFired(object sender, Event e)
 {
     if (e is StartTextInputEvent start)
     {
         Display               = start.InitialValue;
         CaretIndex            = start.InitialValue.Length;
         CaretBlinkingProgress = 0;
         Callback              = start.Callback;
         Label = start.Label;
     }
     else if (e is ModalChangeEvent change)
     {
         ShouldClose = false;
         if (change.From != "text_input")
         {
             SwitchTo = change.From;
         }
         SwitchButton(Pad[0]);
         ModalActive = true;
     }
     else if (e is BeginModalChangeEvent bmce)
     {
         bmce.SystemName = SwitchTo;
         ModalActive     = false;
     }
 }
예제 #2
0
        private async Task HandleSubmitAsync()
        {
            Debug.Assert(_fixedEditContext != null);

            if (OnSubmit.HasDelegate)
            {
                // When using OnSubmit, the developer takes control of the validation lifecycle
                await OnSubmit.InvokeAsync(_fixedEditContext);
            }
            else
            {
                // Otherwise, the system implicitly runs validation on form submission
                var isValid = _fixedEditContext.Validate(); // This will likely become ValidateAsync later

                if (isValid && OnValidSubmit.HasDelegate)
                {
                    await OnValidSubmit.InvokeAsync(_fixedEditContext);
                }

                if (!isValid && OnInvalidSubmit.HasDelegate)
                {
                    await OnInvalidSubmit.InvokeAsync(_fixedEditContext);
                }
            }
        }
예제 #3
0
 public override void EventFired(object sender, Event e)
 {
     if (e is StartNumberInputEvent start)
     {
         Display           = start.InitialValue.ToString();
         Callback          = start.Callback;
         DotButton.Enabled = start.AllowDecimals;
         Label             = start.Label;
     }
     else if (e is ModalChangeEvent change)
     {
         //Console.WriteLine("changed from " + change.From);
         ShouldClose = false;
         if (change.From != "number_input")
         {
             SwitchTo = change.From;
         }
         SwitchButton(Pad[0]);
         ModalActive = true;
     }
     else if (e is BeginModalChangeEvent bmce)
     {
         bmce.SystemName = SwitchTo;
         ModalActive     = false;
     }
 }
예제 #4
0
        private async Task HandleSubmitAsync()
        {
            if (OnSubmit is object)
            {
                // When using OnSubmit, the developer takes control of the validation lifecycle
                var submitSuccess = await OnSubmit.Invoke(_fixedEditContext);

                if (submitSuccess)
                {
                    await _jsRuntime.InvokeVoidAsync("localStorage.removeItem", Id);
                }
            }
            else
            {
                // Otherwise, the system implicitly runs validation on form submission
                var isValid = _fixedEditContext.Validate(); // This will likely become ValidateAsync later

                if (isValid && OnValidSubmit.HasDelegate)
                {
                    await OnValidSubmit.InvokeAsync(_fixedEditContext);

                    // Clear saved form model from local storage
                    await _jsRuntime.InvokeVoidAsync("localStorage.removeItem", Id);
                }

                if (!isValid && OnInvalidSubmit.HasDelegate)
                {
                    await OnInvalidSubmit.InvokeAsync(_fixedEditContext);
                }
            }
        }
예제 #5
0
        private async Task HandleSubmitAsync()
        {
            if (OnSubmit.HasDelegate)
            {
                await OnSubmit.InvokeAsync(_fixedEditContext);
            }
            else
            {
                var isValid = _fixedEditContext.Validate();

                if (isValid)
                {
                    if (OnValidSubmit.HasDelegate)
                    {
                        await OnValidSubmit.InvokeAsync(_fixedEditContext);
                    }
                    else
                    {
                        await HandleValidSubmit();
                    }
                }

                if (!isValid && OnInvalidSubmit.HasDelegate)
                {
                    await OnInvalidSubmit.InvokeAsync(_fixedEditContext);
                }
            }
        }
예제 #6
0
 void Submit(string text)
 {
     submitting = true;
     if (OnSubmit != null)
     {
         OnSubmit.Invoke(text, model);
     }
 }
예제 #7
0
        private void Setup()
        {
            TextField streamIDText = this.Q <TextField>("StreamIDText");
            Button    submitButton = this.Q <Button>("SubmitButton");
            Button    logoutButton = this.Q <Button>("LogoutButton");

            submitButton.RegisterCallback <ClickEvent>(ev => OnSubmit.Invoke(streamIDText.text));
            logoutButton.RegisterCallback <ClickEvent>(ev => LogoutEvent.Invoke());
        }
예제 #8
0
 public InputDialog(string text, string defValue, OnSubmit onSubmit = null)
 {
     InitializeComponent();
     this.label1.Text   = text;
     this.textBox1.Text = defValue;
     this.onSubmit      = onSubmit;
     this.ActiveControl = this.textBox1;
     this.ShowDialog();
 }
        public EditPartyViewModel(Unit[] units, UserParty party = null)
        {
            m_UnitsCollection      = new ObservableCollection <Unit>(units);
            UnitList               = m_UnitsCollection.ToReadOnlyReactiveCollection(x => new UnitViewModel(x));
            m_PartyUnitsCollection = new ObservableCollection <UserUnit>();
            PartyUnits             = m_PartyUnitsCollection.ToReadOnlyReactiveCollection(x => new UserUnitViewModel(x, () => UnselectUserUnit(x)));

            OnCancel.Subscribe(x => CloseWindow((Window)x));
            OnSubmit.Subscribe(x => SaveParty((Window)x));

            OnSearchTextChanged.Subscribe(() => { SearchUnit(SearchText.Value); });

            ShowUnitType.Subscribe(OnChangeShowUnitType);
            OnChangeSelected.Subscribe(OnChangeSelectedUnit);

            OnAddTag.Subscribe(() =>
            {
                var window = new AddTagWindow(tag =>
                {
                    Tags.Add(new TagViewModel(tag, OnRemoveTag));
                });
                window.ShowDialog();
            });

            if (party != null)
            {
                m_Party     = party;
                m_PartUnits = party.UserUnits.ToList();
                foreach (var unitViewModel in UnitList)
                {
                    if (m_PartUnits.Any(x => x.UnitId == unitViewModel.Unit.Id))
                    {
                        unitViewModel.SetSelect(true);
                    }
                }
                m_PartyUnitsCollection.Clear();
                foreach (var unit in m_PartUnits)
                {
                    m_PartyUnitsCollection.Add(unit);
                }

                IsFullParty.Value       = true;
                IsVisibleSelected.Value = Visibility.Visible;
                PartyComment.Value      = party.Comment;
                EstimateDamage.Value    = party.EstimateDamage;

                Tags.Clear();
                if (party.Tags?.Length > 0)
                {
                    var vms = party.Tags
                              .Select(x => Database.I.Tags.SingleOrDefault(db => db.Id == x))
                              .Select(x => new TagViewModel(x, OnRemoveTag));
                    Tags.AddRange(vms);
                }
            }
        }
예제 #10
0
        public async void OnFinishClicked()
        {
            if (FreezeCurrentStep)
            {
                return;
            }

            await OnSubmit.InvokeAsync(new SubmitEventArgs());

            StateHasChanged();
        }
예제 #11
0
        void Submit()
        {
            if (!validator(inputField.text))
            {
                invalidCallback(inputField.text);
                return;
            }

            OnSubmit?.Invoke(inputField.text);
            Close();
        }
        private async Task SetNextAnswer()
        {
            CurrentAnswer = Answers.FirstOrDefault(x => !x.IsAnswered);
            await Storage.SetAsync($"{PlayerId}-Answers", Answers);

            if (CurrentAnswer is null)
            {
                await OnSubmit.InvokeAsync(Answers);

                await Storage.DeleteAsync($"{PlayerId}-Answers");
            }
        }
        private void SubmitPersonalPin()
        {
            Commands cmd = new Backend.Commands();
            var      pinVerificationResult = cmd.SetPin(PersonalPin);

            PersonalPin             = null;
            PersonalPinErrorMessage = null;
            if (pinVerificationResult == 1)
            {
                HIOStaticValues.tmain.IsPinRequired = false;
                ShowResetPersonalPin = false;
                if (SetupWizard != null)
                {
                    SetupWizard.MoveNextPage();
                }
                OnSubmit?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                HIOStaticValues.tmain.IsPinRequired = true;
                PersonalPinErrorMessage             = "Wrong pincode";
                switch (pinVerificationResult)
                {
                case 0:
                    PinLockEnd = null;
                    break;

                case -1:
                    PinLockEnd = DateTime.Now.AddMinutes(1);
                    break;

                case -2:
                    PinLockEnd = DateTime.Now.AddMinutes(5);
                    break;

                case -3:
                    PinLockEnd = DateTime.Now.AddMinutes(10);
                    break;

                case -4:
                    PinLockEnd = DateTime.Now.AddHours(1);
                    break;

                default:
                    PersonalPinErrorMessage = null;
                    SetPersonalPinFooterErrorMessage("Something went wrong!");
                    HIOStaticValues.PinInputDashboardVM?.OnPropertyChanged(nameof(PersonalPinFooterErrorMessage));
                    HIOStaticValues.PinInputExtensionVM?.OnPropertyChanged(nameof(PersonalPinFooterErrorMessage));
                    PinLockEnd = null;
                    break;
                }
            }
        }
        protected async Task HandleSubmit(EventArgs args)
        {
            Form.Validate();

            if (Form.Valid)
            {
                await OnSubmit.InvokeAsync(Form.Values);
            }
            else
            {
                await OnError.InvokeAsync(Form.Error);
            }
        }
        private void Setup()
        {
            TextField inputServer   = this.Q <TextField>("InputServer");
            TextField inputEmail    = this.Q <TextField>("InputEmail");
            TextField inputPassword = this.Q <TextField>("InputPassword");
            Button    buttonSubmit  = this.Q <Button>("ButtonSubmit");

            labelError      = this.Q <Label>("LabelError");
            labelError.text = string.Empty;

            buttonSubmit.RegisterCallback <ClickEvent>(ev => {
                this.SetEnabled(false);
                OnSubmit.Invoke(inputServer.text, inputEmail.text, inputPassword.text, (s) => this.SetEnabled(!s));
            });
        }
예제 #16
0
 public override void Click()
 {
     if (Menu.StaticIsOverButton(submitButton) || EnterPressed)
     {
         if (Value != DefaultValue && !IsDisabled)
         {
             menuArgs = new MenuEventArgs(Value);
             OnSubmit?.Invoke(this, menuArgs);
         }
         EnterPressed = false;
     }
     else
     {
         base.Click();
     }
 }
        protected async void HandleValidSubmitModal()
        {
            ApiResultModel <Warehouse_Area> response = await _api.Post($"inventory/Warehouse/CheckArea", ModelData);

            if (response.Status == 200)
            {
                await OnSubmit.InvokeAsync(ModelData);
            }
            else
            {
                if (formValidator != null && response.Errors != null && response.Errors.Count > 0)
                {
                    formValidator.DisplayErrors(response.Errors);
                }
                _toastService.ShowWarning(response.Message, "Failed");
            }
        }
예제 #18
0
        private void CallDirectEventSubscribers(Event evt)
        {
            switch (evt.Type)
            {
            case "submit":
                if (OnSubmit?.Invoke(evt) != false && !evt.IsDefaultPrevented())
                {
                    Document.HandleFormSubmit(evt.Target as HtmlFormElement, evt.OriginalTarget as HtmlElement);
                }
                break;

            case "click":
                if (OnClick?.Invoke(evt) != false &&
                    !evt.IsDefaultPrevented() &&
                    evt.Target is HtmlButtonElement button &&
                    button.Type == "submit")
                {
                    button.Form?.RaiseSubmit(evt.Target as HtmlElement);
                }
                break;
            }
        }
예제 #19
0
 public override void EventFired(object sender, Event e)
 {
     if (e is BeginModalChangeEvent bmce)
     {
         bmce.SystemName = SwitchTo;
         ModalActive     = false;
     }
     else if (e is ModalChangeEvent change)
     {
         if (change.From != "enum_select")
         {
             SwitchTo = change.From;
         }
         ModalActive = true;
     }
     else if (e is StartEnumSelectEvent start)
     {
         Title    = start.Title;
         Options  = start.Options;
         Callback = start.Callback;
     }
 }
예제 #20
0
        private void Submit()
        {
            OnSubmit?.Invoke(this, new IpcInteractionEventArgs(this));
            var json = JsonConvert.SerializeObject(outgoingMessage);

            encoder.Send(json);
            awaitingResponseToSubmittedMessage = true;
            IpcManager.PrepareToReceiveMessage((sender, args) => {
                receivedMessage = args.message;
                if (receivedMessage != null)
                {
                    UnityEngine.Debug.Log("Got response to originating message");
                }
                var evtArgs = new IpcInteractionEventArgs(this);
                UnityEngine.Debug.Log(json);
                OnResolution += (s, e) =>
                {
                    awaitingResponseToSubmittedMessage = false;
                    IpcChannel.Semaphore.Release();
                };
                OnResolution.Invoke(this, evtArgs);
            });
        }
예제 #21
0
        private void textBox_InputAmount_KeyPress(object sender, KeyPressEventArgs e)
        {
            var eKeyChar = e.KeyChar;

            if (!char.IsDigit(eKeyChar) && !char.IsControl(eKeyChar))
            {
                e.Handled = true;
            }
            if (char.IsControl(eKeyChar) && eKeyChar != '\b')
            {
                e.Handled = true;
            }

            if (!char.IsControl(eKeyChar) || eKeyChar != '\r')
            {
                return;
            }

            e.Handled = true;
            OnSubmit?.Invoke(textBox_InputAmount.Text);
            _isSubmitted = true;
            Close();
        }
예제 #22
0
        public ChatInputComponent(
            ComponentGroup componentGroup,
            Vector2 position,
            Vector2 size,
            int fontSize
            ) : base(
                componentGroup,
                position,
                size,
                "",
                "",
                TextureManager.InputFieldBg,
                FontManager.UIFontRegular,
                fontSize
                )
        {
            Text.alignment = TextAnchor.MiddleLeft;

            InputField.characterLimit   = ChatMessage.MaxMessageLength;
            InputField.onValidateInput += (text, index, addedChar) => {
                if (!WhitelistedChars.Contains(addedChar))
                {
                    return('\0');
                }

                return(addedChar);
            };

            MonoBehaviourUtil.Instance.OnUpdateEvent += () => {
                if (Input.GetKeyDown(KeyCode.Return))
                {
                    OnSubmit?.Invoke(InputField.text);

                    InputField.text = "";
                }
            };
        }
예제 #23
0
 public StartTextInputEvent(string initialValue, OnSubmit callback, Component sender) : base(sender)
 {
     InitialValue = initialValue;
     Callback     = callback;
 }
예제 #24
0
 public StartEnumSelectEvent(string title, List <String> options, OnSubmit callback, Component sender) : base(sender)
 {
     Title    = title;
     Options  = options;
     Callback = callback;
 }
예제 #25
0
 private void HandleSearch()
 {
     OnSubmit.InvokeAsync();
 }
예제 #26
0
 private void OnInputSubmit(InputAction.CallbackContext context)
 {
     OnSubmit?.Invoke();
 }
예제 #27
0
 protected void SendOnSubmit()
 {
     OnSubmit?.Invoke();
 }
예제 #28
0
 protected void DoOnSubmit()
 {
     OnSubmit?.Invoke(this);
 }
예제 #29
0
 public StartNumberInputEvent(double initialValue, OnSubmit callback, bool allowDecimals, Component sender) : base(sender)
 {
     InitialValue  = initialValue;
     Callback      = callback;
     AllowDecimals = allowDecimals;
 }
예제 #30
0
 public StartNumberInputEvent(double initialValue, OnSubmit callback, Component sender) : this(initialValue, callback, true, sender)
 {
 }