コード例 #1
0
ファイル: SkinEditor.cs プロジェクト: truongascii/LevelEditor
            public override void SetValue(object component, object value)
            {
                if (m_font != null && m_font.Equals(value))
                {
                    return;
                }

                if (m_font != null)
                {
                    m_font.Dispose();
                }
                m_font = (Font)value;

                DomNode param = m_domObject.GetChild(SkinSchema.valueInfoType.constructorParamsChild);

                foreach (var arg in param.GetChildren(SkinSchema.constructorParamsType.valueInfoChild))
                {
                    string typeName = (string)arg.GetAttribute(SkinSchema.valueInfoType.typeAttribute);

                    Type type = SkinUtil.GetType(typeName);
                    if (type == typeof(string))
                    {
                        arg.SetAttribute(SkinSchema.valueInfoType.valueAttribute, m_font.FontFamily.Name);
                    }
                    else if (type == typeof(float))
                    {
                        arg.SetAttribute(SkinSchema.valueInfoType.valueAttribute, m_font.Size.ToString());
                    }
                    else if (type == typeof(FontStyle))
                    {
                        arg.SetAttribute(SkinSchema.valueInfoType.valueAttribute, m_font.Style.ToString());
                    }
                }
            }
コード例 #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
                            {
                                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);
                        }
                    }
                }
            }
コード例 #3
0
ファイル: SkinEditor.cs プロジェクト: truongascii/LevelEditor
            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);
            }