private void InitSubFunctionData(DcmConfig.SubFunction subFunction) { // 初始化subFunction.Data if (subFunction.Data == null) { subFunction.Data = new List <byte>(); for (int i = 0; i < subFunction.DataLen; i++) { subFunction.Data.Add(0); } } }
public void UpdateSubFunction(DcmConfig.SubFunction subFunction) { if (InvokeRequired) { UpdateSubFunctionFn fn = UpdateSubFunction; this.Invoke(fn, subFunction); } else { dcmContentWindow.Update(subFunction); statusCurrentTreeItem.Text = string.Format("Current SubFunction: {0}", subFunction.Name); UpdateToolBarEnabled(false); } }
public void Update(DcmConfig.SubFunction subFunction) { dataGridView.SuspendLayout(); dataGridView.Rows.Clear(); InitSubFunctionData(subFunction); AddFirstRow(subFunction); if (subFunction.Message == null || DcmDocument == null || !needSendParsing(subFunction) || subFunction.DataLen == 0) { AddDataRows(subFunction); } else //添加带解码编辑功能 { var msg = DcmDocument.VdfDocument.Message(subFunction.Message); if (msg == null) { AddDataRows(subFunction); } else { foreach (var entry in msg.SignalTable) { var signal = entry.Value; dataGridView.Rows.Add(new string[] { signal.Name, "" }); try { dataGridView.Rows[dataGridView.Rows.Count - 1] .Cells["ColumnData"] = NewDataCell(signal, subFunction, dataGridView.Rows.Count - 1); } catch (Exception ex) { MessageBox.Show(ex.Message, "更新单元格失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } UpdateReadOnly(subFunction); dataGridView.ResumeLayout(); this.subFunction = subFunction; }