Пример #1
0
        public void Test_Common()
        {
            var item1 = new GKListItem(10, null);
            var item2 = new GKListItem(20, null);

            Assert.AreEqual(-1, item1.CompareTo(item2));

            item1 = new GKListItem(10, null);
            item2 = new GKListItem(null, null);
            Assert.AreEqual(-1, item1.CompareTo(item2));

            item1 = new GKListItem(null, null);
            item2 = new GKListItem(20, null);
            Assert.AreEqual(1, item1.CompareTo(item2));

            Assert.AreEqual(0, item1.CompareTo(item1));
            Assert.AreEqual(-1, item1.CompareTo(null));


            var subitem1 = new GKListSubItem(10);
            var subitem2 = new GKListSubItem(20);

            Assert.AreEqual(-1, subitem1.CompareTo(subitem2));

            subitem1 = new GKListSubItem(10);
            subitem2 = new GKListSubItem(null);
            Assert.AreEqual(-1, subitem1.CompareTo(subitem2));

            subitem1 = new GKListSubItem(null);
            subitem2 = new GKListSubItem(20);
            Assert.AreEqual(1, subitem1.CompareTo(subitem2));

            Assert.AreEqual(0, subitem1.CompareTo(subitem1));
            Assert.AreEqual(-1, subitem1.CompareTo(null));
        }
Пример #2
0
        public object GetSelectedData()
        {
            try {
                object result = null;

                if (!VirtualMode)
                {
                    GKListItem item = GetSelectedItem();
                    if (item != null)
                    {
                        result = item.Data;
                    }
                }
                else
                {
                    if (SelectedIndices.Count > 0)
                    {
                        int index = SelectedIndices[0];
                        result = fListMan.GetContentItem(index);
                    }
                }

                return(result);
            } catch (Exception ex) {
                Logger.WriteError("GKListView.GetSelectedData()", ex);
                return(null);
            }
        }
Пример #3
0
        private int CompareItems(GKListItem item1, GKListItem item2)
        {
            int result = 0;

            if (fSortOrder != BSDTypes.SortOrder.None && fSortColumn >= 0)
            {
                if (fSortColumn < item1.Values.Length && fSortColumn < item2.Values.Length)
                {
                    IComparable val1 = item1.Values[fSortColumn] as IComparable;
                    IComparable val2 = item2.Values[fSortColumn] as IComparable;

                    if (val1 != null && val2 != null)
                    {
                        bool isStr1 = val1 is string;
                        bool isStr2 = val2 is string;

                        if (isStr1 && isStr2)
                        {
                            result = agCompare((string)val1, (string)val2);
                        }
                        else
                        {
                            result = val1.CompareTo(val2);
                        }
                    }
                }

                if (fSortOrder == BSDTypes.SortOrder.Descending)
                {
                    result = -result;
                }
            }

            return(result);
        }
Пример #4
0
        public int CompareTo(object obj)
        {
            GKListItem otherItem = obj as GKListItem;

            if (otherItem == null)
            {
                return(-1);
            }

            IComparable cv1 = fValue as IComparable;
            IComparable cv2 = otherItem.fValue as IComparable;

            int compRes;

            if (cv1 != null && cv2 != null)
            {
                compRes = cv1.CompareTo(cv2);
            }
            else if (cv1 != null)
            {
                compRes = -1;
            }
            else if (cv2 != null)
            {
                compRes = 1;
            }
            else
            {
                compRes = 0;
            }
            return(compRes);
        }
Пример #5
0
 private void SelectItem(GKListItem item)
 {
     if (item != null)
     {
         int idx = fItems.IndexOf(item);
         SelectItem(idx);
     }
 }
Пример #6
0
        public GKListItem AddItem(object rowData, params object[] columnValues)
        {
            var item = new GKListItem(columnValues);

            item.Data = rowData;
            fItems.Add(item);
            return(item);
        }
Пример #7
0
 private void SelectItem(GKListItem item)
 {
     if (item != null)
     {
         SelectedIndices.Clear();
         item.Selected = true;
         item.EnsureVisible();
     }
 }
Пример #8
0
        public IListItem AddItem(object rowData, params object[] columnValues)
        {
            var result = new GKListItem(columnValues[0], rowData);

            Items.Add(result);

            int num = columnValues.Length;

            if (num > 1)
            {
                for (int i = 1; i < num; i++)
                {
                    object val = columnValues[i];
                    result.SubItems.Add(new GKListSubItem(val));
                }
            }

            return(result);
        }
Пример #9
0
        public BSLib.Design.MVP.Controls.IListItem AddItem(object rowData, params object[] columnValues)
        {
            object[] itemValues;
            if (fCheckedList)
            {
                int num = columnValues.Length;
                itemValues    = new object[num + 1];
                itemValues[0] = false;
                Array.Copy(columnValues, 0, itemValues, 1, num);
            }
            else
            {
                itemValues = columnValues;
            }

            var item = new GKListItem(itemValues);

            item.Data = rowData;
            fItems.Add(item);
            return(item);
        }
Пример #10
0
        private void UpdateItems()
        {
            if (fListMan == null)
            {
                return;
            }

            fItems.Clear();

            int num = fListMan.FilteredCount;

            for (int i = 0; i < num; i++)
            {
                object rowData = fListMan.GetContentItem(i);

                if (rowData != null)
                {
                    object[]   itemData = fListMan.GetItemData(rowData);
                    GKListItem newItem  = (GKListItem)AddItem(rowData, itemData);
                    fListMan.UpdateItemProps(newItem, rowData);
                }
            }
        }
Пример #11
0
        public object GetSelectedData()
        {
            GKListItem item = fList.GetSelectedItem();

            return((item != null) ? item.Data : null);
        }