Example #1
0
 public GitHubConnectSection1(ISimpleApiClientFactory apiFactory,
                              ITeamExplorerServiceHolder holder,
                              IConnectionManager manager,
                              IPackageSettings settings)
     : base(apiFactory, holder, manager, settings, 1)
 {
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PullRequestDetailViewModel"/> class.
        /// </summary>
        /// <param name="repositoryHost">The repository host.</param>
        /// <param name="teservice">The team explorer service.</param>
        /// <param name="pullRequestsService">The pull requests service.</param>
        /// <param name="avatarProvider">The avatar provider.</param>
        public PullRequestDetailViewModel(
            ILocalRepositoryModel repository,
            IModelService modelService,
            IPullRequestService pullRequestsService,
            IPackageSettings settings)
        {
            this.repository          = repository;
            this.modelService        = modelService;
            this.pullRequestsService = pullRequestsService;

            Checkout = ReactiveCommand.CreateAsyncObservable(
                this.WhenAnyValue(x => x.CheckoutState)
                .Cast <CheckoutCommandState>()
                .Select(x => x != null && x.DisabledMessage == null),
                DoCheckout);
            Checkout.ThrownExceptions.Subscribe(x => OperationError = x.Message);

            Pull = ReactiveCommand.CreateAsyncObservable(
                this.WhenAnyValue(x => x.UpdateState)
                .Cast <UpdateCommandState>()
                .Select(x => x != null && x.PullDisabledMessage == null),
                DoPull);
            Pull.ThrownExceptions.Subscribe(x => OperationError = x.Message);

            Push = ReactiveCommand.CreateAsyncObservable(
                this.WhenAnyValue(x => x.UpdateState)
                .Cast <UpdateCommandState>()
                .Select(x => x != null && x.PushDisabledMessage == null),
                DoPush);
            Push.ThrownExceptions.Subscribe(x => OperationError = x.Message);

            OpenOnGitHub = ReactiveCommand.Create();

            ChangedFilesViewType = (settings.UIState?.PullRequestDetailState?.ShowTree ?? true) ?
                                   ChangedFilesViewType.TreeView : ChangedFilesViewType.ListView;

            ToggleChangedFilesView = ReactiveCommand.Create();
            ToggleChangedFilesView.Subscribe(_ =>
            {
                ChangedFilesViewType = ChangedFilesViewType == ChangedFilesViewType.TreeView ?
                                       ChangedFilesViewType.ListView : ChangedFilesViewType.TreeView;
                settings.UIState.PullRequestDetailState.ShowTree = ChangedFilesViewType == ChangedFilesViewType.TreeView;
                settings.Save();
            });

            OpenChangedFileAction = (settings.UIState?.PullRequestDetailState?.DiffOnOpen ?? true) ?
                                    OpenChangedFileAction.Diff : OpenChangedFileAction.Open;

            ToggleOpenChangedFileAction = ReactiveCommand.Create();
            ToggleOpenChangedFileAction.Subscribe(_ =>
            {
                OpenChangedFileAction = OpenChangedFileAction == OpenChangedFileAction.Diff ?
                                        OpenChangedFileAction.Open : OpenChangedFileAction.Diff;
                settings.UIState.PullRequestDetailState.DiffOnOpen = OpenChangedFileAction == OpenChangedFileAction.Diff;
                settings.Save();
            });

            OpenFile = ReactiveCommand.Create();
            DiffFile = ReactiveCommand.Create();
        }
Example #3
0
        public PullRequestListViewModel(
            IRepositoryHost repositoryHost,
            ILocalRepositoryModel repository,
            IPackageSettings settings)
        {
            this.repositoryHost = repositoryHost;
            this.repository     = repository;
            this.settings       = settings;

            Title = Resources.PullRequestsNavigationItemText;

            this.listSettings = settings.UIState
                                .GetOrCreateRepositoryState(repository.CloneUrl)
                                .PullRequests;

            States = new List <PullRequestState> {
                new PullRequestState {
                    IsOpen = true, Name = "Open"
                },
                new PullRequestState {
                    IsOpen = false, Name = "Closed"
                },
                new PullRequestState {
                    Name = "All"
                }
            };

            trackingAuthors = new TrackingCollection <IAccount>(Observable.Empty <IAccount>(),
                                                                OrderedComparer <IAccount> .OrderByDescending(x => x.Login).Compare);
            trackingAssignees = new TrackingCollection <IAccount>(Observable.Empty <IAccount>(),
                                                                  OrderedComparer <IAccount> .OrderByDescending(x => x.Login).Compare);
            trackingAuthors.Subscribe();
            trackingAssignees.Subscribe();

            Authors   = trackingAuthors.CreateListenerCollection(EmptyUser, this.WhenAnyValue(x => x.SelectedAuthor));
            Assignees = trackingAssignees.CreateListenerCollection(EmptyUser, this.WhenAnyValue(x => x.SelectedAssignee));

            PullRequests          = new TrackingCollection <IPullRequestModel>();
            pullRequests.Comparer = OrderedComparer <IPullRequestModel> .OrderByDescending(x => x.UpdatedAt).Compare;

            pullRequests.NewerComparer = OrderedComparer <IPullRequestModel> .OrderByDescending(x => x.UpdatedAt).Compare;

            this.WhenAny(x => x.SelectedState, x => x.Value)
            .Where(x => PullRequests != null)
            .Subscribe(s => UpdateFilter(s, SelectedAssignee, SelectedAuthor));

            this.WhenAny(x => x.SelectedAssignee, x => x.Value)
            .Where(x => PullRequests != null && x != EmptyUser && IsLoaded)
            .Subscribe(a => UpdateFilter(SelectedState, a, SelectedAuthor));

            this.WhenAny(x => x.SelectedAuthor, x => x.Value)
            .Where(x => PullRequests != null && x != EmptyUser && IsLoaded)
            .Subscribe(a => UpdateFilter(SelectedState, SelectedAssignee, a));

            SelectedState   = States.FirstOrDefault(x => x.Name == listSettings.SelectedState) ?? States[0];
            OpenPullRequest = ReactiveCommand.Create();
            OpenPullRequest.Subscribe(DoOpenPullRequest);
            CreatePullRequest = ReactiveCommand.Create();
            CreatePullRequest.Subscribe(_ => DoCreatePullRequest());
        }
Example #4
0
        public PullRequestListViewModel(
            IRepositoryHost repositoryHost,
            ILocalRepositoryModel repository,
            IPackageSettings settings)
        {
            this.repositoryHost = repositoryHost;
            this.repository     = repository;
            this.settings       = settings;

            this.listSettings = settings.UIState
                                .GetOrCreateRepositoryState(repository.CloneUrl)
                                .PullRequests;

            openPullRequestCommand = ReactiveCommand.Create();
            openPullRequestCommand.Subscribe(_ =>
            {
                VisualStudio.Services.DefaultExportProvider.GetExportedValue <IVisualStudioBrowser>().OpenUrl(repositoryHost.Address.WebUri);
            });

            States = new List <PullRequestState> {
                new PullRequestState {
                    IsOpen = true, Name = "Open"
                },
                new PullRequestState {
                    IsOpen = false, Name = "Closed"
                },
                new PullRequestState {
                    Name = "All"
                }
            };

            trackingAuthors = new TrackingCollection <IAccount>(Observable.Empty <IAccount>(),
                                                                OrderedComparer <IAccount> .OrderByDescending(x => x.Login).Compare);
            trackingAssignees = new TrackingCollection <IAccount>(Observable.Empty <IAccount>(),
                                                                  OrderedComparer <IAccount> .OrderByDescending(x => x.Login).Compare);
            trackingAuthors.Subscribe();
            trackingAssignees.Subscribe();

            Authors   = trackingAuthors.CreateListenerCollection(EmptyUser, this.WhenAnyValue(x => x.SelectedAuthor));
            Assignees = trackingAssignees.CreateListenerCollection(EmptyUser, this.WhenAnyValue(x => x.SelectedAssignee));

            PullRequests          = new TrackingCollection <IPullRequestModel>();
            pullRequests.Comparer = OrderedComparer <IPullRequestModel> .OrderByDescending(x => x.UpdatedAt).Compare;

            pullRequests.NewerComparer = OrderedComparer <IPullRequestModel> .OrderByDescending(x => x.UpdatedAt).Compare;

            this.WhenAny(x => x.SelectedState, x => x.Value)
            .Where(x => PullRequests != null)
            .Subscribe(s => UpdateFilter(s, SelectedAssignee, SelectedAuthor));

            this.WhenAny(x => x.SelectedAssignee, x => x.Value)
            .Where(x => PullRequests != null && x != EmptyUser && IsLoaded)
            .Subscribe(a => UpdateFilter(SelectedState, a, SelectedAuthor));

            this.WhenAny(x => x.SelectedAuthor, x => x.Value)
            .Where(x => PullRequests != null && x != EmptyUser && IsLoaded)
            .Subscribe(a => UpdateFilter(SelectedState, SelectedAssignee, a));

            SelectedState = States.FirstOrDefault(x => x.Name == listSettings.SelectedState) ?? States[0];
        }
 PullRequestListViewModel(
     IConnectionRepositoryHostMap connectionRepositoryHostMap,
     ITeamExplorerServiceHolder teservice,
     IPackageSettings settings)
     : this(connectionRepositoryHostMap.CurrentRepositoryHost, teservice.ActiveRepo, settings)
 {
 }
        public GitHubConnectSection(IGitHubServiceProvider serviceProvider,
                                    ISimpleApiClientFactory apiFactory,
                                    ITeamExplorerServiceHolder holder,
                                    IConnectionManager manager,
                                    IPackageSettings packageSettings,
                                    IVSServices vsServices,
                                    ILocalRepositories localRepositories,
                                    int index)
            : base(serviceProvider, apiFactory, holder, manager)
        {
            Guard.ArgumentNotNull(apiFactory, nameof(apiFactory));
            Guard.ArgumentNotNull(holder, nameof(holder));
            Guard.ArgumentNotNull(manager, nameof(manager));
            Guard.ArgumentNotNull(packageSettings, nameof(packageSettings));
            Guard.ArgumentNotNull(vsServices, nameof(vsServices));
            Guard.ArgumentNotNull(localRepositories, nameof(localRepositories));

            Title        = "GitHub";
            IsEnabled    = true;
            IsVisible    = false;
            LoggedIn     = false;
            sectionIndex = index;

            this.packageSettings   = packageSettings;
            this.vsServices        = vsServices;
            this.localRepositories = localRepositories;

            Clone = CreateAsyncCommandHack(DoClone);

            connectionManager.Connections.CollectionChanged += RefreshConnections;
            PropertyChanged += OnPropertyChange;
            UpdateConnection();
        }
 public GitHubConnectSection0(ISimpleApiClientFactory apiFactory,
     ITeamExplorerServiceHolder holder,
     IConnectionManager manager,
     IPackageSettings settings)
     : base(apiFactory, holder, manager, settings, 0)
 {
 }
Example #8
0
 /// <summary>
 /// Create new command view model.
 /// </summary>
 /// <param name="commandName">Command UI name.</param>
 /// <param name="scope">The default scope where this command was found the first time.</param>
 /// <param name="combination">The first combination which was found for this command.</param>
 /// <param name="packageSettings">Current Visual Studio settings.</param>
 public CommandViewModel(string commandName, string scope, KeyCombination combination, IPackageSettings packageSettings)
 {
     this.commandName     = commandName;
     this.packageSettings = packageSettings;
     this.AddScope(scope);
     this.AddCombination(combination);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="PullRequestDetailViewModel"/> class.
        /// </summary>
        /// <param name="repositoryHost">The repository host.</param>
        /// <param name="teservice">The team explorer service.</param>
        /// <param name="pullRequestsService">The pull requests service.</param>
        /// <param name="avatarProvider">The avatar provider.</param>
        public PullRequestDetailViewModel(
            ILocalRepositoryModel repository,
            IModelService modelService,
            IPullRequestService pullRequestsService,
            IPackageSettings settings)
        {
            this.repository = repository;
            this.modelService = modelService;
            this.pullRequestsService = pullRequestsService;

            Checkout = ReactiveCommand.CreateAsyncObservable(
                this.WhenAnyValue(x => x.CheckoutState)
                    .Cast<CheckoutCommandState>()
                    .Select(x => x != null && x.DisabledMessage == null), 
                DoCheckout);
            Checkout.ThrownExceptions.Subscribe(x => OperationError = x.Message);

            Pull = ReactiveCommand.CreateAsyncObservable(
                this.WhenAnyValue(x => x.UpdateState)
                    .Cast<UpdateCommandState>()
                    .Select(x => x != null && x.PullDisabledMessage == null),
                DoPull);
            Pull.ThrownExceptions.Subscribe(x => OperationError = x.Message);

            Push = ReactiveCommand.CreateAsyncObservable(
                this.WhenAnyValue(x => x.UpdateState)
                    .Cast<UpdateCommandState>()
                    .Select(x => x != null && x.PushDisabledMessage == null),
                DoPush);
            Push.ThrownExceptions.Subscribe(x => OperationError = x.Message);

            OpenOnGitHub = ReactiveCommand.Create();

            ChangedFilesViewType = (settings.UIState?.PullRequestDetailState?.ShowTree ?? true) ?
                ChangedFilesViewType.TreeView : ChangedFilesViewType.ListView;

            ToggleChangedFilesView = ReactiveCommand.Create();
            ToggleChangedFilesView.Subscribe(_ =>
            {
                ChangedFilesViewType = ChangedFilesViewType == ChangedFilesViewType.TreeView ?
                    ChangedFilesViewType.ListView : ChangedFilesViewType.TreeView;
                settings.UIState.PullRequestDetailState.ShowTree = ChangedFilesViewType == ChangedFilesViewType.TreeView;
                settings.Save();
            });

            OpenChangedFileAction = (settings.UIState?.PullRequestDetailState?.DiffOnOpen ?? true) ?
                OpenChangedFileAction.Diff : OpenChangedFileAction.Open;

            ToggleOpenChangedFileAction = ReactiveCommand.Create();
            ToggleOpenChangedFileAction.Subscribe(_ =>
            {
                OpenChangedFileAction = OpenChangedFileAction == OpenChangedFileAction.Diff ?
                    OpenChangedFileAction.Open : OpenChangedFileAction.Diff;
                settings.UIState.PullRequestDetailState.DiffOnOpen = OpenChangedFileAction == OpenChangedFileAction.Diff;
                settings.Save();
            });

            OpenFile = ReactiveCommand.Create();
            DiffFile = ReactiveCommand.Create();
        }
Example #10
0
        public GitHubConnectSection(IGitHubServiceProvider serviceProvider,
                                    ISimpleApiClientFactory apiFactory,
                                    ITeamExplorerServiceHolder holder,
                                    IConnectionManager manager,
                                    IPackageSettings packageSettings,
                                    IVSServices vsServices,
                                    IRepositoryCloneService cloneService,
                                    IDialogService dialogService,
                                    int index)
            : base(serviceProvider, apiFactory, holder, manager)
        {
            Title        = "GitHub";
            IsEnabled    = true;
            IsVisible    = false;
            LoggedIn     = false;
            sectionIndex = index;

            this.packageSettings = packageSettings;
            this.vsServices      = vsServices;
            this.cloneService    = cloneService;
            this.dialogService   = dialogService;

            Clone = CreateAsyncCommandHack(DoClone);

            connectionManager.Connections.CollectionChanged += RefreshConnections;
            PropertyChanged += OnPropertyChange;
            UpdateConnection();
        }
Example #11
0
 PullRequestListViewModel(
     IConnectionRepositoryHostMap connectionRepositoryHostMap,
     ITeamExplorerServiceHolder teservice,
     IPackageSettings settings)
     : this(connectionRepositoryHostMap.CurrentRepositoryHost, teservice.ActiveRepo, settings)
 {
 }
 public GitHubConnectSection0(IGitHubServiceProvider serviceProvider,
     ISimpleApiClientFactory apiFactory,
     ITeamExplorerServiceHolder holder,
     IConnectionManager manager,
     IPackageSettings settings)
     : base(serviceProvider, apiFactory, holder, manager, settings, 0)
 {
 }
Example #13
0
 public GitHubConnectSection1(IGitHubServiceProvider serviceProvider,
                              ISimpleApiClientFactory apiFactory,
                              ITeamExplorerServiceHolder holder,
                              IConnectionManager manager,
                              IPackageSettings settings,
                              IVSServices vsServices,
                              ILocalRepositories localRepositories)
     : base(serviceProvider, apiFactory, holder, manager, settings, vsServices, localRepositories, 1)
 {
 }
 public UsageTracker(
     IGitHubServiceProvider gitHubServiceProvider,
     IUsageService service,
     IPackageSettings settings)
 {
     this.gitHubServiceProvider = gitHubServiceProvider;
     this.service      = service;
     this.userSettings = settings;
     timer             = StartTimer();
 }
Example #15
0
 PullRequestListViewModel(
     IConnectionRepositoryHostMap connectionRepositoryHostMap,
     ITeamExplorerServiceHolder teservice,
     IPackageSettings settings)
     : this(connectionRepositoryHostMap.CurrentRepositoryHost, teservice.ActiveRepo, settings)
 {
     Guard.ArgumentNotNull(connectionRepositoryHostMap, nameof(connectionRepositoryHostMap));
     Guard.ArgumentNotNull(teservice, nameof(teservice));
     Guard.ArgumentNotNull(settings, nameof(settings));
 }
        public PullRequestListViewModel(
            IRepositoryHost repositoryHost,
            ILocalRepositoryModel repository,
            IPackageSettings settings)
        {
            this.repositoryHost = repositoryHost;
            this.repository = repository;
            this.settings = settings;

            Title = Resources.PullRequestsNavigationItemText;

            this.listSettings = settings.UIState
                .GetOrCreateRepositoryState(repository.CloneUrl)
                .PullRequests;

            openPullRequestCommand = ReactiveCommand.Create();
            openPullRequestCommand.Subscribe(_ =>
            {
                VisualStudio.Services.DefaultExportProvider.GetExportedValue<IVisualStudioBrowser>().OpenUrl(repositoryHost.Address.WebUri);
            });

            States = new List<PullRequestState> {
                new PullRequestState { IsOpen = true, Name = "Open" },
                new PullRequestState { IsOpen = false, Name = "Closed" },
                new PullRequestState { Name = "All" }
            };

            trackingAuthors = new TrackingCollection<IAccount>(Observable.Empty<IAccount>(),
                OrderedComparer<IAccount>.OrderByDescending(x => x.Login).Compare);
            trackingAssignees = new TrackingCollection<IAccount>(Observable.Empty<IAccount>(),
                OrderedComparer<IAccount>.OrderByDescending(x => x.Login).Compare);
            trackingAuthors.Subscribe();
            trackingAssignees.Subscribe();

            Authors = trackingAuthors.CreateListenerCollection(EmptyUser, this.WhenAnyValue(x => x.SelectedAuthor));
            Assignees = trackingAssignees.CreateListenerCollection(EmptyUser, this.WhenAnyValue(x => x.SelectedAssignee));

            PullRequests = new TrackingCollection<IPullRequestModel>();
            pullRequests.Comparer = OrderedComparer<IPullRequestModel>.OrderByDescending(x => x.UpdatedAt).Compare;
            pullRequests.NewerComparer = OrderedComparer<IPullRequestModel>.OrderByDescending(x => x.UpdatedAt).Compare;

            this.WhenAny(x => x.SelectedState, x => x.Value)
                .Where(x => PullRequests != null)
                .Subscribe(s => UpdateFilter(s, SelectedAssignee, SelectedAuthor));

            this.WhenAny(x => x.SelectedAssignee, x => x.Value)
                .Where(x => PullRequests != null && x != EmptyUser && IsLoaded)
                .Subscribe(a => UpdateFilter(SelectedState, a, SelectedAuthor));

            this.WhenAny(x => x.SelectedAuthor, x => x.Value)
                .Where(x => PullRequests != null && x != EmptyUser && IsLoaded)
                .Subscribe(a => UpdateFilter(SelectedState, SelectedAssignee, a));

            SelectedState = States.FirstOrDefault(x => x.Name == listSettings.SelectedState) ?? States[0];
        }
Example #17
0
 public GitHubConnectSection1(IGitHubServiceProvider serviceProvider,
                              ISimpleApiClientFactory apiFactory,
                              ITeamExplorerServiceHolder holder,
                              IConnectionManager manager,
                              IPackageSettings settings,
                              IVSServices vsServices,
                              IRepositoryCloneService cloneService,
                              IDialogService dialogService)
     : base(serviceProvider, apiFactory, holder, manager, settings, vsServices, cloneService, dialogService, 1)
 {
 }
Example #18
0
 PullRequestDetailViewModel(
     IConnectionRepositoryHostMap connectionRepositoryHostMap,
     ITeamExplorerServiceHolder teservice,
     IPullRequestService pullRequestsService,
     IPackageSettings settings)
     : this(teservice.ActiveRepo,
            connectionRepositoryHostMap.CurrentRepositoryHost.ModelService,
            pullRequestsService,
            settings)
 {
 }
Example #19
0
 public GitHubConnectSection0(IGitHubServiceProvider serviceProvider,
                              ISimpleApiClientFactory apiFactory,
                              ITeamExplorerServiceHolder holder,
                              IConnectionManager manager,
                              IPackageSettings settings,
                              ITeamExplorerServices teamExplorerServices,
                              ILocalRepositories localRepositories,
                              IUsageTracker usageTracker)
     : base(serviceProvider, apiFactory, holder, manager, settings, teamExplorerServices, localRepositories, usageTracker, 0)
 {
 }
 PullRequestDetailViewModel(
     IConnectionRepositoryHostMap connectionRepositoryHostMap,
     ITeamExplorerServiceHolder teservice,
     IPullRequestService pullRequestsService,
     IPackageSettings settings)
     : this(teservice.ActiveRepo,
           connectionRepositoryHostMap.CurrentRepositoryHost.ModelService,
           pullRequestsService,
           settings)
 {
 }
        protected override void OnActivate(CancelEventArgs e)
        {
            if (!ExportForVisualStudioProcessAttribute.IsVisualStudioProcess())
            {
                log.Warning("Don't activate options for non-Visual Studio process");
                return;
            }

            base.OnActivate(e);
            packageSettings = Services.DefaultExportProvider.GetExportedValue <IPackageSettings>();
            LoadSettings();
        }
Example #22
0
        public UsageTracker(
            IProgram program,
            IConnectionManager connectionManager,
            IPackageSettings userSettings,
            IVSServices vsservices,
            [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider)
        {
            fileExists  = (path) => System.IO.File.Exists(path);
            readAllText = (path, encoding) =>
            {
                try
                {
                    return(System.IO.File.ReadAllText(path, encoding));
                }
                catch
                {
                    return(null);
                }
            };
            writeAllText = (path, content, encoding) =>
            {
                try
                {
                    System.IO.File.WriteAllText(path, content, encoding);
                }
                catch {}
            };
            dirCreate = (path) => System.IO.Directory.CreateDirectory(path);

            this.connectionManager = connectionManager;
            this.userSettings      = userSettings;
            this.vsservices        = vsservices;
            this.client            = serviceProvider.GetExportedValue <IMetricsService>();
            this.timer             = new DispatcherTimer(
                TimeSpan.FromMinutes(1),
                DispatcherPriority.Background,
                TimerTick,
                Dispatcher.CurrentDispatcher);
            this.storePath = System.IO.Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                program.ApplicationName,
                StoreFileName);

            userSettings.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(userSettings.CollectMetrics))
                {
                    UpdateTimer(false);
                }
            };

            UpdateTimer(true);
        }
 PullRequestListViewModel(
     IGlobalConnection connection,
     IModelServiceFactory modelServiceFactory,
     ITeamExplorerServiceHolder teservice,
     IPackageSettings settings,
     IVisualStudioBrowser visualStudioBrowser)
     : this(connection.Get(), modelServiceFactory, teservice.ActiveRepo, settings, visualStudioBrowser)
 {
     Guard.ArgumentNotNull(connection, nameof(connection));
     Guard.ArgumentNotNull(teservice, nameof(teservice));
     Guard.ArgumentNotNull(settings, nameof(settings));
 }
