Example #1
0
        void InitializeComponents()
        {
            DeleteTypeButtonIndex   = 1;
            ApplyChangesButtonIndex = 0;

            this.Size = new Size(WIDTH, HEIGHT);
            Size standard = new Size(150, 20);

            Label manageTypeLabel = new Label();

            manageTypeLabel.Text     = "Manage Tag Type";
            manageTypeLabel.Font     = new Font("Microsoft Sans Serif", 14F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            manageTypeLabel.Size     = new Size(180, 25);
            manageTypeLabel.Location = new Point(xValue + 5, yValue + 5);

            Label typesLabel = new Label();

            typesLabel.Text     = "Tag Types";
            typesLabel.Font     = new Font("Microsoft Sans Serif", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            typesLabel.Size     = standard;
            typesLabel.Location = new Point(xValue + 10, yValue + 35);

            typesList          = new TTTDisplayer <TagType>();
            typesList.Font     = new Font("Microsoft Sans Serif", 11F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            typesList.Size     = new Size(280, 200);
            typesList.Location = new Point(xValue + 10, yValue + 65);

            Label typeNameLabel = new Label();

            typeNameLabel.Text     = "Edit Type Name";
            typeNameLabel.Font     = new Font("Microsoft Sans Serif", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            typeNameLabel.Size     = standard;
            typeNameLabel.Location = new Point(xValue + 10, yValue + 255);

            TextBox newTypeName = new TextBox();

            newTypeName.Font     = new Font("Microsoft Sans Serif", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            newTypeName.Size     = standard;
            newTypeName.Location = new Point(xValue + 10, yValue + 285);

            Label newNsfwLabel = new Label();

            newNsfwLabel.Text     = "Edit NSFW";
            newNsfwLabel.Font     = new Font("Microsoft Sans Serif", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            newNsfwLabel.Size     = new Size(100, 20);
            newNsfwLabel.Location = new Point(xValue + 185, yValue + 255);

            CheckBox newNsfwCheck = new CheckBox();

            newNsfwCheck.Size     = new Size(50, 20);
            newNsfwCheck.Location = new Point(xValue + 220, yValue + 290);

            Button deleteTypeButton = new Button();

            deleteTypeButton.Text      = "Delete Tag";
            deleteTypeButton.ForeColor = Color.Red;
            deleteTypeButton.Font      = new Font("Microsoft Sans Serif", 11F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            deleteTypeButton.Size      = new Size(120, 40);
            deleteTypeButton.Location  = new Point(xValue + 25, yValue + 325);

            Button applyChangesButton = new Button();

            applyChangesButton.Text     = "Apply Changes";
            applyChangesButton.Font     = new Font("Microsoft Sans Serif", 11F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            applyChangesButton.Size     = new Size(120, 40);
            applyChangesButton.Location = new Point(xValue + 160, yValue + 325);


            this.Controls.Add(manageTypeLabel);
            this.Controls.Add(typesLabel);
            this.Controls.Add(typesList);
            this.Controls.Add(typeNameLabel);
            this.Controls.Add(newTypeName);
            this.Controls.Add(newNsfwLabel);
            this.Controls.Add(newNsfwCheck);
            this.Controls.Add(deleteTypeButton);
            this.Controls.Add(applyChangesButton);

            this.Location = new Point(xValue, yValue);

            deleteTypeButton.BringToFront();
            applyChangesButton.BringToFront();

            typesList.SelectedIndexChanged += new EventHandler(typesList_Changed);
            void typesList_Changed(object sender, EventArgs e)
            {
                if (typesList.SelectedIndex != -1)
                {
                    newTypeName.Text     = types[typesList.SelectedIndex].getName();
                    newNsfwCheck.Checked = types[typesList.SelectedIndex].getNsfw();
                }
            }

            deleteTypeButton.Click += new EventHandler(deleteTypeButton_Click);
            void deleteTypeButton_Click(object sender, EventArgs e)
            {
                DialogResult dr = MessageBox.Show("Are you sure you want to delete this type", "Confirmation", MessageBoxButtons.YesNo);

                if (dr == DialogResult.Yes)
                {
                    if (typesList.SelectedIndex != -1)
                    {
                        types.RemoveAt(typesList.SelectedIndex);

                        typesList.ClearSelected();
                        newTypeName.Text     = "";
                        newNsfwCheck.Checked = false;
                    }
                }
            }

            applyChangesButton.Click += new EventHandler(applyChangesButton_Click);
            void applyChangesButton_Click(object sender, EventArgs e)
            {
                DialogResult dr = MessageBox.Show("Are you sure you want to edit this type", "Confirmation", MessageBoxButtons.YesNo);

                if (dr == DialogResult.Yes)
                {
                    if (typesList.SelectedIndex != -1)
                    {
                        TagType tt = new TagType(newTypeName.Text, newNsfwCheck.Checked);
                        types[typesList.SelectedIndex] = tt;

                        typesList.ClearSelected();
                        newTypeName.Text     = "";
                        newNsfwCheck.Checked = false;
                    }
                }
            }
        }