Loading dynamic images on local devices - xamarin

I have a cross-platform solution which is written in C# and VS using Xamarin.Forms. At time being, the PCL project is using the WebRequest class with asynchronous mechanisms to fetch images directly from remote server. The PCL project also applies the UriImageSource class to cache a particular image for the first time when it is requested. However, the solution depends on the speed status of Internet; sometimes it is fast, sometimes it is slow.
Image is not static. It can be changed.
I'd like to change my project in another way. But I am not sure the following way is the right way to go and whether it is possible:
(1) Writing some codes to schedule mobile device (iOS, Android and Win phone) to sync/download images from the server and save images on local mobile device folder (outside embedded folder in the PLC project) dynamically. But is this possible?
(2) If I have images loaded on local mobile devices, how can I fetch such images using methods like ImageSource.FromStream() or ImageSource.FromFile() to show them on Xaml pages? If possible, how can I code?
(3) I am not sure this. If I let image folder of the PCL project to store (assume it is possible) images, then how can I dynamically mark downloaded images as "Embedded Resouce" (Build Actions set). Anyway, I prefer (2) above.
Thank you in advance.

Related

Is it possible to build mobile and web apps from the same code base?

Is it possible to have a single code base for a mobile(ios/android) and web application? I'm thinking about using react native or angular/nativescript. If you have attempted this what are the things to keep in mind before doing this. Also anything particular to for SEO?
Most importantly are there any real world apps with reasonable complexity that already have done this?
NativeScript actually supports this a couple different ways.
NativeScript officially supports Angular; so you can create everything as an Angular application. Almost the entire app can be shared between Web and NativeScript; the only things that can't is the actual screen layout. In Angular for the Web; you use HTML tags so it might be somepage.html <div>{{somevalue}}</div> and for the NativeScript side you would have somepage.xml and it would have <Label text="{{somevalue}}"></Label>. This allows you to layout the app using the native components for Mobile, and web components for browsers, but use the same backend logic.
There are several seeds and platforms that are designed around fully creating a web app and a NativeScript mobile app that can share virtually everything.
NativeScript also supports VueJS; in this case you can again create virtually everything that shares much of its code base, the only thing is again you need separate layout files because again the web uses html, and NativeScript uses native components. So you have to have separate display files.
Disclaimer: I also work for nStudio; I tend to do non-angular type plugins mainly; but I do know that xPlat is really state of the art and has been used in several successful applications that our development studio has produced.

Save file in Windows Phone (pdf, csv)

I'm trying to find way to save files (pdf or csv) presented in application.
I want those files be available from outside the app.
From what I know it is impossible to save file to sdcard, only in isolated storage.
There is nothing like file manager in Windows Phone, right?
Maybe there is possibility to save file to some cloud from app?
Saving outside of your app doesn't appear to be coming until WP8.1.
In WP8 we do have a few alternatives.
Save the PDF locally and launch the associated app for viewing as per this SO answer.
Use a cloud service for saving the file. The easiest way I've come across is integrating with the CloudSix app for Dropbox. The details on how to integrate the nuget package are here. It's fairly simple if you just need fire-and-forget saving.

Map Tile Caching for Offline Viewing

