Exemple #1
0
 private void countNumUpDown_ValueChanged(object sender, EventArgs e)
 {
     NumUpdowns.ForEach(a => this.Controls.Remove(a));
     NumUpdowns.Clear();
     var rand = new Random();
     for (int i = 0; i < countNumUpDown.Value; i++)
     {
         var numupdown = new NumericUpDown();
         numupdown.Maximum = 1000;
         numupdown.Value = rand.Next((int)numupdown.Minimum, (int)numupdown.Maximum);
         numupdown.Location = new Point(10 + i * (numupdown.Width + 10), 50);
         numupdown.BringToFront();
         NumUpdowns.Add(numupdown);
         this.Controls.Add(numupdown);
     }
 }
Exemple #2
0
        //Adding all male apparels information into their respective category(tabPage)
        private void AddMaleApparels()
        {
            foreach (TabPage tp in MCatalogue.TabPages)
            {
                tp.BackColor = Color.White;

                FlowLayoutPanel flp = new FlowLayoutPanel();
                flp.Dock = DockStyle.Fill;
                flp.AutoScroll = true;
                flp.VerticalScroll.Visible = true;
                flp.BackColor = Color.White;

                foreach (Apparel apparel in store.Apparels)
                {
                    if (apparel.Gender == 'M' && MCatalogue.TabPages.IndexOf(tp) == (apparel.Category.CategoryID - 1))
                    {
                        //Panel for each product
                        Panel panel = new Panel();
                        panel.Size = new Size(170, 270);
                        panel.BackColor = Color.White;
                        panel.BorderStyle = BorderStyle.FixedSingle;

                        //PictureBox for each product's image
                        PictureBox pb = new PictureBox();
                        pb.Location = new Point(9, 0);
                        pb.Size = new Size(150, 150);
                        pb.ImageLocation = "images/" + apparel.ImagePath;
                        pb.SizeMode = PictureBoxSizeMode.StretchImage;

                        //Label for the product's Description
                        Label productDescriptionLabel = new Label();
                        productDescriptionLabel.Location = new Point(0, 140);
                        productDescriptionLabel.Size = new Size(170, 40);
                        productDescriptionLabel.BackColor = Color.Transparent;
                        productDescriptionLabel.Text = apparel.Description;
                        productDescriptionLabel.TextAlign = ContentAlignment.MiddleLeft;
                        productDescriptionLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                        //Label for the product's price
                        Label priceLabel = new Label();
                        priceLabel.Location = new Point(0, 180);
                        priceLabel.Size = new Size(170, 22);
                        priceLabel.BackColor = Color.Transparent;
                        productDescriptionLabel.TextAlign = ContentAlignment.MiddleLeft;
                        priceLabel.Text = "Price: " + apparel.Price.ToString("C", CultureInfo.CreateSpecificCulture("en-US"));
                        priceLabel.Font = new System.Drawing.Font("Arial", 8.4F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                        //Label to display text "Size: "
                        Label sizeLabel = new Label();
                        sizeLabel.Location = new Point(0, 207);
                        sizeLabel.Size = new Size(41, 16);
                        sizeLabel.BackColor = Color.Transparent;
                        sizeLabel.Text = "Size:";
                        sizeLabel.Font = new System.Drawing.Font("Arial", 8.4F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                        sizeLabel.SendToBack();

                        //ComboxBox for user to select the size of the apparel
                        ComboBox sizeSelector = new ComboBox();
                        sizeSelector.Location = new Point(41, 205);
                        sizeSelector.Size = new Size(50, 80);
                        sizeSelector.Text = "size";
                        string[] possibleSize = { "XS", "S", "M", "L", "XL" };
                        foreach (string size in possibleSize)
                        {
                            sizeSelector.Items.Add(size);
                        }
                        sizeSelector.SelectedValueChanged += UpdateProductSize;
                        sizeSelector.Tag = apparel;
                        sizeSelector.BringToFront();

                        //Label to display the text "Quantity: "
                        Label quantityLabel = new Label();
                        quantityLabel.Location = new Point(90, 207);
                        quantityLabel.Size = new Size(35, 16);
                        quantityLabel.BackColor = Color.Transparent;
                        quantityLabel.Text = "Qty:";
                        quantityLabel.Font = new System.Drawing.Font("Arial", 8.4F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                        quantityLabel.SendToBack();

                        //NumericUpDown for user to select the quantity of the apparel
                        NumericUpDown quantitySelector = new NumericUpDown();
                        quantitySelector.Location = new Point(125, 205);
                        quantitySelector.Size = new Size(40, 30);
                        quantitySelector.TextAlign = HorizontalAlignment.Right;
                        quantitySelector.ReadOnly = true;
                        quantitySelector.Maximum = 5;
                        quantitySelector.Minimum = 0;
                        quantitySelector.ValueChanged += UpdateProductQuantity;
                        quantitySelector.Tag = apparel;
                        quantitySelector.BringToFront();

                        //Button for adding the product into the cart
                        Button b = new Button();
                        b.Location = new Point(19, 235);
                        b.Size = new Size(130, 30);
                        b.BackColor = System.Drawing.Color.Transparent;
                        b.FlatStyle = FlatStyle.Flat;
                        b.FlatAppearance.BorderColor = Color.Black;
                        b.FlatAppearance.BorderSize = 2;
                        b.Text = "Add to cart";
                        b.Font = new System.Drawing.Font("Arial", 8.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                        b.MouseEnter += MouseHoverButton;
                        b.MouseLeave += MouseLeaveButton;
                        b.MouseDown += MouseDownButton;
                        b.Click += AddToCart;
                        b.Tag = apparel;

                        panel.Controls.Add(pb);
                        panel.Controls.Add(productDescriptionLabel);
                        panel.Controls.Add(priceLabel);
                        panel.Controls.Add(sizeLabel);
                        panel.Controls.Add(sizeSelector);
                        panel.Controls.Add(quantityLabel);
                        panel.Controls.Add(quantitySelector);
                        panel.Controls.Add(b);
                        flp.Controls.Add(panel);
                    }
                }

                tp.Controls.Add(flp);
            }
        }
        public override void Initialize()
        {
            Log.Write("Welcome to Warrior Sample", Color.Green);

            SettingsForm = new Form()
            {
                Text = "Settings",
                StartPosition = FormStartPosition.CenterScreen,
                Width = 800,
                Height = 490,
                ShowIcon = false
            };

            var picBox = new PictureBox()
            {
                Left = 0,
                Top = 0,
                Width = 800,
                Height = 100,
                Image = TopLogo
            };
            SettingsForm.Controls.Add(picBox);

            var lblLastStandHealth = new Label()
            {
                Text = "Last Stand Health",
                Left = 12,
                Top = 117
            };
            SettingsForm.Controls.Add(lblLastStandHealth);

            var nudLastStandHealthPercent = new NumericUpDown()
            {
                Value = 0,
                Maximum = 100,
                Left = 108,
                Top = 115
            };
            SettingsForm.Controls.Add(nudLastStandHealthPercent);

            var cmdSave = new Button()
            {
                Text = "Save",
                Width = 65,
                Height = 25,
                Left = 662,
                Top = 408,
                Size = new Size(108, 31)
            };
            cmdSave.Click += CmdSave_Click;

            SettingsForm.Controls.Add(cmdSave);
            nudLastStandHealthPercent.BringToFront();
        }
Exemple #4
0
        private void ShowInlineForm()
        {
            int row_index = this.dgv.CurrentCell.RowIndex;

            CustomComboBox inline_users_name = new CustomComboBox();
            inline_users_name.Name = "inline_users_name";
            inline_users_name.comboBox1.DropDownStyle = ComboBoxStyle.DropDown;
            inline_users_name.Read_Only = false;
            inline_users_name.BorderStyle = BorderStyle.None;
            foreach (Users u in this.users_list)
            {
                ComboboxItem item = new ComboboxItem(u.username + " : " + u.name, u.id, u.username);
                inline_users_name.AddItem(item);
                if (this.form_mode == FORM_MODE.EDIT_ITEM)
                {
                    if (u.username == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).users_name)
                    {
                        inline_users_name.comboBox1.SelectedItem = item;
                    }
                }
            }
            inline_users_name.Leave += delegate
            {
                if (inline_users_name.comboBox1.Items.Cast<ComboboxItem>().Where(t => t.name.Length >= inline_users_name.comboBox1.Text.Length).Where(t => t.name.Substring(0, inline_users_name.comboBox1.Text.Length) == inline_users_name.comboBox1.Text).Count() > 0)
                {
                    inline_users_name.comboBox1.SelectedItem = inline_users_name.comboBox1.Items.Cast<ComboboxItem>().Where(t => t.name.Length >= inline_users_name.comboBox1.Text.Length).Where(t => t.name.Substring(0, inline_users_name.comboBox1.Text.Length) == inline_users_name.comboBox1.Text).First();
                }
                else
                {
                    inline_users_name.comboBox1.Focus();
                    SendKeys.Send("{F6}");
                }
            };
            inline_users_name.comboBox1.SelectedIndex = (this.form_mode == FORM_MODE.EDIT_ITEM ? this.users_list.FindIndex(t => t.username == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).users_name) : 0);
            this.dgv.Parent.Controls.Add(inline_users_name);

            CustomComboBox inline_leave_cause = new CustomComboBox();
            inline_leave_cause.Name = "inline_leave_cause";
            inline_leave_cause.Read_Only = false;
            inline_leave_cause.BorderStyle = BorderStyle.None;
            foreach (Istab i in this.leave_cause)
            {
                ComboboxItem item = new ComboboxItem(i.typdes_th, i.id, i.typcod);
                item.Tag = i;
                inline_leave_cause.AddItem(item);
                if (this.form_mode == FORM_MODE.EDIT_ITEM)
                {
                    if (i.tabtyp == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).event_type && i.typcod == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).event_code)
                    {
                        inline_leave_cause.comboBox1.SelectedItem = item;
                    }
                }
            }
            inline_leave_cause.comboBox1.SelectedIndex = (this.form_mode == FORM_MODE.EDIT_ITEM ? this.leave_cause.FindIndex(t => t.typcod == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).event_code) : 0);
            this.dgv.Parent.Controls.Add(inline_leave_cause);

            CustomTimePicker inline_from_time = new CustomTimePicker();
            inline_from_time.Name = "inline_from_time";
            inline_from_time.Read_Only = false;
            inline_from_time.BorderStyle = BorderStyle.None;
            inline_from_time.Show_Second = false;
            this.dgv.Parent.Controls.Add(inline_from_time);
            inline_from_time.Time = (this.form_mode == FORM_MODE.EDIT_ITEM ? ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).from_time.TimeString2DateTime() : new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 30, 0));

            CustomTimePicker inline_to_time = new CustomTimePicker();
            inline_to_time.Name = "inline_to_time";
            inline_to_time.Read_Only = false;
            inline_to_time.BorderStyle = BorderStyle.None;
            inline_to_time.Show_Second = false;
            this.dgv.Parent.Controls.Add(inline_to_time);
            inline_to_time.Time = (this.form_mode == FORM_MODE.EDIT_ITEM ? ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).to_time.TimeString2DateTime() : (this.cde.date.Value.GetDayIntOfWeek() == 7 ? new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 12, 00, 0) : new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 30, 0)));

            CustomComboBox inline_status = new CustomComboBox();
            inline_status.Name = "inline_status";
            inline_status.Read_Only = false;
            inline_status.BorderStyle = BorderStyle.None;
            inline_status.AddItem(new ComboboxItem("Wait", 0, "Wait"));
            inline_status.AddItem(new ComboboxItem("Confirmed", 1, "Confirmed"));
            inline_status.AddItem(new ComboboxItem("Canceled", 2, "Canceled"));
            this.dgv.Parent.Controls.Add(inline_status);
            inline_status.comboBox1.SelectedIndex = (this.form_mode == FORM_MODE.EDIT_ITEM ? ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).status : 1);

            CustomTextBox inline_customer = new CustomTextBox();
            inline_customer.Name = "inline_customer";
            inline_customer.Read_Only = false;
            inline_customer.MaxChar = 40;
            inline_customer.BorderStyle = BorderStyle.None;
            this.dgv.Parent.Controls.Add(inline_customer);
            inline_customer.Texts = (this.form_mode == FORM_MODE.EDIT_ITEM ? ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).customer : "");

            CustomComboBox inline_medcert = new CustomComboBox();
            inline_medcert.Name = "inline_medcert";
            inline_medcert.Read_Only = false;
            inline_medcert.BorderStyle = BorderStyle.None;
            inline_medcert.AddItem(new ComboboxItem("N/A (ไม่ระบุ)", 9, "X"));
            inline_medcert.AddItem(new ComboboxItem("ไม่มีเอกสาร", 0, "N"));
            inline_medcert.AddItem(new ComboboxItem("มีใบรับรองแพทย์", 1, "Y"));
            this.dgv.Parent.Controls.Add(inline_medcert);
            inline_medcert.comboBox1.SelectedItem = (this.form_mode == FORM_MODE.EDIT_ITEM ? inline_medcert.comboBox1.Items.Cast<ComboboxItem>().Where(i => i.string_value == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).med_cert).First<ComboboxItem>() : (ComboboxItem)inline_medcert.comboBox1.Items[0]);

            NumericUpDown inline_fine = new NumericUpDown();
            inline_fine.Name = "inline_fine";
            inline_fine.Maximum = 1000;
            inline_fine.Minimum = 0;
            inline_fine.AutoSize = false;
            inline_fine.Font = new Font("tahoma", 9.75f);
            inline_fine.ThousandsSeparator = true;
            inline_fine.BorderStyle = BorderStyle.None;
            inline_fine.TextAlign = HorizontalAlignment.Right;
            this.dgv.Parent.Controls.Add(inline_fine);
            inline_fine.Value = (this.form_mode == FORM_MODE.EDIT_ITEM ? ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).fine : 0);

            this.SetInlineFormPosition();
            this.dgv.SendToBack();
            this.dgv.Enabled = false;
            inline_users_name.BringToFront();
            inline_leave_cause.BringToFront();
            inline_from_time.BringToFront();
            inline_to_time.BringToFront();
            inline_status.BringToFront();
            inline_customer.BringToFront();
            inline_medcert.BringToFront();
            inline_fine.BringToFront();
        }
