コード例 #1
0
        /// <summary>
        /// Rellena los valores del menu
        /// </summary>
        public void Populate()
        {
            this.txtDisplayName.Text = _MenuItemSelected.DisplayName;
            this.txtAssembly.Text    = _MenuItemSelected.AssemblyInfo;

            this.txtToolTipInfo.Text       = _MenuItemSelected.ToolTipInfo;
            this.checkBoxEnabled.Checked   = _MenuItemSelected.Enabled;
            this.btnAuthorizationRule.Text = _MenuItemSelected.AuthorizationRuleName;
            this.txtTag.Text = _MenuItemSelected.Tag;

            if (_MenuItemSelected.ParentID.Equals(0))
            {
                this.txtCategory.Text = "Is root node";
            }
            else
            {
                this.txtCategory.Text = FRM_MainDevExpress.Menu.ItemList.Get(_MenuItemSelected.ParentID).DisplayName;
            }

            MenuImage m = FRM_MainDevExpress.Menu.ImageList.Get(_MenuItemSelected.ImageIndex);

            if (m != null)
            {
                m_Image_index         = m.Index;
                pictureBoxImage.Image = m.Image;
            }
            m = FRM_MainDevExpress.Menu.ImageList.Get(_MenuItemSelected.SelectedImageIndex);
            if (m != null)
            {
                m_Image_Sel_index             = m.Index;
                pictureBoxImageSelected.Image = m.Image;
            }

            SetShowAction();
        }
コード例 #2
0
    void PlayerIsAgree(MenuImage spell)
    {
        if (spell == m_InvincibleImage)
        {
            if (InvincibleSpellSelected != null)
            {
                InvincibleSpellSelected();
            }
        }
        else if (spell == m_ConfusionImage)
        {
            if (ConfusionSpellSelected != null)
            {
                ConfusionSpellSelected();
            }
        }
        else if (spell == m_HealImage)
        {
            if (HealSpellSelected != null)
            {
                HealSpellSelected();
            }
        }
        else if (spell == m_EnergyImage)
        {
            if (EnergySpellSelected != null)
            {
                EnergySpellSelected();
            }
        }

        ServiceLocator.Instance.GetService <PlayerManager>(ManagerType.PLAYER_MANAGER).ReportFusionActionComplete();
    }
コード例 #3
0
        private void ViewLoop(object obj, EventArgs args)
        {
            var nextBitmap = controller.GetNextBitmap(GameMapPictureBox.Size);

            if (nextBitmap != null)
            {
                GameMapPictureBox.Image = nextBitmap;
                ScoresLabel.Text        = controller.GetScores();
            }
            else
            {
                timer.Stop();
                if (controller.GetGameResult())
                {
                    GameResultLabel.Text = "Ты победил!";
                }
                else
                {
                    GameResultLabel.Text = "Ты проиграл!";
                }
                GameResultLabel.Visible = true;
                StartButton.Enabled     = true;
                controller.Initial();
                GameMapPictureBox.Image = controller.GetNextBitmap(GameMapPictureBox.Size);
                ScoresLabel.Text        = controller.GetScores();
                MenuImage.Show();
                StartButton.Show();
                StartButton.Select();
            }
        }
コード例 #4
0
    private void Start()
    {
        m_PlayerOneSelectedImage = m_MenuImage[0];
        m_PlayerTwoSelectedImage = m_MenuImage[0];

        StartCoroutine(PlayerOneIndexChanged(0));
        StartCoroutine(PlayerTwoIndexChanged(0));
    }
コード例 #5
0
 private void gridView1_Click(object sender, EventArgs e)
 {
     SelectedImage = ((MenuImage)gridControl1.FocusedView.GetRow(gridView1.FocusedRowHandle));
     if (SelectedImage != null)
     {
         pictureBoxImageSelected.Image = SelectedImage.Image;
     }
 }
コード例 #6
0
        private void StartGame_Click(object sender, EventArgs e)
        {
            GameResultLabel.Visible = false;
            StartButton.Enabled     = false;
            MenuImage.Hide();
            StartButton.Hide();

            timer.Start();
        }
コード例 #7
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();//Draw inspector UI of ImageEditor

        MenuImage image = (MenuImage)target;

        image.selectID  = EditorGUILayout.IntField("selectID", image.selectID);
        image.playerOne = EditorGUILayout.ObjectField("player one", image.playerOne, typeof(GameObject), true) as GameObject;
        image.playerTwo = EditorGUILayout.ObjectField("player two", image.playerTwo, typeof(GameObject), true) as GameObject;
    }
コード例 #8
0
    private void PlayerTwoSelectChange(MenuImage image)
    {
        ServiceLocator.Instance.GetService <SoundManager>(ManagerType.SOUND_MANAGER).PlaySong("event:/SFX/UI/UI_Choose", 3);
        m_PlayerTwoSelectedImage.playerTwo.SetActive(false);

        m_PlayerTwoSelectedID    = image.selectID;
        m_PlayerTwoSelectedImage = image;

        image.playerTwo.SetActive(true);
    }
コード例 #9
0
    private void PlayerTwoSelectChange(MenuImage image)
    {
        m_SoundManager.PlaySong("event:/SFX/UI/UI_Choose", 3);
        m_PlayerTwoSelectedImage.playerTwo.SetActive(false);

        m_PlayerTwoSelectedID    = image.selectID;
        m_PlayerTwoSelectedImage = image;

        image.playerTwo.SetActive(true);
    }
コード例 #10
0
    void PlayerTwoSelect(MenuImage spell)
    {
        if (m_CurrentButtonPlayerOne == spell)
        {
            PlayerIsAgree(spell);
        }
        else if (m_CurrentButtonPlayerTwo)
        {
            m_CurrentButtonPlayerTwo.playerTwo.SetActive(false);
        }

        m_CurrentButtonPlayerTwo = spell;
        m_CurrentButtonPlayerTwo.playerTwo.SetActive(true);
    }
コード例 #11
0
        void ReleaseDesignerOutlets()
        {
            if (MenuImage != null)
            {
                MenuImage.Dispose();
                MenuImage = null;
            }

            if (MenuText != null)
            {
                MenuText.Dispose();
                MenuText = null;
            }
        }
コード例 #12
0
        public void PopulateImage()
        {
            int i = 0;

            Menu.ImageList = new MenuImageList();
            MenuImage menuImage = null;

            foreach (Image img in imageList2.Images)
            {
                menuImage            = new MenuImage();
                menuImage.Index      = i;
                menuImage.ImageBytes = Fwk.HelperFunctions.TypeFunctions.ConvertImageToByteArray(img, System.Drawing.Imaging.ImageFormat.Png);
                i++;
                Menu.ImageList.Add(menuImage);
            }
        }
