Beispiel #1
0
        private static void ChangeTrackingTest()
        {
            var colors = Enum.GetValues(typeof(KnownColor));
            var types  = Enum.GetValues(typeof(MaterialTypeEnum));
            var random = new Random();

            var materials = new BindingList <MaterialInfo>()(
                Enumerable.Range(0, 10).Select(i =>
                                               new MaterialInfo
            {
                Name         = $"Name_{i:000}",
                Color        = Color.FromKnownColor((KnownColor)colors.GetValue(random.Next(colors.Length))),
                MaterialType = (MaterialTypeEnum)types.GetValue(random.Next(types.Length)),
            }
                                               )
                .ToList()
                );

            if (materials is ICollection)
            {
                Console.WriteLine("Yes");
            }

            var trackableMaterials = materials.AsTrackable();

            var firstItem = trackableMaterials.FirstOrDefault();

            trackableMaterials.Remove(firstItem);
        }