Ejemplo n.º 1
0
        private void btnChonBai_Click(object sender, EventArgs e)
        {
            frmBai f = new frmBai();

            f.ShowDialog();
            id_chon = f.id_chon;
            f.Dispose();
            BaiHoc bh = MyFunction.ThongtinBaihoc(id_chon);

            if (bh == null)
            {
                return;
            }

            baihocTV = bh;

            HienThiBaiHoc();
        }
Ejemplo n.º 2
0
        public frmHoc()
        {
            InitializeComponent();
            init_color_list();


            MyFunction.FromXml();

            set_font();

            //frmBai f = new frmBai();
            //f.ShowDialog();
            //id_chon = f.id_chon;
            //f.Dispose();
            //baihocTV = MyFunction.ThongtinBaihoc(id_chon);

            id_chon = -1;
            //btnBaiKe_Click(null,null);
        }
Ejemplo n.º 3
0
        private void lstBaihoc_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstBaihoc.SelectedIndices.Count <= 0)
            {
                return;
            }
            int intselectedindex = lstBaihoc.SelectedIndices[0];

            if (intselectedindex >= 0)
            {
                String id = lstBaihoc.Items[intselectedindex].SubItems[0].Text;
                txtID.Text = id;

                BaiHoc bh = MyFunction.ThongtinBaihoc(int.Parse(id));
                txtTieude.Text  = bh.tieude;
                txtNoidung.Text = MyFunction.NoidungToText(bh.baihoc);
                txtThutu.Text   = bh.thutu.ToString();
            }
        }
Ejemplo n.º 4
0
        BaiHoc lay_baihoc()
        {
            if (bai_chon == -1)
            {
                MyFunction.FromXml_NoiCau();
                danhsachNoiCau = MyFunction.danhsachBaihoc;
            }


            if (danhsachNoiCau.Count == 0)
            {
                return(null);
            }

            //Random randomBaihoc = new Random();
            //int idx = randomBaihoc.Next(0, danhsachNoiCau.Count);


            BaiHoc bai = null;

            if (bai_chon == -1)
            {
                bai = danhsachNoiCau.OrderBy(x => x.thutu).ToList().FirstOrDefault();
            }
            else
            {
                bai = MyFunction.danhsachBaihoc.OrderBy(x => x.thutu).ToList().FirstOrDefault(x => x.thutu > bai_chon);
            }


            if (bai == null)
            {
                bai_chon = -1;
                MessageBox.Show("Hết rồi !!!");
                return(null);
            }
            baihocTV = bai;
            bai_chon = bai.thutu;


            return(bai);
        }
Ejemplo n.º 5
0
        void ve_trai(List <Cau> cau)
        {
            int x = pnMain.Width / 2 - rong - 100;
            int y = (pnMain.Height - cau.Count * cao - 20) / 2 - 50;

            Random rdDong = new Random();

            while (cau.Count > 0)
            {
                int idx = rdDong.Next(0, cau.Count);
                idx = rdDong.Next(0, cau.Count);

                Label lb = new Label();
                lb.Text = MyFunction.ConvertUNI2TCV(cau[idx].noidung);
                lb.Tag  = cau[idx].id;
                lb.Name = "myLblTrai";

                lb.Font        = new Font(".VnAvant", 20, FontStyle.Bold);
                lb.BackColor   = Color.Aquamarine;
                lb.BorderStyle = BorderStyle.FixedSingle;
                lb.AutoSize    = false;
                lb.Width       = rong;
                lb.Height      = cao;
                lb.TextAlign   = ContentAlignment.MiddleCenter;
                lb.Cursor      = Cursors.Hand;

                Point p = new Point(x, y);

                lb.Location = p;

                lb.MouseDown += button_MouseDown;
                lb.MouseUp   += button_MouseUp;


                pnMain.Controls.Add(lb);

                y = y + cao + 20;

                cau.RemoveAt(idx);
            }
        }
Ejemplo n.º 6
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (txtID.Text != "")
            {
                BaiHoc bh = MyFunction.danhsachBaihoc.FirstOrDefault(x => x.Id == int.Parse(txtID.Text));

                if (bh != null)
                {
                    try
                    {
                        MyFunction.danhsachBaihoc.Remove(bh);
                        MyFunction.ToXml();

                        load_listBaihoc();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Khong Xoa Duoc");
                        return;
                    }
                }
            }
            init_input();
        }
Ejemplo n.º 7
0
        private void init_Tu()
        {
            int_all();
            Random randomX = new Random();
            Random randomY = new Random();

            int Y = this.Height / 2;
            int X = 0;


            listCtr_Tu = new List <Label>();
            List <string> listTu = new List <string>();

            lblBai.Text = MyFunction.ConvertUNI2TCV(baihocTV.tieude);
            txtBai.Text = "";
            foreach (Noidung nd in baihocTV.baihoc)
            {
                txtBai.Text += MyFunction.ConvertUNI2TCV(nd.noidung) + Environment.NewLine;
                foreach (string str in nd.noidung.Split(' '))
                {
                    listTu.Add(str);
                }
            }

            int sotu         = listTu.Count;
            int sotu_motdong = (this.panel1.Width - le_trai) / (rong + 5);

            int sodong = (int)Math.Ceiling((double)sotu / (double)sotu_motdong);

            int vY = panel1.Height - sodong * (cao + 5);

            List <Point> vitri_Tu = new List <Point>();

            for (int i = 0; i < sodong; i++)
            {
                vitri_Tu.Add(new Point(le_trai, vY));

                vY = vY + cao + 5;
            }

            int idxCnt = 0;

            while (listTu.Count > 0)
            {
                Random randomTu    = new Random();
                int    randomIndex = randomTu.Next(0, listTu.Count);
                Random randomDong  = new Random();
                int    dong        = randomDong.Next(0, vitri_Tu.Count);

                Point p = vitri_Tu[dong];


                Label l = new Label();
                l.Name = "myLblCtr_Tu" + idxCnt;
                l.Text = MyFunction.ConvertUNI2TCV(listTu[randomIndex]);

                l.Font = new Font(".VnAvant", 26, FontStyle.Bold);
                //l.Font = new Font(MyFunction.myfonts.Families[0],20, FontStyle.Bold);
                //l.UseCompatibleTextRendering = true;
                l.BackColor   = init_color();
                l.BorderStyle = BorderStyle.FixedSingle;
                //l.ForeColor = Color.Yellow;
                l.AutoSize  = false;
                l.Width     = rong;
                l.Height    = cao;
                l.TextAlign = ContentAlignment.MiddleCenter;
                l.Cursor    = Cursors.Hand;
                l.BringToFront();


                l.Location = p;


                l.MouseMove += LOnMouseMove;
                l.MouseDown += LOnMouseDown;
                l.MouseUp   += LOnMouseUp;

                this.panel1.Controls.Add(l);
                listCtr_Tu.Add(l);


                idxCnt++;

                listTu.RemoveAt(randomIndex);

                p.X = p.X + (rong + 5);


                if (p.X > panel1.Width - (rong + 5))
                {
                    vitri_Tu.RemoveAt(dong);
                }
                else
                {
                    vitri_Tu[dong] = p;
                }
            }
        }