Пример #1
0
        public bool ChangeImage(Delta delta, Action <Action> onComplete)
        {
            if (!FilteredFiles.Any())
            {
                return(false);
            }

            _activeImageSetter = TaskList.StartTask(() =>
            {
                Func <int, bool> filter = i =>
                                          delta == Delta.Next ? i > _imageIndex :
                                          delta == Delta.Prev ? i < _imageIndex :
                                          i <= _imageIndex;
                var defaultValue = delta == Delta.Next
                        ? FilteredFiles.First()
                        : FilteredFiles.Last();

                if (delta == Delta.Next)
                {
                    _imageIndex = FilteredFiles.FirstOrDefault(a => filter(a.Index), defaultValue).Index;
                }
                else
                {
                    _imageIndex = FilteredFiles.LastOrDefault(a => filter(a.Index), defaultValue).Index;
                }

                onComplete(() => _activeImageSetter = null);
            });
            return(true);
        }
Пример #2
0
        /// <summary>
        /// Filter the filtered list of files based on the searchfilter
        /// </summary>
        /// <param name="searchFilter"></param>
        public void SearchOnFiles(string searchFilter)
        {
            if (!tfsController.Connected)
            {
                return;
            }

            this.searchText = searchFilter;

            // Save a little effort here
            if (searchFilter == "")
            {
                SearchedFiles = new ObservableCollection <TFSItemViewModel>(FilteredFiles.OrderBy(p => p.Filename));
            }
            else
            {
                SearchedFiles = new ObservableCollection <TFSItemViewModel>(FilteredFiles.Where(p => Regex.Match(p.Filepath, searchFilter, RegexOptions.IgnoreCase).Success).OrderBy(p => p.Filename));
            }

            SyncCheckedoutItems();
        }
Пример #3
0
        async Task addToListView(List <ListObj> objs)
        {
            FilteredFiles.Items.Clear();
            await Task.Delay(0);

            int count = 0;

            foreach (var obj in objs)
            {
                var item = new ListViewItem();
                item.ImageIndex  = obj.ImageIndex;
                item.ToolTipText = item.Text = obj.FileName;
                item.Tag         = obj.FileName;
                if (obj.Encoding != null)
                {
                    item.SubItems.Add(obj.Encoding.EncodingName);
                }
                else
                {
                    item.SubItems.Add("非UTF8或不明确");
                }
                if (obj.NoUTF8 || obj.UTF8BOM)
                {
                    item.ForeColor = Color.Red;
                }
                item.SubItems.Add(obj.UTF8BOM ? "带签名" : "");
                FilteredFiles.BeginUpdate();
                FilteredFiles.Items.Add(item);
                FilteredFiles.EndUpdate();
                FilteredFiles.Items[FilteredFiles.Items.Count - 1].EnsureVisible();
                count++;
                if (count % 20 == 0)
                {
                    await Task.Delay(1);
                }
            }
        }