예제 #1
0
        public LZWPage(Frame navigationFrame)
        {
            this.InitializeComponent();
            this.navigationFrame = navigationFrame;

            this.worker                     = new BackgroundWorker();
            this.worker.DoWork             += this.DoCompressionAsync;
            this.worker.RunWorkerCompleted += this.DoCompressionCompleted;

            this.CompressionStatus.Visibility = Visibility.Visible;
            this.NoConnection.Visibility      = Visibility.Visible;

            if (InternetAvailability.GetIsInternetAvailable())
            {
                this.InfoFrame.Navigate(new Uri("https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch", UriKind.Absolute));
                this.NoConnection.Visibility      = Visibility.Collapsed;
                this.CompressionStatus.Visibility = Visibility.Collapsed;
            }
            else
            {
                this.NoConnection.Visibility      = Visibility.Visible;
                this.CompressionStatus.Visibility = Visibility.Collapsed;
            }

            this.ToggleComponents(true, false);
        }
예제 #2
0
        private async Task ServerStatusAsync()
        {
            SetText("Checking Internet...");
#if !DEBUG
            if (!InternetAvailability.IsInternetAvailable())
            {
                SetText("Internet Not Availlable");
                SplashModel.ShowRetry = true;
                return;
            }
#endif
            SetText("Internet Availlable");
            try
            {
                SetText("Checking Server Status...");
                //HttpResponseMessage message = await SplashModel.GetServiceStatus();
                //if (message.IsSuccessStatusCode)
                //{
                //    SetText("REST API up & good.");
                UpdateSessionStorageInfo();
                //}
                //else
                //    SetText("Server  " + message.ReasonPhrase);
            }
            catch (Exception exception)
            {
                SetText(exception.Message);
            }
        }
        public void WhenInternetConnectionIsShouldPass()
        {
            //given
            //when
            bool isInternetOn = InternetAvailability.IsInternetAvailable();

            //then
            Assert.IsTrue(isInternetOn);
        }
예제 #4
0
        public static void NoConnectionMsg()
        {
            //Check if internet is ok
            WithoutInternetConnection NoConnection = new WithoutInternetConnection();

            if (!InternetAvailability.IsInternetAvailable())
            {
                NoConnection.ShowDialog();
            }
        }
예제 #5
0
 private void HomeButton_Click(object sender, RoutedEventArgs e)
 {
     if (InternetAvailability.IsInternetAvailable())
     {
         MainPageFrame.Navigate(new HomePage(DataContext));
     }
     else
     {
         MainPageFrame.Navigate(new NetworkErrorPage());
     }
 }
예제 #6
0
 public CotacaoBcb()
 {
     if (InternetAvailability.IsInternetAvailable())
     {
         _service       = new FachadaWSSGSClient(new BasicHttpBinding(BasicHttpSecurityMode.Transport), new EndpointAddress(UrlService));
         _codigoService = new CodigosService();
     }
     else
     {
         throw new InternetNotAvailableException();
     }
 }
예제 #7
0
 public MainWindow()
 {
     InitializeComponent();
     DataContext = new MainViewModel();
     if (InternetAvailability.IsInternetAvailable())
     {
         MainPageFrame.Navigate(new HomePage(DataContext));
     }
     else
     {
         MainPageFrame.Navigate(new NetworkErrorPage());
     }
 }
예제 #8
0
    private static async Task HandleUpdates()
    {
        if (!InternetAvailability.IsInternetAvailable())
        {
            return;
        }

        if (await IsMainAppUpdateAvailable())
        {
            Status = UpdateStatus.UPDATEAVAILABLE;
            await HandleLauncherUpdate();
        }
    }
