예제 #1
0
        private void numberResourceTypes_TextChanged(object sender, EventArgs e)
        {
            mainForm MF = (mainForm)Application.OpenForms[GV.mainFormNumber];              //Gets to mainform level

            int initialY = 60;
            int startingX = 5;
            int maxNumberTypes = GV.maxNumberSubPanels;

            int currentY = initialY;
            int number;
            TextBox TB = sender as TextBox;
            Panel resourcePanel = (Panel)TB.Parent;
            tbInt_TextChanged(sender, e);
            if (TB != null)
            {
                if (int.TryParse(TB.Text, out number))                       //Checks if input is a valid integer
                {
                    for (int i = resourcePanel.Controls.Count - 1; i >= 0; i--)   //This loop removes all panels, note it is independant of the integer check below
                    {
                        Control currentControl = resourcePanel.Controls[i];
                        resourceSubPanel panel = currentControl as resourceSubPanel;
                        if (panel != null)
                        {
                            resourcePanel.Controls.Remove(panel);
                        }
                    }
                    if (number > maxNumberTypes) { number = maxNumberTypes; TB.Text = maxNumberTypes.ToString(); }   //If input number is to big, it is changed to the maximum number
                    if (number == 0)
                    {
                        MF.missionPackage.editMissionGoal("name", GV.defaultValue, "Resource");
                        MF.missionPackage.editMissionGoal("minAmount", GV.defaultValue, "Resource");
                        MF.missionPackage.editMissionGoal("maxAmount", GV.defaultValue, "Resource");
                    }
                    for (int i = 0; i < number; i++)                       //Places the proper amount of panels
                    {
                        resourceSubPanel subPanel = new resourceSubPanel(i);
                        subPanel.Location = new Point(startingX, currentY);
                        resourcePanel.Controls.Add(subPanel);
                        currentY += subPanel.Height + 5;
                    }
                    Panel goalDetailPanel = resourcePanel.Parent as Panel;
                    if (MF != null)
                    {
                        MF.changeGoalPanels(this);
                    }
                    MF.missionPackage.updateValue(resourcePanel, "resourceSubPanel", "", "", number);

                }
            }
        }
예제 #2
0
        private void numberResourceTypes_TextChanged(object sender, EventArgs e)
        {
            int currentY = initialY;
            int number;
            TextBox tb = sender as TextBox;
            intChangeTextBox(tb);
            if (tb != null)
            {
                for (int i = this.Controls.Count - 1; i >= 0; i--)   //This loop removes all panels, note it is independant of the integer check below
                {
                    Control currentControl = this.Controls[i];
                    Panel panel = currentControl as Panel;
                    if (panel != null)
                    {
                        this.Controls.Remove(panel);
                    }
                }
                if (int.TryParse(tb.Text, out number))                       //Checks if input is a valid integer
                {
                    if (number > maxNumberTypes) { number = maxNumberTypes; tb.Text = maxNumberTypes.ToString(); }   //If input number is to big, it is changed to the maximum number

                    for (int i = 0; i < number; i++)                       //Places the propor amount of panels
                    {
                        resourceSubPanel subPanel = new resourceSubPanel(i);
                        subPanel.Location = new Point(startingX, currentY);
                        this.Controls.Add(subPanel);
                        currentY += subPanel.Height + 5;
                    }
                }
            }
            Panel goalDetailPanel = this.Parent as Panel;
            mainForm MAINFORM = goalDetailPanel.Parent as mainForm;               //Gets to mainform level
            if (MAINFORM != null)
            {
                MAINFORM.changeGoalPanels(this);
            }
        }