Skip to content

Commit

Permalink
Package Source Mapping Options Dialogs meet Design and PLOC guidelines (
Browse files Browse the repository at this point in the history
  • Loading branch information
donnie-msft authored Oct 21, 2022
1 parent e89d782 commit 5d2c71b
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
<Compile Include="Options\AddMappingDialog.xaml.cs">
<DependentUpon>AddMappingDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Options\Resources.xaml.cs">
<DependentUpon>Resources.xaml</DependentUpon>
</Compile>
<Compile Include="Options\SourceMappingViewModel.cs" />
<Compile Include="Options\PackageSourceViewModel.cs" />
<Compile Include="Options\PackageSourceMappingOptionsControl.xaml.cs">
Expand Down Expand Up @@ -321,6 +324,9 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Options\Resources.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\generic.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vs="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.15.0"
xmlns:vsui="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.15.0"
xmlns:nuget="clr-namespace:NuGet.PackageManagement.UI"
xmlns:options="clr-namespace:NuGet.Options"
mc:Ignorable="d"
x:Uid="AddMappingDialogWindow"
Height="304"
Width="456"
Height="348"
Width="480"
ShowInTaskbar="False"
WindowStyle="None"
Title="{x:Static nuget:Resources.VSOptions_Label_AddPackageNamespace}"
Expand All @@ -17,16 +19,20 @@
BorderBrush="{DynamicResource {x:Static vsui:EnvironmentColors.PanelBorderBrushKey}}"
BorderThickness="1"
Foreground="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}">
<vsui:DialogWindow.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<options:SharedResources />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</vsui:DialogWindow.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="36"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.Resources>
<Style TargetType="ScrollBar">
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ScrollBarColorKey}}"/>
</Style>
<!-- Copied from ThemedDialogResources.xaml. See https://github.com/NuGet/Home/issues/12163 -->
<Style TargetType="{x:Type vsui:WatermarkedTextBox}">
<Setter Property="Padding" Value="6,8,6,8" />
Expand Down Expand Up @@ -69,20 +75,23 @@
</Setter>
</Style>
</Grid.Resources>
<StackPanel Grid.Row="0">
<Grid>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="24"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock AutomationProperties.Name="AddNewPackageNamespace"
Grid.Column="0"
Text="{x:Static nuget:Resources.VSOptions_Label_AddPackageNamespace}"
Margin="12,12,0,0"/>
Margin="12"/>
<Button x:Uid="ButtonClose"
Height="25"
Width="25"
Grid.Column="1"
HorizontalAlignment="Left"
HorizontalContentAlignment="Stretch"
VerticalAlignment="Top"
VerticalContentAlignment="Center"
Margin="0,6,6,0"
Command="{Binding HideDialogCommand}"
AutomationProperties.Name="Close"
Expand All @@ -100,75 +109,77 @@
</Canvas>
</Button>
</Grid>
</StackPanel>
<StackPanel Grid.Row="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<vsui:WatermarkedTextBox Grid.Row="0"
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{x:Static nuget:Resources.VSOptions_Label_PackagePattern}" Margin="12,0,12,9"/>
<vsui:WatermarkedTextBox Grid.Row="1"
BorderBrush="{DynamicResource {x:Static vsui:CommonControlsColors.ButtonBorderBrushKey}}"
BorderThickness="1"
AutomationProperties.Name="{x:Static nuget:Resources.VSOptions_Watermark_AddPackageNamespace}"
x:Name="_packageID"
MaxLength="100"
Margin="12,6,12,6"
Margin="12,0,12,0"
Watermark="{x:Static nuget:Resources.VSOptions_Watermark_AddPackageNamespace}"
TextChanged="PackageID_TextChanged"/>
<StackPanel Orientation="Vertical" Grid.Row="1">
<nuget:ProjectsListView AutomationProperties.Name="{x:Static nuget:Resources.VSOptions_Accessibility_SourcesList}"
<nuget:ProjectsListView Grid.Row="2"
x:Name="_sourcesListBox"
AutomationProperties.Name="{x:Static nuget:Resources.VSOptions_Accessibility_SourcesList}"
ItemsSource="{Binding SourcesCollection}"
PreviewKeyUp="SourcesListBox_PreviewKeyUp"
Margin="12,0,12,12"
Margin="12"
Height="184">
<ListView.ItemContainerStyle>
<Style>
<Setter Property="AutomationProperties.Name" Value="{Binding SourceInfo.Name}"/>
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView>
<!-- checkbox column -->
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox IsTabStop="False"
<ListView.ItemContainerStyle>
<Style>
<Setter Property="AutomationProperties.Name" Value="{Binding SourceInfo.Name}"/>
</Style>
</ListView.ItemContainerStyle>
<ListView.Resources>
<Style x:Key="{x:Static GridView.GridViewScrollViewerStyleKey}" TargetType="{x:Type ScrollViewer}" BasedOn="{StaticResource {x:Static vs:VsResourceKeys.UnthemedGridViewScrollViewerStyleKey}}" />
<Style TargetType="{x:Type ScrollBar}" BasedOn="{StaticResource {x:Static vs:VsResourceKeys.UnthemedScrollBarStyleKey}}"/>
</ListView.Resources>
<ListView.View>
<GridView>
<!-- checkbox column -->
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox IsTabStop="False"
AutomationProperties.Name="{x:Static nuget:Resources.CheckBox_Selected}"
IsChecked="{Binding Path=IsSelected}"
Checked="CheckBox_Checked"
Unchecked="CheckBox_Checked"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!-- the text column -->
<GridViewColumn>
<GridViewColumnHeader Content="{x:Static nuget:Resources.VSOptions_Label_Source}" HorizontalContentAlignment="Left"/>
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding SourceInfo.Name}"/>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</nuget:ProjectsListView>
</StackPanel>
</Grid>
</StackPanel>
<Grid Grid.Row="2">
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!-- the text column -->
<GridViewColumn>
<GridViewColumnHeader Content="{x:Static nuget:Resources.VSOptions_Label_Source}" HorizontalContentAlignment="Left"/>
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding SourceInfo.Name}"/>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</nuget:ProjectsListView>
</Grid>
<Grid Grid.Row="3" Margin="12,0,12,12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="190"/>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Column="1">
<Button Height="24" Width="86" Command="{Binding AddMappingCommand}" Margin="0,0,3,12" Content="{x:Static nuget:Resources.VSOptions_Button_Add}"/>
<Button Height="24" Width="86" Command ="{Binding HideDialogCommand}" Margin="3,0,12,12" Content="{x:Static nuget:Resources.VSOptions_Button_Cancel}"/>
</StackPanel>
<!-- The `Grid.Column="0"` is missing in order to push the next column to the far right of the grid. -->
<Button Grid.Column="1" Style="{StaticResource PackageSourceMappingButtonStyle}" Command="{Binding AddMappingCommand}" Content="{x:Static nuget:Resources.VSOptions_Button_Add}"/>
<Button Grid.Column="2" Style="{StaticResource PackageSourceMappingButtonStyle}" Command ="{Binding HideDialogCommand}" Content="{x:Static nuget:Resources.VSOptions_Button_Cancel}"/>
</Grid>
</Grid>
</vsui:DialogWindow>
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:nuget="clr-namespace:NuGet.PackageManagement.UI"
xmlns:options="clr-namespace:NuGet.Options"
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
Foreground="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<options:SharedResources />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
Expand All @@ -27,23 +35,22 @@
<ListBox Name="_mappingList"
ItemsSource="{Binding SourceMappingsCollection}"
Grid.Row="1"
Margin="6,6,6,6"
Margin="0,12,0,12"
ItemTemplate="{StaticResource MappingItemTemplate}"
IsSynchronizedWithCurrentItem="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
AutomationProperties.Name="{x:Static nuget:Resources.VSOptions_Label_PackageSourceMappings}">

