Skip to content

Commit 103dc01

Browse files
committed
enhance: button states in Bisect toolbar
Signed-off-by: leo <longshuang@msn.cn>
1 parent 0723ef8 commit 103dc01

3 files changed

Lines changed: 26 additions & 9 deletions

File tree

‎src/Models/Bisect.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ namespace SourceGit.Models
66
public enum BisectState
77
{
88
None = 0,
9-
WaitingForRange,
9+
WaitingForFirstBad,
10+
WaitingForFirstGood,
1011
Detecting,
1112
}
1213

‎src/ViewModels/Histories.cs‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,13 @@ public Models.BisectState UpdateBisectInfo()
212212

213213
Bisect = info;
214214

215-
if (info.Bads.Count == 0 || info.Goods.Count == 0)
216-
return Models.BisectState.WaitingForRange;
217-
else
218-
return Models.BisectState.Detecting;
215+
if (info.Bads.Count == 0)
216+
return Models.BisectState.WaitingForFirstBad;
217+
218+
if (info.Goods.Count == 0)
219+
return Models.BisectState.WaitingForFirstGood;
220+
221+
return Models.BisectState.Detecting;
219222
}
220223

221224
public void NavigateTo(string commitSHA)

‎src/Views/Repository.axaml‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,14 @@
792792
FontWeight="Bold"
793793
Margin="8,0"
794794
Foreground="{DynamicResource Brush.Conflict.Foreground}"
795-
Text="{DynamicResource Text.Bisect.WaitingForRange}"
796-
IsVisible="{Binding BisectState, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:BisectState.WaitingForRange}}"/>
795+
Text="{DynamicResource Text.Bisect.WaitingForRange}">
796+
<TextBlock.IsVisible>
797+
<MultiBinding Converter="{x:Static BoolConverters.Or}">
798+
<Binding Path="BisectState" Converter="{x:Static ObjectConverters.Equal}" ConverterParameter="{x:Static m:BisectState.WaitingForFirstBad}"/>
799+
<Binding Path="BisectState" Converter="{x:Static ObjectConverters.Equal}" ConverterParameter="{x:Static m:BisectState.WaitingForFirstGood}"/>
800+
</MultiBinding>
801+
</TextBlock.IsVisible>
802+
</TextBlock>
797803

798804
<TextBlock Grid.Column="0"
799805
FontWeight="Bold"
@@ -813,10 +819,16 @@
813819
FontWeight="Regular"
814820
BorderThickness="0"
815821
Content="{DynamicResource Text.Bisect.Good}"
816-
IsEnabled="{Binding !IsBisectCommandRunning}"
817822
Padding="8,2"
818823
Click="OnBisectCommand"
819-
Tag="good"/>
824+
Tag="good">
825+
<Button.IsEnabled>
826+
<MultiBinding Converter="{x:Static BoolConverters.And}">
827+
<Binding Path="IsBisectCommandRunning" Converter="{x:Static BoolConverters.Not}"/>
828+
<Binding Path="BisectState" Converter="{x:Static ObjectConverters.NotEqual}" ConverterParameter="{x:Static m:BisectState.WaitingForFirstBad}"/>
829+
</MultiBinding>
830+
</Button.IsEnabled>
831+
</Button>
820832
<Button Grid.Column="3"
821833
Classes="flat"
822834
Margin="4,0"
@@ -833,6 +845,7 @@
833845
FontWeight="Regular"
834846
BorderThickness="0"
835847
Content="{DynamicResource Text.Bisect.Skip}"
848+
IsVisible="{Binding BisectState, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:BisectState.Detecting}}"
836849
IsEnabled="{Binding !IsBisectCommandRunning}"
837850
Padding="8,2"
838851
Click="OnBisectCommand"

0 commit comments

Comments
 (0)