Esempio n. 1
0
        private static void TryDisplayVariableSave(List <InstanceSavePropertyDescriptor> pdc, ElementSave elementSave, InstanceSave instanceSave,
                                                   AmountToDisplay amountToDisplay, VariableSave defaultVariable)
        {
            ElementSave container = elementSave;

            if (instanceSave != null)
            {
                container = instanceSave.ParentContainer;
            }

            // Not sure why we were passing elementSave to this function:
            // I added a container object
            //bool shouldInclude = GetIfShouldInclude(defaultVariable, elementSave, instanceSave, ses);
            bool shouldInclude = Gum.Logic.VariableSaveLogic.GetIfVariableIsActive(defaultVariable, container, instanceSave);

            shouldInclude &= (
                string.IsNullOrEmpty(defaultVariable.SourceObject) ||
                amountToDisplay == AmountToDisplay.AllVariables ||
                !string.IsNullOrEmpty(defaultVariable.ExposedAsName));

            if (shouldInclude)
            {
                TypeConverter typeConverter = defaultVariable.GetTypeConverter(elementSave);

                Attribute[] customAttributes = GetAttributesForVariable(defaultVariable);

                string category = null;
                if (!string.IsNullOrEmpty(defaultVariable.Category))
                {
                    category = defaultVariable.Category;
                }
                else if (!string.IsNullOrEmpty(defaultVariable.ExposedAsName))
                {
                    category = "Exposed";
                }

                //Type type = typeof(string);
                Type type = Gum.Reflection.TypeManager.Self.GetTypeFromString(defaultVariable.Type);

                string name = defaultVariable.Name;

                if (!string.IsNullOrEmpty(defaultVariable.ExposedAsName))
                {
                    name = defaultVariable.ExposedAsName;
                }

                var property = mHelper.AddProperty(pdc,
                                                   name,
                                                   type,
                                                   typeConverter,
                                                   //,
                                                   customAttributes
                                                   );
                property.Category = category;
            }
        }
Esempio n. 2
0
        private static PropertyDescriptorCollection TryDisplayVariableSave(PropertyDescriptorCollection pdc, ElementSave elementSave, InstanceSave instanceSave,
                                                                           AmountToDisplay amountToDisplay, StandardElementSave ses, VariableSave defaultVariable)
        {
            ElementSave container = elementSave;

            if (instanceSave != null)
            {
                container = instanceSave.ParentContainer;
            }

            // Not sure why we were passing elementSave to this function:
            // I added a container object
            //bool shouldInclude = GetIfShouldInclude(defaultVariable, elementSave, instanceSave, ses);
            bool shouldInclude = GetIfShouldInclude(defaultVariable, container, instanceSave, ses);

            shouldInclude &= (
                string.IsNullOrEmpty(defaultVariable.SourceObject) ||
                amountToDisplay == AmountToDisplay.AllVariables ||
                !string.IsNullOrEmpty(defaultVariable.ExposedAsName));

            if (shouldInclude)
            {
                TypeConverter typeConverter = defaultVariable.GetTypeConverter(elementSave);

                Attribute[] customAttributes = GetAttributesForVariable(defaultVariable);


                //Type type = typeof(string);
                Type type = Gum.Reflection.TypeManager.Self.GetTypeFromString(defaultVariable.Type);

                string name = defaultVariable.Name;

                if (!string.IsNullOrEmpty(defaultVariable.ExposedAsName))
                {
                    name = defaultVariable.ExposedAsName;
                }

                pdc = mHelper.AddProperty(pdc,
                                          name,
                                          type,
                                          typeConverter,
                                          //,
                                          customAttributes
                                          );
            }
            return(pdc);
        }
