예제 #1
0
        private void generatesGames(int amount)
        {
            FileAccessModule FAM            = new FileAccessModule();
            List <Game>      libraryofGames = new List <Game>();

            FAM.FromGameFile("", libraryofGames);
            FAM.initateGames(amount, libraryofGames);
            FAM.ToGameFile("", libraryofGames);
        }
예제 #2
0
        public LoginPage()
        {
            InitializeComponent();
            this.FormClosed += our_FormClosed;
            FileAccessModule FAM = new FileAccessModule();


            RandomizeGame RandomGame = new RandomizeGame();

            FAM.ToGameFile(FAM.CreateGame(200));
        }
예제 #3
0
        private void CustomItem_MouseClick(object sender, EventArgs e)
        {
            if (sender is Button)
            {
                Button suspect = (Button)sender;
                if (suspect.Name.Equals(this.GameBuyButton.Name))
                {
                    DialogResult result = MessageBox.Show("Buy " + checkout.Count + " games?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (result == DialogResult.Yes)
                    {
                        Console.WriteLine("GameCart. Yes");

                        //LINQ testing
                        double total = checkout.Sum(a => a.Price);

/*                        double total = 0;
 *                      for (int i = 0; i < checkout.Count; i++)
 *                      {
 *                          total += checkout[i].Price;
 *                      }*/
                        if (loggedBuyer.Funds >= total)
                        {
                            loggedBuyer.Funds -= total;
                            loggedBuyer.gameLibrary.AddRange(checkout);
                            checkout.Clear();
                            GamePanels(this.InCartPanel, checkout);
                            FileAccessModule FAM = new FileAccessModule();
                            FAM.saveUser(loggedBuyer);
                            updatePage();
                        }
                        else
                        {
                        }
                    }
                    else if (result == DialogResult.No)
                    {
                        Console.WriteLine("GameCart. No");
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        Console.WriteLine("GameCart. Cancelled");
                    }
                }
            }
            else if (sender is Panel)
            {
                Panel suspect = (Panel)sender;
                if (Int32.TryParse(suspect.Name, out int x))
                {
                    checkout.Remove(checkout[x]);
                    updatePage();
                }
            }
        }
예제 #4
0
        public void loggingIn()
        {
            string           username = this.UsernameBox.Text;
            string           password = this.PasswordBox.Text;
            FileAccessModule FAM      = new FileAccessModule();

            if (!FAM.checkUser(username, password))
            {
                this.LogInWarning.Text    = "Invalid Login Credentials";
                this.LogInWarning.Visible = true;
                wait(1500);
                this.LogInWarning.Visible = false;
            }
            else
            {
                //Check user came positive
                //we can search it now
                this.LogInWarning.Text    = "Successful Login. Please Wait.";
                this.LogInWarning.Visible = true;
                wait(2000);
                this.LogInWarning.Visible = false;
                Console.WriteLine();
                loggedIn = FAM.readUserFile(username, password);

                StoreSystems LoggedIn = new StoreSystems();

                LoggedIn.loggedUser = loggedIn;

                Welcomepage = new WelcomePage(LoggedIn);
                Welcomepage.StartPosition = FormStartPosition.Manual;
                Welcomepage.Left          = this.Location.X;
                Welcomepage.Top           = this.Location.Y;
                Welcomepage.Location      = this.Location;
                Welcomepage.SetDesktopLocation(this.Location.X, this.Location.Y);

                Welcomepage.setLoggedIn();

                Welcomepage.MainForm = this;

                Welcomepage.Show();

                //Time to purge loggin
                this.UsernameBox.Text = "";
                this.PasswordBox.Text = "";
                loggedIn = null;
                this.Hide();
            }
        }
예제 #5
0
        //Make Panels
        private void GamePanels(Panel parentPanel, List <Game> gamelibrary)
        {
            //starting positions
            int panelheight = 60;
            int edgepad     = 20;

            parentPanel.Controls.Clear();
            //loop this thing
            for (int i = 0; i < gamelibrary.Count; i++)
            {
                //items in the label
                Bitmap gameImage;
                //Generate Game Info
                FileAccessModule FAM = new FileAccessModule();
                if (FAM.checkGameInfo(gamelibrary[i]))
                {
                    gameImage = FAM.getGameImage(gamelibrary[i]);
                }
                else
                {
                    FAM.generateGameInfo(gamelibrary[i]);
                    gameImage = FAM.getGameImage(gamelibrary[i]);
                }



                //

                //items in the label
                Panel      gameFrame   = new Panel();           //holds everthing
                PictureBox gamePicture = new PictureBox();
                Label      gameTitle   = new Label();
                Label      gameStudio  = new Label();
                Label      gameRating  = new Label();
                Label      gameSold    = new Label();
                Label      gamePrice   = new Label();
                //Label gameGenre = new Label();

                //make the labels
                gameFrame.Size         = new Size(parentPanel.Size.Width - edgepad, panelheight);                  //length of the entire panel, and then the height
                gameFrame.Location     = new Point(0, (i * (panelheight + 2)));
                gameFrame.Margin       = new Padding(0);
                gameFrame.Padding      = new Padding(0);
                gameFrame.Name         = StoreLibrary.FindIndex(a => a.GameID.Equals(gamelibrary[i].GameID)).ToString();
                gameFrame.BackColor    = Color.FromArgb(10, 18, 29);
                gameFrame.DoubleClick += CustomItem_DoubleClick;
                gameFrame.MouseHover  += CustomItem_Hover;
                gameFrame.MouseLeave  += CustomItem_MouseLeave;


                gamePicture.Size                  = new Size(gameFrame.Size.Height, gameFrame.Size.Height); //makes it a box using the workframe width, this makes a box
                gamePicture.BackColor             = Color.FromArgb(50, 255, 255, 255);
                gamePicture.BackgroundImage       = gameImage;
                gamePicture.BackgroundImageLayout = ImageLayout.Stretch;


                gameTitle.Text     = (i + 1) + ". " + gamelibrary[i].Name;
                gameTitle.AutoSize = true;
                gameFrame.Controls.Add(gameTitle);
                //add it in so the size resizes
                gameTitle.Font      = new Font(this.Font.FontFamily, 10, FontStyle.Underline);
                gameTitle.Location  = new Point(gamePicture.Location.X + gamePicture.Width, 5);
                gameTitle.ForeColor = Color.FromArgb(255, 255, 255);
                gameTitle.BackColor = Color.FromArgb(0);

                /*                gameTitle.MouseHover += Label_MouseHover;
                 *              gameTitle.MouseLeave += Label_MouseLeave;*/


                gameStudio.Text     = gamelibrary[i].Studio + "\n" + gamelibrary[i].Genre;
                gameStudio.AutoSize = true;
                gameFrame.Controls.Add(gameStudio);
                //add it in so the size resizes
                gameStudio.Font     = new Font(this.Font.FontFamily, 8);
                gameStudio.Location = new Point((gameTitle.Location.X),
                                                (gameTitle.Location.Y + gameTitle.Size.Height));
                gameStudio.ForeColor = Color.FromArgb(255, 255, 255);
                gameStudio.BackColor = Color.FromArgb(0);

/*                gameStudio.MouseHover += Label_MouseHover;
 *              gameStudio.MouseLeave += Label_MouseLeave;*/


                gameRating.Text     = "rating: " + gamelibrary[i].Ratings + "%";
                gameRating.AutoSize = true;
                gameFrame.Controls.Add(gameRating);
                //add it in so the size resizes
                gameRating.Font     = new Font(this.Font.FontFamily, 8);
                gameRating.Location = new Point((gameFrame.Location.X + gamePicture.Size.Width),
                                                (gameFrame.Size.Height - gameRating.Size.Height));
                gameRating.ForeColor = Color.FromArgb(255, 255, 255);
                gameRating.BackColor = Color.FromArgb(0);


                gameSold.Text     = gamelibrary[i].ItemSold + " units sold";
                gameSold.AutoSize = true;
                gameFrame.Controls.Add(gameSold);
                //add it in so the size resizes
                gameSold.Font     = new Font(this.Font.FontFamily, 8);
                gameSold.Location = new Point((gameFrame.Location.X + (gameFrame.Size.Width / 2)) - (0),
                                              (gameFrame.Size.Height - gameRating.Size.Height));
                gameSold.ForeColor = Color.FromArgb(255, 255, 255);
                gameSold.BackColor = Color.FromArgb(0);


                gamePrice.Text     = "$" + gamelibrary[i].Price;
                gamePrice.AutoSize = true;
                gameFrame.Controls.Add(gamePrice);
                //add it in so the size resizes
                gamePrice.Location = new Point((gameFrame.Location.X + gameFrame.Size.Width) - (gamePrice.Size.Width),
                                               (gameFrame.Size.Height - gamePrice.Size.Height));
                gamePrice.Font      = new Font(this.Font.FontFamily, 8);
                gamePrice.ForeColor = Color.FromArgb(255, 255, 255);
                gamePrice.BackColor = Color.FromArgb(0);


                gameFrame.Controls.Add(gamePicture);

                //update Location



                parentPanel.Controls.Add(gameFrame);
            }
            // hide the scroll bar
            Panel hidePanel = new Panel();

            hidePanel.Size      = new Size(edgepad, parentPanel.Height);
            hidePanel.Location  = new Point((parentPanel.Location.X + parentPanel.Size.Width) - hidePanel.Size.Width, parentPanel.Location.Y);
            hidePanel.BackColor = this.BackColor;
            hidePanel.Name      = "HideScroll";


            parentPanel.AutoScroll               = true;
            parentPanel.VerticalScroll.Visible   = false;
            parentPanel.HorizontalScroll.Visible = false;

            this.Controls.Add(hidePanel);
            hidePanel.BringToFront();
        }