Ejemplo n.º 1
0
        public void FlowLayoutPanel_SetFlowBreak_Invoke_GetFlowBreakReturnsExpected(bool value)
        {
            using var child   = new Control();
            using var control = new FlowLayoutPanel();
            int layoutCallCount = 0;

            control.Layout += (sender, e) => layoutCallCount++;
            int childLayoutCallCount = 0;

            child.Layout += (sender, e) => childLayoutCallCount++;

            control.SetFlowBreak(child, value);
            Assert.Equal(value, control.GetFlowBreak(child));
            Assert.Equal(0, layoutCallCount);
            Assert.Equal(0, childLayoutCallCount);
            Assert.False(control.IsHandleCreated);
            Assert.False(child.IsHandleCreated);

            // Set same.
            control.SetFlowBreak(child, value);
            Assert.Equal(value, control.GetFlowBreak(child));
            Assert.Equal(0, layoutCallCount);
            Assert.Equal(0, childLayoutCallCount);
            Assert.False(control.IsHandleCreated);
            Assert.False(child.IsHandleCreated);

            // Set different.
            control.SetFlowBreak(child, !value);
            Assert.Equal(!value, control.GetFlowBreak(child));
            Assert.Equal(0, layoutCallCount);
            Assert.Equal(0, childLayoutCallCount);
            Assert.False(control.IsHandleCreated);
            Assert.False(child.IsHandleCreated);
        }
Ejemplo n.º 2
0
        public static bool ShowDialog(string text, string text2, string caption)
        {
            Boolean checks = false;
            Form    prompt = new Form();

            prompt.Width  = 250;
            prompt.Height = 200;
            prompt.Text   = caption;
            FlowLayoutPanel panel = new FlowLayoutPanel();
            CheckBox        chk   = new CheckBox();
            CheckBox        chk2  = new CheckBox();

            chk.Text      = text;
            chk2.Text     = text2;
            chk.AutoSize  = false;
            chk2.AutoSize = false;
            Button ok = new Button()
            {
                Text = "Yes"
            };

            ok.Click += (sender, e) => { prompt.Close(); };
            panel.Controls.Add(chk);
            panel.Controls.Add(chk2);
            panel.SetFlowBreak(chk, true);
            panel.SetFlowBreak(chk2, true);
            panel.Controls.Add(ok);
            prompt.Controls.Add(panel);
            prompt.ShowDialog();
            if (chk.Checked && chk2.Checked)
            {
                checks = true;
            }
            return(checks);
        }
Ejemplo n.º 3
0
 private static void CreateFieldLabelsandText(string sql, bool useData = false)
 {
     using (SqlConnection con = new SqlConnection(connectionString))
     {
         con.Open();
         try
         {
             using (SqlCommand command = new SqlCommand(sql, con))
             {
                 using (SqlDataReader reader = command.ExecuteReader())
                 {
                     for (int i = 0; i < reader.FieldCount; i++)
                     {
                         string field = reader.GetName(i);
                         Label  l     = ControlGenerator.CreateLabel(0, 0, field);
                         tableData.Controls.Add(l);
                         if (useData)
                         {
                             TextBox t = ControlGenerator.CreateTextBox(0, 0, Settings.formWidth - 50, 50);
                             t.Name = "textBox" + field;
                             tableData.Controls.Add(t);
                             tableData.SetFlowBreak(t, true);
                         }
                         else
                         {
                             tableData.SetFlowBreak(l, true);
                         }
                     }
                 }
             }
         }
         catch (SqlException e)
         {
             HandleError(e);
         }
         try
         {
             string f = getPKFromTable.Replace("table", currentTableData);
             using (SqlCommand command = new SqlCommand(f, con))
             {
                 using (SqlDataReader reader = command.ExecuteReader())
                 {
                     reader.Read();
                     PKColumnName = reader.GetString(0);
                 }
             }
         }
         catch (SqlException e)
         {
             HandleError(e);
         }
     }
 }
Ejemplo n.º 4
0
        void BuildForm()
        {
            this.Width = Font.Height * 40;

            this.Text = "Browse For Ftp Folder";

            mFlow.Parent   = this;
            mFlow.Dock     = DockStyle.Fill;
            mFlow.AutoSize = true;
            mFlow.Resize  += new EventHandler(flow_Resize);

            lblFtpSite.Parent   = mFlow;
            lblFtpSite.AutoSize = true;

            mFlow.SetFlowBreak(lblFtpSite, true);

            mFtpDirTree               = new TreeView();
            mFtpDirTree.Parent        = mFlow;
            mFtpDirTree.Font          = new Font("Lucida Console", 8);
            mFtpDirTree.Size          = FtpDirTree_CalcSize();
            mFtpDirTree.LabelEdit     = true;
            mFtpDirTree.BeforeExpand +=
                new TreeViewCancelEventHandler(FtpDirTree_BeforeExpand);
            mFtpDirTree.NodeMouseClick +=
                new TreeNodeMouseClickEventHandler(FtpDirTree_NodeMouseClick);
            mFtpDirTree.AfterLabelEdit +=
                new NodeLabelEditEventHandler(FtpDirTree_AfterLabelEdit);
            mFlow.SetFlowBreak(mFtpDirTree, true);

            Button butNewFolder = new Button();

            butNewFolder.Parent = mFlow;
            butNewFolder.Width  = this.Font.Height * 8;
            butNewFolder.Text   = "Make new folder";
            butNewFolder.Click += new EventHandler(butNewFolder_Click);

            Button butOk = new Button();

            butOk.Parent = mFlow;
            butOk.Width  = this.Font.Height * 6;
            butOk.Text   = "OK";
            butOk.Click += new EventHandler(butOk_Click);

            Button butCancel = new Button();

            butCancel.Parent = mFlow;
            butCancel.Width  = this.Font.Height * 6;
            butCancel.Text   = "Cancel";
            butCancel.Click += new EventHandler(butCancel_Click);
        }
