Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit37487c3

Browse files
authored
Merge pull requestdotnet#4690 from majocha/fix-underline
Fix QuickInfo links underline style
2 parents0d569e4 +fd45c3d commit37487c3

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

‎vsintegration/src/FSharp.Editor/QuickInfo/WpfNagivableTextRunViewElementFactory.fs‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ open Microsoft.VisualStudio.Text.Adornments
1111
openMicrosoft.VisualStudio.Text.Editor
1212
openMicrosoft.VisualStudio.Utilities
1313

14+
moduleprivateResources=
15+
letstyles=
16+
#if DEBUG
17+
// load ResourceDictionary in a not 100% safe way for better debugging experience
18+
if(isNull Application.ResourceAssembly)then
19+
Application.ResourceAssembly<- typeof<Microsoft.VisualStudio.FSharp.UIResources.QuickInfoOptionControl>.Assembly
20+
ResourceDictionary(Source= Uri("HyperlinkStyles.xaml", UriKind.Relative))
21+
else
22+
#endif
23+
ResourceDictionary(Source= Uri(@"/FSharp.UIResources;component/HyperlinkStyles.xaml", UriKind.Relative))
24+
25+
1426
[<Export(typeof<IViewElementFactory>)>]
1527
[<Name("NavigableTextRun to UIElement")>]
1628
[<TypeConversion(typeof<NavigableTextRun>, typeof<UIElement>)>]
@@ -20,7 +32,6 @@ type WpfNavigableTextRunViewElementFactory
2032
(
2133
viewElementFactoryService:IViewElementFactoryService
2234
)=
23-
letstyles= ResourceDictionary(Source= Uri(@"/FSharp.UIResources;component/HyperlinkStyles.xaml", UriKind.Relative))
2435
interface IViewElementFactorywith
2536
override__.CreateViewElement<'TViewwhen'TView:notstruct>(textView:ITextView,model:obj):'TView=
2637
ifnot(model:? NavigableTextRun)|| typeof<'TView><> typeof<UIElement>then
@@ -44,8 +55,17 @@ type WpfNavigableTextRunViewElementFactory
4455
| QuickInfoUnderlineStyle.Dot->"dot_underline"
4556
else
4657
"no_underline"
47-
styles.[key]:?> Style
48-
tb.Resources.[typeof<TextBlock>]<- underlineStyle
58+
Resources.styles.[key]:?> Style
59+
60+
// we need to enclose the generated Inline, which is actually a Run element,
61+
// because fancy styling does not seem to work properly with Runs
62+
letinl= tb.Inlines.FirstInline
63+
letcolor= inl.Foreground
64+
// clear the color here to make it inherit
65+
inl.ClearValue(Documents.TextElement.ForegroundProperty)|> ignore
66+
// this constructor inserts into TextBlock
67+
Documents.Underline(tb.Inlines.FirstInline, tb.ContentStart, Foreground= color)|> ignore
68+
tb.Resources.[typeof<Documents.Underline>]<- underlineStyle
4969
|_->()
5070

5171
// add navigation

‎vsintegration/src/FSharp.UIResources/HyperlinkStyles.xaml‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<ResourceDictionaryxmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3-
<SolidColorBrushx:Key="inherited_brush"Color="{Binding Path=Foreground.Color, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TextBlock}}" />
4-
<SolidColorBrushx:Key="inherited_semi_brush"Opacity="0.28"Color="{Binding Path=Foreground.Color, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TextBlock}}" />
3+
<SolidColorBrushx:Key="inherited_brush"Color="{Binding Path=Foreground.Color, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Underline}}" />
4+
<SolidColorBrushx:Key="inherited_semi_brush"Opacity="0.28"Color="{Binding Path=Foreground.Color, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Underline}}" />
55
<DashStylex:Key="dash_dashstyle"Dashes="5 5"/>
66
<DashStylex:Key="dot_dashstyle"Dashes="1 5"/>
77
<Penx:Key="dot_pen"DashStyle="{StaticResource dot_dashstyle}"Brush="{StaticResource inherited_brush}"/>
@@ -20,23 +20,23 @@
2020
<TextDecorationCollectionx:Key="full_deco">
2121
<TextDecorationPenOffset="1"Pen="{StaticResource mouseover_pen}" />
2222
</TextDecorationCollection>
23-
<Stylex:Key="base_sourcelink"TargetType="TextBlock" >
23+
<Stylex:Key="base_sourcelink"TargetType="Underline" >
2424
<Style.Triggers>
2525
<TriggerProperty="IsMouseOver"Value="true">
2626
<SetterProperty="TextDecorations"Value="{StaticResource full_deco}"/>
2727
</Trigger>
2828
</Style.Triggers>
2929
</Style>
30-
<Stylex:Key="solid_underline"TargetType="TextBlock"BasedOn="{StaticResource base_sourcelink}">
30+
<Stylex:Key="solid_underline"TargetType="Underline"BasedOn="{StaticResource base_sourcelink}">
3131
<SetterProperty="TextDecorations"Value="{StaticResource solid_deco}"/>
3232
</Style>
33-
<Stylex:Key="dash_underline"TargetType="TextBlock"BasedOn="{StaticResource base_sourcelink}">
33+
<Stylex:Key="dash_underline"TargetType="Underline"BasedOn="{StaticResource base_sourcelink}">
3434
<SetterProperty="TextDecorations"Value="{StaticResource dash_deco}"/>
3535
</Style>
36-
<Stylex:Key="dot_underline"TargetType="TextBlock"BasedOn="{StaticResource base_sourcelink}">
36+
<Stylex:Key="dot_underline"TargetType="Underline"BasedOn="{StaticResource base_sourcelink}">
3737
<SetterProperty="TextDecorations"Value="{StaticResource dot_deco}"/>
3838
</Style>
39-
<Stylex:Key="no_underline"TargetType="TextBlock"BasedOn="{StaticResource base_sourcelink}">
39+
<Stylex:Key="no_underline"TargetType="Underline"BasedOn="{StaticResource base_sourcelink}">
4040
<SetterProperty="TextDecorations"Value="{x:Null}"/>
4141
</Style>
4242
</ResourceDictionary>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp