Пример #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            int update_result;

            scraper.size           = Cfg.size;
            scraper.zoom           = Cfg.zoom;
            scraper.image_folder   = Cfg.image_folder;
            scraper.image_source   = Cfg.image_source;
            scraper.delete_timeout = Cfg.delete_timeout;
            System.Threading.Thread.Sleep(10000); // wait 10 secs for Internet reconnection after system resume.

            update_result = scraper.UpdateImage();

            timer1.Stop();
            timer1.Interval = Cfg.interval * 1000 * 60;
            //success
            if (update_result == 0)
            {
                string image_path = string.Format("{0}\\{1}.png", scraper.image_folder, scraper.save_imageID);
                Wallpaper.Set(image_path);
            }
            //success
            else if (update_result == scraper.RETRY_GET_IMAGE)
            {
                timer1.Interval = Cfg.retry_interval * 1000 * 60;
            }
            timer1.Start();
        }
Пример #2
0
 //All logic pertaining to starting the service
 private void startLogic()
 {
     scraper.size         = Cfg.size;
     scraper.zoom         = Cfg.zoom;
     scraper.image_folder = Cfg.image_folder;
     scraper.image_source = Cfg.image_source;
     scraper.last_imageID = "0"; // reset the scraper record.
     if (!serviceRunning)
     {
         button_start.Enabled    = false;
         button_stop.Enabled     = true;
         button_settings.Enabled = false;
         scraper.UpdateImage();
         timer1.Interval = Cfg.interval * 1000 * 60;
         timer1.Start();
         Wallpaper.SetDefaultStyle();
         Wallpaper.Set(scraper.image_folder + "\\wallpaper.bmp");
         serviceRunning         = true;
         runningLabel.Text      = "    Running";
         runningLabel.ForeColor = Color.DarkGreen;
     }
     else
     {
         MessageBox.Show("Service already running");
     }
     contextMenuSetter();
 }
Пример #3
0
        private void timer3_Tick(object sender, EventArgs e)
        {
            if (Images != null && Images.Count > 0)
            {
                //if (direction == -1)
                //{
                //    ticks--;
                //}
                //else
                //{
                //    ticks++;
                //}


                int index = ticks % (Images.Count);
                ticks++;
                //if (index == Images.Count - 1)
                //{
                //    direction = -1;
                //}
                //if (index == 0)
                //{
                //    direction = 1;
                //}



                Task.Run(() => Wallpaper.Set(Images[index]));
            }
        }
Пример #4
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();
 }
Пример #5
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     scraper.size         = Cfg.size;
     scraper.zoom         = Cfg.zoom;
     scraper.image_folder = Cfg.image_folder;
     scraper.image_source = Cfg.image_source;
     scraper.UpdateImage();
     Wallpaper.Set(scraper.image_folder + "\\wallpaper.bmp");
 }
Пример #6
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");
     }
 }
Пример #7
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            //Program.Trace.WriteLine("[get latest ImageID] " + imageID);

            scraper.AddPicture(radioButton1.Checked);
            label3.Text = "壁纸时钟:" + DateTime.Now.ToString("HH:mm:ss");
            //notifyIcon1.ShowBalloonTip(1000, "壁纸时钟已更新", scraper.last_imageID, ToolTipIcon.Info);
            Wallpaper.Set(scraper.image_folder + "\\wallpaper.bmp");
        }
Пример #8
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");
            }
        }
Пример #9
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     scraper.size         = Cfg.size;
     scraper.zoom         = Cfg.zoom;
     scraper.image_folder = Cfg.image_folder;
     scraper.image_source = Cfg.image_source;
     System.Threading.Thread.Sleep(10000); // wait 10 secs for Internet reconnection after system resume.
     scraper.UpdateImage();
     Wallpaper.Set(scraper.image_folder + "\\wallpaper.bmp");
 }
Пример #10
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     scraper.size         = Cfg.size;
     scraper.zoom         = Cfg.zoom;
     scraper.image_folder = Cfg.image_folder;
     scraper.image_source = Cfg.image_source;
     scraper.UpdateImage();
     notifyIcon1.ShowBalloonTip(1000, "地球照片已更新", scraper.last_imageID, ToolTipIcon.Info);
     scraper.AddPicture(radioButton1.Checked);
     Wallpaper.Set(scraper.image_folder + "\\wallpaper.bmp");
 }
