Exemplo n.º 1
0
        /// <summary>
        /// Fired when an unhandled exception occured
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void App_OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            MessageDialog messageDialog = new MessageDialog(MessagesRsxAccessor.GetString("Error"));
            await messageDialog.ShowAsync();

            e.Handled = false;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Raised when the user clicks on a email address
        /// </summary>
        /// <param name="sender">Textbox pointed</param>
        /// <param name="e">Event arguments</param>
        private async void Email_OnPointerReleased(object sender, PointerRoutedEventArgs e)
        {
            var textBox = (FrameworkElement)sender;

            string url = string.Format("mailto:{0}?subject={1}", textBox.Tag, MessagesRsxAccessor.GetString("EmailSubject"));

            // Check if Url is valid
            if (Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                var uri = new Uri(url);
                await Launcher.LaunchUriAsync(uri);
            }
        }
        /// <summary>
        /// Raised when the user clicks on a hyperlink on the WebView
        /// </summary>
        /// <param name="sender">WebView</param>
        /// <param name="e">Event arguments</param>
        private async void WebView_OnScriptNotify(object sender, NotifyEventArgs e)
        {
            MessageDialog messageDialog = null;

            try
            {
                string data = e.Value;

                if (data.ToLower().StartsWith("launchlink:"))
                {
                    await Launcher.LaunchUriAsync(new Uri(data.Substring("launchlink:".Length), UriKind.Absolute));
                }
            }
            catch
            {
                messageDialog = new MessageDialog(MessagesRsxAccessor.GetString("CannotOpenWebsite"));
            }

            if (messageDialog != null)
            {
                await messageDialog.ShowAsync();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Main application entry point.
        ///     Fire when user launch application from the application icon or from a tile
        /// </summary>
        /// <param name="args">Give details about launch.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            var rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                //Associate the frame with a SuspensionManager key
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        //Something went wrong restoring state.
                        //Assume there is no state and continue
                    }
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                Type page = typeof(MainPage);
                int? id   = null;

                // Check if arguments are availables
                if (!string.IsNullOrWhiteSpace(args.Arguments))
                {
                    string arguments = args.Arguments;

                    IDictionary <string, Func <Type> > pages = new Dictionary <string, Func <Type> >
                    {
                        { "News", () => typeof(NewsDetailsPage) },
                        { "Conference", () => typeof(ConferenceDetailsPage) },
                        { "Show", () => typeof(ShowDetailsPage) },
                    };

                    // Get the page to load
                    string pagename = arguments.Substring(arguments.IndexOf('-') + 1, arguments.LastIndexOf('-'));
                    page = pages[pagename]();

                    // Get the element's ID located after the '-'
                    id = int.Parse(arguments.Substring(arguments.IndexOf('-') + 1));
                }

                SettingsPane.GetForCurrentView().CommandsRequested += OnSettingPane_Opening;

                SearchPane.GetForCurrentView().ShowOnKeyboardInput = true;
                SearchPane.GetForCurrentView().PlaceholderText     = MessagesRsxAccessor.GetString("Search");

                if (!rootFrame.Navigate(page, id))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            Window.Current.Activate();
        }
Exemplo n.º 5
0
        private void OnSettingPane_Opening(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
        {
            SettingsCommand command = new SettingsCommand("privacy", MessagesRsxAccessor.GetString("PrivacyStatement"), OnSettingsCommand_Click);

            args.Request.ApplicationCommands.Add(command);
        }