public void VisaData(IList<AktivPeriod> perioder)
        {
            panel1.Controls.Clear();
            double pixlarPerDygn = 1000;// (double)panel1.Width;

            var förstaTimme = perioder.OrderBy(o => o.Starttid.Hour).FirstOrDefault().Starttid.Hour;
            var sistaTimme = perioder.OrderBy(o => o.Starttid.Hour).LastOrDefault().Starttid.Hour;

            var daghöjd = 30;
            var marginal = 10;
            var vänsterMarginal = 120;
            var minutlängd = (pixlarPerDygn - vänsterMarginal) / (sistaTimme - förstaTimme) / 60; // pixlarPerDygn / 24 / 60;
            var position = 0;
            for (int timme = förstaTimme; timme <= sistaTimme; timme++)
            {
                var timstreck = new TimMarkering(timme);
                timstreck.Top = 0;
                timstreck.Left = (int)(position * minutlängd * 60) + vänsterMarginal;
                panel1.Controls.Add(timstreck);
                position++;

            }

            var y = marginal + daghöjd;

            foreach (var period in perioder.OrderByDescending(o => o.Starttid).GroupBy(o => o.Starttid.Date).Select(o =>
                new
                {
                    Datum = o.Key,
                    Perioder = o
                }))
            {
                var daglabel = new Label();
                daglabel.Top = y;
                daglabel.Left = marginal;
                daglabel.Text = period.Datum.ToString("dddd, d MMM");
                panel1.Controls.Add(daglabel);

                foreach (var item in period.Perioder)
                {
                    var aktivitet = new Aktivitetsmarkering(item);
                    aktivitet.BackColor = System.Drawing.Color.Blue;
                    aktivitet.Top = y;
                    aktivitet.Height = daghöjd;
                    aktivitet.Width = (int)(minutlängd * item.Tidsmängd.TotalMinutes);
                    if (aktivitet.Width == 0) aktivitet.Width = 1;
                    aktivitet.Left = (int)(item.Starttid.Subtract(period.Datum).TotalMinutes * minutlängd) + vänsterMarginal - (int)(förstaTimme * 60 * minutlängd);
                    panel1.Controls.Add(aktivitet);

                }
                y += daghöjd + marginal;
            }
        }
Example #2
1
 /// <summary>
 /// Sorts the object collection by object Type, then by name of object.
 /// This makes for an easy compare of two different memory snapshots
 /// </summary>
 /// <returns></returns>
 public static IList<Object> Sort(IList<Object> unSorted)
 {
     if (unSorted == null)
         return null;
     IList<Object> sorted = unSorted.OrderBy(x => x.GetType().ToString()).ThenBy(x => x.name).ToList();
     return sorted;
 }
        public void GuardarAsignaciones(IList<int> ordenesVenta, IList<Usuario> asistentes)
        {
            try
            {
                var transactionOptions = new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted };

                using (var transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
                {
                    foreach (var idOrdenVenta in ordenesVenta)
                    {
                        var ordenVenta = _orderVentaDA.ObtenerPorID(idOrdenVenta);

                        var asistenteConMenorCarga = asistentes.OrderBy(p => p.CantidadOV).FirstOrDefault();

                        if (asistenteConMenorCarga != null)
                        {
                            asistenteConMenorCarga.CantidadOV++;

                            ordenVenta.Estado = Constantes.EstadoOrdenVenta.Asignado;
                            ordenVenta.AsistentePlaneamiento = asistenteConMenorCarga;

                            _orderVentaDA.AsignarAsistentePlaneamiento(ordenVenta);
                        }
                    }

                    transactionScope.Complete();
                }
            }
            catch (Exception ex)
            {
                throw ThrowException(ex, MethodBase.GetCurrentMethod().Name);
            }
        }
