/// <summary> /// Handler for <see cref="TextElement"/> being inserted in the collection. /// </summary> /// <param name="index">Index of the <see cref="TextElement"/></param> /// <param name="value">Value of the <see cref="TextElement"/> </param> private void OnInserted(int index, TextElement value) { if (string.IsNullOrEmpty(value.Text)) { value.Text = GetDefaultText(); } value.SetParent(this); if (DesignMode) { Container.Add(value); } maxHeight = GetMaxHeight(); }
/// <summary> /// Utility method to take a list of Product objects and wrap the /// in TextElements. TextElements are like label controls for a SuperMarquee /// control. /// </summary> /// <param name="products">the list of products to wrap in /// TextElement controls for placement into a marquee</param> /// <returns>returns a list of TextElement controls</returns> static List<TextElement> GetTextElements(IList<Product> products) { List<TextElement> ret = new List<TextElement>(); for (int i = 0; i < products.Count; i++) { const string fontName = "Segoe UI"; const float fontSize = 12f; ret.Add(new TextElement((i + 1).ToString()) { Font = new Font(fontName, fontSize) }); TextElement element = new TextElement(products[i].ToString()) { IsLink = true, ForeColor = Color.Blue, Tag = products[i], Font = new Font(fontName, fontSize, FontStyle.Underline) }; ret.Add(element); } return ret; }
/// <summary> /// Handler for <see cref="TextElement"/> removed from the collection. /// </summary> /// <param name="index">Index of the <see cref="TextElement"/></param> /// <param name="value">Value of the <see cref="TextElement"/> </param> private void OnRemoved(int index, TextElement value) { maxHeight = GetMaxHeight(); }