I'm trying to make a QRCode reader, in my iOS app. I can't get the QR reading value
var optionsDefault = new MobileBarcodeScanningOptions();
var scanner = new MobileBarcodeScanner()
{
TopText = "Inquadra il QR Code",
BottomText = "MyfitnessApp",
};
var scanResult = await scanner.Scan(optionsDefault);
return scanResult.Text;
I'm developing on xamarin.ios
Related
I am using node.js and n-api. The gist of it is that I cannot create a new object within a for loop without getting a type error that says:
TypeError: wrappedExamData.getPatientID is not a function
This only occurs when trying to create an object the second time. The first time works fine, though. If I create multiple new objects outside of the for loop, it works fine as well.
Here is the module that is throwing the error
//Require the node module
const nodeModule = require('../../../build/Release/QTWebUI.node');
//Require the Exam Class
const Exam = require('./Exam.js');
exports.retrieveAllExams = function(){
// Create a js wrapped c++ class to get a list of exam IDs
var msgGetExamList = new nodeModule.EMGetExamList_Wrapped();
// Create an array of the examIDs
var examList = msgGetExamList.getExamIDs();
console.log(examList);
var examArray = new Array();
for(let i = 0; i < examList.length; i++){
// Create a js wrapped c++ class to send get exam to scanner
var msgGetExam = new nodeModule.EMGetExam_Wrapped(examList[i]);
// Get the js wrapped examData from the c++ class
var wrappedExamData = msgGetExam.getWrappedExamData();
// Create a new exam object with the wrapped examData
var exam = new Exam(wrappedExamData);
// Print the newly created exam object
console.log("Exam: %s", JSON.stringify(exam));
// Push to array
examArray.push(exam);
}
return examArray;
};
Here is the Exam class that I am using where the error is traced back:
module.exports = internal.Exam = class{
constructor(wrappedExamData){
this.patientID = wrappedExamData.getPatientID();
this.firstName = wrappedExamData.getFirstName();
this.lastName = wrappedExamData.getLastName();
this.middleName = wrappedExamData.getMiddleName();
this.gender = wrappedExamData.getGender();
this.birthDate = wrappedExamData.getBirthDate();
this.scanTime = wrappedExamData.getScanTime();
this.description = wrappedExamData.getDescription();
this.breast = wrappedExamData.getBreast();
this.accession = wrappedExamData.getAccession();
this.operatorsName = wrappedExamData.getOperatorsName();
this.examState = wrappedExamData.getExamState();
this.progress = wrappedExamData.getProgress();
this.archiveMultiplicity = wrappedExamData.getArchiveMultiplicity();
this.density = wrappedExamData.getDensity();
this.targetType = wrappedExamData.getTargetType();
this.fromMWL = wrappedExamData.getFromMWL();
}
}
If I instantiate the objects like this:
// Create a js wrapped c++ class to send get exam to scanner
var msgGetExam = new nodeModule.EMGetExam_Wrapped(examList[0]);
// Get the js wrapped examData from the c++ class
var wrappedExamData = msgGetExam.getWrappedExamData();
// Create a new exam object with the wrapped examData
var exam = new Exam(wrappedExamData);
// Print the newly created exam object
console.log("Exam: %s", JSON.stringify(exam));
// Push to array
examArray.push(exam);
// Create a js wrapped c++ class to send get exam to scanner
var msgGetExam1 = new nodeModule.EMGetExam_Wrapped(examList[1]);
// Get the js wrapped examData from the c++ class
var wrappedExamData1 = msgGetExam1.getWrappedExamData();
// Create a new exam object with the wrapped examData
var exam1 = new Exam(wrappedExamData1);
// Print the newly created exam object
console.log("Exam: %s", JSON.stringify(exam1));
// Push to array
examArray.push(exam1);
It works fine. Is there something I'm missing here?
I'm consistently receiving multi-threading issues when downloading a list of gifs from giphy.com. Each time my app crashes and logs a "I/Choreographer(15955): Skipped 104 frames! The application may be doing too much work on its main thread." type error. I haven't come across any threading solutions for flutter. Here is my code...
Future<Null> giphy() async {
var _searchterm = _searchController.text.toString().replaceAll(' ', '+');
String url = GIPHY.com;
//var httpClient = createHttpClient();
var response = await http.get(url);
Map data = json.decode(response.body);
//print(data['data']);
var gifs = new List();
for (var items in data['data']) {
var images = (items['images'] as Map);
var downsized = (images['downsized'] as Map);
var urls = downsized['url'].toString();
gifs.add(urls);
}
setState(() => giphyUrls = gifs);
_neverSatisfied();
}
giphyUrls is a public list that feeds into a gridview builder.
I excerpt from windows 8.1 sample of StorageDataSource and GetVirtualizedFilesVector sample a piece of code in my project can run successfully, but I changed to this: From ApplicationData.current.localFolder the deposit into my pictures do not show up success
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var queryOptions = new QueryOptions();
queryOptions.FolderDepth = FolderDepth.Deep;
queryOptions.IndexerOption = IndexerOption.UseIndexerWhenAvailable;
queryOptions.SortOrder.Clear();
var sortEntry = new SortEntry();
sortEntry.PropertyName = "System.FileName";
sortEntry.AscendingOrder = true;
queryOptions.SortOrder.Add(sortEntry);
//var fileQuery = KnownFolders.PicturesLibrary.CreateFileQueryWithOptions(queryOptions);
var fileQuery = ApplicationData.Current.LocalFolder.CreateFileQueryWithOptions(queryOptions);
const uint size = 400; // default size for PicturesView mode
var fileInformationFactory = new FileInformationFactory(fileQuery, ThumbnailMode.PicturesView, size, ThumbnailOptions.UseCurrentScale, true);
itemsViewSource.Source = fileInformationFactory.GetVirtualizedFilesVector();
}
Commented that the original sample code, comments, following the line of code that I want to be able to run.
thanks a lot!
Do you have accessright for picture library?
To do the programatic access like your code, The app should have it.
You can on/off it from Package.appxmanifest.
In Flash ActionScript 3.0. I have added a video Object to the stage by attaching the camera and video classes. I have also created a simple mute/unmute button. I want to embed this sound button into the video object to give clients more options. Is there anyway I can incorporate the mute button into the video object? This is my code: I wont display it all its too but any help here be much appreciated!!
var nc:NetConnection = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netHandler);
nc.connect(rtmfp://example);
cam:Camera = Camera.getCamera();
var vid:Video = new Video();
camera.setMode(720,540,15,true);
camera.setQuality(0, 100);
vid.attachCamera(cam);
video.width = camera.width;
video.height = camera.height;
addChild(vid);
function setMute(vol){
var sTransform:SoundTransform = new SoundTransform(1,0);
sTransform.volume = vol;
SoundMixer.soundTransform = sTransform;
}
var isMuted:Boolean = false;
mute_Btn.addEventListener(MouseEvent.CLICK, toggleMuteBtn);
function toggleMuteBtn(event:MouseEvent):void{
if(isMuted){
isMuted = false;
setMute(1);
} else {
isMuted = true;
setMute(0);
Once you have added the video to the stage, you can do this;
video.soundTransform = new SoundTransform(0.5);
or in your situation, something like...
function setMute(vol)
{
root.video.soundTransform = new SoundTransform(vol);
}
I want to post some request values alongside the multipart-formdata file contents. In the old API you could use PostFileWithRequest:
[Test]
public void Can_POST_upload_file_using_ServiceClient_with_request()
{
IServiceClient client = new JsonServiceClient(ListeningOn);
var uploadFile = new FileInfo("~/TestExistingDir/upload.html".MapProjectPath());
var request = new FileUpload{CustomerId = 123, CustomerName = "Foo"};
var response = client.PostFileWithRequest<FileUploadResponse>(ListeningOn + "/fileuploads", uploadFile, request);
var expectedContents = new StreamReader(uploadFile.OpenRead()).ReadToEnd();
Assert.That(response.FileName, Is.EqualTo(uploadFile.Name));
Assert.That(response.ContentLength, Is.EqualTo(uploadFile.Length));
Assert.That(response.Contents, Is.EqualTo(expectedContents));
Assert.That(response.CustomerName, Is.EqualTo("Foo"));
Assert.That(response.CustomerId, Is.EqualTo(123));
}
I can't find any such method in the new API, nor any overrides on client.Post() which suggest that this is still possible. Does anyone know if this is a feature that was dropped?
Update
As #Mythz points out, the feature wasn't dropped. I had made the mistake of not casting the client:
private IRestClient CreateRestClient()
{
return new JsonServiceClient(WebServiceHostUrl);
}
[Test]
public void Can_WebRequest_POST_upload_binary_file_to_save_new_file()
{
var restClient = (JsonServiceClient)CreateRestClient(); // this cast was missing
var fileToUpload = new FileInfo(#"D:/test/test.avi");
var beforeHash = this.Hash(fileToUpload);
var response = restClient.PostFileWithRequest<FilesResponse>("files/UploadedFiles/", fileToUpload, new TestRequest() { Echo = "Test"});
var uploadedFile = new FileInfo(FilesRootDir + "UploadedFiles/test.avi");
var afterHash = this.Hash(uploadedFile);
Assert.That(beforeHas, Is.EqualTo(afterHash));
}
private string Hash(FileInfo file)
{
using (var md5 = MD5.Create())
{
using (var stream = file.OpenRead())
{
var bytes = md5.ComputeHash(stream);
return BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLower();
}
}
}
None of the old API was removed from the C# Service Clients, only new API's were added.
The way you process an uploaded file inside a service also hasn't changed.