private void CreateHandler()
        {
            var port = ComManager.GetComPort();

            panelControls.Enabled = !string.IsNullOrWhiteSpace(port);

            if (string.IsNullOrWhiteSpace(port))
            {
                MessageBox.Show(@"COM port not found!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                statusCom.Text            = port;
                _comHandler               = new ComHandler(port);
                _comHandler.DataReceived += _comHandler_DataReceived;
                _comHandler.Start();
            }

            UpdateOnButton();
        }
        private void RefreshComPorts()
        {
            comboPorts.Items.Clear();
            // ReSharper disable once CoVariantArrayConversion
            comboPorts.Items.AddRange(ComManager.ListComPorts()
                                      .Select(x => x.Name)
                                      .ToArray());

            var selectedComPort = ComManager.GetComPort();

            if (!string.IsNullOrEmpty(selectedComPort) && comboPorts.Items.Contains(selectedComPort))
            {
                comboPorts.SelectedItem = selectedComPort;
            }
            else
            {
                if (comboPorts.Items.Count > 0)
                {
                    comboPorts.SelectedIndex = 0;
                }
            }
        }