Exemplo n.º 1
0
        public MainForm()
        {
            InitializeComponent();
            m_obdInterface               = new OBDInterface();
            m_obdInterface.OnConnect    += new OBDInterface.__Delegate_OnConnect(On_OBD_Connect);
            m_obdInterface.OnDisconnect += new OBDInterface.__Delegate_OnDisconnect(On_OBD_Disconnect);

            m_originFont = buttonDefaultFontStyle.Font;
            m_boldFont   = new Font(m_originFont, FontStyle.Bold);

            StatusLabelConnStatus.ForeColor = Color.Red;
            StatusLabelConnStatus.Text      = "OBD通讯接口未连接";
            StatusLabelDeviceName.Text      = "未获取到设备名";
            StatusLabelAppProtocol.Text     = "应用层协议待定";
            StatusLabelCommProtocol.Text    = m_obdInterface.GetProtocol().ToString();
            StatusLabelDeviceType.Text      = m_obdInterface.GetDevice().ToString();
            if (m_obdInterface.CommSettings != null)
            {
                if (m_obdInterface.CommSettings.AutoDetect)
                {
                    StatusLabelPort.Text = "自动探测";
                }
                else
                {
                    StatusLabelPort.Text = m_obdInterface.CommSettings.ComPortName;
                }
            }

            InitSubForm();
            this.Text = "SH_OBD - Ver " + MainFileVersion.AssemblyVersion;
        }
Exemplo n.º 2
0
 private void On_OBD_Connect()
 {
     if (InvokeRequired)
     {
         this.Invoke((EventHandler) delegate {
             On_OBD_Connect();
         });
     }
     else
     {
         StatusLabelConnStatus.Text      = "OBD通讯接口已连接";
         StatusLabelConnStatus.ForeColor = Color.Green;
         StatusLabelDeviceName.Text      = m_obdInterface.GetDeviceIDString();
         StatusLabelCommProtocol.Text    = m_obdInterface.GetProtocol().ToString();
         toolStripBtnUserPrefs.Enabled   = false;
         toolStripBtnVehicles.Enabled    = false;
         toolStripBtnSettings.Enabled    = false;
         BroadcastConnectionUpdate();
     }
 }