applicationData.current.localFolder.CreateFileQueryWithOptions(queryOptions); don't work - windows-8.1

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.

Related

Image downloaded from Azure Storage not being displayed

I'm new to Xamarin. I'm trying display a list of downloaded images. I am downloading images from an APP API on Azure, where I stored the file on Azure Storage.
My server code is the following:
public HttpResponseMessage Get(string PK, string RK)
{
//Creating CloudBlockBlolb...
byte[] bytes = new byte[blockBlob.Properties.Length]
for(int i = 0; i < blockBlob.Properties.Length; i++){
bytes[i] = 0x20;
}
blockBlob.DownloadToByteArray(bytes, 0);
HttpResponseMessage resp = new HttpResponseMessage(HttpStatusCode.OK);
resp.Content = new ByteArrayContent(bytes);
resp.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/jpg");
return resp;
}
My Xamarin code is the following:
public MainPage ()
{
//...
List<PicturePost> list = new List<PicturePost>{
new PicturePost("title", "subtitle", "link/api/Pictures?PK=xxx&RK=yyy")
};
InitializeComponent ();
listView.ItemTemplate = new DataTemplate (typeof(CustomImageCell));
listView.HasUnevenRows = true;
listView.ItemsSource = list;
//...
}
And here is the relevant code for CustomImageCell:
var image = new Image ();
image.SetBinding (Image.SourceProperty, "image");
//...
horizontalLayout.Children.Add (image);
I know that my API call works, because when I test it on the browser, it returns the image. I also know that if I use any random links such as http://www.natureasia.com/common/img/splash/thailand.jpg the image is downloaded and displayed properly. It is only when I use the API link that it doesn't seem to be working. Can someone tell me what I am doing wrong?
so in my public MainPage(), I added the following:
listView.BeginRefresh ();
listView.EndRefresh ();
I realized at some point that the images would take some time to download. I assume that when the listView was created, the images were not finished downloading, so I added the code above... Pretty sure this is not the best way to do this (probably an await would be better, but I don't know where).

ZXing.Net.Mobile Sample.WindowsUniversal Sample Not Scanning

Testing this to incorporate into Win 10 UWP app to scan 1D barcodes (format 39 & 128). I have updated latest through nuget 2.0.4.46. Referenced post at http://www.yortondotnet.com/2015/07/mobile-barcode-scanning-with-zxingnet.html regarding some options setting prior to scan() with no luck. The scanner (camera) opens but never recognizes a barcode scan successfully - or failure for that matter. It seems nothing is happening whatsoever. I have included straight, pertinent sample code with some options modifications for review. I have gotten Scandit API to work and was going to try Manateeworks but both are really costly and not an option. I am developing on Surface Pro 3 (Win 10) and that build will also be target machines when complete.
public sealed partial class MainPage : Page
{
UIElement customOverlayElement = null;
MobileBarcodeScanner scanner;
public MainPage()
{
this.InitializeComponent();
//Create a new instance of our scanner
scanner = new MobileBarcodeScanner(this.Dispatcher);
scanner.Dispatcher = this.Dispatcher;
}
private void buttonScanDefault_Click(object sender, RoutedEventArgs e)
{
//Tell our scanner to use the default overlay
scanner.UseCustomOverlay = false;
//We can customize the top and bottom text of our default overlay
scanner.TopText = "Hold camera up to barcode";
scanner.BottomText = "Camera will automatically scan barcode\r\n\r\nPress the 'Back' button to Cancel";
// GWS Set Options
var options = new MobileBarcodeScanningOptions();
options.PossibleFormats = new List<ZXing.BarcodeFormat>() {
ZXing.BarcodeFormat.CODE_39, ZXing.BarcodeFormat.CODE_128
};
options.AutoRotate = false;
options.TryHarder = false;
options.TryInverted = false;
//Start scanning
scanner.Scan(options).ContinueWith(t =>
{
if (t.Result != null)
HandleScanResult(t.Result);
});
}
private void buttonScanContinuously_Click(object sender, RoutedEventArgs e)
{
//Tell our scanner to use the default overlay
scanner.UseCustomOverlay = false;
//We can customize the top and bottom text of our default overlay
scanner.TopText = "Hold camera up to barcode";
scanner.BottomText = "Camera will automatically scan barcode\r\n\r\nPress the 'Back' button to Cancel";
// GWS Set Options
var options = new MobileBarcodeScanningOptions();
options.PossibleFormats = new List<ZXing.BarcodeFormat>() {
ZXing.BarcodeFormat.CODE_39, ZXing.BarcodeFormat.CODE_128
};
options.AutoRotate = false;
options.TryHarder = false;
options.TryInverted = false;
//Start scanning
scanner.ScanContinuously(options, async (result) =>
{
var msg = "Found Barcode: " + result.Text;
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
{
await MessageBox(msg);
});
});
}
async void HandleScanResult(ZXing.Result result)
{
string msg = "";
if (result != null && !string.IsNullOrEmpty(result.Text))
msg = "Found Barcode: " + result.Text;
else
msg = "Scanning Canceled!";
await MessageBox(msg);
}
}
Simon,
I have the exact same problem. I tested your code with the latest nuget 2.1.47, the problem still exists.
You need to download the latest from Github and add the following projects (or DLLs) to your project:
ZXing.Net (project: zxing.portable.csproj)
ZXing.Net.Mobile.Core
ZXing.Net.Mobile.WindowsUniversal
I have tested your code and it works fine. I hope this help.
Cheers,
Sam
I think that the problem in the hardware you are testing with. Surface Pro 3 (Win 10) does not have an auto focus camera. I've never succeed to scan with ZXing using my Surface Pro 3, while the same application is working fine with my other windows 10 device.

