/// <summary>
        /// Show picker popup
        /// </summary>
        public void Open()
        {
            OldStartValue = StartDate;
            OldEndValue   = EndDate;

            var selectedRange = Ranges?.FirstOrDefault(r =>
                                                       r.Value.Start.Date == StartDate?.Date &&
                                                       r.Value.End.Date == EndDate?.Date);

            if (selectedRange != null)
            {
                ChosenLabel = selectedRange.Value.Key;
            }
            else
            {
                ChosenLabel = CustomRangeLabel;
                ShowCalendars();
            }

            Visible = true;

            JSRuntime.InvokeAsync <object>("clickAndPositionHandler.addClickOutsideEvent", Id, ParentId, DotNetObjectReference.Create(this));
            JSRuntime.InvokeAsync <object>("clickAndPositionHandler.getPickerPosition", Id, ParentId,
                                           Enum.GetName(typeof(DropsType), Drops).ToLower(), Enum.GetName(typeof(SideType), Opens).ToLower());

            OnOpened.InvokeAsync(null);

            StateHasChanged();
        }
Example #2
0
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (firstRender)
            {
                _jsAvailable = true;
                // register timers here so that pre-rendered Panels don't have timers running.
                _animationTimer = new Timer();

                _clearExistingAnimationTimer = () =>
                {
                    if (_animationTimer.Enabled)
                    {
                        _animationTimer.Stop();
                        _animationTimer.Elapsed -= _handler;
                    }
                };

                _animateTo = (animationState) =>
                {
                    Debug.WriteLine($"Animating to {animationState}");
                    _animationTimer.Interval = 200;
                    _handler = null;
                    _handler = (s, e) =>
                    {
                        _animationTimer.Stop();
                        _animationTimer.Elapsed -= _handler;
                        Debug.WriteLine($"Inside invokeAsync from animateTo timer elapsed.");
                        //InvokeAsync(() =>
                        //{
                        previousVisibility = currentVisibility;
                        currentVisibility  = animationState;
                        _onTransitionComplete();
                        //});
                    };
                    _animationTimer.Elapsed += _handler;
                    _animationTimer.Start();
                };

                _onTransitionComplete = async() =>
                {
                    isAnimating = false;
                    //StateHasChanged();
                    await UpdateFooterPositionAsync();

                    if (currentVisibility == PanelVisibilityState.Open)
                    {
                        await OnOpened.InvokeAsync(null);
                    }
                    if (currentVisibility == PanelVisibilityState.Closed)
                    {
                        await OnDismissed.InvokeAsync(null);
                    }
                    InvokeAsync(StateHasChanged);
                };
            }
            await SetRegistrationsAsync();

            await base.OnAfterRenderAsync(firstRender);
        }
