Exemple #1
0
        public override void ApplyFormattingAndLayout(SlotData slotData, SlotStyleData slotStyleData, TableLayoutItemInfo layout)
        {
            base.ApplyFormattingAndLayout(slotData, slotStyleData, layout);

            //IMPLEMENT: the rest of the properties in SlotData, SlotStyleData, and TableLayoutItemInfo

            if (layout != null)
            {
                Margin  = new Spacing(layout.LeftMargin, layout.TopMargin, layout.RightMargin, layout.BottomMargin);
                Padding = new Spacing(layout.LeftPadding, layout.TopPadding, layout.RightPadding, layout.BottomPadding);
                Crop    = layout.CropStrategy;
            }

            if (slotData != null)
            {
                // background
                if (slotData.Background.HasValue)
                {
                    PaintStyleResult bgRes = ResolvePaintStyle(slotData.Background.Value, PaintStyleUse.Background);

                    if (bgRes.Brush != null)
                    {
                        Background = bgRes.Brush;
                    }
                }
            }

            if (slotStyleData != null)
            {
                Crop = slotStyleData.Crop;

                // background
                if (slotStyleData.Background.HasValue)
                {
                    PaintStyleResult bgRes = ResolvePaintStyle(slotStyleData.Background.Value, PaintStyleUse.Background);

                    if (bgRes.Brush != null)
                    {
                        Background = bgRes.Brush;
                    }
                }
            }
        }
Exemple #2
0
        public override void ApplyFormattingAndLayout(SlotData slotData, SlotStyleData slotStyleData, TableLayoutItemInfo layout)
        {
            base.ApplyFormattingAndLayout(slotData, slotStyleData, layout);

            Brush background = null;
            Brush foreground = null;
            short fontID     = -1;

            //IMPLEMENT: the rest of the properties in SlotData, SlotStyleData, and TableLayoutItemInfo

            if (layout != null)
            {
                // margins and paddings
                Margin  = new Spacing(layout.LeftMargin, layout.TopMargin, layout.RightMargin, layout.BottomMargin);
                Padding = new Spacing(layout.LeftPadding, layout.TopPadding, layout.RightPadding, layout.BottomPadding);

                // cropping
                Crop = layout.CropStrategy;
            }

            if (slotData != null)
            {
                // background
                if (slotData.Background.HasValue)
                {
                    PaintStyleResult bgRes = ResolvePaintStyle(slotData.Background.Value, PaintStyleUse.Background);

                    if (bgRes.Brush != null)
                    {
                        background = bgRes.Brush;
                    }
                }

                // foreground
                if (slotData.Foreground.HasValue)
                {
                    PaintStyleResult fgRes = ResolvePaintStyle(slotData.Foreground.Value, PaintStyleUse.Foreground);

                    if (fgRes.Brush != null)
                    {
                        foreground = fgRes.Brush;
                    }
                }

                // get font
                fontID = slotData.Font ?? -1;
            }

            if (slotStyleData != null)
            {
                // cropping
                Crop = slotStyleData.Crop;

                // background
                if (slotStyleData.Background.HasValue)
                {
                    PaintStyleResult bgRes = ResolvePaintStyle(slotStyleData.Background.Value, PaintStyleUse.Background);

                    if (bgRes.Brush != null)
                    {
                        background = bgRes.Brush;
                    }
                }

                // foreground
                if (slotStyleData.Foreground.HasValue)
                {
                    PaintStyleResult fgRes = ResolvePaintStyle(slotStyleData.Foreground.Value, PaintStyleUse.Foreground);

                    if (fgRes.Brush != null)
                    {
                        foreground = fgRes.Brush;
                    }
                }

                // get font
                fontID = slotStyleData.Font;
            }

            // use parent foreground if needed
            if (foreground == null)
            {
                foreground = Atomic.Foreground;
            }

            // apply brushes
            Background             = background;
            textControl.Foreground = foreground;

            // apply font
            if (fontID != -1)
            {
                FontReferencePaletteEntry fr = Atomic.FindCascadedPaletteItem(fontID) as FontReferencePaletteEntry;

                if (fr != null)
                {
                    FontDefinition fd = fr.Resolve(Atomic.ParentNode.ApplicationID);

                    if (fd != null)
                    {
                        fd.Apply(textControl);
                    }
                }
            }

            // apply cropping, alignment, tick
            if ((Crop & CropStrategy.Wrap) == CropStrategy.Wrap)
            {
                textControl.TextWrapping = TextWrapping.Wrap;

                if ((Crop & CropStrategy.Tick) == CropStrategy.Tick)
                {
                    textControl.TextTrimming = TextTrimming.WordEllipsis;
                }
                else
                {
                    textControl.TextTrimming = TextTrimming.None;
                }
            }
            else if ((Crop & CropStrategy.Tick) == CropStrategy.Tick)
            {
                textControl.TextWrapping = TextWrapping.NoWrap;
                textControl.TextTrimming = TextTrimming.WordEllipsis;
            }
            else
            {
                textControl.TextWrapping = TextWrapping.NoWrap;
                textControl.TextTrimming = TextTrimming.None;
            }

            // set horizontal alignment (vertical one is done in layout)
            if ((Crop & CropStrategy.AlignLeft) == CropStrategy.AlignLeft)
            {
                textControl.TextAlignment = TextAlignment.Left;
            }
            else if ((Crop & CropStrategy.AlignHCenter) == CropStrategy.AlignHCenter)
            {
                textControl.TextAlignment = TextAlignment.Center;
            }
            else if ((Crop & CropStrategy.AlignRight) == CropStrategy.AlignRight)
            {
                textControl.TextAlignment = TextAlignment.Right;
            }
        }
