Esempio n. 1
0
 //All logic pertaining to starting the service
 private void startLogic()
 {
     Scrap_wrapper.ResetState();
     if (!serviceRunning)
     {
         button_start.Enabled    = false;
         button_stop.Enabled     = true;
         button_settings.Enabled = false;
         Scrap_wrapper.UpdateImage();
         timer1.Interval = Cfg.interval * 1000 * 60;
         timer1.Start();
         Wallpaper.SetDefaultStyle();
         if (Cfg.setwallpaper)
         {
             Wallpaper.Set(Cfg.image_folder + "\\wallpaper.bmp");
         }
         serviceRunning         = true;
         runningLabel.Text      = "    Running";
         runningLabel.ForeColor = Color.DarkGreen;
     }
     else
     {
         MessageBox.Show("Service already running");
     }
     contextMenuSetter();
 }
Esempio n. 2
0
 private void timer2_Tick(object sender, EventArgs e)
 {
     if (Cfg.source_selection != 0)
     {
         Scrap_wrapper.CleanCDN();
     }
 }
Esempio n. 3
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     System.Threading.Thread.Sleep(10000); // wait 10 secs for Internet reconnection after system resume.
     Scrap_wrapper.UpdateImage();
     if (Cfg.setwallpaper)
     {
         Wallpaper.Set(Cfg.image_folder + "\\wallpaper.bmp");
     }
 }
Esempio n. 4
0
        //All logic pertaining to starting the service
        private async Task StartLogic(CancellationTokenSource _cancelSource)
        {
            await Scrap_wrapper.UpdateImage(_cancelSource);

            Wallpaper.SetDefaultStyle();
            if (Cfg.setwallpaper)
            {
                Wallpaper.Set(Cfg.image_folder + "\\wallpaper.bmp");
            }
        }
Esempio n. 5
0
        private async void timer1_Tick(object sender, EventArgs e)
        {
            _cancelSource = new CancellationTokenSource();
            await Task.Delay(TimeSpan.FromSeconds(10)); // wait 10 secs for Internet reconnection after system resume.

            await Scrap_wrapper.UpdateImage(_cancelSource);

            if (Cfg.setwallpaper)
            {
                Wallpaper.Set(Cfg.image_folder + "\\wallpaper.bmp");
            }
        }
Esempio n. 6
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (Interlocked.Exchange(ref inTimer1, 1) == 0)
     {
         if (timer1.Interval != Cfg.interval * 1000 * 60)
         {
             timer1.Interval = Cfg.interval * 1000 * 60; // set the interval
         }
         System.Threading.Thread.Sleep(5000);            // wait 5 secs for Internet reconnection after system resume.
         Scrap_wrapper.UpdateImage();
         if (Cfg.setwallpaper)
         {
             Wallpaper.Set(Cfg.image_folder + "\\wallpaper.bmp");
         }
         Interlocked.Exchange(ref inTimer1, 0);
     }
 }
Esempio n. 7
0
        private async void button_start_Click(object sender, EventArgs e)
        {
            Scrap_wrapper.ResetState();
            ChangeWidgetState();
            timer1.Interval = Cfg.interval * 1000 * 60;
            timer1.Start();
            _cancelSource = new CancellationTokenSource(); //send the cancelation token to the download service to support Cancelation task.
            if (!serviceRunning)
            {
                serviceRunning = true;
                await StartLogic(_cancelSource);

                contextMenuSetter();
            }
            else
            {
                MessageBox.Show("Service already running");
            }
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            if (System.Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }
            if (File.Exists(Application.StartupPath + @"\trace.log"))
            {
                File.Delete(Application.StartupPath + @"\trace.log");
            }
            Trace.Listeners.Add(new TextWriterTraceListener(Application.StartupPath + @"\trace.log"));
            Trace.AutoFlush = true;

            try
            {
                Cfg.Load();
            }
            catch
            {
                return;
            }
            if (Cfg.source_selection == 0 & Cfg.cloud_name.Equals("demo"))
            {
                #if DEBUG
                #else
                DialogResult dr = MessageBox.Show("WARNING: it's recommended to get images from CDN. \n 注意:推荐使用CDN方式来抓取图片,以提高稳定性。", "EarthLiveSharp");
                if (dr == DialogResult.OK)
                {
                    Process.Start("https://github.com/bitdust/EarthLiveSharp/issues/32");
                }
                #endif
            }
            //if (Cfg.language.Equals("en")| Cfg.language.Equals("zh-Hans")| Cfg.language.Equals("zh-Hant"))
            //{
            //    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Cfg.language);
            //}
            Cfg.image_folder = Application.StartupPath + @"\images";
            Cfg.Save();
            Scrap_wrapper.set_scraper();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new mainForm());
        }
Esempio n. 9
0
 //All logic pertaining to starting the service
 private void startLogic()
 {
     Scrap_wrapper.ResetState();
     if (!serviceRunning)
     {
         button_start.Enabled    = false;
         button_stop.Enabled     = true;
         button_settings.Enabled = false;
         timer1.Interval         = 1000; // trick to trigger timer immediately.
         timer1.Start();
         serviceRunning         = true;
         runningLabel.Text      = "    Running";
         runningLabel.ForeColor = Color.DarkGreen;
     }
     else
     {
         MessageBox.Show("Service already running");
     }
     contextMenuSetter();
 }
Esempio n. 10
0
 private void timer2_Tick(object sender, EventArgs e)
 {
     Scrap_wrapper.CleanCDN();
 }