private void OnDeleteLocalRepo(Repository repo) { if (repo == null) { return; } string path = repo.Path; if (path.EndsWith(new string(Path.DirectorySeparatorChar, 1))) { path = path.Substring(path.Length - 1, 1); } path += '\0'; var fsStruc = new NativeMethods.SHFILEOPSTRUCT() { wFunc = NativeMethods.FO_DELETE, fFlags = NativeMethods.FOF_ALLOWUNDO, pFrom = path }; try { int result = NativeMethods.SHFileOperation(ref fsStruc); if (result == 0) { Repositories.Remove(repo); } } catch (Exception ex) { _teamexplorer.ShowMessage(ex.Message); } }
void ShowWelcomeMessage() { teamExplorerServices.ShowMessage( Resources.TeamExplorerWelcomeMessage, new RelayCommand(o => { var str = o.ToString(); switch (str) { case "show-training": visualStudioBrowser.OpenUrl(new Uri(TrainingUrl)); usageTracker.IncrementCounter(x => x.NumberOfWelcomeTrainingClicks).Forget(); break; case "show-docs": visualStudioBrowser.OpenUrl(new Uri(GitHubUrls.Documentation)); usageTracker.IncrementCounter(x => x.NumberOfWelcomeDocsClicks).Forget(); break; case "dont-show-again": teamExplorerServices.HideNotification(welcomeMessageGuid); settings.HideTeamExplorerWelcomeMessage = true; settings.Save(); break; } }), false, welcomeMessageGuid); }
async Task CheckLogin() { // this is not a github repo, or it hasn't been published yet if (ActiveRepo == null || ActiveRepoUri == null) { return; } var isgithub = await IsAGitHubRepo(); if (!isgithub) { return; } teServices.ClearNotifications(); var add = HostAddress.Create(ActiveRepoUri); bool loggedIn = await connectionManager.IsLoggedIn(hosts, add); if (!loggedIn) { var msg = string.Format(CultureInfo.CurrentUICulture, Resources.NotLoggedInMessage, add.Title, add.Title); teServices.ShowMessage( msg, new Primitives.RelayCommand(_ => StartFlow(UIControllerFlow.Authentication)) ); } }
private void LoadRepositories() { IReadOnlyList <Repository> known = null; IReadOnlyList <Project> remotes = null; Exception ex = null; Task.Run(async() => { try { remotes = await _web.GetProjectsAsync(); known = Registry.GetKnownRepositories(); } catch (Exception e) { ex = e; } }).ContinueWith(async tsk => { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); if (ex == null) { Repositories.Clear(); var activeRepository = _teamexplorer.GetActiveRepository(); var valid = new List <Repository>(); if (known != null) { foreach (var k in known) { var r = remotes.FirstOrDefault(o => o.Name == k.Name); if (r != null) { k.Icon = r.Icon; valid.Add(k); } } } if (activeRepository != null) { var matched = valid.FirstOrDefault(o => string.Equals(o.Path, activeRepository.Path, StringComparison.OrdinalIgnoreCase)); if (matched != null) { matched.IsActived = true; } } valid.Each(o => Repositories.Add(o)); } else if (!(ex is UnauthorizedAccessException)) { _teamexplorer.ShowMessage(ex.Message); } }, TaskScheduler.Default).Forget(); }
public RepositoryPublishControl(ITeamExplorerServices teServices, INotificationDispatcher notifications) { InitializeComponent(); this.WhenActivated(d => { d(this.BindCommand(ViewModel, vm => vm.PublishRepository, v => v.publishRepositoryButton)); ViewModel.PublishRepository.Subscribe(state => { if (state == ProgressState.Success) { teServices.ShowMessage(UI.Resources.RepositoryPublishedMessage); NotifyDone(); } }); d(this.WhenAny(x => x.ViewModel.IsPublishing, x => x.Value) .Subscribe(x => NotifyIsBusy(x))); d(notifications.Listen() .Where(n => n.Type == Notification.NotificationType.Error) .Subscribe(n => teServices.ShowError(n.Message))); d(this.WhenAny(x => x.ViewModel.SafeRepositoryNameWarningValidator.ValidationResult, x => x.Value) .WhereNotNull() .Select(result => result?.Message) .Subscribe(message => { if (!String.IsNullOrEmpty(message)) { teServices.ShowWarning(message); } else { teServices.ClearNotifications(); } })); nameText.Text = ViewModel.DefaultRepositoryName; }); IsVisibleChanged += (s, e) => { if (IsVisible) { this.TryMoveFocus(FocusNavigationDirection.First).Subscribe(); } }; }
public RepositoryPublishControl(ITeamExplorerServices teServices, INotificationDispatcher notifications) { InitializeComponent(); this.WhenActivated(d => { d(this.OneWayBind(ViewModel, vm => vm.Connections, v => v.hostsComboBox.ItemsSource)); d(this.OneWayBind(ViewModel, vm => vm.IsHostComboBoxVisible, v => v.hostsComboBox.Visibility)); d(this.Bind(ViewModel, vm => vm.SelectedConnection, v => v.hostsComboBox.SelectedItem)); d(this.Bind(ViewModel, vm => vm.RepositoryName, v => v.nameText.Text)); d(this.Bind(ViewModel, vm => vm.Description, v => v.description.Text)); d(this.Bind(ViewModel, vm => vm.KeepPrivate, v => v.makePrivate.IsChecked)); d(this.OneWayBind(ViewModel, vm => vm.CanKeepPrivate, v => v.makePrivate.IsEnabled)); d(this.OneWayBind(ViewModel, vm => vm.Accounts, v => v.accountsComboBox.ItemsSource)); d(this.Bind(ViewModel, vm => vm.SelectedAccount, v => v.accountsComboBox.SelectedItem)); d(this.BindCommand(ViewModel, vm => vm.PublishRepository, v => v.publishRepositoryButton)); d(this.OneWayBind(ViewModel, vm => vm.IsPublishing, v => v.nameText.IsEnabled, x => x == false)); d(this.OneWayBind(ViewModel, vm => vm.IsPublishing, v => v.description.IsEnabled, x => x == false)); d(this.OneWayBind(ViewModel, vm => vm.IsPublishing, v => v.accountsComboBox.IsEnabled, x => x == false)); ViewModel.PublishRepository.Subscribe(state => { if (state == ProgressState.Success) { teServices.ShowMessage(UI.Resources.RepositoryPublishedMessage); NotifyDone(); } }); d(this.WhenAny(x => x.ViewModel.IsPublishing, x => x.Value) .Subscribe(x => NotifyIsBusy(x))); d(notifications.Listen() .Where(n => n.Type == Notification.NotificationType.Error) .Subscribe(n => teServices.ShowError(n.Message))); d(this.WhenAny(x => x.ViewModel.SafeRepositoryNameWarningValidator.ValidationResult, x => x.Value) .WhereNotNull() .Select(result => result?.Message) .Subscribe(message => { if (!String.IsNullOrEmpty(message)) { teServices.ShowWarning(message); } else { teServices.ClearNotifications(); } })); nameText.Text = ViewModel.DefaultRepositoryName; }); IsVisibleChanged += (s, e) => { if (IsVisible) { this.TryMoveFocus(FocusNavigationDirection.First).Subscribe(); } }; }