/// <summary> /// 方法:扫码线程方法 /// </summary> private void DecodeThreadMethod() { string decoderesult = null; //ShowRichTextBoxMsgRef ShowRichTextBoxMsgRef_Instance = new ShowRichTextBoxMsgRef(ShowRichTextBoxMsg); UpdateCaptionControl updateCaptionControl = new UpdateCaptionControl(UpdateMsg); do { //+ Environment.NewLine decoderesult = Decoder(); if (decoderesult != null) { try { // decoderesult = new string(decoderesult.Where(c => !Char.IsWhiteSpace(c)).ToArray()); X18J52 x18J52 = JsonConvert.DeserializeObject <X18J52>(decoderesult.Substring(1, decoderesult.Length - 1)); //this.Invoke(ShowRichTextBoxMsgRef_Instance, new object[] { this.richTextBox1, decoderesult + Environment.NewLine }); PropertyInfo[] propertyInfos = x18J52.GetType().GetProperties(); foreach (var item in propertyInfos) { foreach (var con in panel1.Controls) { if (con is CaptionLabel) { CaptionLabel captionLabel = con as CaptionLabel; if (captionLabel.Tag.ToString().Equals(item.Name)) { object obj = item.GetValue(x18J52, null); string str = obj == null ? "" : obj.ToString(); this.Invoke(updateCaptionControl, new object[] { captionLabel, str }); } } } } } catch (Exception ex) { foreach (var con in panel1.Controls) { if (con is CaptionLabel) { CaptionLabel captionLabel = con as CaptionLabel; this.Invoke(updateCaptionControl, new object[] { captionLabel, "" }); } } } decoderesult = null; } }while (bIsLoop); }
private void captionLabel1_Click(object sender, EventArgs e) { CaptionLabel captionLabel = (CaptionLabel)sender; Clipboard.SetDataObject(captionLabel.Text.Trim(), true); }
private void UpdateMsg(CaptionLabel captionLabel, string msg) { captionLabel.Text = msg; }