private void btnOK_Click(object sender, EventArgs e) { HotKey.UnregisterHotKey(Handle, 100); Model.CMD cmd = txtPoly.GetCMD(); if (cmd != null) { byte[] bpoly = cmd.Bytes; if (bpoly.Length > 1) { Poly = BitConverter.ToUInt16(bpoly, 0); this.DialogResult = DialogResult.OK; } else { if (LanguageSet.Language == "0") { MessageBox.Show("请输入2个字节的多项式值!"); } else { MessageBox.Show("Please enter a 2-byte polynomial value!"); } } } txtPoly.Focus(); HotKey.RegisterHotKey(Handle, 100, HotKey.KeyModifiers.None, Keys.Enter); }
/// <summary> /// Modbus /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MS_CRC16_Click(object sender, EventArgs e) { Model.CMD cmd = txtContent.GetCMD(); if (cmd != null) { AppendToContent(Lib.BytesCheck.GetCRC16(cmd.Bytes, false)); } }
private void btnSave_Click(object sender, EventArgs e) { NewCMD = txtContent.GetCMD(); if (NewCMD != null) { this.DialogResult = DialogResult.OK; } }
/// <summary> /// 校验和 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MS_CheckSum_Click(object sender, EventArgs e) { Model.CMD cmd = txtContent.GetCMD(); if (cmd != null) { byte check = Lib.BytesCheck.GetXOR(cmd.Bytes); txtContent.AppendText(Convert.ToString(check, 16).PadLeft(2, '0')); } }
public frmCMD(Model.CMD cmd) { InitializeComponent(); txtContent.SetCMD(cmd); if (txtContent.IsHex == EnumType.CMDType.ASCII) { CM_Type.Text = "切换到Hex"; CM_Check.Visible = false; } }
/// <summary> /// 多项式CRC16 低位在前 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MS_CRCPolyL_Click(object sender, EventArgs e) { Model.CMD cmd = txtContent.GetCMD(); if (cmd != null) { frmPoly fpoly = new frmPoly(); if (fpoly.ShowDialog() == DialogResult.OK) { AppendToContent(Lib.BytesCheck.GetCRC16ByPoly(cmd.Bytes, fpoly.Poly, false)); } } }
public frmCMD(Model.CMD cmd) { InitializeComponent(); if (LanguageSet.Language == "0") { LanguageSet.SetLang("", this, typeof(frmCMD)); } else { LanguageSet.SetLang("en-US", this, typeof(frmCMD)); } txtContent.SetCMD(cmd); SetType(txtContent.EncodeType); ami_Tips.Text = cmd.Tips; }
public frmCMD(Model.CMD cmd) { InitializeComponent(); txtContent.SetCMD(cmd); SetType(txtContent.EncodeType); }