Ejemplo n.º 5
0
        public VwXls()
        {
            InitializeComponent();

            {
                FlowLayoutPanel flp = flperr = new FlowLayoutPanel();
                flp.Hide();
                flp.Dock = DockStyle.Fill;
                {
                    PictureBox pb = new PictureBox();
                    pb.Image    = Resources.eventlogError.ToBitmap();
                    pb.SizeMode = PictureBoxSizeMode.AutoSize;
                    flp.Controls.Add(pb);
                }
                {
                    Label la = laerr1 = new Label();
                    la.AutoSize = true;
                    flp.Controls.Add(la);
                    flp.SetFlowBreak(la, true);
                }
                {
                    Label la = laerr2 = new Label();
                    la.AutoSize = true;
                    flp.Controls.Add(la);
                }
                flp.Parent = this;
            }

            {
                TableLayoutPanel p = flpwip = new TableLayoutPanel();
                p.Hide();
                p.Dock = DockStyle.Fill;
                p.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
                p.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                {
                    FlowLayoutPanel flp = new FlowLayoutPanel();
                    flp.Anchor       = AnchorStyles.None;
                    flp.AutoSize     = true;
                    flp.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                    flp.BackColor    = Color.WhiteSmoke;
                    flp.ForeColor    = Color.Black;
                    {
                        Label la = lawip = new Label();
                        la.AutoSize = true;
                        flp.Controls.Add(la);
                        flp.SetFlowBreak(la, true);
                    }
                    {
                        ProgressBar pb = new ProgressBar();
                        pb.Style = ProgressBarStyle.Marquee;
                        flp.Controls.Add(pb);
                    }
                    p.Controls.Add(flp);
                    flp.Show();
                }
                p.Parent = this;
            }

            Sync = SynchronizationContext.Current;
        }
 private void flowLayoutPanelToday_ControlAdded(object sender, ControlEventArgs e)
 {
     if (flowLayoutPanelToday.Controls.Count % 2 == 0)
     {
         flowLayoutPanelToday.SetFlowBreak(e.Control as Control, true);
     }
 }
Ejemplo n.º 7
0
    /// <summary>
    /// Ouvre une fenêtre lorsqu'un dépôt n'a pas de branche DEV
    /// </summary>
    public static bool ShowDialog(string text, string caption)
    {
        Form prompt = new Form
        {
            AutoSize     = true,
            AutoSizeMode = AutoSizeMode.GrowOnly,
            Padding      = new Padding(20, 20, 20, 0),
            Size         = new System.Drawing.Size(300, 200)
        };
        CheckBox chk = new CheckBox {
            Text = text
        };
        Label label = new Label
        {
            Text     = caption,
            AutoSize = true
        };
        Button ok = new Button()
        {
            Text = "OK"
        };

        ok.Click += (sender, e) => { prompt.Close(); };
        FlowLayoutPanel panel = new FlowLayoutPanel {
            Dock = DockStyle.Fill
        };

        panel.Controls.Add(label);
        panel.Controls.Add(chk);
        panel.SetFlowBreak(chk, true);
        panel.Controls.Add(ok);
        prompt.Controls.Add(panel);
        prompt.ShowDialog();
        return(chk.Checked);
    }
Ejemplo n.º 8
0
        private void showImagesButton_Click(object sender, EventArgs e)
        {
            Form            f    = new Form();
            FlowLayoutPanel flop = new FlowLayoutPanel()
            {
                FlowDirection = FlowDirection.LeftToRight,
                Dock          = DockStyle.Fill,
                AutoScroll    = true,
            };

            f.Controls.Add(flop);
            foreach (var image in images)
            {
                Label label = new Label()
                {
                    Text = image.Key
                };
                PictureBox pic = new PictureBox()
                {
                    Image = image.Value
                };
                pic.SizeMode = PictureBoxSizeMode.AutoSize;
                flop.Controls.Add(label);
                flop.Controls.Add(pic);
                flop.SetFlowBreak(pic, true);
            }
            f.ShowDialog();
        }
Ejemplo n.º 9
0
        private static void addTank(FlowLayoutPanel printerPanel, InkTank tank)
        {
            // add label
            string tankName = tank.Color.Name;

            if (tank.IsPhoto)
            {
                tankName = "Photo " + tankName;
            }
            // add progress bar
            ColorBar barTank = new ColorBar();

            if (tank.IsPhoto)
            {
                //Color.FromArgb(0, tank.Color);
                const int upVal = 100;
                barTank.ForeColor = Color.FromArgb(
                    Math.Min(255, tank.Color.R + upVal),
                    Math.Min(255, tank.Color.G + upVal),
                    Math.Min(255, tank.Color.B + upVal));
            }
            else
            {
                barTank.ForeColor = tank.Color;
            }
            barTank.TextColor = Color.FromArgb(255 - barTank.ForeColor.R,
                                               255 - barTank.ForeColor.G,
                                               255 - barTank.ForeColor.B);
            barTank.Height = 15;
            barTank.Width  = printerPanel.Width - barTank.Left * 2;
            barTank.Value  = (int)tank.Pct;
            barTank.Text   = tankName + " (" + tank.Pct + "%)";
            printerPanel.SetFlowBreak(barTank, true);
            printerPanel.Controls.Add(barTank);
        }
Ejemplo n.º 10
0
        private FlowLayoutPanel createSingleSudokuField(int fieldNumber)
        {
            FlowLayoutPanel field = new FlowLayoutPanel();

            field.AutoSize     = true;
            field.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            field.BackColor    = Color.White;
            field.BorderStyle  = BorderStyle.FixedSingle;
            for (int i = 0; i < 9; ++i)
            {
                Label number = new Label();
                number.Name         = "" + i;
                number.Text         = sudokuValues[i + fieldNumber * 9] != 0 ?"" + sudokuValues[i + fieldNumber * 9] : "?";
                number.Font         = new Font(FontFamily.GenericSansSerif, 20.0f, FontStyle.Bold);
                number.AutoSize     = true;
                number.Click       += new EventHandler(numberClicked);
                number.DoubleClick += new EventHandler(numberClicked);

                field.Controls.Add(number);
                if ((i + 1) % 3 == 0)
                {
                    field.SetFlowBreak(number, true);
                }
            }
            return(field);
        }
