예제 #1
0
        public override bool RemoveItem(ICatalogItem item, bool removeOther)
        {
            if (item == null || _listView.Items.Count == 0)
            {
                return(true);
            }
            ItemInfoListViewDataItem tag  = null;
            List <ListViewDataItem>  temp = new List <ListViewDataItem>();

            temp.AddRange(_listView.Items);
            foreach (ListViewDataItem lvi in temp)
            {
                tag = lvi as ItemInfoListViewDataItem;
                if (tag == null)
                {
                    continue;
                }
                if (tag.Tag.ToString().ToUpper() == item.FileName.ToUpper())
                {
                    _listView.Items.Remove(lvi);
                }
            }
            if (removeOther)
            {
                RemoveOtherCatalog(item, false);
            }
            return(true);
        }
예제 #2
0
        public override bool IsExist(ICatalogItem item)
        {
            //if (_listView.Items == null || _listView.Items.Count == 0 || item == null || string.IsNullOrEmpty(item.FileName))
            //    return false;
            //foreach (var v in _listView.Items)
            //{
            //    ItemInfoListViewDataItem data = v as ItemInfoListViewDataItem;
            //    if (data == null || data.Tag == null)
            //        continue;
            //    if (data.Tag.ToString() == item.FileName)
            //    {
            //        //选中条目
            //        _listView.SelectedItem = data;
            //        return true;
            //    }
            //}
            //return false;
            ItemInfoListViewDataItem data = IsExist(item, true);

            if (data == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
예제 #3
0
 void lv_ItemMouseDoubleClick(object sender, ListViewItemEventArgs e)
 {
     if (_itemDoubleClickedHandler != null)
     {
         ItemInfoListViewDataItem item = e.Item as ItemInfoListViewDataItem;
         _itemDoubleClickedHandler(item != null ? item.Tag : null);
     }
 }
예제 #4
0
        protected override bool RemoveFromWks(ICatalogItem item)
        {
            ItemInfoListViewDataItem data = IsExist(item, false);

            if (data == null)
            {
                return(false);
            }
            else
            {
                _listView.Items.Remove(data);
                return(true);
            }
        }
예제 #5
0
        public override ICatalogItem[] GetSelectedItems()
        {
            if (_listView.SelectedItems == null || _listView.SelectedItems.Count == 0)
            {
                return(null);
            }
            List <ICatalogItem> items = new List <ICatalogItem>(_listView.SelectedItems.Count);

            foreach (var lv in _listView.SelectedItems)
            {
                ItemInfoListViewDataItem tag = lv as ItemInfoListViewDataItem;
                if (tag == null)
                {
                    continue;
                }
                items.Add(new CatalogItem(tag.Tag.ToString(), _definition as SubProductCatalogDef, null));
            }
            return(items.Count > 0 ? items.ToArray() : null);
        }
예제 #6
0
        public override string[] GetSelectedFiles()
        {
            if (_listView.SelectedItems == null || _listView.SelectedItems.Count == 0)
            {
                return(null);
            }
            List <string> items = new List <string>(_listView.SelectedItems.Count);

            foreach (var lv in _listView.SelectedItems)
            {
                ItemInfoListViewDataItem tag = lv as ItemInfoListViewDataItem;
                if (tag == null)
                {
                    continue;
                }
                items.Add(tag.Tag.ToString());
            }
            return(items.Count > 0 ? items.ToArray() : null);
        }
예제 #7
0
 private ItemInfoListViewDataItem IsExist(ICatalogItem item, bool isSelected)
 {
     if (_listView.Items == null || _listView.Items.Count == 0 || item == null || string.IsNullOrEmpty(item.FileName))
     {
         return(null);
     }
     foreach (var v in _listView.Items)
     {
         ItemInfoListViewDataItem data = v as ItemInfoListViewDataItem;
         if (data == null || data.Tag == null)
         {
             continue;
         }
         if (data.Tag.ToString() == item.FileName)
         {
             _listView.SelectedItem = data;
             return(data);
         }
     }
     return(null);
 }