/// <summary>Update UI elements</summary> private void UpdateUI(object sender = null, EventArgs args = null) { m_cb_pattern.BackColor = m_pat.IsValid ? Color.LightGreen : Color.LightSalmon; m_cb_pattern.ToolTip(m_tt, m_pat.SyntaxErrorDescription); m_radio_substr.Checked = m_pat.PatnType == EPattern.Substring; m_radio_wildcard.Checked = m_pat.PatnType == EPattern.Wildcard; m_radio_regexp.Checked = m_pat.PatnType == EPattern.RegularExpression; m_chk_ignore_case.Checked = m_pat.IgnoreCase; m_chk_invert.Checked = m_pat.Invert; }
/// <summary>Set up the UI</summary> private void SetupUI() { // Icons { DeviceImageList = new ImageList(components); DeviceImageList.TransparentColor = Color.Transparent; DeviceImageList.Images.Add(Bluetooth.EClassOfDeviceMajor.Miscellaneous.ToString(), Resources.bt_misc); DeviceImageList.Images.Add(Bluetooth.EClassOfDeviceMajor.Computer.ToString(), Resources.bt_laptop); DeviceImageList.Images.Add(Bluetooth.EClassOfDeviceMajor.Phone.ToString(), Resources.bt_phone); DeviceImageList.Images.Add(Bluetooth.EClassOfDeviceMajor.LanAccess.ToString(), Resources.bt_lan_access); DeviceImageList.Images.Add(Bluetooth.EClassOfDeviceMajor.Audio.ToString(), Resources.bt_audio); DeviceImageList.Images.Add(Bluetooth.EClassOfDeviceMajor.Peripheral.ToString(), Resources.bt_peripheral); DeviceImageList.Images.Add(Bluetooth.EClassOfDeviceMajor.Imaging.ToString(), Resources.bt_imaging); DeviceImageList.Images.Add(Bluetooth.EClassOfDeviceMajor.Wearable.ToString(), Resources.bt_wearable); DeviceImageList.Images.Add(Bluetooth.EClassOfDeviceMajor.Toy.ToString(), Resources.bt_misc); DeviceImageList.Images.Add(Bluetooth.EClassOfDeviceMajor.Unclassified.ToString(), Resources.bt_misc); } // Radio m_cb_radio.ToolTip(m_tt, "Select a specific bluetooth radio"); PopulateRadios(); m_cb_radio.Format += (s, a) => { var radio = a.ListItem as Bluetooth.Radio; a.Value = radio?.Name ?? (string)a.ListItem; }; m_cb_radio.SelectedIndexChanged += (s, a) => { Radio = m_cb_radio.SelectedItem as Bluetooth.Radio; }; // Control panel m_btn_show_bt_cpl.Click += (s, a) => { Process.Start(new ProcessStartInfo("control", "bthprops.cpl")); }; // Discoverable m_chk_discoverable.ToolTip(m_tt, "Check to allow other devices to discovery this PC"); m_chk_discoverable.Checked = Discoverable; m_chk_discoverable.CheckedChanged += (s, a) => { Discoverable = m_chk_discoverable.Checked; }; // Show connected devices m_chk_show_connected.ToolTip(m_tt, "Show devices that have connected with this system"); m_chk_show_connected.Checked = ShowDevices.HasFlag(Bluetooth.EOptions.ReturnConnected); m_chk_show_connected.CheckedChanged += (s, a) => { ShowDevices = Bit.SetBits(ShowDevices, Bluetooth.EOptions.ReturnConnected, m_chk_show_connected.Checked); }; // Show authenticated devices m_chk_show_paired.ToolTip(m_tt, "Show devices that have paired with this system"); m_chk_show_paired.Checked = ShowDevices.HasFlag(Bluetooth.EOptions.ReturnAuthenticated); m_chk_show_paired.CheckedChanged += (s, a) => { ShowDevices = Bit.SetBits(ShowDevices, Bluetooth.EOptions.ReturnAuthenticated, m_chk_show_paired.Checked); }; // Show remembered devices m_chk_show_remembered.ToolTip(m_tt, "Show devices that have connected with this system in the past"); m_chk_show_remembered.Checked = ShowDevices.HasFlag(Bluetooth.EOptions.ReturnRemembered); m_chk_show_remembered.CheckedChanged += (s, a) => { ShowDevices = Bit.SetBits(ShowDevices, Bluetooth.EOptions.ReturnRemembered, m_chk_show_remembered.Checked); }; // Show unknown devices m_chk_show_unknown.ToolTip(m_tt, "Show discovered devices that have not yet connected or paired with this system"); m_chk_show_unknown.Checked = ShowDevices.HasFlag(Bluetooth.EOptions.ReturnUnknown); m_chk_show_unknown.CheckedChanged += (s, a) => { ShowDevices = Bit.SetBits(ShowDevices, Bluetooth.EOptions.ReturnUnknown, m_chk_show_unknown.Checked); }; // Found devices m_lb_devices.SelectedIndexChanged += (s, a) => { Device = (Bluetooth.Device)m_lb_devices.SelectedItem; }; m_lb_devices.DrawItem += (s, a) => { DrawBtDevice(a); }; m_lb_devices.MouseUp += (s, a) => { if (a.Button == MouseButtons.Right) { var idx = m_lb_devices.IndexFromPoint(a.Location); if (idx >= 0) { m_lb_devices.SelectedIndex = idx; ShowCMenu(a); } } }; // Pair/Forget m_btn_pair.Click += (s, a) => { if (m_btn_pair.Text == PairBtn.Disconnect) { DisconnectDevice(); } if (m_btn_pair.Text == PairBtn.Pair) { PairDevice(); } }; // Timer for polling while bluetooth is disabled m_timer.Interval = 1000; m_timer.Tick += (s, a) => { PopulateRadios(); PopulateDevices(); }; m_timer.Enabled = true; }