Exemplo n.º 1
0
        private static string FormatColor(Color color)
        {
            string colorString = FormatString(ColorUtilities.ConvertColorToString(color));

            return(string.Format("ColorUtilities.GetColorFromString({0})", colorString));
        }
Exemplo n.º 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);
        }