void ReleaseDesignerOutlets() { if (BadgeText != null) { BadgeText.Dispose(); BadgeText = null; } if (BalanceLabel != null) { BalanceLabel.Dispose(); BalanceLabel = null; } if (LastUpdateLabel != null) { LastUpdateLabel.Dispose(); LastUpdateLabel = null; } }
public async Task <List <BadgeModel> > GetBadges(Guid personUid) { var personToBadgeEntities = await _badgeRepository.GetBadges(personUid); var badges = await _badgeRepository.GetAllBadges(); var models = _mapper.Map <List <BadgeModel> >(badges); var httpContext = _contextAccessor.HttpContext; var culture = CultureParser.GetCultureFromHttpContext(httpContext); foreach (var model in models) { model.Name = BadgeText.GetBadgeText(model.BadgeName, BadgeTextType.Name, culture); model.Description = BadgeText.GetBadgeText(model.BadgeName, BadgeTextType.Description, culture); model.Received = personToBadgeEntities.Any(x => x.BadgeId == (long)model.BadgeName); } if (personToBadgeEntities.Any(x => !x.IsViewed)) { await _badgeRepository.SetPersonBadgesViewed(personUid); } return(models); }
public override void Draw(CGRect rect) { bool noTextToDraw = BadgeText == null || (BadgeText.Length <= 0); if (noTextToDraw) { return; } var ctx = UIGraphics.GetCurrentContext(); nfloat marginToDrawInside = MarginToDrawInside(); var region = new RectangleF( (float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height); var inflated = RectangleF.Inflate(region, (float)marginToDrawInside, (float)marginToDrawInside); CGRect rectToDraw = new CGRect(inflated.X, inflated.Y, inflated.Width, inflated.Height); var borderPath = UIBezierPath.FromRoundedRect( rect: rectToDraw, corners: UIRectCorner.AllCorners, radii: new CGSize(jsBadgeViewCornerRadius, jsBadgeViewCornerRadius)); /* Background and shadow */ ctx.SaveState(); { ctx.AddPath(borderPath.CGPath); ctx.SetFillColor(BadgeBackgroundColor.CGColor); ctx.SetShadow(BadgeShadowSize, jsBadgeViewShadowRadius, BadgeShadowColor.CGColor); ctx.DrawPath(CGPathDrawingMode.Fill); } ctx.RestoreState(); /* Gradient overlay */ bool colorForOverlayPresent = BadgeOverlayColor != null && BadgeOverlayColor != UIColor.Clear; if (colorForOverlayPresent) { ctx.SaveState(); { ctx.AddPath(borderPath.CGPath); ctx.Clip(); nfloat height = rectToDraw.Height; nfloat width = rectToDraw.Width; CGRect rectForOverlayCircle = new CGRect(rectToDraw.X, rectToDraw.Y - Math.Ceiling(height * 0.5), width, height); ctx.AddEllipseInRect(rectForOverlayCircle); ctx.SetFillColor(BadgeOverlayColor.CGColor); ctx.DrawPath(CGPathDrawingMode.Fill); } ctx.RestoreState(); } /* Stroke */ ctx.SaveState(); { ctx.AddPath(borderPath.CGPath); ctx.SetLineWidth(BadgeStrokeWidth); ctx.SetStrokeColor(BadgeStrokeColor.CGColor); ctx.DrawPath(CGPathDrawingMode.Stroke); } ctx.RestoreState(); /* Text */ ctx.SaveState(); { ctx.SetFillColor(BadgeTextColor.CGColor); ctx.SetShadow(BadgeTextShadowOffset, (nfloat)1.0, BadgeTextShadowColor.CGColor); CGRect textFrame = rectToDraw; CGSize textSize = SizeOfTextForCurrentSettings(); textFrame.Height = textSize.Height; textFrame.Y = rectToDraw.Y + (nfloat)Math.Ceiling((rectToDraw.Height - textFrame.Height) / 2.0f); BadgeText.DrawString( rect: textFrame, font: BadgeTextFont, mode: UILineBreakMode.Clip, alignment: UITextAlignment.Center); } ctx.RestoreState(); }