Exemplo n.º 1
0
        public void MessageBox(string Title, string Message, string ICON, Func <ModelResult, object, bool> CallBack)
        {
            var _Model = new ModalModel
            {
                Title     = Title,
                Message   = Message,
                ModalType = ModalType.信息,
                ICON      = ICON,
                CallBack  = CallBack
            };

            Modals.Add(_Model);
        }
Exemplo n.º 2
0
        public void CustomBox(string Title, string Message, string ICON, object Model, Type Component, Func <ModelResult, object, bool> CallBack)
        {
            var _Model = new ModalModel
            {
                Title     = Title,
                Message   = Message,
                ModalType = ModalType.自定,
                Model     = Model,
                ICON      = ICON,
                Component = Component,
                CallBack  = CallBack
            };

            Modals.Add(_Model);
        }
Exemplo n.º 3
0
        public async Task CallBack(ModalModel _Modal, ModelResult Result)
        {
            bool IsComplete = false;

            if (_Modal.CallBack == null || Result == ModelResult.关闭)
            {
                IsComplete = true;
            }
            else if (_Modal.CallBack.Invoke(Result, _Modal.Model))
            {
                IsComplete = true;
            }
            if (IsComplete)
            {
                await JSRuntime.InvokeVoidAsync("web.modal.hide", _Modal.Element);;
                ModalService.Modals.Remove(_Modal);
            }
        }
Exemplo n.º 4
0
        private void Models_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            ModalModel Temp = null;

            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                Temp = e.NewItems.OfType <ModalModel>().FirstOrDefault();
                if (Temp.ModalType == ModalType.自定)
                {
                    Temp.ComponentRender = CreateButtonRenderer(Temp.Component, Temp.Model);
                }
                Modals.Add(Temp);
            }
            else if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                foreach (var item in e.OldItems.OfType <ModalModel>())
                {
                    Modals.Remove(item);
                }
            }
            InvokeAsync(StateHasChanged);
        }