示例#1
0
        public void ResetShouldAddCurrentItemsToFilteredList()
        {
            var collection       = new MyCollection();
            var filterCollection = new FilterCollection <DataItem>(collection);

            collection.AddRange(Enumerable.Range(1, 10).Select(r => new DataItem(r)));

            Assert.AreEqual(10, filterCollection.Count, "FilterCollection.Count should be equal to 10 after adding items in bulk");

            collection.AddRange(Enumerable.Range(1, 10).Select(r => new DataItem(r)));

            Assert.AreEqual(20, filterCollection.Count, "FilterCollection.Count should be equal to 20 after adding more items in bulk");
        }
示例#2
0
        public void CollectionChangedWithResetShouldShowItems()
        {
            var count = 10;

            ManualForm($"GridView should show {count} items", form =>
            {
                var collection       = new MyCollection();
                var filterCollection = new FilterCollection <DataItem>(collection);
                var myGridView       = new GridView
                {
                    Size      = new Size(200, 260),
                    DataStore = filterCollection,
                    Columns   =
                    {
                        new GridColumn {
                            DataCell = new TextBoxCell{
                                Binding = Eto.Forms.Binding.Property((DataItem m) => m.Id.ToString())
                            }
                        }
                    }
                };
                collection.Clear();
                collection.AddRange(Enumerable.Range(1, count).Select(r => new DataItem(r)));

                return(myGridView);
            });
        }
示例#3
0
        public IconContentViewModel(IIconService iconService, ISetting setting)
        {
            _iconService            = iconService;
            _setting                = setting;
            CopyPathCommand         = new DelegateCommand <int?>(OnClickCopyPath);
            ChangeCartCommand       = new DelegateCommand <int?>(OnChangeCart);
            RemoveCartCommand       = new DelegateCommand <int?>(OnRemoveCart);
            ChangeCollectionCommand = new DelegateCommand <int?>(OnCollectionChanged);
            ClearCartCommand        = new DelegateCommand(OnClearCart);
            DownloadMaterial        = new DelegateCommand(OnDownloadMaterial, CanDownload);
            DownloadCode            = new DelegateCommand(OnDownloadCode, CanDownload);


            IconCarts.CollectionChanged    += IconCarts_CollectionChanged;
            MyCollection.CollectionChanged += MyCollection_CollectionChanged;

            ///加载用户数据库
            if (_setting.IconCarts != null)
            {
                IconCarts.AddRange(_setting.IconCarts);
            }

            ///加载用户数据收藏夹
            if (_setting.MyCollection != null)
            {
                MyCollection.AddRange(_setting.MyCollection);
            }

            InitData();
        }
        public static void Main(string[] args)
        {
            var std = new Person <Student> {
                PersonId = "1001", Age = 25, Type = new Student {
                    StudentFName = "Abhay", StudentLName = "Chaudhry"
                }
            };
            var std1 = new Person <Student> {
                PersonId = "1002", Age = 25, Type = new Student {
                    StudentFName = "Abhay", StudentLName = "Chaudhry"
                }
            };
            var std2 = new Person <Student> {
                PersonId = "1003", Age = 25, Type = new Student {
                    StudentFName = "Abhay", StudentLName = "Chaudhry"
                }
            };
            var studentsColletion = new[] { std1, std2 };

            var emp = new Person <Employee> {
                PersonId = "1004", Age = 35, Type = new Employee()
                {
                    EmployeeFName = "abhijeet", EmployeeLName = "Chaudhry"
                }
            };
            var emp1 = new Person <Employee> {
                PersonId = "1005", Age = 35, Type = new Employee()
                {
                    EmployeeFName = "abhijeet", EmployeeLName = "Chaudhry"
                }
            };
            var emp2 = new Person <Employee> {
                PersonId = "1006", Age = 35, Type = new Employee()
                {
                    EmployeeFName = "abhijeet", EmployeeLName = "Chaudhry"
                }
            };
            var employeeColletion = new[] { emp1, emp2 };

            var personsStd1 = new MyCollection <Person <Student> >(1);
            var students    = personsStd1.Add(std);
            var personEmp1  = new MyCollection <Person <Employee> >(1);
            var employees   = personEmp1.Add(emp);

            PrintStudent(students);
            PrintEmployee(employees);

            var personsStd2 = new MyCollection <Person <Student> >(2);
            var students1   = personsStd2.AddRange(studentsColletion);
            var personEmp2  = new MyCollection <Person <Employee> >(2);
            var employee2   = personEmp2.AddRange(employeeColletion);

            Console.WriteLine("**");
            Console.WriteLine("**");
            PrintStudent(students1);
            PrintEmployee(employee2);


            Console.WriteLine("**");
            students1 = personsStd2.Remove(std1);
            PrintStudent(students1);
            employee2 = personEmp2.RemoveAt(1);
            PrintEmployee(employee2);

            Console.ReadLine();
        }