Exemple #5
0
        private void ShowInlineFormLeaveList()
        {
            this.FormEditItem();
            CustomTimePicker inline_from_time = new CustomTimePicker();
            inline_from_time.Name = "inline_from_time";
            inline_from_time.Read_Only = false;
            this.dgvLeaveList.Parent.Controls.Add(inline_from_time);

            CustomTimePicker inline_to_time = new CustomTimePicker();
            inline_to_time.Name = "inline_to_time";
            inline_to_time.Read_Only = false;
            this.dgvLeaveList.Parent.Controls.Add(inline_to_time);

            CustomComboBox inline_status = new CustomComboBox();
            inline_status.Name = "inline_status";
            inline_status.Read_Only = false;
            inline_status.BorderStyle = BorderStyle.None;
            inline_status.AddItem(new ComboboxItem("WAIT", (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM, "WAIT"));
            inline_status.AddItem(new ComboboxItem("CONFIRMED", (int)CustomDateEvent.EVENT_STATUS.CONFIRMED, "CONFIRMED"));
            inline_status.AddItem(new ComboboxItem("CANCELED", (int)CustomDateEvent.EVENT_STATUS.CANCELED, "CANCELED"));
            this.dgvLeaveList.Parent.Controls.Add(inline_status);

            CustomTextBox inline_customer = new CustomTextBox();
            inline_customer.Name = "inline_customer";
            inline_customer.Read_Only = false;
            inline_customer.BorderStyle = BorderStyle.None;
            inline_customer.MaxChar = 40;
            this.dgvLeaveList.Parent.Controls.Add(inline_customer);

            CustomComboBox inline_medcert = new CustomComboBox();
            inline_medcert.Name = "inline_medcert";
            inline_medcert.Read_Only = false;
            inline_medcert.BorderStyle = BorderStyle.None;
            inline_medcert.AddItem(new ComboboxItem("N/A (ไม่ระบุ)", 9, "X"));
            inline_medcert.AddItem(new ComboboxItem("ไม่มีใบรับรองแพทย์", 0, "N"));
            inline_medcert.AddItem(new ComboboxItem("มีใบรับรองแพทย์", 1, "Y"));
            this.dgvLeaveList.Parent.Controls.Add(inline_medcert);

            NumericUpDown inline_fine = new NumericUpDown();
            inline_fine.Name = "inline_fine";
            inline_fine.Font = new Font("tahoma", 9.75f);
            inline_fine.Maximum = 1000;
            inline_fine.Minimum = 0;
            inline_fine.BorderStyle = BorderStyle.None;
            inline_fine.TextAlign = HorizontalAlignment.Right;
            inline_fine.GotFocus += delegate
            {
                inline_fine.Select(0, inline_fine.Text.Length);
            };
            this.dgvLeaveList.Parent.Controls.Add(inline_fine);

            this.SetPositionFormLeaveList();
            this.dgvAbsentSummary.Enabled = false;
            this.dgvLeaveList.Enabled = false;
            this.dgvLeaveList.SendToBack();
            inline_from_time.BringToFront();
            inline_to_time.BringToFront();
            inline_status.BringToFront();
            inline_customer.BringToFront();
            inline_medcert.BringToFront();
            inline_fine.BringToFront();

            if (this.dgvLeaveList.Rows[this.dgvLeaveList.CurrentCell.RowIndex].Tag is EventCalendar)
            {
                string[] from = ((EventCalendar)this.dgvLeaveList.Rows[this.dgvLeaveList.CurrentCell.RowIndex].Tag).from_time.Split(':');
                inline_from_time.Time = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Convert.ToInt32(from[0]), Convert.ToInt32(from[1]), 0);
                string[] to = ((EventCalendar)this.dgvLeaveList.Rows[this.dgvLeaveList.CurrentCell.RowIndex].Tag).to_time.Split(':');
                inline_to_time.Time = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Convert.ToInt32(to[0]), Convert.ToInt32(to[1]), 0);
                inline_status.comboBox1.SelectedItem = inline_status.comboBox1.Items.Cast<ComboboxItem>().Where(i => i.int_value == ((EventCalendar)this.dgvLeaveList.Rows[this.dgvLeaveList.CurrentCell.RowIndex].Tag).status).First<ComboboxItem>();
                inline_customer.Texts = ((EventCalendar)this.dgvLeaveList.Rows[this.dgvLeaveList.CurrentCell.RowIndex].Tag).customer;
                inline_medcert.comboBox1.SelectedItem = inline_medcert.comboBox1.Items.Cast<ComboboxItem>().Where(i => i.string_value == ((EventCalendar)this.dgvLeaveList.Rows[this.dgvLeaveList.CurrentCell.RowIndex].Tag).med_cert).First<ComboboxItem>();
                inline_fine.Value = ((EventCalendar)this.dgvLeaveList.Rows[this.dgvLeaveList.CurrentCell.RowIndex].Tag).fine;
            }
        }