Ejemplo n.º 1
0
        protected void OnChangeHandler(UIChangeEventArgs ev)
        {
            if (this.checkboxGroup != null)
            {
                this.checkboxGroup.toggleOption(new AntCheckboxOptionType
                {
                    value = this.value,
                    label = this.ChildContent
                });
            }

            OnChange.InvokeAsync(ev);
        }
Ejemplo n.º 2
0
 private async Task ChangeValue()
 {
     if (!_compositionInputting)
     {
         if (!EqualityComparer <TValue> .Default.Equals(CurrentValue, _inputValue))
         {
             CurrentValue = _inputValue;
             if (OnChange.HasDelegate)
             {
                 await OnChange.InvokeAsync(Value);
             }
         }
     }
 }
Ejemplo n.º 3
0
        internal void OnCheckboxChanged(string value, bool checkedState)
        {
            if (checkedState)
            {
                _currentValues.Add(value);
            }
            else
            {
                _currentValues.Remove(value);
            }

            OnChange.InvokeAsync(_currentValues);
            StateHasChanged();
        }
Ejemplo n.º 4
0
        protected async Task DeleteConfirm()
        {
            var parameters = new ModalParameters();

            parameters.Add(nameof(Table), Table);

            var resultModal = ModalService.Show <TableDeletionConfirm>("Confirm", parameters);
            var result      = await resultModal.Result;

            if (!result.Cancelled)
            {
                await OnChange.InvokeAsync("List was changed");
            }
        }
Ejemplo n.º 5
0
 protected void OnChangeHandler(UIChangeEventArgs ev)
 {
     if (disabled)
     {
         return;
     }
     if (this.Checked == null)
     {
         bool _checked;
         bool.TryParse(ev.Value.ToString(), out _checked);
         Checked = _checked;
     }
     OnChange.InvokeAsync(ev);
 }
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (firstRender)
            {
                await Mediator.InitBPMN(Id, DiagramXML);

                Mediator.OnDiagramChange += async(caller, args) =>
                {
                    await OnChange.InvokeAsync(null);

                    EditInProgress = true;
                    StateHasChanged();
                };
            }
        }
        public async Task ConfirmRevertAsync()
        {
            if (!EditInProgress)
            {
                return;
            }

            await Mediator.SetDiagramXML(Id, DiagramXML);

            EditInProgress = false;
            StateHasChanged();
            await revertDialogWindow.CloseAsync();

            await OnChange.InvokeAsync(null);
        }
Ejemplo n.º 8
0
        public void RemoveSelection(string key)
        {
            var option = ItemsSource.FirstOrDefault(x => x.Key == key);

            if (option == null)
            {
                return;
            }

            CascadedEditContext?.NotifyFieldChanged(FieldIdentifier);

            if (MultiSelect)
            {
                if (!SelectedOptions.Contains(option))
                {
                    throw new Exception("This option was not already selected.");
                }

                if (OnChange.HasDelegate)
                {
                    OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, false));
                }

                SelectedOptions = SelectedOptions.Where(x => x != option).ToList();

                if (SelectedOptionsChanged.HasDelegate)
                {
                    SelectedOptionsChanged.InvokeAsync(SelectedOptions);
                }
            }
            else
            {
                if (SelectedOption != null)
                {
                    SelectedOption = null;
                    if (OnChange.HasDelegate)
                    {
                        OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, false));
                    }

                    if (SelectedOptionChanged.HasDelegate)
                    {
                        SelectedOptionChanged.InvokeAsync(SelectedOption);
                    }
                }
            }
            StateHasChanged();
        }
Ejemplo n.º 9
0
        public async Task UploadChanged(string id, int progress)
        {
            var file = FileList.FirstOrDefault(x => x.Id.Equals(id));

            if (file == null)
            {
                return;
            }
            file.Progress = progress;
            await InvokeAsync(StateHasChanged);

            if (OnChange.HasDelegate)
            {
                await OnChange.InvokeAsync(_uploadInfo);
            }
        }