Ejemplo n.º 11
0
        private FlowLayoutPanel createSingleSudokuField(int offset, out int outOffset)
        {
            FlowLayoutPanel field = new FlowLayoutPanel();

            field.AutoSize     = true;
            field.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            field.BackColor    = Color.White;
            field.BorderStyle  = BorderStyle.FixedSingle;
            for (int i = 0; i < size * size; ++i)
            {
                int   row    = i / size;
                int   index  = i % size;
                Label number = new Label();
                number.Name         = "" + (index + offset + row * size * 3);
                number.Text         = sudokuValues[index + offset + row * size * 3] != 0 ?"" + sudokuValues[index + offset + row * size * 3] : "?";
                number.Font         = new Font(FontFamily.GenericSansSerif, 20.0f, FontStyle.Bold);
                number.AutoSize     = true;
                number.Click       += new EventHandler(numberClicked);
                number.DoubleClick += new EventHandler(numberClicked);

                field.Controls.Add(number);
                if ((i + 1) % size == 0)
                {
                    field.SetFlowBreak(number, true);
                }
            }
            outOffset = offset + size;
            return(field);
        }
Ejemplo n.º 12
0
        public void SetFlowBreak_Invoke_GetFlowBreakReturnsExpected(bool value)
        {
            var panel   = new FlowLayoutPanel();
            var control = new Control();

            panel.SetFlowBreak(control, value);
            Assert.Equal(value, panel.GetFlowBreak(control));

            // Set same.
            panel.SetFlowBreak(control, value);
            Assert.Equal(value, panel.GetFlowBreak(control));

            // Set different.
            panel.SetFlowBreak(control, !value);
            Assert.Equal(!value, panel.GetFlowBreak(control));
        }
Ejemplo n.º 13
0
    public static bool ShowDialog(string text, string caption)
    {
        Form prompt = new Form();

        prompt.Width  = 180;
        prompt.Height = 100;
        prompt.Text   = caption;
        FlowLayoutPanel panel = new FlowLayoutPanel();
        CheckBox        chk   = new CheckBox();

        chk.Text = text;
        Button ok = new Button()
        {
            Text = "Yes"
        };

        ok.Click += (sender, e) => { prompt.Close(); };
        Button no = new Button()
        {
            Text = "No"
        };

        no.Click += (sender, e) => { prompt.Close(); };
        panel.Controls.Add(chk);
        panel.SetFlowBreak(chk, true);
        panel.Controls.Add(ok);
        panel.Controls.Add(no);
        prompt.Controls.Add(panel);
        prompt.ShowDialog();
        return(chk.Checked);
    }
Ejemplo n.º 14
0
        private void AddRotesToTab(string arcana, FlowLayoutPanel pnl)
        {
            XPathNavigator    xNav      = cvArcanaXml.CreateNavigator().SelectSingleNode($"Arcanum/Arcana[@Name=\"{arcana}\"]");
            XPathNodeIterator xNodeIter = xNav.Select("Rote");

            while (xNodeIter.MoveNext())
            {
                string rote      = xNodeIter.Current.SelectSingleNode("@Name").Value;
                int    roteLevel = xNodeIter.Current.SelectSingleNode("@Level").ValueAsInt;

                CheckBox cbx = new CheckBox();
                cbx.Name   = "cbxRote" + rote.Replace(" ", "");
                cbx.Text   = rote;
                cbx.Width  = 160;
                cbx.Height = 28;

                cbx.CheckedChanged += rote_CheckedChanged;

                rdoAbilityRank rdo = new rdoAbilityRank();
                rdo.AbilityRank = roteLevel;
                rdo.RadioCount  = roteLevel;
                rdo.ReadOnly    = true;
                rdo.Height      = 28;

                pnl.Controls.Add(cbx);
                pnl.Controls.Add(rdo);
                pnl.SetFlowBreak(rdo, true);
            }
        }
Ejemplo n.º 15
0
        private void InitializeComponent()
        {
            this.SuspendLayout();

            FlowLayoutPanel flow = new FlowLayoutPanel();

            flow.Parent = this;
            flow.Dock   = DockStyle.Fill;

            // prompt label
            lblPrompt          = new Label();
            lblPrompt.Parent   = flow;
            lblPrompt.AutoSize = true;
            lblPrompt.Text     = PromptText;
            flow.SetFlowBreak(lblPrompt, true);

            // tbInput
            tbInput          = new TextBox();
            tbInput.Parent   = flow;
            tbInput.Width    = Font.Height * 10;
            tbInput.KeyDown +=
                new System.Windows.Forms.KeyEventHandler(tbInput_KeyDown);

            // InputBox
            this.Width           = Font.Height * 14;
            this.ControlBox      = false;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.ResumeLayout(false);
            this.Activated += new EventHandler(InputBox_Activated);
        }
Ejemplo n.º 16
0
        private void AddLine(int index)
        {
            panel.SetFlowBreak(panel.Controls[panel.Controls.Count - 1], true);

            Label lbl = new Label();

            lbl.Name      = "lblLineBreakindex";
            lbl.Size      = new Size((panel.Size.Width - 20) * 95 / 100, 2);
            lbl.TabIndex  = panel.Controls.Count;
            lbl.Text      = "";
            lbl.Margin    = new Padding(5);
            lbl.AutoSize  = false;
            lbl.BackColor = SystemColors.ControlDarkDark;

            panel.Controls.Add(lbl);

            panel.SetFlowBreak(panel.Controls[panel.Controls.Count - 1], true);
        }
