Passing fields to a silverlight app from the command line - html

Silverlight is made so that you can run it in a browser. That is cool. So, if I want to pass variables from the command line so that it can be used to populate fields in the silverlight app, how is that done?
You know, like you can with javascript (I think) or php (I am pretty sure).

Silverlight has Init parameters which is a key/value map that you can fill in your Html page and get the values in Application_Startup event. However this does not apply to Silverlight apps running in OOTB (out of the browser) mode.
This MSDN page shows a trick if you run your app both in and out of browser, so that you can save the InitParams values when running in the browser and save it back to Isolated Storage for when you run the application in OOTB mode.

Related

Chrome native messaging - disconnected when launching another app

What I'm trying to do?
I am trying to write an application based on such schema:
The chrome extension launches an application (.jar file) on my computer
The application launches another application (external, not written by me), I am passing data to it, it displays the window for user, user enters some data to it, and then this app returns the data to the parent app
The parent app processes the child app response and sends it back to the chrome extension
What's wrong?
When the window of the child app is displayed, the chrome extension is disconnected (it happens exactly at the same time). What follows, the result is not going back to the chrome extension.
What works:
If I omit point no. 2 (just mocking the answer from the child app), the result is returned to the chrome extension.
Including all points: the child app returns it's result correctly. The parent app catches it and tries to return it to the chrome extension (not succeeding, the extension is disconnected)
Also tried
I tried to do it using java multithreading (ExecutorCompletionService, Callable, Future), I wanted to launch the child app in a separate thread and block the main thread until the child is finished, it didn't help.
Solved!
The communication between the chrome extension and my app is through the standard input/output. Somewhere in the code of my app (written in java) there was System.out.println called. It made some mess on STDOUT and made the app disconnect from the extension. It happened in the same time with launching the external app as I saw it, probably didn't happen exactly at the same time, but some time before/after, something the person cannot see.
Multithreading has nothing to do with this problem.
Solution
I found and removed all code writing to standard output

Can I open Byte array of Docx/Pdf file to WebView in Windows phone

I get byte array data from specified API, and I want to show it on web view in my application.
Is there any option to open word file in Windows Phone with web view ?
You can't show those files in a WebView inside your application. The regular way to show those files by storing them in a file and invoking LaunchFileAsync() to hand displaying off to the system. If only one App supports the file type it will launch directly - otherwise the user will be prompted which App he wants to use to see them.
See MSDN for more information

how to run batch file in chrome

I tried using very simple HTML to create several links to several batch files on my server that are intended to run when users click on the links. Using Chrome, every time I click on one of those files my browser displays the script itself (even though its a .bat) and doesn't actually run the script. Internet Explorer runs it every time, however all the users on the network use Chrome for web browsing.
Is there any way to force Chrome (preferably through HTML or VB or some other scripting on the page itself rather than change all of the users' browser settings) to run these batch files when the user clicks on the link?
The answers given so far - that it's "not possible" - are incorrect or outdated. Using Chrome Apps you can call executables (called "hosts") if they are registered with Chrome. Of course a Chrome App is a client application so you need to distribute it.
See https://developer.chrome.com/extensions/nativeMessaging#examples
HTML, JS on browser cannot run shell command, command line. You have to implement server script to execute your bat file then call it from HTML, JS via Ajax or direct link.

Is there a way to persist cookies or HTML5 localStorage across WebBrowser instances on Windows Phone?

Short version: I have a WebBrowser control hosted in a Windows Phone 8 app. How can I store values from javascript so that they persist across the user closing and reopening my app?
Long version:
I'm developing a Windows Phone 8 application that has a single WebBrowser control hosted in a single MainPage.xaml page that lives for the entire life of my app. I created the app with the "Windows Phone HTML5 App" project type when creating the project in Visual Studio 2012. 99% of my application is hosted in web pages (on the internet, not stored on the phone) that I direct the WebBrowser to go to when the app starts up. In my application's web pages I'm trying to persist data across pages and across sessions. For example, once the user logs in once then I want to store that on the phone so the next time they start the app they don't have to log in again.
Cookies and HTML5 Local Storage (via window.localStorage.setItem and getItem) both work fine for sharing data across pages in the app while the app is running and even if you switch out of the app (via the Windows phone "hard button") and go back in. But if the user exits the app by pressing the hard "back" button then the next time the app is started all localStorage and cookies seem to be gone.
Is this the expected behavior? I guess I'm not sure where WebBrowser would store the data (Isolated Storage? Or maybe in the same place it's stored if going to the web site with Internet Explorer?). In any case, if there's no "fix" for this, can anyone the best way for me to provide my own storage mechanism so that I can let my javascript code persist values across instances of my app running? I'm happy to use the app's Isolated Storage if only I knew of a way to get and retrieve values from it using javascript. Thank you.
I'm not sure if this is expected behaviour or not.
To get at the Isolated Storage you will need to use JS/.NET interop.
if you want to trigger the persistent storage from JS:
Use window.external.notify in JS, generating a JSON string (for instance) to pass along to the .NET side. That could be written to IsolatedStorage without the .NET having to parse the data. You could use IsolatedStorage.AppSettings or a full file depending on the size of the data.
Alternately you could trigger the process from .NET:
Call WebBrowser.InvokeScript to call a JS function which returns the same JSON string representing your data.
The .NET side could detect and restore this data on startup and use WebBrowser.InvokeScript to pass the JSON string back into the WebBrowser via a JS function.
You'd of course have to deal with error cases (attempting to restore bad/corrupt JSON).
Also, if you trigger this from .NET in response to the App.Closing event you need to watch out that you don't take too long writing data.
The faster you run the better, but this definitely needs to be done within 10 seconds or the OS will kill your app.
See MSDN docs for WebBrowser.InvokeScript() and ScriptNotify registration to window.external.notify.

Google Chrome --new-window switch ignores --window-position and --window-size

I'm trying to control the size and position of newly spawned Google Chrome windows via the command line (through C#.)
My command line ends up looking like:
--new-window --window-position=100,100 --window-size=800,600 www.UrlToOpen.com
However, the new window just opens over top of where the last Chrome window was started.
The end result I'm looking for is to be able to start multiple instances of Google Chrome, in separate windows, with a specific location and size. The only way I've been able to do this so far is by specifying that each instance is to have it's own --user-data-dir. However, this is not ideal given how many extensions a user may have installed, and it would not be the best user experience.
Does anyone have any suggestions?
If Chrome is not programmed to allow this, you only have one option.
Create the process and keep the process object.
Use Process.MainWindowHandle to get the newly created window (you might need to use a loop and Process.Refresh, or Process.WaitForInputIdle)
Use the SetWindowPos native function to position the window wherever you want it.
Native hooks could be used to detect creation of the window, but that requires you to create an unmanaged DLL.
I have another idea for you, why not use a chrome extension for handling the positioning.
Background: We had related difficulties. Internal webapp that opens multiple documents in windows, and need to be placed in other monitors.
The javascript does not support this, for security reasons and only a native extension can properly work with the tabs/windows objects.
Therefore, we have created an open source chrome extension for doing exactly that: flexible windows position across multi-monitor setups.
Perhaps more interest to you would be the feature to use predefine templates. The template file is located in any webserver you like and therefore can be easily share across different users.
The chrome extension is called "MultiWindow Positioner" and its complete free. You can get it at the chrome store here
The actual source code you find in github in the project chrome-multiwindow-positioner
Disclaimer: I am the maintainer of the open source (MIT) github project. If there any interesting idea, or comments feel free to share them here.