コード例 #1
0
        private void GenerateAbsoluteVisible(ICodeBlock codeBlock, EntitySave entitySave)
        {
            if (!entitySave.GetInheritsFromIVisible())
            {
                var prop = codeBlock.Property("AbsoluteVisible", Public: true, Override: false, Type: "bool");
                prop.Get().Line("return Visible && (Parent == null || IgnoresParentVisibility || Parent is FlatRedBall.Graphics.IVisible == false || (Parent as FlatRedBall.Graphics.IVisible).AbsoluteVisible);");
            }

        }
コード例 #2
0
 private void GenerateIVisibleParent(ICodeBlock codeBlock, EntitySave entitySave)
 {
     if (!entitySave.GetInheritsFromIVisible())
     {
         var prop = codeBlock.Property("FlatRedBall.Graphics.IVisible.Parent", Override: false, Type: "FlatRedBall.Graphics.IVisible");
         var get = prop.Get();
         get.If("this.Parent != null && this.Parent is FlatRedBall.Graphics.IVisible")
             .Line("return this.Parent as FlatRedBall.Graphics.IVisible;").End()
             .Else()
             .Line("return null;");
     }
 }
コード例 #3
0
        private void UpdateIncludedAndExcluded(EntitySave instance)
        {
            UpdateIncludedAndExcludedBase(instance);


            bool shouldIncludeItemType = true;

            if (!string.IsNullOrEmpty(instance.BaseEntity) && instance.GetInheritsFromIVisible() && 
                // If it inherits from a FRB type, it is an IVisible, but we should still show this property
                !instance.InheritsFromFrbType())
            {
                IncludeMember("ImplementsIVisible", typeof(EntitySave), null, base.ReadOnlyAttribute());
            }


            if (!instance.CreatedByOtherEntities)
            {
                ExcludeMember("PooledByFactory");

            }

            if (!instance.IsScrollableEntityList)
            {
                shouldIncludeItemType = false;
                ExcludeMember("VerticalOrHorizontal");
                ExcludeMember("ListTopBound");
                ExcludeMember("ListBottomBound");
                ExcludeMember("ListLeftBound");
                ExcludeMember("ListRightBound");

                ExcludeMember("SpacingBetweenItems");
            }
            else
            {
                //if (this.VerticalOrHorizontal == SaveClasses.VerticalOrHorizontal.Horizontal)
                //{
                //    pdc = PropertyDescriptorHelper.RemoveProperty(pdc, "ListTopBound");
                //    pdc = PropertyDescriptorHelper.RemoveProperty(pdc, "ListBottomBound");
                //}
                //else
                //{
                //    pdc = PropertyDescriptorHelper.RemoveProperty(pdc, "ListLeftBound");
                //    pdc = PropertyDescriptorHelper.RemoveProperty(pdc, "ListRightBound");
                //}
            }

            // We used to only support inheriting from Entities, but now we support
            // inheriting from FRB types for performance reasons.
            //IncludeMember("BaseEntity", typeof(EntitySave), new AvailableEntityTypeConverter(instance));
            var converter = new AvailableClassGenericTypeConverter();
            // Don't let it inherit from itself:
            converter.EntitiesToExclude.Add(instance);
            IncludeMember("BaseEntity", typeof(EntitySave), converter);

            if (shouldIncludeItemType)
            {
                IncludeMember("ItemType", typeof(EntitySave), new AvailableEntityTypeConverter(instance));
            }
            else
            {
                ExcludeMember("ItemType");
            }
            IncludeMember("Name", typeof(string), SetClassName, GetClassName, null, this.CategoryAttribute("\tEnitity"));


        }
コード例 #4
0
        private static void GenerateVisibleProperty(ICodeBlock codeBlock, IElement element, EntitySave entitySave)
        {
            bool inheritsFromIVisible = entitySave.GetInheritsFromIVisible();

            #region Get whether we use virtual or override

            if (!inheritsFromIVisible)
            {
                codeBlock.Line("protected bool mVisible = true;");
            }

            #endregion

            var prop = codeBlock.Property("Visible", Public: true, Override: entitySave.GetInheritsFromIVisible(), Virtual: !entitySave.GetInheritsFromIVisible(), Type: "bool");

            if (inheritsFromIVisible)
            {
                prop.Get()
                    .Line("return base.Visible;");
            }
            else
            {
                prop.Get()
                    .Line("return mVisible;");
            }
            var set = prop.Set();

            #region History on the before set code

            // See comment above about why we no longer
            // check to see if it creates an event.
            //if (createsVisibleEvent)
            //{
            // Keep hasChanged around just in case we want to make a Changed event.  It won't be used by the Set event
            // Update November 27, 2011
            // This is just polluting code.  Let's remove it for now
            //set.Line("bool hasChanged = value != mVisible;");
            #endregion

            EventCodeGenerator.GenerateEventRaisingCode(set, BeforeOrAfter.Before, "Visible", entitySave);

            if (entitySave.GetInheritsFromIVisible())
            {
                set.Line("base.Visible = value;");
            }
            else
            {
                set.Line("mVisible = value;");
            }

            // May 6, 2012
            // We used to manually
            // set the Visible of all
            // children, but now we no
            // longer do that because there
            // is a concept of relative visibility.
            // WriteVisibleSetForNamedObjectSaves(set, entitySave);
            
            EventCodeGenerator.GenerateEventRaisingCode(set, BeforeOrAfter.After, "Visible", entitySave);
        }
コード例 #5
0
 private void GenerateIgnoresParentVisibility(ICodeBlock codeBlock, EntitySave entitySave)
 {
     if (!entitySave.GetInheritsFromIVisible())
     {
         codeBlock.AutoProperty("public bool", "IgnoresParentVisibility");
     }
 }