Exemplo n.º 1
0
        private void _addressComboBox_SelectedValueChanged(object sender, EventArgs e)
        {
            if (_oldIndex > -1)
            {
                // TODO: check if things actually changed
                //if (DialogResult.Yes == MessageBox.Show("Would you like to save changes?", "Save Changes", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1))
                {
                    SaveAddressSettings();
                }
            }

            _connectMacroComboBox.SelectedIndex    = 0;
            _disconnectMacroComboBox.SelectedIndex = 0;

            AddressSelector.BluetoothDevice device = (AddressSelector.BluetoothDevice)_addressComboBox.SelectedItem;
            foreach (ConnectionSettingCollection.ConnectionSetting macroPair in Properties.Settings.Default.ConnectionSettings)
            {
                if (macroPair.Address == device.Address)
                {
                    foreach (KeyValuePair <string, string> value in _connectMacroComboBox.Items)
                    {
                        if (string.Equals(value.Value, macroPair.ConnectMacro))
                        {
                            _connectMacroComboBox.SelectedItem = value;
                            break;
                        }
                    }
                    foreach (KeyValuePair <string, string> value in _disconnectMacroComboBox.Items)
                    {
                        if (string.Equals(value.Value, macroPair.DisconnectMacro))
                        {
                            _disconnectMacroComboBox.SelectedItem = value;
                            break;
                        }
                    }
                    break;
                }
            }
            _oldIndex = _addressComboBox.SelectedIndex;
        }
Exemplo n.º 2
0
 private void SaveAddressSettings()
 {
     ConnectionSettingCollection.ConnectionSetting setting = null;
     AddressSelector.BluetoothDevice device = (AddressSelector.BluetoothDevice)_addressComboBox.Items[_oldIndex];
     foreach (ConnectionSettingCollection.ConnectionSetting macroPair in Properties.Settings.Default.ConnectionSettings)
     {
         if (macroPair.Address == device.Address)
         {
             setting = macroPair;
             break;
         }
     }
     if (null == setting)
     {
         setting = new ConnectionSettingCollection.ConnectionSetting();
         Properties.Settings.Default.ConnectionSettings.Add(setting);
         setting.Address    = device.Address;
         setting.LegacyMode = device.LegacyMode;
     }
     setting.ConnectMacro    = ((KeyValuePair <string, string>)_connectMacroComboBox.SelectedItem).Value;
     setting.DisconnectMacro = ((KeyValuePair <string, string>)_disconnectMacroComboBox.SelectedItem).Value;
 }
Exemplo n.º 3
0
        public DialogResult ShowDialog(MobileRemoteUI parentForm, WaitHandle waitResult, AddressSelector.BluetoothDevice device, BluetoothHidWriter hidWriter)
        {
            _statusLabel.Text = "Connecting...";
            _hidWriter        = hidWriter;
            _waitResult       = waitResult;
            if (device.Address > 0)
            {
                _existingMachine.Dock    = DockStyle.Fill;
                _existingMachine.Visible = true;
                _newMachineLabel.Visible = false;
            }
            else
            {
                _newMachineLabel.Dock    = DockStyle.Fill;
                _newMachineLabel.Visible = true;
                _existingMachine.Visible = false;
            }

            timer1.Enabled = true;

            if (waitResult.WaitOne(1000, false))
            {
                //return DialogResult.OK;
            }

            try
            {
                return(base.ShowDialog(parentForm));
            }
            finally
            {
                timer1.Enabled = false;
            }
        }