Ejemplo n.º 10
0
        private async Task Clear()
        {
            CurrentValue = default;
            IsFocused    = true;
            await this.FocusAsync(Ref);

            if (OnChange.HasDelegate)
            {
                await OnChange.InvokeAsync(Value);
            }
            else
            {
                //Without the delay, focus is not enforced.
                await Task.Delay(1);
            }
        }
Ejemplo n.º 11
0
        protected override async void OnInputAsync(ChangeEventArgs args)
        {
            // do not call base method to avoid lost focus
            //base.OnInputAsync(args);

            CurrentValueAsString = args.Value.ToString();
            if (OnChange.HasDelegate)
            {
                await OnChange.InvokeAsync(CurrentValueAsString);
            }

            if (AutoSize)
            {
                await ChangeSizeAsync();
            }
        }
Ejemplo n.º 12
0
        protected async Task OnKeyUpAsync(KeyboardEventArgs args)
        {
            if (!EqualityComparer <TValue> .Default.Equals(CurrentValue, _inputValue))
            {
                CurrentValue = _inputValue;
                if (OnChange.HasDelegate)
                {
                    await OnChange.InvokeAsync(Value);
                }
            }

            if (OnkeyUp.HasDelegate)
            {
                await OnkeyUp.InvokeAsync(args);
            }
        }
Ejemplo n.º 13
0
        protected async Task HandleChangeAsync(ChangeEventArgs args)
        {
            var value = args.Value?.ToString();

            if (!IsControlled)
            {
                ValueState = value;

                DirtyCheck(ValueState);

                await InvokeAsync(StateHasChanged);
            }
            else if (!object.Equals(value, Value))
            {
                await OnChange.InvokeAsync(args);
            }
        }
Ejemplo n.º 14
0
        public void Deactivate(params string[] inactiveKeys)
        {
            var selectedKeys = new List <string>();

            foreach (var item in Items)
            {
                if (item.Key.IsIn(inactiveKeys))
                {
                    item.SetActiveInt(false);
                }
                else if (item.Active)
                {
                    selectedKeys.Add(item.Key);
                }
            }

            OnChange.InvokeAsync(selectedKeys.ToArray());
        }
        /// <summary>
        /// Called when [checkbox change].
        /// </summary>
        /// <param name="checkbox">The checkbox.</param>
        /// <returns></returns>
        internal void OnCheckboxChange(Checkbox checkbox)
        {
            var index = _checkboxItems.IndexOf(checkbox);
            int indexOffset;
            OneOf <CheckboxOption[], string[]> workWith;

            if (checkbox.IsFromOptions)
            {
                indexOffset = _indexSetOptionsOffset;
                workWith    = Options;
            }
            else
            {
                indexOffset = _indexConstructedOptionsOffset;
                workWith    = _constructedOptions;
            }


            workWith.Switch(opts =>
            {
                if (opts[index] != null)
                {
                    opts[index].Checked = checkbox.Checked;
                }
            }, opts =>
            {
                if (checkbox.Checked && !opts[index - indexOffset].IsIn(_selectedValues))
                {
                    _selectedValues = _selectedValues.Append(opts[index - indexOffset]);
                }
                else
                {
                    _selectedValues = _selectedValues.Except(new[] { opts[index - indexOffset] }).ToArray();
                }
            });

            CurrentValue = _currentValue();
            if (OnChange.HasDelegate)
            {
                OnChange.InvokeAsync(CurrentValue);
            }

            StateHasChanged();
        }
Ejemplo n.º 16
0
        public void Activate(params string[] activeKeys)
        {
            var selectedKeys = new List <string>(activeKeys.Length);

            foreach (var item in Items)
            {
                if (item.Key.IsIn(activeKeys))
                {
                    selectedKeys.Add(item.Key);
                    item.SetActiveInt(true);
                }
                else if (this.Accordion)
                {
                    item.SetActiveInt(false);
                }
            }

            OnChange.InvokeAsync(selectedKeys.ToArray());
        }
        protected async Task ConfirmSaveAsync()
        {
            try
            {
                Contract.ReplaceSafely(diagramToSave);
                await successSnackbar.ShowAsync();

                EditInProgress = false;
                StateHasChanged();
            }
            catch (Exception e)
            {
                alertController.AddAlert("Diagram confirm unsuccessful: " + e.Message, AlertScheme.Danger);
            }

            await saveDialogWindow.CloseAsync();

            await OnChange.InvokeAsync(null);
        }
