コード例 #1
0
        public void Find()
        {
            var coll = new SortableBindingList <KeyValuePair <int, string> > {
                new KeyValuePair <int, string>(1, "1"), new KeyValuePair <int, string>(2, "2")
            };

            coll.ApplySort(nameof(KeyValuePair <_, _> .Key), ListSortDirection.Ascending);

            Throws <ArgumentException>(() => coll.Find("X", null), "No property descriptor found for property name 'X' in type 'System.Collections.Generic.KeyValuePair`2[System.Int32,System.String]'.");
            Assert.IsTrue(coll.Find(nameof(KeyValuePair <_, _> .Key), 0) < 0);
            Assert.AreEqual(0, coll.Find(nameof(KeyValuePair <_, _> .Key), 1));

            coll.ApplySort(nameof(KeyValuePair <_, _> .Key), ListSortDirection.Descending);
            Assert.AreEqual(1, coll.Find(nameof(KeyValuePair <_, _> .Key), 1));
        }
コード例 #2
0
        private void ApplySearchFilter()
        {
            if (string.IsNullOrWhiteSpace(SearchTextBox.Text) && IsListFiltered)
            {
                if (FilteredBrickList != null && FilteredBrickList.IsSorted)
                {
                    BrickList.ApplySort(FilteredBrickList.PropertyDescriptor, FilteredBrickList.SortDirection);
                }

                BrickGridView.DataSource = BrickList;
                FilteredBrickList.Clear();
                IsListFiltered = false;
                return;
            }

            FilteredBrickList = new SortableBindingList <BrickInfo>(
                BrickList.Where(x => IsBrickVisible(x)).ToList());

            if (BrickList.IsSorted)
            {
                FilteredBrickList.ApplySort(BrickList.PropertyDescriptor, BrickList.SortDirection);
            }

            BrickGridView.DataSource = FilteredBrickList;
            IsListFiltered           = true;
        }
コード例 #3
0
        private void Initialize()
        {
            Connections = new SortableBindingList <PartConnection>();
            SubTypeList = new SortableBindingList <ConnectorInfo>();
            SubTypeList.ApplySort("SubType", ListSortDirection.Ascending);

            ElementsComboBox.ComboBox.DataSource    = Connections;
            ElementsComboBox.ComboBox.DisplayMember = "Name";
            ElementsComboBox.ComboBox.ValueMember   = "ID";
            CloseButtonVisible = false;

            TypeValueLabel.Text      = string.Empty;
            HingeLayoutPanel.Visible = false;

            EditControlHelpers = new List <ControlConnType>()
            {
                new ControlConnType(HingeLayoutPanel, ConnectorType.Hinge),
                new ControlConnType(GearLayoutPanel, ConnectorType.Gear),
                new ControlConnType(TagControlLabel,
                                    ConnectorType.Hinge, ConnectorType.Fixed, ConnectorType.Slider),
                new ControlConnType(LengthControlLabel, LengthBox,
                                    ConnectorType.Axel, ConnectorType.Slider, ConnectorType.Rail),
                new ControlConnType(SpringPanel, CylindricalCheckBox, ConnectorType.Slider),
                new ControlConnType(AxesControlLabel, ConnectorType.Fixed),
                new ControlConnType(GrabbingLayoutPanel, ConnectorType.Axel),
                new ControlConnType(CapLayoutPanel, ConnectorType.Axel, ConnectorType.Slider),
                new ControlConnType(FlexControlLabel, ConnectorType.Ball)
            };
        }
コード例 #4
0
        public void SetExplicit()
        {
            var coll = new SortableBindingList <int>(new[] { 1, 2, 3, 2, 1 })
            {
                CheckConsistency = false
            };

            coll[1] = 1;
            coll[4] = 2;
            coll.ApplySort(ListSortDirection.Ascending);
            AssertConsistency(coll);

            // setting after sorted
            coll[1] = 0;
            AssertConsistency(coll);

            // switching on sort on change sorts immediately
            coll.SortOnChange = true;
            AssertConsistency(coll);
            AssertSorted(coll);

            // setting when SortOnChange is true sorts on change
            coll[0] = 13;
            AssertConsistency(coll);
            AssertSorted(coll);
        }
