Пример #1
0
 public ObjectTableCell(ObjectTableRow row, string parameterName, bool readOnly, int column = -1)
 {
     this.row           = row;
     this.parameterName = parameterName;
     if (column != 1)
     {
         //Make TextBox
         this.textbox = new TextBox();
         updateTextBox();
         this.Controls.Add(textbox);
     }
     else
     {
         dropDown = new DropDownList();
         dropDown.Items.Insert(0, new ListItem("Common", "0"));
         dropDown.Items.Insert(0, new ListItem("Uncommon", "1"));
         dropDown.Items.Insert(0, new ListItem("Rare", "2"));
         dropDown.Items.Insert(0, new ListItem("Very Rare", "3"));
         dropDown.Items.Insert(0, new ListItem("Legendary", "4"));
     }
     if (readOnly)
     {
         textbox.ReadOnly = true;
     }
 }
 void SetupObjectTableRow(VisualElement rowRoot, ref ObjectTableRow row, string name, bool sizesUnknown = false)
 {
     rowRoot.Q <Label>("memory-usage-breakdown__object-table__name").text = name;
     row.Count      = rowRoot.Q <Label>("memory-usage-breakdown__object-table__count-column");
     row.Count.text = "0";
     row.Size       = rowRoot.Q <Label>("memory-usage-breakdown__object-table__size-column");
     row.Size.text  = sizesUnknown ? "-" : "0";
 }
 void UpdateObjectRow(RawFrameDataView data, ref ObjectTableRow row, string countMarkerName, string sizeMarkerName = null)
 {
     row.Count.text = data.GetCounterValueAsLong(data.GetMarkerId(countMarkerName)).ToString();
     if (!string.IsNullOrEmpty(sizeMarkerName))
     {
         row.Size.text = EditorUtility.FormatBytes(data.GetCounterValueAsLong(data.GetMarkerId(sizeMarkerName)));
     }
 }
Пример #4
0
    public void addRow(CustomPage page)
    {
        names.Add(page.PageName);
        ObjectTableRow objectRow = new ObjectTableRow(page, Color.White);

        //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.Text = page.SortIndex.ToString();
        indexCell.Controls.Add(indexLabel);
        objectRow.Controls.Add(indexCell);

        ObjectTableCell pageNameCell = new ObjectTableCell(objectRow, "PageName", false);
        TextBox         nameTextBox  = new TextBox();

        nameTextBox.Text = page.PageName;
        pageNameCell.Controls.Add(nameTextBox);
        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);
        if (objectRow.Color == Color.Empty)
        {
            objectRow.Visible = false;
        }
    }
Пример #5
0
    protected void npcButton_Click(object sender, EventArgs e)
    {
        //Event Data
        RadioButton    button = (RadioButton)sender;
        ObjectTableRow row    = (ObjectTableRow)button.Parent.Parent;

        //Remove Selected from the table, then make a new dictionary so next postback wont build it anymore
        NPC npc = (NPC)row.Obj;

        //Select NPC
        selectNPC(npc);
    }
Пример #6
0
    //Saves the active NPC if there is one
    protected void saveButton_Click(object sender, EventArgs e)
    {
        if (Session["activeNPC"] == null)
        {
            angryLabel.Text = "There is no active NPC.";
            return;
        }

        NPCsTable dbNpcTable = new NPCsTable(new DatabaseConnection());
        NPC       npc        = (NPC)Session["activeNPC"];

        npc.Name             = nameTextBox.Text;
        npc.Sex              = sexTextBox.Text;
        npc.Race             = raceTextBox.Text;
        npc.Location         = locationTextBox.Text;
        npc.Bio              = bioTextBox.Text;
        npc.Appearance       = appearanceTextBox.Text;
        npc.Mannerism        = mannerismTextBox.Text;
        npc.InteractionStyle = interactionTextBox.Text;
        npc.Flaw_secret      = flawTextBox.Text;
        npc.Talent           = talentTextBox.Text;

        //Find the current selected row
        ObjectTableRow selectedRow = null;

        foreach (ObjectTableRow row in objectRows)
        {
            if (((NPC)row.Obj).NpcID == npc.NpcID)
            {
                selectedRow = row;
            }
        }

        //Update Textbox Values
        if (selectedRow != null)
        {
            selectedRow.ObjectCells[0].Textbox.Text = npc.Name;
            selectedRow.ObjectCells[1].Textbox.Text = npc.Sex;
            selectedRow.ObjectCells[2].Textbox.Text = npc.Race;
            selectedRow.ObjectCells[3].Textbox.Text = npc.Location;
        }

        Session["activeNPC"] = npc;
        dbNpcTable.updateNPC(npc);

        angryLabel.ForeColor = Color.Green;
        angryLabel.Text      = "NPC Saved!";
    }
