Beispiel #1
0
 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);
        }
Beispiel #3
0
 private void InsertMenu(string text, Bitmap icon, EventHandler handler)
 {
     MetroButton btn = new MetroButton(fontSize: 16);
     btn.BackColor = Color.FromArgb(45, 45, 45);
     btn.FlatAppearance.BorderSize = 0;
     btn.Image = icon;
     btn.ImageAlign = ContentAlignment.MiddleLeft;
     btn.TextAlign = ContentAlignment.MiddleRight;
     btn.Size = new Size(this.ContentPanel.Width - this.Title.Left * 2, MenuButtonHeight);
     btn.Left = this.Title.Left;
     btn.Click += handler;
     btn.Top = OffsetY;
     btn.Padding = new Padding(16, 0, 16, 0);
     btn.Text = text;
     this.ContentPanel.Controls.Add(btn);
     OffsetY += MenuButtonHeight + 12;
     this.ContentPanel.Height = OffsetY + 12;
 }
Beispiel #4
0
 // allow every class reload this form through this method
 public void ReloadItems(string whereClause = null, string orderBy = null)
 {
     List<Furniture> items = XQL.GetFurnitures(inStore: true, where: whereClause, order: orderBy);
     int scrollbarAdjust = items.Count * RowSize >= ItemList.Height ? SystemInformation.VerticalScrollBarWidth : 0;
     ItemList.Controls.Clear();
     if (items.Count < 1)
     {
         Label lbl = new Label();
         lbl.Font = new Font("Segoe UI Light", 24);
         lbl.ForeColor = Color.FromArgb(204, 204, 204);
         lbl.Text = Root.GetMsg("ui.no-result");
         lbl.AutoSize = true;
         ItemList.Controls.Add(lbl);
         lbl.Margin = new Padding(
             ItemList.Width / 2 - lbl.Width / 2,
             ItemList.Height / 2 - lbl.Height / 2,
             0, 0);
     }
     else for (int i = 0; i < items.Count; i++)
     {
         Furniture item = items[i];
         // create holder for item
         int alpha = (i % 2 == 0) ? 16 : 8;
         Panel row = new Panel();
         row.BackColor = Color.FromArgb(alpha, 255, 255, 255);
         row.Size = new Size(ItemList.Width, RowSize);
         row.Margin = Padding.Empty;
         row.Top = i * RowSize;
         // item photo
         PictureBox pic = new PictureBox();
         pic.Image = Properties.Resources.loader_small;
         pic.ImageLocation = item.Photo.AbsoluteUri;
         pic.Size = new Size(RowSize, RowSize);
         pic.SizeMode = PictureBoxSizeMode.CenterImage;
         pic.LoadCompleted += (sender, e) => {
             pic.SizeMode = PictureBoxSizeMode.Zoom;
         };
         row.Controls.Add(pic);
         // item category and name
         Label id = new Label();
         id.BackColor = Color.Transparent;
         id.AutoSize = true;
         id.MinimumSize = new Size(160, 0);
         id.Font = new Font("Segoe UI Light", 16);
         id.ForeColor = Color.FromArgb(204, 204, 204);
         id.Text = "[" + item.ID + "]";
         int middlePos = RowSize / 2 - id.Height / 2;
         id.Location = new Point(RowSize + RowMargin, middlePos - RowMargin);
         row.Controls.Add(id);
         Label name = new Label();
         name.BackColor = Color.Transparent;
         name.AutoSize = true;
         name.Text = item.Name;
         name.Font = new Font("Segoe UI Light", 16);
         name.Location = new Point(id.Width + id.Left, middlePos - RowMargin);
         row.Controls.Add(name);
         // item details
         Label cat = GetNextItemLabel(item.Category, id.Width - RowMargin);
         Label price = GetNextItemLabel(Util.CalcDiscountedPrice(item), 240, item.Discount > 0 ? Color.FromArgb(255, 213, 77) : (Color?)null);
         Label qty = GetNextItemLabel(Root.GetMsg("stfu.qty") + ": " + item.Quantity, 100);
         Label shelf = GetNextItemLabel(Root.GetMsg("stfu.shelf") + ": " + item.ShelfLocation, 120);
         Label date = GetNextItemLabel(Root.GetMsg("stfu.date") + ": " + item.Date.ToString("d/M/yyyy"), 120);
         DarkToolTip tt = new DarkToolTip();
         tt.SetToolTip(cat, String.IsNullOrEmpty(item.SubCategory) ? Root.GetMsg("ui.not-set") : item.SubCategory);
         // notify out of stock
         if (item.Quantity < 1)
         {
             qty.Text = Root.GetMsg("stfu.qty") + ": " + item.InventoryQuantity;
             if (item.InventoryQuantity < 1) qty.ForeColor = Color.FromArgb(204, 77, 77);
             else qty.ForeColor = Color.FromArgb(204, 128, 34);
         }
         else if (item.Quantity <= item.ReorderLevel) qty.ForeColor = Color.FromArgb(205, 220, 57);
         else qty.ForeColor = Color.FromArgb(77, 160, 45);
         row.Controls.Add(cat);
         row.Controls.Add(price);
         row.Controls.Add(qty);
         row.Controls.Add(shelf);
         row.Controls.Add(date);
         // view details button
         MetroButton btnDetails = new MetroButton(border: 0);
         btnDetails.BackColor = Color.FromArgb(77, 77, 77);
         btnDetails.Size = new Size((int)(RowSize * 0.75), RowSize - 2);
         btnDetails.Click += (sender, e) => ActionViewDetails(sender, e, item);
         btnDetails.Location = new Point(ItemList.Width - btnDetails.Width - scrollbarAdjust, 1);
         btnDetails.BackgroundImage = Properties.Resources.arrow_right;
         btnDetails.BackgroundImageLayout = ImageLayout.Center;
         row.Controls.Add(btnDetails);
         // if not out of stock, add cart actions
         if (item.Quantity > 0)
         {
             CartActionPanel cartActions = new CartActionPanel(this, RowSize, item, false);
             cartActions.Location = new Point(ItemList.Width - btnDetails.Width - cartActions.Width - scrollbarAdjust, 1);
             row.Controls.Add(cartActions);
         }
         else
         {
             if (_Root.OrderCart.ContainsKey(item.ID) && _Root.OrderCart[item.ID] > 0)
             {
                 CartActionPanel cartActions = new CartActionPanel(this, RowSize, item, true);
                 cartActions.Location = new Point(ItemList.Width - btnDetails.Width - cartActions.Width - scrollbarAdjust, 1);
                 row.Controls.Add(cartActions);
             }
             else
             {
                 MetroButton btnOrder = new MetroButton(border: 0);
                 btnOrder.Size = new Size((int)(RowSize * 1.25), RowSize - 2);
                 if (item.InventoryQuantity > 0)
                 {
                     btnOrder.BackColor = Color.FromArgb(204, 128, 34);
                     btnOrder.BackgroundImage = Properties.Resources.receipt;
                     btnOrder.BackgroundImageLayout = ImageLayout.Center;
                     btnOrder.Click += (sender, e) =>
                     {
                         DialogResult order = MessageBox.Show(Root.GetMsg("stfu.continue-order"), Root.GetMsg("ui.info"), MessageBoxButtons.YesNo);
                         if (order == DialogResult.Yes)
                         {
                             //ActionAddInventoryDeliveryOrder(sender, e, item);
                             row.Controls.Remove(btnOrder);
                             CartActionPanel cartActions = new CartActionPanel(this, RowSize, item, true);
                             cartActions.Location = new Point(ItemList.Width - btnDetails.Width - cartActions.Width - scrollbarAdjust, 1);
                             row.Controls.Add(cartActions);
                         }
                     };
                 }
                 else
                 {
                     btnOrder.BackColor = Color.FromArgb(45, 128, 128, 128);
                     btnOrder.FlatAppearance.MouseOverBackColor = btnOrder.BackColor;
                     btnOrder.FlatAppearance.MouseDownBackColor = Color.FromArgb(61, 128, 128, 128);
                     btnOrder.Paint += (sender, e) =>
                     {
                         Image im = Properties.Resources.receipt;
                         ColorMatrix matrix = new ColorMatrix();
                         matrix.Matrix33 = .5f;
                         ImageAttributes attributes = new ImageAttributes();
                         attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
                         e.Graphics.DrawImage(im, new Rectangle(btnOrder.Width / 2 - im.Width / 2, btnOrder.Height / 2 - im.Height / 2, im.Width, im.Height), 0, 0, im.Width, im.Height, GraphicsUnit.Pixel, attributes);
                     };
                     btnOrder.Click += (sender, e) =>
                     {
                         MessageBox.Show(Root.GetMsg("stfu.out-of-stock"), Root.GetMsg("ui.warn"));
                     };
                 }
                 btnOrder.Location = new Point(ItemList.Width - btnDetails.Width - btnOrder.Width - scrollbarAdjust, 1);
                 row.Controls.Add(btnOrder);
             }
         }
         ItemList.Controls.Add(row);
         OffsetCounter = 0;
     }
 }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        // mat. icon: 1x web, 18dp (sys btn)
        // mat. icon: 1x web, 24dp (act btn)

        public void InsertActionButtons(string desc, Bitmap icon, EventHandler handler)
        {
            MetroButton btn = new MetroButton(border: 0);
            btn.Size = new Size(28, 28);
            btn.BackgroundImage = icon;
            btn.BackgroundImageLayout = ImageLayout.Center;
            btn.Click += handler;
            DarkToolTip tt = new DarkToolTip();
            tt.SetToolTip(btn, desc);
            this.Controls.Add(btn);
            btn.Location = new Point(this.Width - btn.Width - ActionButtonsOffsetNegX - 12, 12);
            ActionButtonsOffsetNegX += btn.Width + 12;
        }
Beispiel #7
0
 private void InsertButton(string text, EventHandler handler)
 {
     MetroButton btn = new MetroButton();
     btn.AutoSize = true;
     btn.Click += handler;
     btn.MouseEnter += (sender, e) => { btn.BackColor = Color.FromArgb(128, 45, 45, 45); };
     btn.MouseDown += (sender, e) => { btn.BackColor = Color.FromArgb(128, 34, 34, 34); };
     btn.MouseLeave += (sender, e) => { btn.BackColor = Color.Transparent; };
     btn.Text = text;
     if (PaneAllFieldSize.IsEmpty)
         PaneAllFieldSize = DetailInputPane.Size;
     DetailInputPane.Controls.Add(btn);
     btn.Location = new Point(PaneAllFieldSize.Width - btn.Width - ButtonOffsetX - 3, PaneAllFieldSize.Height + 48);
     ButtonOffsetX = btn.Width + 48;
 }
Beispiel #8
0
 private MetroButton CreateControl(string text, Color btnColor, EventHandler handler)
 {
     MetroButton btn = new MetroButton();
     btn.ForeColor = btnColor;
     btn.Text = text;
     btn.Click += handler;
     return btn;
 }
Beispiel #9
0
 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();
 }