Example #4
1
        private IList<IPriceValue> GetDiscountPrices(IList<IPriceValue> prices, MarketId marketId, Currency currency)
        {
            currency = GetCurrency(currency, marketId);

            var priceValues = new List<IPriceValue>();
            
            _promotionHelper.Reset();
            
            foreach (var entry in GetEntries(prices))
            {
                var price = prices
                    .OrderBy(x => x.UnitPrice.Amount)
                    .FirstOrDefault(x => x.CatalogKey.CatalogEntryCode.Equals(entry.Code) &&
                        x.UnitPrice.Currency.Equals(currency));
                if (price == null)
                {
                    continue;
                }

                priceValues.Add(_promotionEntryService.GetDiscountPrice(
                    price, entry, currency, _promotionHelper));
                
            }
            return priceValues;
        }
Example #5
1
        /// <summary>
        /// Exports the provided questions in CSV format: category,question,answer
        /// </summary>
        /// <param name="questions"></param>
        /// <returns></returns>
        public static string Export(IList<Question> questions)
        {
            StringBuilder builder = new StringBuilder();

            foreach (Question question in questions.OrderBy(q => q.Category.Name))
            {
            #if LOGGING
                builder.AppendLine(string.Format("{0},{1},{2},{3}",
                    question.Category.Name.Replace(",", "~"),
                    question.Title.Replace(",", "~"),
                    question.Answer.Replace(",", "~"),
                    question.NextAskOn.ToShortDateString())
                    );
            #else

                builder.AppendLine(string.Format("{0},{1},{2}",
                    question.Category.Name.Replace(",","~"),
                    question.Title.Replace(",","~"),
                    question.Answer.Replace(",","~"))
                    );
            #endif
            }

            return builder.ToString();
        }
Example #6
1
        protected void Page_Init(object sender, EventArgs e)
        {
            Drugs = Lib.Data.Drug.FindAll();
            SelectedDrugs = Lib.Systems.Lists.GetMyDrugs();
            AvailableDrugs = new List<Lib.Data.Drug>();

            foreach (var d in Drugs)
            {
                bool found = false;
                for (int i = 0; i < SelectedDrugs.Count; i++)
                {
                    if (d.ID.Value == SelectedDrugs[i].ID.Value)
                    {
                        found = true;
                        break;
                    }
                }

                if (found)
                    continue;

                AvailableDrugs.Add(d);
            }
            SelectedDrugs = SelectedDrugs.OrderBy(l => l.GenericName).ToList();
            AvailableDrugs = AvailableDrugs.OrderBy(l => l.GenericName).ToList();
            Eocs = _complianceSvc.GetEocs().ToList();
        }
Example #7
1
        /// <summary>
        /// Returns the next machine to schedule.
        /// </summary>
        /// <param name="next">Next</param>
        /// <param name="choices">Choices</param>
        /// <param name="current">Curent</param>
        /// <returns>Boolean</returns>
        public virtual bool TryGetNext(out MachineInfo next, IList<MachineInfo> choices, MachineInfo current)
        {
            var machines = choices.OrderBy(mi => mi.Machine.Id.Value).ToList();

            var currentMachineIdx = machines.IndexOf(current);
            var orderedMachines = machines.GetRange(currentMachineIdx, machines.Count - currentMachineIdx);
            if (currentMachineIdx != 0)
            {
                orderedMachines.AddRange(machines.GetRange(0, currentMachineIdx));
            }

            var availableMachines = orderedMachines.Where(
                mi => mi.IsEnabled && !mi.IsBlocked && !mi.IsWaiting).ToList();
            if (availableMachines.Count == 0)
            {
                next = null;
                return false;
            }

            int idx = 0;
            while (this.RemainingDelays.Count > 0 && this.ExploredSteps == this.RemainingDelays[0])
            {
                idx = (idx + 1) % availableMachines.Count;
                this.RemainingDelays.RemoveAt(0);
                IO.PrintLine("<DelayLog> Inserted delay, '{0}' remaining.", this.RemainingDelays.Count);
            }

            next = availableMachines[idx];

            this.ExploredSteps++;

            return true;
        }
