コード例 #1
0
        public ParticipatorsContainer Prepare()
        {
            string[] objectsDirectory = Directory.GetFiles(@"C:\Users\Пользователь\source\repos\ComparerApp\ComparerApp.Library\Comparer_Pictures");

            if (objectsDirectory == null)
            {
                throw new DirectoryNotFoundException();
            }

            ParticipatorsContainer container = new ParticipatorsContainer();

            container.Capacity = objectsDirectory.Length;

            if ((Math.Log2((double)container.Capacity) % 1) != 0)
            {
                throw new ComparerValidityException("The amount of files in your Directory is not a number that represents number 2 raised to some power.\nCannot procede.");
            }

            foreach (string item in objectsDirectory)
            {
                ObjectParticipator participator = new ObjectParticipator();
                participator.FileDirectory = item;
                participator.FileName      = Path.GetFileNameWithoutExtension(item);
                container.ObjectsArray.Add(participator);
            }
            return(container);
        }
コード例 #2
0
        public ObjectParticipator MakeDecision(string fileName, Round round, ParticipatorsContainer container)
        {
            ObjectParticipator choosenObject = round.Pairs[0].Find(i => i.FileName.ToLower() == fileName.ToLower());

            round.Pairs.Remove(round.Pairs[0]);
            round.RoundNumber++;
            container.NextRoundObjectsArray.Add(choosenObject);
            container.RemainderOfInitialCapacity--;

            return(choosenObject);
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: TheNoice/ComparerApp
        private void AnyPictureBox_Click(object sender, EventArgs e)
        {
            ThePreviousState.InitializePreviousState(PRound, PContainer);

            PictureBox         tmp           = (PictureBox)sender;
            string             choice        = tmp.Name;
            ObjectParticipator choosedObject = DecisionManager.MakeDecision(choice, PRound, PContainer);

            ThePreviousState.UpdateObjectsLists(choosedObject);

            if (DecisionManager.CheckWinCondition(PContainer))
            {
                MessageBox.Show($"The winner is {PContainer.NextRoundObjectsArray[0].FileName}!\nNow the program will restart the survey.");
                DrawInitialState(Preparator);
            }

            PRound = DecisionManager.CreateNewRoundIfNeeded(PRound, PContainer);
            UpdatePicturesAndLabels();
        }
コード例 #4
0
 public void UpdateObjectsLists(ObjectParticipator choosedObject)
 {
     ChoosedObjects.Add(choosedObject);
     ExcludedObjects.Remove(choosedObject);
 }