Example #1
0
 /// <summary>
 /// Called when the user taps on an item in a word list.
 /// </summary>
 /// <param name="sender">The object sending the event.</param>
 /// <param name="e">The event parameters.</param>
 private async void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
 {
     if (await ConnectivityCheck.AskToEnableConnectivity(this))
     {
         await this.CallSearchPage(((IWord)e.Item).Term);
     }
 }
Example #2
0
        /// <summary>
        /// Called when an item in the exercise list is tapped.
        /// </summary>
        /// <param name="sender">The object sending the event.</param>
        /// <param name="e">The event parameters.</param>
        private async void ExerciseList_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            if (await ConnectivityCheck.AskToEnableConnectivity(this))
            {
                // TODO: support other exercise types
                try
                {
                    ExerciseApi   exerciseEndpoint = new ExerciseApi(App.OAuth2Account, ((EssayExercise)e.Item).Uid);
                    EssayExercise essay            = await Task.Run(async() => await exerciseEndpoint.CallEndpointAsExerciseModel()) as EssayExercise;

                    if (essay == null)
                    {
                        await this.DisplayAlert(Properties.Resources.Error, Properties.Resources.Exercise_UnableToDisplay, Properties.Resources.ButtonOK);
                    }
                    else
                    {
                        await this.Navigation.PushAsync(new EssayExerciseView(essay));
                    }
                }
                catch (UnsuccessfulApiCallException ex)
                {
                    Tools.Logger.Log("ExerciseList_ItemTapped", ex);
                    await this.DisplayAlert(Properties.Resources.Error, Properties.Resources.Exercise_UnableToDisplay, Properties.Resources.ButtonOK);
                }
            }
        }
Example #3
0
 /// <summary>
 /// Called when the user taps on the "Refresh" button.
 /// </summary>
 /// <param name="sender">The object sending the event.</param>
 /// <param name="e">The event parameters.</param>
 private async void Refresh_Clicked(object sender, EventArgs e)
 {
     if (await ConnectivityCheck.AskToEnableConnectivity(this))
     {
         ((ExerciseAnalysisDataModel)this.BindingContext).RefreshAnalysis();
     }
 }
Example #4
0
 /// <summary>
 /// Called when the "Log in" button is clicked.
 /// </summary>
 /// <param name="sender">The object sending the event.</param>
 /// <param name="e">The event parameters.</param>
 private async void LoginButton_Clicked(object sender, EventArgs e)
 {
     if (await ConnectivityCheck.AskToEnableConnectivity(this))
     {
         await this.Navigation.PushModalAsync(new Authentication());
     }
 }
 /// <summary>
 /// Called when an item in the exercise list is tapped.
 /// </summary>
 /// <param name="sender">The object sending the event.</param>
 /// <param name="e">The event parameters.</param>
 private async void HistoryList_ItemTapped(object sender, ItemTappedEventArgs e)
 {
     // TODO: support other exercise types
     if (await ConnectivityCheck.AskToEnableConnectivity(this.page))
     {
         await this.Navigation.PushAsync(new EssayExerciseView((EssayExercise)e.Item));
     }
 }
Example #6
0
 /// <summary>
 /// Checks if graph is valid for dots movement modeling
 /// </summary>
 private bool CheckConnectivity()
 {
     if (!ConnectivityCheck.IsGraphValid(digraph))
     {
         MessageBox.Show(
             digraph.Vertices.Count >= 3
                 ? @"The graph is not strongly connected"
                 : @"Not enough vertices",
             @"Graph validation failed", MessageBoxButtons.OK,
             MessageBoxIcon.Error);
         return(false);
     }
     return(true);
 }
Example #7
0
 /// <summary>
 /// Called when the "Refresh" button is clicked.
 /// </summary>
 /// <param name="sender">The object sending the event.</param>
 /// <param name="e">The event parameters.</param>
 private async void RefreshButton_Clicked(object sender, EventArgs e)
 {
     if (await ConnectivityCheck.AskToEnableConnectivity(this))
     {
         if (this.CurrentPage is DashboardTabHistory)
         {
             ((DashboardTabHistory)this.CurrentPage).Refresh();
         }
         else if (this.CurrentPage is DashboardTabFeatured)
         {
             ((DashboardTabFeatured)this.CurrentPage).Refresh();
         }
     }
 }