Пример #11
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");
            }
        }
Пример #12
0
        private static void JoinImage()
        {
            // join & convert the images to wallpaper.bmp
            Bitmap bitmap = new Bitmap(550 * size, 550 * size);

            Image[,] tile = new Image[size, size];
            Graphics g = Graphics.FromImage(bitmap);

            for (int ii = 0; ii < size; ii++)
            {
                for (int jj = 0; jj < size; jj++)
                {
                    tile[ii, jj] = Image.FromFile(string.Format("{0}\\{1}_{2}.png", image_folder + imageID.Replace("/", ""), ii, jj));
                    g.DrawImage(tile[ii, jj], 550 * ii, 550 * jj);
                    tile[ii, jj].Dispose();
                }
            }
            g.DrawString(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), new Font("新宋体", 30f), new SolidBrush(Color.White), 0, 0);
            g.Save();
            g.Dispose();
            string index = imageID.Replace("/", "");
            string path  = string.Format("{0}\\wallpaper_{1}.bmp", image_folder, index);

            if (zoom == 100)
            {
                bitmap.Save(path, System.Drawing.Imaging.ImageFormat.Bmp);
            }
            else if (1 < zoom & zoom < 100)
            {
                int      new_size    = bitmap.Height * zoom / 100;
                Bitmap   zoom_bitmap = new Bitmap(new_size, new_size);
                Graphics g_2         = Graphics.FromImage(zoom_bitmap);
                g_2.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                g_2.DrawImage(bitmap, 0, 0, new_size, new_size);
                g_2.Save();
                g_2.Dispose();

                zoom_bitmap.Save(path, System.Drawing.Imaging.ImageFormat.Bmp);
                zoom_bitmap.Dispose();
            }
            else
            {
                Trace.WriteLine("[zoom error]");
            }
            Task.Run(() => Wallpaper.Set(path));
            bitmap.Dispose();
        }
Пример #13
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);
     }
 }
Пример #14
0
        //All logic pertaining to starting the service
        private void startLogic()
        {
            radioButton1.Enabled = true;
            radioButton1.Checked = Cfg.showcoastline;

            //scraper.size = Cfg.size;
            //scraper.zoom = Cfg.zoom;
            //scraper.image_folder = Cfg.image_folder;
            //scraper.image_source = Cfg.image_source;


            //client1.Dispose();

            scraper.last_imageID = "0"; // reset the scraper record.
            if (!serviceRunning)
            {
                button_start.Enabled    = false;
                button_stop.Enabled     = true;
                button_settings.Enabled = false;
                scraper.UpdateImage();

                System.Net.WebClient client1 = new System.Net.WebClient();
                string casturl = "http://himawari8-dl.nict.go.jp/himawari8/img/D531106/1d/550/coastline/00ff00_0_0.png";
                client1.DownloadFile(casturl, scraper.image_folder + "\\cast.png");
                client1.Dispose();

                scraper.AddPicture(radioButton1.Checked);
                timer1.Interval = Cfg.interval * 1000 * 60;
                timer1.Start();


                Wallpaper.SetDefaultStyle();
                Wallpaper.Set(scraper.image_folder + "\\wallpaper.bmp");
                serviceRunning         = true;
                runningLabel.Text      = "    Running";
                runningLabel.ForeColor = Color.DarkGreen;
            }
            else
            {
                MessageBox.Show("Service already running");
            }
            timer3.Interval = 1000;
            timer3.Start();
            contextMenuSetter();
        }
Пример #15
0
        private static void SetWallpaper()
        {
            if (Scraper.SavedPath.Length > 0)
            {
                switch (Cfg.DisplayMode)
                {
                case 0:
                    Wallpaper.SetDefaultStyle();
                    Wallpaper.Set(Scraper.SavedPath);
                    break;

                case 1:
                    Wallpaper.Set(Scraper.SavedPath);
                    break;

                case 2:
                    //
                    break;
                }
            }
        }
