Exemplo n.º 1
0
        public RegistrationPagePart(Data data)
        {
            GroupBox = new GroupBox();

            TitleLabel = new Label
            {
                AutoSize  = true,
                Text      = "Регистрация",
                Font      = new Font("Minion Pro", 20F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(204))),
                ForeColor = Color.CadetBlue,
                BackColor = Color.White,
                Anchor    = AnchorStyles.Top | AnchorStyles.Left
            };
            var pictureBox = new PictureBox
            {
                Image    = Properties.Resources.white,
                SizeMode = PictureBoxSizeMode.StretchImage,
                Anchor   = AnchorStyles.Top | AnchorStyles.Left,
                Size     = new Size(10000, 10000),
                Location = new Point(-5, -5)
            };

            DataFields = new DataField[4];

            for (var i = 0; i < standartFields.Length; i++)
            {
                DataFields[i] = new DataField(standartFields[i]);
                GroupBox.Controls.Add(DataFields[i].Label);
                GroupBox.Controls.Add(DataFields[i].TextBox);
            }

            OkButton = new PictureBox
            {
                Image     = Properties.Resources.success,
                Height    = 40,
                Width     = 40,
                SizeMode  = PictureBoxSizeMode.Zoom,
                BackColor = Color.White
            };

            OkButton.Click += (sender, args) =>
            {
                if (Check())
                {
                    var user = new User(DataFields[0].TextBox.Text,
                                        DataFields[1].TextBox.Text,
                                        DataFields[2].TextBox.Text,
                                        DataFields[3].TextBox.Text);
                    data.AddUser(user);
                    var succ = new SuccesForm("Регистрация прошла успешно.");
                    succ.ShowDialog();
                    //TODO Окно успеха
                    foreach (var dataField in DataFields)
                    {
                        dataField.TextBox.Text = "";
                    }
                    Data.LogData("Регистрация: " + user);
                }
                var error = new SuccesForm("Не все поля запонены.");
                error.ShowDialog();
                //TODO Окно неудачи.
            };
            GroupBox.Controls.Add(TitleLabel);

            GroupBox.Controls.Add(OkButton);
            GroupBox.Controls.Add(pictureBox);
        }
Exemplo n.º 2
0
        public OrderPagePart(Data data, string title, string discription, string[] fields)
        {
            GroupBox = new GroupBox();

            TitleLabel = new Label
            {
                AutoSize  = true,
                Text      = title,
                Font      = new Font("Minion Pro", 20F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(204))),
                ForeColor = Color.CadetBlue,
                BackColor = Color.White,
                Anchor    = AnchorStyles.Top | AnchorStyles.Left
            };
            DiscriptionLabel = new Label
            {
                Text      = discription,
                AutoSize  = true,
                Font      = new Font("Verdana", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(204))),
                ForeColor = Color.FromArgb(100, 100, 100),
                BackColor = Color.White
            };
            var pictureBox = new PictureBox
            {
                Image    = Properties.Resources.white,
                SizeMode = PictureBoxSizeMode.StretchImage,
                Anchor   = AnchorStyles.Top | AnchorStyles.Left,
                Size     = new Size(10000, 10000),
                Location = new Point(-5, -5)
            };

            DataFields = new DataField[fields.Length + standartFields.Length];

            for (var i = 0; i < standartFields.Length; i++)
            {
                DataFields[i] = new DataField(standartFields[i]);
                GroupBox.Controls.Add(DataFields[i].Label);
                GroupBox.Controls.Add(DataFields[i].TextBox);
            }

            for (var i = 0; i < fields.Length; i++)
            {
                DataFields[i + standartFields.Length] = new DataField(fields[i]);
                GroupBox.Controls.Add(DataFields[i + standartFields.Length].Label);
                GroupBox.Controls.Add(DataFields[i + standartFields.Length].TextBox);
            }

            OkButton = new PictureBox
            {
                Image     = Properties.Resources.success,
                Height    = 40,
                Width     = 40,
                SizeMode  = PictureBoxSizeMode.Zoom,
                BackColor = Color.White
            };

            OkButton.Click += (sender, args) =>
            {
                var order = new Order(title, DataFields.Select(x => x.Data).Select(x => x.Replace('/', '\\')));
                data.AddOrder(order);
                var sacces = new SuccesForm("Закказ оформлен.");
                sacces.ShowDialog();
                foreach (var dataField in DataFields)
                {
                    dataField.TextBox.Text = "";
                }
                Data.LogData("Заказ: " + order);
            };
            GroupBox.Controls.Add(TitleLabel);

            GroupBox.Controls.Add(DiscriptionLabel);
            GroupBox.Controls.Add(OkButton);
            GroupBox.Controls.Add(pictureBox);
        }