Example #8
1
    internal static void MainSlow()
    {
        // Sets the Console to read from string
        //Console.SetIn(new StringReader(Test001));

        int n = int.Parse(Console.ReadLine());
        frames = new List<int[]>(n);
        perm = new int[n][];
        used = new bool[n];
        for (int i = 0; i < n; i++)
        {
            var frame = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            if (frame.Length != 2)
            {
                throw new ArgumentException("Frames must have two dimensions!");
            }
            frames.Add(frame);
        }

        frames = frames.OrderBy(f => f[0]).ThenBy(f => f[1]).ToList();

        Permutate(0, n);
        Console.WriteLine(count);
        Console.WriteLine(string.Join(Environment.NewLine, allPerms.OrderBy(f => f)));
    }
Example #9
1
        /// <summary>
        /// Benchmarks and compares the execution time stats of the given algorithms.
        /// </summary>
        /// <param name="numberOfIterations">The number of iterations to run.</param>
        /// <param name="reportIndividualIterations">
        /// <para>If set to <c>true</c>, reports individual iteration stats; if <c>false</c>, reports average iteration stats.</para>
        /// <para>If the algorithm runs really fast, the floating point calculations will come out to zero, so you will want to set this to <c>false</c>.</para>
        /// </param>
        /// <param name="algorithms">The algorithms to compare.</param>
        /// <returns>The list of algorithms, sorted from fastest to slowest, with their <see cref="Algorithm.ExecutionTime"/> property set.</returns>
        public static IList<Algorithm> CompareExecutionTime(int numberOfIterations, bool reportIndividualIterations, IList<Algorithm> algorithms)
        {
            if (algorithms == null || !algorithms.Any())
            {
                throw new ArgumentNullException("algorithms");
            }

            foreach (Algorithm algorithm in algorithms)
            {
                ("Running " + algorithm.Name).Dump();
                algorithm.BenchmarkAndCacheExecutionTime(numberOfIterations, reportIndividualIterations);
                "\tDone".Dump();
            }

            "".Dump();
            ("Total iterations: " + numberOfIterations.ToString("n0")).Dump();
            "".Dump();

            algorithms = algorithms.OrderBy(algorithm => algorithm.ExecutionTime.Average).ToList();

            for (int i = 0; i < algorithms.Count; i++)
            {
                DumpAlgorithmStats(algorithms[i], i + 1 < algorithms.Count ? algorithms[i + 1] : null, reportIndividualIterations);
            }

            return algorithms;
        }
Example #10
0
 /// <summary>
 ///     Bir kelimenin çözümleri ile aranan çözümlerin aynı sayıda ve bire bir aynı
 ///     olup olmadığını kontrol eder. Aranan çözümlerin hangi sırada verildiği önemli değildir.
 /// </summary>
 /// <param name="token">kelime</param>
 /// <param name="expectedAnalyses">aranan ve olması gereken çözümlerin tamamı</param>
 public static void AllAnalysesEqual(string token, IList<string> expectedAnalyses)
 {
     IList<Word> words = Analyzer.Analyze(token);
     IList<string> actualAnalyses = words.Select(word => word.Analysis).ToList();
     bool equalIgnoreOrder = actualAnalyses.OrderBy(t => t).SequenceEqual(expectedAnalyses.OrderBy(t => t));
     Assert.True(equalIgnoreOrder);
 }
Example #11
0
        void AssertEquals(IList<IList<int>> firstList, IList<IList<int>> secondList)
        {
            Assert.AreEqual(firstList.Count(), secondList.Count());

            firstList = firstList
                .OrderBy(list => list[0])
                .ThenBy(list => list[1])
                .ThenBy(list => list[2])
                .ToList();

            secondList = secondList
                .OrderBy(list => list[0])
                .ThenBy(list => list[1])
                .ThenBy(list => list[2])
                .ToList();

            Assert.IsTrue(firstList
                .Zip(secondList
                    , (firstSubList, secondeSubList) =>
                        firstSubList
                            .Zip(secondeSubList
                                , (first, second) =>
                                    first == second)
                            .All(item => item))
                .All(item => item)); ;
        }
