Exemple #1
0
        public void TestIconForExtension()
        {
            Assert.That(mapper.DirectoryIcon, Is.GreaterThan(0));
            Assert.That(mapper.FileIcon, Is.GreaterThan(0));

            Assert.That(mapper.GetIconForExtension(null), Is.EqualTo(mapper.FileIcon));
            Assert.That(mapper.GetIconForExtension(""), Is.EqualTo(mapper.FileIcon));
            Assert.That(mapper.GetIconForExtension("qweqweqeqwe"), Is.EqualTo(mapper.FileIcon));
            Assert.That(mapper.GetIconForExtension("exe"), Is.GreaterThan(0));
        }
Exemple #2
0
        public RepositoryListItem(RepositoryListView view, SharpSvn.Remote.ISvnRepositoryListItem listItem, SvnOrigin dirOrigin, IFileIconMapper iconMapper)
            : base(view)
        {
            if (listItem == null)
            {
                throw new ArgumentNullException("listItem");
            }
            else if (dirOrigin == null)
            {
                throw new ArgumentNullException("dirOrigin");
            }

            SvnDirEntry entry    = listItem.Entry;
            Uri         entryUri = listItem.Uri;

            _entry  = entry;
            _origin = new SvnOrigin(entryUri, dirOrigin);

            string name = SvnTools.GetFileName(entryUri);

            bool isFile = (entry.NodeKind == SvnNodeKind.File);

            string extension = isFile ? Path.GetExtension(name) : "";

            if (iconMapper != null)
            {
                if (isFile)
                {
                    ImageIndex = iconMapper.GetIconForExtension(extension);
                }
                else
                {
                    ImageIndex = iconMapper.DirectoryIcon;
                }
            }

            SvnLockInfo      lockInfo = null;
            SvnListEventArgs lea      = listItem as SvnListEventArgs;

            if (lea != null)
            {
                lockInfo = lea.Lock;
            }

            SetValues(
                name,
                IsFolder ? RepositoryStrings.ExplorerDirectoryName : view.Context.GetService <IFileIconMapper>().GetFileType(extension),
                entry.Revision.ToString(),
                entry.Author,
                IsFolder ? "" : entry.FileSize.ToString(),
                entry.Time.ToLocalTime().ToString("g"),
                (lockInfo != null) ? lockInfo.Owner : "");
        }
Exemple #3
0
        public WCSolutionNode(IAnkhServiceProvider context, SvnItem item)
            : base(context, null, item)
        {
            string file = Context.GetService <IAnkhSolutionSettings>().SolutionFilename;

            IFileIconMapper iconMapper = context.GetService <IFileIconMapper>();

            if (string.IsNullOrEmpty(file))
            {
                _imageIndex = iconMapper.GetIconForExtension(".sln");
            }
            else
            {
                _imageIndex = iconMapper.GetIcon(file);
            }
        }
Exemple #4
0
        public RepositoryListItem(RepositoryListView view, SharpSvn.Remote.ISvnRepositoryListItem listItem, SvnOrigin dirOrigin, IFileIconMapper iconMapper)
            : base(view)
        {
            if (listItem == null)
                throw new ArgumentNullException("listItem");
            else if (dirOrigin == null)
                throw new ArgumentNullException("dirOrigin");

            SvnDirEntry entry = listItem.Entry;
            Uri entryUri = listItem.Uri;

            _entry = entry;
            _origin = new SvnOrigin(entryUri, dirOrigin);

            string name = SvnTools.GetFileName(entryUri);

            bool isFile = (entry.NodeKind == SvnNodeKind.File);

            string extension = isFile ? Path.GetExtension(name) : "";

            if (iconMapper != null)
            {
                if (isFile)
                    ImageIndex = iconMapper.GetIconForExtension(extension);
                else
                {
                    ImageIndex = iconMapper.DirectoryIcon;
                }
            }

            SvnLockInfo lockInfo = null;
            SvnListEventArgs lea = listItem as SvnListEventArgs;
            if (lea != null)
                lockInfo = lea.Lock;

            SetValues(
                name,
                IsFolder ? RepositoryStrings.ExplorerDirectoryName : view.Context.GetService<IFileIconMapper>().GetFileType(extension),
                entry.Revision.ToString(),
                entry.Author,
                IsFolder ? "" : entry.FileSize.ToString(),
                entry.Time.ToLocalTime().ToString("g"),
                (lockInfo != null) ? lockInfo.Owner : "");
        }
