コード例 #1
0
        public static AccessoryImageSet[] LoadDefinitionFile()
        {
            XmlTextReader            reader = new XmlTextReader(new Uri("AccessoryImageSets.xml", UriKind.Relative).ToString());
            List <AccessoryImageSet> sets   = new List <AccessoryImageSet>();
            AccessoryImageSet        set    = null;

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "AccessoryImageSet")
                {
                    set      = new AccessoryImageSet();
                    set.Name = reader.GetAttribute("ID");
                    set.FrequencyPercentage = int.Parse(reader.GetAttribute("Frequency"));
                    sets.Add(set);
                }
                else if (reader.NodeType == XmlNodeType.Element && reader.Name == "ImageJointCombo")
                {
                    Image img = new Image();
                    img.Source = new BitmapImage(new Uri(reader.GetAttribute("Image"), UriKind.Relative));
                    JointType       jt    = (JointType)Enum.Parse(typeof(JointType), reader.GetAttribute("JointType"));
                    Vector          vec   = new Vector(double.Parse(reader.GetAttribute("OffsetX")), double.Parse(reader.GetAttribute("OffsetY")));
                    ImageJointCombo combo = new ImageJointCombo(img, jt, vec, set.Name);

                    set.AddImageJointCombo(combo);
                }
            }

            AccessoryImageSet[] returnSets = new AccessoryImageSet[sets.Count];
            for (int i = 0; i < sets.Count; i++)
            {
                returnSets[i] = sets[i];
            }

            return(returnSets);
        }
コード例 #2
0
 private void LoadAccessoryImages()
 {
     Accessories = AccessoryImageSet.LoadDefinitionFile();
 }