Exemplo n.º 1
0
        public static int SetCompatabilityMode()
        {
            int radioCOD = GetRadioCOD();

            if (!GetInCompatabilityMode())
            {
                L2CAPAPI.RadioMode radioMode = L2CAPAPI.RadioMode.Off;
                L2CAPAPI.BthGetMode(out radioMode);

                if (radioMode != L2CAPAPI.RadioMode.Off)
                {
                    L2CAPAPI.BthSetMode(L2CAPAPI.RadioMode.Off);
                }
                try
                {
                    Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Microsoft\Bluetooth\sys", "COD", CODCompatabilityMode);
                    L2CAPAPI.BthSetMode(L2CAPAPI.RadioMode.Discoverable);
                }
                finally
                {
                    //Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Microsoft\Bluetooth\sys", "COD", radioCOD);
                }
            }
            return(radioCOD);
        }
Exemplo n.º 2
0
        public int WriteRawData(ushort cid, uint length, byte[] pkg)
        {
            if (0 != cid && _state == 1)
            {
                if (_isRecording)
                {
                    // TODO: need to have higher resolution than milliseconds...perhaps have a list of byte[]'s
                    TimeSpan timeSpan = DateTime.Now.Subtract(_recordingStart);
                    //while (timeSpan.Ticks == 0 || _macroBytes.ContainsKey(timeSpan))
                    //{
                    //    timeSpan = timeSpan.Add(new TimeSpan(0, 0, 0, 0, 1));
                    //}
                    try
                    {
                        Program.Debug.WriteLine(pkg[4].ToString());
                        _macroBytes.Add(new KeyValuePair <TimeSpan, byte[]>(timeSpan, (byte[])pkg.Clone()));
                    }
                    catch (Exception e)
                    {
                        Program.Debug.WriteLine(e.Message);
                        Program.Debug.WriteLine(e.StackTrace);
                        Program.Debug.WriteLine(timeSpan.ToString());

                        foreach (KeyValuePair <TimeSpan, byte[]> key in _macroBytes)
                        {
                            Program.Debug.WriteLine(key.Key.ToString());
                        }
                    }
                }
                return(L2CAPAPI.L2CAPWrite(cid, length, pkg));
            }
            return(-1);
        }
Exemplo n.º 3
0
 protected override void OnLostFocus(EventArgs e)
 {
     base.OnLostFocus(e);
     if (Platform.IsWindowsMobileStandard)
     {
         IntPtr hC = L2CAPAPI.ImmGetContext(this.Handle);
         L2CAPAPI.ImmEscape(IntPtr.Zero, hC, L2CAPAPI.IME_ESC_RETAIN_MODE_ICON, new IntPtr(1));
         //L2CAPAPI.ImmSetOpenStatus(this.Handle, false);
     }
 }
Exemplo n.º 4
0
        void SetIMEMode()
        {
            uint   ret  = 0;
            bool   bret = false;
            IntPtr hC   = L2CAPAPI.ImmGetContext(MobileRemoteUI.Instance.Handle);

            // Open the IME
            bret = L2CAPAPI.ImmSetOpenStatus(hC, true);
            // Set "multi-press" input mode
            ret = (uint)L2CAPAPI.ImmEscape(IntPtr.Zero, hC, L2CAPAPI.IME_ESC_SET_MODE, L2CAPAPI.IM_SPELL);
        }
Exemplo n.º 5
0
        void MobileRemoteUI_Closing(object sender, CancelEventArgs e)
        {
            L2CAPAPI.RadioMode currentRadioMode = 0;
            L2CAPAPI.BthGetMode(out currentRadioMode);

            if (currentRadioMode != _initialRadioMode)
            {
                L2CAPAPI.BthSetMode(_initialRadioMode);
            }
            _hidWriter.Dispose();
        }
