Esempio n. 1
0
        private async Task Show(DialogOption option)
        {
            if (ModalContainer != null)
            {
                await ModalContainer.SetParametersAsync(ParameterView.FromDictionary(new Dictionary <string, object>()
                {
                    [nameof(Modal.ChildContent)] = new RenderFragment(builder =>
                    {
                        var index = 0;
                        builder.OpenComponent <ModalDialog>(index++);
                        builder.AddMultipleAttributes(index++, option.ToAttributes());
                        if (option.BodyTemplate != null)
                        {
                            builder.AddAttribute(index++, nameof(ModalDialog.BodyTemplate), option.BodyTemplate);
                        }
                        if (option.FooterTemplate != null)
                        {
                            builder.AddAttribute(index++, nameof(ModalDialog.FooterTemplate), option.FooterTemplate);
                        }
                        if (option.BodyComponent != null)
                        {
                            var val = GetInstanceRenderFragment(option.BodyComponent);
                            if (val != null)
                            {
                                builder.AddAttribute(index++, nameof(ModalDialog.BodyTemplate), val);
                            }
                        }
                        builder.CloseComponent();
                    })
                }));

                IsShowDialog = true;
                StateHasChanged();
            }
        }
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (ModalContainer != null && IsShowDialog)
            {
                IsShowDialog = false;
                await ModalContainer.Toggle();

                if (IsAutoHide && Delay > 0)
                {
                    if (DelayToken == null)
                    {
                        DelayToken = new CancellationTokenSource();
                    }
                    await Task.Delay(Delay, DelayToken.Token);

                    if (!DelayToken.IsCancellationRequested)
                    {
                        // 自动关闭弹窗
                        await ModalContainer.Toggle();
                    }
                }
            }
        }
Esempio n. 3
0
        Task PresentModal(Page modal, bool animated)
        {
            var modalContainer = new ModalContainer(_context, modal);

            _renderer.AddView(modalContainer);

            var source = new TaskCompletionSource <bool>();

            NavAnimationInProgress = true;
            if (animated)
            {
                modalContainer.TranslationY = _renderer.Height;
                modalContainer.Animate().TranslationY(0).SetInterpolator(new DecelerateInterpolator(1)).SetDuration(300).SetListener(new GenericAnimatorListener
                {
                    OnEnd = a =>
                    {
                        source.TrySetResult(false);
                        modalContainer = null;
                    },
                    OnCancel = a =>
                    {
                        source.TrySetResult(true);
                        modalContainer = null;
                    }
                });
            }
            else
            {
                source.TrySetResult(true);
            }

            return(source.Task.ContinueWith(task => NavAnimationInProgress = false));
        }
Esempio n. 4
0
        private void InitializeModalAnimations()
        {
            var noteEditorFadeInAnimation = compositor.CreateScalarKeyFrameAnimation();

            noteEditorFadeInAnimation.Duration = TimeSpan.FromMilliseconds(ModalContainer.DefaultDuration);
            noteEditorFadeInAnimation.InsertExpressionKeyFrame(0, "Height");
            noteEditorFadeInAnimation.InsertKeyFrame(1, 0, ModalContainer.DefaultEasing);
            ModalContainer.AddFadeInAnimation <NoteEditorView>("Offset.Y", noteEditorFadeInAnimation);

            var noteEditorFadeOutAnimation = compositor.CreateScalarKeyFrameAnimation();

            noteEditorFadeOutAnimation.Duration = TimeSpan.FromMilliseconds(ModalContainer.DefaultDuration);
            noteEditorFadeOutAnimation.InsertKeyFrame(0, 0);
            noteEditorFadeOutAnimation.InsertExpressionKeyFrame(1, "Height", ModalContainer.DefaultEasing);
            ModalContainer.AddFadeOutAnimation <NoteEditorView>("Offset.Y", noteEditorFadeOutAnimation);

            var settingsFadeInAnimation = compositor.CreateScalarKeyFrameAnimation();

            settingsFadeInAnimation.Duration = TimeSpan.FromMilliseconds(ModalContainer.DefaultDuration);
            settingsFadeInAnimation.InsertExpressionKeyFrame(0, "Width");
            settingsFadeInAnimation.InsertKeyFrame(1, 0, ModalContainer.DefaultEasing);
            ModalContainer.AddFadeInAnimation <SettingsView>("Offset.X", settingsFadeInAnimation);

            var settingsFadeOutAnimation = compositor.CreateScalarKeyFrameAnimation();

            settingsFadeOutAnimation.Duration = TimeSpan.FromMilliseconds(ModalContainer.DefaultDuration);
            settingsFadeOutAnimation.InsertKeyFrame(0, 0);
            settingsFadeOutAnimation.InsertExpressionKeyFrame(1, "Width", ModalContainer.DefaultEasing);
            ModalContainer.AddFadeOutAnimation <SettingsView>("Offset.X", settingsFadeOutAnimation);
        }
    private Task Show(SwalOption option)
    {
        IsAutoHide = option.IsAutoHide;
        Delay      = option.Delay;

        option.Dialog = ModalContainer;
        var parameters = option.ToAttributes();

        parameters.Add(nameof(ModalDialog.OnClose), new Func <Task>(async() =>
        {
            if (IsAutoHide && DelayToken != null)
            {
                DelayToken.Cancel();
                DelayToken = null;
            }
            DialogParameter = null;
            await ModalContainer.CloseOrPopDialog();
            StateHasChanged();
        }));

        parameters.Add(nameof(ModalDialog.BodyTemplate), BootstrapDynamicComponent.CreateComponent <SweetAlertBody>(SweetAlertBody.Parse(option)).Render());

        DialogParameter = parameters;
        IsShowDialog    = true;
        StateHasChanged();
        return(Task.CompletedTask);
    }
        private void OnClick()
        {
            var modalContainer = string.IsNullOrEmpty(_containerName)
                ? ModalContainer.Of(transform)
                : ModalContainer.Find(_containerName);

            modalContainer.Pop(_playAnimation);
        }
