public TagButton InsertTagView(TagButton tagView, int index) { TagViews.Insert(index, tagView); _tagBackgroundViews.Insert(index, new UIView(tagView.Bounds)); RearrangeViews(); return(tagView); }
public TagButton AddTagView(TagButton tagView) { TagViews.Add(tagView); _tagBackgroundViews.Add(new UIView(tagView.Bounds)); RearrangeViews(); return(tagView); }
public async Task Tags(IGuildUser user = null) { user ??= Context.User as IGuildUser; var tags = await _tagService.GetTagSummaries(Context.Guild.Id, x => x.OwnerId == user.Id); var embed = TagViews.FormatUserTags(user, tags); await ReplyAsync(embed : embed); }
public IEnumerable <TagButton> AddTagViews(IEnumerable <TagButton> tagViews) { foreach (var tagView in tagViews) { TagViews.Add(tagView); _tagBackgroundViews.Add(new UIView(tagView.Bounds)); } RearrangeViews(); return(tagViews); }
public void RemoveAllTags() { var views = TagViews.Cast <UIView>().Concat(_tagBackgroundViews); foreach (var view in views) { view.RemoveFromSuperview(); } TagViews = new List <TagButton>(); _tagBackgroundViews = new List <UIView>(); RearrangeViews(); }
public void RemoveTagView(TagButton tagView) { tagView.RemoveFromSuperview(); var index = TagViews.IndexOf(tagView); if (index > -1) { TagViews.RemoveAt(index); _tagBackgroundViews.RemoveAt(index); } RearrangeViews(); }
public async Task Info(string name) { var tag = await _tagService.GetTagSummaryAsync(Context.Guild.Id, name); if (tag is null) { await ReplyAsync($"No tag called \"{name}\" found."); return; } var author = Context.Guild.GetUser(tag.AuthorId); var owner = Context.Guild.GetUser(tag.OwnerId); var embed = TagViews.FormatTagInfo(author, owner, tag); await ReplyAsync(embed : embed); }
public IEnumerable <TagButton> SelectedTags() { return(TagViews.Where(p => p.IsSelected)); }
public void RemoveTag(string title) { RemoveTagView(TagViews.FirstOrDefault(p => p.TitleLabel.Text.Equals(title))); }
void RearrangeViews() { var views = TagViews.Cast <UIView>().Concat(_tagBackgroundViews).Concat(_rowViews); foreach (var view in views) { view.RemoveFromSuperview(); } _rowViews.Clear(); var currentRow = 0; UIView currentRowView = new UIView { UserInteractionEnabled = true }; var currentRowTagCount = 0; nfloat currentRowWidth = 0; for (int i = 0; i < TagViews.Count(); i++) { var tagView = TagViews[i]; var tagViewFrame = tagView.Frame; tagViewFrame.Size = tagView.IntrinsicContentSize; tagView.Frame = tagViewFrame; _tagViewHeight = tagView.Frame.Height; if (currentRowTagCount == 0 || currentRowWidth + tagView.Frame.Width > Frame.Width) { currentRow += 1; currentRowWidth = 0; currentRowTagCount = 0; currentRowView = new UIView { UserInteractionEnabled = true }; var currentRowViewFrame = currentRowView.Frame; currentRowViewFrame.Y = Convert.ToSingle((currentRow - 1) * (_tagViewHeight + MarginY)); currentRowView.Frame = currentRowViewFrame; _rowViews.Add(currentRowView); Add(currentRowView); } var tagBackgroundView = _tagBackgroundViews[i]; var tagBackgroundViewFrame = tagBackgroundView.Frame; tagBackgroundViewFrame.Location = new CGPoint(currentRowWidth, 0); tagBackgroundViewFrame.Size = tagView.Bounds.Size; tagBackgroundView.Frame = tagBackgroundViewFrame; tagBackgroundView.Layer.ShadowColor = ShadowColor.CGColor; tagBackgroundView.Layer.ShadowPath = UIBezierPath.FromRoundedRect(tagBackgroundView.Bounds, CornerRadius).CGPath; tagBackgroundView.Layer.ShadowOffset = ShadowOffset; tagBackgroundView.Layer.ShadowOpacity = ShadowOpacity; tagBackgroundView.Layer.ShadowRadius = ShadowRadius; tagBackgroundView.Add(tagView); currentRowView.Add(tagBackgroundView); currentRowTagCount += 1; currentRowWidth += tagView.Frame.Width + MarginX; var currentRowViewFrameForAlignment = currentRowView.Frame; switch (Alignment) { case TagListViewAlignment.Left: currentRowViewFrameForAlignment.X = 0; break; case TagListViewAlignment.Center: currentRowViewFrameForAlignment.X = (Frame.Width - (currentRowWidth - MarginX)) / 2; break; case TagListViewAlignment.Right: currentRowViewFrameForAlignment.X = Frame.Width - (currentRowWidth - MarginX); break; } var currentRowViewFrameForAlignmentSize = currentRowViewFrameForAlignment.Size; currentRowViewFrameForAlignmentSize.Width = currentRowWidth; currentRowViewFrameForAlignmentSize.Height = Convert.ToSingle(Math.Max(_tagViewHeight, currentRowView.Frame.Height)); currentRowViewFrameForAlignment.Size = currentRowViewFrameForAlignmentSize; currentRowView.Frame = currentRowViewFrameForAlignment; } Rows = currentRow; InvalidateIntrinsicContentSize(); }