Example #3
0
        /// <summary>
        /// Show picker popup
        /// </summary>
        public async Task Open()
        {
            Render = true;

            await Task.Yield();

            if (Visible)
            {
                return;
            }

            StartTime = TStartDate.HasValue
                ? TStartDate.Value.TimeOfDay
                : InitialStartTime ?? TimeSpan.Zero;

            EndTime = TEndDate.HasValue
                ? TEndDate.Value.TimeOfDay
                : InitialEndTime ?? TimeSpan.FromDays(1).Add(TimeSpan.FromTicks(-1));

            var selectedRange = Ranges?.FirstOrDefault(r =>
                                                       r.Value.Start.Date == TStartDate?.Date &&
                                                       r.Value.End.Date == TEndDate?.Date);

            if (selectedRange?.Value != null)
            {
                ChosenLabel = selectedRange.Value.Key;
                if (AlwaysShowCalendars != true)
                {
                    CalendarsVisible = false;
                }
            }
            else if (CalendarsVisible || AlwaysShowCalendars == true)
            {
                ChosenLabel      = CustomRangeLabel;
                CalendarsVisible = true;
            }

            await JSRuntime.InvokeAsync <object>("clickAndPositionHandler.addClickOutsideEvent", ContainerId, Id, DotNetObjectReference.Create(this));

            await JSRuntime.InvokeAsync <object>("clickAndPositionHandler.getPickerPosition", ContainerId, Id,
                                                 Enum.GetName(typeof(DropsType), Drops).ToLower(), Enum.GetName(typeof(SideType), Opens).ToLower());

            Visible = true;
            await OnOpened.InvokeAsync(null);

            if (AutoAdjustCalendars == true || Prerender != true)
            {
                await AdjustCalendars();
            }
        }
        /// <summary>
        /// Show picker popup
        /// </summary>
        public async Task Open()
        {
            if (Visible)
            {
                return;
            }

            var selectedRange = Ranges?.FirstOrDefault(r =>
                                                       r.Value.Start.Date == TStartDate?.Date &&
                                                       r.Value.End.Date == TEndDate?.Date);

            if (selectedRange?.Value != null)
            {
                ChosenLabel = selectedRange.Value.Key;
                if (AlwaysShowCalendars != true)
                {
                    CalendarsVisible = false;
                }
            }
            else if (CalendarsVisible || AlwaysShowCalendars == true)
            {
                ChosenLabel      = CustomRangeLabel;
                CalendarsVisible = true;
            }

            await JSRuntime.InvokeAsync <object>("clickAndPositionHandler.addClickOutsideEvent", Id, ParentId, DotNetObjectReference.Create(this));

            await JSRuntime.InvokeAsync <object>("clickAndPositionHandler.getPickerPosition", Id, ParentId,
                                                 Enum.GetName(typeof(DropsType), Drops).ToLower(), Enum.GetName(typeof(SideType), Opens).ToLower());

            Visible = true;
            await OnOpened.InvokeAsync(null);

            if (AutoAdjustCalendars == true)
            {
                await AdjustCalendars();
            }
        }
Example #5
0
        public Panel()
        {
            Debug.WriteLine("Panel Created");
            _animationTimer = new Timer();

            HeaderTemplate = builder =>
            {
                if (HeaderText != null)
                {
                    builder.OpenElement(0, "div");
                    {
                        builder.AddAttribute(1, "class", "ms-Panel-header");
                        builder.OpenElement(2, "p");
                        {
                            builder.AddAttribute(3, "class", "xlargeFont ms-Panel-headerText");
                            //builder.AddAttribute(4, "id", )
                            builder.AddAttribute(5, "role", "heading");
                            builder.AddAttribute(6, "aria-level", "2");
                            builder.AddContent(7, HeaderText);
                        }
                        builder.CloseElement();
                    }
                    builder.CloseElement();
                }
            };

            onPanelClick = () =>
            {
                this._dismiss();
            };

            _dismiss = async() =>
            {
                await OnDismiss.InvokeAsync(null);

                //normally, would check react synth events to see if event was interrupted from the OnDismiss callback before calling the following...
                // To Do
                this.Close();
            };

            _clearExistingAnimationTimer = () =>
            {
                if (_animationTimer.Enabled)
                {
                    _animationTimer.Stop();
                    _animationTimer.Elapsed -= _handler;
                }
            };

            _animateTo = (animationState) =>
            {
                _animationTimer.Interval = 200;
                _handler = null;
                _handler = (s, e) =>
                {
                    InvokeAsync(() =>
                    {
                        //Debug.WriteLine("Inside invokeAsync from animateTo timer elapsed");
                        _animationTimer.Elapsed -= _handler;
                        _animationTimer.Stop();

                        previousVisibility = currentVisibility;
                        currentVisibility  = animationState;
                        _onTransitionComplete();
                    });
                };
                _animationTimer.Elapsed += _handler;
                _animationTimer.Start();
            };

            _onTransitionComplete = async() =>
            {
                isAnimating = false;
                //StateHasChanged();
                await UpdateFooterPositionAsync();

                if (currentVisibility == PanelVisibilityState.Open)
                {
                    await OnOpened.InvokeAsync(null);
                }
                if (currentVisibility == PanelVisibilityState.Closed)
                {
                    await OnDismissed.InvokeAsync(null);
                }
                StateHasChanged();
            };
        }