This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +66
-4
lines changed
GitHub.VisualStudio/UI/Views/Controls Expand file tree Collapse file tree 5 files changed +66
-4
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,13 @@ public class ViewBase : ContentControl
4242 typeof ( ViewBase ) ,
4343 new FrameworkPropertyMetadata ( ) ) ;
4444
45+ static readonly DependencyProperty ShowBusyStateProperty =
46+ DependencyProperty . Register (
47+ nameof ( ShowBusyState ) ,
48+ typeof ( bool ) ,
49+ typeof ( ViewBase ) ,
50+ new FrameworkPropertyMetadata ( true ) ) ;
51+
4552 public static readonly DependencyProperty HasBusyStateProperty = HasBusyStatePropertyKey . DependencyProperty ;
4653 public static readonly DependencyProperty IsBusyProperty = IsBusyPropertyKey . DependencyProperty ;
4754 public static readonly DependencyProperty IsLoadingProperty = IsLoadingPropertyKey . DependencyProperty ;
@@ -83,6 +90,15 @@ public bool IsLoading
8390 protected set { SetValue ( IsLoadingPropertyKey , value ) ; }
8491 }
8592
93+ /// <summary>
94+ /// Gets or sets a value indicating whether to display the view model's busy state.
95+ /// </summary>
96+ public bool ShowBusyState
97+ {
98+ get { return ( bool ) GetValue ( ShowBusyStateProperty ) ; }
99+ set { SetValue ( ShowBusyStateProperty , value ) ; }
100+ }
101+
86102 internal ViewBase ( )
87103 {
88104 }
Original file line number Diff line number Diff line change 3232
3333 <ui : GitHubProgressBar Foreground =" {DynamicResource GitHubAccentBrush}"
3434 IsIndeterminate =" True"
35- Style =" {DynamicResource GitHubProgressBar}"
36- Visibility =" {TemplateBinding IsBusy, Converter={ui:BooleanToHiddenVisibilityConverter}}" />
35+ Style =" {DynamicResource GitHubProgressBar}" >
36+ <ui : GitHubProgressBar .Visibility>
37+ <MultiBinding Converter =" {ui:MultiBooleanToVisibilityConverter}" >
38+ <Binding RelativeSource =" {RelativeSource TemplatedParent}" Path =" IsBusy" />
39+ <Binding RelativeSource =" {RelativeSource TemplatedParent}" Path =" ShowBusyState" />
40+ </MultiBinding >
41+ </ui : GitHubProgressBar .Visibility>
42+ </ui : GitHubProgressBar >
3743
3844 <c : Spinner Name =" spinner"
3945 Grid.Row=" 1"
4046 Width =" 48"
4147 Height =" 48"
4248 HorizontalAlignment =" Center"
43- VerticalAlignment =" Center"
44- Visibility =" {TemplateBinding IsLoading, Converter={ui:BooleanToVisibilityConverter}}" />
49+ VerticalAlignment =" Center" >
50+ <c : Spinner .Visibility>
51+ <MultiBinding Converter =" {ui:MultiBooleanToVisibilityConverter}" >
52+ <Binding RelativeSource =" {RelativeSource TemplatedParent}" Path =" IsLoading" />
53+ <Binding RelativeSource =" {RelativeSource TemplatedParent}" Path =" ShowBusyState" />
54+ </MultiBinding >
55+ </c : Spinner .Visibility>
56+ </c : Spinner >
4557
4658 <ContentPresenter Grid.Row=" 1"
4759 HorizontalAlignment =" {TemplateBinding HorizontalContentAlignment}"
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Globalization ;
3+ using System . Linq ;
4+ using System . Windows ;
5+ using NullGuard ;
6+
7+ namespace GitHub . UI
8+ {
9+ [ Localizability ( LocalizationCategory . NeverLocalize ) ]
10+ public sealed class MultiBooleanToVisibilityConverter : MultiValueConverterMarkupExtension < MultiBooleanToVisibilityConverter >
11+ {
12+ readonly System . Windows . Controls . BooleanToVisibilityConverter converter = new System . Windows . Controls . BooleanToVisibilityConverter ( ) ;
13+
14+ public override object Convert (
15+ [ AllowNull ] object [ ] value ,
16+ [ AllowNull ] Type targetType ,
17+ [ AllowNull ] object parameter ,
18+ [ AllowNull ] CultureInfo culture )
19+ {
20+ return value . OfType < bool > ( ) . All ( x => x ) ? Visibility . Visible : Visibility . Collapsed ;
21+ }
22+
23+ public override object [ ] ConvertBack (
24+ [ AllowNull ] object value ,
25+ [ AllowNull ] Type [ ] targetType ,
26+ [ AllowNull ] object parameter ,
27+ [ AllowNull ] CultureInfo culture )
28+ {
29+ return null ;
30+ }
31+ }
32+ }
Original file line number Diff line number Diff line change 9191 <DependentUpon >Spinner.xaml</DependentUpon >
9292 </Compile >
9393 <Compile Include =" Converters\AllCapsConverter.cs" />
94+ <Compile Include =" Converters\MultiBooleanToVisibilityConverter.cs" />
9495 <Compile Include =" Converters\NullToVisibilityConverter.cs" />
9596 <Compile Include =" Converters\BranchNameConverter.cs" />
9697 <Compile Include =" Converters\CountToVisibilityConverter.cs" />
Original file line number Diff line number Diff line change 1515 d : DesignWidth =" 414"
1616 d : DesignHeight =" 440"
1717 Style =" {DynamicResource DialogUserControl}"
18+ ShowBusyState =" False"
1819 AutomationProperties.AutomationId=" {x:Static automation:AutomationIDs.TwoFactorAuthenticationCustom}" >
1920
2021 <Control .Resources>
You can’t perform that action at this time.
0 commit comments