Example #1
0
            public override object GetValue(object component)
            {
                try
                {
                    if (m_font == null)
                    {
                        DomNode   param     = m_domObject.GetChild(SkinSchema.valueInfoType.constructorParamsChild);
                        string    fname     = null;
                        float     fontSize  = 1.0f;
                        FontStyle fontStyle = FontStyle.Regular;

                        foreach (var arg in param.GetChildren(SkinSchema.constructorParamsType.valueInfoChild))
                        {
                            string typeName = (string)arg.GetAttribute(SkinSchema.valueInfoType.typeAttribute);
                            Type   type     = SkinUtil.GetType(typeName);
                            string val      = (string)arg.GetAttribute(SkinSchema.valueInfoType.valueAttribute);

                            if (type == typeof(string))
                            {
                                fname = val;
                            }
                            else if (type == typeof(float))
                            {
                                fontSize = float.Parse(val);
                            }
                            else if (type == typeof(FontStyle))
                            {
                                fontStyle = (FontStyle)Enum.Parse(typeof(FontStyle), val);
                            }
                        }
                        m_font = new Font(fname, fontSize, fontStyle);
                    }
                }
                catch { } // suppress parsing error.

                return(m_font);
            }
Example #2
0
            private void ProcessValueInfo(DomNode valInfo, string propName,
                                          List <System.ComponentModel.PropertyDescriptor> descriptors)
            {
                string typeName = (string)valInfo.GetAttribute(SkinSchema.valueInfoType.typeAttribute);
                Type   type     = SkinUtil.GetType(typeName);


                if (type == typeof(Font))
                {
                    FontDescriptor descr
                        = new FontDescriptor(valInfo, propName, null, null, null, null);
                    descriptors.Add(descr);
                }
                else
                {
                    TypeConverter converter;
                    object        editor;
                    GetEditorAndConverter(type, out editor, out converter);
                    if (editor != null)
                    {
                        var descr = new SkinSetterAttributePropertyDescriptor(valInfo
                                                                              , propName, SkinSchema.valueInfoType.valueAttribute, null, null, false, editor, converter);
                        descriptors.Add(descr);
                    }
                    else
                    {
                        DomNode ctorParams = valInfo.GetChild(SkinSchema.valueInfoType.constructorParamsChild);
                        if (ctorParams != null)
                        {
                            var vInfoChildList = ctorParams.GetChildList(SkinSchema.constructorParamsType.valueInfoChild);
                            if (vInfoChildList.Count == 1)
                            {
                                ProcessValueInfo(vInfoChildList[0], propName, descriptors);
                            }
                            else
                            {
                                // special handling for SyntaxEditorControl
                                if (typeName == "Sce.Atf.Controls.SyntaxEditorControl.TextHighlightStyle")
                                {
                                    string argName =
                                        (string)vInfoChildList[0].GetAttribute(SkinSchema.valueInfoType.valueAttribute);

                                    string name = propName + "->" + argName;
                                    ProcessValueInfo(vInfoChildList[1], name, descriptors);
                                }
                                else
                                {
                                    int    k         = 1;
                                    string paramName = propName + " : Arg_";
                                    foreach (DomNode vInfoChild in vInfoChildList)
                                    {
                                        string name = paramName + k;
                                        ProcessValueInfo(vInfoChild, name, descriptors);
                                        k++;
                                    }
                                }
                            }
                        }

                        foreach (DomNode setterChild in valInfo.GetChildList(SkinSchema.valueInfoType.setterChild))
                        {
                            ProcessSetterType(setterChild, propName, descriptors);
                        }
                    }
                }
            }