I'm trying to build an application that will use open source maps from Open Street Maps (though the concept should be applicable to any map provider). The application will enable the user to specify a number of waypoints along a route prior to departure.
Because I don't have a data plan for my cell phone (and because rambling in the countryside rarely gives you a good connection), I want to be able to pre-load the relevant map tiles for the waypoints and/or route before departure so that maps can continue to be used without a data connection.
My initial thoughts are to download the required tiles from the map provider and store them in isolated storage. However, the Bing Maps control implementation, which uses the TileSource class relies on returning an absolute URI that it can download the tile(s) from, which clearly won't work with data stored in isolated storage.
The question has already been asked: Windows Phone 7 Map Control with custom layer in offline mode, but wasn't answered and I'm wondering if since then anyone has cracked the problem.
I've seen this done with a custom layer placed over the map. Tiles are then loaded from anywhere you like (IsolatedStorage, online, somehwere else?) into the custom layer.
Sorry, I don't have any code I can share which demonstrates this at the moment but am currently doing something very similar.
I built a small prototype using OpenStreetMaps for Android. I think it might be interesting to look at the repository and therefore, find a solution similar to mine. I did download the maps before hand, but maybe you can use an online solution for this. This is the repo: https://github.com/kikofernandez/OpenStreetMapExample and the video of how it could look like: https://vimeo.com/40619538.
I used for this prototype OpenLayers, OpenStreetMaps, JavaScript and a WebView in Android. I would like to give you further details but it was just a prototype.
If you can store the data locally (embed it in the XAP), you can reference it via an absolute URI. Chris Walshie talks about it here.
So, for example, once you have the installation path for the app, you can reference the resource like this:
Uri toResource = new Uri("file:///Applications/Install/4FFA38B5-00AF-4760-A7EB-7C0C0BC1D31A/Install/EMBEDDED_RESOURCE", UriKind.Absolute);
Have you set the Build Action on your image(s) to Content?
If your app is running on WP8 then use the built in maps control in the Windows Phone 8 SDK as this already supports offline maps out of the box. If targeting WP7 it is possible to get offline maps to work but takes a lot of work. I created this for a customer a few years ago and I believe that it took me a little over 3000 lines of code to do. Mind you they wanted to also have a framework for adding tiles from various sources such as downloading over and area and downloading zipped files. They way I managed to get the rendering to work was to a canvas to the map without setting it's position. This will be default make it a child of the map but it will not move. I then made the canvas the same size as the map and used the resize event to resize the canvas should the map be resized. I then used the view change event to trigger a method to render the tiles. When this event fired I first calculated all the tiles in view using the code found here: http://msdn.microsoft.com/en-us/library/bb259689.aspx
I then would pull the tiles from isolated storage and draw them on the canvas. For performance I keep track of which tiles I added to the canvas so that if the tile was still in view I simply changed it's position rather than reloading it from isolated storage. I also removed any images that were no longer in view. Overall this works fine but there were some minor issues such as not having the smooth transition between zoom levels. If you really wanted that it is possible to get that to work but requires a lot more math. Also, if you zoom into an area where there is no tiles you end up with an empty map. You can create a custom map mode to prevent the user from going into areas where you don't have tiles.
A solution
The question is a bit old, but there's a solution for anyone who can use Qt.
The solution is not limited to the Windows Phone platform, I've done it targetting Android, and it also works on my desktop.
In Qt, you'll want to patch the OSM Plugin used by QtLocation. It's simple, quick and easy.
How to do it ?
A quick implementation could modify the QGeoTiledMappingManagerEngineOsm class to make it call your own QGeoTileFetcher instead of QGeoTileFetcherOsm.
There may be better ways to acheive this, but at least it works for me.
Basically, you make a fetcher that reads tiles from the filesystem instead of the network.
You build your filesystem database once, from an online resource for instance (see below) and you deploy it with your application for its offline use.
Where do I get tiles from ?
Information how to get the tiles to your offline implementation is available here :
http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
Here are two sources for tiles that can be used for free :
Open Street Maps project servers
Mapquest Open Tiles servers
Take care of the licensing and terms of use.
Open Street Map
Project : wiki.openstreetmap.org/wiki/Main_Page
License : www.openstreetmap.org/copyright
Terms of use : wiki.openstreetmap.org/wiki/Tile_usage_policy
Servers are currently named like *.tile.openstreetmap.org
MapQuest-OSM Tiles
Project : developer.mapquest.com/web/products/open/map
License : opendatacommons.org/licenses/odbl/
Terms of use : developer.mapquest.com/web/info/terms-of-use
Servers are currently named like otile*.mqcdn.com
(Sorry for strange links : I haven't got enough reputation to post real links).

windows phone 7 picture metadata

Is there a way to read picture data such as date picture taken, filename, GPS location and other information that is stored inside the images that stored in the medialibrary?
From what I can find the GDI+ components you would need for this are not currently available on the phone (or Silverlight for that matter). You can have a webservice provide this data to you or you can look into porting a desktop library, it seems some people here have had luck with that.
There is also a project called ExifLib that loads the metadata without the extra GDI+ overhead. http://www.codeproject.com/KB/graphics/exiflib.aspx

Images in AX forms

In Dynamics AX, we use a large number of images and icons for various purposes in our custom forms. We're currently having to individually install image/icon packs on every client machine in order for everything to work.
Is there a way (or best practice) for handling images and icons in Dynamics so an install on every single client is not necessary?
Ideally, I'd install all images and icons in one place on the server and reference everything from there, but I'm open to any suggestions available.
Thanks
You have to deploy the files to each client but this deployment can be done automatically by the AOS. You have more information in this thread of the community:
https://community.dynamics.com/forums/t/26444.aspx
Using the SysFileDeployment class is quite easy and works fine to send icons and files to the clients from a shared location, for example, in the AOS machine.

Resources