public ImGuiMethodParameter(string name, string type, string defaultValue = "", bool isRefToPtr = false) { DefaultValue = ""; if (type == "...") { Name = "args"; Type = "params Object[]"; IsVaList = true; } else { Name = name; Type = ImGui.FixType(type); IsVaList = false; if (defaultValue == "NULL") { DefaultValue = "null"; } else if (defaultValue != "") { if (defaultValue.EndsWith(")")) { DefaultValue = "default"; } else { DefaultValue = ImGui.RemovePrefix(defaultValue); } if (DefaultValue == "FLT_MAX") { DefaultValue = "float.MaxValue"; } else if (DefaultValue.Contains("_")) { DefaultValue = DefaultValue.Remove(0, DefaultValue.IndexOf('_') + 1).Insert(0, "."); } if (char.IsDigit(DefaultValue[0])) { DefaultValue = $"({Type}) {DefaultValue}"; } } } //IsOutParam = name.StartsWith("out_") && (isRefToPtr || type.EndsWith("**")); IsOutParam = name.StartsWith("out_") && !type.Contains("_") && type.EndsWith("*") && DefaultValue == ""; IsRefParam = !IsOutParam && isRefToPtr; if (Name.EndsWith("]")) { var arraySpecifier = Name.Substring(Name.IndexOf('[')); Name = Name.Replace(arraySpecifier, ""); Type += arraySpecifier; } Name = ImGui.MakeSafeName(Name); }
/// <summary> /// Reformats the default value of the text setting to have the same format than the values /// of the read XBee AT parameters. /// </summary> private void ReFormatDefaultValue() { if (DefaultValue == null || DefaultValue.Length == 0) { return; } string[] characters; if (DefaultValue.Contains(HEXADECIMAL_PREFIX_UPPER)) { characters = DefaultValue.Split(HEXADECIMAL_PREFIX_UPPER.ToCharArray(), StringSplitOptions.None); } else if (DefaultValue.Contains(HEXADECIMAL_PREFIX_LOWER)) { characters = DefaultValue.Split(HEXADECIMAL_PREFIX_LOWER.ToCharArray()); } else { characters = new string[] { DefaultValue } }; string newDefaultValue = ""; for (int i = 0; i < characters.Length; i++) { if (characters[i].Length == 0) { continue; } switch (Format) { case Format.ASCII: int asciiChar; if (int.TryParse(characters[i], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out asciiChar)) { newDefaultValue += asciiChar; } else { newDefaultValue += characters[i]; } break; default: newDefaultValue += characters[i]; break; } } DefaultValue = newDefaultValue; for (int i = 0; i < NumNetworks; i++) { CurrentValues[i] = DefaultValue; XBeeValues[i] = DefaultValue; } } }