void page_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e) { PhoneApplicationPage page = sender as PhoneApplicationPage; if (page != null && notifBox != null) { Grid grid = page.FindName("LayoutRoot") as Grid; if (grid != null) { grid.Children.Remove(notifBox); } notifBox = null; page.BackKeyPress -= page_BackKeyPress; e.Cancel = true; } DispatchCommandResult(new PluginResult(PluginResult.Status.OK, 0)); }
public void confirm(string options) { Deployment.Current.Dispatcher.BeginInvoke(() => { AlertOptions alertOpts = JSON.JsonHelper.Deserialize<AlertOptions>(options); PhoneApplicationPage page = Page; if (page != null) { Grid grid = page.FindName("LayoutRoot") as Grid; if (grid != null) { notifBox = new NotificationBox(); notifBox.PageTitle.Text = alertOpts.title; notifBox.SubTitle.Text = alertOpts.message; string[] labels = alertOpts.buttonLabel.Split(','); for (int n = 0; n < labels.Length; n++) { Button btn = new Button(); btn.Content = labels[n]; btn.Tag = n; btn.Click += new RoutedEventHandler(btnOK_Click); notifBox.ButtonPanel.Children.Add(btn); } grid.Children.Add(notifBox); page.BackKeyPress += page_BackKeyPress; } } else { DispatchCommandResult(new PluginResult(PluginResult.Status.INSTANTIATION_EXCEPTION)); } }); }
void btnOK_Click(object sender, RoutedEventArgs e) { Button btn = sender as Button; int retVal = 0; if (btn != null) { retVal = (int)btn.Tag + 1; } if (notifBox != null) { PhoneApplicationPage page = Page; if (page != null) { Grid grid = page.FindName("LayoutRoot") as Grid; if (grid != null) { grid.Children.Remove(notifBox); } } notifBox = null; } DispatchCommandResult(new PluginResult(PluginResult.Status.OK, retVal)); }
public void alert(string options) { Deployment.Current.Dispatcher.BeginInvoke(() => { //string[] args = JSON.JsonHelper.Deserialize<string[]>(options); AlertOptions alertOpts = JSON.JsonHelper.Deserialize<AlertOptions>(options); //alertOpts.message = args[0]; //alertOpts.title = args[1]; //alertOpts.buttonLabel = args[2]; PhoneApplicationPage page = Page; if (page != null) { Grid grid = page.FindName("LayoutRoot") as Grid; if (grid != null) { notifBox = new NotificationBox(); notifBox.PageTitle.Text = alertOpts.title; notifBox.SubTitle.Text = alertOpts.message; Button btnOK = new Button(); btnOK.Content = alertOpts.buttonLabel; btnOK.Click += new RoutedEventHandler(btnOK_Click); btnOK.Tag = 1; notifBox.ButtonPanel.Children.Add(btnOK); grid.Children.Add(notifBox); page.BackKeyPress += page_BackKeyPress; } } else { DispatchCommandResult(new PluginResult(PluginResult.Status.INSTANTIATION_EXCEPTION)); } }); }