Example #8
0
        /// <summary>
        /// Called when the "Refresh" button is clicked.
        /// </summary>
        /// <param name="sender">The object sending the event.</param>
        /// <param name="e">The event parameters.</param>
        private async void RefreshButton_Clicked(object sender, EventArgs e)
        {
            if (await ConnectivityCheck.AskToEnableConnectivity(this))
            {
                if (this.featureGrid.GetBindingContext().CanRefresh())
                {
                    this.featureGrid.GetBindingContext().RefreshExercises();
                }

                if (this.historyGrid.GetBindingContext().CanRefresh())
                {
                    this.historyGrid.GetBindingContext().RefreshHistory();
                }
            }
        }
Example #9
0
        /// <summary>
        /// Called when the user taps on a word in the list.
        /// </summary>
        /// <param name="sender">The object sending the event.</param>
        /// <param name="e">The event parameters.</param>
        private async void TableWord_Tapped(object sender, EventArgs e)
        {
            if (await ConnectivityCheck.AskToEnableConnectivity(this))
            {
                TextCell senderCell = sender as TextCell;
                if (senderCell == null)
                {
                    return;
                }

                if (senderCell.BindingContext is IWord)
                {
                    await this.CallSearchPage(((IWord)senderCell.BindingContext).Term);
                }
                else
                {
                    await this.CallSearchPage(senderCell.Text);
                }
            }
        }
Example #10
0
        /// <summary>
        /// Checks URL specified at CloudVeil.CompileSecrets.ConnectivityCheck + "/ncsi.txt" for connectivity.
        /// </summary>
        /// <remarks>
        /// Windows 7 captive portal detection isn't perfect. Somehow in my testing, it got disabled on my test network.
        ///
        /// Granted, a restart may fix it, but we're not going to ask our customers to do that in order to get their computer working on a captive portal.
        /// </remarks>
        /// <returns>true if captive portal.</returns>
        private CaptivePortalDetected checkCaptivePortalState()
        {
            if (NetworkStatus.Default.BehindIPv4CaptivePortal || NetworkStatus.Default.BehindIPv6CaptivePortal)
            {
                return(CaptivePortalDetected.Yes);
            }

            // "Oh, you want to depend on Windows captive portal detection? Haha nope!" -- Boingo Wi-FI
            // Some captive portals indeed let msftncsi.com through and thoroughly break windows captive portal detection.
            // BWI airport wifi is one of them.
            switch (ConnectivityCheck.IsAccessible())
            {
            case ConnectivityCheck.Accessible.No: return(CaptivePortalDetected.NoResponseReturned);

            case ConnectivityCheck.Accessible.Yes: return(CaptivePortalDetected.No);

            case ConnectivityCheck.Accessible.UnexpectedResponse: return(CaptivePortalDetected.Yes);

            default: return(CaptivePortalDetected.No);
            }
        }
Example #11
0
        /// <summary>
        /// Called when the user taps on "Search" in the search bar.
        /// </summary>
        /// <param name="sender">The object sending the event.</param>
        /// <param name="e">The event parameters.</param>
        private async void SearchBar_SearchButtonPressed(object sender, System.EventArgs e)
        {
            SearchBar searchBar = (SearchBar)sender;

            // Note: this warning might not appear on Android platforms where null/empty/whitespace strings are already
            // handled and refused by the component itself.
            if (string.IsNullOrWhiteSpace(searchBar.Text))
            {
                await this.DisplayAlert(Properties.Resources.Search_NoTermEntered_Title, Properties.Resources.Search_NoTermEntered_Text, Properties.Resources.ButtonOK);

                return;
            }

            if (await ConnectivityCheck.AskToEnableConnectivity(this))
            {
                ((ISearchDataModel)this.BindingContext).SearchForWord(searchBar.Text);

                // Hide all panels, enable the buttons
                this.EnableDefinitionsPanel(true, false);
            }

            this.StringNetAfterTitle.Text  = string.Format(Properties.Resources.MainSearch_StringNet_CollocationsAfterTitle, searchBar.Text);
            this.StringNetBeforeTitle.Text = string.Format(Properties.Resources.MainSearch_StringNet_CollocationsBeforeTitle, searchBar.Text);
        }
Example #12
0
 static int connectivityCheck()
 {
     return((int)ConnectivityCheck.IsAccessible());
 }