当前位置:网站首页>C countdown tool

C countdown tool

2022-07-28 09:47:00 biyusr

Recently, a friend was playing an online game , There are games 10 Several small leaders , After the death of the little head, every 10 Minutes to refresh . There are many players fighting against monsters , Who was hurt for the first time ,boss Who owns the goods after death , Friends suffer from not being able to count small leaders boss Time to refresh . Always can't win others . I want to help him get a multi-point countdown time software . I feel bored and feasible , Do as you say .

The software interface is provided by :2 Button ( add to 、 Delete )、 One listView, One pictureBox, One timer The clock of .

Dotnet Industrial control

Focus on sharing DotNET Programming experience , Mining programmers' excellent learning resources .

7 Original content

official account


  1. Design when starting listView Column : You can only select the whole line to be designed listView1.FullRowSelect by True, Design timer To count down , In seconds .

        private void Form1_Load(object sender, EventArgs e)        {
               comboBox1.SelectedIndex = 0;            listView1.Columns.Add(" count down / second ",80,HorizontalAlignment.Left);            listView1.Columns.Add(" Set the time ");            listView1.Columns.Add(" Picture address ", 100, HorizontalAlignment.Left);            listView1.FullRowSelect = true;// Only one line can be selected             timer1.Interval = 1000;            timer1.Start();        }

2. Add a button , Load pictures and save pictures , Convenient to check next time .

        private void button1_Click(object sender, EventArgs e)        {
               pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;// The picture is pulled up or down , To adapt to picture Control             string url; Save the picture address             pictureBox1.Image = GetScreenCapture(out url);  // Use the method to load the map             ListViewItem listViewItem = new ListViewItem();            string timeritem = System.Text.RegularExpressions.Regex.Replace(comboBox1.Text, @"[^0-9]+", "");   // Ask for numbers             listViewItem.Text = (int.Parse(timeritem)*60).ToString();            listViewItem.SubItems.Add($"{comboBox1.Text}");            listViewItem.SubItems.Add(url);            listView1.Items.Add(listViewItem);        }        private Bitmap GetScreenCapture(out string url)        {
               Rectangle tScreenRect = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);            Bitmap tSrcBmp = new Bitmap(tScreenRect.Width, tScreenRect.Height); //  Used to save the original picture of the screen             Graphics gp = Graphics.FromImage(tSrcBmp);            gp.CopyFromScreen(0, 0, 0, 0, tScreenRect.Size);            gp.DrawImage(tSrcBmp, 0, 0, tScreenRect, GraphicsUnit.Pixel);            Random ran = new Random();            url = @$"temp\{ran.Next(1, 999)}.jpg";            tSrcBmp.Save(url);            return tSrcBmp;        }

3. Need to update the countdown by seconds , stay timer Update all the countdown in the clock ,

        private void timer1_Tick(object sender, EventArgs e)        {
               this.listView1.BeginUpdate();   // Data update ,UI Hang up for a while , until EndUpdate Draw control , Can effectively avoid flashing and greatly improve the loading speed             foreach (ListViewItem item in listView1.Items)            {
                   item.SubItems[0].Text = (int.Parse(item.SubItems[0].Text) - 1).ToString();             }            this.listView1.EndUpdate();  // End of data processing ,UI The interface is drawn once .        }        /// <summary>        ///  Double click to display the picture         /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)        {                   pictureBox1.ImageLocation = listView1.SelectedItems[0].SubItems[2].Text;         }        /// <summary>        ///  Delete         /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void button2_Click(object sender, EventArgs e)        {
               File.Delete(listView1.SelectedItems[0].SubItems[2].Text);            listView1.SelectedItems[0].Remove();        }

4. design sketch : Friends are very satisfied , Can calculate to small head second refresh . The countdown is 10 Seconds, hurry to the place to refresh and wait for the little leader . Always able to grab the small leader

5. Afterwards, he asked me if I could help him get a script for automatically fighting monsters and grabbing heads , I'm afraid of him

, Tell him directly that he won't .

原网站

版权声明
本文为[biyusr]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/209/202207280917286974.html