Esempio n. 1
0
        public void TryCreateFontFileFor(InstanceSave instance, StateSave stateSave)
        {
            string prefix = "";

            if (instance != null)
            {
                prefix = instance.Name + ".";
            }

            int?fontSize     = stateSave.GetValueRecursive(prefix + "FontSize") as int?;
            var fontValue    = (string)stateSave.GetValueRecursive(prefix + "Font");
            int outlineValue = stateSave.GetValueRecursive(prefix + "OutlineThickness") as int? ?? 0;

            // default to true to match how old behavior worked
            bool fontSmoothing = stateSave.GetValueRecursive(prefix + "UseFontSmoothing") as bool? ?? true;
            bool isItalic      = stateSave.GetValueRecursive(prefix + "IsItalic") as bool? ?? false;

            if (fontValue != null && fontSize != null)
            {
                BmfcSave.CreateBitmapFontFilesIfNecessary(
                    fontSize.Value,
                    fontValue,
                    outlineValue,
                    fontSmoothing, isItalic);
            }
        }
        public object GetValue(string variableName)
        {
            switch (ContainerType)
            {
            case VariableContainerType.InstanceSave:

#if DEBUG
                if (ElementStack.Count != 0)
                {
                    if (ElementStack.Last().Element == null)
                    {
                        throw new InvalidOperationException("The ElementStack contains an ElementWithState with no Element");
                    }
                }
#endif

                VariableSave variable = GetVariable(variableName);
                if (variable != null)
                {
                    return(variable.Value);
                }
                else
                {
                    return(null);
                }

            //return mInstanceSave.GetValueFromThisOrBase(mElementStack, variableName);
            //break;
            case VariableContainerType.StateSave:
                return(mStateSave.GetValueRecursive(variableName));
                //break;
            }

            throw new NotImplementedException();
        }
Esempio n. 3
0
        public void TryCreateFontFileFor(InstanceSave instance, StateSave stateSave)
        {
            string prefix = "";

            if (instance != null)
            {
                prefix = instance.Name + ".";
            }

            int?   fontSize         = null;
            object fontSizeAsObject = stateSave.GetValueRecursive(prefix + "FontSize");

            if (fontSizeAsObject != null)
            {
                fontSize = (int)fontSizeAsObject;
            }

            var fontValue =
                (string)stateSave.GetValueRecursive(prefix + "Font");

            int?outlineValue         = 0;
            var outlineValueAsObject = stateSave.GetValueRecursive(prefix + "OutlineThickness");

            if (outlineValueAsObject != null)
            {
                outlineValue = (int)outlineValueAsObject;
            }

            // default to true to match how old behavior worked
            bool fontSmoothing         = true;
            var  fontSmoothingAsObject = stateSave.GetValueRecursive(prefix + "UseFontSmoothing");

            if (fontSmoothingAsObject != null)
            {
                fontSmoothing = (bool)fontSmoothingAsObject;
            }

            if (fontValue != null && fontSize != null && outlineValue != null)
            {
                BmfcSave.CreateBitmapFontFilesIfNecessary(
                    fontSize.Value,
                    fontValue,
                    outlineValue.Value,
                    fontSmoothing);
            }
        }
Esempio n. 4
0
        internal void ReactToFontValueSet()
        {
            StateSave stateSave = SelectedState.Self.SelectedStateSave;

            string prefix = "";

            if (SelectedState.Self.SelectedInstance != null)
            {
                prefix = SelectedState.Self.SelectedInstance.Name + ".";
            }

            object fontSizeAsObject = stateSave.GetValueRecursive(prefix + "FontSize");

            BmfcSave.CreateBitmapFontFilesIfNecessary(
                (int)fontSizeAsObject,
                (string)stateSave.GetValueRecursive(prefix + "Font"),
                0);
        }
        private object HandleCustomGet(object instance)
        {
            if (mPropertyDescriptor != null)
            {
                var toReturn = mPropertyDescriptor.GetValue(instance);

                if (toReturn == null)
                {
                    toReturn = mStateSave.GetValueRecursive(mVariableName);
                }

                return(toReturn);
            }
            else
            {
                return(mStateSave.GetValue(mVariableName));
            }
        }
Esempio n. 6
0
        public void Test()
        {
            StateSave defaultState = mElementSaveCollection.Screen.DefaultState;

            object value = defaultState.GetValueRecursive("ButtonInstance.X");

            if (value == null)
            {
                throw new Exception("StateSave.GetValueRecursive is not properly returning values");
            }

            VariableSave variableSave = defaultState.GetVariableRecursive("ButtonInstance.X");

            if (variableSave == null)
            {
                throw new Exception("StateSave.GetVariableSaveRecursively is not finding values");
            }
        }