Exemple #5
0
 private int GetIcon(IFileIconMapper mapper)
 {
     if (SvnItem.Exists)
     {
         return(mapper.GetIcon(_item.FullPath));
     }
     else if (_status.NodeKind == SvnNodeKind.Directory)
     {
         return(mapper.DirectoryIcon);
     }
     else if (_status.NodeKind == SvnNodeKind.None && _status.RemoteUpdateNodeKind == SvnNodeKind.Directory)
     {
         return(mapper.DirectoryIcon);
     }
     else
     {
         return(mapper.GetIconForExtension(_item.Extension));
     }
 }
        void OnFill(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException();
            }

            try
            {
                using (SvnPoolRemoteSession session = GetSession(uri))
                {
                    string path = session.MakeRelativePath(uri);

                    SvnRemoteListArgs la = new SvnRemoteListArgs();
                    la.ThrowOnError    = false;
                    la.RetrieveEntries = SvnDirEntryItems.Kind;

                    Uri repositoryRoot        = null;
                    List <ListViewItem> items = new List <ListViewItem>();

                    SvnRemoteNodeKindArgs commonArgs = new SvnRemoteNodeKindArgs();
                    commonArgs.ThrowOnError = false;
                    SvnNodeKind kind;

                    session.GetNodeKind(path, commonArgs, out kind);

                    session.GetRepositoryRoot(out repositoryRoot);

                    bool ok = (kind == SvnNodeKind.File) || session.List(path, la,
                                                                         delegate(object sender, SvnRemoteListEventArgs e)
                    {
                        if (string.IsNullOrEmpty(e.Path))
                        {
                            return;
                        }

                        ListViewItem lvi = new ListViewItem();
                        lvi.Tag          = e.Uri;
                        lvi.Text         = SvnTools.GetFileName(e.Uri);
                        lvi.ImageIndex   = (e.Entry.NodeKind == SvnNodeKind.Directory) ? _dirOffset : _fileOffset;
                        items.Add(lvi);
                    });


                    if (IsHandleCreated)
                    {
                        Invoke((AnkhAction) delegate()
                        {
                            if (uri == _currentUri)
                            {
                                dirView.Items.Clear();

                                if (repositoryRoot != null && !_repositoryRoots.Contains(repositoryRoot))
                                {
                                    _repositoryRoots.Add(repositoryRoot);
                                }

                                if (ok)
                                {
                                    IFileIconMapper mapper = Context != null ? Context.GetService <IFileIconMapper>() : null;

                                    foreach (ListViewItem item in items)
                                    {
                                        if (item.ImageIndex == _fileOffset)
                                        {
                                            string ext = Path.GetExtension(item.Text);

                                            if (!string.IsNullOrEmpty(ext))
                                            {
                                                int n = mapper.GetIconForExtension(ext);

                                                if (n > 0)
                                                {
                                                    item.ImageIndex = n;
                                                }
                                            }
                                        }
                                    }

                                    SetView(items.ToArray());
                                    _walking[uri] = items;
                                }
                                else
                                {
                                    string message =
                                        string.Format("<{0}>",
                                                      la.LastException != null ? la.LastException.Message : "Nothing");
                                    dirView.Items.Add(message);
                                }
                            }
                        });
                    }
                }
            }
            catch (SvnException svnEx)
            {
                BeginInvoke((AnkhAction) delegate()
                {
                    dirView.Items.Clear();

                    string message =
                        string.Format("<{0}>", svnEx.Message);
                    dirView.Items.Add(message);
                });
            }
            finally
            {
                BeginInvoke((AnkhAction) delegate()
                {
                    lock (_running)
                    {
                        _running.Remove(uri);

                        if (_running.Count == 0)
                        {
                            if (_busy != null && _loading)
                            {
                                _loading = false;
                                _busy.Hide();
                            }
                        }
                    }
                });
                // Exception or something
            }
        }
 private int GetIcon(IFileIconMapper mapper)
 {
     if (SvnItem.Exists)
         return mapper.GetIcon(_item.FullPath);
     else if (_status.NodeKind == SvnNodeKind.Directory)
         return mapper.DirectoryIcon;
     else if (_status.NodeKind == SvnNodeKind.None && _status.RemoteUpdateNodeKind == SvnNodeKind.Directory)
         return mapper.DirectoryIcon;
     else
         return mapper.GetIconForExtension(_item.Extension);
 }