Example #12
0
        public ZapperProcessor(FileZapperSettings settings = null, IList<IZapperPhase> phases = null)
        {
            _log.Info("Initializing");

            ZapperFiles = new ConcurrentDictionary<string, ZapperFile>();
            ZapperFilesDeleted = new ConcurrentDictionary<string, ZapperFileDeleted>();

            if (settings == null)
            {
                settings = new FileZapperSettings();
                settings.Load();
            }
            Settings = settings;

            if (phases != null)
            {
                foreach (var phase in phases) { phase.ZapperProcessor = this; }
                _phases = phases.OrderBy(x => x.PhaseOrder);
            }
            else
            {
                List<IZapperPhase> allphases = new List<IZapperPhase>();
                allphases.Add(new PhaseCleanup { PhaseOrder = 1, ZapperProcessor = this, IsInitialPhase = true });
                allphases.Add(new PhaseParseFilesystem { PhaseOrder = 2, ZapperProcessor = this });
                allphases.Add(new PhaseCalculateSamples { PhaseOrder = 3, ZapperProcessor = this });
                allphases.Add(new PhaseCalculateHashes { PhaseOrder = 4, ZapperProcessor = this });
                allphases.Add(new PhaseRemoveDuplicates { PhaseOrder = 5, ZapperProcessor = this });
                _phases = allphases.OrderBy(x => x.PhaseOrder);
            }
        }
        public void Init(dynamic pedal, IList<ToolkitKnob> knobs)
        {
            var sortedKnobs = knobs.OrderBy(k => k.Index).ToList();
            tableLayoutPanel.RowCount = knobs.Count;
            for (var i = 0; i < sortedKnobs.Count; i++)
            {
                var knob = sortedKnobs[i];
                var label = new Label();
                tableLayoutPanel.Controls.Add(label, 0, i);
                if (knob.Name != null)
                {
                    var name = knob.Name;
                    var niceName = nameParser.Match(name);
                    if(niceName.Groups.Count > 1) {
                        name = niceName.Groups[1].Value;
                    }
                    label.Text = name;
                }
                label.Anchor = AnchorStyles.Left;

                var numericControl = new NumericUpDownFixed();
                tableLayoutPanel.Controls.Add(numericControl, 1, i);
                numericControl.DecimalPlaces = 2;
                numericControl.Minimum = (decimal)knob.MinValue;
                numericControl.Maximum = (decimal)knob.MaxValue;
                numericControl.Increment = (decimal)knob.ValueStep;                
                numericControl.Value = Math.Min((decimal)pedal.KnobValues[knob.Key], numericControl.Maximum);
                numericControl.ValueChanged += (obj, args) =>
                    pedal.KnobValues[knob.Key] = (float)Math.Min(numericControl.Value, numericControl.Maximum);
            }
        }
        public frmRefundTypeMappings(IList<RefundTypeMappingDTO> refundMappingTypeDTOs)
        {
            InitializeComponent();

            checkBoxIssueRefundCheck.DataBindings.Add(new Binding("Checked", refundTypeMappingDTOBindingSource, "IssueCheck", true, DataSourceUpdateMode.OnPropertyChanged));
            checkBoxEnabled.DataBindings.Add(new Binding("Checked", refundTypeMappingDTOBindingSource, "Enabled", true, DataSourceUpdateMode.OnPropertyChanged));
            checkBoxIssueRefundCheck.DataBindings.Add(new Binding("Enabled", refundTypeMappingDTOBindingSource, "Enabled", true, DataSourceUpdateMode.OnPropertyChanged));

            comboBoxCheckRecipient.DataBindings.Add(new Binding("Enabled", refundTypeMappingDTOBindingSource, "EnableCheckField", true, DataSourceUpdateMode.OnPropertyChanged));
            comboBoxCheckRecipient.DataBindings.Add(new Binding("SelectedItem", refundTypeMappingDTOBindingSource, "RefundCheckRecipient"));

            comboBoxQBFrom.DataBindings.Add(new Binding("Enabled", refundTypeMappingDTOBindingSource, "EnableFromField", true, DataSourceUpdateMode.OnPropertyChanged));
            comboBoxQBPaymentType.DataBindings.Add(new Binding("Enabled", refundTypeMappingDTOBindingSource, "EnableQuickbooksPayTypeField", true, DataSourceUpdateMode.OnPropertyChanged));
            comboBoxQBIncomeAccount.DataBindings.Add(new Binding("Enabled", refundTypeMappingDTOBindingSource, "Enabled", true, DataSourceUpdateMode.OnPropertyChanged));
            comboBoxRefundBankAccount.DataBindings.Add(new Binding("Enabled", refundTypeMappingDTOBindingSource, "EnableBankAccountField", true, DataSourceUpdateMode.OnPropertyChanged));

            comboBoxCheckRecipient.DataSource = Enum.GetValues(typeof(RefundCheckRecipient));

            Configuration configuration = UserSettings.getInstance().Configuration;
            quickbooksPaytypeBindingSource.DataSource = configuration.QuickbooksPaytypes;
            quickbooksCustomerBindingSource.DataSource = configuration.QuickbooksCustomers;
            quickbooksIncomeAccountBindingSource.DataSource = configuration.QuickbooksIncomeAccounts;
            quickbooksBankAccountBindingSource.DataSource = configuration.QuickbooksBankAccounts;
            refundTypeMappingDTOBindingSource.DataSource = refundMappingTypeDTOs.OrderBy(x => x.EaglesoftAdjustment);
        }
        public ProductViewModel(Product product, IList<Category> categories)
            : this()
        {
            this.ProductId = product.Id;
            this.ProductGuid = product.Guid;
            this.Code = product.Code;
            this.Title = product.Title;
            this.Description = product.Description;
            this.Keywords = product.Keywords;
            this.Cost = product.Cost;
            this.Type = product.Type;
            this.IsFeatured = product.IsFeatured;
            this.ImageUrls = product.Images.Select(o => new ProductImageViewModel(o)).ToList();

            foreach (Category category in categories.OrderBy(o => o.DisplayName))
            {
                CategoryViewModel categoryViewModel = new CategoryViewModel(category);
                categoryViewModel.Selected = product.Categories.Any(o => o.Id == category.Id);

                foreach(var child in category.Children)
                {
                    categoryViewModel.Children.First(o => o.Id == child.Id).Selected = product.Categories.Any(o => o.Id == category.Id && o.Children.Any(x => x.Id == child.Id));
                }

                this.Categories.Add(categoryViewModel);
            }
        }