Пример #7
0
    public void addRow(T newObject, Color color)
    {
        //Make the remaining rows, where each row contains one object from the provided List<T>
        ObjectTableRow objectRow = new ObjectTableRow(newObject, color);

        //Check if Object should be player editable
        bool readOnly = false;

        if (viewOnly && !exceptions.Contains((Object)newObject))
        {
            readOnly = true;
        }

        //Make the individual cells for this object, using the provided parameter Names to obtain the desired values.
        for (int column = 0; column < columns; column++)
        {
            ObjectTableCell objectCell = new ObjectTableCell(objectRow, parameters[column], readOnly);
            objectRow.Cells.Add(objectCell);
            objectRow.ObjectCells.Add(objectCell);
        }
        //Make Delete button if not view only
        if (!viewOnly)
        {
            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);
        if (color == Color.Empty)
        {
            objectRow.Visible = false;
        }
    }
Пример #8
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 ObjectTable(Dictionary <T, Color> objects, string[] parameters, bool viewOnly = false, List <Object> exceptions = null)
    {
        this.columns    = parameters.Length;
        this.colors     = objects;
        this.parameters = parameters;
        this.viewOnly   = viewOnly;
        this.exceptions = exceptions;

        //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();

        for (int i = 0; i < columns; i++)
        {
            TableCell headerColumn = new TableCell();
            Button    sortButton   = new Button();
            sortButton.Text          = parameters[i];
            sortButton.CssClass      = "fullWidth";
            sortButton.OnClientClick = "return sortTable(" + i + ")";

            headerColumn.Controls.Add(sortButton);
            header.Cells.Add(headerColumn);
        }
        this.Rows.Add(header);
        if (colors.Count == 0)
        {
            header.Visible = false;
        }
        else
        {
            header.Visible = true;
        }

        //Make the remaining rows, where each row contains one object from the provided List<T>
        foreach (KeyValuePair <T, Color> entry in colors)
        {
            ObjectTableRow objectRow = new ObjectTableRow(entry.Key, entry.Value);

            //Check if Object should be player editable
            bool readOnly = false;
            if (viewOnly && !exceptions.Contains((Object)entry.Key))
            {
                readOnly = true;
            }

            //Make the individual cells for this object, using the provided parameter Names to obtain the desired values.
            for (int column = 0; column < columns; column++)
            {
                ObjectTableCell objectCell = new ObjectTableCell(objectRow, parameters[column], readOnly);
                objectRow.Cells.Add(objectCell);
                objectRow.ObjectCells.Add(objectCell);
            }
            //Make Delete button if not view only
            if (!viewOnly)
            {
                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);
            if (objectRow.Color == Color.Empty)
            {
                objectRow.Visible = false;
            }
        }
    }
Пример #9
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);
        }
    }
Пример #10
0
    private void loadNPCTable()
    {
        NPCsTable dbNpcTable = new NPCsTable(new DatabaseConnection());

        npcs = dbNpcTable.getGameNPCs(game.GameID);
        String[] parameters = new string[] { "Name", "Sex", "Race", "Location" };

        //Generate Table
        table    = new Table();
        table.ID = "objectTable";
        TableRow header = new TableRow();

        TableCell blankColumn = new TableCell();

        header.Cells.Add(blankColumn);

        //Make Header Columns
        for (int i = 0; i < parameters.Length; i++)
        {
            TableCell headerColumn = new TableCell();
            Button    sortButton   = new Button();
            sortButton.Text          = parameters[i];
            sortButton.CssClass      = "fullWidth";
            sortButton.OnClientClick = "return sortTable(" + (i + 1) + ")";

            headerColumn.Controls.Add(sortButton);
            header.Cells.Add(headerColumn);
        }
        table.Rows.Add(header);

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

        //Make the remaining rows, where each row contains one object from the provided List<T>
        foreach (NPC npc in npcs)
        {
            ObjectTableRow objectRow = new ObjectTableRow(npc, Color.White);

            //Check if Object should be player editable
            bool readOnly = true;

            //Add select radio button
            TableCell   selectCell = new TableCell();
            RadioButton isSelected = new RadioButton();
            isSelected.Attributes.Add("value", npc.NpcID.ToString());
            isSelected.GroupName       = "npcGroup";
            isSelected.AutoPostBack    = true;
            isSelected.CheckedChanged += new EventHandler(npcButton_Click);
            selectCell.Controls.Add(isSelected);
            radioButtons.Add(isSelected);
            objectRow.Controls.Add(selectCell);

            //Make the individual cells for this object, using the provided parameter Names to obtain the desired values.
            for (int column = 0; column < parameters.Length; column++)
            {
                ObjectTableCell objectCell = new ObjectTableCell(objectRow, parameters[column], readOnly);
                objectRow.Cells.Add(objectCell);
                objectRow.ObjectCells.Add(objectCell);
            }

            //Add to table
            table.Rows.Add(objectRow);
            objectRows.Add(objectRow);
            if (objectRow.Color == Color.Empty)
            {
                objectRow.Visible = false;
            }
        }

        NPCTablePlaceHolder.Controls.Add(table);
    }