private void menuExpandPanel_Click(object sender, EventArgs e)
        {
            Panel   menuPanel;
            Control ctrl;

            ctrl      = (Control)sender;
            menuPanel = (Panel)ctrl.Parent;
            string menuKey    = menuPanel.Name.Substring(0, menuPanel.Name.IndexOf("-"));
            int    submenuPos = Conversions.ToInteger(menuPanel.Name.Substring(menuPanel.Name.IndexOf("-") + 1));

            if (enVars.layoutDesign.menu.items.ElementAt(submenuPos).subMenuIndex.Equals(0))
            {
                enVars.layoutDesign.menu.items.ElementAt(submenuPos).isOpen = !enVars.layoutDesign.menu.items.ElementAt(submenuPos).isOpen;
                MenuUpdate(true);
                return;
            }

            // TODO
            bool menuState = true;

            if (enVars.layoutDesign.menu.items.ElementAt(0).menuWrapperPanel.Width.Equals(enVars.layoutDesign.MENU_OPEN_STATE))
            {
                menuState = false;
            }

            menuExpandPanelClick?.Invoke(sender, e);
        }
        public MenuBuilderClass(Form _mainform, PanelDoubleBuffer _menuPanel, environmentVarsCore _envars, int _menuOrientation, ref environmentVarsCore.updateMainLayoutDelegate _updateMainApp)
        {
            resources       = new ResourceManager(GetType().Namespace + ".config.strings", Assembly.GetExecutingAssembly());
            updateMainApp   = _updateMainApp;
            mainForm        = _mainform;
            enVars          = _envars;
            menuOrientation = _menuOrientation;
            menuPanel       = _menuPanel;
            if (enVars.layoutDesign.fontTitle.Families.Count() < 1)
            {
                Interaction.MsgBox("Font files not loaded properly:" + ToString());
                return;
            }

            var fontToMeasure = new Font(enVars.layoutDesign.fontTitle.Families[0], enVars.layoutDesign.subMenuTitleFontSize, FontStyle.Regular);
            var g             = mainForm.CreateGraphics();

            sizeOfString = g.MeasureString("PQWER", fontToMeasure);
            previousPanelTimer.Interval = 300;
            previousPanelTimer.Tick    += (_, __) => delayActiveBar();
        }
