Пример #1
0
        public void Assert_that_percentage_has_two_decimals_when_needed()
        {
            double result   = Uncategorized.GetPercentageXOfY(1111, 10000);
            double expected = 11.11;

            Assert.That(result, Is.EqualTo(expected));
        }
Пример #2
0
        public async Task LoadCustomIcons()
        {
            var brands = new Brands();

            foreach (var prop in typeof(Brands).GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty))
            {
                CustomBrands.Add(new MudIcons(prop.Name, prop.GetValue(brands).ToString(), IconType.Brands));
            }

            CustomAll.AddRange(CustomBrands);

            var fileFormats = new FileFormats();

            foreach (var prop in typeof(FileFormats).GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty))
            {
                CustomFileFormats.Add(new MudIcons(prop.Name, prop.GetValue(fileFormats).ToString(), IconType.FileFormats));
            }

            CustomAll.AddRange(CustomFileFormats);

            var uncategorized = new Uncategorized();

            foreach (var prop in typeof(Uncategorized).GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty))
            {
                CustomUncategorized.Add(new MudIcons(prop.Name, prop.GetValue(uncategorized).ToString(), IconType.Uncategorized));
            }

            CustomAll.AddRange(CustomUncategorized);

            await Task.WhenAll();
        }
Пример #3
0
        public void Assert_that_percentage_is_returned_without_decimals()
        {
            double result   = Uncategorized.GetPercentageXOfY(50, 100);
            double expected = 50;

            Assert.That(result, Is.EqualTo(expected));
        }
Пример #4
0
        public void WriteToXml(XmlWriter writer)
        {
            writer.WriteStartElement(TypeIdString);

            writer.WriteElementString(XmlName_Name, Name);
            writer.WriteElementString(XmlName_Uncategorized, Uncategorized.ToString());
            writer.WriteElementString(XmlName_Hidden, Hidden.ToString());
            writer.WriteElementString(XmlName_VR, VR.ToString());

            foreach (Category c in Allow)
            {
                writer.WriteElementString(XmlName_Allow, c.Name);
            }

            foreach (Category c in Require)
            {
                writer.WriteElementString(XmlName_Require, c.Name);
            }

            foreach (Category c in Exclude)
            {
                writer.WriteElementString(XmlName_Exclude, c.Name);
            }

            writer.WriteEndElement();             // Filter
        }
Пример #5
0
        public void WriteToXml(XmlWriter writer)
        {
            Logger.Info(GlobalStrings.Filter_SavingFilter, Name);

            writer.WriteStartElement(TypeIdString);

            writer.WriteElementString(XmlNameName, Name);

            writer.WriteElementString(XmlNameGame, Game.ToString());
            writer.WriteElementString(XmlNameHidden, Hidden.ToString());
            writer.WriteElementString(XmlNameSoftware, Software.ToString());
            writer.WriteElementString(XmlNameUncategorized, Uncategorized.ToString());
            writer.WriteElementString(XmlNameVR, VR.ToString());

            foreach (Category c in Allow)
            {
                writer.WriteElementString(XmlNameAllow, c.Name);
            }

            foreach (Category c in Require)
            {
                writer.WriteElementString(XmlNameRequire, c.Name);
            }

            foreach (Category c in Exclude)
            {
                writer.WriteElementString(XmlNameExclude, c.Name);
            }

            writer.WriteEndElement();

            Logger.Info(GlobalStrings.Filter_FilterSaveComplete);
        }
Пример #6
0
 private static void CompleteOutcomeSimulation(int totalWeight, int usedWeight, List <int> results)
 {
     //the order of these do matter.
     WeightedNamedOutcome.Outcomes = Uncategorized.AddNothingOutcome(WeightedNamedOutcome.Outcomes, totalWeight, usedWeight);
     WeightedNamedOutcome.Outcomes = ResultAndOutcomeMerger.AssignNumberRangeToOutcomes(WeightedNamedOutcome.Outcomes);
     WeightedNamedOutcome.Outcomes = ResultAndOutcomeMerger.AssignResultsToOutcomes(results, WeightedNamedOutcome.Outcomes);
     WeightedNamedOutcome.Outcomes = Uncategorized.SetMultipleChanceToOccur(WeightedNamedOutcome.Outcomes, totalWeight);
 }
