void GetElemValue(XmlReader r, string type, out object elem) { char[] div = {','}; string val = r.ReadElementContentAsString(); switch (type) { case "int" : int vint = Convert.ToInt32(val); elem = new System.Int32(vint); break; case "uint" : int vuint = Convert.ToUInt32(val); elem = new System.UInt32(vint); break; case "float" : float v = Convert.ToSingle(val); elem = new System.Single(v); break; case "double" : double v = Convert.ToDouble(val); elem = new System.Double(v); break; case "Size" : string[] comp = val.Split(div); elem = new Size(Convert.ToInt32(comp[0].Trim()), Convert.ToInt32(comp[1].Trim())); break; case "Point" : string[] comp = val.Split(div); elem = new Point(Convert.ToInt32(comp[0].Trim()), Convert.ToInt32(comp[1].Trim())); break; case "wxColor" : string[] comp = val.Split(div); elem = new wxColor(Convert.ToByte(comp[0].Trim()), Convert.ToByte(comp[1].Trim()), Convert.ToByte(comp[2].Trim())); break; case "wxFont" : string[] comp = val.Split(div); elem = new wxFont(comp[0].Trim(), Convert.ToInt32(comp[1].Trim()), Convert.ToByte(comp[2].Trim())); break; case "wxFlags" : if (elem == null) elem = new wxFlags(); wxFlags fl = (wxFlags)elem; string[] comp = val.Split(div); fl.AddItem(comp[0].Trim(), Convert.ToInt32(comp[1].Trim()), Convert.ToBoolean(comp[2].Trim())); break; case "bool": bool v = Convert.ToBoolean(val); elem = new System.Boolean(v); break; } return elem; }
void GetElemDefault(XmlReader r, string type, out object elem) { switch (type) { case "int" : elem = (int)0; case "uint" : elem = (uint)0; case "float" : elem = 0.0f; case "double" : elem = 0.0; case "Size" : elem = new Size(-1, -1); case "Point" : elem = new Point(-1, -1); case "wxColor" : elem = new wxColor(0, 0 ,0); case "wxFont" : elem = new wxFont("Arial", 8); case "wxFlags" : elem = new wxFlags(); case "bool": elem = true; } }