예제 #1
0
 public void ResetBounds( )
 {
     // reset our dimensions and call sizeToFit, which will
     // fully recalculate our bounds assuming this should all fit on a single line
     PlatformLabel.Bounds = new RectangleF(0, 0, 0, 0);
     PlatformLabel.SizeToFit( );
 }
예제 #2
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 );
                }
예제 #3
0
                public void SetStyleValue(EditStyling.Style style, object value)
                {
                    switch (style)
                    {
                    case EditStyling.Style.FontName:
                    {
                        string fontName = value as string;
                        PlatformLabel.Editable_SetFontName(fontName);

                        break;
                    }

                    case EditStyling.Style.FontSize:
                    {
                        float fontSize = (float)value;
                        PlatformLabel.Editable_SetFontSize(fontSize);

                        break;
                    }

                    case EditStyling.Style.Underline:
                    {
                        bool enableUnderline = (bool)value;

                        if (enableUnderline)
                        {
                            PlatformLabel.Editable_AddUnderline( );
                        }
                        else
                        {
                            PlatformLabel.Editable_RemoveUnderline( );
                        }

                        break;
                    }

                    case EditStyling.Style.BoldParagraph:
                    {
                        // for bolding the paragraph, forward this to the parent
                        ParentControl.SetStyleValue(style, value);
                        break;
                    }

                    case EditStyling.Style.UnderlineParagraph:
                    {
                        // for underlining the paragraph, forward this to the parent
                        ParentControl.SetStyleValue(style, value);
                        break;
                    }

                    case EditStyling.Style.BulletParagraph:
                    {
                        ParentControl.SetStyleValue(style, value);
                        break;
                    }

                    case EditStyling.Style.BoldItalicizeParagraph:
                    {
                        ParentControl.SetStyleValue(style, value);
                        break;
                    }

                    case EditStyling.Style.ItalicizeParagraph:
                    {
                        ParentControl.SetStyleValue(style, value);
                        break;
                    }
                    }

                    // first, reset our dimensions and call sizeToFit, which will
                    // fully recalculate our bounds (since our font name / size may have changed.)
                    PlatformLabel.Bounds = new RectangleF(0, 0, 0, 0);
                    PlatformLabel.SizeToFit( );

                    // now notify our parent so it can update its layout with our new size
                    ParentControl.HandleChildStyleChanged(style, this);
                }
예제 #4
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);
                }