private void okBtn_Click(object sender, EventArgs e) { StringMode pattern = GetRadioChecked(); string expression = textBox.Text; if (pattern == StringMode.Javascript) { expression = textBox.Text; } else if (pattern == StringMode.Regex) { expression = regexTextbox.Text; } if (pattern == StringMode.Replace) { for (int i = 0; i < replaceList.Count; i++) { if (i == 0) { expression = ""; } else { expression += ","; } expression += replaceList.GetKey(i) + "," + replaceList.Get(i); } } Pattern = new StringPattern() { Expression = expression, Pattern = pattern }; }
public static void SaveGuiElement(NumericUpDown upDown, StringMode stringMode = StringMode.Any) { switch (stringMode) { case StringMode.Any: Config.Set(upDown.Name, ((float)upDown.Value).ToString().Replace(",", ".")); break; case StringMode.Int: Config.Set(upDown.Name, ((int)upDown.Value).ToString()); break; case StringMode.Float: Config.Set(upDown.Name, ((float)upDown.Value).ToString().Replace(",", "."));; break; } }
public static void SaveGuiElement(ComboBox comboBox, StringMode stringMode = StringMode.Any) { switch (stringMode) { case StringMode.Any: Config.Set(comboBox.Name, comboBox.Text); break; case StringMode.Int: Config.Set(comboBox.Name, comboBox.Text.GetInt().ToString()); break; case StringMode.Float: Config.Set(comboBox.Name, comboBox.Text.GetFloat().ToString().Replace(",", ".")); break; } }
public static void SaveGuiElement(TextBox textbox, StringMode stringMode = StringMode.Any) { switch (stringMode) { case StringMode.Any: Config.Set(textbox.Name, textbox.Text); break; case StringMode.Int: Config.Set(textbox.Name, textbox.Text.GetInt().ToString()); break; case StringMode.Float: Config.Set(textbox.Name, textbox.Text.GetFloat().ToString()); break; } }
private void UpdateTabPage(StringMode model) { tabControl1.Controls.Clear(); if (model == StringMode.Javascript) { tabControl1.Controls.Add(javascriptPage); } else if (model == StringMode.Regex) { tabControl1.Controls.Add(regxPage); } else if (model == StringMode.Replace) { tabControl1.Controls.Add(replacePage); } }
public void Write(string value, StringMode mode) { switch (mode) { case StringMode.LengthPrefixed: Write(value); break; case StringMode.NullTerminated: Write(enc.GetBytes(value)); Write((byte)0); break; case StringMode.Fixed: Write(enc.GetBytes(value)); break; } }
private StringMode GetRadioChecked() { StringMode pattern = StringMode.None; if (scriptRadio.Checked) { pattern = StringMode.Javascript; } if (regexRadio.Checked) { pattern = StringMode.Regex; } if (replaceRadioButton.Checked) { pattern = StringMode.Replace; } return(pattern); }
public void Dump(StringMode smeMode, string sPrependString) { string sMsg = string.Empty; if (!(string.IsNullOrEmpty(sPrependString))) { if (!(sPrependString.EndsWith(ConventionSupport.Space))) { sPrependString += ConventionSupport.Space; } sMsg += sPrependString; } switch (smeMode) { case StringMode.VERBOSE: Console.WriteLine(this.ToStringVerbose( )); break; case StringMode.DEFAULT: Console.WriteLine(this.ToString( )); break; case StringMode.HEX: Console.Write(this.ToStringHex( )); break; case StringMode.BINARY: Console.WriteLine(this.ToStringBinary( )); break; case StringMode.DECIMAL: Console.WriteLine(this.ToStringDecimal( )); break; case StringMode.ALL_BASE: case StringMode.HEX_DECIMAL: case StringMode.HEX_BINARY: case StringMode.BINARY_DECIMAL: default: throw new NotImplementedException( ); } }
public void Dump(StringMode smeMode) { Dump(smeMode, null); }
/// <summary> /// 获得所有操作符字符串 /// </summary> /// <returns></returns> public void Parse(string text) { this.Clear(); if (text == null || text.Length == 0) { return; } DCToken currentToken = null; StringMode sm = StringMode.None; for (int position = 0; position < text.Length; position++) { char c = text[position]; if (sm == StringMode.SingleQuotes || sm == StringMode.DoubleQuotes) { // 正在定义字符串 if (c == '\\') { // 开始转义 const string EigthDigs = "01234567"; const string HexDigs = "0123456789ABCDEF"; char nextC = NextChar(text, position); if (EigthDigs.IndexOf(nextC) >= 0) { // 三位八进制数字 string v = NextChars(text, position, 3); if (v != null && v.Length == 3) { position += 3; int num = ParseNumber(v, EigthDigs); currentToken._Str.Append((char)num); } else { throw new System.Exception("长度不够:" + text); } } else if (nextC == 'x') { // 两个十六进制 position++; string v = NextChars(text, position, 2); if (v != null && v.Length == 2) { v = v.ToUpper(); position += 2; int num = ParseNumber(v, HexDigs); currentToken._Str.Append((char)num); } else { throw new System.Exception("长度不够:" + text); } } else if (nextC == 'a') { currentToken._Str.Append('\a'); } else if (nextC == 'b') { currentToken._Str.Append('\b'); } else if (nextC == 'n') { currentToken._Str.Append('\n'); } else if (nextC == 'r') { currentToken._Str.Append('\r'); } else if (nextC == 'v') { currentToken._Str.Append('\v'); } else if (nextC == '"') { currentToken._Str.Append('"'); } else if (nextC == '\'') { currentToken._Str.Append('\''); } else { throw new System.Exception("不支持的转移:" + nextC); } } else if (sm == StringMode.SingleQuotes && c == '\'') { // 结束定义单引号字符串 currentToken._Str.Append(c); currentToken = null; sm = StringMode.None; } else if (sm == StringMode.DoubleQuotes && c == '"') { // 结束定义双引号字符串 currentToken._Str.Append(c); currentToken = null; sm = StringMode.None; } else { // 添加正常字符 currentToken._Str.Append(c); } } else { // 不是正在定义字符串 if (c == '\'') { // 开始定义单引号字符串 currentToken = new DCToken(); currentToken.Type = CharType.StringConst; currentToken._Str.Append(c); sm = StringMode.SingleQuotes; this.Add(currentToken); } else if (c == '"') { // 开始定义双引号字符串 currentToken = new DCToken(); currentToken.Type = CharType.StringConst; currentToken._Str.Append(c); sm = StringMode.DoubleQuotes; this.Add(currentToken); } else if (char.IsWhiteSpace(c)) { // 遇到空白字符则过滤掉空白字符 currentToken = null; for (; position < text.Length; position++) { if (char.IsWhiteSpace(text[position]) == false) { position--; break; } } } else { // 普通字符 if (c == '(') { currentToken = new DCToken(); currentToken._Str.Append(c); currentToken.Type = CharType.CurLeft; this.Add(currentToken); currentToken = null; } else if (c == ')') { currentToken = new DCToken(); currentToken._Str.Append(c); currentToken.Type = CharType.CurRight; this.Add(currentToken); currentToken = null; } else { CharType ct = GetChartType(c); if (currentToken == null || currentToken.Type != ct) { currentToken = new DCToken(); currentToken.Type = ct; this.Add(currentToken); } currentToken._Str.Append(c); } } } }//for if (currentToken != null && currentToken._Str.Length > 0) { if (this.Contains(currentToken) == false) { this.Add(currentToken); } } foreach (var item in this) { if (item._Str != null) { item.Text = item._Str.ToString(); item._Str = null; } } }