コード例 #1
0
        private void UnlockFields()
        {
            if (comboBox1.SelectedIndex == -1) return;
            if (!maskedTextBox1.MaskCompleted) return;

            panel1.Enabled = true;
            CleanFields();

            visualCheck.BackColor = SystemColors.Control;

            if (_set.GroupWithGasEngine(comboBox1.SelectedItem.ToString()))
            {
                switch (_gbo)
                {
                    case GBOSTATE.None:
                        if (MessageBox.Show(_rm.GetString("IsGBOActive"), _rm.GetString("warning"),
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                        {
                            _gbo = GBOSTATE.Active;
                            GBO.Enabled = true;
                            GBO.BackColor = Color.Gold;
                        }
                        else
                        {
                            _gbo = GBOSTATE.NonActive;
                            GBO.Enabled = false;
                            GBO.BackColor = SystemColors.Control;
                        }
                        break;
                    case GBOSTATE.Active:
                        _gbo = GBOSTATE.Active;
                        GBO.Enabled = true;
                        GBO.BackColor = Color.Gold;
                        break;
                    default:
                        _gbo = GBOSTATE.NonActive;
                        GBO.Enabled = false;
                        GBO.BackColor = SystemColors.Control;
                        break;
                }
            }
            else
            {
                _gbo = GBOSTATE.NonActive;
                GBO.Enabled = false;
                GBO.BackColor = SystemColors.Control;
            }

            PreviewBtn.Enabled = true;
            SaveBtn.Enabled = true;
            PrintBtn.Enabled = true;

            _rows = new List<VisualRow>();

            _normatives = _set.GetNormativesFromGroup(comboBox1.SelectedItem.ToString());

            foreach (NewVipAvtoSet.NormativesRow normative in _normatives)
            {
                var row = new VisualRow(normative, _random);

                var lables = new List<Label>();

                foreach (Control control2 in panel1.Controls)
                {
                    if (!(control2 is GroupBox)) continue;

                    foreach (Control control3 in control2.Controls)
                    {
                        if (!(control3 is TableLayoutPanel)) continue;

                        foreach (Control control in control3.Controls)
                        {
                            if (control.Tag == null) continue;

                            int tag = Convert.ToInt32(control.Tag);

                            if (tag != row.Id) continue;

                            if (tag == 3 && numericUpDown1.Value == 1)
                                continue;
                            if (tag == 4 && (numericUpDown1.Value == 2 || numericUpDown1.Value == 1))
                                continue;
                            if (tag == 23 &&
                                (numericUpDown1.Value == 1 || numericUpDown1.Value == 2 || numericUpDown1.Value == 3))
                                continue;

                            if (control is TextBox)
                            {
                                row.TextBox = (control as TextBox);
                            }
                            else if (control is Label)
                            {
                                lables.Add((control as Label));
                            }
                        }
                    }
                }

                if (lables.Count == 0)
                    continue;

                if (lables[0].Location.X > lables[1].Location.X)
                {
                    row.MaxLabel = lables[0];
                    row.MinLabel = lables[1];
                }
                else
                {
                    row.MaxLabel = lables[1];
                    row.MinLabel = lables[0];
                }

                _rows.Add(row);

                visualCheck.BackColor = Color.Gold;
                groupBox10.BackColor = Color.Gold;

                panel2.BackColor = Color.Gold;
            }

            timer1.Start();
        }
コード例 #2
0
        public void VisualRowTest()
        {
            var set = new NewVipAvtoSet();
            set.AddGroup(2007, "M1", 0, true);
            set.AddNormative(set.Groups[0].IdGroup, 0, 30);

            var row = new VisualRow(set.Normatives[0], new DRandom());
            row.TextBox = new TextBox();
            row.TextBox = new TextBox();
            row.MinLabel = new Label();
            row.MaxLabel = new Label();
            row.SetMinMax();

            row.TextBox.Text = "";
            row.Requred();

            row.TextBox.Text = "43";
            row.IsValid();
            row.TextBox.Text = "fedsa";
            row.IsValid();
            row.TextBox.Text = "25";
            row.IsValid();

            row.Requred();

            row.PressKey(Keys.D);
            row.PressKey(Keys.OemBackslash);

            Assert.AreEqual(typeof (Label), row.MinLabel.GetType());
            Assert.AreEqual(typeof (Label), row.MaxLabel.GetType());
            Assert.AreEqual(typeof (TextBox), row.TextBox.GetType());
        }