Example #16
0
 public IList<NameModel> SortNameByLastAndFirstName(IList<NameModel> unsortedNames)
 {
     if (unsortedNames != null && unsortedNames.Count > 0)
     {
         return unsortedNames.OrderBy(n => n.LastName).ThenBy(n => n.FirstName).ToList();
     }
     return null;
 }
 public FieldsGenerator(ModelBase model, IList<Field> fields, string padding = "")
     : base(model)
 {
     foreach (Field field in fields.OrderBy(x => x.Name))
     {
         GenerateField(field, padding);
     }
 }
Example #18
0
 public void CreateFileFromList(string baseFilename, IList<int> markers)
 {
     var markerFile = GetMarkerFilename(baseFilename);
     using (var sw = File.CreateText(markerFile))
     {
         foreach (var mark in markers.OrderBy(x => x))
             sw.WriteLine(mark.ToString());
     }
 }
        private void CarregarPrimeiroAcesso()
        {
            txtNome.Focus();

            ListGrupoVisao = new ManterGrupoVisao().GetAll();

            grdGrupoVisoes.DataSource = ListGrupoVisao.OrderBy(l => l.Nome).ToList();
            grdGrupoVisoes.DataBind();
        }
 /// <summary>
 /// Employee View Model Constructor. 
 /// Will load all employees from excel
 /// </summary>
 public EmployeeViewModel()
 {
     RMA_Roots.AppConfig.LoadAppConfiguration("EmployeeOverview");
     _sitzplanSource = new BitmapImage(new Uri(@"D:\sitzplan.png"));
     var import = new Import();
     _employees = import.Employees;
     _employees = _employees.OrderBy(f => f.Vorname).ToList();
     _showSeatingVisibility = Visibility.Hidden;
 }
        public void Carregar(IList<TicketDeOrcamentoPessoal> ticketsDeOrcamentoPessoal)
        {
            TodosOsTicketsCadastrados = ticketsDeOrcamentoPessoal;

            rptTickets.DataSource = ticketsDeOrcamentoPessoal.OrderBy(x => x.Descricao);
            rptTickets.DataBind();

            CarregarAcordoConvencao();
        }
 public void FormOrgList(IList<MyJobLeads.DomainModel.Entities.Organization> Organizations)
 {
     OrganizationList = Organizations
         .OrderBy(x => x.Name)
         .Select(x => new SelectListItem
     {
         Text = x.Name,
         Value = x.Id.ToString()
     }).ToList();
 }