Ejemplo n.º 17
0
        public static void AddQuestionsToFlowLayout(List <QuestionForms> questionsList, ref FlowLayoutPanel flowLayout, ref RichTextBox rtb, ref Logger aLogger, ref List <Question> finalQuestions)
        {
            FinalQuestions = finalQuestions;
            RichTextBox aRtb = rtb;

            //int aquestionCounter = questionCounte;r
            foreach (var forms in questionsList)
            {
                Label generalDescriptionLabel = new Label();
                generalDescriptionLabel.Text     = forms.questions[0].Description;
                generalDescriptionLabel.Font     = new Font("Courier New", 14, FontStyle.Bold);
                generalDescriptionLabel.AutoSize = true;

                flowLayout.Controls.Add(generalDescriptionLabel);
                flowLayout.SetFlowBreak(generalDescriptionLabel, true);
                foreach (var question in forms.questions)
                {
                    Button question1Btn = new Button();
                    question1Btn.Tag      = question;
                    question1Btn.AutoSize = true;
                    question1Btn.Text     = "<- Add";
                    question1Btn.Click   += (s, ee) =>
                    {
                        QuizHelper.AddQuestionTortb(ref aRtb, questionNumber++, (Question)((Button)s).Tag, addAssets, addAnswers);
                        FinalQuestions.Add((Question)((Button)s).Tag);
                    };
                    Label question1Lbl = new Label();
                    question1Lbl.Text     = question.ToString();
                    question1Lbl.AutoSize = true;
                    Label question1Answer = new Label();
                    question1Answer.Text      = question.Answer;
                    question1Answer.BackColor = Color.Green;
                    question1Answer.AutoSize  = true;


                    flowLayout.Controls.Add(question1Btn);

                    flowLayout.Controls.Add(question1Lbl);

                    flowLayout.Controls.Add(question1Answer);
                    flowLayout.SetFlowBreak(question1Answer, true);
                }
            }
        }
Ejemplo n.º 18
0
        public void Add(Graphic type, Graphic graphic, UOColor color, bool stock, Point offset, bool flowBreak)
        {
            var sc = new SupplyCounter(World.Player.Backpack, type, color);

            var c = new ItemCount(sc, graphic, color, stock, offset);

            c.Size = ItemSize;

            container.Controls.Add(c);
            container.SetFlowBreak(c, flowBreak);
        }
Ejemplo n.º 19
0
        private void editGroundIDToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int  entryID  = WhichEntry(this.dataGridView1);
            Form dialoger = new Form
            {
                Text        = "Ground ID Editor",
                MinimizeBox = false,
                MaximizeBox = false,
                Size        = new Size(200, 200)
            };
            Label lbltext = new Label {
                Text = "Please input ground ID:"
            };
            TextBox tbtBox = new TextBox {
                Text = "0"
            };
            FlowLayoutPanel flp = new FlowLayoutPanel();

            flp.Controls.Add(lbltext);
            flp.SetFlowBreak(lbltext, true);
            flp.Controls.Add(tbtBox);
            //dialoger.Controls.Add(new FlowLayoutPanel());
            dialoger.Controls.Add(flp);
            dialoger.Closing += (o, args) => dialogerDelegateClose(o);
            dialoger.ShowDialog();
            dialoger.Dispose();

            entries[entryID].GroundID = (byte)____a;

            int getRealOffset = entryID > 0 ? entryID - (entryID % 8) : 0;

            //int moduloFromEight = entryID%8;
            for (int i = getRealOffset; i < getRealOffset + 8; i++)
            {
                dataGridView1.Rows[i].Cells[2].Value = returnGroundType(entries[entryID].GroundID);
            }

            dataGridView1.Rows[entryID].Cells[2].Value = returnGroundType(entries[entryID].GroundID);

            int realWMSET1index = (int)____a / 8; //redundant int cast on purpouse

            realWMSET1index *= 4;

            using (FileStream fs = new FileStream(WM_Section1.ppath, FileMode.Open, FileAccess.ReadWrite))
                using (BinaryWriter bw = new BinaryWriter(fs))
                {
                    fs.Seek(realWMSET1index, SeekOrigin.Begin);
                    fs.Seek(2, SeekOrigin.Current); //jump to ground id
                    bw.Write(entries[entryID].GroundID);
                }
        }
Ejemplo n.º 20
0
        private void AddPrinters()
        {
            SuspendLayout();
            int prevTop = 0;

            Height = 0;

            foreach (Printer printer in printers)
            {
                FlowLayoutPanel printerPanel = new FlowLayoutPanel();

                printerPanel.FlowDirection = FlowDirection.LeftToRight;
                printerPanel.AutoSizeMode  = AutoSizeMode.GrowAndShrink;

                Label lblPrinterName = new Label();
                lblPrinterName.Text     = printer.Name;
                lblPrinterName.AutoSize = true;
                printerPanel.SetFlowBreak(lblPrinterName, true);
                printerPanel.Controls.Add(lblPrinterName);
                int rows = 1;
                try
                {
                    InkTank[] tanks = printer.GetTanks(printer.Server, printer.Port, printer.Device);
                    foreach (InkTank tank in tanks)
                    {
                        addTank(printerPanel, tank);
                    }
                    rows += tanks.Count();
                }
                catch (Exception e)
                {
                    Label error = new Label();
                    error.AutoSize = true;
                    error.Text     = e.Message;
                    printerPanel.Controls.Add(error);
                    rows += 2;
                }

                printerPanel.Top    = prevTop;
                printerPanel.Width  = this.Width;
                printerPanel.Height = 20 * rows;
                Height = rows * 20;
                Controls.Add(printerPanel);

                prevTop = printerPanel.Bottom + 1;
            }
            ResumeLayout();
        }
