当前位置: 首页>>代码示例>>C#>>正文


C# NamedObjectSave.UpdateCustomProperties方法代码示例

本文整理汇总了C#中FlatRedBall.Glue.SaveClasses.NamedObjectSave.UpdateCustomProperties方法的典型用法代码示例。如果您正苦于以下问题:C# NamedObjectSave.UpdateCustomProperties方法的具体用法?C# NamedObjectSave.UpdateCustomProperties怎么用?C# NamedObjectSave.UpdateCustomProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FlatRedBall.Glue.SaveClasses.NamedObjectSave的用法示例。


在下文中一共展示了NamedObjectSave.UpdateCustomProperties方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Show

 public void Show(ElementRuntime elementRuntime, NamedObjectSave nosToShow)
 {
     mCurrentElementRuntime = elementRuntime;
     if (nosToShow != null)
     {
         nosToShow.UpdateCustomProperties();
     }
     mCurrentNos = nosToShow;
     mNosDisplayer.CurrentElement = GlueViewState.Self.CurrentElement;
     mNosDisplayer.Instance = mCurrentNos;
     mNosDisplayer.PropertyGrid = mPropertyGrid;
 }
开发者ID:kainazzzo,项目名称:flatredball-spriter,代码行数:12,代码来源:PropertyGridManager.cs

