private bool ShouldShow(ShowTo showTo, bool showToNot) { bool result; switch (showTo) { case ShowTo.All: result = true; break; case ShowTo.Beta: result = !App.IsProduction; break; case ShowTo.Cloud: result = _audioticaService.IsAuthenticated; break; case ShowTo.Cancelled: result = _audioticaService.IsAuthenticated && _audioticaService.CurrentUser.SubscriptionStatus == SubscriptionStatus.Canceled; break; case ShowTo.Trial: result = _audioticaService.IsAuthenticated && _audioticaService.CurrentUser.SubscriptionStatus == SubscriptionStatus.Trialing; break; case ShowTo.ActiveSubscription: result = _audioticaService.IsAuthenticated && _audioticaService.CurrentUser.SubscriptionStatus == SubscriptionStatus.Active; break; case ShowTo.PastDue: result = _audioticaService.IsAuthenticated && _audioticaService.CurrentUser.SubscriptionStatus == SubscriptionStatus.PastDue; break; case ShowTo.ScrobblingEnabled: result = App.Locator.ScrobblerService.IsAuthenticated; break; default: return(false); } if (showToNot) { return(!result); } return(result); }
protected override async Task OnAfterRenderAsync(bool firstRender) { if (string.IsNullOrWhiteSpace(ShowTo.Id)) { if (!rendered) { await Task.Delay(100); } return; } if (rendered) { return; } rendered = true; var showToRect = await ShowTo.Dom(JSRuntime).GetBoundingClientRectAsync(); var containerRect = await container.Dom(JSRuntime).GetBoundingClientRectAsync(); popupLayerOption = new PopupLayerOption(); popupLayerOption.Content = ChildContent; switch (Position) { case ShowToPosition.Bottom: popupLayerOption.Position = new System.Drawing.PointF() { X = (showToRect.X + showToRect.Width - containerRect.Width) / 2, Y = showToRect.Y + showToRect.Height }; break; case ShowToPosition.Top: popupLayerOption.Position = new System.Drawing.PointF() { X = (showToRect.X + showToRect.Width - containerRect.Width) / 2, Y = showToRect.Y - 32 /*按钮高度*/ }; break; } ChildContent = null; MarkAsRequireRender(); StateHasChanged(); popupService.PopupLayerOptions.Add(popupLayerOption); }
private bool ShouldShow(ShowTo showTo, bool showToNot) { bool result; switch (showTo) { case ShowTo.All: result = true; break; case ShowTo.Beta: result = !App.IsProduction; break; case ShowTo.Cloud: result = _audioticaService.IsAuthenticated; break; case ShowTo.Cancelled: result = _audioticaService.IsAuthenticated && _audioticaService.CurrentUser.SubscriptionStatus == SubscriptionStatus.Canceled; break; case ShowTo.Trial: result = _audioticaService.IsAuthenticated && _audioticaService.CurrentUser.SubscriptionStatus == SubscriptionStatus.Trialing; break; case ShowTo.ActiveSubscription: result = _audioticaService.IsAuthenticated && _audioticaService.CurrentUser.SubscriptionStatus == SubscriptionStatus.Active; break; case ShowTo.PastDue: result = _audioticaService.IsAuthenticated && _audioticaService.CurrentUser.SubscriptionStatus == SubscriptionStatus.PastDue; break; case ShowTo.ScrobblingEnabled: result = App.Locator.ScrobblerService.IsAuthenticated; break; default: return false; } if (showToNot) { return !result; } return result; }