Beispiel #1
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            using (var covidMsgBox = new CustomizeDialog.CovidMsgBox("Do you want to save COVID-19 Data for offline use?", "Question"))
            {
                OpenMsgBox(covidMsgBox.ShowDialog());

                if (!covidMsgBox.IsDisposed)
                {
                    covidMsgBox.Dispose();
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    GC.Collect();
                }
            }

            if (Properties.Settings.Default.isInternet)
            {
                isOnline.BackColor = Color.FromArgb(28, 177, 66);
                lblonline.Text     = "You're using online mode";
                if (Classes.OpenURL.Ping("https://disease.sh/v2/all"))
                {
                    DisposeUserControl(new View.OverviewUserControl(), mainpanel);
                }
                else
                {
                    pictureBox2.BringToFront();
                }
            }
            else
            {
                isOnline.BackColor = Color.FromArgb(249, 52, 94);
                lblonline.Text     = "You're using offline mode";
                DisposeUserControl(new View.OverviewUserControl(), mainpanel);
            }
        }
Beispiel #2
0
        void OpenMsgBox(DialogResult result)
        {
            using (var covidMsgBox1 = new CustomizeDialog.CovidMsgBox("Do you want to Load Updated COVID-19 Data from WebAPI? (Internet Required)", "Question"))
            {
                if (result == DialogResult.Yes)
                {
                    using (var downloadDialog = new CustomizeDialog.DownloadDialog(true, ""))
                    {
                        downloadDialog.ShowDialog();

                        if (!downloadDialog.IsDisposed)
                        {
                            downloadDialog.Dispose();
                            GC.Collect();
                            GC.WaitForPendingFinalizers();
                            GC.Collect();
                        }
                    }

                    DialogResult result1 = covidMsgBox1.ShowDialog();
                    if (result1 == DialogResult.Yes)
                    {
                        Properties.Settings.Default.isInternet = true;
                        Properties.Settings.Default.Save();
                    }
                    else if (result1 == DialogResult.No)
                    {
                        Properties.Settings.Default.isInternet = false;
                        Properties.Settings.Default.Save();
                    }
                }
                else if (result == DialogResult.No)
                {
                    DialogResult result1 = covidMsgBox1.ShowDialog();
                    if (result1 == DialogResult.Yes)
                    {
                        Properties.Settings.Default.isInternet = true;
                        Properties.Settings.Default.Save();
                    }
                    else if (result1 == DialogResult.No)
                    {
                        Properties.Settings.Default.isInternet = false;
                        Properties.Settings.Default.Save();
                    }
                }
                if (!covidMsgBox1.IsDisposed)
                {
                    covidMsgBox1.Dispose();
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    GC.Collect();
                }
            }
        }