Example #23
0
 public void Insert(IList<string> values)
 {
     if (values != null && values.Count > 0)
     {
         foreach (string str in values.OrderBy(i => i))
         {
             flow.Controls.Add(NewLabel(str));
         }
     }
 }
        public void SaveAllProperties(IList<KeyValuePair<string, object>> output)
        {
            IEnumerable<KeyValuePair<string, object>> sorted = output.OrderBy(kvp => kvp.Key);
            this.properties = sorted.ToList();

            foreach (var item in output)
            {
                this.LoadProperty(item.Key, item.Value.ToString());
            }
        }
Example #25
0
        public void Init()
        {
            _organizations = new List<Organization> {
                new Organization{ Id = 1, Name = "Pos #1", StatusId = (byte)Status.Approved, ParentId = 0, CreatedAt = DateTime.Now },
                new Organization{ Id = 2, Name = "Pos #2", StatusId = (byte)Status.Approved, ParentId = 0, CreatedAt = DateTime.Now },
            };

            Organization pos1 = _organizations.OrderBy(x => x.Id).First();
            Organization pos2 = _organizations.OrderBy(x => x.Id).Skip(1).First();
            _categories = new List<Category> {
                new Category { Id = 2, Name = "Light alcohol", OrganizationId = pos1.Id, ParentId = 0, StatusId = (byte)Status.Approved, CategoryTypeId = 1 },
                new Category { Id = 2, Name = "Food", OrganizationId = pos1.Id, ParentId = 0, StatusId = (byte)Status.Approved, CategoryTypeId = 1 },
                new Category { Id = 3, Name = "Men shoes", OrganizationId = pos2.Id, ParentId = 0, StatusId = (byte)Status.Approved, CategoryTypeId = 1 },
                new Category { Id = 4, Name = "Women shoes", OrganizationId = pos2.Id, ParentId = 0, StatusId = (byte)Status.Approved, CategoryTypeId = 1 },
                new Category { Id = 5, Name = "Children shoes", OrganizationId = pos2.Id, ParentId = 0, StatusId = (byte)Status.Approved, CategoryTypeId = 1 }
            };

            Category lightAlcohol = _categories.First(x => x.Name.Contains("Light alcohol"));
            Category food = _categories.First(x => x.Name.Equals("Food"));
            _products = new List<Product> {
                    new Product { Id = 1, CategoryId = lightAlcohol.Id, InternalCode = "internal_001", Name = "Beer", PosId = pos1.Id, Price = 10m, StatusId = (byte)Status.Approved, Uid = "uid_0001", UserId = "TestUser", CreatedAt = DateTime.Now },
                    new Product { Id = 2, CategoryId = food.Id, InternalCode = "internal_002", Name = "Cheese", PosId = pos1.Id, Price = 15m, StatusId = (byte)Status.Approved, Uid = "uid_0002", UserId = "TestUser", CreatedAt = DateTime.Now },
                    new Product { Id = 3, CategoryId = lightAlcohol.Id, InternalCode = "internal_003", Name = "Beer light", PosId = pos1.Id, Price = 5m, StatusId = (byte)Status.Approved, Uid = "uid_0003", UserId = "TestUser", CreatedAt = DateTime.Now }
            };

            _organizationRepository = new Mock<IOrganizationRepository>();
            _organizationRepository.Setup(x => x.Organizations)
                .Returns(_organizations.AsQueryable());

            _categoryMock = new Mock<ICategoryRepository>();
            _categoryMock.Setup(x => x.Categories)
                .Returns(_categories.AsQueryable());

            _productRepository = new Mock<IProductRepository>();
            _productRepository.Setup(x => x.Products)
                .Returns(_products.AsQueryable());

            _categoryController = new CategoryController(
                _categoryMock.Object,
                _organizationRepository.Object,
                _productRepository.Object);
        }