Ejemplo n.º 18
0
        protected async Task OnMouseUpAsync(MouseEventArgs args)
        {
            if (!EqualityComparer <TValue> .Default.Equals(CurrentValue, _inputValue))
            {
                if (!_compositionInputting)
                {
                    CurrentValue = _inputValue;
                    if (OnChange.HasDelegate)
                    {
                        await OnChange.InvokeAsync(Value);
                    }
                }
            }

            if (OnMouseUp.HasDelegate)
            {
                await OnMouseUp.InvokeAsync(args);
            }
        }
Ejemplo n.º 19
0
        private async Task HandleSelected()
        {
            foreach (var file in await FileReaderService.CreateReference(_input).EnumerateFilesAsync())
            {
                if (file != null)
                {
                    var fileInfo = await file.ReadFileInfoAsync();

                    await using var ms = await file.CreateMemoryStreamAsync();

                    var content = new MultipartFormDataContent();
                    content.Add(new StreamContent(ms, Convert.ToInt32(ms.Length)), fileInfo.Name, fileInfo.Name);
                    var path = await UserHttpRepository.UploadFile(content);

                    FileDataUrls.Add(path);
                    await OnChange.InvokeAsync(path);
                }
            }
        }
Ejemplo n.º 20
0
        private async Task MoveItem(MouseEventArgs e, string direction)
        {
            var moveKeys = direction == TransferDirection.Right ? _sourceSelectedKeys : _targetSelectedKeys;

            if (direction == TransferDirection.Left)
            {
                _targetKeys.RemoveAll(key => moveKeys.Contains(key));
            }
            else
            {
                _targetKeys.AddRange(moveKeys);
            }

            InitData();

            var oppositeDirection = direction == TransferDirection.Right ? TransferDirection.Left : TransferDirection.Right;

            HandleSelect(oppositeDirection, new List <string>());

            if (!string.IsNullOrEmpty(_leftFilterValue))
            {
                await HandleSearch(new ChangeEventArgs()
                {
                    Value = _leftFilterValue
                }, TransferDirection.Left, false);
            }

            if (!string.IsNullOrEmpty(_rightFilterValue))
            {
                await HandleSearch(new ChangeEventArgs()
                {
                    Value = _rightFilterValue
                }, TransferDirection.Right, false);
            }

            MathTitleCount();

            if (OnChange.HasDelegate)
            {
                await OnChange.InvokeAsync(new TransferChangeArgs(_targetKeys.ToArray(), direction, moveKeys.ToArray()));
            }
        }
Ejemplo n.º 21
0
        private async Task HandleSelected()
        {
            foreach (var file in await FileReaderService.CreateReference(_input).EnumerateFilesAsync())
            {
                if (file != null)
                {
                    var fileInfo = await file.ReadFileInfoAsync();

                    using (var ms = await file.CreateMemoryStreamAsync(4 * 1024))
                    {
                        var content = new MultipartFormDataContent();
                        content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
                        content.Add(new StreamContent(ms, Convert.ToInt32(ms.Length)), "image", fileInfo.Name);
                        ImgUrl = await HouseRepository.UploadImage(content);

                        await OnChange.InvokeAsync(ImgUrl);
                    }
                }
            }
        }
Ejemplo n.º 22
0
        internal void Click(Panel panel)
        {
            if (panel == null)
            {
                return;
            }

            if (this.Accordion && !panel.Active)
            {
                this.Items.Where(item => item != panel && item.Active)
                .ForEach(item => item.SetActiveInt(false));
            }

            panel.SetActiveInt(!panel.Active);

            var selectedKeys = this.Items.Where(x => x.Active).Select(x => x.Key).ToArray();

            OnChange.InvokeAsync(selectedKeys);

            panel.OnActiveChange.InvokeAsync(panel.Active);
        }