Exemple #3
0
 public virtual void ApplyFormattingAndLayout(SlotData slotData, SlotStyleData slotStyleData, TableLayoutItemInfo layout)
 {
 }
Exemple #4
0
        public RendererBase CreateRenderer(AtomicBlockBase parent, DisplayData data, SlotData slotData, SlotStyleData slotStyleData, TableLayoutItemInfo layout)
        {
            RendererBase res = null;

            if (data != null)
            {
                switch (data.DisplayType)
                {
                case DisplayType.String:
                    res = new TextRenderer(parent);
                    break;

                case DisplayType.ContentReference:
                {
                    ContentReference cref = data.Data as ContentReference;

                    if (cref != null)
                    {
                        switch (cref.MediaType)
                        {
                        case MediaPrimitiveType.Image:
                        case MediaPrimitiveType.ImageStrip:
                            res = new ImageRenderer(parent);
                            break;

                        default:
                            DebugHelper.Out("Unsupported content reference media type: {0}", cref.MediaType);
                            break;
                        }
                    }

                    break;
                }

                case DisplayType.MediaMetaData:
                {
                    MediaMetaData mmd = data.Data as MediaMetaData;

                    if (mmd != null)
                    {
                        ContentReference cref = mmd[Core.System.CurrentDeviceGroup];

                        if (cref != null)
                        {
                            switch (cref.MediaType)
                            {
                            case MediaPrimitiveType.Image:
                            case MediaPrimitiveType.ImageStrip:
                                res = new ImageRenderer(parent);
                                break;

                            case MediaPrimitiveType.String:
                                res = new TextRenderer(parent);
                                break;

                            default:
                                DebugHelper.Out("Unsupported content reference media type: {0}", cref.MediaType);
                                break;
                            }
                        }
                    }

                    break;
                }

                case DisplayType.EditableString:
                    res = new TextEntryRenderer(parent);
                    break;

                default:     //IMPLEMENT: more display types
                    DebugHelper.Out("Unsupported renderer type: {0}", data.DisplayType);
                    break;
                }

                if (res != null)
                {
                    res.SetDisplayData(data);
                    res.ApplyFormattingAndLayout(slotData, slotStyleData, layout);
                }
            }

            return(res);
        }