Ejemplo n.º 1
0
 private void InsertCategorySelector()
 {
     int comboBoxHeight = 32;
     Panel top = new Panel();
     top.Size = new Size(_This.ContentPanel.Width, TopSelectorBarSize);
     _This.ContentPanel.Controls.Add(top);
     // category selector
     MetroComboBox selCategory = new MetroComboBox();
     selCategory.Size = new Size((_This.ContentPanel.Width / 2) - 16 - 16 / 2, comboBoxHeight);
     top.Controls.Add(selCategory);
     selCategory.Location = new Point(16, top.Height / 2 - comboBoxHeight / 2);
     // sub-category selector
     MetroComboBox selSubCategory = new MetroComboBox();
     selSubCategory.Size = new Size((_This.ContentPanel.Width / 2) - 16 - 16 / 2, comboBoxHeight);
     top.Controls.Add(selSubCategory);
     selSubCategory.Location = new Point(16 + selCategory.Width + 16, top.Height / 2 - comboBoxHeight / 2);
     // set items
     selCategory.SelectedIndexChanged += (sender, e) =>
     {
         int id = (int)((sender as ComboBox).SelectedItem as ComboItem).Value;
         selSubCategory.Items.Clear();
         selSubCategory.Items.AddRange(XQL.GetSubcategoeiesForDropDown(id, Root.GetMsg("imfu.any-subcategory")));
         selSubCategory.SelectedIndex = 0;
         if (id > 0)
             QueryCat = "[Furnitures].[_CID] = " + id;
         else
             QueryCat = null;
         QuerySubCat = null;
         UpdateList();
     };
     selCategory.Items.Clear();
     selCategory.Items.AddRange(XQL.GetCategoeiesForDropDown(Root.GetMsg("imfu.any-category")));
     selCategory.SelectedIndex = 0;
     selSubCategory.SelectedIndexChanged += (sender, e) =>
     {
         int id = (int)((sender as ComboBox).SelectedItem as ComboItem).Value;
         if (id > 0)
             QuerySubCat = " and [Furnitures].[_SCID] = " + id;
         else
             QuerySubCat = null;
         UpdateList();
     };
 }
Ejemplo n.º 2
0
 private ComboBox InsertDropDown(string name)
 {
     Label lbl = new Label();
     lbl.ForeColor = Color.White;
     lbl.Font = new Font("Segoe UI Light", 14);
     lbl.Location = new Point(0, FieldOffsetY);
     lbl.Text = name;
     lbl.Size = new Size((int)(_This.Width * .2), FieldHeight);
     BoxGroup.Controls.Add(lbl);
     // Input
     MetroComboBox cmbx = new MetroComboBox();
     cmbx.Location = new Point(lbl.Left + lbl.Width + FieldPadding, FieldOffsetY);
     cmbx.ImeMode = System.Windows.Forms.ImeMode.Disable;
     FieldOffsetY += FieldHeight + FieldPadding;
     int tbxW = (int)(_This.Width * .4);
     cmbx.Size = new Size(tbxW, FieldHeight);
     BoxGroup.Controls.Add(cmbx);
     return cmbx;
 }
Ejemplo n.º 3
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();
 }