Пример #7
0
 private bool IsTotalWeightHigherOrEqualToUsedWeight()
 {
     if (Decimal.ToInt32(numericUpDownTotalWeight.Value) >= Uncategorized.GetTotalCombinedWeight(WeightedNamedOutcome.Outcomes))
     {
         return(true);
     }
     return(false);
 }
        public SimulationRepresentationForm(int totalWeight, int numberOfRepeats, BindingList <WeightedNamedOutcome> outcomes, List <int> results)
        {
            InitializeComponent();
            listViewSimulationResult.View = View.Details;
            FillListView(outcomes);

            this.totalWeight     = totalWeight;
            this.numberOfRepeats = numberOfRepeats;
            this.totalUsedWeight = Uncategorized.GetTotalCombinedWeight(outcomes);
            InitializeTextValues();
        }
Пример #9
0
        public void Init()
        {
            outcomes.Add(new WeightedNamedOutcome("Stian1", 1, false));
            outcomes.Add(new WeightedNamedOutcome("Stian2", 2, false));
            outcomes.Add(new WeightedNamedOutcome("Stian3", 3, false));
            outcomes.Add(new WeightedNamedOutcome("Stian4", 4, false));
            outcomes.Add(new WeightedNamedOutcome("Stian5", 5, false));
            outcomes.Add(new WeightedNamedOutcome("Stian6", 6, false));
            outcomes.Add(new WeightedNamedOutcome("Stian7", 7, false));
            outcomes.Add(new WeightedNamedOutcome("Stian8", 8, false));
            outcomes.Add(new WeightedNamedOutcome("Stian9", 9, false));
            outcomes.Add(new WeightedNamedOutcome("Stian10", 10, false));

            results.Add(1);
            results.Add(1);

            results.Add(2);
            results.Add(3);

            results.Add(4);
            results.Add(6);

            results.Add(7);
            results.Add(10);

            results.Add(11);
            results.Add(15);

            results.Add(16);
            results.Add(21);

            results.Add(22);
            results.Add(28);

            results.Add(29);
            results.Add(36);

            results.Add(37);
            results.Add(45);

            results.Add(46);
            results.Add(55);

            results.Add(56);
            results.Add(110);

            outcomes = Uncategorized.AddNothingOutcome(outcomes, totalWeight, Uncategorized.GetTotalCombinedWeight(outcomes));
            outcomes = ResultAndOutcomeMerger.AssignNumberRangeToOutcomes(outcomes);
        }
Пример #10
0
        private void ButtonGenerate_Click(object sender, EventArgs e)
        {
            ResetSimulationData();

            if (!IsTotalWeightHigherOrEqualToUsedWeight())
            {
                MessageBox.Show("The total weight must be higher than or equal to the weight used by your outcomes.", "Weight not legal(get a lawyer)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int totalWeight     = Decimal.ToInt32(numericUpDownTotalWeight.Value);
            int numberOfRepeats = Decimal.ToInt32(numericUpDownNumberOfRounds.Value);
            int usedWeight      = Uncategorized.GetTotalCombinedWeight(WeightedNamedOutcome.Outcomes);

            List <int> results = GetResults(totalWeight, numberOfRepeats);

            CompleteOutcomeSimulation(totalWeight, usedWeight, results);

            SimulationRepresentationForm simulationRepresentationForm =
                new SimulationRepresentationForm(totalWeight, numberOfRepeats, WeightedNamedOutcome.Outcomes, results);

            simulationRepresentationForm.Show();
        }
Пример #11
0
 public void UpdateCurrentUsedWeight()
 {
     //keep up-to-date
     textBoxCurrentUsedWeight.Text = "Current used weight: " + Uncategorized.GetTotalCombinedWeight(WeightedNamedOutcome.Outcomes);
 }
Пример #12
0
 private void ResetSimulationData()
 {
     Uncategorized.ResetAllOccurances(WeightedNamedOutcome.Outcomes);
 }