Пример #16
0
        //All logic pertaining to starting the service
        private void startLogic()
        {
            scraper.size             = Cfg.size;
            scraper.zoom             = Cfg.zoom;
            scraper.image_folder     = Cfg.image_folder;
            scraper.image_tmp_folder = Cfg.image_folder + @"_tmp";
            scraper.image_source     = Cfg.image_source;
            scraper.last_imageID     = "0"; // reset the scraper record.
            if (!serviceRunning)
            {
                int update_result = 0;
                button_start.Enabled    = false;
                button_stop.Enabled     = true;
                button_settings.Enabled = false;

                update_result   = scraper.UpdateImage();
                timer1.Interval = Cfg.interval * 1000 * 60;
                if (update_result == 0)
                {
                    string image_path = string.Format("{0}\\{1}.png", scraper.image_folder, scraper.save_imageID);
                    Wallpaper.SetDefaultStyle();
                    Wallpaper.Set(image_path);
                }
                else if (update_result == scraper.RETRY_GET_IMAGE)
                {
                    timer1.Interval = Cfg.retry_interval * 1000 * 60;
                }
                timer1.Start();
                serviceRunning         = true;
                runningLabel.Text      = "    Running";
                runningLabel.ForeColor = Color.DarkGreen;
            }
            else
            {
                MessageBox.Show("Service already running");
            }
            contextMenuSetter();
        }
Пример #17
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            Random rd       = new Random();
            int    selector = rd.Next(1, 5);

            switch (selector)
            {
            case 1: scraper.pic_url = Cfg.cdn1_addr; break;

            case 2: scraper.pic_url = Cfg.cdn2_addr; break;

            case 3: scraper.pic_url = Cfg.cdn3_addr; break;

            case 4: scraper.pic_url = Cfg.cdn4_addr; break;

            default: scraper.pic_url = Cfg.cdn1_addr; break;
            }
            scraper.UpdateImage();
            if (Cfg.display_mode == 0)
            {
                // Wallpaper.SetDefaultStyle();
                if (scraper.saved_path.Length > 0)
                {
                    Wallpaper.Set(scraper.saved_path);
                }
            }
            else if (Cfg.display_mode == 1)
            {
                if (scraper.saved_path.Length > 0)
                {
                    Wallpaper.Set(scraper.saved_path);
                }
            }
            else if (Cfg.display_mode == 2)
            {
                //
            }
        }
Пример #18
0
 private void radioButton1_CheckedChanged(object sender, EventArgs e)
 {
     //选中
     scraper.AddPicture(radioButton1.Checked);
     Wallpaper.Set(scraper.image_folder + "\\wallpaper.bmp");
 }
Пример #19
0
        //All logic pertaining to starting the service
        private void startLogic()
        {
            if (!serviceRunning)
            {
                //notifyIcon1.ShowBalloonTip(200, "", "EarthLive# Service Started", ToolTipIcon.Warning);
                Cfg.Load();
                if (Cfg.source_select == "cdn")
                {
                    Random rd       = new Random();
                    int    selector = rd.Next(1, 5);
                    switch (selector)
                    {
                    case 1: scraper.pic_url = Cfg.cdn1_addr; break;

                    case 2: scraper.pic_url = Cfg.cdn2_addr; break;

                    case 3: scraper.pic_url = Cfg.cdn3_addr; break;

                    case 4: scraper.pic_url = Cfg.cdn4_addr; break;

                    default: scraper.pic_url = Cfg.cdn1_addr; break;
                    }
                }
                else
                {
                    scraper.pic_url = Cfg.origin_addr;
                }
                //scraper.image_folder = Cfg.image_folder;
                scraper.image_folder    = Application.StartupPath + @"\images";
                scraper.max_number      = Cfg.max_number;
                button_start.Enabled    = false;
                button_stop.Enabled     = true;
                button_settings.Enabled = false;
                scraper.InitFolder();
                scraper.UpdateImage();
                timer1.Interval = Cfg.interval * 1000 * 60;
                timer1.Start();

                switch (Cfg.display_mode)
                {
                case 0:
                    Wallpaper.SetDefaultStyle();
                    if (scraper.saved_path.Length > 0)
                    {
                        Wallpaper.Set(scraper.saved_path);
                    }
                    break;

                case 1:
                    if (scraper.saved_path.Length > 0)
                    {
                        Wallpaper.Set(scraper.saved_path);
                    }
                    break;

                case 2:
                    break;

                default:
                    break;
                }
                ;
                serviceRunning         = true;
                runningLabel.Text      = "    Running";
                runningLabel.ForeColor = Color.DarkGreen;
            }
            else if (serviceRunning)
            {
                MessageBox.Show("Service already running");
            }
            contextMenuSetter();
        }