Take a photo in WPF using the default camera app in Windows 8 - wpf

I was asked to develop a software in vb.net and one of it's features should be the possibility to take photos on a tablet PC. I already played around with the MediaCapture API which returns me a photo, but as it seems that it's not possible to show a preview or anything else outside of ModernUI apps. It's just pure photo capturing.
I thought for a little while how this problem could be solved. I got some inspiration from my Android phone then. My idea was to call some sort of API to open up the regular Windows 8 camera app in ModernUI mode, let the user take the photo and then receiving that through a "return value", just like you usually do it in Android apps.
Now my question is, if there is a way to start up the Windows 8 default camera app, let it take a photo and receive that back into my WPF desktop application.
I could develop my software as ModernUI app as well, but I never did that and it also seems like you must publish it over the web store then, but I only want to use that inside my company.
My other (simple stupid) idea would be to ask the user to open the camera app by himself, take some photos and come back to my software later. I could then receive the images from the folder they were stored in. I guess that would work as well, but I don't really like that idea because it's not very intuitive and seems just stupid.
If you have an idea (or an alternative), I would be really happy if you could share it with me.
Thanks in advance!

Unfortunately, there are no .NET classes that allow you to access a webcam or integrated camera on your computer. This means that you have to take a look at the native Windows API and call it from your application. I cannot point you to the right methods that you have to use, as I just have used Microsoft Media Foundation to capture a continuous stream of images from a webcam and encode it to a video file.
There are some sites that encapsulate this native functionality in .NET classes, but I don't know if they are good or not:
http://dotnet.dzone.com/articles/using-webcam-wpf-application
http://www.yiigo.com/guides/vbnet/how-to-process-image.shtml
(just google for more if you'd like to).
In Windows Store Apps, this task can be performed relatively easy with the media capture API you've mentioned. You can also side-load Windows Store Apps if you have Windows 8 Pro or Enterprise - then you do not have to publish your app in the Windows Store.
If you have any further questions, please feel free to ask.

Related

Losing control while testing in Xamarin test cloud

After entering into phonebook or gmail or playing YouTube through the testing application, I am losing all the controls to test or query. As soon as it comes into play I lose control. Then I have to manually deal with it. On writing tree on Repl mode I am not able to see anything.
This is because you are leaving the application. Xamarin UITest works by running a client-side server next to or inside the mobile application. the client-side server is what enables us to interact with controls and query for things on the screen.
If you are on iOS, you have to have the Calabash agent installed in the application to make things work. Once you leave the application (switching to YouTube or other app), the client-side server is backgrounded and won't be able to do anything because of how iOS operating system is designed.
On Android, it depends on what version of Android you are using. Older Android versions don't sand box apps the same. Android 6.0 and above have more security controls and I wouldn't expect this behavior to work.
If you are trying to test if those things work, You should be testing that the Intent you are sending is correct. You are really testing the operating system at this point because you are verifying that YouTube or whatever did what you expected. Really we should have a base assumption that when we provide the phonebook with the proper intent, the operating system should behave accordingly. If you test that the video actually opens in the YouTube app, you are now testing if YouTube can open their links/intents successfully. Some people decide to test these things, many find that it is redundant and increases their teams cycle time.
I hope this helps!
Disclosure: I work at Xamarin/Microsoft

Winform application for tablet?

I have a customer who wants an application for his travels where he can update an online DB, he doesn't want to buy a laptop, he wants a tablet or something similar. I have no knowledge nor desire in creating special apps for mobile devices, I want to create a winform just like I always did when it was targeted for pc. Tablet pcs (which from what I understood is just a regular pc?) are still very expensive in my country.
Is there a simple adjustment to make winform app run on a tablet with android or I have to build a special app for it? Any other solution? (I began in writing a web page for it, but it's much easier using winforms)
Native WinForms applications will not run directly on Android (or any non-Windows platform). You may want to begin by looking into MonoDroid for porting .NET code Android (and Mono in general for porting .NET code to non-Windows platforms).
A successful port across platforms will require that the application be structured in a very de-coupled manner. Core business logic in the abstract part of the application should be easily ported, but concrete implementations (specifically views and data/service access) will require some re-implementation for the different concrete platforms. So the overall architecture needs to be very de-coupled and pluggable.
Is a Windows tablet an option? Using various new technologies at Microsoft (Windows 8, Metro UI, etc.) you could build an application that would target multiple Microsoft-based platforms. This could easily satisfy the requirement of being "a tablet" (if the requirement isn't more specifically "an Android tablet"). However, it won't be the old WinForms style of applications.
In general you'll find that the industry has been steadily moving away from WinForms for, well, this exact reason. It doesn't port to other platforms, and there's a wide variety of platforms in demand today.
Forget convertion i was in a similar position years ago and i did something easier faster and i think smarter.
just make a winform with nice big controls take care of docking scaling anchors etc so that it will look nice and can be used with small smart devices.
Make sure you pass some start program parameters in your app and when a special parameter is passed instead of opening the main typically desktop form of your app open that new one in fullscreen.
Now the tricky parts isnelsewhere. I hade setup a tiny windows 2008 r2 server that allows remote apps to be run on it.
Create a user account that you will allow access to that server and only that app of yours with the specific parameter we talked about. (Ex myapp.exe -remote)
The what ever device he will get you can download the free app like 2x rdp or microsoft rdp in android. Make a new connection to your server (you can use any free ddns you like if you dont have a static ip) and connect with that windows server account you did before.
This account if has been properly setuped will only run your app and will only show that new mini winform you did..
The end user will do a simle click and from his internet connection will do a simple remote desktop that is linited to your app only. (Router configuration is needed once)
That way you will keep maintain just one source code and he will have low bandwidth cost and can continue his work without data loose in case of disconnection.
I use that for years in mobiles tablets and pos systems. Its fast its stable its secure its easy to maintain (nothing on the client side) and you don't waste months of learning wpf or doing xamarin converting.

Is it possible to make a silverlight program as a mac OSX app?

I have a silverlight application, now I want make it run as a mac OSX app, perhaps aiming to sell on app store. Since I'm completely a newbie in mac developing, is it possible to make this silverlight app run like a native app?
Maybe there is some way to make a browser shell, and embed that silverlight on a html to show it. is there any way make it more native without a browser control, and I want to disable the right click "silverlight" popup.
More over, since silverlight cannot access local file system directly, any good idea to do this? First came into my mind is put a webservice module in the app, so that this app acts both client(silverlight) and server, and then process the local file on server module.
The most you can do is have it run as a Silverlight Out Of Browser application (see a bit more detailed explanation here). This mode is pretty much like running in a chromeless browser, however it is still running in the same sandbox and you have very limited resource access.
Apps running this way will definitely not have the native OS/X app feel, neither will they be started similarly and you won't be able to sell it on the Apple App Store.
If you want to target Mac desktops and deliver a native experience I'm afraid currently Objective C or a framework on top of that is the only viable choice.

Silverlight SQL Deployment

I'm about to write an application in either Adobe Air or Silverlight, to run standalone, offline, on the desktop. It's a simple enough application that allows the user to enter text data and will then print formatted documents based on that information. The obvious place to store all this relational data is in a database. I believe Air comes with SQLite out of the box, so no problems there, but from what I can tell Silverlight doesn't. How does Silverlight handle installing an out of browser application that needs to access a local database? Does the user have to install SQL/SQLite first and then Silverlight, or is there some way that Silverlight can deploy that side of things itself?
Thanks
I don't know much about Air, But Silverlight has IsolatedStorage for saving data on client-end and it has its own constrains. But if you want to have an application that can access local database why don't you try WPF(XBAP)?
This link can be helpful regarding SQLLite and Silverlight using IsolatedStorage.
http://forums.silverlight.net/forums/p/118411/267135.aspx
Regards.
I'm fairly certain silverlight isn't intended for... whatever it is you're trying to do.

Multiple Out-of-Browser Applications in One Application

I'm looking at a scenario where I need to create a single "master" Silverlight application and then add "child" applications for an out-of-browser Silverlight application.
The scenario is something like this.
A user will visit a gameboard web site
and choose a game to play. Let's call
it Checkers. He likes it, so then he
installs the out-of-browser app to his
desktop. He then finds Chess, and
installs that too. For both games,
while played on the site, he has stats
(games played, win/loss records,
etc.). For each game on the site, he
navigates to a different page.
But now he wants to play offline and
view his stats and other cross-games
information. He wants to have a single
app to launch to play either game.
From his single out-of-browser app, he
sees that Go is also available, and he
places a checkmark against it to
download on his next connection.
Does anyone have any experience at developing multiple out-of-browser Silverlight apps that reside within a single master app? What considerations need to be had for this type of design? How would this work in terms of install experience from different web pages?
What you need is MEF (which will be included in the CLR of the upcoming Microsoft .NET Framework 4)
You Can read more about it here , here & there's an example here
Is there a reason why every game must be a separate application? It would be much easier to just install the master application as an OOB app and then have it load new XAPs from IsolatedStorage at runtime depending on what games the user has downloaded (installed). Or perhaps I am misunderstanding your scenario?

Resources