예제 #9
0
        private static bool IsInternetConnected()
        {
            InternetAvailability internet = new InternetAvailability();

            internet.CheckConnection();
            if ((bool)internet.IsConnected)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #10
0
        //return list of best mache of nanny
        public List <PriorityNanny> PriorityNannyList(Mother m, ref int counter)
        {
            List <PriorityNanny> p = new List <PriorityNanny>();

            int countfailure = 0;
            List <System.Threading.Thread> thds = new List <System.Threading.Thread>();

            foreach (Nanny nan in motherPriorities(m))
            {
                PriorityNanny temp = new PriorityNanny(nan);
                temp.Salary = calculateSalary(nan, m);
                if (!InternetAvailability.IsInternetAvailable())
                {
                    throw new Exception("No internet connection");
                }
                System.Threading.Thread t = new System.Threading.Thread(() =>
                {
                    try
                    {
                        temp.Distance = calculateDistance(m.Address, nan.address);
                        if (temp.Distance == 10000000)//not possible number
                        {
                            countfailure++;
                        }
                        else if (temp.Distance <= m.Max_Distance)
                        {
                            p.Add(temp);
                        }
                    }
                    catch (Exception l)
                    {
                        throw new Exception("Failed to calculate the distance!");
                    }
                });
                t.Start();
                //t.Join();
                thds.Add(t);
            }
            foreach (System.Threading.Thread t in thds)
            {
                t.Join();
            }
            p.Sort((x, y) => x.Distance.CompareTo(y.Distance));
            if (countfailure > 0)
            {
                counter = countfailure;
            }
            return(p);
        }
예제 #11
0
        //Confirm button
        private void Confirm_Click(object sender, RoutedEventArgs e)
        {
            if (!InternetAvailability.IsAvailable())
            {
                MessageBox.Show("Error! No internet connection");
                return;
            }

            SyndicationFeed feed = null;

            if (!RSSFeed.TryParseFeed(inputURL.Text, out feed))
            {
                MessageBox.Show("Error! Invalid feed URL");
                return;
            }

            int update = 0;

            int.TryParse(UpdatePeriod.Text, out update);
            if (update <= 0)
            {
                MessageBox.Show("Error! Invalid update period");
                return;
            }

            // determine channel
            Channel parent = null;

            if (Groups.SelectedIndex > 0)
            {
                parent = Groups.SelectedItem as Channel;
            }

            // begin creation/modification
            if (originalFeed == null)
            {
                main.CreateFeed(inputAlias.Text, feed.Title.Text, inputURL.Text, update, parent);
            }
            else
            {
                main.ModifyFeed(originalFeed, inputAlias.Text, feed.Title.Text, inputURL.Text, update, parent);
            }
            Close();
        }
예제 #12
0
    public void PostNewScore(string name, string mail, int score, bool wantsMore)
    {
        //NOTE: Make strings safe by removing commas
        name = name.Replace(",", ".");
        mail = mail.Replace(",", ".");


        string[] values = new string[4];
        values[0] = name;
        values[1] = mail;
        values[2] = score.ToString();
        values[3] = wantsMore ? "YES" : "NO";

        _csvWriter.AddNewEntry(values);

        if (InternetAvailability.HasInternet())
        {
            _sendToGoogle.Send(name, mail, wantsMore ? "YES" : "NO", score.ToString());
        }
    }
        public async Task <ResponseData <string> > TranslateText(string originalText)
        {
            var responseData = new ResponseData <string>();

            await Task.Run(async() =>
            {
                var requestUrl = string.Format(Constants.YodaTranslateRequestPattern, Constants.YodaTranslationServiceMainUrl, Uri.EscapeDataString(originalText));

                if (InternetAvailability.IsInternetAvailable())
                {
                    var request    = (HttpWebRequest)WebRequest.Create(requestUrl);
                    request.Method = Constants.GetRequestMethod;
                    request.Headers.Add("X-Mashape-Key", this._constantYodaApiKey);
                    request.Accept = "text/plain";

                    try
                    {
                        var response       = await request.GetResponseAsync();
                        var responseStream = response?.GetResponseStream();
                        if (responseStream != null)
                        {
                            var responseContent       = new StreamReader(responseStream).ReadToEnd();
                            responseData.Data         = responseContent;
                            responseData.IsSuccessful = true;
                            response.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        responseData.Exception    = ex;
                        responseData.ErrorMessage = ex.Message;
                    }
                }
                else
                {
                    responseData.ErrorMessage = Resources.InternetConnectionError;
                }
            });

            return(responseData);
        }
 private void NavigateToCountryPage()
 {
     if (InternetAvailability.IsInternetAvailable())
     {
         if (Countries.Names.Any(s => s.Equals(CountrySearchBox.Text, StringComparison.OrdinalIgnoreCase)))
         {
             MainPageFrame.Navigate(new CountryData((string)CountrySearchBox.Text));
             CountrySearchBox.Text = "";
             Keyboard.ClearFocus();
         }
         else
         {
             MainPageFrame.Navigate(new CountryNotFoundErrorPage());
             CountrySearchBox.Text = "";
             Keyboard.ClearFocus();
         }
     }
     else
     {
         MainPageFrame.Navigate(new NetworkErrorPage());
     }
 }
        public ACPage(Frame navigationFrame)
        {
            this.InitializeComponent();
            this.navigationFrame = navigationFrame;

            this.worker                     = new BackgroundWorker();
            this.worker.DoWork             += this.DoCodingAsync;
            this.worker.RunWorkerCompleted += this.DoCodingCompleted;

            this.CodingStatus.Visibility = Visibility.Collapsed;
            if (InternetAvailability.GetIsInternetAvailable())
            {
                this.InfoFrame.Navigate(new Uri("https://en.wikipedia.org/wiki/Arithmetic_coding", UriKind.Absolute));
                this.NoConnection.Visibility = Visibility.Collapsed;
            }
            else
            {
                this.NoConnection.Visibility = Visibility.Visible;
            }

            this.ToggleComponents(true, false);
        }
예제 #16
0
    // Use this for initialization
    void Start()
    {
        Action <string> commCallback = (csv) =>
        {
            Debug.Log("The loaded data is " + csv);

            int advantageIndex = 0;

            List <List <string> > parsedValues = GoogleSheetsDataFetcher.ParseCSV(csv);
            foreach (List <string> list in parsedValues)
            {
                if (list.Count == 3)
                {
                    string title  = list[0];
                    string text   = list[1];
                    string imgUrl = list[2];

                    advantages[advantageIndex].Init(title, text, imgUrl);
                    advantageIndex++;
                }
                else
                {
                    Debug.LogError("Got data with wrong format! List count " + list.Count);
                }
            }
        };

        //Fetch the data from the remote sheet
        if (InternetAvailability.HasInternet())
        {
            StartCoroutine(GoogleSheetsDataFetcher.DownloadCSVCoroutine(DOC_ID, commCallback, true, LOCAL_FILENAME));
        }
        else
        {
            LocalFetchContent(LOCAL_FILENAME, commCallback);
        }
    }
예제 #17
0
 private void InternetChecker(object sender, EventArgs e)
 {
     IsConnectionOn = InternetAvailability.IsInternetAvailable();
 }