예제 #1
0
        private void suggestionListView_ItemActivate(object sender, EventArgs e)
        {
            // What kind of suggestion is this?
            ListViewItem item    = suggestionListView.Items[suggestionListView.SelectedIndices[0]];
            string       command = Convert.ToString(item.Tag);

            switch (command)
            {
            case "ConfigureGpsid":
                if (Devices.IsBluetoothSupported)
                {
                    MessageBox.Show("No serial devices could be found.  You can \"pair\" a Bluetooth GPS device to give it a serial port for your software to use.", "Use a Bluetooth Device", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                }
                else
                {
                    MessageBox.Show("No serial devices could be found.  If you have a GPS device to plug in to your PDA, plug it in now and try the scan again.", "Plug In a GPS Device", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
                break;

            case "NoDevices":
                MessageBox.Show("No GPS devices were found.  They may be turned off, out of range, or \"stuck open\".  If the device is on but shows a constant light, turn the device off then back on again.", "No Devices Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                break;

            case "UseGpsidPort":
                MessageBox.Show("Using the GPS Intermediate Driver is preferred because it will share your GPS device with multiple applications.", "Share Your GPS", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                break;

            case "WindowsMobileFirmware":
                MessageBox.Show("The .NET Compact Framework is unable to connect to the GPS Intermediate Driver.  A firmware update for your device may resolve this issue.", "Update Your Firmware", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                break;

            case "ThirdPartyGpsPort":
                MessageBox.Show("You can use the port \"" + preferredSerialDevice.Port + "\" and baud rate \"" + preferredSerialDevice.BaudRate.ToString() + "\" for your third-party GPS applications.", "Use " + preferredSerialDevice.Port, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                break;

            case "GpsidFixHardwarePort":
            case "GpsidIncorrectPort":
                if (MessageBox.Show("Would you like to configure the GPS Intermediate Driver (GPSID) to use a better device?", "Update Settings", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    // Update the setting
                    gpsid.HardwarePort = preferredSerialDevice;

                    // Restart the GPSID
                    gpsid.Restart();

                    if (MessageBox.Show("The GPSID has been updated to use \"" + preferredSerialDevice.Port + "\" at baud rate \"" + preferredSerialDevice.BaudRate.ToString() + "\".  Do you want to verify that it's working?", "Confirm Settings", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        // Restart the scan
                        menuRestart_Click(this, EventArgs.Empty);
                    }
                }
                break;

            case "GpsidUseVirtualBluetoothPort":
                if (MessageBox.Show("Would you like to configure the GPS Intermediate Driver (GPSID) to use a better device?", "Update Settings", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    // Update the setting
                    gpsid.HardwarePort = preferredVirtualSerialDevice;

                    // Restart the GPSID
                    gpsid.Restart();

                    if (MessageBox.Show("The GPSID has been updated to use \"" + preferredSerialDevice.Port + "\" at baud rate \"" + preferredSerialDevice.BaudRate.ToString() + "\".  Do you want to verify that it's working?", "Confirm Settings", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        // Restart the scan
                        menuRestart_Click(this, EventArgs.Empty);
                    }
                }
                break;

            case "BluetoothCreateVirtualPort":
                if (MessageBox.Show("Setting up a virtual serial port can make your Bluetooth GPS device available to programs.  Would you like to set this up now?", "Virtual Serial Port", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start(@"\windows\ctlpnl.exe", "cplmain.cpl,23");
                }
                break;

            case "GpsidNoDevice":
                MessageBox.Show("Your device supports sharing a GPS device with multiple applications, but no GPS devices were found.  Try hooking one up and running the scan again.", "No Devices Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                break;

            case "GpsidNotSupported":
                MessageBox.Show("This device runs an older operating system.  You can take advantage of GPS device sharing if you upgrade to Windows Mobile 5.0 or later.", "Consider Upgrading", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                break;

            case "BluetoothNotSupported":
                MessageBox.Show("The Bluetooth software on this device is not by Microsoft.  Everything may be working fine, but it limits the use of Bluetooth by some third-party applications.", "Other Bluetooth Stack", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                break;

            case "BluetoothOk":
                MessageBox.Show("Microsoft® Bluetooth software was found on this device, which is good.", "Microsoft® Bluetooth", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                break;

            case "TurnBluetoothOn":
                if (MessageBox.Show("Would you like to turn Bluetooth on now?", "Enable Bluetooth", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    // Enable Bluetooth
                    Devices.IsBluetoothEnabled = true;

                    // Was it actually enabled?
                    if (Devices.IsBluetoothEnabled)
                    {
                        if (MessageBox.Show("Bluetooth is now enabled.  Would you like to look for GPS devices again?", "Bluetooth Enabled", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                        {
                            menuRestart_Click(this, EventArgs.Empty);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Bluetooth could not be turned on.  You can turn Bluetooth on manually; look for a Bluetooth icon from the main Today screen, or from your Settings.", "Bluetooth Not Enabled", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }
                }
                break;

            case "TurnDeviceOn":
                MessageBox.Show("The device is a GPS device, but it may be turned off or \"stuck open.\"  Turn the device off then back on again.", "GPS Not Responding", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                break;

            case "AlternativeSerialPort":
                MessageBox.Show("You should use \"" + gpsid.Port + "\" in your software, but you could also use \"" + preferredSerialDevice.Port + "\" at \"" + preferredSerialDevice.BaudRate.ToString() + "\" baud.", "Alternative GPS Device", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                break;
            }
        }