Exemplo n.º 1
0
        private void Save_Charges(string dieType_)
        {
            DieType          dieType = (DieType)System.Enum.Parse(typeof(DieType), dieType_);
            List <DieCharge> DC_List = new List <DieCharge>();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (dataGridView1.Rows.IndexOf(row) < dataGridView1.Rows.Count)
                {
                    try
                    {
                        DieCharge DC = new DieCharge(dieType);
                        DC.Name    = row.Cells[0].Value.ToString();
                        DC.Formula = row.Cells[1].Value.ToString();

                        DC_List.Add(DC);
                    }
                    catch
                    {
                    }
                }
            }

            parent.Charge_Dictionary[dieType] = DC_List;
        }
Exemplo n.º 2
0
        private void tB2_TextChanged(object sender, EventArgs e)
        {
            TextBox RefBox = (TextBox)sender;

            try
            {
                DieCharge RefCharge = Ref_List[Convert.ToInt32(RefBox.Name.Substring(1))];
                RefCharge.Quantity = Convert.ToInt32(RefBox.Text);

                Label RefLabel = Label_List.First(x => x.Name == "p" + RefBox.Name.Substring(1));

                RefLabel.Text = "$" + String.Format("{0:0.00}", parent.Charge_Dictionary[Cur_DieType].FirstOrDefault(x => x.Name == RefCharge.Name).GetAdditionalCost(Cur_BasePrice) * RefCharge.Quantity);

                if (RefLabel.Text == "$0")
                {
                    RefLabel.ForeColor = Color.White;
                }
                else
                {
                    RefLabel.ForeColor = Color.LightGreen;
                }
            }
            catch
            {
                if (RefBox.Text.Length > 0)
                {
                    Grey_Out();
                    Form_Message_Box FMB = new Form_Message_Box(parent, "Invalid Quantity", true, -20, this.Location, this.Size);
                    FMB.ShowDialog();
                    Grey_In();
                    RefBox.Text = "";
                }
            }
        }
Exemplo n.º 3
0
        private void tB1_TextChanged(object sender, EventArgs e)
        {
            TextBox   RefBox    = (TextBox)sender;
            DieCharge RefCharge = Ref_List[Convert.ToInt32(RefBox.Name.Substring(1))];

            RefCharge.Notes = RefBox.Text;
        }
Exemplo n.º 4
0
        private void Form_Load(object sender, EventArgs e)
        {
            // Mousedown anywhere to drag
            this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form_MouseDown);

            #region Fade Box
            TFLP           = new FadeControl();
            TFLP.Size      = new Size(this.Width - 2, this.Height - 2);
            TFLP.Location  = new Point(999, 999);
            TFLP.Visible   = true;
            TFLP.BackColor = this.BackColor;
            TFLP.Anchor    = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;

            TFLP.AllowDrop = true;
            TFLP.BringToFront();
            this.Controls.Add(TFLP);
            TFLP.BringToFront();

            TFLP.Opacity = 80;
            #endregion

            foreach (Control c in this.Controls)
            {
                if (c is Button)
                {
                    Button g = (Button)c;
                    g.TabStop   = false;
                    g.FlatStyle = FlatStyle.Flat;
                    g.FlatAppearance.BorderSize  = 0;
                    g.FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255); //transparent
                }
            }

            int count = 0;
            // Set existing charges
            foreach (DieCharge DC in Ref_List)
            {
                DieCharge Ref_DC = Transferred_List.FirstOrDefault(x => x.Name == DC.Name);

                if (Ref_DC != null)
                {
                    DC.Notes    = Ref_DC.Notes;
                    DC.Quantity = Ref_DC.Quantity;
                }

                Create_Charge_Entry(DC, count++);
            }
            if (count <= 6)
            {
                this.Width = this.Width / 2;
            }
            this.Width = this.Width - 20;

            TFLP.Size = new Size(this.Width - 2, this.Height - 2);
        }
Exemplo n.º 5
0
        private void Create_Charge_Entry(DieCharge Charge, int Charge_Index)
        {
            if (parent.Charge_Dictionary[Cur_DieType].Count(x => x.Name == Charge.Name) > 0)
            {
                // Define panel
                Panel main = new Panel()
                {
                    Size = new Size(458, 22)
                };

                // Define label
                Label title = new Label()
                {
                    Name      = "t" + Charge_Index,
                    Text      = Charge.Name,
                    BackColor = this.BackColor,
                    ForeColor = Color.White,
                    Location  = new Point(4, 3),
                    Size      = new Size(185, 18),
                    Font      = new Font(this.Font.FontFamily, 9, FontStyle.Regular)
                };

                // define first notes box
                TextBox tB1 = new TextBox()
                {
                    Name        = "n" + Charge_Index,
                    BorderStyle = BorderStyle.FixedSingle,
                    Text        = Charge.Notes,
                    BackColor   = this.BackColor,
                    ForeColor   = Color.White,
                    Font        = new Font(this.Font.FontFamily, 9, FontStyle.Regular),
                    Size        = new Size(126, 20),
                    Location    = new Point(201, 1)
                };

                // define first qty box
                TextBox tB2 = new TextBox()
                {
                    Name        = "q" + Charge_Index,
                    BorderStyle = BorderStyle.FixedSingle,
                    Text        = Charge.Quantity.ToString(),
                    BackColor   = this.BackColor,
                    ForeColor   = Color.White,
                    Font        = new Font(this.Font.FontFamily, 9, FontStyle.Regular),
                    Size        = new Size(51, 20),
                    Location    = new Point(332, 1),
                    MaxLength   = 3
                };

                tB1.TextChanged += tB1_TextChanged;
                tB2.TextChanged += tB2_TextChanged;

                // Define price label
                Label price = new Label()
                {
                    Name      = "p" + Charge_Index,
                    Text      = "$" + (Charge.Quantity > 0 ? String.Format("{0:0.00}", Charge.Quantity * Charge.GetAdditionalCost(Cur_BasePrice)) : "0"),
                    BackColor = this.BackColor,
                    ForeColor = Charge.Quantity > 0 ? Color.LightGreen : Color.White,
                    Location  = new Point(390, 3),
                    AutoSize  = true,
                    Font      = new Font(this.Font.FontFamily, 8, FontStyle.Regular)
                };

                Label_List.Add(price);

                main.Controls.Add(title);
                main.Controls.Add(tB1);
                main.Controls.Add(tB2);
                main.Controls.Add(price);
                flowLayoutPanel1.Controls.Add(main);

                if (Charge_Index % 2 == 1 && Charge_Index > 2)
                {
                    this.Height += 28;
                    TFLP.Size    = new Size(this.Width - 2, this.Height - 2);
                }
            }
            else
            {
                Console.WriteLine("Invalid charge name detected");
            }
        }