Example #24
0
 public UsageTracker(
     IGitHubServiceProvider gitHubServiceProvider,
     IUsageService service,
     IPackageSettings settings,
     JoinableTaskContext joinableTaskContext)
 {
     this.gitHubServiceProvider = gitHubServiceProvider;
     this.service        = service;
     this.userSettings   = settings;
     JoinableTaskContext = joinableTaskContext;
     timer = StartTimer();
 }
Example #25
0
 public PullRequestFileMarginProvider(
     IToggleInlineCommentMarginCommand enableInlineCommentsCommand,
     IGoToSolutionOrPullRequestFileCommand goToSolutionOrPullRequestFileCommand,
     IPullRequestSessionManager sessionManager,
     IPackageSettings packageSettings,
     Lazy <IUsageTracker> usageTracker)
 {
     this.enableInlineCommentsCommand          = enableInlineCommentsCommand;
     this.goToSolutionOrPullRequestFileCommand = goToSolutionOrPullRequestFileCommand;
     this.sessionManager  = sessionManager;
     this.packageSettings = packageSettings;
     this.usageTracker    = usageTracker;
 }
Example #26
0
 public InlineCommentMarginProvider(
     IEditorFormatMapService editorFormatMapService,
     IViewTagAggregatorFactoryService tagAggregatorFactory,
     IInlineCommentPeekService peekService,
     IPullRequestSessionManager sessionManager,
     IPackageSettings packageSettings)
 {
     this.editorFormatMapService = editorFormatMapService;
     this.tagAggregatorFactory   = tagAggregatorFactory;
     this.peekService            = peekService;
     this.sessionManager         = sessionManager;
     this.packageSettings        = packageSettings;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandsInfoWindow"/> class.
        /// </summary>
        /// <param name="servicesProvider">The services provider.</param>
        internal CommandsInfoWindow(IAppServiceProvider servicesProvider)
        {
            this.DataContext = new CommandsPresenter(servicesProvider, this);
            this.InitializeComponent();

            this.packageSettings = servicesProvider.GetService <IPackageSettings>();
            this.packageSettings.SettingsChanged += (sender, args) => this.UpdateTheme();

            this.UpdateTheme();

            this.SizeChanged += this.OnSizeChanged;

            this.IsOpen = false;
        }
Example #28
0
        async Task Initialize()
        {
            // The services needed by the usage tracker are loaded when they are first needed to
            // improve the startup time of the extension.
            if (!initialized)
            {
                await ThreadingHelper.SwitchToMainThreadAsync();

                client            = gitHubServiceProvider.TryGetService <IMetricsService>();
                connectionManager = gitHubServiceProvider.GetService <IConnectionManager>();
                userSettings      = gitHubServiceProvider.GetService <IPackageSettings>();
                vsservices        = gitHubServiceProvider.GetService <IVSServices>();
                initialized       = true;
            }
        }
Example #29
0
        /// <summary>
        /// 实例化ClientHandler
        /// </summary>
        /// <param name="connection">接收消息的Socket.</param>
        /// <param name="bufferSize">接收数据的缓冲大小.</param>
        //internal ClientHandler(Socket connection, Int32 bufferSize, Encoding encoding, SocketAsyncEventArgs context)
        //{

        //    // ClientUID
        //    this.Client = new ClientInfo(System.Guid.NewGuid().ToString("N"));

        //    this.connection = connection;
        //    this.encoding = encoding;
        //}

        public TcpClientProxy(System.Net.Sockets.Socket connection, IPackageSettings settings)
        {
            // ClientUID
            //this.Client = new ClientInfo(System.Guid.NewGuid().ToString("N"));

            this.GUID     = System.Guid.NewGuid().ToString("N");
            _clientSocket = connection;
            _clientBuffer = new byte[settings.BufferSize];
            _encoding     = settings.Encoding;

            // Default
            byte[] prefixBytes = Encoding.Default.GetBytes(settings.PrefixString);
            int    length      = Convert.ToInt32(settings.LengthString);

            DefaultOperater = new PackageOperater(prefixBytes, length);
        }
Example #30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandsPresenter"/> class.
        /// </summary>
        /// <param name="servicesProvider">
        /// The services Provider.
        /// </param>
        /// <param name="window">
        /// The window.
        /// </param>
        public CommandsPresenter(IAppServiceProvider servicesProvider, ICommandsInfoWindow window)
        {
            this.window = window;

            this.servicesProvider    = servicesProvider;
            this.dispatcher          = servicesProvider.GetService <Dispatcher>();
            this.commandScopeService = servicesProvider.GetService <ICommandScopeService>();
            this.listenerService     = servicesProvider.GetService <IKeyboardListenerService>();
            this.packageSettings     = servicesProvider.GetService <IPackageSettings>();

            this.packageSettings.SettingsChanged += this.PackageSettingsOnSettingsChanged;
            this.PackageSettingsOnSettingsChanged(this, EventArgs.Empty);

            this.commandInfos = new CommandInfosLoader(this.servicesProvider).LoadCommands();

            this.listenerService.KeyDown += this.ListenerServiceOnKeyDown;
            this.listenerService.KeyUp   += this.ListenerServiceOnKeyUp;
        }
        public GitHubConnectSection(ISimpleApiClientFactory apiFactory,
                                    ITeamExplorerServiceHolder holder,
                                    IConnectionManager manager,
                                    IPackageSettings packageSettings,
                                    int index)
            : base(apiFactory, holder, manager)
        {
            Title        = "GitHub";
            IsEnabled    = true;
            IsVisible    = false;
            LoggedIn     = false;
            sectionIndex = index;

            this.packageSettings = packageSettings;

            connectionManager.Connections.CollectionChanged += RefreshConnections;
            PropertyChanged += OnPropertyChange;
            UpdateConnection();
        }
Example #32
0
        async Task Initialize()
        {
            // The services needed by the usage tracker are loaded when they are first needed to
            // improve the startup time of the extension.
            if (userSettings == null)
            {
                await ThreadingHelper.SwitchToMainThreadAsync();

                client            = gitHubServiceProvider.GetService <IMetricsService>();
                connectionManager = gitHubServiceProvider.GetService <IConnectionManager>();
                userSettings      = gitHubServiceProvider.GetService <IPackageSettings>();
                vsservices        = gitHubServiceProvider.GetService <IVSServices>();

                var program = gitHubServiceProvider.GetService <IProgram>();
                storePath = System.IO.Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                    program.ApplicationName,
                    StoreFileName);
            }
        }