</ListBox>
<Grid Grid.Row="3">
AutomationProperties.Name="{x:Static nuget:Resources.VSOptions_Label_PackageSourceMappings}" />
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="101"/>
<ColumnDefinition Width="89"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="101"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Width="86" Height="24" Command="{Binding ShowAddDialogCommand}" Content="{x:Static nuget:Resources.VSOptions_Button_Add}"/>
<Button Grid.Column="1" Width="86" Height="24" Margin = "3,0,0,0" Command="{Binding RemoveMappingCommand}" Content="{x:Static nuget:Resources.VSOptions_Button_Remove}"/>
<Button Grid.Column="3" Width="86" Height="24" Command="{Binding RemoveAllMappingsCommand}" Content="{x:Static nuget:Resources.VSOptions_Button_RemoveAll}"/>
<Button Grid.Column="0" Style="{StaticResource PackageSourceMappingFirstRowButtonStyle}" Command="{Binding ShowAddDialogCommand}" Content="{x:Static nuget:Resources.VSOptions_Button_Add}"/>
<Button Grid.Column="1" Style="{StaticResource PackageSourceMappingButtonStyle}" Command="{Binding RemoveMappingCommand}" Content="{x:Static nuget:Resources.VSOptions_Button_Remove}"/>
<!-- The `Grid.Column="2"` is missing in order to push the next column to the far right of the grid. -->
<Button Grid.Column="3" Style="{StaticResource PackageSourceMappingButtonStyle}" Command="{Binding RemoveAllMappingsCommand}" Content="{x:Static nuget:Resources.VSOptions_Button_RemoveAll}"/>
</Grid>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<ResourceDictionary
x:Class="NuGet.Options.SharedResources"
x:ClassModifier="internal"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Style x:Key="PackageSourceMappingButtonStyle" TargetType="{x:Type Button}">
<Setter Property="MinWidth" Value="86" />
<Setter Property="Height" Value="24" />
<Setter Property="Padding" Value="10,1,10,1" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Margin" Value="6,0,0,0" />
</Style>
<Style x:Key="PackageSourceMappingFirstRowButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource PackageSourceMappingButtonStyle}">
<Setter Property="Margin" Value="0" />
</Style>
</ResourceDictionary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Windows;

namespace NuGet.Options
{
internal partial class SharedResources : ResourceDictionary
{
public SharedResources()
{
InitializeComponent();
}
}
}

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

5 changes: 4 additions & 1 deletion src/NuGet.Clients/NuGet.PackageManagement.UI/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ Please see https://aka.ms/troubleshoot_nuget_cache for more help.</value>
<value>Source</value>
</data>
<data name="VSOptions_Watermark_AddPackageNamespace" xml:space="preserve">
<value>Enter a valid Package pattern (Example: Contoso.Contracts or System.*)</value>
<value>Example: Contoso.Contracts or System.*</value>
<comment>"Contoso.Contracts" and "System.*" are examples of a package ID pattern and a package prefix pattern, respectively, so these two specific examples should not be translated.</comment>
</data>
<data name="PackageSourceMappingOptions_OnActivated" xml:space="preserve">
Expand All @@ -972,4 +972,7 @@ Please see https://aka.ms/troubleshoot_nuget_cache for more help.</value>
<data name="VSOptions_Accessibility_SourcesList" xml:space="preserve">
<value>Package sources list</value>
</data>
<data name="VSOptions_Label_PackagePattern" xml:space="preserve">
<value>Package pattern:</value>
</data>
</root>

0 comments on commit 5d2c71b

Please sign in to comment.