Example #1
0
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            ctx = 0;
            var    items = Items?.Value();
            string hash  = "";

            hash = items?.GetHashCode().ToString();

            if (previousHash != hash)
            {
                this.Children.Value = new List <DataboundAsset>();
                if (items != null)
                {
                    foreach (VirtualizedDataContext dataContext in items)
                    {
                        var newItem = screenResources.GetTemplate(Template.Value());
                        newItem.VirtualizedDataContext = dataContext;
                        newItem.ParentAsset            = this;

                        this.Children.Value.Add(newItem);
                    }
                }

                this.FixParentChildRelationship();
                this.FixBinds();
                previousHash = hash;
            }


            SetChildrenOriginToMyOrigin();
        }
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            ctx = 0;
            var    items = Items?.Value();
            string hash  = "";

            hash = items?.GetHashCode().ToString();

            if (previousHash != hash)
            {
                this.Children.Value = new List <DataboundAsset>();
                foreach (VirtualizedDataContext dataContext in items)
                {
                    var newItem = screenResources.GetTemplate(Template.Value());
                    newItem.VirtualizedDataContext = dataContext;
                    newItem.ParentAsset            = this;

                    this.Children.Value.Add(newItem);
                }

                this.FixParentChildRelationship();
                this.FixBinds();
                previousHash = hash;
            }

            float pos = 0;

            foreach (DataboundAsset item in Children.Value)
            {
                if (item.Margin != null && item.Margin.Value != null)
                {
                    pos = pos + item.Margin.Value.Top;
                }


                float width = item.Position.Value.Width;
                if (item.ActualSize.Y > 0)
                {
                    width = item.ActualSize.X;
                }

                float lm = 0;
                float bm = 0;
                float rm = 0;
                if (item.Margin != null && item.Margin.Value != null)
                {
                    lm = item.Margin.Value.Left;
                    bm = item.Margin.Value.Bottom;
                    rm = item.Margin.Value.Right;
                }

                item.Position.Value = new FloatRectangle(lm + pos, 0, item.Position.Value.Width, item.Position.Value.Height);

                pos = pos + width + rm;
            }

            this.ActualSize = new Vector2(this.Position.Value.Width, pos - this.Position.ToVector2().Y);

            SetChildrenOriginToMyOrigin();
        }
Example #3
0
        public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null)
        {
            if (!haveLoadedTemplate)
            {
                string template = Template.Value();

                List <DataboundAsset> children = this.Children.Value;

                DataboundAsset templateContent = screenResources.GetTemplate(template);
                templateContent.ParentAsset = this;

                if (templateContent is DataboundContainterAsset containerAsset)
                {
                    //containerAsset.Children.Value = children;

                    List <DataboundAsset> contentAssets = containerAsset.FindChildrenOfType <ContentAsset>();
                    if (contentAssets.Count > 0)
                    {
                        foreach (var contentAsset in contentAssets)
                        {
                            ((DataboundContainterAsset)contentAsset.ParentAsset).Children.Value = children;
                        }
                    }
                }

                this.Children.Value = new List <DataboundAsset> {
                    templateContent
                };
                this.FixParentChildRelationship();

                this.FixBinds();
                haveLoadedTemplate = true;
            }

            SetChildrenOriginToMyOrigin();
            if (ActualSize == Vector2.Zero)
            {
                this.ActualSize = this.Children.Value.First().ActualSize;
            }
        }