PIXI getting image width,height

I need to get size of image that I just added to stage and set it to defaultX and defaultY before I call the autorenderer, but I can't seem to grab the size.
How do I grab the size?
Also, from what I got so far, I think the best way to set the size is including with autorenderer. But what would be the implication here if I resize() later?
Any help will be appreciated. Thank you.
my code:
this.stage = new PIXI.Container();
var texture = PIXI.Texture.fromImage('background.png'); //1610x640
var spr = new PIXI.Sprite(texture);
this.stage.addChild(spr);
defaultX = texture.width;
defaultY = texture.height;
this.renderer = PIXI.autoDetectRenderer(defaultX, defaultY); //640x690
this.renderer.resize(x,y); // I know this works with other values
// eg if I hardcode with 1610,640
// but texture.width doesn't work and
// I don't want to hardcode it
Your image can not be loaded when you call texture.width.
I use next construction:
this.stage = new PIXI.Container();
this.renderer = PIXI.autoDetectRenderer(640, 690); //640x690
var baseTexture = new PIXI.BaseTexture('background.png');
// can be loaded from cache
if (baseTexture .hasLoaded) {
createSprite(baseTexture);
} else {
baseTexture .on('loaded', function() {
createSprite(baseTexture); // or this
});
}
function createSprite(baseTexture) {
var texture = new PIXI.Texture(baseTexture);
var spr = new PIXI.Sprite(texture);
this.stage.addChild(spr);
defaultX = texture.width;
defaultY = texture.height;
this.renderer.resize(defaultX,defaultY);
}

How to get notified in the progress of the operations in ExcelStorage of FileHelpers

Documentation http://www.filehelpers.com/example_progress.html saying
that i need to use method SetProgressHandler but ExcelStorage does not have it.
ExcelStorage has method public event EventHandler<ProgressEventArgs> Progress;
so looks like i need to use it in some way?
ExcelStorage provider = new ExcelStorage(typeof(MyModel));
provider.StartRow = 2;
provider.StartColumn = 1;
provider.FileName = #"C:\Customers.xlsx";
provider.HeaderRows = 13;
provider.InsertRecords(data.ToArray()); // need to get progress here
May be some one could help?
Try this:
provider.Progress += provider_Progress;
and then define the provider_Progress event handler to update
static void provider_Progress(object sender, ProgressEventArgs e)
{
var percent = e.Percent;
var positionMax = e.TotalRecords;
var position = e.CurrentRecord;
// update the progress control
Application.DoEvents();
}

Add a Sound Mute Button to a Video Object

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);
}

Resources