public CheckoutForm(Root root, IParentForm parent, bool isCheckout) : base(root, parent, isCheckout ? Root.GetMsg("cart.checkout") : Root.GetMsg("cart.order")) { IsCheckout = isCheckout; Cart = IsCheckout ? _Root.ShoppingCart : _Root.OrderCart; _This.InsertActionButtons(Root.GetMsg("cart.action.clear-all"), Properties.Resources.clear_all, (sender, e) => { Cart.Clear(); UpdateList(); }); ItemList.Size = new Size((int)Math.Round(_This.ContentPanel.Width * .65) + PanePadding, _This.ContentPanel.Height); ItemList.Paint += (sender, e) => { int strip = (int)(InfoPane.Height * .1); Pen borderPen = new Pen(new SolidBrush(Color.FromArgb(77, 77, 77))); int off = ItemList.Width - 1; e.Graphics.DrawLine(borderPen, new Point(off, strip), new Point(off, ItemList.Height - strip - 1)); }; _This.ContentPanel.Controls.Add(ItemList); InfoPane.AutoSize = true; InfoPane.MinimumSize = new Size((int)Math.Round(_This.ContentPanel.Width * .35), 0); InfoPane.Left = ItemList.Width + PanePadding / 2; _This.ContentPanel.Controls.Add(InfoPane); InitialInfoPaneComponents(); // must reload parent list avoid any inconsistency OverrideBackReloadDHS = true; UpdateList(); }
public BackableForm(Root root, IParentForm parent, string name) { _Parent = parent; _RefRoot = root; _RefThis = new MetroForm(_Root, name, 1136, 720, OnBack); _This.Tag = this; if (_Parent.GetType().BaseType == typeof(MetroForm)) { _Parent.AnimateHideForm((sn, ev) => { ((MetroForm)_Parent).Hide(((MetroForm)_Parent)); }); } else { IParentForm parentAtTaskBar = _Parent; while (((BackableForm)parentAtTaskBar)._Parent.GetType() != typeof(MainForm)) { parentAtTaskBar = ((BackableForm)parentAtTaskBar)._Parent; } _Parent.AnimateHideForm((sn, ev) => { ((BackableForm) parentAtTaskBar)._This.Hide(((BackableForm) parentAtTaskBar)._This); }); } }
public ImportFurnitureForm(Root root, IParentForm parent) : base(root, parent, Root.GetMsg("main.menu.import-furnitures")) { _This.InsertActionButtons(Root.GetMsg("imfu.import-csv"), Properties.Resources.import_file, ActionImportFromCSV); ItemList.Size = new Size(_This.ContentPanel.Width, _This.ContentPanel.Height - TopSelectorBarSize); ItemList.Top = TopSelectorBarSize; _This.ContentPanel.Controls.Add(ItemList); InsertCategorySelector(); }
public EditItemForm(Root root, IParentForm parent, Furniture data) : base(root, parent, Root.GetMsg("edit.title")) { _Item = data; BoxGroup = new Panel(); BoxGroup.AutoSize = true; ScrollPanel SP = new ScrollPanel(); SP.Size = new Size(_This.ContentPanel.Width, _This.ContentPanel.Height); SP.AutoScroll = true; // create textboxes input BoxName = InsertField(Root.GetMsg("edit.name"), null, null, null); BoxDesc = InsertField(Root.GetMsg("edit.desc"), null, 160, null); BoxDimen1 = InsertField(Root.GetMsg("edit.dimen"), Validation.FloatField, null, 1); BoxDimen2 = InsertField(null, Validation.FloatField, null, 2); BoxDimen3 = InsertField(null, Validation.FloatField, null, 3); BoxPrice = InsertField(Root.GetMsg("edit.price"), (sender, e) => { Validation.NumberField(sender, e, 7); }, null, null); BoxDiscnt = InsertField(Root.GetMsg("edit.discount"), (sender, e) => { Validation.NumberField(sender, e, 2); }, null, null); BoxQty = InsertField(Root.GetMsg("edit.quantity"), (sender, e) => { Validation.NumberField(sender, e, 4); }, null, null); BoxReordrLv = InsertField(Root.GetMsg("edit.rl"), (sender, e) => { Validation.NumberField(sender, e, 4); }, null, null); BoxShelf = InsertField(Root.GetMsg("edit.sl"), Validation.ShelfLocationField, null, null); BoxCtgy = InsertDropDown(Root.GetMsg("edit.category")); BoxCtgy.SelectedIndexChanged += (sender, e) => { int id = (int)((sender as ComboBox).SelectedItem as ComboItem).Value; BoxSubCtgy.Items.Clear(); BoxSubCtgy.Items.AddRange(XQL.GetSubcategoeiesForDropDown(id)); BoxSubCtgy.SelectedIndex = 0; }; BoxSubCtgy = InsertDropDown(Root.GetMsg("edit.subcategory")); BoxCtgy.Items.Clear(); BoxCtgy.Items.AddRange(XQL.GetCategoeiesForDropDown()); BoxCtgy.SelectedIndex = 0; BoxPhoto = InsertField(Root.GetMsg("edit.photo"), null, null, null); BoxName.Text = _Item.Name; BoxDesc.Text = _Item.Description; string[] dimens = _Item.Dimension.Split('x'); BoxDimen1.Text = dimens[0]; BoxDimen2.Text = dimens[1]; BoxDimen3.Text = dimens[2]; BoxPrice.Text = _Item.Price.ToString(); BoxDiscnt.Text = _Item.Discount.ToString(); BoxQty.Text = _Item.Quantity.ToString(); BoxReordrLv.Text = _Item.ReorderLevel.ToString(); BoxShelf.Text = _Item.ShelfLocation.ToString(); BoxCtgy.Text = _Item.Category.ToString(); BoxSubCtgy.Text = _Item.SubCategory.ToString(); BoxPhoto.Text = _Item.Photo.AbsoluteUri; // add / update button BtnSubmit = new MetroButton(); BtnSubmit.AutoSize = true; BtnSubmit.Click += HandleSubmit; BtnSubmit.Text = Root.GetMsg("edit.btn-update"); BoxGroup.Controls.Add(BtnSubmit); BtnSubmit.Location = new Point((BoxPhoto.Left + BoxPhoto.Width) - BtnSubmit.Width, (BoxPhoto.Top + BoxPhoto.Height) + FieldPadding * 2); // align box group to middle SP.Controls.Add(BoxGroup); BoxGroup.Margin = new Padding((_This.ContentPanel.Width - SystemInformation.VerticalScrollBarWidth) / 2 - BoxGroup.Width / 2, 48, 0, 48); _This.ContentPanel.Controls.Add(SP); }
public SearchStoreFurnituresForm(Root root, IParentForm parent) : base(root, parent, Root.GetMsg("srch.title")) { BoxGroup = new Panel(); BoxGroup.AutoSize = true; ScrollPanel SP = new ScrollPanel(); SP.Size = new Size(_This.ContentPanel.Width, _This.ContentPanel.Height); SP.AutoScroll = true; // create textboxes input BoxID = InsertField(Root.GetMsg("edit.id"), Validation.IDField); BoxName = InsertField(Root.GetMsg("edit.name"), null); BoxPrice = InsertField(Root.GetMsg("edit.price"), Validation.SearchFloatField); BoxQty = InsertField(Root.GetMsg("edit.quantity"), Validation.SearchFloatField); BoxCtgy = InsertDropDown(Root.GetMsg("edit.category")); BoxCtgy.SelectedIndexChanged += (sender, e) => { int id = (int)((sender as ComboBox).SelectedItem as ComboItem).Value; BoxSubCtgy.Items.Clear(); BoxSubCtgy.Items.AddRange(XQL.GetSubcategoeiesForDropDown(id)); BoxSubCtgy.SelectedIndex = 0; }; BoxSubCtgy = InsertDropDown(Root.GetMsg("edit.subcategory")); BoxCtgy.Items.Clear(); BoxCtgy.Items.AddRange(XQL.GetCategoeiesForDropDown()); BoxCtgy.SelectedIndex = 0; BoxOrderBy = InsertDropDown(Root.GetMsg("srch.order-by")); string asc = Root.GetMsg("srch.asc"); string desc = Root.GetMsg("srch.desc"); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.id") + " " + asc, 0)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.id") + " " + desc, 1)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.name") + " " + asc, 2)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.name") + " " + desc, 3)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.price") + " " + asc, 4)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.price") + " " + desc, 5)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.quantity") + " " + asc, 6)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.quantity") + " " + desc, 7)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.sl") + " " + asc, 8)); BoxOrderBy.Items.Add(new ComboItem(Root.GetMsg("edit.sl") + " " + desc, 9)); BoxOrderBy.SelectedIndex = 0; // add / update button BtnSubmit = new MetroButton(); BtnSubmit.AutoSize = true; BtnSubmit.Click += HandleSubmit; BtnSubmit.Text = Root.GetMsg("srch.search"); BoxGroup.Controls.Add(BtnSubmit); BtnSubmit.Location = new Point((BoxOrderBy.Left + BoxOrderBy.Width) - BtnSubmit.Width, (BoxOrderBy.Top + BoxOrderBy.Height) + FieldPadding * 2); // reset button MetroButton BtnReset = new MetroButton(); BtnReset.AutoSize = true; BtnReset.Click += HandleReset; BtnReset.Text = Root.GetMsg("srch.reset"); BoxGroup.Controls.Add(BtnReset); BtnReset.Location = new Point(BtnSubmit.Left - BtnReset.Width - 32, BtnSubmit.Top); SP.Controls.Add(BoxGroup); BoxGroup.Margin = new Padding(_This.ContentPanel.Width / 2 - BoxGroup.Width / 2, _This.ContentPanel.Height / 2 - BoxGroup.Height / 2, 0, 0); _This.ContentPanel.Controls.Add(SP); }
public StoreFurnituresForm(Root root, MetroForm parent) : base(root, parent, Root.GetMsg("main.menu.store-furnitures")) { _This.InsertActionButtons(Root.GetMsg("stfu.action.reload"), Properties.Resources.reload, (sender, e) => { ReloadItems(); }); _This.InsertActionButtons(Root.GetMsg("stfu.action.search"), Properties.Resources.search, ActionSearch); _This.InsertActionButtons(Root.GetMsg("stfu.action.order-cart"), Properties.Resources.receipt, ActionOrder); _This.InsertActionButtons(Root.GetMsg("stfu.action.shopping-cart"), Properties.Resources.cart, ActionCheckout); // add furnitures ItemList.Size = _This.ContentPanel.Size; _This.ContentPanel.Controls.Add(ItemList); ReloadItems(); }
public GenerateSalesReportForm(Root root, MetroForm parent) : base(root, parent, Root.GetMsg("main.menu.sales-report")) { WebBrowser Preview = new WebBrowser(); _This.InsertActionButtons(Root.GetMsg("gsrp.print"), Properties.Resources.print, (sender, e) => { Printing.PrintPage(_Root, Preview.DocumentText); }); Preview.Size = new Size(_This.ContentPanel.Width, _This.ContentPanel.Height); Preview.DocumentText = GetReportContent(); _This.ContentPanel.Controls.Add(Preview); }
public SendReorderReportForm(Root root, MetroForm parent) : base(root, parent, Root.GetMsg("main.menu.reorder-report")) { _This.InsertActionButtons(Root.GetMsg("snrp.send"), Properties.Resources.send, (sender, e) => { if (!NilRecord) { XQL.UpdateQuantity(UpdateQtySql); MessageBox.Show(Root.GetMsg("snrp.reorder-report-sent"), Root.GetMsg("ui.info")); OnBack(); } else MessageBox.Show(Root.GetMsg("snrp.empty-reorder"), Root.GetMsg("ui.warn")); }); WebBrowser Preview = new WebBrowser(); Preview.Size = new Size(_This.ContentPanel.Width, _This.ContentPanel.Height); Preview.DocumentText = GetReportContent(); _This.ContentPanel.Controls.Add(Preview); }
public MainForm(Root p) : base(p, Root.GetMsg("main.title"), 540, 72) { _Root = p; // home icon web@2x this.SuspendLayout(); this.AutoSize = true; InsertMenu(Root.GetMsg("main.menu.store-furnitures"), Properties.Resources.menu_list, ViewFurnitures); if (Root.CurrentStaff.IsManager()) { InsertCategory(Root.GetMsg("main.category.management")); InsertMenu(Root.GetMsg("main.menu.delivery-report"), Properties.Resources.menu_send, SendDeliveryReport); InsertMenu(Root.GetMsg("main.menu.reorder-report"), Properties.Resources.menu_reorder, SendReorderReport); InsertMenu(Root.GetMsg("main.menu.sales-report"), Properties.Resources.menu_chart, GenerateSalesReport); InsertMenu(Root.GetMsg("main.menu.import-furnitures"), Properties.Resources.menu_import, ImportFurniture); } this.ResumeLayout(false); AnimateShowFormTrigger(); IsLaunched = true; }
public SendDeliveryReportForm(Root root, MetroForm parent) : base(root, parent, Root.GetMsg("main.menu.delivery-report")) { _This.InsertActionButtons(Root.GetMsg("snrp.send"), Properties.Resources.send, (sender, e) => { if (null != SelectedReport) { File.Delete(SelectedReport); Reset(); } else MessageBox.Show(Root.GetMsg("snrp.choose-report"), Root.GetMsg("ui.warn")); }); RecordList.Size = new Size(360, _This.ContentPanel.Height); _This.ContentPanel.Controls.Add(RecordList); Preview.Size = new Size(_This.ContentPanel.Width - 361, _This.ContentPanel.Height); Preview.Left = 361; _This.ContentPanel.Controls.Add(Preview); Reset(); }
public MetroForm(Root p, string name, int width, int height, EventHandler onBack = null) { _RRoot = p; _RThis = this; Flag_IsSecondary = null != onBack; this.SuspendLayout(); this.DoubleBuffered = true; this.FormBorderStyle = FormBorderStyle.None; this.Icon = Properties.Resources.logo; this.Size = new Size(width, height); this.BackColor = Color.FromArgb(34, 34, 34); this.ForeColor = Color.White; this.CenterToScreen(); this.Activated += OnFormResumed; this.FormClosed += OnFormClosed; this.DoubleBuffered = true; ContentPanel.Visible = false; // title Title = new Label(); Title.Anchor = AnchorStyles.Top | AnchorStyles.Left; Title.Font = new Font("Segoe UI Light", 20); Title.Text = name; this.Text = name; Title.AutoSize = true; if (Flag_IsSecondary) { MetroButton back = new MetroButton(border: 0); back.Size = new Size(32, 32); Title.Location = new Point(back.Width + 16 * 2, 16); back.BackgroundImage = Properties.Resources.form_back; back.BackgroundImageLayout = ImageLayout.Center; DarkToolTip tt = new DarkToolTip(); tt.SetToolTip(back, Root.GetMsg("ui.back")); back.Location = new Point(16, 16 + Title.Top - Title.Height / 2); back.Click += onBack; this.Controls.Add(back); } else Title.Location = new Point(16, 16); this.Controls.Add(Title); // close button InsertActionButtons(Root.GetMsg("ui.close"), Properties.Resources.form_close, (sender, e) => { AnimateHideForm(CloseFormAction); }); // minimize button InsertActionButtons(Root.GetMsg("ui.minimize"), Properties.Resources.form_minimize, (sender, e) => { AnimateHideForm(MinimizeFormAction); }); if (Root.CurrentStaff != null) { InsertCurrentUser(Root.CurrentStaff.Name); InsertActionButtons(Root.GetMsg("ui.logout"), Properties.Resources.logout, (sender, e) => { _Root.NotifyLoggedOut(); }); } // avoid overlap painted border ContentPanel.Anchor = AnchorStyles.Top | AnchorStyles.Left; ContentPanel.Left = 1; ContentPanel.Top = Title.Height + Title.Top * 2; ContentPanel.Size = new Size(width - 2, height - ContentPanel.Top - 1); this.Controls.Add(ContentPanel); // hide immediately prepare for animation // form next will call Activated => FormResumed this.Opacity = 0; this.CenterToScreen(); this.Top += 80; this.ResumeLayout(false); }
public FurnitureDetailsForm(Root root, IParentForm parent, Furniture item) : base(root, parent, item.Name) { _Item = item; if (Root.CurrentStaff.IsManager()) { _This.InsertActionButtons(Root.GetMsg("edit.title"), Properties.Resources.edit, EditDetails); _This.InsertActionButtons(Root.GetMsg("edit.delete-item"), Properties.Resources.delete, DeleteItem); } int borderSpacing = 12; Font fieldFont = new Font("Segoe UI Light", 15); // left side description pane Panel leftSide = new Panel(); leftSide.AutoSize = true; leftSide.Width = (int)(_This.ContentPanel.Width * .5); _This.ContentPanel.Controls.Add(leftSide); PictureBox pic = new PictureBox(); pic.Image = Properties.Resources.loader_medium; pic.ImageLocation = _Item.Photo.AbsoluteUri; pic.Size = new Size(200, 200); pic.Paint += (sender, e) => { ControlPaint.DrawBorder(e.Graphics, new Rectangle(0, 0, pic.Width, pic.Height), Color.FromArgb(64, 128, 128, 128), ButtonBorderStyle.Solid); }; pic.SizeMode = PictureBoxSizeMode.CenterImage; pic.LoadCompleted += (sender, e) => { pic.SizeMode = PictureBoxSizeMode.Zoom; }; leftSide.Controls.Add(pic); pic.Location = new Point(leftSide.Width / 2 - pic.Width / 2, borderSpacing * 2); // description Label desc = new Label(); desc.AutoSize = true; desc.MaximumSize = new Size(leftSide.Width, _This.ContentPanel.Height - _This.ContentPanel.Top - pic.Height - pic.Top * 2); desc.Font = fieldFont; desc.ForeColor = Color.FromArgb(204, 204, 204); desc.Padding = new Padding(borderSpacing * 2, borderSpacing * 4, borderSpacing * 2, borderSpacing * 2); desc.Text = _Item.Description; leftSide.Controls.Add(desc); desc.Location = new Point(leftSide.Width / 2 - desc.Width / 2, _This.ContentPanel.Top + pic.Height - pic.Top * 2); leftSide.Top = _This.ContentPanel.Height / 2 - leftSide.Height / 2; // right side details pane Panel rightSide = new Panel(); rightSide.Left = leftSide.Width; rightSide.Size = new Size(_This.ContentPanel.Width - rightSide.Left, _This.ContentPanel.Height); // textboxes for _Item k Label kes = new Label(); kes.TextAlign = ContentAlignment.MiddleRight; kes.Size = new Size((int)(rightSide.Width * .4) - borderSpacing, rightSide.Height); kes.Font = fieldFont; kes.Text = Root.GetMsg("edit.id") + "\n\n" + Root.GetMsg("edit.dimen") + "\n\n" + Root.GetMsg("edit.price") + "\n\n" + Root.GetMsg("edit.discount") + "\n\n" + Root.GetMsg("edit.quantity") + "\n\n" + Root.GetMsg("edit.rl") + "\n\n" + Root.GetMsg("edit.sl") + "\n\n" + Root.GetMsg("edit.category") + "\n\n" + Root.GetMsg("edit.subcategory") + "\n\n" + Root.GetMsg("edit.date"); rightSide.Controls.Add(kes); // textboxes for _Item v Label ves = new Label(); ves.TextAlign = ContentAlignment.MiddleLeft; ves.ForeColor = Color.FromArgb(204, 204, 204); ves.Font = fieldFont; ves.Size = new Size((int)(rightSide.Width * .6) - borderSpacing, rightSide.Height); ves.Text = _Item.ID + "\n\n" + _Item.Dimension.Replace("x", " × ") + "\n\n" + _Item.Price.ToString("C", CultureInfo.CreateSpecificCulture("zh-HK")) + "\n\n" + _Item.Discount + "%" + "\n\n" + _Item.Quantity + "\n\n" + _Item.ReorderLevel + "\n\n" + _Item.ShelfLocation + "\n\n" + _Item.Category + "\n\n" + (String.IsNullOrEmpty(_Item.SubCategory) ? Root.GetMsg("ui.not-set") : _Item.SubCategory) + "\n\n" + _Item.Date.ToString("yyyy-MM-dd HH:mm"); ves.Left = kes.Width + borderSpacing * 2; rightSide.Controls.Add(ves); _This.ContentPanel.Controls.Add(rightSide); }
public PaymentForm(Root root, IParentForm parent, bool isCheckout, bool payByCash, double total, bool delivery, string customer = null, string address = null, string phone = null) : base(root, parent, Root.GetMsg("cart.make-payment")) { FinalTotal = total; IsCheckout = isCheckout; PaymentMethodCash = payByCash; IsDelivery = delivery; CustomerName = customer; CustomerAddress = address; CustomerPhone = Int32.TryParse(phone, out CustomerPhone) ? CustomerPhone : -1; int panelpw = (int)(_This.ContentPanel.Width * (1 / 3.0)); Panel container = new Panel(); container.AutoSize = true; // amount Label hintAmount = new Label(); hintAmount.AutoSize = true; hintAmount.Text = delivery ? Root.GetMsg("cart.deposit") : Root.GetMsg("cart.total"); hintAmount.Font = new Font("Segoe UI Light", 13); hintAmount.ForeColor = Color.FromArgb(204, 204, 204); container.Controls.Add(hintAmount); hintAmount.Location = new Point(0, offsetY); bool canPay = false; if (delivery) { Label hintDeposit = new Label(); hintDeposit.AutoSize = true; hintDeposit.Text = "(" + (total * .2).ToString("C", CultureInfo.CreateSpecificCulture("zh-HK")) + " - " + total.ToString("C", CultureInfo.CreateSpecificCulture("zh-HK")) + ")"; hintDeposit.Font = new Font("Segoe UI Light", 12); hintDeposit.ForeColor = Color.FromArgb(255, 213, 77); container.Controls.Add(hintDeposit); hintDeposit.Location = new Point(hintAmount.Width, offsetY + hintAmount.Height / 2 - hintDeposit.Height / 2); } offsetY += hintAmount.Height + 12; Control amount; if (delivery) { amount = new MetroTextBox(panelpw, 32); amount.KeyPress += Validation.FloatField; amount.KeyUp += (sender, e) => { double deposit = double.TryParse(amount.Text, out deposit) ? deposit : 0.0; double minimum = total * .2; if (deposit >= minimum && deposit <= total) { canPay = true; /*if (PaymentMethodCash) _This.SelectNextControl((Control)sender, true, true, true, true); else */if (!PaymentMethodCash) CashIn.ForeColor = Color.White; } else { canPay = false; if (!BtnPaid.Disabled) BtnPaid.Disabled = true; if (!PaymentMethodCash) CashIn.ForeColor = Color.Gray; } }; } else { amount = new Label(); amount.AutoSize = true; amount.Text = total.ToString("C", CultureInfo.CreateSpecificCulture("zh-HK")); amount.Font = new Font("Segoe UI Light", 16); canPay = true; } container.Controls.Add(amount); amount.Location = new Point(0, offsetY); offsetY += amount.Height + 12; // cash in Label hintCashIn = new Label(); hintCashIn.AutoSize = true; hintCashIn.Text = Root.GetMsg("cart.cash-in"); hintCashIn.Font = new Font("Segoe UI Light", 13); hintCashIn.ForeColor = Color.FromArgb(204, 204, 204); container.Controls.Add(hintCashIn); hintCashIn.Location = new Point(0, offsetY); offsetY += hintCashIn.Height + 12; if (PaymentMethodCash) { Change.Text = 0.ToString("C", CultureInfo.CreateSpecificCulture("zh-HK")); MetroTextBox tbx = new MetroTextBox(panelpw, 32); tbx.KeyPress += Validation.FloatField; EventHandler eh = new EventHandler((sender, e) => { double paid = double.TryParse(tbx.Text, out paid) ? paid : 0.0; // <!> MUST be used only in Deposit scenario double deposit = double.TryParse(amount.Text, out deposit) ? deposit : 0.0; // </!> MUST be used only in Deposit scenario double ttl = delivery ? deposit : total; if (canPay) { Change.Text = (paid - ttl > 0 ? paid - ttl : 0).ToString("C", CultureInfo.CreateSpecificCulture("zh-HK")); FinalAmount = ttl; FinalCashIn = paid; BtnPaid.Disabled = paid < ttl; } }); tbx.GotFocus += eh; tbx.KeyUp += new KeyEventHandler(eh); container.Controls.Add(tbx); tbx.Location = new Point(0, offsetY); offsetY += tbx.Height + 12; } else { Change.Text = "N/A"; // icon PictureBox icon = new PictureBox(); icon.Size = new Size(24, 24); icon.Image = Properties.Resources.scan; container.Controls.Add(icon); icon.Location = new Point(0, offsetY); // status text CashIn = new Label(); CashIn.AutoSize = true; CashIn.Text = Root.GetMsg("cart.pay-by-card"); CashIn.Font = new Font("Segoe UI Light", 16); if (delivery) CashIn.ForeColor = Color.Gray; container.Controls.Add(CashIn); CashIn.Location = new Point(0 + icon.Width + 12, offsetY + (icon.Height / 2 - CashIn.Height / 2)); offsetY += icon.Height + 12; // emulate payment process int ticked = 0; bool paymentSucceed = false; Timer emulate = new Timer(); emulate.Interval = 500; emulate.Tick += (sender, e) => { if (paymentSucceed) { icon.Image = Properties.Resources.tick; CashIn.Text = Root.GetMsg("cart.payment-ok"); BtnPaid.Disabled = false; FinalAmount = !delivery ? total : double.TryParse(amount.Text, out FinalAmount) ? FinalAmount : 0.0; FinalCashIn = FinalAmount; emulate.Stop(); } else { if (ticked < 4) CashIn.Text = Root.GetMsg("cart.payment-card-phase-1"); else if (ticked < 8) CashIn.Text = Root.GetMsg("cart.payment-card-phase-2"); else if (ticked < 16) CashIn.Text = Root.GetMsg("cart.payment-card-phase-3"); else if (ticked < 24) CashIn.Text = Root.GetMsg("cart.payment-card-phase-4"); else paymentSucceed = true; ticked++; } }; EventHandler eh = null; eh = new EventHandler((sender, e) => { if (delivery && !canPay) return; emulate.Enabled = true; emulate.Start(); icon.Image = Properties.Resources.loader_small; icon.Click -= eh; icon.Cursor = Cursors.Default; CashIn.Click -= eh; CashIn.Cursor = Cursors.Default; }); icon.Click += eh; icon.Cursor = Cursors.Hand; CashIn.Click += eh; CashIn.Cursor = Cursors.Hand; } // changes Label hintChange = new Label(); hintChange.AutoSize = true; hintChange.Text = Root.GetMsg("cart.change"); hintChange.Font = new Font("Segoe UI Light", 13); hintChange.ForeColor = Color.FromArgb(204, 204, 204); container.Controls.Add(hintChange); hintChange.Location = new Point(0, offsetY); offsetY += hintChange.Height + 12; Change.AutoSize = true; Change.Font = new Font("Segoe UI Light", 16); container.Controls.Add(Change); Change.Location = new Point(0, offsetY); offsetY += Change.Height + 12; // offset for buttons offsetY += 32; // mark order paid BtnPaid.AutoSize = true; BtnPaid.Text = Root.GetMsg("cart.mark-and-return"); BtnPaid.Click += ActionPaymentCompleted; BtnPaid.Disabled = true; container.Controls.Add(BtnPaid); BtnPaid.Location = new Point(0, offsetY); offsetY += BtnPaid.Height + 12; // print invoice checkbox container.Controls.Add(PrintInvoice); PrintInvoice.Location = new Point(BtnPaid.Left + BtnPaid.Width + 32, BtnPaid.Top + BtnPaid.Height / 2 - PrintInvoice.Height / 2); Label hintPrintInvoice = new Label(); hintPrintInvoice.AutoSize = true; hintPrintInvoice.Text = Root.GetMsg("cart.print-invoice"); hintPrintInvoice.Font = new Font("Segoe UI Light", 12); hintPrintInvoice.ForeColor = Color.FromArgb(204, 204, 204); container.Controls.Add(hintPrintInvoice); hintPrintInvoice.Location = new Point(PrintInvoice.Left + PrintInvoice.Width + 8, BtnPaid.Top + BtnPaid.Height / 2 - hintPrintInvoice.Height / 2); _This.ContentPanel.Controls.Add(container); container.Location = new Point(_This.ContentPanel.Width / 2 - container.Width / 2, _This.ContentPanel.Height / 2 - container.Height / 2 - _This.ContentPanel.Top / 2); }
public LoginForm(Root p) : base(p, Root.GetMsg("login.title"), 540, 320) { _Root = p; // label - staff id LabelLogin = new Label(); LabelLogin.AutoSize = true; LabelLogin.Font = new Font("Segoe UI Light", 14); LabelLogin.AutoSize = true; int lblX = base.Title.Left * 3; int lblHeight = LabelLogin.Height; int panelAdjust = (base.Size.Height - base.ContentPanel.Height) / 2; int lblInFormMiddle = (base.ContentPanel.Height / 2 - lblHeight / 2) - panelAdjust; int yOffsetLogin = lblInFormMiddle - lblHeight - 8; LabelLogin.Location = new Point(lblX, yOffsetLogin); LabelLogin.Text = Root.GetMsg("login.staffid"); this.ContentPanel.Controls.Add(LabelLogin); // label - password LabelPassword = new Label(); LabelPassword.AutoSize = true; LabelPassword.Font = new Font("Segoe UI Light", 14); LabelPassword.AutoSize = true; int yOffsetPassword = lblInFormMiddle + lblHeight + 8; LabelPassword.Location = new Point(lblX, yOffsetPassword); LabelPassword.Text = Root.GetMsg("login.passwd"); this.ContentPanel.Controls.Add(LabelPassword); // textbox - staff id InputLogin = new MetroTextBox(256, 32); InputLogin.BackColor = Color.FromArgb(77, 77, 77); InputLogin.BorderStyle = BorderStyle.None; InputLogin.Font = new Font("Segoe UI Light", 16); InputLogin.ForeColor = Color.White; int txtX = base.Size.Width - lblX - InputLogin.Width; InputLogin.Location = new Point(txtX, yOffsetLogin - 8); InputLogin.TabStop = false; InputLogin.KeyDown += DetectHotKey; InputLogin.KeyPress += ValidateCharacters; this.ContentPanel.Controls.Add(InputLogin); // textbox - password InputPassword = new MetroTextBox(256, 32); InputPassword.BackColor = Color.FromArgb(77, 77, 77); InputPassword.BorderStyle = BorderStyle.None; InputPassword.Font = new Font("Segoe UI Light", 16); InputPassword.ForeColor = Color.White; InputPassword.Location = new Point(txtX, yOffsetPassword - 8); InputPassword.TabStop = false; InputPassword.KeyDown += DetectHotKey; InputPassword.KeyPress += ValidateCharacters; InputPassword.PasswordChar = '*'; this.ContentPanel.Controls.Add(InputPassword); InputLogin.Text = "1"; InputPassword.Text = "1234"; // button login ButtonLogin = new MetroButton(fontSize: 12); ButtonLogin.Text = Root.GetMsg("login.title"); ButtonLogin.AutoSize = true; ButtonLogin.Click += HandleLogin; ButtonLogin.TabStop = false; this.ContentPanel.Controls.Add(ButtonLogin); int btnX = base.Size.Width - lblX - ButtonLogin.Width; int btnY = base.Size.Height - base.ContentPanel.Top - base.Title.Top - ButtonLogin.Height + 1/* border size */; int minus = base.Size.Height - (base.ContentPanel.Top + yOffsetPassword + InputPassword.Height); btnY = (btnY - minus / 2) + ButtonLogin.Height - 1 * 2; ButtonLogin.Location = new Point(btnX, btnY); // lang chooser DropLang = new MetroComboBox(); DropLang.Size = new Size(128, ButtonLogin.Height); DropLang.ImeMode = System.Windows.Forms.ImeMode.Disable; this.ContentPanel.Controls.Add(DropLang); DropLang.Location = new Point(InputPassword.Left, btnY + 1 /* border */); // add langs DropLang.SelectedIndexChanged += (sender, e) => { int lang = (int)((sender as ComboBox).SelectedItem as ComboItem).Value; Root.SetLang(lang); UpdateFormLang(); }; DropLang.Items.Add(new ComboItem("English", 0xa)); DropLang.Items.Add(new ComboItem("繁體中文", 0xb)); DropLang.Items.Add(new ComboItem("简体中文", 0xc)); DropLang.SelectedIndex = 0; // add clock Label currTime = new Label(); currTime.AutoSize = true; currTime.Font = new Font("Segoe UI Light", 11); currTime.ForeColor = Color.FromArgb(204, 204, 204); currTime.Location = new Point(lblX, btnY + ButtonLogin.Height / 4); this.ContentPanel.Controls.Add(currTime); Timer tm = new Timer(); tm.Tick += (sender, e) => { currTime.Text = DateTime.Now.ToString("yyyy/M/d H:mm:ss"); }; tm.Start(); }