예제 #1
0
                public NoteText(CreateParams parentParams, string text)
                {
                    base.Initialize( );

                    PlatformLabel = PlatformLabel.Create( );

                    // take our parent's style, and for anything not set by them use the default.
                    mStyle = parentParams.Style;
                    Styles.Style.MergeStyleAttributesWithDefaults(ref mStyle, ref ControlStyles.mText);

                    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;
                    }

                    // set the dimensions and position
                    RectangleF bounds = new RectangleF( );

                    if (bounds.Width == 0)
                    {
                        // always take the available width, in case this control
                        // is specified to be offset relative to its parent
                        bounds.Width = parentParams.Width - bounds.X;
                    }
                    PlatformLabel.Bounds = bounds;

                    // get text
                    SetText(text);

                    // position ourselves in absolute coordinates, and trust our parent to offset us to be relative to them.
                    PlatformLabel.Position = new PointF(bounds.X, bounds.Y);
                    SetDebugFrame(PlatformLabel.Frame);
                }
예제 #2
0
파일: NoteText.cs 프로젝트: jhawkzz/CCVApp
                public NoteText( CreateParams parentParams, string text )
                {
                    base.Initialize( );

                    PlatformLabel = PlatformLabel.Create( );

                    // check for attributes we support
                    RectangleF bounds = new RectangleF( );

                    // take our parent's style, and for anything not set by them use the default.
                    mStyle = parentParams.Style;
                    Styles.Style.MergeStyleAttributesWithDefaults( ref mStyle, ref ControlStyles.mText );

                    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;
                    }

                    // set the dimensions and position
                    if( bounds.Width == 0 )
                    {
                        // always take the available width, in case this control
                        // is specified to be offset relative to its parent
                        bounds.Width = parentParams.Width - bounds.X;
                    }
                    PlatformLabel.Bounds = bounds;

                    // get text
                    SetText( text );

                    // position ourselves in absolute coordinates, and trust our parent to offset us to be relative to them.
                    PlatformLabel.Position = new PointF( bounds.X, bounds.Y );
                }
예제 #3
0
                void ParseHeaderElement( XmlReader reader, float parentWidth, float parentHeight, uint? parentBGColor, out PlatformLabel element, ref RectangleF elementBounds, ref Styles.Style defaultStyle )
                {
                    element = PlatformLabel.Create( );

                    // header elements are weird with styles. We don't want any of our parent's styles,
                    // so we create our own and mix that with our defaults
                    Styles.Style elementStyle = new Styles.Style( );
                    elementStyle.Initialize( );
                    elementStyle.mBackgroundColor = parentBGColor.HasValue ? parentBGColor.Value : 0; //one exception is background color. We do want to inherit that.
                    Styles.Style.ParseStyleAttributesWithDefaults( reader, ref elementStyle, ref defaultStyle );

                    // Note: Margins and padding are not supported by the individual elements of the header.

                    element.SetFont( elementStyle.mFont.mName, elementStyle.mFont.mSize.Value );
                    element.TextColor = elementStyle.mFont.mColor.Value;

                    if( elementStyle.mBackgroundColor.HasValue )
                    {
                        element.BackgroundColor = elementStyle.mBackgroundColor.Value;
                    }

                    element.Bounds = elementBounds;

                    // get text
                    switch( elementStyle.mTextCase )
                    {
                        case Styles.TextCase.Upper:
                        {
                            element.Text = reader.ReadElementContentAsString( ).ToUpper( );
                            break;
                        }

                        case Styles.TextCase.Lower:
                        {
                            element.Text = reader.ReadElementContentAsString( ).ToLower( );
                            break;
                        }

                        case Styles.TextCase.Normal:
                        {
                            element.Text = reader.ReadElementContentAsString( );
                            break;
                        }
                    }
                    element.SizeToFit( );


                    // horizontally position the controls according to their 
                    // requested alignment
                    Styles.Alignment controlAlignment = elementStyle.mAlignment.Value;

                    // adjust by our position
                    float xAdjust = 0;
                    switch( controlAlignment )
                    {
                        case Styles.Alignment.Center:
                        {
                            xAdjust = elementBounds.X + ( ( parentWidth / 2 ) - ( element.Bounds.Width / 2 ) );
                            element.TextAlignment = TextAlignment.Center;
                            break;
                        }
                        case Styles.Alignment.Right:
                        {
                            xAdjust = elementBounds.X + ( parentWidth - element.Bounds.Width );
                            element.TextAlignment = TextAlignment.Right;
                            break;
                        }
                        case Styles.Alignment.Left:
                        {
                            xAdjust = elementBounds.X;
                            element.TextAlignment = TextAlignment.Left;
                            break;
                        }
                    }

                    // adjust position
                    element.Position = new PointF( elementBounds.X + xAdjust, elementBounds.Y );
                }
예제 #4
0
                // 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);
                }
