Ejemplo n.º 1
0
        //this method creates all the buttons and labels necessary for tag creation
        void InitializeComponents()
        {
            this.TypeButtonIndex = 0;
            this.TagButtonIndex  = 1;

            //many controls here use these dimensions, so this just makes it quicker
            Size standard = new Size(130, 20);

            //sets the TagCreators dimensions to whatever is put in those big global variables
            this.Size = new Size(WIDTH, HEIGHT);

            //all this is boring and kinda obvious so like...
            Label heading = new Label();

            heading.Text     = "Create New Tag";
            heading.Size     = new Size(150, 25);
            heading.Font     = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            heading.Location = new Point(xValue + 5, yValue + 5);

            Label tagNameLabel = new Label();

            tagNameLabel.Text     = "Tag Name";
            tagNameLabel.Size     = standard;
            tagNameLabel.Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            tagNameLabel.Location = new Point(xValue + 10, yValue + 40);

            TextBox tagNameTextBox = new TextBox();

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

            Label tagTypeLabel = new Label();

            tagTypeLabel.Text     = "Tag Type";
            tagTypeLabel.Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            tagTypeLabel.Size     = standard;
            tagTypeLabel.Location = new Point(xValue + 10, yValue + 100);

            //keep scrolling
            tagTypeBox               = new ComboBox();
            tagTypeBox.Size          = standard;
            tagTypeBox.Font          = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            tagTypeBox.Location      = new Point(xValue + 10, yValue + 130);
            tagTypeBox.DropDownStyle = ComboBoxStyle.DropDownList;

            Label createTypeLabel = new Label();

            createTypeLabel.Text     = "Create New Type";
            createTypeLabel.Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            createTypeLabel.Size     = standard;
            createTypeLabel.Location = new Point(xValue + 10, yValue + 165);

            Label typeNameLabel = new Label();

            typeNameLabel.Text     = "Tag Type Name";
            typeNameLabel.Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            typeNameLabel.Size     = standard;
            typeNameLabel.Location = new Point(xValue + 15, yValue + 200);

            //halfway there buddy
            TextBox typeNameBox = new TextBox();

            typeNameBox.Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            typeNameBox.Size     = standard;
            typeNameBox.Location = new Point(xValue + 15, yValue + 230);

            CheckBox typeNsfw = new CheckBox();

            typeNsfw.Text     = "Set Type as NSFW";
            typeNsfw.Font     = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            typeNsfw.Size     = new Size(155, 25);
            typeNsfw.Location = new Point(xValue + 15, yValue + 260);

            Button createTypeButton = new Button();

            createTypeButton.Text     = "Create Type";
            createTypeButton.Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            createTypeButton.Size     = new Size(150, 30);
            createTypeButton.Location = new Point(xValue + 15, yValue + 290);

            Label tagColorLabel = new Label();

            tagColorLabel.Text     = "Tag Color";
            tagColorLabel.Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            tagColorLabel.Size     = new Size(80, 20);
            tagColorLabel.Location = new Point(xValue + 10, yValue + 350);

            //almost there - but check my fancy ColorPicker class
            ColorPicker tagColorPicker = new ColorPicker();

            tagColorPicker.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            //apparently a ComboBox's height is based on font size...not the Size property
            //it took me a while to find that out...
            tagColorPicker.Width    = 40;
            tagColorPicker.Location = new Point(xValue + 110, yValue + 350);

            CheckBox tagNsfw = new CheckBox();

            tagNsfw.Text     = "Set Tag as NSFW";
            tagNsfw.Font     = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            tagNsfw.Size     = new Size(170, 25);
            tagNsfw.Location = new Point(xValue + 10, yValue + 380);

            Button createTagButton = new Button();

            createTagButton.Text     = "Create Tag";
            createTagButton.Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            createTagButton.Size     = new Size(135, 30);
            createTagButton.Location = new Point(xValue + 20, yValue + 420);

            //and this blob just adds all the controls to the TagControl, so you can see them and stuff
            this.Controls.Add(heading);
            this.Controls.Add(tagNameLabel);
            this.Controls.Add(tagNameTextBox);
            this.Controls.Add(tagTypeLabel);
            this.Controls.Add(tagTypeBox);
            this.Controls.Add(createTypeLabel);
            this.Controls.Add(typeNameLabel);
            this.Controls.Add(typeNameBox);
            this.Controls.Add(typeNsfw);
            this.Controls.Add(createTypeButton);
            this.Controls.Add(tagColorLabel);
            this.Controls.Add(tagColorPicker);
            this.Controls.Add(tagNsfw);
            this.Controls.Add(createTagButton);

            //places the TagCreator to wherever the x and y are
            this.Location = new Point(xValue, yValue);

            createTagButton.BringToFront();
            createTypeButton.BringToFront();

            createTypeButton.Click += new EventHandler(createTypeButton_Click);
            void createTypeButton_Click(object sender, EventArgs e)
            {
                //actual input validation needed
                if (typeNameBox.Text != null) //make sure name is valid
                {
                    createdType = new TagType(typeNameBox.Text, typeNsfw.Checked);
                }
                else
                {
                    MessageBox.Show("u messed up homeslice");
                }
            }

            createTagButton.Click += new EventHandler(createTagButton_Click);
            void createTagButton_Click(object sender, EventArgs e)
            {
                //actual input validation needed
                if (tagNameTextBox.Text != null)        //make sure name is valid
                {
                    if (tagTypeBox.SelectedIndex != -1) //if theres a tagtype
                    {
                        int index = -1;
                        for (int i = 0; i < types.Count; i++)
                        {
                            if (types[i].getName() == (string)tagTypeBox.SelectedItem)
                            {
                                index = i;
                            }
                        }
                        createdTag = new Tag(tagNameTextBox.Text, tagColorPicker.getColor(), types[index], tagNsfw.Checked);
                    }
                    else // if there aint no tagtype
                    {
                        createdTag = new Tag(tagNameTextBox.Text, tagColorPicker.getColor(), tagNsfw.Checked);
                    }
                }
                else
                {
                    MessageBox.Show("u messed up homeslice");
                }
            }
        }