Exemplo n.º 6
0
        private void ShowConnectDialog(bool autoConnect)
        {
            L2CAPAPI.RadioMode radioMode = L2CAPAPI.RadioMode.Off;
            L2CAPAPI.BthGetMode(out radioMode);

            if (radioMode != L2CAPAPI.RadioMode.Discoverable)
            {
                if (autoConnect || (DialogResult.Yes == MessageBox.Show("MobileRemote requires that Bluetooth is enabled.  Would you like to enable Bluetooth on your phone?", "Bluetooth Required", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)))
                {
                    L2CAPAPI.BthSetMode(L2CAPAPI.RadioMode.Discoverable);
                }
                else
                {
                    return;
                }
            }

            using (AddressSelector selector = new AddressSelector())
            {
                bool firstConnect = autoConnect && (selector.SelectedDevice.Address != 0);
                if (firstConnect || (DialogResult.OK == selector.ShowDialog(this)))
                {
                    if (null != selector.SelectedDevice)
                    {
                        bool legacyMode = selector.LegacyMode;
                        int  oldMode    = 0;

                        if (legacyMode)
                        {
                            oldMode = Utils.SetCompatabilityMode();
                        }
                        WaitHandle result = _hidWriter.ConnectAsync(selector.SelectedDevice.Address);
                        try
                        {
                            using (WaitForConnection waitDialog = new WaitForConnection())
                            {
                                if (DialogResult.OK != waitDialog.ShowDialog(this, result, selector.SelectedDevice, _hidWriter))
                                {
                                    _hidWriter.Disconnect();
                                }
                            }
                        }
                        finally
                        {
                            if (legacyMode)
                            {
                                Utils.UnsetCompatabilityMode(oldMode);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        public void Disconnect()
        {
            _state = 0;

            if (_connected)
            {
                _connected = false;
            }

            L2CAPAPI.L2CAPClosePSM(L2CAP_PSM_HIDP_INTR);
            L2CAPAPI.L2CAPClosePSM(L2CAP_PSM_HIDP_CTRL);

            if (0 != _cidCtrl)
            {
                L2CAPAPI.L2CAPCloseCID(_cidCtrl);
                _cidCtrl = 0;
            }
            if (0 != _cidIntr)
            {
                L2CAPAPI.L2CAPCloseCID(_cidIntr);
                _cidIntr = 0;
            }
            _bluetoothAddress = 0;

            if (null != Disconnected)
            {
                Disconnected(this, null);
            }

            if (null != _intrThread)
            {
                if (Thread.CurrentThread != _intrThread)
                {
                    _intrThread.Abort();
                }
            }
            if (null != _ctrlThread)
            {
                if (Thread.CurrentThread != _ctrlThread)
                {
                    _ctrlThread.Abort();
                }
            }
            lock (this)
            {
                if (null != _connectThread)
                {
                    _connectThread.Abort();
                    _connectThread = null;
                }
            }
        }
Exemplo n.º 8
0
        public void Dispose()
        {
            Disconnect();

            if (_l2capLoaded)
            {
                L2CAPAPI.L2CAPUnload();
            }
            if (_sdpRegistered)
            {
                L2CAPAPI.SDPCleanup();
            }
        }
Exemplo n.º 9
0
        protected override void OnGotFocus(EventArgs e)
        {
            base.OnGotFocus(e);
            if (Platform.IsWindowsMobileStandard)
            {
                bool   bret = false;
                IntPtr hC   = L2CAPAPI.ImmGetContext(this.Handle);
                // Open the IME
                bret = L2CAPAPI.ImmSetOpenStatus(hC, true);
                // Set "multi-press" input mode

                L2CAPAPI.ImmEscape(IntPtr.Zero, hC, L2CAPAPI.IME_ESC_SET_MODE, L2CAPAPI.IM_SPELL);
            }
        }
Exemplo n.º 10
0
        private void ListenOnCtrl()
        {
            Program.Debug.WriteLine("ListenOnCtrl started");
            ushort ctrlCid = _cidCtrl;

            for (; ;)
            {
                byte[] ucBuffer = new byte[1024];
                uint   cSize    = 0;

                Program.Debug.WriteLine("Try Read CTRL");
                int iErr = L2CAPAPI.L2CAPRead(ctrlCid, (uint)ucBuffer.Length, ref cSize, ucBuffer);
                Program.Debug.WriteLine(String.Format("Read CTRL : {0} [cSize={1}, ucBuffer[0] = {2}]", iErr, cSize, (cSize > 0) ? ucBuffer[0] : -1));
                if (iErr != 0)
                {
                    Disconnect();
                    break;
                }

                if (cSize > 0 && 0 != (ucBuffer[0] & 0x70))
                {
                    byte[] szBuffer = new byte[1];
                    szBuffer[0] = 0;

                    iErr = L2CAPAPI.L2CAPWrite(ctrlCid, 1, szBuffer);
                    Program.Debug.WriteLine("Write CTRL: Responding to 0x70: " + iErr);

                    _state = 1;
                }
                else if (cSize > 0 && 0 != (ucBuffer[0] & 0x90))
                {
                    byte[] szBuffer = new byte[1];
                    szBuffer[0] = 0;

                    iErr = L2CAPAPI.L2CAPWrite(ctrlCid, 1, szBuffer);
                    Program.Debug.WriteLine("Write CTRL: Responding to 0x90: " + iErr);

                    _state = 1;
                }
                else
                {
                    byte[] szBuffer = new byte[1];
                    szBuffer[0] = 0;

                    iErr = L2CAPAPI.L2CAPWrite(ctrlCid, 1, szBuffer);
                    Program.Debug.WriteLine("Write CTRL: No Response");
                }
            }
        }
Exemplo n.º 11
0
        private void Initialize()
        {
            _sdpRegistered = _l2capLoaded = false;
            int iErr = 0;

            try
            {
                iErr = L2CAPAPI.SDPRegister();

                if (0 == iErr)
                {
                    _sdpRegistered = true;
                    int result = 0;

                    if (0 == (result = L2CAPAPI.L2CAPLoad()))
                    {
                        _l2capLoaded = true;
                    }
                    else if (0 == (result = L2CAPAPI.L2CAPLoad()))
                    {
                        _l2capLoaded = true;
                    }
                    else
                    {
                        iErr = result;
                        Program.Debug.WriteError("L2CAPLoad failed", result);
                    }
                }
                else
                {
                    Program.Debug.WriteError("SDPRegister failed", iErr);
                }
            }
            catch (Exception e)
            {
                Program.Debug.WriteError("Initialize failed: " + e.ToString(), 0);
            }
            if (!_l2capLoaded)
            {
                // we failed to load our driver here...
                MessageBox.Show("Failed to load driver: " + iErr);
            }
        }
Exemplo n.º 12
0
        private void ListenOnIntr()
        {
            Program.Debug.WriteLine("ListenOnIntr started");
            ushort intrCid = _cidIntr;

            for (; ;)
            {
                byte[] ucBuffer = new byte[1024];
                uint   cSize    = 0;

                Program.Debug.WriteLine("Try Read INTR");
                int iErr = L2CAPAPI.L2CAPRead(intrCid, (uint)ucBuffer.Length, ref cSize, ucBuffer);
                Program.Debug.WriteLine("Read INTR : " + iErr);

                if (iErr != 0)
                {
                    Disconnect();
                    break;
                }
            }
        }
Exemplo n.º 13
0
        public static void UnregisterServices()
        {
            ulong addr = GetLocalRadioAddress();

            L2CAPAPI.UnregisterServices(ref addr);
        }
Exemplo n.º 14
0
        public static void AddNewAddress(UInt64 address, bool legacyMode)
        {
            if (!Utils.CheckRegistration())
            {
                return;
            }
            List <BluetoothDevice> devices = GetPreviousDevices();

            string szName = string.Empty;// address.ToString("C");

            try
            {
                int    num;
                byte[] szString = new byte[0x1f0];
                if (0 == L2CAPAPI.BthRemoteNameQuery(ref address, 0xf8, out num, szString) || num == 0)
                {
                    szName = Encoding.Unicode.GetString(szString, 0, (num - 1) * 2);;
                }
            }
            catch
            {
            }

            if (string.IsNullOrEmpty(szName))
            {
                using (StringInput si = new StringInput("Enter Name", "Enter the name of this connection..."))
                {
                    si.ShowDialog(MobileRemoteUI.Instance);
                    szName = si.Value;
                }
            }

            StringBuilder sbAddresses = new StringBuilder();

            sbAddresses.Append(String.Format("{0}={1}={2}", szName, address, legacyMode));

            List <string> names    = new List <string>();
            List <ulong>  addrs    = new List <ulong>();
            List <bool>   legModes = new List <bool>();

            for (int i = 0; i < devices.Count; ++i)
            {
                if (names.Contains(devices[i].Name) || addrs.Contains(devices[i].Address))
                {
                    devices.RemoveAt(i);
                    i--;
                }
                else
                {
                    names.Add(devices[i].Name);
                    addrs.Add(devices[i].Address);
                    legModes.Add(devices[i].LegacyMode);
                }
            }

            for (int i = 0; i < devices.Count; ++i)
            {
                if (devices[i].Address != address)
                {
                    sbAddresses.Append(",");
                    sbAddresses.Append(String.Format("{0}={1}={2}", devices[i].Name, devices[i].Address, devices[i].LegacyMode));
                }
            }

            using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\MobileSrc\MobileRemote"))
            {
                key.SetValue("PreviousAddresses", sbAddresses.ToString(), RegistryValueKind.String);
            }
        }
Exemplo n.º 15
0
        public bool Connect(UInt64 bluetoothAddress)
        {
            if (_connected)
            {
                Disconnect();
            }

            Program.Debug.WriteLine("Connecting to: " + bluetoothAddress);

            //_connected = true;
            //return true;

            _bluetoothAddress = bluetoothAddress;

            int    iErr = 0;
            ushort outmtu = 0, intrCid = 0, ctrlCid = 0;

            _connected = false;

            if (0 != _bluetoothAddress)
            {
                UInt64 ba = _bluetoothAddress;

                Program.Debug.WriteLine("Connect CTRL: " + bluetoothAddress);
                if (0 == (iErr = L2CAPAPI.L2CAPConnect(ref ba, L2CAP_PSM_HIDP_CTRL, 48, ref ctrlCid, ref outmtu)))
                {
                    Program.Debug.WriteLine("Connect INTR: " + bluetoothAddress);
                    if (0 == (iErr = L2CAPAPI.L2CAPConnect(ref ba, L2CAP_PSM_HIDP_INTR, 48, ref intrCid, ref outmtu)))
                    {
                        _connected = true;
                    }
                    else
                    {
                        Program.Debug.WriteError("Connect INTR failed", iErr);
                    }
                }
                else
                {
                    Program.Debug.WriteError("Connect CTRL failed", iErr);
                }
            }
            else
            {
                if (!_connected)
                {
                    _connected = false;

                    UInt64 ba = 0;
                    if (0 == (iErr = L2CAPAPI.L2CAPListen(L2CAP_PSM_HIDP_CTRL, 48)))
                    {
                        if (0 == (iErr = L2CAPAPI.L2CAPListen(L2CAP_PSM_HIDP_INTR, 48)))
                        {
                            if (0 == (iErr = L2CAPAPI.L2CAPAccept(L2CAP_PSM_HIDP_CTRL, ref ba, ref ctrlCid, ref outmtu)))
                            {
                                if (0 == (iErr = L2CAPAPI.L2CAPAccept(L2CAP_PSM_HIDP_INTR, ref ba, ref intrCid, ref outmtu)))
                                {
                                    _connected        = true;
                                    _bluetoothAddress = ba;
                                }
                                else
                                {
                                    Program.Debug.WriteError("Accept INTR failed", iErr);
                                }
                            }
                            else
                            {
                                Program.Debug.WriteError("Accept CTRL failed", iErr);
                            }
                        }
                        else
                        {
                            Program.Debug.WriteError("Listen CTRL failed", iErr);
                        }
                    }
                    else
                    {
                        Program.Debug.WriteError("Listen INTR failed", iErr);
                    }

                    if (!_connected)
                    {
                        Program.Debug.WriteLine("Disconnecting: " + bluetoothAddress);
                        iErr = L2CAPAPI.L2CAPClosePSM(L2CAP_PSM_HIDP_INTR);
                        iErr = L2CAPAPI.L2CAPClosePSM(L2CAP_PSM_HIDP_CTRL);
                    }
                }
            }

            if (_connected)
            {
                Program.Debug.WriteLine("Connected. Launching listeners: " + bluetoothAddress);
                // write our stuff here
                //unsafe
                //{
                //    L2CAPAPI.btFLOWSPEC flowSpec = new L2CAPAPI.btFLOWSPEC();
                //    flowSpec.token_rate = 900;
                //    flowSpec.token_bucket_size = 20;
                //    flowSpec.peak_bandwidth = 900;
                //    flowSpec.latency = 10;
                //    flowSpec.delay_variation = 10;
                //    flowSpec.service_type = 1;

                //    iErr = L2CAPAPI.L2CAPConfigReq(_cidIntr, 48, 0xFF, &flowSpec, 0, null);
                //}

                ThreadStart listenThreadIntr = new ThreadStart(ListenOnIntr);
                ThreadStart listenThreadCtrl = new ThreadStart(ListenOnCtrl);

                _cidIntr = intrCid;
                _cidCtrl = ctrlCid;

                _intrThread = new Thread(listenThreadIntr);
                _intrThread.IsBackground = true;
                _ctrlThread = new Thread(listenThreadCtrl);
                _ctrlThread.IsBackground = true;

                _intrThread.Start();
                _ctrlThread.Start();

                _state = 1;

                Program.Debug.WriteLine("Firing connected event");
                if (null != Connected)
                {
                    Connected(this, null);
                }
            }
            return(_connected);
        }
Exemplo n.º 16
0
        public MobileRemoteUI()
        {
            this.IsLoaded = false;
            Properties.Settings.Load();
            L2CAPAPI.BthGetMode(out _initialRadioMode);
            _instance      = this;
            this.Load     += new EventHandler(MobileRemoteUI_Load);
            this.GotFocus += new EventHandler(MobileRemoteUI_GotFocus);
            _inputs        = new List <InputInterfaceControl>(
                new InputInterfaceControl[]
            {
                new InputInterfaceControl("Keyboard", _keyboardControl, Properties.Resources.keyboard, Properties.Resources.keyboard_down, Properties.Resources.keyboard_sel),
                new InputInterfaceControl("Mouse", _mouseControl, Properties.Resources.mouse, Properties.Resources.mouse_down, Properties.Resources.mouse_sel),
                new InputInterfaceControl("TouchPad", _touchPanel, Properties.Resources.touch, Properties.Resources.touch_down, Properties.Resources.touch_sel),
                //new InputInterfaceControl("Media", _mediaControl, Properties.Resources.media, Properties.Resources.media_down, Properties.Resources.media_sel),
                //new InputInterfaceControl("Present", _presentControl, Properties.Resources.present, Properties.Resources.present_down, Properties.Resources.present_sel)
            }
                );
            InitializeComponent();

            _hidWriter               = new BluetoothHidWriter();
            _hidWriter.Connected    += new EventHandler(_hidWriter_Connected);
            _hidWriter.Disconnected += new EventHandler(_hidWriter_Disconnected);

            //_presentControl.HidWriter = _hidWriter;
            //_mediaControl.HidWriter = _hidWriter;
            _mouseControl.HidWriter    = _hidWriter;
            _touchPanel.HidWriter      = _hidWriter;
            _keyboardControl.HidWriter = _hidWriter;
            _connectButton.HidWriter   = _hidWriter;

            XmlSerializer xs = new XmlSerializer(typeof(Classes.CustomInput));

            foreach (string customInput in Directory.GetFiles(Path.Combine(Utils.GetWorkingDirectory(), "CustomInputs")))
            {
                using (StreamReader fs = File.OpenText(customInput))
                {
                    Classes.CustomInput ci = (Classes.CustomInput)xs.Deserialize(fs);
                    ci.ScaleToResolution();

                    CustomInputControl    input            = new CustomInputControl(ci, _hidWriter);
                    InputInterfaceControl interfaceControl = new InputInterfaceControl
                                                             (
                        ci.Name, input,
                        CustomInputControl.GetBitmap(ci.Image),
                        CustomInputControl.GetBitmap(ci.DownImage),
                        CustomInputControl.GetBitmap(ci.SelectedImage)
                                                             );

                    _inputs.Add(interfaceControl);
                }
            }

            Menu menu = null;

            if (!Platform.IsWindowsMobileClassic)
            {
                int totalButtonsVisible = (buttonPanel1.Width / buttonPanel1.Height) - 2;

                if (_inputs.Count < totalButtonsVisible)
                {
                    // great...
                    buttonPanel1.Controls.Remove(_inputsButton);
                }
                else
                {
                    totalButtonsVisible--;
                }

                int count = 0;
                foreach (InputInterfaceControl control in _inputs)
                {
                    PushButton button = new PushButton();
                    button.DownImage     = control.Down;
                    button.Image         = control.Up;
                    button.Name          = control.Text;
                    button.Text          = control.Text;
                    button.SelectedImage = control.Sel;
                    button.Size          = new System.Drawing.Size(buttonPanel1.Height, buttonPanel1.Height);
                    button.TabIndex      = 11;
                    button.Dock          = DockStyle.Left;
                    button.Click        += new EventHandler(button_Click);
                    button.RightClick   += new EventHandler(_controlSettingsMenu_Click);

                    if (_inputList.Count < totalButtonsVisible)
                    {
                    }
                    else
                    {
                        button.Visible = false;
                    }
                    buttonPanel1.Controls.Add(button);
                    buttonPanel1.Controls.SetChildIndex(button, count++);

                    control.Click = button_Click;
                    control.Tag   = button;

                    _inputList.Add(button, control);
                }
                ((PushButton)_inputs[0].Tag).IsSelected = true;

                menu = _mainContextMenu;
            }
            else
            {
                this.buttonPanel1.Visible = false;

                _leftMenu      = new MenuItem();
                _leftMenu.Text = "";

                MenuItem rightMenu = new MenuItem();
                rightMenu.Text = "Menu";

                _mainMenu.MenuItems.Add(_leftMenu);
                _mainMenu.MenuItems.Add(rightMenu);

                int i = 0;
                foreach (InputInterfaceControl control in _inputs)
                {
                    if (!control.Control.RequiresTouchscreen)
                    {
                        MenuItem menuItem = new MenuItem();
                        menuItem.Text   = String.Format("&{1}", i++, control.Text);
                        menuItem.Click += new EventHandler(menuItem_Click);
                        rightMenu.MenuItems.Add(menuItem);

                        control.Click = menuItem_Click;
                        control.Tag   = menuItem;

                        _inputList.Add(menuItem, control);
                    }
                }
                ((MenuItem)_inputs[0].Tag).Checked = true;

                MenuItem seperatorMenu1 = new MenuItem();
                seperatorMenu1.Text = "-";
                rightMenu.MenuItems.Add(seperatorMenu1);

                this.Menu = _mainMenu;
                menu      = rightMenu;
            }


            MenuItem connectionSettingsMenu = new MenuItem();

            connectionSettingsMenu.Text   = "Connection &Settings";
            connectionSettingsMenu.Click += new EventHandler(connectionSettingsMenu_Click);

            _controlSettingsMenu.Text   = "Control Settings";
            _controlSettingsMenu.Click += new EventHandler(_controlSettingsMenu_Click);

            MenuItem recorderMenu = new MenuItem();

            recorderMenu.Text = "&Recorder";

            _startRecorder.Text   = "&Create Recording";
            _startRecorder.Click += new EventHandler(startRecorder_Click);

            _stopRecorder.Text    = "&Stop Recording";
            _stopRecorder.Enabled = false;
            _stopRecorder.Click  += new EventHandler(stopRecorder_Click);

            _loadRecorder.Text    = "&Load Recording";
            _loadRecorder.Enabled = true;
            _loadRecorder.Popup  += new EventHandler(_loadRecorder_Popup);

            MenuItem nullMenuItem = new MenuItem();

            nullMenuItem.Text = "--No Saved Recordings--";
            _loadRecorder.MenuItems.Add(nullMenuItem);

            recorderMenu.MenuItems.Add(_loadRecorder);
            recorderMenu.MenuItems.Add(_startRecorder);
            recorderMenu.MenuItems.Add(_stopRecorder);

            _connectionMenuItem.Text   = "&Connect";
            _connectionMenuItem.Click += new EventHandler(connect_Click);

            _registerMenu.Text   = "Re&gister";
            _registerMenu.Click += new EventHandler(_registerMenu_Click);

            MenuItem aboutMenuItem = new MenuItem();

            aboutMenuItem.Text   = "&About";
            aboutMenuItem.Click += new EventHandler(aboutMenuItem_Click);

            MenuItem exitMenu = new MenuItem();

            exitMenu.Text   = "E&xit";
            exitMenu.Click += new EventHandler(exitMenu_Click);

            menu.MenuItems.Add(recorderMenu);
            menu.MenuItems.Add(_connectionMenuItem);
            menu.MenuItems.Add(connectionSettingsMenu);
            menu.MenuItems.Add(_controlSettingsMenu);
            menu.MenuItems.Add(_registerMenu);
            menu.MenuItems.Add(aboutMenuItem);
            menu.MenuItems.Add(exitMenu);

            SetActivePanel(_inputs[0]);
            this.Closing += new CancelEventHandler(MobileRemoteUI_Closing);
            this.IsLoaded = true;
        }