예제 #5
0
파일: Header.cs 프로젝트: J3057/MobileApp
                void ParseHeaderElement(XmlReader reader, float parentWidth, float parentHeight, uint?parentBGColor, out PlatformLabel element, ref RectangleF elementBounds, ref Styles.Style defaultStyle)
                {
                    element = PlatformLabel.Create( );

                    // header elements are weird with styles. We don't want any of our parent's styles,
                    // so we create our own and mix that with our defaults
                    Styles.Style elementStyle = new Styles.Style( );
                    elementStyle.Initialize( );
                    elementStyle.mBackgroundColor = parentBGColor.HasValue ? parentBGColor.Value : 0; //one exception is background color. We do want to inherit that.
                    Styles.Style.ParseStyleAttributesWithDefaults(reader, ref elementStyle, ref defaultStyle);

                    // Note: Margins and padding are not supported by the individual elements of the header.

                    element.SetFont(elementStyle.mFont.mName, elementStyle.mFont.mSize.Value);
                    element.TextColor = elementStyle.mFont.mColor.Value;

                    if (elementStyle.mBackgroundColor.HasValue)
                    {
                        element.BackgroundColor = elementStyle.mBackgroundColor.Value;
                    }

                    element.Bounds = elementBounds;

                    // get text
                    switch (elementStyle.mTextCase)
                    {
                    case Styles.TextCase.Upper:
                    {
                        element.Text = reader.ReadElementContentAsString( ).ToUpper( );
                        break;
                    }

                    case Styles.TextCase.Lower:
                    {
                        element.Text = reader.ReadElementContentAsString( ).ToLower( );
                        break;
                    }

                    case Styles.TextCase.Normal:
                    {
                        element.Text = reader.ReadElementContentAsString( );
                        break;
                    }
                    }
                    element.SizeToFit( );


                    // horizontally position the controls according to their
                    // requested alignment
                    Styles.Alignment controlAlignment = elementStyle.mAlignment.Value;

                    // adjust by our position
                    float xAdjust = 0;

                    switch (controlAlignment)
                    {
                    case Styles.Alignment.Center:
                    {
                        xAdjust = elementBounds.X + ((parentWidth / 2) - (element.Bounds.Width / 2));
                        element.TextAlignment = TextAlignment.Center;
                        break;
                    }

                    case Styles.Alignment.Right:
                    {
                        xAdjust = elementBounds.X + (parentWidth - element.Bounds.Width);
                        element.TextAlignment = TextAlignment.Right;
                        break;
                    }

                    case Styles.Alignment.Left:
                    {
                        xAdjust = elementBounds.X;
                        element.TextAlignment = TextAlignment.Left;
                        break;
                    }
                    }

                    // adjust position
                    element.Position = new PointF(elementBounds.X + xAdjust, elementBounds.Y);
                }
예제 #6
0
                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;
                    }

                    // 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 );
                }
예제 #7
0
                public RevealBox(CreateParams parentParams, string revealText) : base( )
                {
                    // don't call the base constructor that reads. we'll do the reading here.
                    base.Initialize( );

                    Revealed = false;

                    PlatformLabel = PlatformLabel.CreateRevealLabel( );
                    PlatformLabel.SetFade(0.0f);

                    // take our parent's style, and for anything not set by them use the default.
                    mStyle = parentParams.Style;
                    Styles.Style.MergeStyleAttributesWithDefaults(ref mStyle, ref ControlStyles.mText);

                    // 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;
                    }

                    // set the dimensions and position
                    RectangleF bounds = new RectangleF( );

                    if (bounds.Width == 0)
                    {
                        // always take the available width, in case this control
                        // is specified to be offset relative to its parent
                        bounds.Width = parentParams.Width - bounds.X;
                    }
                    PlatformLabel.Bounds = bounds;

                    // ensure that there's something IN the reveal text. We cannot render blank, because the bitmap mask can't be 0 width / height
                    if (string.IsNullOrWhiteSpace(revealText))
                    {
                        throw new Exception("RevealBox text cannot be blank.");
                    }

                    // adjust the text
                    switch (mStyle.mTextCase)
                    {
                    case Styles.TextCase.Upper:
                    {
                        revealText = revealText.ToUpper( );
                        break;
                    }

                    case Styles.TextCase.Lower:
                    {
                        revealText = revealText.ToLower( );
                        break;
                    }
                    }

                    SetText(revealText);

                    PlatformLabel.Position = new PointF(bounds.X, bounds.Y);
                }
예제 #8
0
                public RevealBox(CreateParams parentParams, XmlReader reader) : base( )
                {
                    // don't call the base constructor that reads. we'll do the reading here.
                    base.Initialize( );

                    Revealed = false;

                    PlatformLabel = PlatformLabel.CreateRevealLabel( );
                    PlatformLabel.SetFade(0.0f);

                    // Always get our style first
                    mStyle = parentParams.Style;
                    Styles.Style.ParseStyleAttributesWithDefaults(reader, ref mStyle, ref ControlStyles.mRevealBox);

                    // 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;
                    }

                    // parse the stream
                    string revealText = "";

                    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
                                revealText = reader.Value.Replace(System.Environment.NewLine, "");

                                break;
                            }

                            case XmlNodeType.EndElement:
                            {
                                // if we hit the end of our label, we're done.
                                //if( reader.Name == "RevealBox" || reader.Name == "RB" )
                                if (ElementTagMatches(reader.Name))
                                {
                                    finishedLabel = true;
                                }

                                break;
                            }
                            }
                        }
                    }

                    // ensure that there's something IN the reveal text. We cannot render blank, because the bitmap mask can't be 0 width / height
                    if (string.IsNullOrWhiteSpace(revealText))
                    {
                        throw new Exception("RevealBox text cannot be blank.");
                    }

                    // adjust the text
                    switch (mStyle.mTextCase)
                    {
                    case Styles.TextCase.Upper:
                    {
                        revealText = revealText.ToUpper( );
                        break;
                    }

                    case Styles.TextCase.Lower:
                    {
                        revealText = revealText.ToLower( );
                        break;
                    }
                    }

                    SetText(revealText);

                    PlatformLabel.Position = new PointF(bounds.X, bounds.Y);
                }