Skip to content

Commit

Permalink
Make most textblocks selectable. Add UI for Owners.
Browse files Browse the repository at this point in the history
Fixes NuGet/Home#1769 (and went ahead and made most fields text selectable.)
Fixes UI part of NuGet/Home#442 - will follow up to get data down from server.
  • Loading branch information
rrelyea committed Mar 18, 2016
1 parent 983d5c2 commit 95978d2
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 32 deletions.
9 changes: 9 additions & 0 deletions src/NuGet.Clients/PackageManagement.UI/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/NuGet.Clients/PackageManagement.UI/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@
<data name="Label_Options" xml:space="preserve">
<value>Options</value>
</data>
<data name="Label_Owners" xml:space="preserve">
<value>Owner(s):</value>
</data>
<data name="Label_LegalDisclaimer" xml:space="preserve">
<value>Legal Disclaimer</value>
</data>
Expand Down
38 changes: 38 additions & 0 deletions src/NuGet.Clients/PackageManagement.UI/Resources/Resources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,44 @@
Value="300" />
</Style>

<!-- In order to create a TextBlock like element, but with selectable text use:
<TextBox Style="{DynamicResource SelectableTextBlockStyle}" />
Thanks to juanjo.arana for his style, which we tweaked: http://stackoverflow.com/questions/136435/any-way-to-make-a-wpf-textblock-selectable
-->
<Style x:Key="SelectableTextBlockStyle" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static nuget:Brushes.UIText}}"/>
<Setter Property="Padding" Value="-2,0,-2,0"/>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="False" />
<Condition Property="IsFocused" Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<TextBlock Text="{TemplateBinding Text}"
Foreground="{DynamicResource {x:Static nuget:Brushes.UIText}}"
Background="{TemplateBinding Background}"
FontSize="{TemplateBinding FontSize}"
FontStyle="{TemplateBinding FontStyle}"
FontFamily="{TemplateBinding FontFamily}"
FontWeight="{TemplateBinding FontWeight}"
TextWrapping="{TemplateBinding TextWrapping}"
Padding="0,0,0,0"
/>
</ControlTemplate>
</Setter.Value>
</Setter>
</MultiTrigger>
</Style.Triggers>
</Style>

<Style
TargetType="{x:Type Hyperlink}"
x:Key="HyperlinkStyle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,8 @@
Margin="0,0,8,0"
Style="{StaticResource PackageIconImageStyle}" />
<TextBox
Background="Transparent"
Foreground="{DynamicResource {x:Static nuget:Brushes.UIText}}"
BorderThickness="0"
Margin="-2,0,-2,0"
Style="{DynamicResource SelectableTextBlockStyle}"
Text="{Binding Path=Id, Mode=OneWay}"
IsReadOnly="True"
FontSize="{Binding ElementName=_self,Path=FontSize,Converter={StaticResource Font155PercentSizeConverter}}" />
</StackPanel>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
Grid.Row="0"
Text="{x:Static nuget:Resources.Label_Description}"
FontWeight="Bold" />
<TextBlock
<TextBox
Style="{DynamicResource SelectableTextBlockStyle}"
Grid.Row="1"
x:Name="_description"
Margin="0,8,0,0"
Expand All @@ -55,6 +56,7 @@
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition
Expand All @@ -64,40 +66,59 @@

<!-- version -->
<TextBlock
Visibility="{Binding Path=Authors,Converter={StaticResource NullToVisibilityConverter}}"
Visibility="{Binding Path=Version,Converter={StaticResource NullToVisibilityConverter}}"
Grid.Row="0"
Grid.Column="0"
Margin="0,8,0,0"
FontWeight="Bold"
Text="{x:Static nuget:Resources.Label_Version}" />
<TextBlock
<TextBox
Style="{DynamicResource SelectableTextBlockStyle}"
Grid.Row="0"
Grid.Column="1"
Visibility="{Binding Path=Version,Converter={StaticResource NullToVisibilityConverter}}"
Text="{Binding Path=Version,Converter={StaticResource VersionToStringConverter}}"
Margin="8,8,0,0"
TextWrapping="Wrap" />

<!-- Owner(s) -->
<TextBlock
Visibility="{Binding Path=Owners,Converter={StaticResource NullToVisibilityConverter}}"
Grid.Row="1"
Grid.Column="0"
Margin="0,8,0,0"
FontWeight="Bold"
Text="{x:Static nuget:Resources.Label_Owners}" />
<TextBox
Style="{DynamicResource SelectableTextBlockStyle}"
Visibility="{Binding Path=Owners,Converter={StaticResource NullToVisibilityConverter}}"
Text="{Binding Path=Owners}"
Margin="8,8,0,0"
TextWrapping="Wrap"
Grid.Row="1"
Grid.Column="1" />

<!-- Author(s) -->
<TextBlock
Visibility="{Binding Path=Authors,Converter={StaticResource NullToVisibilityConverter}}"
Grid.Row="1"
Grid.Row="2"
Grid.Column="0"
Margin="0,8,0,0"
FontWeight="Bold"
Text="{x:Static nuget:Resources.Label_Authors}" />
<TextBlock
<TextBox
Style="{DynamicResource SelectableTextBlockStyle}"
Visibility="{Binding Path=Authors,Converter={StaticResource NullToVisibilityConverter}}"
Text="{Binding Path=Authors}"
Margin="8,8,0,0"
TextWrapping="Wrap"
Grid.Row="1"
Grid.Row="2"
Grid.Column="1" />

