Пример #1
0
        private void btnDocbai_Click(object sender, EventArgs e)
        {
            frmDocbai f = new frmDocbai();

            string strNoidung = "";

            if (phan == 1)
            {
                BaiHoc bh = lstXepTu.FirstOrDefault(s => s.Id == bai);
                foreach (Noidung nd in bh.baihoc)
                {
                    strNoidung += MyFunction.ConvertUNI2TCV(nd.noidung) + Environment.NewLine;
                }
            }

            if (phan == 2)
            {
                BaiHoc bh = lstNoiOChu.FirstOrDefault(s => s.Id == bai);
                foreach (Noidung nd in bh.baihoc)
                {
                    strNoidung += MyFunction.ConvertUNI2TCV(nd.noidung.Replace("//", " ")) + Environment.NewLine;
                }
            }

            f.lblNoidung.Text = strNoidung;
            f.ShowDialog();
            f.Dispose();
        }
Пример #2
0
        void init_box()
        {
            int x = le_trai;
            int y = le_trai;
            int w = rong + 10;
            int h = cao + 10;



            foreach (Noidung dong in baihocTV.baihoc)
            {
                int i = 0;
                foreach (string str in dong.noidung.Split(' '))
                {
                    if (x == le_trai && i > 0)
                    {
                        y = y + h + 5;
                    }

                    Label label = new Label();
                    label.Name = "myLblCtr_Box_" + dong.dong + "_" + i;
                    label.Text = "";
                    label.Tag  = MyFunction.ConvertUNI2TCV(str);


                    label.Width       = w;
                    label.Height      = h;
                    label.BackColor   = box_bcolor;
                    label.Location    = new Point(x, y);
                    label.AutoSize    = false;
                    label.TextAlign   = ContentAlignment.MiddleCenter;
                    label.BorderStyle = BorderStyle.Fixed3D;


                    this.panel1.Controls.Add(label);

                    x += w + 10;

                    if (x > panel1.Width - w)
                    {
                        x = le_trai;
                    }

                    i++;
                }
                y = y + h + 15;
                x = le_trai;
            }
        }
Пример #3
0
        void init_noicau()
        {
            clear_all();

            BaiHoc bh = lay_baihoc();

            if (bh == null)
            {
                return;
            }

            List <Cau> trai = new List <Cau>();
            List <Cau> phai = new List <Cau>();

            Random ranDong = new Random();

            List <Noidung> listCau = bh.baihoc;

            sotu = listCau.Count;

            lblBai.Text = MyFunction.ConvertUNI2TCV("Bài " + bh.tieude);

            int i = 0;

            while (listCau.Count > 0)
            {
                int    dong       = ranDong.Next(0, listCau.Count);
                string strNoidung = bh.baihoc[dong].noidung;

                string[] s = strNoidung.Split(new[] { "//" }, StringSplitOptions.None);


                trai.Add(new Cau()
                {
                    id = bh.baihoc[dong].dong, noidung = s[0]
                });
                phai.Add(new Cau()
                {
                    id = bh.baihoc[dong].dong, noidung = s[1]
                });

                listCau.RemoveAt(dong);
                i++;
            }


            ve_trai(trai);
            ve_phai(phai);
        }
Пример #4
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" + cau[idx].id;

                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);
            }
        }
Пример #5
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("Bài " + 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;
                }
            }
        }
Пример #6
0
        public void Load_Bai()
        {
            if (lstBai == null || lstBai.Count == 0)
            {
                return;
            }

            if (bai == -1)
            {
                bai = lstBai.OrderBy(s => s).FirstOrDefault();
            }
            else
            {
                if (phan == 2) //Den bai ke tiep
                {
                    int bai_ke;
                    bai_ke = lstBai.OrderBy(s => s).FirstOrDefault(s => s > bai);

                    if (bai_ke == 0)
                    {
                        MessageBox.Show("Hết rồi !!!");
                        return;
                    }
                    bai  = bai_ke;
                    phan = -1;
                }
            }

            if (phan < 1)
            {
                //kiem tra Bai co phan 1 khong
                var p = lst1.FirstOrDefault(s => s == bai);
                if (p > 0)
                {
                    phan = 1;
                }
                else
                {
                    phan = 2;
                }
                init_uControl(bai, phan);
            }
            else if (phan == 1)
            {
                //kiem tra co phan 2 khong, neu co phan 2 thi hien thi phan 2. neu khong co thi hien thi bai ke tiep

                //kiem tra Bai co phan 2 khong
                var p = lst2.FirstOrDefault(s => s == bai);
                if (p > 0)
                {
                    phan = 2;
                    init_uControl(bai, phan);
                }
                else
                {
                    phan = 2;
                    Load_Bai();
                    return;
                }
            }

            lblBai.Text = MyFunction.ConvertUNI2TCV("Bài " + bai);
        }
Пример #7
0
        public void HienThiBaiHoc(List <int> lstBai)
        {
            int rong  = 150;
            int cao   = 45;
            int space = 5;
            int le    = 50;
            int X     = le;
            int Y     = le;

            int sobai         = lstBai.Count;
            int sobai_motdong = (this.pnMain.Width - le) / (rong + space);
            int sodong        = (int)Math.Ceiling((double)sobai / (double)sobai_motdong);

            int Y_batdau = (this.pnMain.Height - sodong * (cao + space)) / 2;

            if (Y_batdau < 0)
            {
                Y_batdau = 5;
            }
            Y = Y_batdau;

            for (int i = 0; i < lstBai.Count; i++)
            {
                Label l = new Label();
                l.Name = "myLblCtr_bai" + i;
                l.Text = MyFunction.ConvertUNI2TCV("Bài " + lstBai[i]);
                l.Tag  = lstBai[i];

                l.Font = new Font(".VnAvant", 16, FontStyle.Regular);

                l.BackColor   = Color.Bisque;
                l.BorderStyle = BorderStyle.FixedSingle;
                //l.ForeColor = Color.Blue;
                l.AutoSize  = false;
                l.Width     = rong;
                l.Height    = cao;
                l.TextAlign = ContentAlignment.MiddleCenter;
                l.Cursor    = Cursors.Hand;
                l.BringToFront();


                //l.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;

                Point p = new Point(X, Y);
                l.Location = p;

                l.Click += LOnClick;
                //l.MouseHover += LOnMouseHover;
                l.MouseLeave += LOnMouseLeave;
                l.MouseMove  += LOnMouseMove;

                this.pnMain.Controls.Add(l);

                X = X + rong + space;

                if (X > this.pnMain.Width - (rong + space))
                {
                    X = le;
                    Y = Y + cao + space;
                }
            }
        }