Ejemplo n.º 23
0
        private async Task HandleSelected(InputFileChangeEventArgs e)
        {
            //foreach (var file in await FileReaderService.CreateReference(_input).EnumerateFilesAsync())
            //{
            //    if (file != null)
            //    {
            //        var fileInfo = await file.ReadFileInfoAsync();
            //        using (var ms = await file.CreateMemoryStreamAsync(4 * 1024))
            //        {
            //            var content = new MultipartFormDataContent();
            //            content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
            //            content.Add(new StreamContent(ms, Convert.ToInt32(ms.Length)), "image", fileInfo.Name);

            //            ImgUrl = await Repository.UploadImage(content, Id, Table);

            //            await OnChange.InvokeAsync(ImgUrl);
            //        }
            //    }
            //}

            var imageFiles = e.GetMultipleFiles();

            foreach (var imageFile in imageFiles)
            {
                if (imageFile != null)
                {
                    //var resizedFile = await imageFile.RequestImageFileAsync("image/png", 300, 500);

                    using (var ms = imageFile.OpenReadStream(imageFile.Size))
                    {
                        var content = new MultipartFormDataContent();
                        content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
                        content.Add(new StreamContent(ms, Convert.ToInt32(imageFile.Size)), "image", imageFile.Name);
                        ImgUrl = await Repository.UploadImage(content, Id, Table);

                        await OnChange.InvokeAsync(ImgUrl);
                    }
                }
            }
        }
        private async Task HandleSelected(ChangeEventArgs changeEventArgs)
        {
            foreach (var file in await FileReaderService.CreateReference(_input).EnumerateFilesAsync())
            {
                if (file == null)
                {
                    continue;
                }
                var fileInfo = await file.ReadFileInfoAsync();

                await using var ms = await file.CreateMemoryStreamAsync(4 * 1024);

                var content = new MultipartFormDataContent();
                content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
                content.Add(new StreamContent(ms, Convert.ToInt32(ms.Length)), "image", fileInfo.Name);
                ImgUrl = await Repository.UploadAdImage(content, HttpClientFactory.CreateClient(Configuration["Service:Api:AnonymousApiName"]),
                                                        NavigationManager);

                Console.WriteLine($"Upload Ad Image {ImgUrl}");
                await OnChange.InvokeAsync(ImgUrl);
            }
        }
Ejemplo n.º 25
0
        public void AddSelection(string key)
        {
            if (MultiSelect)
            {
                if (SelectedKeys.Contains(key))
                {
                    throw new Exception("This key was already selected.");
                }

                if (OnChange.HasDelegate)
                {
                    OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, true));
                }

                SelectedKeys.Add(key);

                if (SelectedKeysChanged.HasDelegate)
                {
                    SelectedKeysChanged.InvokeAsync(SelectedKeys);
                }
            }
            else
            {
                if (SelectedKey != key)
                {
                    SelectedKey = key;
                    if (OnChange.HasDelegate)
                    {
                        OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, true));
                    }
                    if (SelectedKeyChanged.HasDelegate)
                    {
                        SelectedKeyChanged.InvokeAsync(SelectedKey);
                    }
                }
                isOpen = false;
            }
            StateHasChanged();
        }
Ejemplo n.º 26
0
        public void RemoveSelection(string key)
        {
            if (MultiSelect)
            {
                if (!SelectedKeys.Contains(key))
                {
                    throw new Exception("This key was not already selected.");
                }

                if (OnChange.HasDelegate)
                {
                    OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, false));
                }

                SelectedKeys.Remove(key);  //this used to be following the next command.  A bug?  I moved it here...

                if (SelectedKeysChanged.HasDelegate)
                {
                    SelectedKeysChanged.InvokeAsync(SelectedKeys);
                }
            }
            else
            {
                if (SelectedKey != null)
                {
                    SelectedKey = null;
                    if (OnChange.HasDelegate)
                    {
                        OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, false));
                    }

                    if (SelectedKeyChanged.HasDelegate)
                    {
                        SelectedKeyChanged.InvokeAsync(SelectedKey);
                    }
                }
            }
            StateHasChanged();
        }