Example #33
0
        public GitHubHomeSection(IGitHubServiceProvider serviceProvider,
                                 ISimpleApiClientFactory apiFactory,
                                 ITeamExplorerServiceHolder holder,
                                 IVisualStudioBrowser visualStudioBrowser,
                                 ITeamExplorerServices teamExplorerServices,
                                 IPackageSettings settings,
                                 IUsageTracker usageTracker)
            : base(serviceProvider, apiFactory, holder)
        {
            Title                     = "GitHub";
            View                      = new GitHubHomeContent();
            View.DataContext          = this;
            this.visualStudioBrowser  = visualStudioBrowser;
            this.teamExplorerServices = teamExplorerServices;
            this.settings             = settings;
            this.usageTracker         = usageTracker;

            var openOnGitHub = ReactiveCommand.Create();

            openOnGitHub.Subscribe(_ => DoOpenOnGitHub());
            OpenOnGitHub = openOnGitHub;

            // We want to display a welcome message but only if Team Explorer isn't
            // already displaying the "Install 3rd Party Tools" message. To do this
            // we need to set a timer and check in the tick as at this point the message
            // won't be initialized.
            if (!settings.HideTeamExplorerWelcomeMessage)
            {
                var timer = new DispatcherTimer();
                timer.Interval = new TimeSpan(10);
                timer.Tick    += (s, e) =>
                {
                    timer.Stop();
                    if (!IsGitToolsMessageVisible())
                    {
                        ShowWelcomeMessage();
                    }
                };
                timer.Start();
            }
        }
