Exemple #1
0
 public StashStagedSectionViewModel(IServiceProvider serviceProvider, ITeamExplorerSection section)
 {
     _serviceProvider = serviceProvider;
     _section         = section;
     _teamExplorer    = _serviceProvider.GetService(typeof(ITeamExplorer)) as ITeamExplorer;
     _gitService      = new VisualStudioGitService(serviceProvider);
 }
Exemple #2
0
        public void SectionController_RespondsToIsBusyChanged()
        {
            // Arrange
            SectionController    testSubject = this.CreateTestSubject();
            ITeamExplorerSection viewModel   = testSubject.ViewModel;

            // Act
            this.host.TestStateManager.SetAndInvokeBusyChanged(true);

            // Assert
            viewModel.IsBusy.Should().BeTrue();

            // Act again (different value)
            this.host.TestStateManager.SetAndInvokeBusyChanged(false);

            // Assert (should change)
            viewModel.IsBusy.Should().BeFalse();

            // Dispose
            testSubject.Dispose();

            // Act again(different value)
            this.host.TestStateManager.SetAndInvokeBusyChanged(true);

            // Assert (should remain the same)
            viewModel.IsBusy.Should().BeFalse();
        }
Exemple #3
0
 internal static void SetSectionIsIncluded(ITeamExplorerSection section, bool isIncluded)
 {
     if (isIncluded)
     {
         IncludeSection(section);
     }
     else
     {
         ExcludeSection(section);
     }
 }
 public override void Refresh()
 {
     ITeamExplorerSection[] teamExplorerSections = this.GetSections();
     foreach (var section in teamExplorerSections.Where(s => s is IGitFlowSection))
     {
         ITeamExplorerSection section1 = section;
         System.Windows.Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                                   new Action(() =>
                                                                              ((IGitFlowSection)section1).UpdateVisibleState()));
     }
     ui.Refresh();
 }
Exemple #5
0
        void InitializeInvitationSection()
        {
            // We're only interested in the invitation section if sectionIndex == 0. Don't want to show
            // two "Log In" options.
            if (sectionIndex == 0 && invitationSection == null)
            {
                invitationSection = GetSection(TeamExplorerInvitationBase.TeamExplorerInvitationSectionGuid);

                if (invitationSection != null)
                {
                    invitationSection.PropertyChanged += InvitationSectionPropertyChanged;
                }
            }
        }
Exemple #6
0
        internal static void ExcludeSection(ITeamExplorerSection section)
        {
            var teamExplorerBase = section as TeamExplorerBase;

            if (teamExplorerBase != null)
            {
                teamExplorerBase.IsEnabled = false;
            }
            var handler = GetPropertyChangedHandler(section);

            if (handler != null)
            {
                section.PropertyChanged += handler;
            }
            section.IsVisible = false;
        }
 private void ExtendSection(ITeamExplorerSection section, IEnumerable <IUICommand> commands)
 {
     if (section != null)
     {
         var sectionView = section.SectionContent as DependencyObject;
         var link        = sectionView.FindDescendant <TextLink>();
         if (link?.Parent is WrapPanel)
         {
             foreach (var command in commands)
             {
                 ((WrapPanel)link.Parent).Children.Add(new Border {
                     Width = 1, VerticalAlignment = VerticalAlignment.Stretch, Background = Brushes.Gray, Margin = new Thickness(4, 0, 4, 0)
                 });
                 ((WrapPanel)link.Parent).Children.Add(command.ToTextLink());
             }
         }
     }
 }
Exemple #8
0
 private static PropertyChangedEventHandler GetPropertyChangedHandler(ITeamExplorerSection section)
 {
     if (!includedChangeHandlers.ContainsKey(section))
     {
         includedChangeHandlers.Add(section, (sender, args) =>
         {
             if (args.PropertyName == "IsVisible")
             {
                 //SettingsService settingsService = serviceProvider.Get<SettingsService>();
                 if (section.IsVisible)
                 {
                     section.IsVisible = false;
                 }
             }
         });
     }
     return(includedChangeHandlers[section]);
 }
            public SectionStateTracker(ITeamExplorerSection section, Func <Task> onRefreshed)
            {
                this.section = section;
                machine      = new Stateless.StateMachine <SectionState, string>(SectionState.Idle);
                machine.Configure(SectionState.Idle)
                .PermitIf("IsBusy", SectionState.Busy, () => this.section.IsBusy)
                .IgnoreIf("IsBusy", () => !this.section.IsBusy);
                machine.Configure(SectionState.Busy)
                .Permit("Title", SectionState.Refreshing)
                .PermitIf("IsBusy", SectionState.Idle, () => !this.section.IsBusy)
                .IgnoreIf("IsBusy", () => this.section.IsBusy);
                machine.Configure(SectionState.Refreshing)
                .Ignore("Title")
                .PermitIf("IsBusy", SectionState.Idle, () => !this.section.IsBusy)
                .IgnoreIf("IsBusy", () => this.section.IsBusy)
                .OnExit(() => onRefreshed());

                section.PropertyChanged += TrackState;
            }
        static async Task BringIntoViewAsync(ITeamExplorerSection section)
        {
            var content = section?.SectionContent as UserControl;

            if (section == null)
            {
                return;
            }

            // Wait for section content to load
            await Observable.FromEventPattern(content, nameof(content.Loaded))
            .Select(e => content.IsLoaded)
            .StartWith(content.IsLoaded)
            .Where(l => l == true)
            .Take(1);

            // Specify a tall rectangle to bring section to the top
            var targetRectangle = new Rect(0, 0, 0, 1000);

            content.BringIntoView(targetRectangle);
        }
            public SectionStateTracker(ITeamExplorerSection section, Func<Task> onRefreshed)
            {
                this.section = section;
                machine = new Stateless.StateMachine<SectionState, string>(SectionState.Idle);
                machine.Configure(SectionState.Idle)
                    .PermitIf("IsBusy", SectionState.Busy, () => this.section.IsBusy)
                    .IgnoreIf("IsBusy", () => !this.section.IsBusy);
                machine.Configure(SectionState.Busy)
                    .Permit("Title", SectionState.Refreshing)
                    .PermitIf("IsBusy", SectionState.Idle, () => !this.section.IsBusy)
                    .IgnoreIf("IsBusy", () => this.section.IsBusy);
                machine.Configure(SectionState.Refreshing)
                    .Ignore("Title")
                    .PermitIf("IsBusy", SectionState.Idle, () => !this.section.IsBusy)
                    .IgnoreIf("IsBusy", () => this.section.IsBusy)
                    .OnExit(() => onRefreshed());

                section.PropertyChanged += TrackState;
            }
Exemple #12
0
 public override void Initialize(object sender, SectionInitializeEventArgs e)
 {
     _appServiceProvider.YouTrackServiceProvider = ServiceProvider = e.ServiceProvider;
     _section = GetSection(Guid.Parse(TeamExplorerPageIds.PendingChanges));
     base.Initialize(sender, e);
 }
Exemple #13
0
 public override void Initialize(object sender, SectionInitializeEventArgs e)
 {
     _appServiceProvider.GitServiceProvider = ServiceProvider = e.ServiceProvider;
     _section = GetSection(TeamExplorerConnectionsSectionId);
     base.Initialize(sender, e);
 }
        public StashStagedSection(IServiceProvider serviceProvider, ITeamExplorerSection currentSection)
        {
            InitializeComponent();

            DataContext = _viewModel = new StashStagedSectionViewModel(serviceProvider, currentSection);
        }