Esempio n. 7
0
 public UniversalModalView()
 {
     primaryContentPresenter = new ContentPresenter();
     modalContentPresenter   = new ContentPresenter();
     logicalChildren         = new object[2];
     InitializeComponent();
     Controller = new ModalContainer();
 }
Esempio n. 8
0
        private void OnFirstThumbButtonClicked()
        {
            var modalContainer = ModalContainer.Find(ContainerKey.MainModalContainer);

            modalContainer.Push(ResourceKey.CharacterModalPrefab(), true, modal =>
            {
                var characterModal = (CharacterModal)modal;
                characterModal.Setup(_characterId);
            });
        }
Esempio n. 9
0
        } // DisposeManagedResources

        #endregion

        #region Show Modal

        /// <summary>
        /// Show this container in modal mode.
        /// That means that prevent user from interacting with the rest of the controls.
        /// </summary>
        public virtual void ShowModal()
        {
            // You can't activate the modal mode twice at the same time.
            if (UserInterfaceManager.ModalWindow == this)
                return;
            lastModal = UserInterfaceManager.ModalWindow;
            UserInterfaceManager.ModalWindow = this;
            // This allow to close the modal window with the escape key.
            UserInterfaceManager.InputSystem.KeyDown += InputKeyDown;
        } // ShowModal
Esempio n. 10
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (ModalContainer != null && IsShowDialog)
            {
                IsShowDialog = false;
                await ModalContainer.Toggle();
            }
        }
Esempio n. 11
0
        private void Start()
        {
            var btn = button.GetOrAddComponent <Button>();

            btn.OnClickAsObservable()
            .ThrottleFirst(TimeSpan.FromSeconds(2))
            .Subscribe(_ =>
            {
                //NetworkSystem.In.Photon.OnLeaveRoomAsync().Forget();
                ModalContainer.Find(Constants.MainModalContainer).Pop(false);
            });
        }
Esempio n. 12
0
        private void TestModal(object Sender, RoutedEventArgs E)
        {
            var model = new ModalContainer()
            {
                ModalBrush = new SolidColorBrush(Color.FromArgb(200, 169, 169, 169))
            };
            var win = new ModalTestWindow()
            {
                DataContext = model
            };

            win.Show();
        }
Esempio n. 13
0
        public Navigator(NavigationManager manager, ModalContainer modalContainer, Interop interop, IJSRuntime js)
        {
            Ensure.NotNull(manager, "manager");
            Ensure.NotNull(interop, "interop");
            Ensure.NotNull(modalContainer, "modalContainer");
            Ensure.NotNull(js, "js");
            this.manager        = manager;
            this.modalContainer = modalContainer;
            this.interop        = interop;
            this.js             = js;

            manager.LocationChanged += OnLocationChanged;
        }
Esempio n. 14
0
 private RenderFragment RenderDialog() => builder =>
 {
     if (DialogParameter != null)
     {
         builder.OpenComponent <ModalDialog>(0);
         builder.AddMultipleAttributes(1, DialogParameter);
         builder.AddComponentReferenceCapture(2, dialog =>
         {
             var modal = (ModalDialog)dialog;
             ModalContainer.ShowDialog(modal);
         });
         builder.CloseComponent();
     }
 };
Esempio n. 15
0
 private void HandleModal(ShowLogMessage message)
 {
     ModalContainer.Show(new LogView());
 }
Esempio n. 16
0
 private void HandleModal(ShowSettingsMessage message)
 {
     ModalContainer.Show(new SettingsView());
 }
Esempio n. 17
0
 private void HandleModal(CloseModalMessage message)
 {
     ModalContainer.TryClose();
 }
Esempio n. 18
0
 private void HandleModal(ShowNoteEditorMessage message)
 {
     ModalContainer.Show(new NoteEditorView(message.Id));
 }
 private WebElement FindTab(string name)
 {
     return(ModalContainer.FindElements(TabsBy).Find(x => StringCompare(x.Text, name)));
 }
 public void OnOptionButton()
 {
     ModalContainer.Find(Constants.MainModalContainer)
     .Push(AddressableManager.In.DevSettingRef, false);
 }
Esempio n. 21
0
 private void OnSettingButtonClicked()
 {
     ModalContainer.Find(ContainerKey.MainModalContainer).Push(ResourceKey.SettingsModalPrefab(), true);
 }
Esempio n. 22
0
		Task PresentModal(Page modal, bool animated)
		{
			var modalContainer = new ModalContainer(_context, modal);

			_renderer.AddView(modalContainer);

			var source = new TaskCompletionSource<bool>();
			NavAnimationInProgress = true;
			if (animated)
			{
				modalContainer.TranslationY = _renderer.Height;
				modalContainer.Animate().TranslationY(0).SetInterpolator(new DecelerateInterpolator(1)).SetDuration(300).SetListener(new GenericAnimatorListener
				{
					OnEnd = a =>
					{
						source.TrySetResult(false);
						NavAnimationInProgress = false;
						modalContainer = null;
					},
					OnCancel = a =>
					{
						source.TrySetResult(true);
						NavAnimationInProgress = false;
						modalContainer = null;
					}
				});
			}
			else
			{
				NavAnimationInProgress = false;
				source.TrySetResult(true);
			}

			return source.Task;
		}