Example #34
0
        public GitHubHomeSection(IGitHubServiceProvider serviceProvider,
                                 ISimpleApiClientFactory apiFactory,
                                 ITeamExplorerServiceHolder holder,
                                 IVisualStudioBrowser visualStudioBrowser,
                                 ITeamExplorerServices teamExplorerServices,
                                 IPackageSettings settings,
                                 IUsageTracker usageTracker)
            : base(serviceProvider, apiFactory, holder)
        {
            Title                     = "GitHub";
            View                      = new GitHubHomeContent();
            View.DataContext          = this;
            this.visualStudioBrowser  = visualStudioBrowser;
            this.teamExplorerServices = teamExplorerServices;
            this.settings             = settings;
            this.usageTracker         = usageTracker;

            var openOnGitHub = new RelayCommand(_ => DoOpenOnGitHub());

            OpenOnGitHub = openOnGitHub;
        }
Example #35
0
        /// <summary>
        /// 实例化一个面向连接的侦听服务器, 并指定编码格式,最大连接数和读写缓冲大小
        /// </summary>
        /// <param name="maxConnectionNumber">服务器同时处理的最大连接数量.</param>
        /// <param name="receiveBufferSize">每个I/O操作的缓冲大小.</param>
        public TcpServer(IPackageSettings setting)
        {
            // 启动日志
            StartLog();

            _bufferEncoding    = setting.Encoding;
            _backlog           = setting.MaxConnectionNumber;
            _receiveBufferSize = setting.BufferSize;

            _semaphoreAcceptedClients = new Semaphore(_backlog, _backlog);
            _poolOfAcceptEventArgs    = new SocketAsyncEventArgsPool(_backlog);
            _poolOfReadWriteEventArgs = new SocketAsyncEventArgsPool(_backlog);
            //_sendPool = new SocketAsyncEventArgsPool(this._backlog);

            this.Setting = setting;

            // 设置心跳超时
            Timeout = 30; // 默认30秒

            _clientMembers = new TcpClientProxyList();

            InitializeContexts();
        }
