Exemplo n.º 1
0
        private void InitializeGui()
        {
            var v = Assembly.GetExecutingAssembly().GetName().Version;

            Text = String.Format("{0} v{1} b{2}", Application.ProductName, v.ToString(2), v.Build);

            // Save
            openFilesDialogProgram.Filter = Resources.FilterInput;
            openFileDialogProgram.Filter  = Resources.FilterInput;
            saveFileDialogProgram.Filter  = Resources.FilterOutput;

            _userFilesFolder = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Connectivity Kit", "WorkFolder", null) as string;
            connectivityKitUserFolderToolStripMenuItem.Enabled = _userFilesFolder != null && Directory.Exists(_userFilesFolder);

            _emulatorFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "HP_Prime");
            sendToEmulatorKitToolStripMenuItem.Enabled = IsWorkFolderAvailable;
            emulatorToolStripMenuItem.Enabled          = sendToEmulatorKitToolStripMenuItem.Enabled;
            exploreVirtualHPPrimeWorkingFolderToolStripMenuItem.Enabled = sendToEmulatorKitToolStripMenuItem.Enabled;

            _emulatorExeFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
                                            @"Hewlett-Packard\HP Prime Virtual Calculator\HPPrime.exe");

            //UpdateDevices();
            _calculator               = new PrimeCalculator();
            _calculator.Connected    += usbCalculator_OnSpecifiedDeviceArrived;
            _calculator.Disconnected += usbCalculator_OnSpecifiedDeviceRemoved;
            _calculator.DataReceived += usbCalculator_OnDataReceived;
            _calculator.CheckForChanges();
        }
Exemplo n.º 2
0
 protected override void WndProc(ref Message m)
 {
     if (m.Msg == 0x0219 && _calculator != null)
     {
         _calculator.CheckForChanges();
     }
     base.WndProc(ref m); // Pass message on to base form
 }
Exemplo n.º 3
0
        private static void WaitForDevice(PrimeCalculator calculator, int timeout)
        {
            Console.WriteLine("Connecting to the device..."); Console.WriteLine();
            var t = Stopwatch.StartNew();

            do
            {
                calculator.CheckForChanges();
                if (calculator.IsConnected)
                {
                    break;
                }
                Thread.Sleep(500);
            } while (t.Elapsed.TotalSeconds < timeout);
        }