Exemplo n.º 1
0
 private bool TrySetRevisionText(TagListItem listItem)
 {
     if (listItem != null)
     {
         var tag = listItem.DataContext;
         _txtRevision.Text = tag.Name;
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
        // GET: Tag
        public ActionResult Index(TagListItem name, string search, string option)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new TagService(userId);
            var model   = service.GetTags();

            if (option == "Manufacturer")

            {
                return(View(model.Where(t => t.TagManufacturer.StartsWith(search, StringComparison.OrdinalIgnoreCase) || search == null).ToList()));
            }
            else if (option == "Model")
            {
                return(View(model.Where(t => t.TagModel.StartsWith(search, StringComparison.OrdinalIgnoreCase) || search == null).ToList()));
            }
            else if (option == "SerialNumber")
            {
                return(View(model.Where(t => t.TagSerialNumber.StartsWith(search, StringComparison.OrdinalIgnoreCase) || search == null).ToList()));
            }
            return(View(model));
        }
Exemplo n.º 3
0
 private bool TrySetRevisionText(TagListItem listItem)
 {
     if(listItem != null)
     {
         var tag = listItem.DataContext;
         _txtRevision.Text = tag.Name;
         return true;
     }
     return false;
 }
Exemplo n.º 4
0
        public ReferenceTreeBinding(CustomListBoxItemsCollection itemHost, Repository repository,
            bool groupItems, bool groupRemoteBranches, Predicate<IRevisionPointer> predicate, ReferenceType referenceTypes)
        {
            Verify.Argument.IsNotNull(itemHost, "itemHost");
            Verify.Argument.IsNotNull(repository, "repository");

            _itemHost = itemHost;
            _repository = repository;

            _groupItems = groupItems;
            _groupRemotes = groupRemoteBranches;
            _predicate = predicate;
            _referenceTypes = referenceTypes;

            _itemHost.Clear();
            if(groupItems)
            {
                _refsHeads = new ReferenceGroupListItem(repository, ReferenceType.LocalBranch);
                _refsHeads.Items.Comparison = BranchListItem.CompareByName;
                _refsRemotes = new ReferenceGroupListItem(repository, ReferenceType.RemoteBranch);
                if(groupRemoteBranches)
                {
                    _refsRemotes.Items.Comparison = RemoteListItem.CompareByName;
                }
                else
                {
                    _refsRemotes.Items.Comparison = RemoteBranchListItem.CompareByName;
                }
                _refsTags = new ReferenceGroupListItem(repository, ReferenceType.Tag);
                _refsTags.Items.Comparison = TagListItem.CompareByName;
                _itemHost.Comparison = null;
            }
            else
            {
                _refsHeads = null;
                _refsRemotes = null;
                _refsTags = null;
                _itemHost.Comparison = ReferenceListItemBase.UniversalComparer;
            }

            _remotes = groupRemoteBranches ? new List<RemoteListItem>(repository.Remotes.Count) : null;

            if((referenceTypes & ReferenceType.LocalBranch) == ReferenceType.LocalBranch)
            {
                var refs = _repository.Refs.Heads;
                lock(refs.SyncRoot)
                {
                    foreach(var branch in refs)
                    {
                        if(predicate != null && !predicate(branch)) continue;
                        var item = new BranchListItem(branch);
                        item.Activated += OnItemActivated;
                        CustomListBoxItemsCollection host;
                        if(groupItems)
                        {
                            host = _refsHeads.Items;
                        }
                        else
                        {
                            host = _itemHost;
                        }
                        host.Add(item);
                    }
                    refs.ObjectAdded += OnBranchCreated;
                }
            }

            if((referenceTypes & ReferenceType.RemoteBranch) == ReferenceType.RemoteBranch)
            {
                var refs = repository.Refs.Remotes;
                lock(refs.SyncRoot)
                {
                    foreach(var branch in refs)
                    {
                        if(predicate != null && !predicate(branch)) continue;
                        var host = groupItems ? _refsRemotes.Items : _itemHost;
                        var item = new RemoteBranchListItem(branch);
                        item.Activated += OnItemActivated;
                        if(groupRemoteBranches)
                        {
                            var ritem = GetRemoteListItem(branch);
                            if(ritem != null)
                            {
                                host = ritem.Items;
                            }
                        }
                        host.Add(item);
                    }
                    refs.ObjectAdded += OnRemoteBranchCreated;
                }
            }

            if((referenceTypes & ReferenceType.Tag) == ReferenceType.Tag)
            {
                var refs = repository.Refs.Tags;
                lock(refs.SyncRoot)
                {
                    foreach(var tag in refs)
                    {
                        if(predicate != null && !predicate(tag)) continue;
                        var item = new TagListItem(tag);
                        item.Activated += OnItemActivated;
                        CustomListBoxItemsCollection host;
                        if(groupItems)
                        {
                            host = _refsTags.Items;
                        }
                        else
                        {
                            host = _itemHost;
                        }
                        host.Add(item);
                    }
                    refs.ObjectAdded += OnTagCreated;
                }
            }

            if(groupItems)
            {
                _itemHost.Add(_refsHeads);
                _itemHost.Add(_refsRemotes);
                _itemHost.Add(_refsTags);
            }
        }
Exemplo n.º 5
0
 private void OnTagCreated(object sender, TagEventArgs e)
 {
     var tag = e.Object;
     if(_predicate == null || _predicate(tag))
     {
         CustomListBoxItemsCollection host;
         var item = new TagListItem(tag);
         item.Activated += OnItemActivated;
         if(_groupItems)
         {
             host = _refsTags.Items;
         }
         else
         {
             host = _itemHost;
         }
         host.AddSafe(item);
     }
 }