Exemple #1
0
        private void FillTest(int count,string path)
        {
            int currentpos = 10;
            const int buttonsize = 150;
            int buttonstart = split_Тесты.Panel2.Width - 40 - buttonsize;
            int buttonwidth = split_Тесты.Panel2.Width - 40 - buttonstart;
            int browserwidth = split_Тесты.Panel2.Width - 45;
            for (int i = 0; i < count; i++)
            {
                WebBrowser b = new WebBrowser();
                b.Location = new Point(10, currentpos);
                b.IsWebBrowserContextMenuEnabled = false;
                b.AllowWebBrowserDrop = false;
                b.WebBrowserShortcutsEnabled = false;
                b.Url = new Uri(String.Format("file:///{0}", Path.Combine(path,(i+1).ToString(),"main.html")));
                b.Visible = true;
                b.Name = "WebBrowser" + i.ToString();
                b.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
                b.Invalidate();
                b.Width = browserwidth;
                b.Height = 250;

                //установка стиля согласно настройкам
                settings.ApplyWebBrowserStyle(b);

                /* Размер по документу
                while (b.Document.Body == null)
                {
                    Application.DoEvents();
                }
                b.Height = b.Document.Body.ScrollRectangle.Height + 25;*/

                b.Parent = split_Тесты.Panel2;
                currentpos += b.Height + 5;

                TextBox t = new TextBox();
                t.Location = new Point(10, currentpos);
                t.Width = buttonstart;
                t.Name = "TextBox" + (i + 1).ToString();
                t.Visible = true;
                t.Multiline = false;
                t.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
                t.Parent = split_Тесты.Panel2;
                t.TextChanged += TestTextBoxChanged;

                Button btn = new Button();
                btn.Location = new Point(buttonstart + 10, currentpos - 1);
                btn.Height = t.Height + 2;
                btn.Width = buttonwidth;
                btn.Name = "Button" + (i + 1).ToString();
                btn.Text = "Проверить";
                btn.Visible = true;
                btn.Anchor = AnchorStyles.Right | AnchorStyles.Top;
                btn.Parent = split_Тесты.Panel2;
                btn.Click += TestButtonPressed;

                currentpos += t.Height + 100;
            }
        }