public override void ChangedType(Items type) { switch (type.K) { case INPUT_FILE_BIN: _Di.TbData.Enabled = true; _Di.BtData.Enabled = true; _Di.BtData.Focus(); _Di.LbMask.Visible = false; _Di.CbMask.Visible = false; _Di.BtMask.Visible = false; break; case INPUT_FILE_TXT: case INPUT_TEXT: _Di.TbData.Enabled = true; _Di.BtData.Enabled = true; _Di.BtData.Focus(); _Di.LbMask.Visible = true; _Di.CbMask.Visible = true; _Di.BtMask.Visible = true; break; default: _Di.LbMask.Visible = false; _Di.CbMask.Visible = false; _Di.BtMask.Visible = false; break; } }
private void ShowConfig(Items item) { if (!_itemList.ContainsKey(item.K)) { switch (item.K) { case "system": var robot = new Robot(); robot.Init(); _itemList[item.K] = robot; break; case "taglist": var tagList = new TagList(_DataModel); tagList.Init(); _itemList[item.K] = tagList; break; case "about": var about = new About(); about.Init(); _itemList[item.K] = about; break; default: return; } } UserControl uc = _itemList[item.K].UserControl; uc.Location = new System.Drawing.Point(6, 20); uc.Name = "Config"; uc.Size = new System.Drawing.Size(225, 187); uc.TabIndex = 0; GbItem.Controls.Clear(); GbItem.Controls.Add(_itemList[item.K].UserControl); GbItem.Text = item.V; }
public override void ChangedType(Items type) { _Do.TbData.Text = ""; switch (_Type.K) { case OUTPUT_FILE_BIN: _Do.TbData.Enabled = true; _Do.BtData.Enabled = true; _Do.BtData.Focus(); _Do.LbMask.Visible = false; _Do.CbMask.Visible = false; _Do.BtMask.Visible = false; break; case OUTPUT_TEXT: case OUTPUT_FILE_TXT: _Do.TbData.Enabled = true; _Do.BtData.Enabled = true; _Do.BtData.Focus(); _Do.LbMask.Visible = true; _Do.CbMask.Visible = true; _Do.BtMask.Visible = true; break; default: _Do.BtData.Enabled = false; _Do.LbMask.Visible = false; _Do.CbMask.Visible = false; _Do.BtMask.Visible = false; break; } }
public override void ChangedType(Items type) { _Type = type; switch (_Type.K) { case INPUT_TEXT: _Di.TbData.Enabled = true; _Di.TbData.Focus(); _Di.BtData.Enabled = true; _Di.CbMask.Enabled = true; break; case INPUT_FILE: _Di.TbData.Enabled = true; _Di.BtData.Enabled = true; _Di.BtData.Focus(); _Di.CbMask.Enabled = true; break; default: _Di.BtData.Enabled = false; _Di.CbMask.Enabled = false; break; } }
public void Init(MSec mSec) { _MSec = mSec; _DefAlg = new Items { K = "", V = "默认" }; _DefMod = new Items { K = "", V = "默认" }; _DefPad = new Items { K = "", V = "默认" }; _DefLen = new Items { K = "", V = "默认" }; switch (_MSec.Operation) { case ESec.OPT_CONFUSE: ShowConfuse(); break; case ESec.OPT_WRAPPER: ShowWrapper(); break; case ESec.OPT_DIGEST: ShowDigest(); break; case ESec.OPT_SCRYPTO: ShowScrypto(); break; case ESec.OPT_SSTREAM: ShowSstream(); break; case ESec.OPT_ACRYPTO: ShowAcrypto(); break; } }
public override void ChangedType(Items type) { _Type = type; if (_Cur != null) { _Cur.ChangedType(type); } }
public override void ChangedType(Items type) { _Type = type; _Do.TbData.Text = ""; _Do.TbData.Enabled = true; _Do.BtData.Enabled = true; _Do.CbMask.Enabled = true; }
public static void Clear(ComboBox cBox, Items[] items) { int idx = cBox.SelectedIndex; for (int i = cBox.Items.Count - 1; i > 1; i -= 1) { cBox.Items.RemoveAt(i); } cBox.Items.AddRange(items); if (idx != 0) { cBox.SelectedIndex = 0; } }
public override void ChangedType(Items type) { switch (_Type.K) { case INPUT_FILE: _Di.TbData.Enabled = true; _Di.BtData.Enabled = true; _Di.BtData.Focus(); break; case INPUT_TEXT: _Di.TbData.Enabled = true; _Di.BtData.Enabled = true; _Di.BtData.Focus(); break; } }
public void InitOnce() { CbError.Items.Add(new Items { K = "L", V = "L" }); CbError.Items.Add(new Items { K = "M", V = "M" }); CbError.Items.Add(new Items { K = "Q", V = "Q" }); CbError.Items.Add(new Items { K = "H", V = "H" }); CbError.SelectedIndex = 0; Items item; foreach (EncodingInfo encoding in Encoding.GetEncodings()) { item = new Items { K = encoding.Name, V = encoding.DisplayName }; CbCoding.Items.Add(item); if (item.K.ToLower() == "utf-8") { CbCoding.SelectedItem = item; } } }
public override void ChangedType(Items type) { _Type = type; _Do.TbData.Text = ""; switch (_Type.K) { case OUTPUT_FILE: case OUTPUT_TEXT: _Do.TbData.Enabled = true; _Do.BtData.Enabled = true; break; default: _Do.TbData.Enabled = false; _Do.BtData.Enabled = false; break; } }
public override void ChangedType(Items type) { _Di.BtData.Enabled = false; }
public override void ChangedType(Items type) { _Type = type; }
public override void ChangedType(Items type) { _Type = type; _Do.TbData.Text = ""; }
public abstract void ChangedType(Items type);
public void Load(string filePath) { if (!File.Exists(filePath)) { return; } using (StreamReader reader = new StreamReader(filePath)) { string line; bool multiLine = false; bool isComment = false; Items item = new Items { V = "", D = "" }; while (true) { line = reader.ReadLine(); if (line == null) { break; } if (string.IsNullOrEmpty(line)) { continue; } line = line.Replace("\\r", "\r").Replace("\\n", "\n").Replace("\\t", "\t"); if (line.StartsWith("#")) { item.D += line.Substring(1); isComment = true; continue; } if (multiLine) { if (isComment) { item.D += line; } else { item.V += line; } multiLine = line.EndsWith(" \\"); continue; } int idx = line.IndexOf('='); if (idx < 0) { continue; } item.K = line.Substring(0, idx); item.V = line.Substring(idx + 1); dict[item.K] = item; keys.Add(item.K); item = new Items { V = "", D = "" }; isComment = false; } reader.Close(); } }
public void Set(string key, string value, string comment) { if (key != null) { if (dict.ContainsKey(key)) { Items item = dict[key]; item.V = value; item.D = comment; } else { dict[key] = new Items { V = value, D = comment }; keys.Add(key); } } }
/// <summary> /// 重写Add方法,实现按添加顺序排列 /// </summary> /// <param name="key">key</param> ///<param name="value">value</param> /// <returns></returns> public void Set(string key, string value) { if (key != null) { if (dict.ContainsKey(key)) { dict[key].V = value; } else { dict[key] = new Items { V = value }; keys.Add(key); } } }
//throws Exception private Items calculate(String exp, int dec) { String lOpd; String mOpr = ((Op)oprStack.Pop()).S; var rOpd = (String)numStack.Pop(); String tNum; var kvItem = new Items(); // 加 if (ConstUI.OPR_ADD_EXP == mOpr) { lOpd = (String)numStack.Pop(); tNum = Decimal.Add(Decimal.Parse(lOpd), Decimal.Parse(rOpd)).ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = lOpd + mOpr + rOpd; kvItem.D = tNum; return kvItem; } // 减 if (ConstUI.OPR_SUB_EXP == mOpr) { lOpd = (String)numStack.Pop(); tNum = Decimal.Subtract(Decimal.Parse(lOpd), Decimal.Parse(rOpd)).ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = lOpd + mOpr + rOpd; kvItem.D = tNum; return kvItem; } // 乘 if (ConstUI.OPR_MUL_EXP == mOpr) { lOpd = (String)numStack.Pop(); tNum = Decimal.Multiply(Decimal.Parse(lOpd), Decimal.Parse(rOpd)).ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = lOpd + mOpr + rOpd; kvItem.D = tNum; return kvItem; } // 除 if (ConstUI.OPR_DIV_EXP == mOpr) { Decimal t = Decimal.Parse(rOpd); if (t.CompareTo(Decimal.Zero) == 0) { throw new Exception("除数为0"); } lOpd = (String)numStack.Pop(); tNum = Decimal.Divide(Decimal.Parse(lOpd), t).ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = lOpd + mOpr + rOpd; kvItem.D = tNum; return kvItem; } // 取模 if (ConstUI.OPR_MOD_EXP == mOpr) { Decimal t = Decimal.Parse(rOpd); if (t.CompareTo(Decimal.Zero) == 0) { throw new Exception("除数为0"); } lOpd = (String)numStack.Pop(); tNum = Decimal.Remainder(Decimal.Parse(lOpd), t).ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = lOpd + mOpr + rOpd; kvItem.D = tNum; return kvItem; } // 次幂 if (ConstUI.OPR_POW_EXP == mOpr) { try { int t = Decimal.ToInt32(Decimal.Parse(rOpd)); lOpd = (String)numStack.Pop(); tNum = Math.Pow(Decimal.ToDouble(Decimal.Parse(lOpd)), Decimal.ToDouble(t)).ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = lOpd + mOpr + rOpd; kvItem.D = tNum; return kvItem; } catch (ArithmeticException) { throw new Exception(String.Format("次幂时,指数{0}应为一个整数!", rOpd)); } } // 方根 if (ConstUI.OPR_ROT_EXP == mOpr) { lOpd = (String)numStack.Pop(); Decimal tl = Decimal.Parse(rOpd); Decimal tr = Decimal.Divide(Decimal.Zero, Decimal.Parse(lOpd)); tNum = Math.Pow(Decimal.ToDouble(tl), Decimal.ToDouble(tr)).ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = lOpd + mOpr + rOpd; kvItem.D = tNum; return kvItem; } // 正弦 if (ConstUI.OPR_SIN_EXP == mOpr.ToLower()) { Decimal t = Decimal.Parse(rOpd); tNum = Decimal.Round(new Decimal(Math.Sin(Decimal.ToDouble(t))), dec).ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = mOpr + rOpd; kvItem.D = tNum; return kvItem; } // 余弦 if (ConstUI.OPR_COS_EXP == mOpr.ToLower()) { Decimal t = Decimal.Parse(rOpd); tNum = Decimal.Round(new Decimal(Math.Cos(Decimal.ToDouble(t))), dec).ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = mOpr + rOpd; kvItem.D = tNum; return kvItem; } // 正切 if (ConstUI.OPR_TAN_EXP == mOpr.ToLower()) { Decimal t = Decimal.Parse(rOpd); tNum = Decimal.Round(new Decimal(Math.Tan(Decimal.ToDouble(t))), dec).ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = mOpr + rOpd; kvItem.D = tNum; return kvItem; } // 正割 if (ConstUI.OPR_SEC_EXP == mOpr.ToLower()) { Decimal t = Decimal.Parse(rOpd); tNum = Decimal.Round(new Decimal(Math.Asin(Decimal.ToDouble(t))), dec).ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = mOpr + rOpd; kvItem.D = tNum; return kvItem; } // 余割 if (ConstUI.OPR_CSC_EXP == mOpr.ToLower()) { Decimal t = Decimal.Parse(rOpd); tNum = Decimal.Round(new Decimal(Math.Acos(Decimal.ToDouble(t))), dec).ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = mOpr + rOpd; kvItem.D = tNum; return kvItem; } // 反正切 if (ConstUI.OPR_COT_EXP == mOpr.ToLower()) { Decimal t = Decimal.Parse(rOpd); tNum = Decimal.Round(new Decimal(Math.Atan(Decimal.ToDouble(t))), dec).ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = mOpr + rOpd; kvItem.D = tNum; return kvItem; } // 阶乘 if (ConstUI.OPR_FAC_EXP == mOpr) { int t; try { t = Int32.Parse(rOpd); } catch (Exception) { throw new Exception("阶乘数值只能为正整数!"); } if (t <= 0) { throw new Exception("阶乘值不能小于1!"); } if (t > 27) { throw new Exception("暂时不支持大于27的阶乘值!"); } Decimal d = Decimal.One; while (t > 1) { d = Decimal.Multiply(d, new Decimal(t--)); } tNum = d.ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = rOpd + mOpr; kvItem.D = tNum; return kvItem; } // 10的对数 if (ConstUI.OPR_LOG_EXP == mOpr.ToLower()) { Decimal t = Decimal.Parse(rOpd); tNum = Decimal.Round(new Decimal(Math.Log10(Decimal.ToDouble(t))), dec).ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = mOpr + rOpd; kvItem.D = tNum; return kvItem; } // e的对数 if (ConstUI.OPR_LNE_EXP == mOpr.ToLower()) { Decimal t = Decimal.Parse(rOpd); tNum = Decimal.Round(new Decimal(Math.Log(Decimal.ToDouble(t))), dec).ToString(); numStack.Push(tNum); kvItem.K = exp; kvItem.V = mOpr + rOpd; kvItem.D = tNum; return kvItem; } return null; }