Example #26
0
        public int Count(IList<Tribe> initialtribes)
        {
            Wall wall = new Wall();

            IList<Tribe> tribes = initialtribes.OrderBy(t => t.Day).ToList();

            int counter = 0;
            int lastday = -1;

            while (tribes.Count > 0)
            {
                var tribe = tribes.First();
                tribes.RemoveAt(0);

                if (lastday != tribe.Day)
                {
                    wall.NewDay();
                    lastday = tribe.Day;
                }

                if (wall.Attack(tribe.West, tribe.East, tribe.Strength))
                    counter++;

                tribe.NewDay();

                if (!tribe.CanAttack())
                    continue;

                int n = tribes.Count;

                if (n == 0 || tribes[n - 1].Day <= tribe.Day)
                {
                    tribes.Add(tribe);
                    continue;
                }

                bool added = false;

                for (int k = 0; k < n; k++)
                {
                    if (tribes[k].Day > tribe.Day)
                    {
                        tribes.Insert(k, tribe);
                        added = true;
                        break;
                    }
                }

                if (!added)
                    tribes.Add(tribe);
            }

            return counter;
        }
Example #27
0
 private static string FormatReasons(IList<string> reasons)
 {
     reasons = reasons.OrderBy(x => x.First()).ToList();
     var formatted = new StringBuilder();
     //ul is rendered by episerver
     foreach (var reason in reasons)
     {
         formatted.AppendFormat("<li>{0}</li>", reason);
     }
     return formatted.ToString();
 }
Example #28
0
 public WarInitializer(IList<UnitData> unitDatas,
     Area area, IList<Tuple<int, IList<Unit>, Area>> conquerInfo,
     PhaseCreator phaseCreator, string gamepath)
 {
     _units = unitDatas;
     _area = area;
     _conquerInfo = conquerInfo;
     _conquerInfo.OrderBy(conquer => conquer.Item1);
     _phaseCreator = phaseCreator;
     _gamePath = gamepath;
 }
Example #29
0
        public TreeBuilderQueue(Dictionary<byte, long> dictionary)
        {
            this.itemList = new List<QueueItem>();

            foreach (var b in dictionary)
            {
                itemList.Add(new QueueItem(new TreeNode(b.Key), b.Value));
            }

            itemList = itemList.OrderBy(i => i.Priority).ToList();
        }
 public IEnumerable<Pairing> Shuffle(IList<Player> players)
 {
     ValidatePlayerCount(players);
     var pairings = new List<Pairing>();
     var shuffled = players.OrderBy(i => Guid.NewGuid()).ToList();
     for (var i = 0; i < shuffled.Count; i += 2)
     {
         pairings.Add(new Pairing(shuffled[i], shuffled[i + 1]));
     }
     return pairings;
 }