Example #36
0
        async Task Initialize()
        {
            // The services needed by the usage tracker are loaded when they are first needed to
            // improve the startup time of the extension.
            if (userSettings == null)
            {
                await ThreadingHelper.SwitchToMainThreadAsync();

                client = uiProvider.GetService<IMetricsService>();
                connectionManager = uiProvider.GetService<IConnectionManager>();
                userSettings = uiProvider.GetService<IPackageSettings>();
                vsservices = uiProvider.GetService<IVSServices>();

                var program = uiProvider.GetService<IProgram>();
                storePath = System.IO.Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                    program.ApplicationName,
                    StoreFileName);
            }
        }
Example #37
0
 protected override void OnActivate(CancelEventArgs e)
 {
     base.OnActivate(e);
     packageSettings = Services.DefaultExportProvider.GetExportedValue<IPackageSettings>();
     LoadSettings();
 }
        public GitHubConnectSection(ISimpleApiClientFactory apiFactory,
            ITeamExplorerServiceHolder holder,
            IConnectionManager manager,
            IPackageSettings packageSettings,
            int index)
            : base(apiFactory, holder, manager)
        {
            Title = "GitHub";
            IsEnabled = true;
            IsVisible = false;
            LoggedIn = false;
            sectionIndex = index;

            this.packageSettings = packageSettings;

            connectionManager.Connections.CollectionChanged += RefreshConnections;
            PropertyChanged += OnPropertyChange;
            UpdateConnection();
        }