예제 #1
0
        private static void GetMaterial(IdName name, XmlElement element)
        {
            Material   mat = null;
            XmlElement e   = element.GetElementsByTagName("instance_effect")[0] as XmlElement;
            Dictionary <string, XmlElement> par = e.GetParameters();
            string s = e.GetAttribute("url").Substring(1);
            IdName n = new IdName(s, s);

            e = nameElement[n];
            foreach (string key in materialCalc.Keys)
            {
                XmlNodeList nl = e.GetElementsByTagName(key);
                if (nl.Count == 1)
                {
                    mat = materialCalc[key](nl[0] as XmlElement);
                }
            }
            if (mat == null)
            {
            }
            materials[name] = mat;
            IdName nd = name.Double();

            if (nd != null)
            {
                materials[nd] = mat;
            }
        }
예제 #2
0
        private static T Find <T>(this IdName name) where T : class
        {
            IdName n = name.Double();

            if (sources.ContainsKey(name))
            {
                return(sources[name] as T);
            }
            if (n != null)
            {
                if (sources.ContainsKey(n))
                {
                    return(sources[n] as T);
                }
            }
            XmlElement e = name.Find();

            object[] o = actions[e.Name];
            if (o[1] is Dictionary <IdName, object> )
            {
                Dictionary <IdName, object> dd = o[1] as Dictionary <IdName, object>;
                if (!dd.ContainsKey(name))
                {
                    (o[0] as Action <IdName, XmlElement>)(name, e);
                }
                return(dd[name] as T);
            }
            Dictionary <IdName, T> d = o[1] as Dictionary <IdName, T>;

            if (!d.ContainsKey(name))
            {
                (o[0] as Action <IdName, XmlElement>)(name, e);
            }
            return(d[name]);
        }
예제 #3
0
        private static void SetDictionaryId(XmlElement element)
        {
            IdName id = element.ToIdName();

            if (id != null)
            {
                if (nameElement.ContainsKey(id))
                {
                }
                else
                {
                    nameElement[id] = element;
                }
                string name = element.GetAttribute("name");
                if (name.Length > 0)
                {
                    names[name] = element;
                }
            }
            XmlNodeList nl = element.ChildNodes;

            foreach (XmlNode n in nl)
            {
                if (n is XmlElement)
                {
                    SetDictionaryId(n as XmlElement);
                }
            }
        }
예제 #4
0
 private static double[] FindArray(IdName name)
 {
     if (!arrays.ContainsKey(name))
     {
         GetArray(name, nameElement[name]);
     }
     return(arrays[name]);
 }
예제 #5
0
        static void Add <T>(this XmlElement element, T t, Dictionary <IdName, T> dic) where T : class
        {
            IdName n = element.ToIdName();

            if (n != null)
            {
                if (!dic.ContainsKey(n))
                {
                    dic[n] = t;
                }
            }
        }
예제 #6
0
        static XmlElement Find(this IdName idName)
        {
            if (nameElement.ContainsKey(idName))
            {
                return(nameElement[idName]);
            }
            IdName id = idName.Double();

            if (nameElement.ContainsKey(id))
            {
                return(nameElement[id]);
            }
            return(null);
        }
예제 #7
0
 private static void GetArray(IdName name, XmlElement element)
 {
     if (arrays.ContainsKey(name))
     {
         return;
     }
     double[] x;
     if (sources.ContainsKey(name))
     {
         x = sources[name] as double[];
     }
     else
     {
         x = element.ToDoubleArray();
     }
     arrays[name] = x;
 }
예제 #8
0
 private static void GetSource(IdName name, XmlElement element)
 {
     if (sources.ContainsKey(name))
     {
         return;
     }
     foreach (string key in sourceDic.Keys)
     {
         XmlElement e = element.GetChild(key);
         if (e != null)
         {
             object o = sourceDic[key](e);
             element.Add <object>(o, sources);
             return;
         }
     }
 }
예제 #9
0
        private static void GetGeometry(IdName name, XmlElement element)
        {
            XmlElement e    = element.FirstChild as XmlElement;
            string     type = e.Name;

            ///!!!===============================

            /*   if (!element.GetAttribute("name").Equals("rudder"))
             * {
             *     visuals[name] = null;
             *     return;
             * }
             * //*/
            //!!!!=====================
            if (visualDic.ContainsKey(type))
            {
                Visual3D v3d = visualDic[type](e);
                visuals[name] = v3d;
            }
        }
예제 #10
0
파일: IdName.cs 프로젝트: Erroman/universal
        public override bool Equals(object obj)
        {
            IdName idn = obj as IdName;

            return(idn.name.Equals(name) & idn.id.Equals(id));
        }
예제 #11
0
        private static void GetImage(IdName name, XmlElement element)
        {
            ImageSource im = element.InnerText.ToImage();

            images[name] = im;
        }
예제 #12
0
 private static void GetVetrices(IdName name, XmlElement element)
 {
     double[] x = element.FindSource <double[]>();
     element.Add <object>(x, sources);
     element.Add <double[]>(x, arrays);
 }