Skip to content

Commit

Permalink
Merge pull request #53770 from dotnet/merges/release/dev16.11-vs-deps…
Browse files Browse the repository at this point in the history
…-to-main-vs-deps

Merge release/dev16.11-vs-deps to main-vs-deps
  • Loading branch information
Cosifne authored May 29, 2021
2 parents 966f81f + 04f0144 commit a55983a
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@ internal sealed class InheritanceGlyphFactory : IGlyphFactory
private readonly ClassificationTypeMap _classificationTypeMap;
private readonly IClassificationFormatMap _classificationFormatMap;
private readonly IUIThreadOperationExecutor _operationExecutor;
private readonly IWpfTextView _textView;

public InheritanceGlyphFactory(
IThreadingContext threadingContext,
IStreamingFindUsagesPresenter streamingFindUsagesPresenter,
ClassificationTypeMap classificationTypeMap,
IClassificationFormatMap classificationFormatMap,
IUIThreadOperationExecutor operationExecutor)
IUIThreadOperationExecutor operationExecutor,
IWpfTextView textView)
{
_threadingContext = threadingContext;
_streamingFindUsagesPresenter = streamingFindUsagesPresenter;
_classificationTypeMap = classificationTypeMap;
_classificationFormatMap = classificationFormatMap;
_operationExecutor = operationExecutor;
_textView = textView;
}

public UIElement? GenerateGlyph(IWpfTextViewLine line, IGlyphTag tag)
Expand All @@ -41,13 +44,18 @@ public InheritanceGlyphFactory(
{
var membersOnLine = inheritanceMarginTag.MembersOnLine;
Contract.ThrowIfTrue(membersOnLine.IsEmpty);

// ZoomLevel of textView is percentage based. (e.g. 20 -> 400 means 20% -> 400%)
// and the scaleFactor of CrispImage is 1 based. (e.g 1 means 100%)
var scaleFactor = _textView.ZoomLevel / 100;
return new MarginGlyph.InheritanceMargin(
_threadingContext,
_streamingFindUsagesPresenter,
_classificationTypeMap,
_classificationFormatMap,
_operationExecutor,
inheritanceMarginTag);
inheritanceMarginTag,
scaleFactor);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public IGlyphFactory GetGlyphFactory(IWpfTextView view, IWpfTextViewMargin margi
_streamingFindUsagesPresenter,
_classificationTypeMap,
_classificationFormatMapService.GetClassificationFormatMap("tooltip"),
_operationExecutor);
_operationExecutor,
view);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<Border x:Name="Border" BorderThickness="1"
Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"
BorderBrush="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderBrush}">
<imaging:CrispImage Moniker="{Binding Path=ImageMoniker}"/>
<imaging:CrispImage Moniker="{Binding ImageMoniker}" ScaleFactor="{Binding ScaleFactor}" />
</Border>
</ControlTemplate>
</Button.Template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ public InheritanceMargin(
ClassificationTypeMap classificationTypeMap,
IClassificationFormatMap classificationFormatMap,
IUIThreadOperationExecutor operationExecutor,
InheritanceMarginTag tag)
InheritanceMarginTag tag,
double scaleFactor)
{
_threadingContext = threadingContext;
_streamingFindUsagesPresenter = streamingFindUsagesPresenter;
_workspace = tag.Workspace;
_operationExecutor = operationExecutor;
InitializeComponent();

var viewModel = InheritanceMarginViewModel.Create(classificationTypeMap, classificationFormatMap, tag);
var viewModel = InheritanceMarginViewModel.Create(classificationTypeMap, classificationFormatMap, tag, scaleFactor);
DataContext = viewModel;
ContextMenu.DataContext = viewModel;
ToolTip = new ToolTip { Content = viewModel.ToolTipTextBlock, Style = (Style)FindResource("ToolTipStyle") };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,31 @@ internal class InheritanceMarginViewModel
/// </summary>
public ImmutableArray<InheritanceMenuItemViewModel> MenuItemViewModels { get; }

/// <summary>
/// Scale factor for the margin.
/// </summary>
public double ScaleFactor { get; }

// Internal for testing purpose
internal InheritanceMarginViewModel(
ImageMoniker imageMoniker,
TextBlock toolTipTextBlock,
string automationName,
double scaleFactor,
ImmutableArray<InheritanceMenuItemViewModel> menuItemViewModels)
{
ImageMoniker = imageMoniker;
ToolTipTextBlock = toolTipTextBlock;
AutomationName = automationName;
MenuItemViewModels = menuItemViewModels;
ScaleFactor = scaleFactor;
}

public static InheritanceMarginViewModel Create(
ClassificationTypeMap classificationTypeMap,
IClassificationFormatMap classificationFormatMap,
InheritanceMarginTag tag)
InheritanceMarginTag tag,
double scaleFactor)
{
var members = tag.MembersOnLine;
if (members.Length == 1)
Expand All @@ -74,7 +82,7 @@ public static InheritanceMarginViewModel Create(

var automationName = string.Format(ServicesVSResources._0_is_inherited, member.DisplayTexts.JoinText());
var menuItemViewModels = InheritanceMarginHelpers.CreateMenuItemViewModelsForSingleMember(member.TargetItems);
return new InheritanceMarginViewModel(tag.Moniker, toolTipTextBlock, automationName, menuItemViewModels);
return new InheritanceMarginViewModel(tag.Moniker, toolTipTextBlock, automationName, scaleFactor, menuItemViewModels);
}
else
{
Expand All @@ -86,7 +94,7 @@ public static InheritanceMarginViewModel Create(
// Same automation name can't be set for control for accessibility purpose. So add the line number info.
var automationName = string.Format(ServicesVSResources.Multiple_members_are_inherited_on_line_0, tag.LineNumber);
var menuItemViewModels = InheritanceMarginHelpers.CreateMenuItemViewModelsForMultipleMembers(tag.MembersOnLine);
return new InheritanceMarginViewModel(tag.Moniker, textBlock, automationName, menuItemViewModels);
return new InheritanceMarginViewModel(tag.Moniker, textBlock, automationName, scaleFactor, menuItemViewModels);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.InheritanceMargin

Dim acutalTag = acutalLineToTagDictionary(lineNumber)
Dim actualViewModel = InheritanceMarginViewModel.Create(
classificationTypeMap, classificationFormatMap.GetClassificationFormatMap("tooltip"), acutalTag)
classificationTypeMap, classificationFormatMap.GetClassificationFormatMap("tooltip"), acutalTag, 1)

VerifyTwoViewModelAreSame(expectedViewModel, actualViewModel)
Next
Expand Down Expand Up @@ -155,11 +155,13 @@ public class Bar : IBar
KnownMonikers.Implemented,
CreateTextBlock(tooltipTextForIBar),
tooltipTextForIBar,
1,
targetForIBar)},
{5, New InheritanceMarginViewModel(
KnownMonikers.Implementing,
CreateTextBlock(tooltipTextForBar),
tooltipTextForBar,
1,
targetForBar)}})
End Function

