Beispiel #1
0
        /// <summary>
        /// Close the modal dialog.
        /// </summary>
        public void Hide()
        {
            IsOpen = false;
            Closed.InvokeAsync(null);

            StateHasChanged();
        }
        private async Task ReceiveMessagesAsync(CancellationToken token)
        {
            try
            {
                var sb = new StringBuilder();
                while (_clientWebSocket.State == WebSocketState.Open)
                {
                    WebSocketReceiveResult result;
                    _buffer = new ArraySegment <byte>(new byte[BufferSize]);
                    sb.Clear();
                    do
                    {
                        result = await _clientWebSocket.ReceiveAsync(_buffer, token);

                        var message = Encoding.UTF8.GetString(_buffer.Array, 0, result.Count);
                        sb.Append(message);
                    } while (!result.EndOfMessage);

                    await TextReceived.InvokeAsync(this, sb.ToString());
                }
            }
            catch (Exception e)
            {
                await Closed.InvokeAsync(this, EventArgs.Empty);
            }
        }
Beispiel #3
0
 private void RaiseEvents(bool visible)
 {
     if (!visible)
     {
         _ = Closed.InvokeAsync(new SnackbarClosedEventArgs(Key, closeReason));
     }
 }
Beispiel #4
0
 private void RaiseEvents(bool visible)
 {
     if (!visible)
     {
         Closed.InvokeAsync(null);
     }
 }
        /// <summary>
        /// Hides the snackbar.
        /// </summary>
        public void Hide()
        {
            Visible = false;

            _ = Closed.InvokeAsync(null);

            StateHasChanged();
        }
Beispiel #6
0
        private void RaiseEvents(bool visible)
        {
            StateChanged?.Invoke(this, new ModalStateEventArgs(visible));

            if (!visible)
            {
                Closed.InvokeAsync(null);
            }
        }
        private Task OnSnackbarClosed(string key, SnackbarCloseReason closeReason)
        {
            var info = snackbarInfos.FirstOrDefault(x => x.Key == key);

            if (info != null)
            {
                snackbarInfos.Remove(info);
            }

            StateHasChanged();

            return(Closed.InvokeAsync(new SnackbarClosedEventArgs(key, closeReason)));
        }
Beispiel #8
0
 /// <summary>
 /// Handles the <see cref="Snackbar.Snackbar"/> closing event.
 /// </summary>
 /// <param name="eventArgs"></param>
 /// <returns></returns>
 protected virtual Task OnSnackbarClosed(SnackbarClosedEventArgs eventArgs)
 {
     return(eventArgs.CloseReason == SnackbarCloseReason.UserClosed
         ? Okayed.InvokeAsync()
         : Closed.InvokeAsync());
 }
Beispiel #9
0
 private async Task OnMenuItemClick(IMenuItem item)
 {
     await Closed.InvokeAsync(item);
 }
Beispiel #10
0
 protected Task OnOpenedChange(bool isOpen) =>
 !isOpen?Closed.InvokeAsync() : Task.CompletedTask;