Skip to content

Commit

Permalink
Use binding instead of tri state check box
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosifne committed Jun 25, 2021
1 parent 39f4e23 commit 5cb76b7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,11 @@ public async ValueTask<ImmutableArray<InheritanceMarginItem>> GetInheritanceMemb
}

var solution = project.Solution;
var serializedInheritanceMarginItems = ImmutableArray<SerializableInheritanceMarginItem>.Empty;
using (Logger.LogBlock(FunctionId.InheritanceMargin_TraverseInheritanceChain, cancellationToken, LogLevel.Information))
{
serializedInheritanceMarginItems = await GetInheritanceMemberItemAsync(
solution,
project.Id,
symbolKeyAndLineNumbers,
cancellationToken).ConfigureAwait(false);
}
var serializedInheritanceMarginItems = await GetInheritanceMemberItemAsync(
solution,
project.Id,
symbolKeyAndLineNumbers,
cancellationToken).ConfigureAwait(false);

return await serializedInheritanceMarginItems.SelectAsArrayAsync(
(serializedItem, _) => InheritanceMarginItem.ConvertAsync(solution, serializedItem, cancellationToken), cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,6 @@
<StackPanel>
<CheckBox x:Uid="ShowInheritanceMargin"
x:Name="ShowInheritanceMargin"
IsThreeState="True"
Checked="ShowInheritanceMargin_Changed"
Unchecked="ShowInheritanceMargin_Changed"
Indeterminate="ShowInheritanceMargin_Changed"
Content="{x:Static local:AdvancedOptionPageStrings.Show_inheritance_margin}"/>
</StackPanel>
</GroupBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ public AdvancedOptionPageControl(OptionStore optionStore, IComponentModel compon
BindToOption(ShowHintsForLambdaParameterTypes, InlineHintsOptions.ForLambdaParameterTypes, LanguageNames.CSharp);
BindToOption(ShowHintsForImplicitObjectCreation, InlineHintsOptions.ForImplicitObjectCreation, LanguageNames.CSharp);

ShowInheritanceMargin.IsChecked = OptionStore.GetOption(FeatureOnOffOptions.ShowInheritanceMargin, LanguageNames.CSharp);
// If the option has not been set by the user, check if the option is enabled from experimentation.
// If so, default to that. Otherwise default to disabled
BindToOption(ShowInheritanceMargin, FeatureOnOffOptions.ShowInheritanceMargin, LanguageNames.CSharp, () =>
experimentationService?.IsExperimentEnabled(WellKnownExperimentNames.InheritanceMargin) ?? false);
}

// Since this dialog is constructed once for the lifetime of the application and VS Theme can be changed after the application has started,
Expand Down Expand Up @@ -218,11 +221,5 @@ private void DisplayInlineTypeHints_Unchecked(object sender, RoutedEventArgs e)
this.OptionStore.SetOption(InlineHintsOptions.EnabledForTypes, LanguageNames.CSharp, false);
UpdateInlineHintsOptions();
}

private void ShowInheritanceMargin_Changed(object sender, RoutedEventArgs e)
{
this.ShowInheritanceMargin.IsThreeState = false;
this.OptionStore.SetOption(FeatureOnOffOptions.ShowInheritanceMargin, LanguageNames.CSharp, this.ShowInheritanceMargin.IsChecked);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,6 @@
<StackPanel>
<CheckBox x:Uid="ShowInheritanceMargin"
x:Name="ShowInheritanceMargin"
IsThreeState="True"
Checked="ShowInheritanceMargin_Changed"
Unchecked="ShowInheritanceMargin_Changed"
Indeterminate="ShowInheritanceMargin_Changed"
Content="{x:Static local:AdvancedOptionPageStrings.Show_inheritance_margin}"/>
</StackPanel>
</GroupBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
BindToOption(SuppressHintsWhenParameterNameMatchesTheMethodsIntent, InlineHintsOptions.SuppressForParametersThatMatchMethodIntent, LanguageNames.VisualBasic)
BindToOption(SuppressHintsWhenParameterNamesDifferOnlyBySuffix, InlineHintsOptions.SuppressForParametersThatDifferOnlyBySuffix, LanguageNames.VisualBasic)

ShowInheritanceMargin.IsChecked = optionStore.GetOption(FeatureOnOffOptions.ShowInheritanceMargin, LanguageNames.VisualBasic)
BindToOption(ShowInheritanceMargin, FeatureOnOffOptions.ShowInheritanceMargin, LanguageNames.VisualBasic,
Function()
' If the option has not been set by the user, check if the option Is enabled from experimentation.
' If so, default to that. Otherwise default to disabled
Return If(experimentationService?.IsExperimentEnabled(WellKnownExperimentNames.InheritanceMargin), False)
End Function)
End Sub

' Since this dialog is constructed once for the lifetime of the application and VS Theme can be changed after the application has started,
Expand Down Expand Up @@ -182,10 +187,5 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
Me.OptionStore.SetOption(InlineHintsOptions.EnabledForParameters, LanguageNames.VisualBasic, False)
UpdateInlineHintsOptions()
End Sub

Private Sub ShowInheritanceMargin_Changed(sender As Object, e As RoutedEventArgs)
Me.ShowInheritanceMargin.IsThreeState = False
Me.OptionStore.SetOption(FeatureOnOffOptions.ShowInheritanceMargin, LanguageNames.VisualBasic, Me.ShowInheritanceMargin.IsChecked)
End Sub
End Class
End Namespace

0 comments on commit 5cb76b7

Please sign in to comment.