Expand Down Expand Up @@ -197,21 +199,25 @@ public class Bar : AbsBar
KnownMonikers.Implemented,
CreateTextBlock(tooltipTextForAbsBar),
tooltipTextForAbsBar,
1,
targetForAbsBar)},
{4, New InheritanceMarginViewModel(
KnownMonikers.Overridden,
CreateTextBlock(tooltipTextForAbstractFoo),
tooltipTextForAbstractFoo,
1,
targetForAbsFoo)},
{7, New InheritanceMarginViewModel(
KnownMonikers.Implementing,
CreateTextBlock(tooltipTextForBar),
tooltipTextForBar,
1,
targetForBar)},
{9, New InheritanceMarginViewModel(
KnownMonikers.Overriding,
CreateTextBlock(tooltipTextForOverrideFoo),
tooltipTextForOverrideFoo,
1,
targetForOverrideFoo)}})
End Function

Expand Down Expand Up @@ -244,16 +250,19 @@ public interface IBar3 : IBar2 { }
KnownMonikers.Implemented,
CreateTextBlock(tooltipTextForIBar1),
tooltipTextForIBar1,
1,
targetForIBar1)},
{3, New InheritanceMarginViewModel(
KnownMonikers.Implemented,
CreateTextBlock(tooltipTextForIBar2),
tooltipTextForIBar2,
1,
targetForIBar2)},
{4, New InheritanceMarginViewModel(
KnownMonikers.Implementing,
CreateTextBlock(tooltipTextForIBar3),
tooltipTextForIBar3,
1,
targetForIBar3)}})
End Function

Expand Down Expand Up @@ -300,21 +309,25 @@ public class BarSample : IBar1
KnownMonikers.Implemented,
CreateTextBlock(tooltipTextForIBar1),
tooltipTextForIBar1,
1,
targetForIBar1)},
{5, New InheritanceMarginViewModel(
KnownMonikers.Implemented,
CreateTextBlock(tooltipTextForE1AndE2InInterface),
String.Format(ServicesVSResources.Multiple_members_are_inherited_on_line_0, 5),
1,
targetForE1AndE2InInterface)},
{8, New InheritanceMarginViewModel(
KnownMonikers.Implementing,
CreateTextBlock(tooltipTextForBarSample),
tooltipTextForBarSample,
1,
targetForBarSample)},
{10, New InheritanceMarginViewModel(
KnownMonikers.Implementing,
CreateTextBlock(tooltipTextForE1AndE2InBarSample),
String.Format(ServicesVSResources.Multiple_members_are_inherited_on_line_0, 10),
1,
targetForE1AndE2InInBarSample)}})
End Function
End Class
Expand Down

0 comments on commit a55983a

Please sign in to comment.