コード例 #1
0
//        public ICommand GoToSubmoduleCommand
//        {
//			get { return new MvxCommand<SourceModel>(GoToSubmodule);}
//        }

//		private void GoToSubmodule(SourceModel x)
//        {
//            var nameAndSlug = x.GitUrl.Substring(x.GitUrl.IndexOf("/repos/", System.StringComparison.Ordinal) + 7);
//            var repoId = new RepositoryIdentifier(nameAndSlug.Substring(0, nameAndSlug.IndexOf("/git", System.StringComparison.Ordinal)));
//            var sha = x.GitUrl.Substring(x.GitUrl.LastIndexOf("/", System.StringComparison.Ordinal) + 1);
//            ShowViewModel<SourceTreeViewModel>(new NavObject {Username = repoId.Owner, Repository = repoId.Name, Branch = sha});
//        }

        public SourceTreeViewModel()
        {
			_content = new FilterableCollectionViewModel<SourceModel, SourceFilterModel>("SourceViewModel");
            _content.FilteringFunction = FilterModel;
            _content.Bind(x => x.Filter).Subscribe(_ => _content.Refresh());

            this.Bind(x => x.Filter).Subscribe(_ => _content.Refresh());

            GoToSourceCommand = ReactiveUI.ReactiveCommand.Create();
            GoToSourceCommand.OfType<SourceModel>().Subscribe(x =>
            {
                if (x.Type.Equals("dir", StringComparison.OrdinalIgnoreCase))
                {
                    ShowViewModel<SourceTreeViewModel>(new NavObject
                    {
                        Username = Username,
                        Branch = Branch,
                        Repository = Repository,
                        Path = x.Path
                    });
                }
                else if (x.Type.Equals("file", StringComparison.OrdinalIgnoreCase))
                {
                    ShowViewModel<SourceViewModel>(new SourceViewModel.NavObject 
                    { 
                        Name = x.Name, 
                        User = Username,
                        Repository = Repository, 
                        Branch = Branch, 
                        Path = x.Path 
                    });
                }
            });
        }
コード例 #2
0
        public SourceTreeViewModel(IFeaturesService featuresService)
        {
            _featuresService = featuresService;

            GoToItemCommand = ReactiveUI.ReactiveCommand.Create();
            GoToItemCommand.OfType <ContentModel>().Subscribe(x =>
            {
                if (x.Type.Equals("dir", StringComparison.OrdinalIgnoreCase))
                {
                    ShowViewModel <SourceTreeViewModel>(new NavObject {
                        Username   = Username, Branch = Branch,
                        Repository = Repository, Path = x.Path, TrueBranch = TrueBranch
                    });
                }
                if (x.Type.Equals("file", StringComparison.OrdinalIgnoreCase))
                {
                    if (x.DownloadUrl == null)
                    {
                        var nameAndSlug = x.GitUrl.Substring(x.GitUrl.IndexOf("/repos/", StringComparison.Ordinal) + 7);
                        var repoId      = new RepositoryIdentifier(nameAndSlug.Substring(0, nameAndSlug.IndexOf("/git", StringComparison.Ordinal)));
                        var sha         = x.GitUrl.Substring(x.GitUrl.LastIndexOf("/", StringComparison.Ordinal) + 1);
                        ShowViewModel <SourceTreeViewModel>(new NavObject {
                            Username = repoId.Owner, Repository = repoId.Name, Branch = sha
                        });
                    }
                    else
                    {
                        ShowViewModel <SourceViewModel>(new SourceViewModel.NavObject {
                            Name = x.Name, Username = Username, Repository = Repository, Branch = Branch,
                            Path = x.Path, HtmlUrl = x.HtmlUrl, GitUrl = x.GitUrl, TrueBranch = TrueBranch
                        });
                    }
                }
            });
        }
コード例 #3
0
//        public ICommand GoToSubmoduleCommand
//        {
//			get { return new MvxCommand<SourceModel>(GoToSubmodule);}
//        }

//		private void GoToSubmodule(SourceModel x)
//        {
//            var nameAndSlug = x.GitUrl.Substring(x.GitUrl.IndexOf("/repos/", System.StringComparison.Ordinal) + 7);
//            var repoId = new RepositoryIdentifier(nameAndSlug.Substring(0, nameAndSlug.IndexOf("/git", System.StringComparison.Ordinal)));
//            var sha = x.GitUrl.Substring(x.GitUrl.LastIndexOf("/", System.StringComparison.Ordinal) + 1);
//            ShowViewModel<SourceTreeViewModel>(new NavObject {Username = repoId.Owner, Repository = repoId.Name, Branch = sha});
//        }

        public SourceTreeViewModel()
        {
            _content = new FilterableCollectionViewModel <SourceModel, SourceFilterModel>("SourceViewModel");
            _content.FilteringFunction = FilterModel;
            _content.Bind(x => x.Filter).Subscribe(_ => _content.Refresh());

            this.Bind(x => x.Filter).Subscribe(_ => _content.Refresh());

            GoToSourceCommand = ReactiveUI.ReactiveCommand.Create();
            GoToSourceCommand.OfType <SourceModel>().Subscribe(x =>
            {
                if (x.Type.Equals("dir", StringComparison.OrdinalIgnoreCase))
                {
                    ShowViewModel <SourceTreeViewModel>(new NavObject
                    {
                        Username   = Username,
                        Branch     = Branch,
                        Repository = Repository,
                        Path       = x.Path
                    });
                }
                else if (x.Type.Equals("file", StringComparison.OrdinalIgnoreCase))
                {
                    ShowViewModel <SourceViewModel>(new SourceViewModel.NavObject
                    {
                        Name       = x.Name,
                        User       = Username,
                        Repository = Repository,
                        Branch     = Branch,
                        Path       = x.Path
                    });
                }
            });
        }