Ejemplo n.º 2
0
        void InitializeComponents()
        {
            DeleteTagButtonIndex    = 1;
            ApplyChangesButtonIndex = 0;

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

            Label manageTagsLabel = new Label();

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

            Label tagsLabel = new Label();

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

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

            Label tagNameLabel = new Label();

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

            TextBox newTagName = new TextBox();

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

            Label newTagType = new Label();

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

            ComboBox tagTypeCombo = new ComboBox();

            tagTypeCombo.Font     = new Font("Microsoft Sans Serif", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            tagTypeCombo.Width    = 150;
            tagTypeCombo.Location = new Point(xValue + 10, yValue + 345);

            Label editColorLabel = new Label();

            editColorLabel.Text     = "Edit Color";
            editColorLabel.Font     = new Font("Microsoft Sans Serif", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            editColorLabel.Size     = new Size(80, 20);
            editColorLabel.Location = new Point(xValue + 190, yValue + 255);

            ColorPicker newTagColor = new ColorPicker();

            newTagColor.Font     = new Font("Microsoft Sans Serif", 9.5F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            newTagColor.Width    = 40;
            newTagColor.Location = new Point(xValue + 205, yValue + 285);

            Label newNsfw = new Label();

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

            CheckBox newNsfwCheck = new CheckBox();

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

            Button deleteTagButton = new Button();

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

            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 + 385);

            this.Controls.Add(manageTagsLabel);
            this.Controls.Add(tagsLabel);
            this.Controls.Add(tagsList);
            this.Controls.Add(tagNameLabel);
            this.Controls.Add(newTagName);
            this.Controls.Add(newTagType);
            this.Controls.Add(tagTypeCombo);
            this.Controls.Add(editColorLabel);
            this.Controls.Add(newTagColor);
            this.Controls.Add(newNsfw);
            this.Controls.Add(newNsfwCheck);
            this.Controls.Add(deleteTagButton);
            this.Controls.Add(applyChangesButton);

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

            deleteTagButton.BringToFront();
            applyChangesButton.BringToFront();

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

                if (dr == DialogResult.Yes)
                {
                    if (tagsList.SelectedIndex != -1)
                    {
                        tags.RemoveAt(tagsList.SelectedIndex);

                        tagsList.ClearSelected();
                        newTagName.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 tag", "Confirmation", MessageBoxButtons.YesNo);

                if (dr == DialogResult.Yes)
                {
                    if (tagsList.SelectedIndex != -1)
                    {
                        if (tagTypeCombo.SelectedIndex != -1)
                        {
                            Tag t = new Tag(newTagName.Text, newTagColor.getColor(), types[tagTypeCombo.SelectedIndex], newNsfwCheck.Checked);
                        }
                    }
                }
            }
        }