Exemplo n.º 1
0
 private static void WriteTouchElementNode(XElement parent, Models.Panels.TouchElement element)
 {
     parent.Add(new XElement("Touch",
                             new XElement("Location", $"{element.LocationX}, {element.LocationY}"),
                             new XElement("Size", $"{element.SizeX}, {element.SizeY}"),
                             new XElement("JumpScreen", element.JumpScreen),
                             new XElement("SoundEntries", element.SoundEntries.Select(WriteTouchElementSoundEntryNode)),
                             new XElement("CommandEntries", element.CommandEntries.Select(WriteTouchElementCommandEntryNode)),
                             new XElement("Layer", element.Layer)
                             ));
 }
Exemplo n.º 2
0
 private static void WriteTouchElementNode(XElement parent, Models.Panels.TouchElement element)
 {
     parent.Add(new XElement("Touch",
                             new XElement("Location", $"{element.LocationX}, {element.LocationY}"),
                             new XElement("Size", $"{element.SizeX}, {element.SizeY}"),
                             new XElement("JumpScreen", element.JumpScreen),
                             new XElement("SoundIndex", element.SoundIndex),
                             new XElement("CommandInfo", element.CommandInfo.Command),
                             new XElement("CommandOption", element.CommandOption)
                             ));
 }
Exemplo n.º 3
0
        private static Models.Panels.TouchElement ParseTouchElementNode(Screen screen, XElement parent)
        {
            double[] location = ((string)parent.Element("Location")).Split(',').Select(double.Parse).ToArray();
            double[] size     = ((string)parent.Element("Size")).Split(',').Select(double.Parse).ToArray();

            Models.Panels.TouchElement element = new Models.Panels.TouchElement(screen)
            {
                LocationX  = location[0],
                LocationY  = location[1],
                SizeX      = size[0],
                SizeY      = size[1],
                JumpScreen = (int)parent.Element("JumpScreen")
            };

            if (parent.Element("SoundIndex") != null)
            {
                element.SoundEntries.Add(new Models.Panels.TouchElement.SoundEntry
                {
                    Index = (int)parent.Element("SoundIndex")
                });
            }

            if (parent.Element("CommandInfo") != null && parent.Element("CommandOption") != null)
            {
                element.CommandEntries.Add(new Models.Panels.TouchElement.CommandEntry
                {
                    Info   = Translations.CommandInfos.TryGetInfo((Translations.Command)Enum.Parse(typeof(Translations.Command), (string)parent.Element("CommandInfo"))),
                    Option = (int)parent.Element("CommandOption")
                });
            }

            element.SoundEntries.AddRange(parent.XPathSelectElements("SoundEntries/Entry").Select(ParseTouchElementSoundEntryNode));
            element.CommandEntries.AddRange(parent.XPathSelectElements("CommandEntries/Entry").Select(ParseTouchElementCommandEntryNode));
            element.Layer = (int)parent.Element("Layer");

            return(element);
        }