public CiPad() { this.SuspendLayout(); InitializeComponent(); this.CiGroup = new CiPadGroup(this); this.CGroup = new CiPadGroup(this); this.DGroup = new CiPadGroup(this); this.JavaGroup = new CiPadGroup(this); this.CsGroup = new CiPadGroup(this); this.PerlGroup = new CiPadGroup(this); this.JsGroup = new CiPadGroup(this); this.AsGroup = new CiPadGroup(this); this.CiGroup.Set("hello.ci", @"public class HelloCi { public const int VersionMajor = 0; public const int VersionMinor = 3; public const string Version = VersionMajor + ""."" + VersionMinor; /// Returns `true` if and only if `x` is a power of 2 (1, 2, 4, 8, 16, ...). public static bool IsPowerOfTwo(int x) { return (x & x - 1) == 0 && x > 0; } /// Calculates greatest common divisor of `a` and `b`. public static int GreatestCommonDivisor(int a, int b) { // Euclidean algorithm while (b != 0) { int t = b; b = a % b; a = t; } return a; } /// Checks whether the given string is a palindrome. /// Note: empty string is considered palindrome. public static bool IsPalindrome(string s) { int j = s.Length; for (int i = 0; i < --j; i++) if (s[i] != s[j]) return false; return true; } /// Gets a boolean value out of strings `""true""` and `""false""`. /// In other cases returns `defaultValue`. public static bool ParseBool(string s, bool defaultValue) { if (s == ""true"") return true; if (s == ""false"") return false; return defaultValue; } /// Converts an unsigned integer from its decimal representation. public static int ParseUnsignedInt(string s) { if (s == null || s.Length == 0) throw ""null or empty argument""; int n = s.Length; int r = 0; for (int i = 0; i < n; i++) { int c = s[i]; if (c < '0' || c > '9') throw ""Not a digit""; // TODO: detect overflow r = r * 10 + c - '0'; } return r; } } ".Replace("\n", "\r\n"), false); Translate(); FocusCi(); this.ResumeLayout(); }
public CiPadWriter(CiPadGroup parent, string name) { this.Parent = parent; this.Name = name; }