Show a Dialog Box from non event thread - user-interface

I need to show a Dialog box, from an app started via an alternate entry point, when a push message arrives.
To do this I need to create an Application instance from the alternate entry point and listen for incoming push.
The problem is when I extend my application class from UiApplication, and call enterEventDispatcher() from the alternate entry point it shows an application icon in running applications forever.
I need to listen for push messages and alert user by a dialog without having an application icon.
So is there any way I can show a dialog from an alternate entry point without a UI event thread?

You can use global dialog. Just use this code.
synchronized (Application.getEventLock()) {
UiEngine ui = Ui.getUiEngine();
Screen screen = new Dialog(Dialog.D_OK, "Look out!!!", Dialog.OK,
Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION),
Manager.VERTICAL_SCROLL);
ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_QUEUE);
}

Related

What can I do to get informed for every new inspector

I need to subsribe to events for every new inspector that will be opend.
And also want to invalidate the ribbon on every new Inspector.
Ther is an event that will be called for every new inspector:
Globals.ThisAddIn.Inspectors.NewInspector += (sender, explorer) => ribbon.Invalidate();
However this event will not be called when a new inspector is opend via the send to -> Mail recipient from the windowsd explorer.
Another aproach was to register to the UI events in the ribbon. But those will also not called every time a new window is opend.
Is there is any way to reliable get notified for every new inspector?
NewInspector does not fire on purpose when a new message is created using Simple MAPI or fro ma mailto link.
You can have a timer that wakes up every couple seconds and checks if the Application.Inspectors collection has any new inspectors you have not processed yet.

uiless action in Outlook add-in with displayDialog()

We are seeing a change in Outlook with one of actions (“Help”) that stopped working on the web client only.
This action simply calls a js that opens a web page in a displayDialog() but it’s uiless in the sense that there’s no pane.
The other action (“Sign”) works ok but it launches a pane that does this.
Both of them work fine on the rich client (at least the version I use).
I wonder if there has been in recent changes in the requirements or the way this works?
We’re not seeing any error messages, just nothing happens after the prompt saying that the add-in is doing something.
We did some initial testing and noticed that in chrome the dialog will sometimes appear briefly. Could you confirm that you are calling event.completed() in the eventhandler of EventType.DialogEventReceived? event.completed() must be called in the DialogEventReceived handler otherwise the dialog will be closed prematurely.
Office.context.ui.displayDialogAsync(url, dialogOptions, function(result) {
// In the callback, save the dialog object
dialog = result.value;
// Add an event handler for messages sent via messageParent
dialog.addEventHandler(Microsoft.Office.WebExtension.EventType.DialogMessageReceived, receiveMessage);
// Add an event handler for events from the platform (like closing the dialog, etc.)
dialog.addEventHandler(Microsoft.Office.WebExtension.EventType.DialogEventReceived, dialogClosed);
});

How to associate event with all editors opened in a page in Eclipse

Using the below code I am able to capture all the key events in currently active editor (First.java) in eclipse
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart editor = page.getActiveEditor();
((StyledText)editor.getAdapter(org.eclipse.swt.widgets.Control.class)).addKeyListener(new KeyListener() {
//code here
});
But as soon as I open (Activate) another editor (Second.java), key event are not captured.
How can I capture key events on all the editors I open in workbenchPage.
You can use an IPartListener to listen for changes to the active part so that you can add and remove your listener as the part changes:
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.addPartListener(listener);
The listener is told about parts being opened, closed, activated and deactivated. The parts may be Views or Editors.
Note: Not all editors use StyledText so you need to check the type of the object returned by getAdapter.

The equivalent to onResume() in Windows Phone 7

I'm looking for some app life cycle help from the wp7 experts. My app has a refresh step in a specific page but I only want to launch this when the user brings the app to life from the background.
Note- The life cycle step I'm looking for isn't called when the page is init() only when I'm navigated (back) to or the user has taken a phone call and then re-opens the app (keeping the same page open)
Thank you in advance
what you are looking for is called Tombstoning and you can find a great article at http://wildermuth.com/2010/10/17/Architecting_WP7_-_Part_5_of_10_Tombstoning
The events are:
Launching (opened from tile)
Deactivated (user takes a call or something)
Activated (back from the call)
Closing (Leaves you app via the "Back" button)
You are looking for the Activated event. These are in your App.xaml.cs/vb file. Hook into the event, and update your data model. When your page is bound to that model it will get the data.
If you are not using MVVM, and can't really refresh from that event, you can do it using the PhoneApplicationService.Current.StartupMode property. It has two options Activate (what you are looking for) and Launch (loaded fresh from the tile). It would look something like
Init()
{
if (PhoneApplicationService.Current.StartupMode == StartupMode.Activate)
{
Refresh()
}
}

How to get to the Messaging app to text someone?

I'm making an app and I want to be able to go from my app to the messaging app straight to the "Create new" page. Is there a way I can navigate to that page straight from my app?
As Andrew M mentioned, the SmsComposeTask is the correct control to use. Here is some sample code for you:
SmsComposeTask smsTask = new SmsComposeTask();
smsTask.To = "0123456789"; // the number you would like to send the sms to
smsTask.Body = "Some prefilled text..."; // if you would like to fill some text
smsTask.Show();
When Show() is called, the app will navigate to the Messaging application and display an SMS filled in with the defined parameters.
Simply use the above code in an event handler (i.e., the event for when a button is clicked), and the user will be navigated accordingly.
Use the SMSComposeTask:
http://www.nickharris.net/2010/09/how-to-sms-using-the-smscomposetask-for-windows-phone-7/

Resources