Exemplo n.º 1
0
        /// <summary>
        /// Fetches the items to the given list box.
        /// </summary>
        private void FillListBox <T>(IEnumerable <T> items, ListBox listBox)
            where T : ISkillLevel
        {
            PlanScratchpad plan = new PlanScratchpad(m_operation.Plan.Character);

            plan.RebuildPlanFrom(items.Select(x => new PlanEntry(x.Skill, x.Level)));
            plan.FixPrerequisites();

            listBox.Items.Clear();
            foreach (PlanEntry entry in plan)
            {
                string name = entry.ToString();

                if (m_operation.Type == PlanOperations.Addition)
                {
                    // Skip if the entry is already in the plan
                    if (m_operation.Plan.IsPlanned(entry.Skill, entry.Level))
                    {
                        continue;
                    }
                }
                else
                {
                    // On creation of "entries to remove" listbox (first pass),
                    // skip if entry type is of prerequisite.
                    // "Useless prerequisites" listbox is created on second pass
                    // and in that case entry type is of type planned.
                    if (entry.Type == PlanEntryType.Prerequisite)
                    {
                        continue;
                    }

                    if (entry.Type == PlanEntryType.Planned)
                    {
                        name += " (planned)";
                    }
                }

                listBox.Items.Add(name);
            }
        }