Ejemplo n.º 1
0
        public Hatchu()
        {
            InitializeComponent();

            listBoxArray = new CastListBoxArray(this);
            comboBoxArray = new CastSelectionBoxArray(this, listBoxArray);
            danceTypeBoxArray = new DanceTypeBoxArray(this);
            textBoxArray = new PieceNameBoxArray(this);
            showOrder = new ShowOrder(this);
            showOrderPosition = new ShowOrderPosition(this);
            castListArray = new List<CastList>();
            solutionList = new List<ShowOrder>();

            listBoxArray[0].Parent = panelContainer;
            comboBoxArray[0].Parent = panelContainer;
            danceTypeBoxArray[0].Parent = panelContainer;
            textBoxArray[0].Parent = panelContainer;

            listBoxArray[0].Visible = false;
            comboBoxArray[0].Visible = false;
            danceTypeBoxArray[0].Visible = false;
            textBoxArray[0].Visible = false;

            pieceNameLbl.Parent = panelContainer;
            danceTypeLbl.Parent = panelContainer;
            castListLbl.Parent = panelContainer;
            castMembersLbl.Parent = panelContainer;

            solutionsContainer.Parent = this;
            solutionsContainer.Location = panelContainer.Location;
            loadingBox.Parent = this;
            loadingBox.Location = new Point(this.Width / 2, this.Height / 2);

            foreach (string item in danceTypeBoxArray[0].Items)
                DanceTypeBoxArray.amountOfTypes.Add(item, 0);

            SwitchVisibility("startup");

            if (!File.Exists("sessions.txt"))
            {
                loadSession.Enabled = false;
            }
        }
Ejemplo n.º 2
0
 private void CopyShowOrderPosition(ShowOrderPosition src, ShowOrderPosition dest)
 {
     for (int i = 0; i < src.Count; i++)
     {
         if (dest.Count > i) dest[i].Clear();
         else
         {
             List<int> temp = new List<int>();
             dest.Add(temp);
         }
         foreach (int item in src[i])
         {
             dest[i].Add(item);
         }
     }
 }
Ejemplo n.º 3
0
        //main backtrack function
        private bool BacktrackSearch()
        {
            if (solutionList.Count >= listThreshold) return true;

            if (solutionFull())
            {
                if (solutionAlreadyFound())
                    return true;

                ShowOrder temp = new ShowOrder(this);
                foreach (int item in showOrder)
                    temp.Add(item);
                addToSolutionList(temp);

                return true;
            }

            //insert the cast list that has the least amount of piece-possiblities but also
            int nextPossible = 0;
            int insertedValue  = insertNextPossible(showOrder.Count, nextPossible);

            while (insertedValue != -1)
            {

                //save the showOrderPosition into temp
                //save the showOrder into temp
                ShowOrderPosition tempShowOrderPosition = new ShowOrderPosition(this);
                ShowOrder tempShowOrder = new ShowOrder(this);
                CopyShowOrderPosition(showOrderPosition, tempShowOrderPosition);
                CopyShowOrder(showOrder, tempShowOrder);

                bool works = insertIntoShowOrder(insertedValue);

                if (works)
                    BacktrackSearch();

                //else return back to previous state
                CopyShowOrderPosition(tempShowOrderPosition, showOrderPosition);
                CopyShowOrder(tempShowOrder, showOrder);

                nextPossible++;
                insertedValue = insertNextPossible(showOrder.Count, nextPossible);

            }

            return false;
        }