Exemple #3
0
 private void openChildForm(PanelDoubleBuffer targetPanel, Form childForm)
 {
     SuspendLayout();
     if (currentForm is object)
     {
         currentForm.Close();
     }
     currentForm               = childForm;
     childForm.TopLevel        = false;
     childForm.FormBorderStyle = FormBorderStyle.None;
     childForm.Dock            = DockStyle.Fill;
     childForm.Parent          = targetPanel;
     childForm.Width           = targetPanel.Width;
     targetPanel.Height        = childForm.Height;
     targetPanel.Controls.Add(childForm);
     targetPanel.Tag = childForm;
     childForm.BringToFront();
     childForm.BackgroundImage       = imageManipulationLib.cropImage(this.BackgroundImage, targetPanel.Location, targetPanel.Size, this.Size);
     childForm.BackgroundImageLayout = ImageLayout.Stretch;
     childForm.Show();
     ResumeLayout();
 }
        private void buildMenuOption(menuItemClass menuItem, int placeIndex, int firstmenuItemListIndex, int menuItemsCount)
        {
            int titlePosY         = 0;
            int menuPosX          = enVars.layoutDesign.menu.properties.ClosedStateSize;
            int iconSize          = Convert.ToInt16(enVars.layoutDesign.menu.properties.ClosedStateSize * 0.7);
            var subMenuExpandIcon = new IconPictureBox();
            var subMenuIcon       = new PictureBox();

            menuItem.iconPicHolder = new List <PictureBox>();
            PanelDoubleBuffer activeBar;
            var index        = enVars.layoutDesign.menu.items.FindIndex(c => c.menuUID.Equals(menuItem.menuUID));
            var subMenuPanel = new PanelDoubleBuffer()
            {
                Width     = enVars.layoutDesign.menu.properties.width,
                Height    = enVars.layoutDesign.menu.properties.height,
                BackColor = enVars.layoutDesign.menu.properties.backColor,
                Parent    = setup.menuPanel,
                Name      = menuItem.menuUID + "-" + index,
                Location  = new Point(0, enVars.layoutDesign.menu.properties.height * placeIndex)
            };

            subMenuPanel.Click += menuPanel_Click;
            if (placeIndex.Equals(0))
            {
                subMenuIcon = new PictureBox()
                {
                    Width    = iconSize,
                    Height   = iconSize,
                    Location = new Point((enVars.layoutDesign.menu.properties.height - iconSize) / 2, (enVars.layoutDesign.menu.properties.height - iconSize) / 2),
                    Parent   = subMenuPanel,
                    Cursor   = Cursors.Hand
                };
                if (menuItem.menuTitle.Equals("username"))
                {
                    if (enVars.userPhoto.Equals(""))
                    {
                        subMenuIcon.Image = Image.FromFile(enVars.imagesPath + "worker.icon.png");
                    }
                    else
                    {
                        subMenuIcon.InitialImage = Image.FromFile(enVars.imagesPath + Convert.ToString("loading.png"));
                        subMenuIcon.SizeMode     = PictureBoxSizeMode.StretchImage;
                        var tClient = new WebClient();
                        try
                        {
                            // TODO where to save the files
                            Bitmap tImage = (Bitmap)Image.FromStream(new MemoryStream(tClient.DownloadData(enVars.ServerBaseAddr + "/csl/photos/" + enVars.userPhoto)));
                            subMenuIcon.Image = tImage;
                        }
                        catch (Exception ex)
                        {
                            System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(enVars.currentLang);
                            subMenuIcon.Image = Image.FromFile(enVars.imagesPath + Convert.ToString("worker.icon.png"));
                            updateStausMessage?.Invoke(this, resources.GetString("errorDownloadingPhoto"));
                        }
                    }
                }
                else if (!menuItem.icon.Equals(""))
                {
                    var checkFile = new FileInfo(enVars.imagesPath + menuItem.icon);
                    checkFile.Refresh();
                    if (checkFile.Exists)
                    {
                        subMenuIcon.Image = Image.FromFile(enVars.imagesPath + menuItem.icon);
                    }
                }

                subMenuIcon.SizeMode = PictureBoxSizeMode.StretchImage;
                subMenuIcon.Click   += menuPanel_Click;
                subMenuPanel.Controls.Add(subMenuIcon);

                //expand icon
                subMenuExpandIcon = new IconPictureBox()
                {
                    IconColor = enVars.layoutDesign.labelForeColor,
                    BackColor = Color.Transparent,
                    Cursor    = Cursors.Hand,
                    IconChar  = IconChar.ArrowDown,
                    IconSize  = iconSize,
                    Location  = new Point(enVars.layoutDesign.menu.properties.width - enVars.layoutDesign.menu.properties.height, Convert.ToInt16(enVars.layoutDesign.menu.properties.height / 2 - iconSize / 2)),
                    Name      = menuItem.menuUID + "_expandIcon-" + index,
                    Size      = new Size(enVars.layoutDesign.menu.properties.height - 6, enVars.layoutDesign.menu.properties.height - 6),
                    Parent    = subMenuPanel
                };

                // TODO add tooltips
                subMenuExpandIcon.Click += menuExpandPanel_Click;
                subMenuPanel.Controls.Add(subMenuExpandIcon);
            }

            // MENU ITEM ACTIVE BAR  =====================================================================================================================
            // TODO: ????
            if (placeIndex.Equals(0))
            {
                menuPosX = enVars.layoutDesign.menu.properties.height;
            }
            else
            {
                menuPosX = enVars.layoutDesign.menu.properties.activeBarWidth + 5;
            }

            if (placeIndex > 0)
            {
                activeBar = new PanelDoubleBuffer()
                {
                    Width     = enVars.layoutDesign.menu.properties.activeBarWidth,
                    Height    = subMenuPanel.Height - 1,
                    BackColor = Color.Transparent,
                    Location  = new Point(0, 0),
                    Parent    = subMenuPanel,
                    Name      = menuItem.menuUID + "_activeBar-" + index
                };
                subMenuPanel.Controls.Add(activeBar);
            }
            else
            {
                activeBar = default;
            }

            // MENU ITEM NOTIFICATION  =====================================================================================================================
            var notif = new LabelDoubleBuffer()
            {
                Location  = new Point(subMenuPanel.Width - enVars.layoutDesign.menu.properties.ClosedStateSize, 5),
                Font      = new Font(enVars.layoutDesign.fontTitle.Families[0], enVars.layoutDesign.subMenuTitleFontSize, FontStyle.Regular),
                Text      = "",
                Parent    = subMenuPanel,
                ForeColor = Color.Orange,
                BackColor = Color.Transparent,
                Cursor    = Cursors.Hand,
                Name      = menuItem.menuUID + "_notificationIcon-" + index
            };

            if (menuItem.notifications > 0)
            {
                if (menuItem.notifications < 10)
                {
                    notif.Text = "0" + menuItem.notifications.ToString();
                }
                else
                {
                    notif.Text = menuItem.notifications.ToString();
                }
            }

            notif.Click += menuNotification_Click;
            subMenuPanel.Controls.Add(notif);

            // MENU ITEM TITLE TEXT =====================================================================================================================
            if (menuItem.menuTitle.Equals("username"))
            {
                var subtitle = new LabelDoubleBuffer()
                {
                    Font      = new Font(enVars.layoutDesign.fontTitle.Families[0], enVars.layoutDesign.subMenuTitleFontSize, FontStyle.Regular),
                    Location  = new Point(menuPosX, 26),
                    Text      = enVars.customization.businessname,
                    Parent    = setup.menuPanel,
                    ForeColor = Color.White,
                    BackColor = Color.Transparent,
                    Width     = enVars.layoutDesign.menu.properties.width,
                    Cursor    = Cursors.Hand
                };
                subtitle.Click += menuPanel_Click;
                setup.menuPanel.Controls.Add(subtitle);
                titlePosY = 5;
            }
            else if (placeIndex.Equals(0))
            {
                titlePosY = Convert.ToInt16((setup.menuPanel.Height - sizeOfString.Height) / 2);
            }
            else
            {
                titlePosY = Convert.ToInt16((setup.menuPanel.Height - sizeOfString.Height) / 2);
            }

            var title = new LabelDoubleBuffer()
            {
                Font      = new Font(enVars.layoutDesign.fontTitle.Families[0], enVars.layoutDesign.menuTitleFontSize, FontStyle.Regular),
                Location  = new Point(menuPosX, titlePosY),
                Text      = menuItem.menuTitle.Equals("username") ? enVars.username.Equals("") ? "user" : enVars.username : menuItem.menuTitle,
                Parent    = setup.menuPanel,
                ForeColor = Color.White,
                BackColor = Color.Transparent,
                Width     = enVars.layoutDesign.menu.properties.width,
                Cursor    = Cursors.Hand,
                Name      = menuItem.menuUID + "_title-" + index
            };

            title.Click += menuPanel_Click;
            subMenuPanel.Controls.Add(title);
            setup.menuPanel.Controls.Add(subMenuPanel);
            enVars.layoutDesign.menu.items[index].menuListIndex      = firstmenuItemListIndex;
            enVars.layoutDesign.menu.items[index].menuItemPanel      = subMenuPanel;
            enVars.layoutDesign.menu.items[index].menuActiveBarPanel = activeBar;
            enVars.layoutDesign.menu.items[index].iconPicHolder      = new List <PictureBox>();
            enVars.layoutDesign.menu.items[index].iconPicHolder.Add(subMenuIcon);
            enVars.layoutDesign.menu.items[index].iconPicHolderFontAwesome[1] = subMenuExpandIcon;
        }
Exemple #5
0
 private void updateBkImageOnChildForms(Control ctrlContainer, bool isOnChildren, PanelDoubleBuffer panelHost)
 {
     foreach (Control ctrl in ctrlContainer.Controls)
     {
         string t   = ctrl.Name;
         var    typ = ctrl.GetType();
         if (ctrl is PanelDoubleBuffer)
         {
             if (ctrl.HasChildren)
             {
                 updateBkImageOnChildForms(ctrl, true, (PanelDoubleBuffer)ctrl);
             }
         }
         else if ((ctrl is FormCustomized | ctrl is Form) & isOnChildren)
         {
             ctrl.BackgroundImage       = imageManipulationLib.cropImage(this.BackgroundImage, panelHost.Location, panelHost.Size, this.Size);
             ctrl.BackgroundImageLayout = ImageLayout.Stretch;
         }
     }
 }