Ejemplo n.º 21
0
        public override void InitializeCrazyControls(FlowLayoutPanel flowLayoutPanel, Label errLabel)
        {
            flowLayoutPanel.Controls.Clear();
            CheckBox opCacheCheckbox = new CheckBox();

            opCacheCheckbox.Text            = "Op Cache";
            opCacheCheckbox.Checked         = GetOpCacheEnabledStatus();
            opCacheCheckbox.CheckedChanged += HandleOpCacheCheckbox;
            opCacheCheckbox.Width           = TextRenderer.MeasureText(opCacheCheckbox.Text, opCacheCheckbox.Font).Width + 20;
            flowLayoutPanel.Controls.Add(opCacheCheckbox);

            CheckBox boostCheckbox = new CheckBox();

            boostCheckbox.Text            = "Core Performance Boost";
            boostCheckbox.Checked         = GetCpbEnabled();
            boostCheckbox.CheckedChanged += HandleCorePerformanceBoostCheckbox;
            boostCheckbox.Width           = TextRenderer.MeasureText(boostCheckbox.Text, boostCheckbox.Font).Width + 20;
            flowLayoutPanel.Controls.Add(boostCheckbox);
            flowLayoutPanel.SetFlowBreak(boostCheckbox, true);

            CheckBox l1dStreamPrefetchCheckbox = new CheckBox();

            l1dStreamPrefetchCheckbox.Text            = "L1D Stream Prefetcher";
            l1dStreamPrefetchCheckbox.Checked         = GetL1DStreamPrefetchStatus();
            l1dStreamPrefetchCheckbox.CheckedChanged += HandleL1dStreamCheckbox;
            l1dStreamPrefetchCheckbox.Width           = TextRenderer.MeasureText(l1dStreamPrefetchCheckbox.Text, l1dStreamPrefetchCheckbox.Font).Width + 20;
            flowLayoutPanel.Controls.Add(l1dStreamPrefetchCheckbox);

            CheckBox l2StreamPrefetchCheckbox = new CheckBox();

            l2StreamPrefetchCheckbox.Text            = "L2 Stream Prefetcher";
            l2StreamPrefetchCheckbox.Checked         = GetL2StreamPrefetchStatus();
            l2StreamPrefetchCheckbox.CheckedChanged += HandleL2StreamCheckbox;
            l2StreamPrefetchCheckbox.Width           = TextRenderer.MeasureText(l2StreamPrefetchCheckbox.Text, l2StreamPrefetchCheckbox.Font).Width + 20;
            flowLayoutPanel.Controls.Add(l2StreamPrefetchCheckbox);

            Button setProcNameButton = CreateButton("Set CPU Name String", SetCpuNameString);

            procNameTextBox           = new TextBox();
            procNameTextBox.Width     = 325;
            procNameTextBox.MaxLength = 47;
            flowLayoutPanel.Controls.Add(procNameTextBox);
            flowLayoutPanel.Controls.Add(setProcNameButton);

            errorLabel = errLabel;
        }
Ejemplo n.º 22
0
 public void dynamicPanel(FlowLayoutPanel panel, map[] array)
 {
     panel.Controls.Clear();
     foreach (var row in array)
     {
         var     index   = Array.IndexOf(array, row);
         Label   label   = new Label();
         TextBox textBox = new TextBox();
         label.Name   = "label" + index;
         label.Text   = row.Text;
         textBox.Text = row.Value.ToString();
         textBox.Name = "textBox" + index;
         panel.Controls.Add(label);
         panel.Controls.Add(textBox);
         panel.SetFlowBreak(textBox, true);
     }
 }
Ejemplo n.º 23
0
        public FormThemeEditor(FormThemeEditorController controller)
            : this()
        {
            _controller = controller;

            var sysColors = Theme.SysColors.OrderBy(c => c.ToString(), StringComparer.InvariantCulture);

            foreach (var name in sysColors)
            {
                _layoutPanel.Controls.Add(
                    CreateColorPicker(
                        name,
                        (theme, n) => theme.GetColor(n),
                        (theme, n) => theme.GetDefaultColor(n),
                        (editor, n, color) => editor.SetColor(n, color),
                        (editor, n) => editor.Reset(n)));
            }

            var appColors = Theme.AppColors.OrderBy(c => c.ToString(), StringComparer.InvariantCulture);

            foreach (var name in appColors)
            {
                _layoutPanel.Controls.Add(
                    CreateColorPicker(
                        name,
                        (theme, n) => theme.GetColor(n),
                        (theme, n) => theme.GetDefaultColor(n),
                        (editor, n, color) => editor.SetColor(n, color),
                        (editor, n) => editor.Reset(n)));
            }

            _layoutPanel.SetFlowBreak(_layoutPanel.Controls[_layoutPanel.Controls.Count - 1], true);

            AddButtons();

            Closing += (s, e) =>
            {
                Hide();
                e.Cancel = true;
            };

            UpdateFormSize();
            InitializeComplete();
        }
Ejemplo n.º 24
0
        private void buildSudoku()
        {
            flowLayoutPanel1.Controls.Clear();
            int halfWidth  = this.Width / 2;
            int halfHeight = this.Height / 3;


            int x     = halfWidth - halfWidth / 2;
            int y     = halfHeight - halfHeight / 2;
            int x_inc = (x + halfWidth) / (size);
            int y_inc = (y + halfHeight) / (size);

            FlowLayoutPanel sudoku = new FlowLayoutPanel();

            sudoku.AutoSize = true;


            int offset = 0;

            for (int i = 0; i < 9; ++i)
            {
                FlowLayoutPanel field = createSingleSudokuField(offset, out offset);
                sudoku.Controls.Add(field);

                if ((i + 1) % 3 == 0)
                {
                    sudoku.SetFlowBreak(field, true);
                    offset += (size - 1) * size * 3;
                    x       = halfWidth - halfWidth / 2;
                    y      += y_inc;
                }
                else
                {
                    x += x_inc;
                }
            }
            sudoku.Location = new Point(halfWidth - sudoku.Size.Width, halfHeight - sudoku.Size.Height);
            flowLayoutPanel1.Controls.Add(sudoku);
            this.Refresh();
        }
