// This constructor is called when explicit Note Text is being declared. // This means the XML has "<NoteText>Something</NoteText>. Its used when // the user wants to alter a particular piece of text within a paragraph. public NoteText(CreateParams parentParams, XmlReader reader) { base.Initialize( ); PlatformLabel = PlatformLabel.Create( ); PlatformLabel.SetFade(0.0f); // Always get our style first mStyle = parentParams.Style; Styles.Style.ParseStyleAttributesWithDefaults(reader, ref mStyle, ref ControlStyles.mText); // check for attributes we support RectangleF bounds = new RectangleF( ); SizeF parentSize = new SizeF(parentParams.Width, parentParams.Height); ParseCommonAttribs(reader, ref parentSize, ref bounds); // Get margins and padding RectangleF padding; RectangleF margin; GetMarginsAndPadding(ref mStyle, ref parentSize, ref bounds, out margin, out padding); // apply margins to as much of the bounds as we can (bottom must be done by our parent container) ApplyImmediateMargins(ref bounds, ref margin, ref parentSize); Margin = margin; // create the font that either we or our parent defined PlatformLabel.SetFont(mStyle.mFont.mName, mStyle.mFont.mSize.Value); PlatformLabel.TextColor = mStyle.mFont.mColor.Value; // check for border styling if (mStyle.mBorderColor.HasValue) { PlatformLabel.BorderColor = mStyle.mBorderColor.Value; } if (mStyle.mBorderRadius.HasValue) { PlatformLabel.CornerRadius = mStyle.mBorderRadius.Value; } if (mStyle.mBorderWidth.HasValue) { PlatformLabel.BorderWidth = mStyle.mBorderWidth.Value; } if (mStyle.mBackgroundColor.HasValue) { PlatformLabel.BackgroundColor = mStyle.mBackgroundColor.Value; } // see if the user wants this text underlined string underlined = reader.GetAttribute("Underlined"); if (string.IsNullOrWhiteSpace(underlined) == false) { bool addUnderline = bool.Parse(underlined); if (addUnderline) { PlatformLabel.AddUnderline( ); } } // parse the stream string noteText = ""; if (reader.IsEmptyElement == false) { bool finishedLabel = false; while (finishedLabel == false && reader.Read( )) { switch (reader.NodeType) { case XmlNodeType.Text: { // support text as embedded in the element noteText = reader.Value.Replace(System.Environment.NewLine, ""); break; } case XmlNodeType.EndElement: { // if we hit the end of our label, we're done. //if( reader.Name == "NoteText" || reader.Name == "NT" ) if (ElementTagMatches(reader.Name)) { finishedLabel = true; } break; } } } } // adjust the text switch (mStyle.mTextCase) { case Styles.TextCase.Upper: { noteText = noteText.ToUpper( ); break; } case Styles.TextCase.Lower: { noteText = noteText.ToLower( ); break; } } SetText(noteText); PlatformLabel.Position = new PointF(bounds.X, bounds.Y); SetDebugFrame(PlatformLabel.Frame); }