//adds a tag to the display public void AddTag(TagButton tagIn) { if (tagIn.Text == "") //if tag text is empty, dont add { return; } this.tags.Add(tagIn); AddTagToPage(tagIn); RefreshTags(); }
//deletes the tag from the display public void DeleteTags() { Console.WriteLine("deleting tags"); int i = 0; while (i < tags.Count) //move through tag list to find all that are hightlighted and delete them { TagButton button = tags[i]; if (button.isHighlighted()) { tags.RemoveAt(i); } else { i++; } } }
//adds the given tag to the optimal row private void AddTagToOptimalRow(TagButton newTag) { List <View> rows = this.Children.ToList(); rows.RemoveAt(0); int newTagWidth = newTag.CalculateButtonWidth(); StackLayout optimalRow = null; if (newTagWidth >= MasterNavigationPage.current.Width) { optimalRow = MakeNewTagsRow(); } else { foreach (StackLayout row in rows) { if (row.Width == 0) { optimalRow = row; break; } else if (LayoutWidth(row) + newTagWidth <= MasterNavigationPage.current.Width) { optimalRow = row; break; } } if (optimalRow == null) { optimalRow = MakeNewTagsRow(); } } optimalRow.Children.Add(newTag); }
//adds a tag to the page private void AddTagToPage(TagButton newTag) { TagButton newButton = newTag; AddTagToOptimalRow(newButton); }