Ejemplo n.º 25
0
        private static FlowLayoutPanel GetTypeFilters()
        {
            var flp = new FlowLayoutPanel {
                Dock = DockStyle.Fill
            };
            var types  = (EncounterOrder[])Enum.GetValues(typeof(EncounterOrder));
            var checks = types.Select(z => new CheckBox
            {
                Name     = z.ToString(),
                Text     = z.ToString(),
                AutoSize = true,
                Checked  = true,
                Padding  = Padding.Empty,
                Margin   = Padding.Empty,
            }).ToArray();

            foreach (var chk in checks)
            {
                flp.Controls.Add(chk);
                flp.SetFlowBreak(chk, true);
            }
            flp.AutoSize = true;
            return(flp);
        }
Ejemplo n.º 26
0
        public void SetFlowBreak_NullControl_ThrowsArgumentNullException(bool value)
        {
            var panel = new FlowLayoutPanel();

            Assert.Throws <ArgumentNullException>("control", () => panel.SetFlowBreak(null, value));
        }
        private Control GenerateServiceTable(int teamIndex)
        {
            //SERVICE INPUTS BEGIN HERE
            //

            FlowLayoutPanel innerflp = new FlowLayoutPanel
            {
                FlowDirection = FlowDirection.LeftToRight,
                AutoSize      = true
            };

            DataGridView serviceDGV = new DataGridView();

            serviceDGV.Columns.Add("name", "Name");
            serviceDGV.Columns.Add("checkName", "Check Name");
            serviceDGV.Columns.Add("host", "Host");
            serviceDGV.Columns.Add("port", "Port");
            serviceDGV.Columns.Add("points", "Points");

            serviceDGV.Columns[0].Frozen   = true;
            serviceDGV.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;

            for (int j = 0; j < teams[teamIndex].services.Count; j++)
            {
                serviceDGV.Rows.Add(new object[] {
                    teams[teamIndex].services[j].name,
                    teams[teamIndex].services[j].checkName,
                    teams[teamIndex].services[j].host,
                    teams[teamIndex].services[j].port,
                    teams[teamIndex].services[j].points
                });
            }
            serviceDGV.SelectionChanged += ServiceDGV_SelectionChanged;
            serviceDGV.CellValueChanged += ServiceDGV_CellValueChanged;

            /*Break down of what to do:
             *	Select a service
             *		List box to the right of the dgv shows:
             *			Accounts
             *				Selecting this shows a dgv of all accounts for that service, with ability to add more
             *			Environment
             *				Selecting this opens another list box showing:
             *					All matching contents within environment
             *						Selecting one will open a dgv of all properties related to that matching_content
             */
            ListBox mainListBox = new ListBox();

            mainListBox.Items.AddRange(new string[] { "Accounts", "Environment" });
            mainListBox.SelectedIndexChanged += MainListBox_SelectedIndexChanged;

            ComboBox envCmbox = new ComboBox();

            envCmbox.SelectedIndexChanged += EnvCmbox_SelectedIndexChanged;

            TextBox envTbox = new TextBox
            {
                Multiline = true,
                Width     = envCmbox.Width,
                Height    = mainListBox.Height - envCmbox.Height
            };

            envTbox.TextChanged += EnvTbox_TextChanged;

            Button addNew = new Button
            {
                Text   = "Add",
                Width  = envCmbox.Width / 2,
                Margin = Padding.Empty
            };

            addNew.Click += AddNew_Click;

            Button deleteCur = new Button
            {
                Text   = "Delete Selected",
                Width  = envCmbox.Width / 2,
                Margin = Padding.Empty
            };

            deleteCur.Click += DeleteCur_Click;

            DataGridView envDGV = new DataGridView();

            envDGV.Columns.Add("Property", "Property");
            envDGV.Columns.Add("Value", "Value");
            envDGV.CellValueChanged += EnvDGV_CellValueChanged;

            //envDGV.Visible = false;

            Label dumLabel = new Label
            {
                Width  = 0,
                Height = 0,
                Margin = new Padding(0)
            };

            FlowLayoutPanel buttonFLP = new FlowLayoutPanel
            {
                Margin  = Padding.Empty,
                Padding = Padding.Empty,
                Width   = addNew.Width + deleteCur.Width,
                Height  = addNew.Height
            };

            buttonFLP.Controls.AddRange(new Control[] { addNew, deleteCur });
            buttonFLP.SetFlowBreak(deleteCur, true);

            FlowLayoutPanel envFLP = new FlowLayoutPanel
            {
                FlowDirection = FlowDirection.TopDown,
                AutoSize      = true,
                Visible       = false
            };

            envFLP.Controls.AddRange(new Control[] { envCmbox, envTbox, buttonFLP, envDGV });
            envFLP.SetFlowBreak(buttonFLP, true);

            DataGridView acctDGV = new DataGridView();

            acctDGV.Columns.Add("Username", "Username");
            acctDGV.Columns.Add("Password", "Password");
            acctDGV.CellValueChanged += AcctDGV_CellValueChanged;
            acctDGV.Visible           = false;



            //innerflp.Height = serviceDGV.Height;
            //Modify the envListBox, it needs to be able to be modified, incase a new matching_content is created.
            //											0			1			2			3
            innerflp.Controls.AddRange(new Control[] { serviceDGV, mainListBox, envFLP, acctDGV });

            //////////////////////////////////
            //The following are purely for seeing the controls spaces
            //PLEASE REMOVE WHEN FINALIZED

            /*
             * innerflp.BackColor = Color.Purple;
             * buttonFLP.BackColor = Color.Red;
             * envFLP.BackColor = Color.Green;
             */

            return(innerflp);
        }