<!-- License -->
<TextBlock
Visibility="{Binding Path=LicenseUrl,Converter={StaticResource NullToVisibilityConverter}}"
Grid.Row="2"
Grid.Row="3"
Grid.Column="0"
FontWeight="Bold"
Margin="0,8,0,0"
Expand All @@ -106,7 +127,7 @@
Visibility="{Binding Path=LicenseUrl,Converter={StaticResource NullToVisibilityConverter}}"
TextWrapping="Wrap"
Margin="8,8,0,0"
Grid.Row="2"
Grid.Row="3"
Grid.Column="1">
<Hyperlink
NavigateUri="{Binding Path=LicenseUrl}"
Expand All @@ -119,39 +140,41 @@
<!-- downloads -->
<TextBlock
Visibility="{Binding Path=DownloadCount,Converter={StaticResource DownloadCountToVisibilityConverter}}"
Grid.Row="3"
Grid.Row="4"
Grid.Column="0"
FontWeight="Bold"
Margin="0,8,0,0"
Text="{x:Static nuget:Resources.Label_Downloads}" />
<TextBlock
<TextBox
Style="{DynamicResource SelectableTextBlockStyle}"
Visibility="{Binding Path=DownloadCount,Converter={StaticResource DownloadCountToVisibilityConverter}}"
Text="{Binding Path=DownloadCount,StringFormat={}{0:N0}}"
Margin="8,8,0,0"
TextWrapping="Wrap"
Grid.Row="3"
Grid.Column="1"></TextBlock>
Grid.Row="4"
Grid.Column="1" />

<!--Date Published -->
<TextBlock
Visibility="{Binding Path=Published,Converter={StaticResource NullToVisibilityConverter}}"
Grid.Row="4"
Grid.Row="5"
Grid.Column="0"
FontWeight="Bold"
Margin="0,8,0,0"
Text="{x:Static nuget:Resources.Label_DatePublished}" />
<TextBlock
<TextBox
Style="{DynamicResource SelectableTextBlockStyle}"
Visibility="{Binding Path=Published,Converter={StaticResource NullToVisibilityConverter}}"
Text="{Binding Path=Published,StringFormat={}{0:D} ({0:d})}"
Margin="8,8,0,0"
TextWrapping="Wrap"
Grid.Row="4"
Grid.Column="1"></TextBlock>
Grid.Row="5"
Grid.Column="1" />

<!-- Project Url -->
<TextBlock
Visibility="{Binding Path=ProjectUrl,Converter={StaticResource NullToVisibilityConverter}}"
Grid.Row="5"
Grid.Row="6"
Grid.Column="0"
FontWeight="Bold"
Margin="0,8,0,0"
Expand All @@ -161,7 +184,7 @@
Visibility="{Binding Path=ProjectUrl,Converter={StaticResource NullToVisibilityConverter}}"
TextWrapping="Wrap"
Margin="8,8,0,0"
Grid.Row="5"
Grid.Row="6"
Grid.Column="1">
<Hyperlink
NavigateUri="{Binding Path=ProjectUrl}"
Expand All @@ -174,7 +197,7 @@
<!-- Report abuse Url -->
<TextBlock
Visibility="{Binding Path=ReportAbuseUrl,Converter={StaticResource NullToVisibilityConverter}}"
Grid.Row="6"
Grid.Row="7"
Grid.Column="0"
FontWeight="Bold"
Margin="0,8,0,0"
Expand All @@ -184,7 +207,7 @@
Visibility="{Binding Path=ReportAbuseUrl,Converter={StaticResource NullToVisibilityConverter}}"
TextWrapping="Wrap"
Margin="8,8,0,0"
Grid.Row="6"
Grid.Row="7"
Grid.Column="1">
<Hyperlink
NavigateUri="{Binding Path=ReportAbuseUrl}"
Expand All @@ -197,17 +220,18 @@
<!-- Tags -->
<TextBlock
Visibility="{Binding Path=Tags,Converter={StaticResource NullToVisibilityConverter}}"
Grid.Row="7"
Grid.Row="8"
Grid.Column="0"
FontWeight="Bold"
Margin="0,8,0,0"
Text="{x:Static nuget:Resources.Label_Tags}" />
<TextBlock
<TextBox
Style="{DynamicResource SelectableTextBlockStyle}"
Visibility="{Binding Path=Tags,Converter={StaticResource NullToVisibilityConverter}}"
Text="{Binding Path=Tags}"
Margin="8,8,0,0"
TextWrapping="Wrap"
Grid.Row="7"
Grid.Row="8"
Grid.Column="1" />
</Grid>

Expand Down Expand Up @@ -239,8 +263,9 @@
IsTabStop="False">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock
Text="{Binding}"></TextBlock>
<TextBox
Style="{DynamicResource SelectableTextBlockStyle}"
Text="{Binding Mode=OneWay}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Expand Down
5 changes: 3 additions & 2 deletions src/NuGet.Clients/PackageManagement.UI/Xamls/ProjectView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
Grid.Column="0"
FontWeight="Bold"
VerticalAlignment="Center"
Visibility="{Binding InstalledVersion, Converter={StaticResource NullToVisibilityConverter}}"
Visibility="{Binding InstalledVersion, Converter={StaticResource NullToVisibilityConverter}}"
Text="{x:Static local:Resources.Label_InstalledColon}" />

<Border
Expand All @@ -54,7 +54,8 @@
Visibility="{Binding InstalledVersion, Converter={StaticResource NullToVisibilityConverter}}"
BorderThickness="1"
VerticalAlignment="Center">
<TextBlock
<TextBox
Style="{DynamicResource SelectableTextBlockStyle}"
VerticalAlignment="Center"
AutomationProperties.AutomationId="InstalledVersion"
Margin="4,0,0,0"
Expand Down

0 comments on commit 95978d2

Please sign in to comment.