public static string PathFixDir(string path, string lookfor) { if (lookfor.Length == 0) { return(slash); } string path2 = ""; if (path.Length > 0) { if (VbX.Right(path, 1) != slash) { path += slash; } path2 = path; } else { path2 = "." + slash; } foreach (string dir in Directory.GetDirectories(path2)) { if (dir.ToLower() == path + lookfor.ToLower()) { return(dir); } } if (path.Length > 0) { lookfor = path + slash + lookfor; } return(lookfor); }
public static string PathFixFile(string path, string lookfor) { string path2 = ""; if (path.Length > 0) { if (VbX.Right(path, 1) != slash) { path += slash; } path2 = path; } else { path2 = "." + slash; } try { foreach (string dir in Directory.GetFiles(path2)) { if (dir.ToLower() == path + lookfor.ToLower()) { return(dir); } } } catch (Exception ex) { VbX.MsgBox(ex.ToString()); } return(path + lookfor); }
public static string addslash(string lin) { if (lin.Length == 0) { return(""); } if (VbX.Right(lin, 1) == "/" || VbX.Right(lin, 1) == "\\") { return(lin); } return(lin + slash); }
/* * * private string GetPair(int y, int x) * { * int transpcount = 0; * if (x < 0) return "Bad!"; * string thispair = ""; * for (int pair = 0; pair < 2; pair++) * { * int thisbyte = 0; * for (int bit = 0; bit < 4; bit++) * { * int tx = x + (3 - bit) + (pair * 4); * int dot = spritepixel[tx, y]; * if (dot > 15) * { * transpcount++; * dot = 0; * } * else if (dot > 3) { * dot = 3; * } * string binary = VbX.Right("00" + Convert.ToString(dot, 2), 2); * string Binary2 = binary.Substring(1, 1) + "000" + binary.Substring(0, 1); * * thisbyte = thisbyte + (Convert.ToInt32(Binary2, 2) << bit); * // if (dot == 3) VbX.MsgBox(Binary2 + " " + bit.ToString() + " " + thisbyte.ToString()); * } * thispair = VbX.Right("00" + thisbyte.ToString("X"), 2) + thispair; * } * if (transpcount == 8) { return "ZZZZ"; } * return thispair; * } */ private string GetPair(int y, int x) { int transpcount = 0; if (x < 0) { return("Bad!"); } string thispair = ""; for (int pair = 0; pair < 2; pair++) { int thisbyte = 0; for (int bit = 0; bit < 2; bit++) { int tx = x + (bit) + (pair * 2); int dot = spritepixel[tx, y]; if (dot > 15) { transpcount++; dot = 0; } // else if (dot > 1) { // dot = 1; // } string binary = VbX.Right("0000" + Convert.ToString(dot, 2), 4); string Binary2 = binary;//binary.Substring(1, 1) + "000" + binary.Substring(0, 1); thisbyte = thisbyte + (Convert.ToInt32(Binary2, 2) << (1 - bit) * 4); // if (dot == 3) VbX.MsgBox(Binary2 + " " + bit.ToString() + " " + thisbyte.ToString()); } thispair = thispair + VbX.Right("00" + thisbyte.ToString("X"), 2); } // VbX.MsgBox(thispair); if (transpcount == 8) { return("ZZZZ"); } return(thispair); }
public static string IntToBin(int i) { return(VbX.Right("00000000" + Convert.ToString(i, 2), 8)); }
public static string GetItem(string lin, string ch, int pos, string brackets) { if (lin.Length == 0 || ch.Length == 0) { return(""); } string bracketarray = ""; string part = ""; int foundnum = 0; for (int i = 1; i <= lin.Length; i++) { string c = VbX.Mid(lin, i, 1); if (c == ch & string.IsNullOrEmpty(bracketarray)) { if (foundnum == pos) { return(part); } else { part = ""; foundnum = foundnum + 1; } } else { part = part + c; } // MsgBox(c) if (c == VbX.Chr(34) & VbX.InStr(brackets, VbX.Chr(34)) > 0) { if (VbX.Right(bracketarray, 1) == VbX.Chr(34) & !string.IsNullOrEmpty(bracketarray)) { bracketarray = VbX.Left(bracketarray, VbX.Len(bracketarray) - 1); } else { bracketarray = bracketarray + VbX.Chr(34); } //part = part + c } else if ((c == "(" | c == ")") & VbX.InStr(brackets, "(") > 0) { if (VbX.Right(bracketarray, 1) == "(" & c == ")" & !string.IsNullOrEmpty(bracketarray)) { bracketarray = VbX.Left(bracketarray, VbX.Len(bracketarray) - 1); } else { bracketarray = bracketarray + "("; } //part = part + c } else if ((c == "{" | c == "}") & VbX.InStr(brackets, "{") > 0) { if (VbX.Right(bracketarray, 1) == "{" & c == "}" & !string.IsNullOrEmpty(bracketarray)) { bracketarray = VbX.Left(bracketarray, VbX.Len(bracketarray) - 1); } else { bracketarray = bracketarray + "{"; } //part = part + c } } if (foundnum == pos) { return(part); } if (pos == -1) { return(foundnum.ToString()); } return(""); }