コード例 #13
0
ファイル: frmImageSelector.cs プロジェクト: gpanayir/sffwk
        void addPicture(string imgFile)
        {
          
            m_PictureBoxImageOnPanel = new PictureBox();
            m_PictureBoxImageOnPanel.Click += new EventHandler(pictureBoxImage_Click);

            m_PictureBoxImageOnPanel.Image = new Bitmap(imgFile);

            flowLayoutPanel1.Controls.Add(m_PictureBoxImageOnPanel);

            MenuImage wMenuImage = new MenuImage();
            wMenuImage.Index = _MenuImageList.Count + 1;
            wMenuImage.Image = Helper.LoadImage(m_PictureBoxImageOnPanel.Image, m_Image_Extension);
            _MenuImageList.Add(wMenuImage);


        }
コード例 #14
0
    void OnEnable()
    {
        m_CurrentButtonPlayerOne = null;
        m_CurrentButtonPlayerTwo = null;

        m_P1FusionHold = true;
        m_P2FusionHold = true;

        m_InvincibleImage.playerOne.SetActive(false);
        m_InvincibleImage.playerTwo.SetActive(false);

        m_ConfusionImage.playerOne.SetActive(false);
        m_ConfusionImage.playerTwo.SetActive(false);

        m_HealImage.playerOne.SetActive(false);
        m_HealImage.playerTwo.SetActive(false);

        m_EnergyImage.playerOne.SetActive(false);
        m_EnergyImage.playerTwo.SetActive(false);
    }
コード例 #15
0
        void ReleaseDesignerOutlets()
        {
            if (MenuTableView != null)
            {
                MenuTableView.Dispose();
                MenuTableView = null;
            }

            if (MenuName != null)
            {
                MenuName.Dispose();
                MenuName = null;
            }

            if (MenuImage != null)
            {
                MenuImage.Dispose();
                MenuImage = null;
            }
        }
コード例 #16
0
    private void Start()
    {
        m_Animator = GetComponent <Animator>();

        m_SoundManager = ServiceLocator.Instance.GetService <SoundManager>(ManagerType.SOUND_MANAGER);
        m_GUIManager   = ServiceLocator.Instance.GetService <GUIManager>(ManagerType.GUI_MANAGER);

        m_PageCredits = transform.Find("Pages/Credits").gameObject;

        if (m_GUIManager.CreditsRequested)
        {
            InitCredits();
        }

        m_PlayerOneSelectedImage = m_MenuImage[0];
        m_PlayerTwoSelectedImage = m_MenuImage[0];

        StartCoroutine(PlayerOneIndexChanged(0));
        StartCoroutine(PlayerTwoIndexChanged(0));
    }