示例2: TestRelativeAbsoluteConversion

        public void TestRelativeAbsoluteConversion()
        {
            NamedObjectSave nos = new NamedObjectSave();
            nos.SourceType = SourceType.FlatRedBallType;
            nos.SourceClassType = "Sprite";
            nos.UpdateCustomProperties();
            nos.InstanceName = "SpriteObject";
            nos.SetPropertyValue("ScaleX", 2.0f);
            nos.SetPropertyValue("X", 4.0f);
            nos.SetPropertyValue("RotationZ", 4.0f);
            nos.SetPropertyValue("RotationZVelocity", 4.0f);

            mEntitySave.NamedObjects.Add(nos);

            CustomVariable customVariable = new CustomVariable();
            customVariable.SourceObject = nos.InstanceName;
            customVariable.SourceObjectProperty = "ScaleY";
            customVariable.DefaultValue = 8.0f;

            mEntitySave.CustomVariables.Add(customVariable);

            ElementRuntime elementRuntime = new ElementRuntime(mEntitySave, null, null, null, null);

            Sprite sprite = elementRuntime.ContainedElements[0].DirectObjectReference as Sprite;
            sprite.ForceUpdateDependencies();

            if (elementRuntime.X != 0)
            {
                throw new Exception("NOS variables are being applied to the container instead of just to the NOS");
            }

            if (sprite.X != 4.0f)
            {
                throw new Exception("Absolute values should get set when setting X on objects even though they're attached");
            }

            if (sprite.RotationZ != 4.0f)
            {
                throw new Exception("Absolute values should get set when setting RotationZ on objects even though they're attached");
            }
            if (sprite.RelativeRotationZVelocity != 4.0f)
            {
                throw new Exception("Setting RotationZVelocity should set RelativeRotationZVelocity");
            }
            if (sprite.ScaleX != 2.0f)
            {
                throw new Exception("Scale values aren't properly showing up on Sprites");
            }
            if (sprite.ScaleY != 8.0f)
            {
                throw new Exception("Scale values aren't properly showing up on Sprites");
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:53,代码来源:NamedObjectSaveTests.cs

示例3: UpdateShownVariables

        public static void UpdateShownVariables(DataUiGrid grid, NamedObjectSave instance, IElement container)
        {
            grid.Categories.Clear();

            List<MemberCategory> categories = new List<MemberCategory>();
            var defaultCategory = new MemberCategory("Variables");
            defaultCategory.FontSize = 14;
            categories.Add(defaultCategory);

            AssetTypeInfo ati = instance.GetAssetTypeInfo();

            // not sure if this is needed:
            if (instance.TypedMembers.Count == 0)
            {
                instance.UpdateCustomProperties();
            }

            CreateCategoriesAndVariables(instance, container, categories, ati);

            if (ati != null)
            {
                SortCategoriesAndMembers(ref categories, ati);
            }


            if (defaultCategory.Members.Count == 0)
            {
                categories.Remove(defaultCategory);
            }
            else if (categories.Count != 1)
            {
                defaultCategory.Name = "Other Variables";
            }

            if (categories.Count != 0)
            {
                // "Name" should be the very first property:
                var nameCategory = CreateNameInstanceMember(instance);
                categories.Insert(0, nameCategory);
            }

            SetAlternatingColors(grid, categories);

            foreach(var category in categories)
            {
                grid.Categories.Add(category);
            }

            grid.Refresh();
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:50,代码来源:NamedObjectVariableShowingLogic.cs

示例4: CreateScreenSave

        private void CreateScreenSave()
        {
            mScreenSave = new ScreenSave();
            mScreenSave.Name = "ScreenSaveInVariableSettingTest";
            ObjectFinder.Self.GlueProject.Screens.Add(mScreenSave);

            NamedObjectSave nos = new NamedObjectSave();
            nos.SourceType = SourceType.Entity;
            nos.SourceClassType = mEntitySave.Name;
            nos.UpdateCustomProperties();
            nos.InstanceName = "TestObject1";
            nos.SetPropertyValue("X", 150);

            mScreenSave.NamedObjects.Add(nos);
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:15,代码来源:VariableSetting.cs

示例5: ShowPopupsForMissingVariablesInNewType

        private void ShowPopupsForMissingVariablesInNewType(NamedObjectSave namedObjectSave, object oldValue)
        {
            if (namedObjectSave.SourceType == SourceType.Entity)
            {
                string oldType = (string)oldValue;
                string message = namedObjectSave.GetMessageWhySwitchMightCauseProblems(oldType);

                if (message != null)
                {
                    message += "\nDo you want to change to " + namedObjectSave.SourceClassType + " anyway?";

                    DialogResult result = MessageBox.Show(message, "Change anyway?", MessageBoxButtons.YesNo);

                    if (result == DialogResult.No)
                    {
                        namedObjectSave.SourceClassType = (string)oldValue;
                        namedObjectSave.UpdateCustomProperties();

                    }
                }
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:22,代码来源:NamedObjectSetVariableLogic.cs

示例6: ReactToChangedSourceClassType

        private void ReactToChangedSourceClassType(NamedObjectSave namedObjectSave, object oldValue)
        {
            if (namedObjectSave.SourceClassType == "<NONE>" ||
                namedObjectSave.SourceClassType == null)
            {
                namedObjectSave.SourceClassType = (string)oldValue;
                namedObjectSave.UpdateCustomProperties();

            }
            else
            {



                if (namedObjectSave.SourceType == SourceType.Entity)
                {
                    EntitySave entitySave = ObjectFinder.Self.GetEntitySave(namedObjectSave.SourceClassType);

#if GLUE
                    // If the EntitySave is null then that probably means that the Entity has been renamed and this hasn't
                    // been pushed to the project yet.
                    if (entitySave != null && ProjectManager.VerifyReferenceGraph(entitySave) == ProjectManager.CheckResult.Failed)
                    {
                        namedObjectSave.SourceClassType = (string)oldValue;
                    }
                    else
#endif
                    {
                        namedObjectSave.UpdateCustomProperties();
                    }
                }
                else if (namedObjectSave.SourceType == SaveClasses.SourceType.FlatRedBallType)
                {
                    namedObjectSave.UpdateCustomProperties();

                }
            }

            if (namedObjectSave.SourceClassType != (string)oldValue)
            {
                ShowPopupsForMissingVariablesInNewType( namedObjectSave, oldValue);

                if (namedObjectSave.SourceClassType == "Layer")
                {
                    namedObjectSave.AddToManagers = true;
                }
            }
            // else, we should probably do something here to revert to defaults.  What a pain

        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:50,代码来源:NamedObjectSetVariableLogic.cs

示例7: ReactToSourceClassGenericType

        private void ReactToSourceClassGenericType(NamedObjectSave namedObjectSave, object oldValue)
        {
            namedObjectSave.UpdateCustomProperties();

            if (ObjectFinder.Self.GetEntitySave(namedObjectSave.SourceClassGenericType) != null)
            {
                namedObjectSave.AddToManagers = true;
            }

            var baseNos = namedObjectSave;
            var element = EditorLogic.CurrentElement;

            if (baseNos.SetByDerived)
            {
                List<IElement> derivedElements = new List<IElement>();
                if (element is EntitySave)
                {
                    derivedElements.AddRange(ObjectFinder.Self.GetAllEntitiesThatInheritFrom(element as EntitySave));
                }
                else
                {
                    derivedElements.AddRange(ObjectFinder.Self.GetAllScreensThatInheritFrom(element as ScreenSave));
                }

                foreach (IElement derivedElement in derivedElements)
                {
                    NamedObjectSave derivedNos = derivedElement.GetNamedObjectRecursively(baseNos.InstanceName);

                    if (derivedNos != baseNos)
                    {
                        UpdateDerivedNosFromBase(baseNos, derivedNos);
                    }
                }
            }

            ProjectManager.UpdateAllDerivedElementFromBaseValues(false, true);
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:37,代码来源:NamedObjectSetVariableLogic.cs

示例8: CreateNamedObjectWithSetVariable

        private void CreateNamedObjectWithSetVariable()
        {
            mNamedObjectWithSetVariable = new NamedObjectSave();
            mNamedObjectWithSetVariable.InstanceName = "SpriteObject";
            // This will be complicated because it requires FRB to be instantiated!
            //mNamedObjectWithSetVariable.SourceType = SourceType.File;
            //mNamedObjectWithSetVariable.SourceFile = "Entities/StateTestEntity/SceneFile.scnx";
            //mNamedObjectWithSetVariable.SourceName = "Untextured (Sprite)";

            mNamedObjectWithSetVariable.SourceType = SourceType.FlatRedBallType;
            mNamedObjectWithSetVariable.SourceClassType = "Sprite";

            mNamedObjectWithSetVariable.UpdateCustomProperties();
            mNamedObjectWithSetVariable.SetPropertyValue("Y", 10.0f);

            mEntitySave.NamedObjects.Add(mNamedObjectWithSetVariable);
            
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:18,代码来源:StateTests.cs

示例9: CreateContainerEntitySave

        private void CreateContainerEntitySave()
        {
            mContainerEntitySave = new EntitySave();
            mContainerEntitySave.Name = "ContainerCustomVariableEntity";

            mBaseNosInContainer = new NamedObjectSave();
            mBaseNosInContainer.InstanceName = mEntitySave.Name + "Instance";
            mBaseNosInContainer.SourceType = SourceType.Entity;
            mBaseNosInContainer.SourceClassType = mEntitySave.Name;
            mContainerEntitySave.NamedObjects.Add(mBaseNosInContainer);

            CustomVariable customVariable = new CustomVariable();
            customVariable.Name = "TunneledCategorizedStateVariable";
            customVariable.SourceObject = mBaseNosInContainer.InstanceName;
            customVariable.SourceObjectProperty = "CurrentStateCategoryState";
            customVariable.Type = "StateCategory";
            mContainerEntitySave.CustomVariables.Add(customVariable);

            mDerivedNosInContainer = new NamedObjectSave();
            mDerivedNosInContainer.InstanceName = "DerivedNosInContainer";
            mDerivedNosInContainer.SourceType = SourceType.Entity;
            mDerivedNosInContainer.SourceClassType = mDerivedEntitySave.Name;
            mDerivedNosInContainer.UpdateCustomProperties();
            mContainerEntitySave.NamedObjects.Add(mDerivedNosInContainer);


            ObjectFinder.Self.GlueProject.Entities.Add(mContainerEntitySave);
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:28,代码来源:CustomVariableTests.cs

示例10: TestSetPropertyValue

        public void TestSetPropertyValue()
        {
            NamedObjectSave nos = new NamedObjectSave();
            nos.SourceType = SourceType.FlatRedBallType;
            nos.SourceClassType = "Sprite";

            nos.UpdateCustomProperties();
            nos.SetPropertyValue("Texture", "redball");

            if (nos.InstructionSaves.Count == 0)
            {
                throw new Exception("There should be a Texture instruction save");
            }

            if (nos.InstructionSaves.First(instruction => instruction.Member == "Texture").Type != "Texture2D")
            {
                throw new Exception("The instruction should be of type Texture2D, but it's not");
            }

        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:20,代码来源:NamedObjectSaveTests.cs

示例11: CreateElementRuntime

        void CreateElementRuntime(string name)
        {
            var entitySave = new EntitySave {Name = name};

            ObjectFinder.Self.GlueProject.Entities.Add(entitySave);

            #region Create CustomVariables
            var xVariable = new CustomVariable
                                {
                                    Name = "X", 
                                    Type = "float", 
                                    DefaultValue = 3.0f
                                };
            entitySave.CustomVariables.Add(xVariable);

            var yVariable = new CustomVariable
                                {
                                    Name = "Y", 
                                    Type = "float", 
                                    DefaultValue = 4.0f
                                };
            entitySave.CustomVariables.Add(yVariable);


            var customVariable = new CustomVariable
                                {
                                    Name = "SomeNewVar",
                                    Type = "double",
                                    DefaultValue = 3.333
                                };
            entitySave.CustomVariables.Add(customVariable);

            var csvTypeVAriable = new CustomVariable
                                {
                                    Name = "CsvTypeVariable",
                                    Type = "CsvType.csv",
                                    DefaultValue = null

                                };
            entitySave.CustomVariables.Add(csvTypeVAriable);

            var csvTypeVariable2 = new CustomVariable
                                {
                                    Name = "EnemyInfoVariable",
                                    Type = "EnemyInfo.csv",
                                    DefaultValue = "Imp"

                                };
            entitySave.CustomVariables.Add(csvTypeVariable2);

            var scaleXVariable = new CustomVariable
            {
                Name = "ScaleX",
                Type = "float",
                DefaultValue = 10.0f
            };
            entitySave.CustomVariables.Add(scaleXVariable);


            #endregion

            #region Create the NamedObjectsSave

            NamedObjectSave nos = new NamedObjectSave();
            nos.SourceType = SourceType.FlatRedBallType;
            nos.SourceClassType = "Sprite";
            nos.InstanceName = "SpriteObject";
            nos.UpdateCustomProperties();
            nos.SetPropertyValue("ScaleX", 3.0f);
            entitySave.NamedObjects.Add(nos);


            #endregion

            #region Create the ReferencedFileSaves

            ReferencedFileSave rfs = new ReferencedFileSave();
            rfs.Name = "Content/Entities/ReferencedFileSaveTestsBaseEntity/SceneFile.scnx";
            entitySave.ReferencedFiles.Add(rfs);

            rfs = new ReferencedFileSave();
            rfs.Name = "Content/EnemyInfo.csv";
            rfs.CreatesDictionary = true;

            entitySave.ReferencedFiles.Add(rfs);


            #endregion

            mElementRuntime = new ElementRuntime(entitySave, null, null, null, null)
                                  {
                                      X = (float) xVariable.DefaultValue, 
                                      Y = (float) yVariable.DefaultValue
                                  };


            #region Create the uncategorized states

            var leftX = new InstructionSave
            {
//.........这里部分代码省略.........
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:101,代码来源:ExpressionParserTests.cs

示例12: CreateContainerElementRuntime

        void CreateContainerElementRuntime()
        {

            EntitySave containerEntitySave = new EntitySave { Name = "ContainerVariableSetting" };
            ObjectFinder.Self.GlueProject.Entities.Add(containerEntitySave);
            NamedObjectSave nos = new NamedObjectSave();
            nos.SourceType = SourceType.Entity;
            nos.InstanceName = mEntitySave.Name + "Instance";
            nos.SourceClassType = mEntitySave.Name;
            containerEntitySave.NamedObjects.Add(nos);

            nos.UpdateCustomProperties();
            nos.SetPropertyValue("CurrentStateSaveCategoryState", "SecondState");

            mContainedElementRuntime = new ElementRuntime(containerEntitySave, null, null, null, null);

            // This thing is attached - we need to check its relativeX
            //if (mContainedElementRuntime.ContainedElements[0].X != -10.0f)
            if (mContainedElementRuntime.ContainedElements[0].RelativeX != -10.0f)
            {
                throw new Exception("Categorized states on contained NamedObjectSave Elements aren't setting values properly");
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:23,代码来源:VariableSetting.cs

示例13: CreateNewNamedObjectInElement

        internal static NamedObjectSave CreateNewNamedObjectInElement(IElement elementToCreateIn, EntitySave blueprintEntity, bool createList = false)
        {
            if (elementToCreateIn is EntitySave && ((EntitySave)elementToCreateIn).ImplementsIVisible && !blueprintEntity.ImplementsIVisible)
            {
                MultiButtonMessageBox mbmb = new MultiButtonMessageBox();
                mbmb.MessageText = "The Entity\n\n" + blueprintEntity + "\n\nDoes not Implement IVisible, but the Entity it is being dropped in does.  " +
                    "What would you like to do?";

                mbmb.AddButton("Make " + blueprintEntity.Name + " implement IVisible", DialogResult.OK);
                mbmb.AddButton("Nothing (your code will not compile until this problem is resolved manually)", DialogResult.Cancel);

                DialogResult result = mbmb.ShowDialog(MainGlueWindow.Self);
                if (result == DialogResult.OK)
                {
                    blueprintEntity.ImplementsIVisible = true;
                    CodeGeneratorIElement.GenerateElementDerivedAndReferenced(blueprintEntity);
                }

            }

            BaseElementTreeNode elementTreeNode = GlueState.Self.Find.ElementTreeNode(elementToCreateIn);

            //EntityTreeNode entityTreeNode =
            //    ElementViewWindow.GetEntityTreeNode(entityToCreateIn); 

            NamedObjectSave newNamedObject = new NamedObjectSave();

            // We'll add "List" or "Instance" below
            string newName = FileManager.RemovePath(blueprintEntity.Name);

            #region Set the source type properties for the new NamedObject

            if (createList)
            {
                newName += "List";
                newNamedObject.SourceType = SourceType.FlatRedBallType;
                newNamedObject.SourceClassType = "PositionedObjectList<T>";
                newNamedObject.SourceClassGenericType = blueprintEntity.Name;
                newNamedObject.UpdateCustomProperties();
            }
            else
            {
                newName += "Instance";
                newNamedObject.SourceType = SourceType.Entity;
                newNamedObject.SourceClassType = blueprintEntity.Name;
                newNamedObject.UpdateCustomProperties();
            }

            #endregion

            #region Set the name for the new NamedObject

            // get an acceptable name for the new object
            if (elementToCreateIn.GetNamedObjectRecursively(newName) != null)
            {
                newName += "2";
            }

            while (elementToCreateIn.GetNamedObjectRecursively(newName) != null)
            {
                newName = StringFunctions.IncrementNumberAtEnd(newName);
            }

            newNamedObject.InstanceName = newName;


            #endregion

            // We need to add to managers here.  Why?  Because normally when the type of a NamedObject is changed, 
            // the PropertyGrid handles setting whether it should be added or not. But in this case, we're not changing
            // the type of the new NamedObject through the PropertyGrid - instead it's being set programatically to be an
            // Entity.  So, we should add to managers programatically since the PropertyGrid won't do it for us.
            // Update December 11, 2011
            // AddToManagers defaults to
            // true on new NamedObjectSaves
            // so there's no need to explicitly
            // set it to true here.
            //newNamedObject.AddToManagers = true;


            NamedObjectSaveExtensionMethodsGlue.AddNewNamedObjectToElementTreeNode(elementTreeNode, newNamedObject, true);

            return newNamedObject;
        }
开发者ID:gitter-badger,项目名称:FlatRedBall,代码行数:84,代码来源:ElementViewWindow.DragDrop.cs

示例14: UpdateShownVariables

        public static void UpdateShownVariables(DataUiGrid grid, NamedObjectSave instance, IElement container)
        {
            grid.Categories.Clear();

            List<MemberCategory> categories = new List<MemberCategory>();
            var defaultCategory = new MemberCategory("Variables");
            defaultCategory.FontSize = 14;
            categories.Add(defaultCategory);

            AssetTypeInfo ati = instance.GetAssetTypeInfo();

            // not sure if this is needed:
            if (instance.TypedMembers.Count == 0)
            {
                instance.UpdateCustomProperties();
            }

            for (int i = 0; i < instance.TypedMembers.Count; i++)
            {

                TypedMemberBase typedMember = instance.TypedMembers[i];
                InstanceMember instanceMember = CreateInstanceMember(instance, container, typedMember, ati);

                var categoryToAddTo = GetOrCreateCategoryToAddTo(categories, ati, typedMember);

                if (instanceMember != null)
                {
                    categoryToAddTo.Members.Add(instanceMember);
                }
            }

            if (ati != null)
            {
                SortCategoriesAndMembers(ref categories, ati);
            }

            if (defaultCategory.Members.Count == 0)
            {
                categories.Remove(defaultCategory);
            }
            else if(categories.Count != 1)
            {
                defaultCategory.Name = "Other Variables";
            }

            if (categories.Count != 0)
            {
                // "Name" shoul be the very first property:
                var nameCategory = CreateNameInstanceMember(instance);
                //categories.Add(nameCategory);
                categories.Insert(0, nameCategory);
                //categories.First().Members.Insert(0, nameInstanceMember);
            }

            // skip the first category in putting the alternating colors:
            for (int i = 0; i < categories.Count; i++)
            {
                var category = categories[i];
                if (i != 0)
                {
                    const byte brightness = 227;
                    category.SetAlternatingColors(new SolidColorBrush(Color.FromRgb(brightness, brightness, brightness)), Brushes.Transparent);
                }
                grid.Categories.Add(category);
            }
            grid.Refresh();
        }
开发者ID:gitter-badger,项目名称:FlatRedBall,代码行数:67,代码来源:NamedObjectVariableShowingLogic.cs

示例15: UpdateDerivedNosFromBase

        private void UpdateDerivedNosFromBase(NamedObjectSave baseNos, NamedObjectSave derivedNos)
        {
            if (baseNos.IsList && !string.IsNullOrEmpty(baseNos.SourceClassGenericType))
            {
                derivedNos.SourceType = baseNos.SourceType;
                derivedNos.SourceClassType = baseNos.SourceClassType;
                derivedNos.SourceClassGenericType = baseNos.SourceClassGenericType;
                derivedNos.UpdateCustomProperties();

            }

        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:12,代码来源:NamedObjectSetVariableLogic.cs


注:本文中的FlatRedBall.Glue.SaveClasses.NamedObjectSave.UpdateCustomProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。