Beispiel #1
0
        public ListViewItemViewModel Insert(int index, object item)
        {
            ListViewItemViewModel newItem = StaticContainer.Instance.Resolve <ListViewItemViewModel>();

            newItem.Text = ((ListViewItemViewModel)item).Text ?? "";
            _ListViewViewModel.AddItem(newItem, index);
            return(newItem);
        }
Beispiel #2
0
        public ListViewItemViewModel Insert(int index, string text)
        {
            ListViewItemViewModel newItem = StaticContainer.Instance.Resolve <ListViewItemViewModel>();

            newItem.Text             = text;
            newItem.PropertyChanged += _ListViewViewModel.newItem_PropertyChanged;
            _ListViewViewModel.AddItem(newItem, index);
            return(newItem);
        }
Beispiel #3
0
        public virtual ListViewItemViewModel Add(string key, string text, string imageKey)
        {
            ListViewItemViewModel newItem = StaticContainer.Instance.Resolve <ListViewItemViewModel>();

            newItem.Text     = text;
            newItem.ImageKey = imageKey;
            _ListViewViewModel.AddItem(newItem);
            return(newItem);
        }
Beispiel #4
0
        public virtual ListViewItemViewModel Add(string text, int imageIndex)
        {
            ListViewItemViewModel newItem = StaticContainer.Instance.Resolve <ListViewItemViewModel>();

            newItem.Text       = text;
            newItem.ImageIndex = imageIndex;
            _ListViewViewModel.AddItem(newItem);
            return(newItem);
        }
Beispiel #5
0
        public virtual ListViewItemViewModel Insert(int index, string key, string text, string imageKey)
        {
            ListViewItemViewModel newItem = StaticContainer.Instance.Resolve <ListViewItemViewModel>();

            newItem.Text             = text;
            newItem.PropertyChanged += _ListViewViewModel.newItem_PropertyChanged;
            newItem.ImageKey         = imageKey;
            newItem.Name             = key;
            _ListViewViewModel.AddItem(newItem, index);
            return(newItem);
        }
Beispiel #6
0
        public ListViewItemViewModel this[int index]
        {
            get
            {
                ListViewItemViewModel item = ((ListViewItemViewModel)_ListViewViewModel.ListViewItemViewModels[index]);
                item.PropertyChanged += _ListViewViewModel.newItem_PropertyChanged;
                return(item);
            }



            set { _ListViewViewModel.ListViewItemViewModels[index].Text = value.ToString(); }
        }
Beispiel #7
0
        public ListViewItemViewModel GetItemByKey(string key)
        {
            ListViewItemViewModel result = null;

            /* for (int i = 0; i < this.Items.Count; i++)
             * {
             *       if (this.Items[i].Name == key)
             *       {
             *               result = this.Items[i];
             *               break;
             *       }
             * }*/
            return(result);
        }
Beispiel #8
0
        /// <summary>
        ///   Search for an element inside the ListView items collection
        /// </summary>
        /// <param name="text">text used to serach the item</param>
        /// <param name="includeSubItems">flag to indicate if the search will be performed on sub items</param>
        /// <param name="startIndex">the initial index where the search starts</param>
        /// <param name="isPrefixSearch">flag to indicate if this is a prefix search</param>
        /// <returns></returns>
        public ListViewItemViewModel FindItemWithText(string text, bool includeSubItems = false, int startIndex = 0, bool isPrefixSearch = false)
        {
            ListViewItemViewModel result = null;
            var count = this.Items.Count;

            for (int i = startIndex; i < count; i++)
            {
                var current = this.Items[i];
                if (FindItemCompare(text, includeSubItems, isPrefixSearch, current))
                {
                    result = current;
                    break;
                }
            }
            return(result);
        }
Beispiel #9
0
        public void newItem_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            ListViewItemViewModel item = ((ListViewItemViewModel)sender);

            if (item.Selected || item.Focused)
            {
                int index = Items.IndexOf(item);
                if (index > -1)
                {
                    SelectedIndices.Add(index);
                }
            }
            if (item.Checked)
            {
                int index = Items.IndexOf(item);
                if (index > -1)
                {
                    CheckedIndices.Add(index);
                }
            }
        }
 internal ListViewItemSubItemCollection(ListViewItemViewModel viewModel)
 {
     _viewModel = viewModel;
 }
Beispiel #11
0
        private static bool FindItemCompare(string text, bool includeSubItems, bool isPrefixSearch, ListViewItemViewModel current)
        {
            bool result = false;

            if (!isPrefixSearch)
            {
                result = (text == current.Text ||
                          (includeSubItems &&
                           Array.IndexOf(current.ItemContent, text) != -1));
            }
            else
            {
                result = (current.Text.StartsWith(text) ||
                          (includeSubItems &&
                           current.ItemContent.Any(item => item.StartsWith(text))));
            }
            return(result);
        }