Exemplo n.º 1
0
        private void RadioButtonGrouped_Clicked(object sender, EventArgs e)
        {
            RadioButtonGrouped rb = (sender as RadioButtonGrouped);

            string rcId    = "-1";
            string radioId = "-1";

            string radioName = rb.Name;

            string[] radioNameSplited = radioName.Split(new string[] { "sectionB" }, StringSplitOptions.None);

            if (radioNameSplited[0] == "" && radioNameSplited.Length == 2)
            {
                string[] radioPositions = radioNameSplited[1].Split(new string[] { "radioButton" }, StringSplitOptions.None);
                if (radioPositions.Length == 2)
                {
                    rcId    = radioPositions[0];
                    radioId = radioPositions[1];
                }
            }

            if (!rb.Checked)
            {
                foreach (Control gb in Controls)
                {
                    if (gb is GroupBox)
                    {
                        foreach (var c in gb.Controls)
                        {
                            if (c is RadioButtonGrouped && (c as RadioButtonGrouped).GroupName == rb.GroupName)
                            {
                                (c as RadioButtonGrouped).Checked = false;
                            }
                            if (radioId == "4")
                            {
                                if (c is GroupBox && (c as GroupBox).Name == "sectionB" + rcId + "groupBox2")
                                {
                                    (c as GroupBox).Enabled = false;


                                    foreach (var d in (c as GroupBox).Controls)
                                    {
                                        if (d is TextBox)
                                        {
                                            (d as TextBox).Text = "";
                                        }
                                    }
                                }
                            }
                            if (radioId == "5")
                            {
                                if (c is GroupBox && (c as GroupBox).Name == "sectionB" + rcId + "groupBox2")
                                {
                                    (c as GroupBox).Enabled = true;

                                    foreach (var d in (c as GroupBox).Controls)
                                    {
                                        if (d is TextBox)
                                        {
                                            (d as TextBox).Text = "";
                                        }
                                    }
                                }
                            }
                            if (radioId == "7")
                            {
                                if (c is RadioButtonGrouped && (c as RadioButtonGrouped).Name == "sectionB" + rcId + "radioButton10")
                                {
                                    (c as RadioButtonGrouped).Checked   = true;
                                    (c as RadioButtonGrouped).Enabled   = true;
                                    (c as RadioButtonGrouped).ForeColor = Color.FromArgb(100, Color.Black);
                                }
                                if (c is RadioButtonGrouped && (c as RadioButtonGrouped).Name == "sectionB" + rcId + "radioButton11" || c is RadioButtonGrouped && (c as RadioButtonGrouped).Name == "sectionB" + rcId + "radioButton12")
                                {
                                    (c as RadioButtonGrouped).Checked   = false;
                                    (c as RadioButtonGrouped).Enabled   = false;
                                    (c as RadioButtonGrouped).ForeColor = Color.FromArgb(50, Color.Black);
                                }
                                if (c is TextBox && (c as TextBox).Name == "sectionB" + rcId + "textBox13")
                                {
                                    (c as TextBox).Text      = "";
                                    (c as TextBox).MaxLength = 11;
                                }
                            }
                            if (radioId == "8")
                            {
                                if (c is RadioButtonGrouped && (c as RadioButtonGrouped).Name == "sectionB" + rcId + "radioButton10")
                                {
                                    (c as RadioButtonGrouped).Checked   = false;
                                    (c as RadioButtonGrouped).Enabled   = false;
                                    (c as RadioButtonGrouped).ForeColor = Color.FromArgb(50, Color.Black);
                                }
                                if (c is RadioButtonGrouped && (c as RadioButtonGrouped).Name == "sectionB" + rcId + "radioButton11" || c is RadioButtonGrouped && (c as RadioButtonGrouped).Name == "sectionB" + rcId + "radioButton12")
                                {
                                    (c as RadioButtonGrouped).Enabled   = true;
                                    (c as RadioButtonGrouped).ForeColor = Color.FromArgb(100, Color.Black);
                                }
                                if (c is TextBox && (c as TextBox).Name == "sectionB" + rcId + "textBox13")
                                {
                                    (c as TextBox).Text      = "";
                                    (c as TextBox).MaxLength = 9;
                                }
                            }
                        }
                        rb.Checked = true;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void sectionBDrawing(int relativesCount)
        {
            sectionBY += sectionAHeight + sectionSeparator;

            for (int rc = 1; rc <= relativesCount; rc++)
            {
                //if(rc==1) { sectionBY += sectionSeparator; }
                sectionX = rc > 1 ? 30 : 40;
                GroupBox groupBox = new GroupBox();
                groupBox.Text     = rc + 1 + ". " + sectionNames[1];
                groupBox.Name     = "sectionB" + rc + "groupBox" + "1";
                groupBox.Location = new Point(sectionX, sectionBY);
                groupBox.Size     = new Size(400, sectionBHeight);
                groupBox.Font     = new System.Drawing.Font(groupBox.Font.FontFamily.Name, 11);
                groupBox.Anchor   = (AnchorStyles.Top);

                string radioGroupName = "";
                int    startPoint     = 20;

                for (int i = 0; i < contentSectionB.Count; i++)
                {
                    if ((int)contentSectionB[i][1] > -3)
                    {
                        string lastContent = i != 0 ? (string)contentSectionB[i - 1][0] : "";
                        if (lastContent.Contains("\n"))
                        {
                            startPoint += 70;
                        }
                        else
                        {
                            startPoint += 40;
                        }
                        Label label = new Label();
                        label.Name     = "sectionB" + rc + "label" + i;
                        label.Location = new Point(6, startPoint);
                        label.Text     = (string)contentSectionB[i][0];
                        label.Font     = new System.Drawing.Font(label.Font.FontFamily.Name, 12);
                        label.AutoSize = true;
                        groupBox.Controls.Add(label);

                        if ((int)contentSectionB[i][1] != -2 && (int)contentSectionB[i][1] != -1)
                        {
                            startPoint += 20;
                            TextBox textBox = new TextBox();
                            textBox.Name      = "sectionB" + rc + "textBox" + i;
                            textBox.Location  = new Point(10, startPoint);
                            textBox.Size      = new Size(380, 20);
                            textBox.MaxLength = (int)contentSectionB[i][1];
                            textBox.Font      = new System.Drawing.Font(textBox.Font.FontFamily.Name, 12);
                            groupBox.Controls.Add(textBox);
                        }

                        if ((int)contentSectionB[i][1] == -1)
                        {
                            startPoint += 30;
                            DateTimePicker dateTimePicker = new DateTimePicker();
                            dateTimePicker.Name     = "sectionB" + rc + "dateTimePicker" + i;
                            dateTimePicker.Location = new Point(10, startPoint);
                            dateTimePicker.MinDate  = new DateTime(1901, 6, 20);
                            dateTimePicker.MaxDate  = DateTime.Today;
                            dateTimePicker.Font     = new System.Drawing.Font(dateTimePicker.Font.FontFamily.Name, 12);
                            groupBox.Controls.Add(dateTimePicker);
                        }
                        if ((int)contentSectionB[i][1] == -2)
                        {
                            radioGroupName = (string)contentSectionB[i][0] + rc;
                        }
                    }
                    else
                    {
                        string lastContent = (string)contentSectionB[i - 1][0];
                        int    breaksCount = lastContent.Split(new string[] { "\n" }, StringSplitOptions.None).Length;
                        if (breaksCount == 3)
                        {
                            startPoint += 70;
                        }
                        else
                        {
                            if (breaksCount == 2)
                            {
                                startPoint += 50;
                            }
                            else
                            {
                                if (breaksCount == 1)
                                {
                                    startPoint += 30;
                                }
                                else
                                {
                                    startPoint += 30;
                                }
                            }
                        }
                        RadioButtonGrouped radioButton = new RadioButtonGrouped();
                        radioButton.Name      = "sectionB" + rc + "radioButton" + i;
                        radioButton.Text      = (string)contentSectionB[i][0];
                        radioButton.AutoSize  = true;
                        radioButton.AutoSize  = true;
                        radioButton.AutoCheck = false;
                        radioButton.Top       = startPoint;
                        radioButton.Left      = 10;
                        radioButton.Font      = new System.Drawing.Font(radioButton.Font.FontFamily.Name, 12);
                        radioButton.GroupName = radioGroupName;
                        radioButton.Click    += RadioButtonGrouped_Clicked;

                        groupBox.Controls.Add(radioButton);
                    }
                }

                startPoint += 90;
                GroupBox groupBoxAdd = new GroupBox();
                groupBoxAdd.Text      = rc + 1 + ". " + sectionNames[2];
                groupBoxAdd.ForeColor = Color.Red;
                groupBoxAdd.Name      = "sectionB" + rc + "groupBox" + "2";
                groupBoxAdd.Location  = new Point(10, startPoint);
                groupBoxAdd.Size      = new Size(380, sectionCHeight);
                groupBoxAdd.Anchor    = (AnchorStyles.Top);
                groupBoxAdd.Font      = new System.Drawing.Font(groupBoxAdd.Font.FontFamily.Name, 12);
                groupBox.Controls.Add(groupBoxAdd);

                int startPointC = 40;
                for (int i = 0; i < contentSectionC.Count; i++)
                {
                    startPointC += 40;
                    Label label = new Label();
                    label.Name      = "sectionC" + rc + "label" + i;
                    label.Location  = new Point(6, startPointC);
                    label.Text      = (string)contentSectionC[i][0];
                    label.AutoSize  = true;
                    label.ForeColor = Color.Black;
                    label.Font      = new System.Drawing.Font(label.Font.FontFamily.Name, 12);
                    groupBoxAdd.Controls.Add(label);

                    startPointC += 20;
                    TextBox textBox = new TextBox();
                    textBox.Name      = "sectionC" + rc + "textBox" + i;
                    textBox.Location  = new Point(10, startPointC);
                    textBox.Size      = new Size(360, 20);
                    textBox.MaxLength = (int)contentSectionC[i][1];
                    textBox.ForeColor = Color.Black;
                    textBox.Font      = new System.Drawing.Font(textBox.Font.FontFamily.Name, 12);
                    groupBoxAdd.Controls.Add(textBox);
                }

                Controls.Add(groupBox);

                sectionBY += sectionBHeight + 20;
            }
            sectionX = relativesCount == 0 ? 40 : 30;
        }