NEWS

[BUNIFU FRAMEWORK] Hướng dẫn viết ứng dụng đếm ngược thời gian (Count Down Timer) C#

[BUNIFU FRAMEWORK] Hướng dẫn viết ứng dụng đếm ngược thời gian (Count Down Timer) C#
Đăng bởi: Thảo Meo - Lượt xem: 12302 19:03:14, 31/05/2017DEVEXPRESS   In bài viết

Bài viết này, mình tiếp tục chia sẽ cho các bạn source code sử dụng Bunifu Framework trong C# bằng ứng dụng đếm ngược thời gian, sử dụng Count Down Timer.

Ứng dụng này, các bạn nhập vào ngày sinh nhật, sắp đến của mình rồi ứng dụng đếm ngược còn bao nhiêu thời gian đến ngày sinh nhật của bạn. 

C# COUNT DOWN TIMER USE BUNIFU FRAMEWORK

Bunifu Framework giúp cho các bạn dễ dàng thiết kế giao diện bắt mắt, mặc định Bunifu Framework chỉ cho các bạn phiên bản dùng thử 7 ngày. Các bạn có thể download source code của mình bên dưới, ứng dụng đang sử dụng Bunifu Framework phiên bản 1.5.2 bằng ngôn ngữ C#.

Dưới đây là giao diện ứng dụng count down timer bằng C#:

count down timer bunifu framework

SOURCE CODE C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace count_down_timer
{
    public partial class Form1 : Form
    {
        //store gradient themes
        List> templates = new List>();
        public Form1()
        {
            InitializeComponent();


            loader.Dock = DockStyle.Fill;

            //lets add asome templates
            Dictionary template = new Dictionary();

            template.Add("bottomleft", Color.FromArgb(255, 192, 128));
            template.Add("bottomright", Color.FromArgb(251, 97, 122));
            template.Add("topleft", Color.FromArgb(251, 97, 122));
            template.Add("topright", Color.FromArgb(251, 97, 122));

            templates.Add(template);


            template = new Dictionary();

            template.Add("bottomleft", Color.FromArgb(192, 0, 192));
            template.Add("bottomright", Color.Black);
            template.Add("topleft", Color.FromArgb(251, 97, 122));
            template.Add("topright", Color.FromArgb(251, 97, 122));

            templates.Add(template);

            template = new Dictionary();

            template.Add("bottomleft", Color.Black);
            template.Add("bottomright", Color.Black);
            template.Add("topleft", Color.FromArgb(251, 97, 122));
            template.Add("topright", Color.DarkTurquoise);

            templates.Add(template);

            //init fist theme
            load_theme(templates[cur_template]);
        }


        int cur_template = 0;
        private void bunifuThinButton21_Click(object sender, EventArgs e)
        {
            if (cur_template theme)
        {
            this.Opacity = 0.7;
            loader.Visible = true;
            bunifuGradientPanel1.GradientBottomLeft = theme["bottomleft"];
            bunifuGradientPanel1.GradientBottomRight = theme["bottomright"];
            bunifuGradientPanel1.GradientTopLeft = theme["topleft"];
            bunifuGradientPanel1.GradientTopRight = theme["topright"];

            hideloader.Start();
        }

        private void bunifuThinButton22_Click(object sender, EventArgs e)
        {
            Random r = new Random();
            //lets add asome templates
            Dictionary template = new Dictionary();

            template.Add("bottomleft", Color.FromArgb(r.Next(0,255), r.Next(0, 255), r.Next(0, 255)));
            template.Add("bottomright", Color.FromArgb(r.Next(0, 255), r.Next(0, 255), r.Next(0, 255)));
            template.Add("topleft", Color.FromArgb(r.Next(0, 255), r.Next(0, 255), r.Next(0, 255)));
            template.Add("topright", Color.FromArgb(r.Next(0, 255), r.Next(0, 255), r.Next(0, 255)));

            bunifuThinButton21.BackColor = Color.Transparent;        
            bunifuThinButton22.BackColor = Color.Transparent;

            load_theme(template);


            //safe theme
            templates.Add(template);
        }

        private void hideloader_Tick(object sender, EventArgs e)
        {
            hideloader.Stop();
            loader.Visible = false;
            this.Opacity = 0.9;

        } 
        DateTime endTime = new DateTime(2017, 08, 26, 0, 0, 0); //my bithday
        private void timer1_Tick(object sender, EventArgs e)
        { 
            TimeSpan ts = endTime.Subtract(DateTime.Now);

            d.Text = ts.Days.ToString("00");
            h.Text = ts.Hours.ToString("00");
            m.Text = ts.Minutes.ToString("00");
            s.Text = ts.Seconds.ToString("0");


        }

        void openurl(string url)
        {
            Bunifu.Framework.Lib.cmd.EXECUTECMD("start explorer.exe ""+url+""");
        }

        private void bunifuImageButton1_Click(object sender, EventArgs e)
        {
            //my facebook
            openurl("https://www.facebook.com/kimutai.flex");


        }

        private void bunifuImageButton2_Click(object sender, EventArgs e)
        {
            openurl("https://twitter.com/KimTooFlex_KE");
        }

        private void bunifuImageButton3_Click(object sender, EventArgs e)
        {
            openurl("https://github.com/KimTooFlex");
        }

        private void bunifuImageButton4_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }
    }
}

DOWNLOAD SOURCE

THÔNG TIN TÁC GIẢ

BÀI VIẾT LIÊN QUAN

[BUNIFU FRAMEWORK] Hướng dẫn viết ứng dụng đếm ngược thời gian (Count Down Timer) C#
Đăng bởi: Thảo Meo - Lượt xem: 12302 19:03:14, 31/05/2017DEVEXPRESS   In bài viết

CÁC BÀI CÙNG CHỦ ĐỀ

Đọc tiếp
.