protected void Page_Load(object sender, EventArgs e)
    {
        //Set Game for Page
        if (Session["userID"] == null)
        {
            Response.Redirect("~/Login");
        }
        if (Session["activeGame"] == null)
        {
            Response.Redirect("~/Home");
        }

        //Get Active Game
        game = (Game)Session["activeGame"];
        gameNameLabel.Text = game.GameName;

        //Load CustomPages State if appropriate
        if (Session["savedContent"] != null && ((CustomPageList)Session["savedContent"]).GameID != game.GameID)
        {
            Session.Remove("savedContent");                                                                                                      //Handles if there is savedContent from a wrong game.
        }
        if (Session["savedContent"] == null)
        {
            loadPages();                                  //Handles a fresh load with no saved content
        }
        else
        {
            pages = (CustomPageList)Session["savedContent"];   //Handles there is saved content from this game.
        }
        loadPageTable();

        //Little tool for relaying messages thru redirects
        if (Session["message"] != null)
        {
            Message message = (Message)Session["message"];
            angryLabel.ForeColor = message.Color;
            angryLabel.Text      = message.Text;
            Session.Remove("message");
        }
        else
        {
            angryLabel.Text = " ";
        }
    }
Esempio n. 2
0
    //Gets all custom pages belonging to this game
    public CustomPageList getGamePages(int gameID)
    {
        //Make query
        string query = "spGetGameCustomPages";

        //Obtain Parameters
        SqlParameter[] parameters = new SqlParameter[1];
        parameters[0] = new SqlParameter("gameID", gameID);

        //Retrieve Data
        DataSet data = database.downloadCommand(query, parameters);

        //Make sure the database found the encounter, else return an empty encounter
        CustomPageList pages = new CustomPageList();

        pages.GameID = gameID;

        for (int i = 0; i < data.Tables[0].Rows.Count; i++)
        {
            int    pageID    = (Int32)data.Tables[0].Rows[i]["pageID"];
            int    sortIndex = (Int32)data.Tables[0].Rows[i]["sortIndex"];
            string pageName  = HttpUtility.HtmlEncode(data.Tables[0].Rows[i]["pageName"].ToString());
            if (pageName.Contains("&#39;"))
            {
                pageName = pageName.Replace("&#39;", "'");
            }
            string pageURL = data.Tables[0].Rows[i]["pageURL"].ToString();

            CustomPage page = new CustomPage();
            page.PageID    = pageID;
            page.GameID    = gameID;
            page.SortIndex = sortIndex;
            page.PageName  = pageName;
            page.PageURL   = pageURL;

            pages.Pages.Add(page.SortIndex, page);
        }
        return(pages);
    }
Esempio n. 3
0
    //Takes a list of any kind of objects, an array with the desired parameters to form the columns, and an optional Dictionary of types/colors so you can color code by inherritance.
    public PageTable(CustomPageList pages)
    {
        this.pages = pages;
        //Generate Table
        this.ID = "objectTable";  //Needed so javascript can find the table to sort columns.  Should use a better way.
                                  //Make Header Row, and Buttons so can be sorted by whatever column I want.  Uses JS to sort entire rows.

        TableRow header = new TableRow();

        TableCell indexColumn = new TableCell();

        indexColumn.Text = "Index";
        header.Cells.Add(indexColumn);

        TableCell nameColumn = new TableCell();

        nameColumn.Text = "Page Name";
        header.Cells.Add(nameColumn);

        this.Rows.Add(header);

        if (pages.Pages.Count == 0)
        {
            header.Visible = false;
        }
        else
        {
            header.Visible = true;
        }

        //Make the remaining rows, where each row contains one object from the provided List<T>
        for (int i = 0; i < pages.Pages.Count; i++)
        {
            CustomPage page = pages.Pages[i];

            ObjectTableRow objectRow = new ObjectTableRow(page, Color.White);
            if (page.MarkedForDeletion == true)
            {
                objectRow.Visible = false;
            }

            //Make the individual cells for this object, using the provided parameter Names to obtain the desired values.
            TableCell indexCell  = new TableCell();
            Label     indexLabel = new Label();
            indexLabel.EnableViewState = false;
            indexLabel.CssClass        = "regularFont";
            indexLabel.Text            = page.SortIndex.ToString();
            indexCell.Controls.Add(indexLabel);
            objectRow.Controls.Add(indexCell);

            ObjectTableCell pageNameCell = new ObjectTableCell(objectRow, "PageName", false);
            objectRow.ObjectCells.Add(pageNameCell);
            objectRow.Controls.Add(pageNameCell);

            TableCell upCell   = new TableCell();
            Button    upButton = new Button();
            upButton.Text   = "+";
            upButton.Click += new EventHandler(upButton_Click);
            upCell.Controls.Add(upButton);
            objectRow.Cells.Add(upCell);

            TableCell downCell   = new TableCell();
            Button    downButton = new Button();
            downButton.Text   = "-";
            downButton.Click += new EventHandler(downButton_Click);
            downCell.Controls.Add(downButton);
            objectRow.Cells.Add(downCell);

            TableCell deleteCell   = new TableCell();
            Button    deleteButton = new Button();
            deleteButton.Text   = "Delete";
            deleteButton.Click += new EventHandler(deleteButton_Click);
            deleteCell.Controls.Add(deleteButton);
            objectRow.Cells.Add(deleteCell);


            //Add to table
            this.Rows.Add(objectRow);
            objectRows.Add(objectRow);
        }
    }