コード例 #17
0
        public ActionResult Save(SaveProductFormModel model)
        {
            #region thêm sản phẩm
            Menu menu = new Menu()
            {
                CodeProduct = RejectMarks(model.NameProductLong),
                PriceOffPro = model.PriceOffPro,
                Content     = ChangeImageSEO(model.Content, model.NameProduct, ConvertFont(model.NameProductLong)),
                Content1    = ChangeImageSEO1(model.Content1, model.NameProduct, ConvertFont(model.NameProductLong)),
                Content2    = ChangeImageSEO2(model.Content2, model.NameProduct, ConvertFont(model.NameProductLong)),
                Content3    = ChangeImageSEO3(model.Content3, model.NameProduct, ConvertFont(model.NameProductLong)),
                Content4    = ChangeImageSEO4(model.Content4, model.NameProduct, ConvertFont(model.NameProductLong)),
                //Content = model.Content,
                //Content1 = model.Content1,
                //Content2 = model.Content2,
                //Content3 = model.Content3,
                //Content4 = model.Content4,
                Img                = (model.Img).Replace("/files/", ""),
                IdNhaCungCap       = model.IdNhaCungCap,
                idControl          = 11,
                Note               = model.Note,
                ok                 = false,//vua them thi san pham an di
                Option1            = model.Option1,
                Option5            = model.Option5,
                Option6            = model.Option6,
                Menu2              = "",
                MenuAdwords        = "",
                Link               = ConvertFont(model.NameProductLong),
                LevelMenu          = 1,
                LinkHttp           = "https://beautygarden.vn/" + ConvertFont(model.NameProduct) + ".html",
                LinkHttp1          = "",
                Style              = "san-pham",
                ui                 = "vi",
                ContentLabel       = model.ContentLabel,
                Option             = true,
                ContentLabel1      = model.ContentLabel1,
                ContentLabel2      = model.ContentLabel2,
                ContentLabel3      = model.ContentLabel3,
                ContentLabel4      = model.ContentLabel4,
                VIP                = false,
                Option8            = true,
                Option9            = model.Option9,
                sPosition          = model.sPosition,
                Visitor            = model.Visitor,
                sDate              = DateTime.Now,
                sDateOk            = DateTime.Now,
                idUser             = 18,
                idUserOk           = 18,
                Option2            = true,
                Option3            = true,
                Option4            = true,
                SEOKeyWord         = "",
                NumberHaveGift     = 0,
                idMPADSys          = 0,
                HasSale            = model.HasSale,
                HasValue           = false,
                NameProduct        = model.NameProduct,
                BarCode            = string.IsNullOrEmpty(model.BarCode) ? "" : model.BarCode.Trim(), //luu tam thoi ben bang menu sau do lay du lieu do qua bang menuoption
                HasOnHand          = true,                                                            //mac dinh =1 tuc la con hang. sau khi kiem tra ma vach thi update lai onhand
                SapXepSanPham      = model.SapXepSanPham,
                SapxepDanhMuc      = model.SapxepDanhMuc,
                BarcodeType        = model.BarcodeType,
                ContentTaiSao      = model.ContentTaiSao,
                ContentLabelTaiSao = model.ContentLabelTaiSao,
                ContentTheoSp      = model.ContentTheoSp,
                GiaHot             = false,
                NameProductLong    = model.NameProductLong,
                DungSai            = true,
                SEODescription     = model.SEODescription,
                SEOtitle           = model.SEOtitle,
                NgayHetHang        = DateTime.Now,
                NguoiTao           = User.Identity.Name,
                Bestseller         = false
            };

            _menuRepository.Add(menu);
            _unitOfWork.Commit();
            //sau khi thêm mới sp xong insert 4 sao cho phần đánh giá
            using (var context = new ShopDataContex())
            {
                context.Database.ExecuteSqlCommand("INSERT INTO UserRatings (Rating, IdSanPham)VALUES (4, {0})", menu.id_);
            }
            #endregion
            #region hinh anh khac
            //luu hinh anh khac
            IList <MenuImageMapping.MenuImage> images = !string.IsNullOrEmpty(model.OtherImages)
                                                         ? JsonConvert.DeserializeObject
                                                        <IList <MenuImageMapping.MenuImage> >(model.OtherImages)
                                                         : new List <MenuImageMapping.MenuImage>();
            if (images.Any())
            {
                foreach (var menuImage in images)
                {
                    if (menuImage.id == 0)//them moi hinh anh
                    {
                        MenuImage img = new MenuImage()
                        {
                            idMenu    = menu.id_,
                            date      = DateTime.Now,
                            ImageName = menuImage.ImageName,
                        };
                        _menuImageRepository.Add(img);
                        _unitOfWork.Commit();
                    }
                }
            }
            #endregion
            #region danh muc

            IList <int> idDanhMucs = !string.IsNullOrEmpty(model.DanhMucIds)
                                        ? JsonConvert.DeserializeObject
                                     <IList <int> >(model.DanhMucIds)
                                        : new List <int>();
            if (model.id_ != 0)
            {
                IList <MenuProAdd> menusDanhMuc = _menuProAddRepository.GetMany(o => o.idMenuProAdded == model.id_).ToList();
                foreach (var menuProAdd in menusDanhMuc)
                {
                    if (!idDanhMucs.Contains(menuProAdd.idMenuCatelogy))
                    {
                        //delete nhung thang khong co trong danh sach idDanhMucs
                        _menuProAddRepository.Delete(menuProAdd);
                        _unitOfWork.Commit();
                    }
                }
                if (menusDanhMuc.Any())
                {
                    if (idDanhMucs.Any())
                    {
                        //lay danh sach menuproadd hien tai cua product

                        foreach (var idDanhMuc in idDanhMucs)
                        {
                            if (!menusDanhMuc.Any(o => o.idMenuCatelogy == idDanhMuc))
                            {
                                MenuProAdd menuProAdd = new MenuProAdd()
                                {
                                    idMenuCatelogy = idDanhMuc,
                                    idMenuProAdded = menu.id_,
                                    sDate          = DateTime.Now,
                                    sDateOk        = DateTime.Now,
                                    Style          = "add-san-pham",
                                    idUser         = 15,
                                    idUserOk       = 15
                                };
                                _menuProAddRepository.Add(menuProAdd);
                                _unitOfWork.Commit();
                            }
                        }
                    }

                    IList <int> removeMenuProdIds =
                        menusDanhMuc.Where(o => !idDanhMucs.Contains(o.idMenuCatelogy)).Select(o => o.id_).ToList();
                    if (removeMenuProdIds.Any())
                    {
                        _menuProAddRepository.Delete(o => removeMenuProdIds.Contains(o.id_));
                    }
                }
            }
            else
            {
                if (idDanhMucs.Any())
                {
                    foreach (var idDanhMuc in idDanhMucs)
                    {
                        MenuProAdd menuProAdd = new MenuProAdd()
                        {
                            idMenuCatelogy = idDanhMuc,
                            idMenuProAdded = menu.id_,
                            sDate          = DateTime.Now,
                            sDateOk        = DateTime.Now,
                            Style          = "add-san-pham",
                            idUser         = 15,
                            idUserOk       = 15
                        };
                        _menuProAddRepository.Add(menuProAdd);
                        _unitOfWork.Commit();
                    }
                }
            }

            #endregion
            #region ma vach

            IList <MenuOptionMapping.OptionShow> maVachs = !string.IsNullOrEmpty(model.MaVachJson)
                                                      ? JsonConvert.DeserializeObject
                                                           <IList <MenuOptionMapping.OptionShow> >(model.MaVachJson)
                                                      : new List <MenuOptionMapping.OptionShow>();
            IList <MenuOption> menuOptionsCu = _menuOptionRepository.GetMany(o => o.IdMenu == model.id_).ToList();
            if (maVachs.Any())
            {
                foreach (var optionShow in maVachs)
                {
                    if (optionShow.id_ == 0)//them moi ma vach
                    {
                        MenuOption menuOption = new MenuOption()
                        {
                            IdMenu      = menu.id_,
                            TenLoai     = optionShow.TenLoai,
                            Img         = optionShow.Img.Replace("/files/", ""),
                            Barcode     = string.IsNullOrEmpty(optionShow.Barcode) ? "" : optionShow.Barcode.Trim(),
                            Flag        = optionShow.Flag,
                            NameProduct = menu.NameProduct,
                            SDate       = DateTime.Now,
                            sDateOk     = DateTime.Now
                        };
                        //truoc khi luu ma vach kiem tra ma vach co ton tai trong he thong hay khong
                        int istontai = _menuRepository.ChekBarcode(string.IsNullOrEmpty(optionShow.Barcode) ? "" : optionShow.Barcode.Trim());
                        if (istontai > 0)//ma vach ton tai ==> them duoc
                        {
                            _menuOptionRepository.Add(menuOption);
                            _unitOfWork.Commit();
                            //update hasvalue=1
                            using (var context = new ShopDataContex())
                            {
                                context.Database.ExecuteSqlCommand("update Menu set HasValue='True' where id_ ={0}", menu.id_);
                                //update barcodetype
                                context.Database.ExecuteSqlCommand("update Menu set BarcodeType={0} where id_ ={1}", optionShow.Flag, menu.id_);
                            }
                            //them dl thanh cong roi thi kiem tra san pham: onhand=0 thi an di nguoc lai show ra
                            //neu tong onhand <=0  het hang. nguoc lai con hang
                            int isonhand = _menuRepository.CheckOnhand(optionShow.Barcode.Trim());
                            if (isonhand <= 0)
                            {
                                //update hasOnhand =0

                                using (var context = new ShopDataContex())
                                {
                                    context.Database.ExecuteSqlCommand("update Menu set HasOnHand='false' where id_ ={0}", menu.id_);
                                }
                            }
                        }
                        else
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                    else
                    {
                        MenuOption sua = menuOptionsCu.FirstOrDefault(o => o.id_ == optionShow.id_);//sua ma vach
                        if (sua != null)
                        {
                            sua.Img     = optionShow.Img;
                            sua.Barcode = optionShow.Barcode.Trim();
                            sua.TenLoai = optionShow.TenLoai;
                            sua.Flag    = optionShow.Flag;
                            _menuOptionRepository.Update(sua);
                            _unitOfWork.Commit();
                        }
                    }
                }
            }


            #endregion
            #region ma vach khong co gi
            //cach 1:lay barcode cua bang menu sau do luu vao bang meuoption
            //truoc khi luu ma vach kiem tra ma vach co ton tai trong he thong hay khong
            if (model.BarcodeType == 0)
            {
                int somavach = _menuRepository.ChekBarcode(menu.BarCode.Trim());
                if (somavach > 0)//ma vach ton tai ==> them duoc
                {
                    //luu san pham
                    MenuOption menuOp = new MenuOption()
                    {
                        IdMenu      = menu.id_,
                        TenLoai     = "không có gì",
                        Img         = "images.png",
                        Barcode     = menu.BarCode,
                        SDate       = DateTime.Now,
                        sDateOk     = DateTime.Now,
                        NameProduct = menu.NameProduct,
                        Flag        = (short)BarcodeType.KhongCoGi
                    };
                    //luu ma vach
                    _menuOptionRepository.Add(menuOp);
                    _unitOfWork.Commit();

                    //update hasvalue=1
                    // _menuRepository.UpdateHasvalue(menu.id_, true);
                    using (var context = new ShopDataContex())
                    {
                        context.Database.ExecuteSqlCommand("update Menu set HasValue='True' where id_ ={0}", menu.id_);
                        //update barcodetype=0 neu la san pham khong co gi
                        context.Database.ExecuteSqlCommand("update Menu set BarcodeType=0 where id_ ={0}", menu.id_);
                    }
                    //them dl thanh cong roi thi kiem tra san pham: onhand=0 thi an di nguoc lai show ra
                    //neu tong onhand <=0  het hang. nguoc lai con hang
                    int tonkho = _menuRepository.CheckOnhand(menu.BarCode);
                    if (tonkho <= 0)
                    {
                        //update hasOnhand = 0
                        using (var context = new ShopDataContex())
                        {
                            context.Database.ExecuteSqlCommand("update Menu set HasOnHand='false' where id_ ={0}", menu.id_);
                        }
                    }
                    //  kiểm tra nếu mã vạch là CB hoặc cb tức là (Combo) thì update Hasonhand =1
                    if (menu.BarCode.IndexOf("CB") != -1 || menu.BarCode.IndexOf("cb") != -1)
                    {
                        using (var context = new ShopDataContex())
                        {
                            context.Database.ExecuteSqlCommand("update Menu set HasOnHand='True' where id_ ={0}", menu.id_);
                        }
                    }
                }
            }

            #endregion
            #region thêm mới tag

            string[] separators = { "," };
            var      taglist    = model.mySingleField.Split(separators, StringSplitOptions.RemoveEmptyEntries);
            //check null: nếu tồn tại thêm mới bình thường
            if (taglist.Any())
            {
                foreach (var tag in taglist)
                {
                    DanhSachTag _tag = new DanhSachTag()
                    {
                        NgayTao  = DateTime.Now,
                        IdMenu   = menu.id_,
                        NguoiTao = 18,
                        TenTag   = tag.Trim(),
                        Code     = RejectMarks(tag.Trim())
                    };
                    _danhSachTagRepository.Add(_tag);
                    _unitOfWork.Commit();
                }
            }
            #endregion
            #region thêm mới kho quà tặng

            if (model.IdQUaTangs != null)
            {
                KhoQuaTang khoQuaTang = new KhoQuaTang()
                {
                    IdMenu        = menu.id_,
                    NgayTao       = DateTime.Now,
                    IdSanPhamTang = model.IdQUaTangs
                };
                _khoQuaTangRepository.Add(khoQuaTang);
                _unitOfWork.Commit();
            }

            #endregion

            _menuRepository.ClearCacheByKey(new List <string>()
            {
                Shop.Web.Core.Cache.CacheKey.AllMenu
            });

            return(RedirectToAction("Index"));
        }
コード例 #18
0
        public ActionResult SaveEdit(SaveProductFormModel model)
        {
            #region san pham
            //SaveProductFormModel
            Menu dlcu = _menuRepository.GetById(model.id_);
            dlcu.NameProduct   = model.NameProduct;
            dlcu.Img           = (model.Img).Replace("/files/", "");
            dlcu.IdNhaCungCap  = model.IdNhaCungCap;
            dlcu.id_           = model.id_;
            dlcu.Option1       = model.Option1;
            dlcu.Option5       = model.Option5;
            dlcu.Option6       = model.Option6;
            dlcu.ContentLabel  = model.ContentLabel;
            dlcu.ContentLabel1 = model.ContentLabel1;
            dlcu.ContentLabel2 = model.ContentLabel2;
            dlcu.ContentLabel3 = model.ContentLabel3;
            dlcu.ContentLabel4 = model.ContentLabel4;
            //dlcu.Content = ChangeImageSEO(model.Content, model.NameProduct, ConvertFont(model.NameProductLong));
            //dlcu.Content1 = ChangeImageSEO1(model.Content1, model.NameProduct, ConvertFont(model.NameProductLong));
            //dlcu.Content2 = ChangeImageSEO2(model.Content2, model.NameProduct, ConvertFont(model.NameProductLong));
            //dlcu.Content3 = ChangeImageSEO3(model.Content3, model.NameProduct, ConvertFont(model.NameProductLong));
            //dlcu.Content4 = ChangeImageSEO4(model.Content4, model.NameProduct, ConvertFont(model.NameProductLong));
            dlcu.Content            = model.Content;
            dlcu.Content1           = model.Content1;
            dlcu.Content2           = model.Content2;
            dlcu.Content3           = model.Content3;
            dlcu.Content4           = model.Content4;
            dlcu.Note               = model.Note;
            dlcu.SapXepSanPham      = model.SapXepSanPham;
            dlcu.sDate              = DateTime.Now;
            dlcu.sDateOk            = DateTime.Now;
            dlcu.ContentLabelTaiSao = model.ContentLabelTaiSao;
            dlcu.ContentTaiSao      = model.ContentTaiSao;
            dlcu.BarCode            = model.BarCode;
            dlcu.ContentTheoSp      = model.ContentTheoSp;
            dlcu.NameProductLong    = model.NameProductLong;
            dlcu.Link               = model.Link; //sửa sản phẩm không sửa tên thành link nữa, cho sửa link trực tiếp
            dlcu.DungSai            = true;
            dlcu.SEOtitle           = model.SEOtitle;
            dlcu.SEODescription     = model.SEODescription;
            dlcu.NguoiTao           = User.Identity.Name;
            dlcu.Bestseller         = false;
            //dlcu.NgayHetHang = DateTime.Now;
            #endregion san pham
            #region hinh anh khac
            //------------- hinh anh khac -----------------


            IList <MenuImageMapping.MenuImage> images = !string.IsNullOrEmpty(model.OtherImages)
                                                       ? JsonConvert.DeserializeObject
                                                        <IList <MenuImageMapping.MenuImage> >(model.OtherImages)
                                                       : new List <MenuImageMapping.MenuImage>();
            foreach (var menuImage in images)
            {
                if (menuImage.id == 0)//them moi hinh anh
                {
                    MenuImage img = new MenuImage()
                    {
                        idMenu    = model.id_,
                        date      = DateTime.Now,
                        ImageName = menuImage.ImageName,
                    };
                    _menuImageRepository.Add(img);
                }
            }
            #endregion hinh anh khac
            #region danh muc

            IList <int> idDanhMucs = !string.IsNullOrEmpty(model.DanhMucIds)
                                        ? JsonConvert.DeserializeObject
                                     <IList <int> >(model.DanhMucIds)
                                        : new List <int>();
            if (model.id_ != 0)
            {
                IList <MenuProAdd> menusDanhMuc = _menuProAddRepository.GetMany(o => o.idMenuProAdded == model.id_).ToList();
                foreach (var menuProAdd in menusDanhMuc)
                {
                    if (!idDanhMucs.Contains(menuProAdd.idMenuCatelogy))
                    {
                        //delete nhung thang khong co trong danh sach idDanhMucs
                        _menuProAddRepository.Delete(menuProAdd);
                        _unitOfWork.Commit();
                    }
                }
                if (idDanhMucs.Any())
                {
                    //lay danh sach menuproadd hien tai cua product

                    foreach (var idDanhMuc in idDanhMucs)
                    {
                        if (!menusDanhMuc.Any(o => o.idMenuCatelogy == idDanhMuc))
                        {
                            MenuProAdd menuProAdd = new MenuProAdd()
                            {
                                idMenuCatelogy = idDanhMuc,
                                idMenuProAdded = model.id_,
                                sDate          = DateTime.Now,
                                sDateOk        = DateTime.Now,
                                Style          = "add-san-pham",
                                idUser         = 15,
                                idUserOk       = 15
                            };
                            _menuProAddRepository.Add(menuProAdd);
                            _unitOfWork.Commit();
                        }
                    }
                }
            }
            else
            {
                if (idDanhMucs.Any())
                {
                    foreach (var idDanhMuc in idDanhMucs)
                    {
                        MenuProAdd menuProAdd = new MenuProAdd()
                        {
                            idMenuCatelogy = idDanhMuc,
                            idMenuProAdded = model.id_,
                            sDate          = DateTime.Now,
                            sDateOk        = DateTime.Now,
                            Style          = "add-san-pham",
                            idUser         = 15,
                            idUserOk       = 15
                        };
                        _menuProAddRepository.Add(menuProAdd);
                        _unitOfWork.Commit();
                    }
                }
            }

            #endregion
            #region danh sach tag
            string[] separators = { "," };
            var      taglist    = model.mySingleField.Split(separators, StringSplitOptions.RemoveEmptyEntries);
            //check null: nếu tồn tại thêm mới bình thường
            if (taglist.Any())
            {
                foreach (var tag in taglist)
                {
                    //check trung
                    int checktrung = _danhSachTagRepository.GetTagNamebyIdmenu(model.id_, tag.Trim());
                    if (checktrung == 0)
                    {
                        DanhSachTag _tag = new DanhSachTag()
                        {
                            NgayTao  = DateTime.Now,
                            IdMenu   = model.id_,
                            NguoiTao = 18,
                            TenTag   = tag.Trim(),
                            Code     = RejectMarks(tag.Trim())
                        };
                        _danhSachTagRepository.Add(_tag);
                    }
                }
            }
            #endregion
            #region update kho quà tặng

            var idkhoqt = _khoQuaTangRepository.Get(o => o.IdMenu == model.id_);
            if (idkhoqt == null)
            {
                //thêm mới
                #region thêm mới kho quà tặng

                if (model.IdQUaTangs != null)
                {
                    KhoQuaTang khoQuaTang = new KhoQuaTang()
                    {
                        IdMenu        = model.id_,
                        NgayTao       = DateTime.Now,
                        IdSanPhamTang = model.IdQUaTangs.Remove(0, 1)
                    };
                    _khoQuaTangRepository.Add(khoQuaTang);
                    _unitOfWork.Commit();
                }

                #endregion
            }
            else
            {
                //update
                KhoQuaTang kho = _khoQuaTangRepository.GetById(idkhoqt.Id);
                kho.Id            = idkhoqt.Id;
                kho.IdMenu        = model.id_;
                kho.NgayTao       = DateTime.Now;
                kho.IdSanPhamTang = model.IdQUaTangs;
                _khoQuaTangRepository.Update(kho);
            }

            #endregion
            _menuRepository.Update(dlcu);

            _menuRepository.ClearCacheByKey(new List <string>()
            {
                Shop.Web.Core.Cache.CacheKey.AllMenu
            });
            _unitOfWork.Commit();
            return(RedirectToAction("Index"));
        }
コード例 #19
0
ファイル: MenuStateManager.cs プロジェクト: rodstrom/soul
        public void Initialize()
        {
            // Creating main menu
            MenuManager menuManager = new MenuManager(inputManager, "MainMenu");
            ImageButton button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), Constants.GUI_START, "start");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_OPTIONS, "options");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), Constants.GUI_CREDITS, "credits");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 250.0f), Constants.GUI_QUIT, "quit");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            menu["MainMenu"] = menuManager;

            // Creating options menu
            menuManager = new MenuManager(inputManager, "Options");
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 50.0f), Constants.GUI_GAME_PLAY, "gameplay");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), Constants.GUI_GRAPHICS, "graphics");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_SOUND, "sound");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), Constants.GUI_CONTROLS, "controls");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 250.0f), Constants.GUI_BACK, "options_back");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            menu["Options"] = menuManager;

            // Creating Sound Options Menu
            menuManager = new MenuManager(inputManager, "Sound");
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), Constants.GUI_EFFECTS_VOLUME, "effect_volume");
            VolumeSlider volumeSlider = new VolumeSlider(spriteBatch, game, audioManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), "effect_volume_slider");
            menuManager.AddButton(button, volumeSlider);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_MUSIC_VOLUME, "music_volume");
            volumeSlider = new VolumeSlider(spriteBatch, game, null, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), "music_volume_slider");
            menuManager.AddButton(button, volumeSlider);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), Constants.GUI_BACK, "sound_options_back");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            menu["Sound"] = menuManager;

            // Creating Game Play Options Menu
            menuManager = new MenuManager(inputManager, "GamePlay");
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_TUTORIAL, "tutorial");
            Selection selection = new Selection(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), "tutorial_selection");
            selection.AddSelection("On", Constants.GUI_ON);
            selection.AddSelection("Off", Constants.GUI_OFF);
            menuManager.AddButton(button, selection);
            bool tut = bool.Parse(game.config.getValue("General", "Tutorial"));
            if (tut == true)
            {
                selection.Selection = "On";
            }
            else
            {
                selection.Selection = "Off";
            }

            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), Constants.GUI_BACK, "game_play_options_back");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            menu["GamePlay"] = menuManager;

            // Creating Graphics Options Menu
            menuManager = new MenuManager(inputManager, "Graphics");
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), Constants.GUI_SPECULAR, "specular");
            selection = new Selection(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), "specular_selection");
            selection.AddSelection("High", Constants.GUI_HIGH);
            selection.AddSelection("Medium", Constants.GUI_MEDIUM);
            selection.AddSelection("Low", Constants.GUI_LOW);
            selection.AddSelection("Off", Constants.GUI_OFF);
            float specular = float.Parse(game.config.getValue("Video", "Specular"));
            selection.Selection = ParseSpecularConfig(specular);
            menuManager.AddButton(button, selection);

            /*button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_DYNAMIC_LIGHTING, "dynamic_lighting");
            selection = new Selection(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), "dynamic_lighting_selection");
            selection.AddSelection("On", Constants.GUI_ON);
            selection.AddSelection("Off", Constants.GUI_OFF);
            bool dynLights = bool.Parse(game.config.getValue("Video", "DynamicLights"));
            if (dynLights == true)
            {
                selection.Selection = "On";
            }
            else
            {
                selection.Selection = "Off";
            }

            menuManager.AddButton(button, selection);*/

            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_SCREEN_MODE, "screen_mode");
            selection = new Selection(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), "screen_mode_selection");
            selection.AddSelection("Fullscreen", Constants.GUI_FULLSCREEN);
            selection.AddSelection("Windowed", Constants.GUI_WINDOWED);

            if (bool.Parse(game.config.getValue("Video", "Fullscreen")) == true)
            {
                selection.Selection = "Fullscreen";
            }
            else
            {
                selection.Selection = "Windowed";
            }

            menuManager.AddButton(button, selection);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), Constants.GUI_RESOLUTION, "resolution");
            string output = game.Window.ClientBounds.Width + "x" + game.Window.ClientBounds.Height.ToString();
            Label label = new Label(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), "resolution_label", output);
            menuManager.AddButton(button, label);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 250.0f), Constants.GUI_BACK, "graphics_options_back");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            menu["Graphics"] = menuManager;

            // Creating Controls Options Menu
            menuManager = new MenuManager(inputManager, "Controls");
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 50.0f), Constants.GUI_SHOOT, "controls_shoot");
            label = new Label(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 50.0f), "shoot_string", inputManager.shoot.ToString(), false);
            menuManager.AddButton(button, label);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), Constants.GUI_UP, "controls_up");
            label = new Label(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 100.0f), "up_string", inputManager.up.ToString(), false);
            menuManager.AddButton(button, label);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_DOWN, "controls_down");
            label = new Label(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), "down_string", inputManager.down.ToString(), false);
            menuManager.AddButton(button, label);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), Constants.GUI_LEFT, "controls_left");
            label = new Label(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200.0f), "left_string", inputManager.left.ToString(), false);
            menuManager.AddButton(button, label);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 250.0f), Constants.GUI_RIGHT, "controls_right");
            label = new Label(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 300f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 250.0f), "right_string", inputManager.right.ToString(), false);
            menuManager.AddButton(button, label);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 300.0f), Constants.GUI_BACK, "controls_back");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            menu["Controls"] = menuManager;

            // Creating Credits Options Menu
            menuManager = new MenuManager(inputManager, "Credits");
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 250.0f), Constants.GUI_BACK, "credits_back");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            MenuImage menuImage = new MenuImage(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_DEVELOPERS_CREDITS, "dev_text");
            menuManager.AddButton(button, menuImage);
            menuManager.initialize();
            menu["Credits"] = menuManager;

            // Creating Quit Menu
            menuManager = new MenuManager(inputManager, "Quit");
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f - 200, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_YES, "quit_yes");
            label = new Label(spriteBatch, game, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f), "quit_text", "Are you sure you want to quit?", false);
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button, label);
            button = new ImageButton(spriteBatch, game, inputManager, new Vector2(Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 200, Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 150.0f), Constants.GUI_NO, "quit_no");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            menu["Quit"] = menuManager;

            currentMenuManager = menu["MainMenu"];
            currentMenuManager.FadeIn();

            keyChangeWarning = new Vector2(game.Window.ClientBounds.Width * 0.5f, game.Window.ClientBounds.Height * 0.5f);
            spriteFont = game.Content.Load<SpriteFont>(Constants.GUI_FONT);
        }