Ejemplo n.º 28
0
        public Info(KryptonPanel updatePanel)
        {
            updatePanel.Dock = DockStyle.Fill;
            updatePanel.Controls.Clear();

            FlowLayoutPanel flp1 = new FlowLayoutPanel();

            flp1.Dock          = DockStyle.Fill;
            flp1.FlowDirection = FlowDirection.LeftToRight;
            flp1.Padding       = new Padding(20);

            KryptonLabel lblNetworks = new KryptonLabel();

            lblNetworks.StateCommon.ShortText.TextV = PaletteRelativeAlign.Near;
            lblNetworks.Text = "Networks";

            KryptonComboBox         cboNetworks = new KryptonComboBox();
            List <NetworkInterface> interfaces  = new List <NetworkInterface>();

            foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
            {
                if (nic.OperationalStatus == OperationalStatus.Up)
                {
                    cboNetworks.Items.Add(nic.Name);
                    interfaces.Add(nic);
                }
            }

            cboNetworks.SelectedIndex = 0;
            NetworkInterface selectedNic = interfaces[0];

            KryptonLabel lblMACAddress = new KryptonLabel();

            lblMACAddress.StateCommon.ShortText.TextV = PaletteRelativeAlign.Near;
            lblMACAddress.Text = "Network Address";

            KryptonLabel lblMACAddressValue = new KryptonLabel();

            lblMACAddressValue.StateCommon.ShortText.TextV = PaletteRelativeAlign.Near;
            lblMACAddressValue.Text = selectedNic.GetPhysicalAddress().ToString();

            KryptonLabel lblIP = new KryptonLabel();

            lblIP.StateCommon.ShortText.TextV = PaletteRelativeAlign.Near;
            lblIP.Text = "IP Address";

            KryptonLabel lblIPValue = new KryptonLabel();

            lblIPValue.StateCommon.ShortText.TextV = PaletteRelativeAlign.Near;

            foreach (UnicastIPAddressInformation ip in selectedNic.GetIPProperties().UnicastAddresses)
            {
                if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                {
                    lblIPValue.Text = ip.Address.ToString();
                    break;
                }
            }

            KryptonLabel lblSpeed = new KryptonLabel();

            lblSpeed.StateCommon.ShortText.TextV = PaletteRelativeAlign.Near;
            lblSpeed.Text = "Speed";

            KryptonLabel lblSpeedValue = new KryptonLabel();

            lblSpeedValue.StateCommon.ShortText.TextV = PaletteRelativeAlign.Near;
            lblSpeedValue.Text = selectedNic.Speed.ToString() + " bits";

            KryptonLabel lblMachineName = new KryptonLabel();

            lblMachineName.StateCommon.ShortText.TextV = PaletteRelativeAlign.Near;
            lblMachineName.Text = "Machine Name";

            KryptonLabel lblMachineNameValue = new KryptonLabel();

            lblMachineNameValue.StateCommon.ShortText.TextV = PaletteRelativeAlign.Near;
            lblMachineNameValue.Text = System.Windows.Forms.SystemInformation.ComputerName;

            KryptonLabel lblUserName = new KryptonLabel();

            lblUserName.StateCommon.ShortText.TextV = PaletteRelativeAlign.Near;
            lblUserName.Text = "Username";

            KryptonLabel lblUserNameValue = new KryptonLabel();

            lblUserNameValue.StateCommon.ShortText.TextV = PaletteRelativeAlign.Near;
            lblUserNameValue.Text = System.Windows.Forms.SystemInformation.UserName;

            flp1.Controls.Add(lblNetworks);
            flp1.Controls.Add(cboNetworks);
            flp1.SetFlowBreak(cboNetworks, true);
            flp1.Controls.Add(lblMACAddress);
            flp1.Controls.Add(lblMACAddressValue);
            flp1.SetFlowBreak(lblMACAddressValue, true);
            flp1.Controls.Add(lblIP);
            flp1.Controls.Add(lblIPValue);
            flp1.SetFlowBreak(lblIPValue, true);
            flp1.Controls.Add(lblSpeed);
            flp1.Controls.Add(lblSpeedValue);
            flp1.SetFlowBreak(lblSpeedValue, true);
            flp1.Controls.Add(lblMachineName);
            flp1.Controls.Add(lblMachineNameValue);
            flp1.SetFlowBreak(lblMachineNameValue, true);
            flp1.Controls.Add(lblUserName);
            flp1.Controls.Add(lblUserNameValue);

            updatePanel.Controls.Add(flp1);
        }