Esempio n. 3
0
        private static PropertyDescriptorCollection DisplayCurrentElement(PropertyDescriptorCollection pdc, ElementSave elementSave,
                                                                          InstanceSave instanceSave, StateSave defaultState, string prependedVariable, AmountToDisplay amountToDisplay = AmountToDisplay.AllVariables)
        {
            bool isDefault = SelectedState.Self.SelectedStateSave == SelectedState.Self.SelectedElement.DefaultState;

            if (!string.IsNullOrEmpty(prependedVariable))
            {
                prependedVariable += ".";
            }

            bool isCustomType = (elementSave is StandardElementSave) == false;

            if (isDefault && (isCustomType || instanceSave != null))
            {
                pdc = AddNameAndBaseTypeProperties(pdc);
            }

            if (instanceSave != null)
            {
                if (isDefault)
                {
                    pdc = mHelper.AddProperty(pdc, "Locked", typeof(bool));
                }
            }

            // if component
            if (instanceSave == null && elementSave as ComponentSave != null)
            {
                foreach (var item in StandardElementsManager.Self.GetDefaultStateFor("Component").Variables)
                {
                    pdc = TryDisplayVariableSave(pdc, elementSave, instanceSave, amountToDisplay, null, item);
                }
            }
            // else if screen
            else if (instanceSave == null && elementSave as ScreenSave != null)
            {
                foreach (var item in StandardElementsManager.Self.GetDefaultStateFor("Screen").Variables)
                {
                    pdc = TryDisplayVariableSave(pdc, elementSave, instanceSave, amountToDisplay, null, item);
                }
            }



            #region Get the StandardElementSave for the instance/element (depending on what's selected)

            StandardElementSave ses = null;

            if (instanceSave != null)
            {
                ses = ObjectFinder.Self.GetRootStandardElementSave(instanceSave);
            }
            else if ((elementSave is ScreenSave) == false)
            {
                ses = ObjectFinder.Self.GetRootStandardElementSave(elementSave);
            }

            #endregion

            #region Loop through all variables

            // We want to use the default state to get all possible
            // variables because the default state will always set all
            // variables.  We then look at the current state to get the
            // actual value
            for (int i = 0; i < defaultState.Variables.Count; i++)
            {
                VariableSave defaultVariable = defaultState.Variables[i];

                pdc = TryDisplayVariableSave(pdc, elementSave, instanceSave, amountToDisplay, ses, defaultVariable);
            }

            #endregion


            #region Loop through all list variables

            for (int i = 0; i < defaultState.VariableLists.Count; i++)
            {
                VariableListSave variableList = defaultState.VariableLists[i];

                bool shouldInclude = GetIfShouldInclude(variableList, elementSave, instanceSave, null);

                if (shouldInclude)
                {
                    TypeConverter typeConverter = variableList.GetTypeConverter();

                    Attribute[] customAttributes = GetAttributesForVariable(variableList);


                    Type type = typeof(List <string>);



                    pdc = mHelper.AddProperty(pdc,
                                              variableList.Name,
                                              type,
                                              typeConverter,
                                              //    //,
                                              customAttributes
                                              );
                }
            }



            #endregion



            return(pdc);
        }
Esempio n. 4
0
        private static void DisplayCurrentElement(List <InstanceSavePropertyDescriptor> pdc, ElementSave elementSave,
                                                  InstanceSave instanceSave, StateSave defaultState, string prependedVariable, AmountToDisplay amountToDisplay = AmountToDisplay.AllVariables)
        {
            bool isDefault = SelectedState.Self.SelectedStateSave == SelectedState.Self.SelectedElement.DefaultState;

            if (instanceSave?.DefinedByBase == true)
            {
                isDefault = false;
            }
            if (!string.IsNullOrEmpty(prependedVariable))
            {
                prependedVariable += ".";
            }

            bool isCustomType = (elementSave is StandardElementSave) == false;

            if (isCustomType || instanceSave != null)
            {
                AddNameAndBaseTypeProperties(pdc, elementSave, instanceSave, isReadOnly: isDefault == false);
            }

            if (instanceSave != null)
            {
                mHelper.AddProperty(pdc, "Locked", typeof(bool)).IsReadOnly = !isDefault;
            }

            // if component
            if (instanceSave == null && elementSave as ComponentSave != null)
            {
                var variables = StandardElementsManager.Self.GetDefaultStateFor("Component").Variables;
                foreach (var item in variables)
                {
                    // Don't add states here, because they're handled below from this object's Default:
                    if (item.IsState(elementSave) == false)
                    {
                        TryDisplayVariableSave(pdc, elementSave, instanceSave, amountToDisplay, item);
                    }
                }
            }
            // else if screen
            else if (instanceSave == null && elementSave as ScreenSave != null)
            {
                foreach (var item in StandardElementsManager.Self.GetDefaultStateFor("Screen").Variables)
                {
                    TryDisplayVariableSave(pdc, elementSave, instanceSave, amountToDisplay, item);
                }
            }



            #region Loop through all variables

            // We want to use the default state to get all possible
            // variables because the default state will always set all
            // variables.  We then look at the current state to get the
            // actual value
            for (int i = 0; i < defaultState.Variables.Count; i++)
            {
                VariableSave defaultVariable = defaultState.Variables[i];

                TryDisplayVariableSave(pdc, elementSave, instanceSave, amountToDisplay, defaultVariable);
            }

            #endregion


            #region Loop through all list variables

            for (int i = 0; i < defaultState.VariableLists.Count; i++)
            {
                VariableListSave variableList = defaultState.VariableLists[i];

                bool shouldInclude = GetIfShouldInclude(variableList, elementSave, instanceSave);

                if (shouldInclude)
                {
                    TypeConverter typeConverter = variableList.GetTypeConverter();

                    Attribute[] customAttributes = GetAttributesForVariable(variableList);


                    Type type = typeof(List <string>);



                    mHelper.AddProperty(pdc,
                                        variableList.Name,
                                        type,
                                        typeConverter,
                                        //    //,
                                        customAttributes
                                        );
                }
            }



            #endregion
        }