コード例 #20
0
 private void btnAcepc_Click(object sender, EventArgs e)
 {
     SelectedImage     = ((MenuImage)gridControl1.FocusedView.GetRow(gridView1.FocusedRowHandle));
     this.DialogResult = System.Windows.Forms.DialogResult.OK;
 }
コード例 #21
0
 private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     SelectedImage = ((MenuImage)gridControl1.FocusedView.GetRow(gridView1.FocusedRowHandle));
     pictureBoxImageSelected.Image = SelectedImage.Image;
 }
コード例 #22
0
ファイル: MainWindow.xaml.cs プロジェクト: Velikss/Runch
        private Dictionary <MenuType, Menu> PrepareMenus()
        {
            var Menus = new Dictionary <MenuType, Menu>();
            //button sprite
            var buttonsprite = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "Scene/54b2d246e0e35be.png");
            //Buttons
            var SinglePlayerBtn = new MenuButton("Singleplayer",
                                                 new Font("Munro", 25, System.Drawing.FontStyle.Bold), Brushes.Gainsboro,
                                                 55, 200, 250,
                                                 50, buttonsprite);
            var HighScoresBtn = new MenuButton("High Scores",
                                               new Font("Munro", 25, System.Drawing.FontStyle.Bold), Brushes.Gainsboro,
                                               55, 255, 250,
                                               50, buttonsprite);
            var HighScoreToTitleScrn = new MenuButton("Return to start",
                                                      new Font("Munro", 25, System.Drawing.FontStyle.Bold), Brushes.Gainsboro,
                                                      55, 475, 250,
                                                      50, buttonsprite);
            var ExitBtn = new MenuButton("Exit", new Font("Munro", 25, System.Drawing.FontStyle.Bold),
                                         Brushes.Gainsboro,
                                         55, 375, 250,
                                         50, buttonsprite);
            var PauseRestart = new MenuButton("Restart", new Font("Munro", 25, System.Drawing.FontStyle.Bold),
                                              Brushes.Gainsboro,
                                              800 / 2 - 170, 120, 340,
                                              50, buttonsprite);
            var PauseLvlOptions = new MenuButton("Level Options",
                                                 new Font("Munro", 25, System.Drawing.FontStyle.Bold), Brushes.Gainsboro,
                                                 800 / 2 - 170, 175, 340,
                                                 50, buttonsprite);
            var PauseToTitleScrn = new MenuButton("Return to start",
                                                  new Font("Munro", 25, System.Drawing.FontStyle.Bold),
                                                  Brushes.Gainsboro,
                                                  800 / 2 - 170, 230, 340,
                                                  50, buttonsprite);
            var DeathToTitleScrn = new MenuButton("Return to start",
                                                  new Font("Munro", 25, System.Drawing.FontStyle.Bold),
                                                  Brushes.Gainsboro,
                                                  800 / 2 - 170, 230, 340,
                                                  50, buttonsprite);
            var VictoryToTitleScrn = new MenuButton("Return to start",
                                                    new Font("Munro", 25, System.Drawing.FontStyle.Bold),
                                                    Brushes.Gainsboro,
                                                    800 / 2 - 170, 350, 340,
                                                    50, buttonsprite);
            var DeathLvlOptions = new MenuButton("Level Options",
                                                 new Font("Munro", 25, System.Drawing.FontStyle.Bold), Brushes.Gainsboro,
                                                 800 / 2 - 170, 175, 340,
                                                 50, buttonsprite);
            var DeathRestart = new MenuButton("Restart", new Font("Munro", 25, System.Drawing.FontStyle.Bold),
                                              Brushes.Gainsboro,
                                              800 / 2 - 170, 120, 340,
                                              50, buttonsprite);
            var VictoryRestart = new MenuButton("Restart", new Font("Munro", 25, System.Drawing.FontStyle.Bold),
                                                Brushes.Gainsboro,
                                                800 / 2 - 170, 405, 340,
                                                50, buttonsprite);
            var StartGame = new MenuButton("Start Game", new Font("Munro", 25, System.Drawing.FontStyle.Bold),
                                           Brushes.Gainsboro,
                                           800 / 2 - 170, 340, 340,
                                           50, buttonsprite);
            var PreviousCharacter = new MenuButton("<", new Font("Calibri", 26), Brushes.Gainsboro,
                                                   800 / 2 - 170, 250, 25,
                                                   75, buttonsprite);
            var NextCharacter = new MenuButton(">", new Font("Calibri", 26), Brushes.Gainsboro,
                                               800 / 2 + 145, 250, 25,
                                               75, buttonsprite);
            var PreviousLevel = new MenuButton("<", new Font("Calibri", 26), Brushes.Gainsboro,
                                               800 / 2 - 170, 100, 25,
                                               75, buttonsprite);
            var NextLevel = new MenuButton(">", new Font("Calibri", 26), Brushes.Gainsboro,
                                           800 / 2 + 145, 100, 25,
                                           75, buttonsprite);
            var LevelOptionsToTitleScrn = new MenuButton("Return to start",
                                                         new Font("Munro", 25, System.Drawing.FontStyle.Bold),
                                                         Brushes.Gainsboro,
                                                         800 / 2 - 170, 395, 340,
                                                         50, buttonsprite);
            var GoToNextLevel = new MenuButton("Continue",
                                               new Font("Munro", 25, System.Drawing.FontStyle.Bold),
                                               Brushes.Gainsboro,
                                               800 / 2 - 170, 295, 340,
                                               50, buttonsprite);
            var InstructionsBtn = new MenuButton("Instructions", new Font("Munro", 25, System.Drawing.FontStyle.Bold),
                                                 Brushes.Gainsboro,
                                                 55, 310, 250,
                                                 50, buttonsprite);
            var InstructionsScreenToTitleScrnBtn = new MenuButton("Return to start", new Font("Munro", 25, System.Drawing.FontStyle.Bold),
                                                                  Brushes.Gainsboro,
                                                                  55, 475, 250,
                                                                  50, buttonsprite);
            var CreditsToTitleBtn = new MenuButton("Return to start", new Font("Munro", 25, System.Drawing.FontStyle.Bold),
                                                   Brushes.Gainsboro,
                                                   55, 475, 250,
                                                   50, buttonsprite);
            //Panels
            var LevelSpriteBack     = new MenuPanel(800 / 2 - 145, 100, 75, 75, buttonsprite);
            var LevelTitleBack      = new MenuPanel(800 / 2 - 74, 100, 221, 75, buttonsprite);
            var CharacterSpriteBack = new MenuPanel(800 / 2 - 145, 250, 75, 75, buttonsprite);
            var CharacterTitleBack  = new MenuPanel(800 / 2 - 74, 250, 221, 75, buttonsprite);
            var OverlayPanel        = new MenuPanel(800 / 12 * 3, 0, 800 / 12 * 6, 600,
                                                    Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "Scene/menu-background.jpg"));
            var LevelOptionsPanel = new MenuPanel(800 / 12 * 3, 0, 800 / 12 * 6, 600,
                                                  Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "Scene/menu-background.jpg"));
            //Texts
            var PauseText =
                new MenuText("Pause", new Font("ArcadeClassic", 60), Brushes.White)
            {
                y = 50
            };
            var DeadText =
                new MenuText("GAME  OVER", new Font("ArcadeClassic", 60), Brushes.White)
            {
                y = 50
            };
            var VictoryText =
                new MenuText("Victory", new Font("ArcadeClassic", 60), Brushes.White)
            {
                y = 120
            };

            VictoryHighScoreText =
                new MenuText("Score: " + gm.Points, new Font("ArcadeClassic", 60), Brushes.White)
            {
                y = 180
            };
            var CharacterName = new MenuText(Player.CharacterNames[Player.Character_index],
                                             new Font("Calibri", 32, System.Drawing.FontStyle.Bold),
                                             Brushes.DarkSlateGray, 800 / 2 - 55, 600 / 2 - 34);
            var LevelName = new MenuText(Level.Levels[Level.Level_index].Name,
                                         new Font("Calibri", 32, System.Drawing.FontStyle.Bold),
                                         Brushes.DarkSlateGray, 800 / 2 - 55, 115);
            var SelectLevel =
                new MenuText("Select  Level", new Font("ArcadeClassic", 40), Brushes.White)
            {
                y = 50
            };
            var SelectCharacter =
                new MenuText("Select  Character", new Font("ArcadeClassic", 40),
                             Brushes.White)
            {
                y = 200
            };
            var HighScores = new MenuText(ScoreController.GetTopActive(),
                                          new Font("ArcadeClassic", 40, System.Drawing.FontStyle.Underline), Brushes.White)
            {
                y = 200
            };
            var Instructions = new MenuText("You can control your character with 'A', 'D' and spacebar."
                                            + Environment.NewLine
                                            + "The goal is to reach the red flag at the end of each level."
                                            + Environment.NewLine
                                            + "Good luck!",
                                            new Font("ArcadeClassic", 25), Brushes.White)
            {
                y = 200
            };
            var CopyrightDisclaimer = new MenuText("This game is for educational purpose only", new Font("ArcadeClassic", 21, System.Drawing.FontStyle.Italic), Brushes.White)
            {
                y = 440
            };
            var Congratulations = new MenuText("Congratulations", new Font("ArcadeClassic", 60), Brushes.White)
            {
                y = 120
            };
            var CongratulationsTxt = new MenuText("You have succesfully completed the game, good job!",
                                                  new Font("ArcadeClassic", 25), Brushes.White)
            {
                y = 200
            };
            var Credits = new MenuText("Credits", new Font("ArcadeClassic", 60), Brushes.White)
            {
                y = 280
            };
            var CreditsTxt = new MenuText("This game was made by:"
                                          + Environment.NewLine
                                          + "Buster, Bart, Remy, Nolen, Felix en Bram",
                                          new Font("ArcadeClassic", 25), Brushes.White)
            {
                y = 360
            };
            //Images
            var CharacterSprite = new MenuImage(800 / 2 - 132, 262, 48, 48,
                                                Image.FromFile("Animations/" + Player.CharacterNames[Player.Character_index] + "/normal.gif"), true);
            var LevelSprite = new MenuImage(800 / 2 - 132, 112, 48, 48,
                                            Image.FromFile("Levels/" + Level.Levels[Level.Level_index].Name + ".gif"), true);
            var VictorySprite = new MenuImage(368, 50, 64, 64,
                                              Image.FromFile("Scene/trophy.png"), true);

            //Click events
            GoToNextLevel.Clicked += delegate
            {
                if (Level.Level_index != Level.Levels.Count - 1)
                {
                    Menus[MenuType.Completed].Deactivate();
                    Level.Level_index++;
                    gm.StartLevel(true);
                }
                else
                {
                    Level.Level_index = 0;
                    Menus[MenuType.Completed].Deactivate();
                    Menus[MenuType.Credits].Activate();
                }
            };
            LevelOptionsToTitleScrn.Clicked += delegate
            {
                Menus[MenuType.LevelOptions].Deactivate();
                Menus[MenuType.TitleScreen].Activate();
            };
            NextLevel.Clicked += delegate
            {
                if (Level.Level_index != Level.Levels.Count - 1)
                {
                    Level.Level_index++;
                }
                else
                {
                    Level.Level_index = 0;
                }
                LevelSprite.Sprite = Image.FromFile("Levels/" + Level.Levels[Level.Level_index].Name + ".gif");
                LevelName.Content  = Level.Levels[Level.Level_index].Name;
                HighScores.Content = ScoreController.GetTopActive();
            };
            PreviousLevel.Clicked += delegate
            {
                if (Level.Level_index == 0)
                {
                    Level.Level_index = Level.Levels.Count - 1;
                }
                else
                {
                    Level.Level_index--;
                }
                LevelSprite.Sprite = Image.FromFile("Levels/" + Level.Levels[Level.Level_index].Name + ".gif");
                LevelName.Content  = Level.Levels[Level.Level_index].Name;
                HighScores.Content = ScoreController.GetTopActive();
            };
            NextCharacter.Clicked += delegate
            {
                if (Player.Character_index != Player.CharacterNames.Count - 1)
                {
                    Player.Character_index++;
                }
                else
                {
                    Player.Character_index = 0;
                }
                CharacterSprite.Sprite =
                    Image.FromFile("Animations/" + Player.CharacterNames[Player.Character_index] + "/normal.gif");
                CharacterName.Content = Player.CharacterNames[Player.Character_index];
            };
            PreviousCharacter.Clicked += delegate
            {
                if (Player.Character_index == 0)
                {
                    Player.Character_index = Player.CharacterNames.Count - 1;
                }
                else
                {
                    Player.Character_index -= 1;
                }
                CharacterSprite.Sprite =
                    Image.FromFile("Animations/" + Player.CharacterNames[Player.Character_index] + "/normal.gif");
                CharacterName.Content = Player.CharacterNames[Player.Character_index];
            };
            StartGame.Clicked += delegate
            {
                Menus[MenuType.LevelOptions].Deactivate();
                gm.StartLevel(true);
            };
            DeathLvlOptions.Clicked += delegate
            {
                Menus[MenuType.Death].Deactivate();
                Menus[MenuType.LevelOptions].Activate();
            };
            DeathToTitleScrn.Clicked += delegate
            {
                Menus[MenuType.Death].Deactivate();
                Menus[MenuType.TitleScreen].Activate();
            };
            VictoryToTitleScrn.Clicked += delegate
            {
                Menus[MenuType.Completed].Deactivate();
                Menus[MenuType.TitleScreen].Activate();
            };
            DeathRestart.Clicked += delegate
            {
                Menus[MenuType.Death].Deactivate();
                gm.StartLevel(true);
            };
            VictoryRestart.Clicked += delegate
            {
                Menus[MenuType.Completed].Deactivate();
                gm.StartLevel(true);
            };
            SinglePlayerBtn.Clicked += delegate
            {
                Menus[MenuType.TitleScreen].Deactivate();
                Menus[MenuType.LevelOptions].Activate();
            };
            ExitBtn.Clicked      += delegate { Environment.Exit(0); };
            PauseRestart.Clicked += delegate
            {
                Menus[MenuType.Pause].Deactivate();
                gm.StartLevel(true);
            };
            HighScoresBtn.Clicked += delegate
            {
                Menus[MenuType.TitleScreen].Deactivate();
                Menus[MenuType.HighScoreScreen].Activate();
            };
            PauseLvlOptions.Clicked += delegate
            {
                Menus[MenuType.Pause].Deactivate();
                Menus[MenuType.LevelOptions].Activate();
            };
            PauseToTitleScrn.Clicked += delegate
            {
                Menus[MenuType.Pause].Deactivate();
                Menus[MenuType.TitleScreen].Activate();
            };
            HighScoreToTitleScrn.Clicked += delegate
            {
                Menus[MenuType.HighScoreScreen].Deactivate();
                Menus[MenuType.TitleScreen].Activate();
            };
            InstructionsBtn.Clicked += delegate
            {
                Menus[MenuType.TitleScreen].Deactivate();
                Menus[MenuType.InstructionsScreen].Activate();
            };
            InstructionsScreenToTitleScrnBtn.Clicked += delegate
            {
                Menus[MenuType.InstructionsScreen].Deactivate();
                Menus[MenuType.TitleScreen].Activate();
            };
            CreditsToTitleBtn.Clicked += delegate
            {
                Menus[MenuType.Credits].Deactivate();
                Menus[MenuType.TitleScreen].Activate();
            };
            //adds to Menu's
            Menus.Add(MenuType.TitleScreen, new Menu(ref gm.screen,
                                                     new List <MenuItem> {
                SinglePlayerBtn, HighScoresBtn, InstructionsBtn, ExitBtn
            },
                                                     Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "Scene/Title.gif")));
            Menus.Add(MenuType.HighScoreScreen, new Menu(ref gm.screen,
                                                         new List <MenuItem>
            {
                HighScoreToTitleScrn, LevelSpriteBack, LevelTitleBack, PreviousLevel, NextLevel, LevelName,
                LevelSprite, HighScores
            },
                                                         Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "Scene/HighScores.gif")));
            Menus.Add(MenuType.InstructionsScreen, new Menu(ref gm.screen,
                                                            new List <MenuItem>
            {
                InstructionsScreenToTitleScrnBtn, Instructions, CopyrightDisclaimer
            },
                                                            Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "Scene/Title.gif")));
            Menus.Add(MenuType.Pause, new Menu(ref gm.screen,
                                               new List <MenuItem> {
                OverlayPanel, PauseText, PauseToTitleScrn, PauseRestart, PauseLvlOptions
            },
                                               null));
            Menus.Add(MenuType.Death, new Menu(ref gm.screen,
                                               new List <MenuItem> {
                OverlayPanel, DeadText, DeathToTitleScrn, DeathRestart, DeathLvlOptions
            },
                                               null));
            Menus.Add(MenuType.Completed, new Menu(ref gm.screen,
                                                   new List <MenuItem>
            {
                OverlayPanel, VictorySprite, VictoryText, VictoryHighScoreText, VictoryToTitleScrn, VictoryRestart,
                GoToNextLevel
            },
                                                   null));
            Menus.Add(MenuType.Credits, new Menu(ref gm.screen, new List <MenuItem>
            {
                Congratulations, CongratulationsTxt, Credits, CreditsTxt, CreditsToTitleBtn
            },
                                                 Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "Scene/back.gif")));
            Menus.Add(MenuType.LevelOptions, new Menu(ref gm.screen,
                                                      new List <MenuItem>
            {
                LevelOptionsPanel,
                StartGame,
                PreviousCharacter,
                CharacterSpriteBack,
                CharacterTitleBack,
                CharacterSprite,
                NextCharacter,
                CharacterName,
                LevelSpriteBack,
                LevelTitleBack,
                PreviousLevel,
                NextLevel,
                LevelName,
                LevelSprite,
                SelectCharacter,
                SelectLevel,
                LevelOptionsToTitleScrn
            },
                                                      Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "Scene/back.gif")));
            return(Menus);
        }