コード例 #5
0
        public void AddExplicit()
        {
            var coll = new SortableBindingList <int>();

            coll.Add(1);
            coll.Add(2);
            coll.Add(1);
            coll.Insert(0, 1);
            coll.ApplySort(ListSortDirection.Ascending);
            AssertConsistency(coll);
            AssertSorted(coll);

            // adding after sorted
            coll.Add(1);
            coll.Add(2);
            coll.Add(1);
            coll.Insert(0, 1);
            AssertConsistency(coll);

            // switching on sort on change sorts immediately
            coll.SortOnChange = true;
            AssertConsistency(coll);
            AssertSorted(coll);

            // adding when SortOnChange is true sorts on add
            coll.Add(0);
            AssertConsistency(coll);
            AssertSorted(coll);
        }
コード例 #6
0
        public void RemoveExplicit()
        {
            var coll = new SortableBindingList <int>(new List <int> {
                1, 2, 3, 2, 1
            })
            {
                CheckConsistency = false
            };

            coll.ApplySort(ListSortDirection.Ascending);
            coll.Remove(1);   // first 1
            coll.RemoveAt(1); // 2
            coll.Remove(1);   // last 1 (1st element)
            AssertConsistency(coll);
        }
コード例 #7
0
        public LifViewerWindow()
        {
            InitializeComponent();
            BackHistory                     = new List <LifFile.FolderEntry>();
            FwrdHistory                     = new List <LifFile.FolderEntry>();
            CurrentFolderItems              = new SortableBindingList <ILifItemInfo>();
            CurrentFolderItems.ListChanged += CurrentFolderItems_ListChanged;
            CurrentLifFolders               = new SortableBindingList <LifFolderInfo>();
            CurrentLifFolders.ApplySort("FullName", ListSortDirection.Ascending);

            NativeMethods.SetWindowTheme(LifTreeView.Handle, "Explorer", null);


            ToolBarFolderCombo.ComboBox.DisplayMember         = "FullName";
            ToolBarFolderCombo.ComboBox.DrawMode              = DrawMode.OwnerDrawVariable;
            ToolBarFolderCombo.ComboBox.DrawItem             += ComboBox_DrawItem;
            ToolBarFolderCombo.ComboBox.SelectedIndexChanged += ComboBox_SelectedIndexChanged;
        }
コード例 #8
0
        public void SetInner()
        {
            var inner = new List <string> {
                "0", "3", "2", "3", "1"
            };
            var coll = new SortableBindingList <string>(inner)
            {
                CheckConsistency = false
            };

            coll.ApplySort(ListSortDirection.Ascending);

            // causing inconsistency
            inner[0] = null;
            Throws <AssertionException>(() => AssertConsistency(coll));

            // inconsistency detected and fixed on next set
            coll.CheckConsistency = true;
            coll[0] = "x";
            AssertConsistency(coll);
        }
コード例 #9
0
        public void RemoveInner()
        {
            var inner = new List <string> {
                "1", "2", "3", "2", "1"
            };
            var coll = new SortableBindingList <string>(inner)
            {
                CheckConsistency = false
            };

            coll.ApplySort(ListSortDirection.Ascending);

            // causing inconsistency
            inner.RemoveAt(2);
            inner.Add("a"); // making sure inner length does not change; otherwise, inconsistency is detected and fixed in Assert
            Throws <AssertionException>(() => AssertConsistency(coll));

            // inconsistency detected and fixed on next remove
            coll.CheckConsistency = true;
            coll.RemoveAt(0);
            AssertConsistency(coll);
        }