Esempio n. 1
0
        private void ShowDevicesClick(object sender, EventArgs e)
        {
            RemoveControls();
            ShowDevices sd = new ShowDevices();

            sd.AddDeviceButtonClicked  -= AddDeviceClick;
            sd.AddDeviceButtonClicked  += AddDeviceClick;
            sd.EditDeviceButtonClicked -= EditDeviceClick;
            sd.EditDeviceButtonClicked += EditDeviceClick;
            ShowIcons("devices");
            contentPanel.Controls.Add(sd);
        }
Esempio n. 2
0
        private void ClientPlaceDevices(object sender, EventArgs e)
        {
            DataGridViewRow row    = ShowPlaces.selectedRow;
            int             miejID = Convert.ToInt32(row.Cells["id"].Value.ToString());

            RemoveControls();

            using (InzynierkaDBEntities db = new InzynierkaDBEntities())
            {
                ShowDevices sd = new ShowDevices(
                    ShowPlaces.podatnik,
                    db.Miejsce_instalacji.Where(x => x.miejsce_id == miejID).First());

                sd.AddDeviceButtonClicked  -= AddDeviceClick;
                sd.AddDeviceButtonClicked  += AddDeviceClick;
                sd.EditDeviceButtonClicked -= EditDeviceClick;
                sd.EditDeviceButtonClicked += EditDeviceClick;
                ShowIcons("devices");
                contentPanel.Controls.Add(sd);
            }
        }
Esempio n. 3
0
        private void ClientDevices(object sender, EventArgs e)
        {
            DataGridViewRow row = ShowClients.selectedRow;
            string          a   = row.Cells["nazwa"].Value.ToString();

            RemoveControls();

            using (InzynierkaDBEntities db = new InzynierkaDBEntities())
            {
                ShowDevices sd = new ShowDevices(
                    db.Podatnik.Where(x => x.nazwa == a).
                    FirstOrDefault()
                    );

                sd.AddDeviceButtonClicked  -= AddDeviceClick;
                sd.AddDeviceButtonClicked  += AddDeviceClick;
                sd.EditDeviceButtonClicked -= EditDeviceClick;
                sd.EditDeviceButtonClicked += EditDeviceClick;
                ShowIcons("devices");
                contentPanel.Controls.Add(sd);
            }
        }
Esempio n. 4
0
        /// <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;
        }