internal static void ParseWidgetName(string name, out string baseName, out int idx)
{
// Extract a numerical suffix from the name
// If suffix has more than 4 digits, only the last 4 digits are considered
// a numerical suffix.
int n;
for (n = name.Length - 1; n >= name.Length-4 && n >= 0 && char.IsDigit (name [n]); n--)
;
if (n < name.Length - 1) {
baseName = name.Substring (0, n + 1);
idx = int.Parse (name.Substring (n + 1));
} else {
baseName = name;
idx = 0;
}
}