Ejemplo n.º 27
0
        private async Task HandleSelected(InputFileChangeEventArgs e)
        {
            var imageFile = e.File;

            if (imageFile is null)
            {
                return;
            }

            fileUploadMessage = imageFile.Name;

            var resizedFile = await imageFile.RequestImageFileAsync("image/png", 300, 500);

            using var ms = resizedFile.OpenReadStream(resizedFile.Size);
            var content = new MultipartFormDataContent();

            content.Headers.ContentDisposition =
                new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data");
            content.Add(new StreamContent(ms, Convert.ToInt32(resizedFile.Size)), "image", imageFile.Name);

            ImgUrl = await Repository.UploadImage(content);

            await OnChange.InvokeAsync(ImgUrl);
        }
Ejemplo n.º 28
0
        public void RemoveSelection(string key)
        {
            var option = ItemsSource.FirstOrDefault(x => x.Key == key);

            if (option == null)
            {
                return;
            }

            if (MultiSelect)
            {
                if (!SelectedOptions.Contains(option))
                {
                    throw new Exception("This option was not already selected.");
                }

                if (OnChange.HasDelegate)
                {
                    OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, false));
                }

                SelectedOptions = SelectedOptions.Where(x => x != option).ToList();

                if (SelectedOptionsChanged.HasDelegate)
                {
                    SelectedOptionsChanged.InvokeAsync(SelectedOptions);
                }


                //if (!SelectedKeys.Contains(key))
                //    throw new Exception("This key was not already selected.");

                //if (OnChange.HasDelegate)
                //    OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, false));

                //SelectedKeys.Remove(key);  //this used to be following the next command.  A bug?  I moved it here...

                //if (SelectedKeysChanged.HasDelegate)
                //    SelectedKeysChanged.InvokeAsync(SelectedKeys);
            }
            else
            {
                if (SelectedOption != null)
                {
                    SelectedOption = null;
                    if (OnChange.HasDelegate)
                    {
                        OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, false));
                    }

                    if (SelectedOptionChanged.HasDelegate)
                    {
                        SelectedOptionChanged.InvokeAsync(SelectedOption);
                    }
                }
                //if (SelectedKey != null)
                //{
                //    SelectedKey = null;
                //    if (OnChange.HasDelegate)
                //        OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, false));

                //    if (SelectedKeyChanged.HasDelegate)
                //        SelectedKeyChanged.InvokeAsync(SelectedKey);
                //}
            }
            StateHasChanged();
        }
Ejemplo n.º 29
0
        public void AddSelection(string key)
        {
            var option = ItemsSource.FirstOrDefault(x => x.Key == key);

            if (option == null)
            {
                return;
            }

            if (MultiSelect)
            {
                if (SelectedOptions.Contains(option))
                {
                    throw new Exception("This option was already selected somehow.");
                }

                if (OnChange.HasDelegate)
                {
                    OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, true));
                }

                SelectedOptions = SelectedOptions.Append(option).ToList();

                if (SelectedOptionsChanged.HasDelegate)
                {
                    SelectedOptionsChanged.InvokeAsync(SelectedOptions);
                }

                //if (SelectedKeys.Contains(key))
                //    throw new Exception("This key was already selected.");

                //if (OnChange.HasDelegate)
                //    OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, true));

                //SelectedKeys.Add(key);

                //if (SelectedKeysChanged.HasDelegate)
                //    SelectedKeysChanged.InvokeAsync(SelectedKeys);
            }
            else
            {
                if (SelectedOption != option)
                {
                    SelectedOption = option;
                    if (OnChange.HasDelegate)
                    {
                        OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, true));
                    }
                    if (SelectedOptionChanged.HasDelegate)
                    {
                        SelectedOptionChanged.InvokeAsync(SelectedOption);
                    }
                }
                isOpen = false;
                //if (SelectedKey!= key)
                //{
                //    SelectedKey = key;
                //    if (OnChange.HasDelegate)
                //        OnChange.InvokeAsync(new BFUDropdownChangeArgs(key, true));
                //    if (SelectedKeyChanged.HasDelegate)
                //        SelectedKeyChanged.InvokeAsync(SelectedKey);
                //}
                //isOpen = false;
            }
            StateHasChanged();
        }
Ejemplo n.º 30
0
 public async void OnChangeEvent(SortableJSEvent e)
 {
     await OnChange.InvokeAsync(new SortableEvent <TItem>(this, e));
 }