Esempio n. 4
0
    //Loads all the NavBar content for each game the user is playing in.
    protected void loadPlayerGames()
    {
        Panel playerGames = new Panel();

        playerGames.ID       = "playerGames";
        playerGames.CssClass = "outerDropdownContainer";

        //Foreach Game database says User is playing in, create a corresponding Game Dropdown and associated panel.  These are both 'pretend' games
        //to display what it should look like if you actually are playing in two games.
        foreach (Game game in playerGamesList)
        {
            GameLink gameLink = new GameLink(playerGamesLink, playerCarrot);
            gameLink.ID           = Server.HtmlDecode(game.GameName + "PlayerLink");
            gameLink.Text         = game.GameName;
            gameLink.Text        += "<i class=\"fa fa-caret-down\"></i>";
            gameLink.GameCarrotID = game.GameName + "PlayerCarrot";
            gameLink.CssClass     = "dropdown-btn";
            playerGames.Controls.Add(gameLink);

            Panel gamePanel = new Panel();
            gamePanel.ID       = Server.HtmlDecode(game.GameName + "PlayerPanel");
            gamePanel.CssClass = "innerDropdownContainer";
            {
                GamePageButton gameInfo = new GamePageButton(gameLink, "Player/GameInformation", game);
                gameInfo.Text   = "Game Information";
                gameInfo.Click += new EventHandler(gamePageButtonClicked);
                gamePanel.Controls.Add(gameInfo);

                GamePageButton charList = new GamePageButton(gameLink, "Player/GameParty", game);
                charList.Text   = "Game Party";
                charList.Click += new EventHandler(gamePageButtonClicked);
                gamePanel.Controls.Add(charList);

                //Add Custom Pages
                PagesTable     pagesTable = new PagesTable(new DatabaseConnection());
                CustomPageList pages      = pagesTable.getGamePages(game.GameID);

                for (int i = 0; i < pages.Pages.Count; i++)
                {
                    CustomPage     page       = pages.Pages[i];
                    GamePageButton publicPage = new GamePageButton(gameLink, page.PageURL, game, true);
                    publicPage.Text   = page.PageName;
                    publicPage.Click += new EventHandler(gamePageButtonClicked);
                    gamePanel.Controls.Add(publicPage);
                }
            }
            playerGames.Controls.Add(gamePanel);
        }

        //Give a nice label if user has no games, so they are not sad :(
        if (playerGamesList.Count == 0)
        {
            Label noGamesLabel = new Label();
            noGamesLabel.Text     = "You have no games.";
            noGamesLabel.CssClass = "innerDropdownNoGames";
            playerGames.Controls.Add(noGamesLabel);
            playerGamesDropdown.Controls.Add(noGamesLabel);
        }

        else
        {
            playerGamesDropdown.Controls.Add(playerGames);
        }
    }
    //Loads the custom pages from the database
    private void loadPages()
    {
        PagesTable pagesTable = new PagesTable(new DatabaseConnection());

        pages = pagesTable.getGamePages(game.GameID);
    }