Пример #1
0
        public override string ToString()
        {
            XDocument xmlBuild = new XDocument();
            XElement  root     = new XElement("Data", _name);

            xmlBuild.Add(root);

            if (_groupList.Count > 0)
            {
                root.Add(new XAttribute("groupList", String.Join(",", _groupList)));
            }

            root.Add(new XAttribute("base", _watchVar.BaseAddressType.ToString()));

            if (_watchVar.OffsetDefault != null)
            {
                root.Add(new XAttribute(
                             "offset",
                             String.Format("0x{0:X}", _watchVar.OffsetDefault.Value)));
            }

            if (_watchVar.OffsetUS != null)
            {
                root.Add(new XAttribute(
                             "offsetUS",
                             String.Format("0x{0:X}", _watchVar.OffsetUS.Value)));
            }

            if (_watchVar.OffsetJP != null)
            {
                root.Add(new XAttribute(
                             "offsetJP",
                             String.Format("0x{0:X}", _watchVar.OffsetJP.Value)));
            }

            if (_watchVar.OffsetPAL != null)
            {
                root.Add(new XAttribute(
                             "offsetPAL",
                             String.Format("0x{0:X}", _watchVar.OffsetPAL.Value)));
            }

            if (_watchVar.MemoryTypeName != null)
            {
                root.Add(new XAttribute("type", _watchVar.MemoryTypeName));
            }

            if (_watchVar.SpecialType != null)
            {
                root.Add(new XAttribute("specialType", _watchVar.SpecialType));
            }

            if (_watchVar.Mask != null)
            {
                root.Add(new XAttribute(
                             "mask",
                             String.Format("0x{0:X" + _watchVar.NibbleCount + "}", _watchVar.Mask.Value)));
            }

            if (_subclass != WatchVariableSubclass.Number)
            {
                root.Add(new XAttribute("subclass", _subclass.ToString()));
            }

            if (_invertBool.HasValue)
            {
                root.Add(new XAttribute("invertBool", _invertBool.Value.ToString().ToLower()));
            }

            if (_useHex.HasValue)
            {
                root.Add(new XAttribute("useHex", _useHex.Value.ToString().ToLower()));
            }

            if (_coordinate.HasValue)
            {
                root.Add(new XAttribute("coord", _coordinate.Value.ToString()));
            }

            if (_backgroundColor.HasValue)
            {
                root.Add(new XAttribute(
                             "color",
                             "#" + ColorUtilities.ToString(_backgroundColor.Value)));
            }

            return(root.ToString());
        }
Пример #2
0
        public XElement ToXML(
            string newName = null,
            Color?newColor = null,
            List <VariableGroup> newVariableGroupList = null,
            List <uint> newFixedAddresses             = null)
        {
            string   name     = newName ?? Name;
            XElement xElement = new XElement("Data", name);

            List <VariableGroup> groupList = newVariableGroupList ?? GroupList;

            if (groupList.Count > 0)
            {
                xElement.Add(new XAttribute("groupList", String.Join(",", groupList)));
            }

            xElement.Add(new XAttribute("base", WatchVar.BaseAddressType.ToString()));

            if (WatchVar.OffsetDefault != null)
            {
                xElement.Add(new XAttribute(
                                 "offset",
                                 HexUtilities.FormatValue(WatchVar.OffsetDefault.Value)));
            }

            if (WatchVar.OffsetUS != null)
            {
                xElement.Add(new XAttribute(
                                 "offsetUS",
                                 HexUtilities.FormatValue(WatchVar.OffsetUS.Value)));
            }

            if (WatchVar.OffsetJP != null)
            {
                xElement.Add(new XAttribute(
                                 "offsetJP",
                                 HexUtilities.FormatValue(WatchVar.OffsetJP.Value)));
            }

            if (WatchVar.OffsetSH != null)
            {
                xElement.Add(new XAttribute(
                                 "offsetSH",
                                 HexUtilities.FormatValue(WatchVar.OffsetSH.Value)));
            }

            if (WatchVar.OffsetEU != null)
            {
                xElement.Add(new XAttribute(
                                 "offsetEU",
                                 HexUtilities.FormatValue(WatchVar.OffsetEU.Value)));
            }

            if (WatchVar.MemoryTypeName != null)
            {
                xElement.Add(new XAttribute("type", WatchVar.MemoryTypeName));
            }

            if (WatchVar.SpecialType != null)
            {
                xElement.Add(new XAttribute("specialType", WatchVar.SpecialType));
            }

            if (DisplayType != null)
            {
                xElement.Add(new XAttribute("display", TypeUtilities.TypeToString[DisplayType]));
            }

            if (WatchVar.Mask != null)
            {
                xElement.Add(new XAttribute(
                                 "mask",
                                 HexUtilities.FormatValue(WatchVar.Mask.Value, WatchVar.NibbleCount)));
            }

            if (WatchVar.Shift != null)
            {
                xElement.Add(new XAttribute("shift", WatchVar.Shift.Value));
            }

            if (WatchVar.HandleMapping == false)
            {
                xElement.Add(new XAttribute("handleMapping", WatchVar.HandleMapping));
            }

            if (Subclass != WatchVariableSubclass.Number)
            {
                xElement.Add(new XAttribute("subclass", Subclass.ToString()));
            }

            if (RoundingLimit.HasValue)
            {
                xElement.Add(new XAttribute("round", RoundingLimit.Value.ToString()));
            }

            if (InvertBool.HasValue)
            {
                xElement.Add(new XAttribute("invertBool", InvertBool.Value.ToString().ToLower()));
            }

            if (UseHex.HasValue)
            {
                xElement.Add(new XAttribute("useHex", UseHex.Value.ToString().ToLower()));
            }

            if (Coordinate.HasValue)
            {
                xElement.Add(new XAttribute("coord", Coordinate.Value.ToString()));
            }

            if (IsYaw.HasValue)
            {
                xElement.Add(new XAttribute("yaw", IsYaw.Value.ToString()));
            }

            Color?color = newColor ?? BackgroundColor;

            if (color.HasValue)
            {
                xElement.Add(new XAttribute(
                                 "color",
                                 ColorUtilities.ConvertColorToString(color.Value)));
            }

            List <uint> fixedAddresses = newFixedAddresses ?? FixedAddresses;

            if (fixedAddresses != null)
            {
                xElement.Add(new XAttribute("fixed", String.Join(
                                                ",", fixedAddresses.ConvertAll(
                                                    address => HexUtilities.FormatValue(address)))));
            }

            return(xElement);
        }