Example #1
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;
     }
 }
Example #2
0
 private void InsertCurrentUser(string name)
 {
     Label lbl = new Label();
     lbl.Anchor = AnchorStyles.Top | AnchorStyles.Right;
     lbl.MinimumSize = new Size(0, 28);
     lbl.AutoSize = true;
     lbl.Font = new Font("Segoe UI Light", 12);
     lbl.TextAlign = ContentAlignment.MiddleCenter;
     lbl.Text = name;
     DarkToolTip tt = new DarkToolTip();
     lbl.MouseHover += (sender, e) => {
         tt.SetToolTip(lbl, DateTime.Now.ToString("d/M/yyyy H:mm:ss"));
     };
     this.Controls.Add(lbl);
     lbl.Location = new Point(this.Width - lbl.Width - ActionButtonsOffsetNegX - 12, 12);
     ActionButtonsOffsetNegX += lbl.Width + 12;
 }
Example #3
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);
        }
Example #4
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;
        }