Beispiel #1
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        async protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame         = Window.Current.Content as Frame;
            var   connectionProfile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();

            if (connectionProfile != null)
            {
                TaskDataSource taskDataSource = (TaskDataSource)App.Current.Resources["taskDataSource"];
                if (taskDataSource != null)
                {
                    if (taskDataSource.TaskLists.Count == 0)
                    {
                        await taskDataSource.GetTaskListsAsync(false);
                    }
                }
            }
            else
            {
                var messageDialog = new Windows.UI.Popups.MessageDialog("An internet connection is needed to download feeds. Please check your connection and restart the app.");
                var result        = messageDialog.ShowAsync();
            }
            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

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

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active

            Window.Current.Activate();
        }
Beispiel #2
0
        async private void sync_Click(object sender, RoutedEventArgs e)
        {
            Synchronizer synchronizer = await Synchronizer.GetInstance();

            if (synchronizer.IsInternetAvailable())
            {
                progressBar.Visibility = Windows.UI.Xaml.Visibility.Visible;
                TaskDataSource taskDataSource = (TaskDataSource)App.Current.Resources["taskDataSource"];
                bool           success        = await synchronizer.Synchronize();

                if (success)
                {
                    // pobranie jeszcze raz i zastapienie
                    await taskDataSource.GetTaskListsAsync(true);

                    showEmptyTextBlock(Messages.GetMsgValue(MessageKey.SELECT_LIST));
                    tasksView.ItemsSource = null;
                    taskDataSource.RefreshLists();
                    RefreshCounters(taskDataSource);
                }
                else
                {
                    var messageDialog =
                        new Windows.UI.Popups.MessageDialog(
                            Messages.GetMsgValue(MessageKey.SYNC_ERROR_CNTNT), Messages.GetMsgValue(MessageKey.SYNC_ERROR));
                }

                progressBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
            else
            {
                var messageDialog =
                    new Windows.UI.Popups.MessageDialog(
                        Messages.GetMsgValue(MessageKey.NO_INTERNET_CNTNT), Messages.GetMsgValue(MessageKey.NO_INTERNET));

                messageDialog.Commands.Add(new UICommand("OK"));
            }
        }