public void SendTextTo(Destinations destination, String text = null) { var f = Utilities.CreateTemporalFileFromText(text); var res = new SendResults(1, destination); if (f != null) { var fileSet = PrimeFileSet.Create(new[] { f }, new PrimeParameters(Settings.Default)); fileSet.Destination = destination; if (destination == Destinations.Custom) { var fs = new FolderSelectDialog { Title = "Select the destination folder" }; if (!fs.ShowDialog()) { return; // Conversion was cancel } fileSet.CustomDestination = fs.FileName; } else { fileSet.CustomDestination = _emulatorFolder; } SendDataTo(fileSet); res.Add(SendResult.Success); } else { res.Add(SendResult.ErrorInvalidInput); res.ShowMsg(false, this); } }
private void backgroundWorkerSend_DoWork(object sender, DoWorkEventArgs e) { var fs = (PrimeFileSet)e.Argument; var res = new SendResults(fs.Files.Length, fs.Destination); var nullFile = new PrimeUsbData(new byte[] { 0x00 }, null); foreach (var file in fs.Files) { try { var b = new PrimeProgramFile(file, Settings.Default); try { if (b.IsValid) { var primeFile = new PrimeUsbData(b.Name, b.Data, fs.Destination == Destinations.Calculator ? _calculator.OutputChunkSize : 0, Parameters); switch (fs.Destination) { case Destinations.Calculator: _calculator.Send(nullFile); _calculator.Send(primeFile); _calculator.Send(nullFile); res.Add(SendResult.Success); break; case Destinations.UserFolder: case Destinations.Custom: primeFile.Save(Path.Combine(fs.CustomDestination, primeFile.Name + ".hpprgm")); res.Add(SendResult.Success); break; } } else { res.Add(SendResult.ErrorInvalidFile); } } catch { res.Add(SendResult.ErrorSend); } } catch { res.Add(SendResult.ErrorReading); } backgroundWorkerSend.ReportProgress(0, res); } e.Result = res; }
private void FormMain_Shown(object sender, EventArgs e) { if (!Settings.Default.SkipConflictingProcessChecking) { // Check running processes if (new[] { Constants.ConnectivityKitProcessName, Constants.EmulatorProcessName }.Any(p => Process.GetProcessesByName(p).Length > 0)) { SendResults.ShowMsg("It seems you have either the Connectivity Kit or HP Virtual Prime running, this may conflict with this app to detect your physical calculator.", this); } } }
public void SendTextTo(Destinations destination, String text = null) { var f = Utilities.CreateTemporalFileFromText(text); var res = new SendResults(1, destination); if (f != null) { var fileSet = PrimeFileSet.Create(new[] {f}, new PrimeParameters(Settings.Default)); fileSet.Destination = destination; if (destination == Destinations.Custom) { var fs = new FolderSelectDialog {Title = "Select the destination folder"}; if (!fs.ShowDialog()) return; // Conversion was cancel fileSet.CustomDestination = fs.FileName; } else fileSet.CustomDestination = _emulatorFolder; SendDataTo(fileSet); res.Add(SendResult.Success); } else { res.Add(SendResult.ErrorInvalidInput); res.ShowMsg(false, this); } }
private void backgroundWorkerSend_DoWork(object sender, DoWorkEventArgs e) { var fs = (PrimeFileSet) e.Argument; var res = new SendResults(fs.Files.Length, fs.Destination); var nullFile = new PrimeUsbData(new byte[] {0x00}, null); foreach (var file in fs.Files) { try { var b = new PrimeProgramFile(file, Settings.Default); try { if (b.IsValid) { var primeFile = new PrimeUsbData(b.Name, b.Data, fs.Destination == Destinations.Calculator ? _calculator.OutputChunkSize : 0, Parameters); switch (fs.Destination) { case Destinations.Calculator: _calculator.Send(nullFile); _calculator.Send(primeFile); _calculator.Send(nullFile); res.Add(SendResult.Success); break; case Destinations.UserFolder: case Destinations.Custom: primeFile.Save(Path.Combine(fs.CustomDestination, primeFile.Name + ".hpprgm")); res.Add(SendResult.Success); break; } } else res.Add(SendResult.ErrorInvalidFile); } catch { res.Add(SendResult.ErrorSend); } } catch { res.Add(SendResult.ErrorReading); } backgroundWorkerSend.ReportProgress(0, res); } e.Result = res; }