Ejemplo n.º 29
0
        public static void AddQuestionToFlowLayout(ref FlowLayoutPanel flowlayout, ref Logger logger, ref Exam anExam,
                                                   ref RichTextBox assetsrtb, ref List <string> anexamLog)
        {
            Logger        aLogger = logger;
            List <string> ExamLog = anexamLog;

            for (int i = 0; i < anExam.QuestionsList.Count; i++)
            {
                var question       = anExam.QuestionsList[i];
                var questionNumber = question.QuestionNumber;
                QuizHelper.AddQuestionTortb(ref assetsrtb, questionNumber, question, true, false);

                Label question1Lbl = new Label();
                question1Lbl.Text     = $"Q{questionNumber}. " + question.ToString();
                question1Lbl.AutoSize = true;
                question1Lbl.Font     = new Font("Courier New", 12, FontStyle.Bold);

                flowlayout.Controls.Add(question1Lbl);
                if (question.GetType() == typeof(MultipleChoiceQuestion))
                {
                    GroupBox gb = new GroupBox();
                    gb.Location     = new Point(5, 20);
                    gb.MinimumSize  = new Size(100, 30);
                    gb.AutoSize     = true;
                    gb.AutoSizeMode = AutoSizeMode.GrowOnly;
                    gb.Text         = "Choices";
                    gb.Tag          = questionNumber;

                    int lastpos = 0;
                    for (int j = 0; j < question.Choices.Count; j++)
                    {
                        var option = question.Choices[j];

                        RadioButton rb = new RadioButton();
                        rb.Location        = new Point(7, lastpos += 20);
                        rb.AutoSize        = true;
                        rb.Text            = option;
                        rb.Font            = new Font("Courier New", 12, FontStyle.Bold);
                        rb.CheckedChanged += (s, ee) =>
                        {
                            var rbb = s as RadioButton;
                            if (rbb == null)
                            {
                                return;
                            }
                            if (rbb.Checked)
                            {
                                question.StudentAnswer = rbb.Text;
                                aLogger.LogMessage($"[Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}", LogMsgType.Verbose);
                                ExamLog.Add($"[{DateTime.Now}] [Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}");
                            }
                        };

                        gb.Controls.Add(rb);
                    }
                    flowlayout.Controls.Add(gb);
                    flowlayout.SetFlowBreak(gb, true);
                }
                else if (question.GetType() == typeof(TrueFalseQuestion))
                {
                    GroupBox gb = new GroupBox();
                    gb.Location     = new Point(5, 20);
                    gb.MinimumSize  = new Size(100, 50);
                    gb.AutoSize     = true;
                    gb.AutoSizeMode = AutoSizeMode.GrowOnly;
                    gb.Text         = "Choices";


                    RadioButton rbt = new RadioButton();
                    rbt.Location = new Point(7, 20);
                    rbt.AutoSize = true;
                    rbt.Text     = true.ToString();
                    rbt.Font     = new Font("Courier New", 12, FontStyle.Bold);

                    rbt.CheckedChanged += (s, ee) =>
                    {
                        var rbb = s as RadioButton;
                        if (rbb == null)
                        {
                            return;
                        }
                        if (rbb.Checked)
                        {
                            question.StudentAnswer = rbb.Text;
                            aLogger.LogMessage($"[Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}", LogMsgType.Verbose);
                            ExamLog.Add($"[{DateTime.Now}] [Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}");
                        }
                    };

                    gb.Controls.Add(rbt);

                    RadioButton rbf = new RadioButton();
                    rbf.Location        = new Point(7, 40);
                    rbf.AutoSize        = true;
                    rbf.Text            = false.ToString();
                    rbf.Font            = new Font("Courier New", 12, FontStyle.Bold);
                    rbf.CheckedChanged += (s, ee) =>
                    {
                        var rbb = s as RadioButton;
                        if (rbb == null)
                        {
                            return;
                        }
                        if (rbb.Checked)
                        {
                            question.StudentAnswer = rbb.Text;
                            aLogger.LogMessage($"[Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}", LogMsgType.Verbose);
                            ExamLog.Add($"[{DateTime.Now}] [Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}");
                        }
                    };
                    gb.Controls.Add(rbf);


                    flowlayout.Controls.Add(gb);
                    flowlayout.SetFlowBreak(gb, true);
                }
                else if (question.GetType() == typeof(ValueInputQuestion))
                {
                    TextBox tb = new TextBox();
                    tb.Width        = 100;
                    tb.TextChanged += (s, ee) =>
                    {
                        question.StudentAnswer = tb.Text;
                        aLogger.LogMessage($"[Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}", LogMsgType.Verbose);
                        ExamLog.Add($"[{DateTime.Now}] [Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}");
                    };
                    flowlayout.Controls.Add(tb);
                    flowlayout.SetFlowBreak(tb, true);
                }
            }
        }
Ejemplo n.º 30
0
    private InputDialog()
    {
        Panel pl = new Panel();

        pl.Dock = DockStyle.Fill;

        FlowLayoutPanel flp = new FlowLayoutPanel();

        flp.Dock = DockStyle.Fill;

        lblMessage           = new Label();
        lblMessage.Font      = new Font("Segoe UI", 10);
        lblMessage.ForeColor = Color.White;
        lblMessage.AutoSize  = true;

        Panel txtPl = new Panel();

        txtPl.BorderStyle = BorderStyle.None;
        txtPl.Width       = 360;
        txtPl.Height      = 28;
        txtPl.Padding     = new Padding(5);
        txtPl.BackColor   = Color.White;
        txtPl.Margin      = new Padding(0, 15, 0, 0);
        txtPl.Paint      += txtPl_Paint;

        txtInput             = new TextBox();
        txtInput.Dock        = DockStyle.Fill;
        txtInput.BorderStyle = BorderStyle.None;
        txtInput.Font        = new Font("Segoe UI", 9);
        txtInput.KeyDown    += txtInput_KeyDown;
        txtInput.BackColor   = Color.FromArgb(240, 240, 240);
        txtInput.Multiline   = true;
        txtPl.Controls.Add(txtInput);

        FlowLayoutPanel flpButtons = new FlowLayoutPanel();

        flpButtons.Dock          = DockStyle.Bottom;
        flpButtons.FlowDirection = FlowDirection.RightToLeft;
        flpButtons.Height        = 35;

        Button btnCancel = new Button();

        btnCancel.Text      = "Cancel";
        btnCancel.ForeColor = Color.FromArgb(170, 170, 170);
        btnCancel.Font      = new Font("Segoe UI", 8);
        btnCancel.Padding   = new Padding(3);
        btnCancel.FlatStyle = FlatStyle.Flat;
        btnCancel.Height    = 30;
        btnCancel.Click    += btnCancel_Click;

        Button btnOK = new Button();

        btnOK.Text      = "OK";
        btnOK.ForeColor = Color.FromArgb(170, 170, 170);
        btnOK.Font      = new System.Drawing.Font("Segoe UI", 8);
        btnOK.Padding   = new Padding(3);
        btnOK.FlatStyle = FlatStyle.Flat;
        btnOK.Height    = 30;
        btnOK.Click    += btnOK_Click;

        flpButtons.Controls.Add(btnCancel);
        flpButtons.Controls.Add(btnOK);

        flp.Controls.Add(lblMessage);
        flp.SetFlowBreak(lblMessage, true);
        flp.Controls.Add(txtPl);
        flp.SetFlowBreak(txtPl, true);
        flp.Controls.Add(flpButtons);
        pl.Controls.Add(flp);

        this.Controls.Add(pl);
        this.Controls.Add(flpButtons);
        this.FormBorderStyle = FormBorderStyle.None;
        this.BackColor       = Color.FromArgb(45, 45, 48);
        this.StartPosition   = FormStartPosition.CenterScreen;
        this.Padding         = new Padding(20);
        this.Width           = 400;
        this.Height          = 200;
    }