Esempio n. 1
0
        /// <summary>
        /// Method that handles the Property XML element.
        /// </summary>
        /// <param name="attributes"></param>
        private void ElementPropertyStart(XMLAttributes attributes)
        {
            // get property name
            var propertyName = attributes.GetValueAsString(Property.NameXMLAttributeName);

            // get property value string
            var propertyValue = String.Empty;

            if (attributes.Exists(Property.ValueXMLAttributeName))
            {
                propertyValue = attributes.GetValueAsString(Property.ValueXMLAttributeName);
            }

            // Short property
            if (!String.IsNullOrEmpty(propertyValue))
            {
                d_stringItemName = String.Empty;
                try
                {
                    // need a window to be able to set properties!
                    if (d_stack.Count != 0)
                    {
                        // get current window being defined.
                        var curwindow = d_stack[d_stack.Count - 1].Item1;

                        var useit = true;

                        // if client defined a callback, call it and discover if we should
                        // set the property.
                        if (d_propertyCallback != null)
                        {
                            useit = d_propertyCallback(curwindow,
                                                       propertyName,
                                                       propertyValue,
                                                       d_userData);
                        }
                        // set the property as needed
                        if (useit)
                        {
                            curwindow.SetProperty(propertyName, propertyValue);
                        }
                    }
                }
                catch (Exception)
                {
                    // Don't do anything here, but the error will have been logged.
                }
            }
            // Long property
            else
            {
                // Store name for later use
                d_stringItemName = propertyName;
                // reset the property value buffer
                d_stringItemValue = String.Empty;
            }
        }
Esempio n. 2
0
        private void ElementImageStart(XMLAttributes attributes)
        {
            var image_name = s_texture.GetName() + '/' + attributes.GetValueAsString(ImageNameAttribute);

            if (IsDefined(image_name))
            {
                System.GetSingleton().Logger.LogEvent("[ImageManager] WARNING: Using existing image :" + image_name);
                return;
            }

            XMLAttributes rwAttrs = attributes;

            // rewrite the name attribute to include the texture name
            rwAttrs.Add(ImageNameAttribute, image_name);

            if (!rwAttrs.Exists(ImageTextureAttribute))
            {
                rwAttrs.Add(ImageTextureAttribute, s_texture.GetName());
            }

            if (!rwAttrs.Exists(ImagesetAutoScaledAttribute))
            {
                rwAttrs.Add(ImagesetAutoScaledAttribute, s_autoScaled.ToString());
            }

            if (!rwAttrs.Exists(ImagesetNativeHorzResAttribute))
            {
                rwAttrs.Add(ImagesetNativeHorzResAttribute,
                            s_nativeResolution.Width.ToString(CultureInfo.InvariantCulture));
            }

            if (!rwAttrs.Exists(ImagesetNativeVertResAttribute))
            {
                rwAttrs.Add(ImagesetNativeVertResAttribute,
                            s_nativeResolution.Height.ToString(CultureInfo.InvariantCulture));
            }

            DeleteChaniedHandler = false;
            ChainedHandler       = Create(rwAttrs);
        }
Esempio n. 3
0
        /// <summary>
        /// Method that handles the UserString XML element.
        /// </summary>
        /// <param name="attributes"></param>
        private void ElementUserStringStart(XMLAttributes attributes)
        {
            // Get user string name
            var userStringName = attributes.GetValueAsString(Window.UserStringNameXMLAttributeName);

            // Get user string value
            var userStringValue = String.Empty;

            if (attributes.Exists(Window.UserStringValueXMLAttributeName))
            {
                userStringValue = attributes.GetValueAsString(Window.UserStringValueXMLAttributeName);
            }

            // Short user string
            if (!String.IsNullOrEmpty(userStringValue))
            {
                d_stringItemName = null;
                try
                {
                    // need a window to be able to set properties!
                    if (d_stack.Count != 0)
                    {
                        // get current window being defined.
                        var curwindow = d_stack[d_stack.Count - 1].Item1;

                        curwindow.SetUserString(userStringName, userStringValue);
                    }
                }
                catch (Exception)
                {
                    // Don't do anything here, but the error will have been logged.
                }
            }
            // Long user string
            else
            {
                // Store name for later use
                d_stringItemName = userStringName;
                // reset the property (user string) value buffer
                d_stringItemValue = null;
            }
        }