Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
30a35e1
Split old rename UI into folder and add basic new rename UI
ryzngard Nov 9, 2021
6c87d0a
Update to use an if to leave code compiling instead of pragma. Switch…
ryzngard Nov 11, 2021
450167f
Merge branch 'main' into features/rename_ui
ryzngard Nov 19, 2021
739f45e
Merge pull request #57686 from ryzngard/features/rename_ui
Nov 19, 2021
1c07b7f
Merge pull request #58068 from dotnet/main
JoeRobich Dec 2, 2021
ab0af20
Merge pull request #58111 from dotnet/merges/main-to-features/rename_…
dotnet-bot Dec 4, 2021
d48d670
Merge pull request #58118 from dotnet/merges/main-to-features/rename_…
dotnet-bot Dec 5, 2021
6cea3dc
Merge pull request #58124 from dotnet/merges/main-to-features/rename_…
dotnet-bot Dec 6, 2021
225f6cd
Merge pull request #58144 from dotnet/merges/main-to-features/rename_…
dotnet-bot Dec 7, 2021
7b5dd02
Merge pull request #58181 from dotnet/merges/main-to-features/rename_…
dotnet-bot Dec 8, 2021
9a8ebfa
Merge pull request #58207 from dotnet/merges/main-to-features/rename_…
dotnet-bot Dec 9, 2021
87811fd
Merge pull request #58236 from dotnet/merges/main-to-features/rename_…
dotnet-bot Dec 10, 2021
f6416d5
Merge pull request #58266 from dotnet/merges/main-to-features/rename_…
dotnet-bot Dec 11, 2021
3861fa6
Merge pull request #58284 from dotnet/merges/main-to-features/rename_…
dotnet-bot Dec 12, 2021
2e9e63e
Merge pull request #58294 from dotnet/merges/main-to-features/rename_…
dotnet-bot Dec 13, 2021
b0f1a6d
Merge pull request #58314 from dotnet/merges/main-to-features/rename_…
dotnet-bot Dec 14, 2021
2f8a90c
Merge pull request #58334 from dotnet/merges/main-to-features/rename_…
dotnet-bot Dec 15, 2021
5de646e
Merge pull request #58362 from dotnet/merges/main-to-features/rename_…
dotnet-bot Dec 16, 2021
6166298
Merge pull request #58383 from dotnet/merges/main-to-features/rename_…
dotnet-bot Dec 17, 2021
12ca3fc
Merge https://github.com/dotnet/roslyn into features/rename_ui_rework
ryzngard Jan 19, 2022
bac6292
Merge pull request #59201 from ryzngard/features/rename_ui_rework
Feb 2, 2022
4db8861
Add option in feature flags to control which UI is shown (#59238)
Feb 3, 2022
7faeb50
Merge pull request #58989 from dotnet/merges/main-to-features/rename_…
dotnet-bot Feb 8, 2022
7912899
Merge branch 'main' into merge/rename_ui_rework
ryzngard Feb 8, 2022
dbca90b
Merge pull request #59372 from ryzngard/merge/rename_ui_rework
Feb 8, 2022
891bbbf
Merge remote-tracking branch 'origin/features/rename_ui_rework' into …
JoeRobich Feb 11, 2022
b5d0d17
Add EditorFeatures.WPF dependency on VisualStudio.Shell
JoeRobich Feb 11, 2022
d3e2815
Use new Inline Session Options
JoeRobich Feb 11, 2022
7805a51
Merge pull request #59400 from dotnet/merges/main-to-features/rename_…
dotnet-bot Feb 12, 2022
e692e87
Merge pull request #59521 from dotnet/merges/main-to-features/rename_…
dotnet-bot Feb 13, 2022
5148c1d
Merge pull request #59527 from dotnet/merges/main-to-features/rename_…
dotnet-bot Feb 14, 2022
717d19f
Merge pull request #59551 from dotnet/merges/main-to-features/rename_…
dotnet-bot Feb 15, 2022
ce6ac71
Merge pull request #59572 from dotnet/merges/main-to-features/rename_…
dotnet-bot Feb 16, 2022
f198b0d
Finalize New Inline Rename UI (#59351)
ryzngard Feb 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<Compile Include="..\Core.Wpf\ExternalAccess\VSTypeScript\**\*.cs" LinkBase="ExternalAccess\VSTypeScript" />
<Compile Include="..\Core.Wpf\InlineRename\**\*.cs" Exclude="..\Core.Wpf\InlineRename\Dashboard\**\*.cs" LinkBase="InlineRename" />
<Compile Include="..\Core.Wpf\InlineRename\**\*.cs" Exclude="..\Core.Wpf\InlineRename\UI\**\*.cs" LinkBase="InlineRename" />
<Compile Include="..\Core.Wpf\Classification\**\*.cs" LinkBase="Classification" />
<Compile Include="..\Core.Wpf\Diagnostics\**\*.cs" LinkBase="Diagnostics" />
<Compile Include="..\Core.Wpf\NavigableSymbols\**\*.cs" LinkBase="NavigableSymbols" />
Expand Down
3 changes: 3 additions & 0 deletions src/EditorFeatures/Core.Wpf/EditorFeaturesWpfResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,7 @@
<data name="Interactive_host_process_platform" xml:space="preserve">
<value>Interactive host process platform</value>
</data>
<data name="Enter_to_rename_shift_enter_to_preview" xml:space="preserve">
<value>Enter to rename, Shift+Enter to preview</value>
</data>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.Editor.InlineRename
{
internal sealed class InlineRenameExperimentationOptions
{
public static readonly Option<bool> UseInlineAdornment = new(
feature: "InlineRenameExperimentation",
name: "UseInlineAdornment",
defaultValue: false,
storageLocation: new FeatureFlagStorageLocation("Roslyn.UseInlineAdornmentForRename"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<UserControl x:Class="Microsoft.CodeAnalysis.Editor.InlineRename.Adornment.InlineRenameAdornment"
x:ClassModifier="internal"
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:local="clr-namespace:Microsoft.CodeAnalysis.Editor.InlineRename.Adornment"
xmlns:rename="clr-namespace:Microsoft.CodeAnalysis.Editor.Implementation.InlineRename"
xmlns:imaging="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.Imaging"
xmlns:imagecatalog="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.ImageCatalog"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
MinWidth="200"
x:Name="control"
KeyDown="Adornment_KeyDown"
MouseDown="Adornment_ConsumeMouseEvent"
MouseUp="Adornment_ConsumeMouseEvent"
GotKeyboardFocus="Adornment_GotKeyboardFocus"
Focusable="False"
UseLayoutRounding="True"
Background="{DynamicResource {x:Static rename:InlineRenameColors.BackgroundBrushKey}}">

<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../InlineRenameColors.xaml"/>
</ResourceDictionary.MergedDictionaries>

<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>

<SolidColorBrush x:Key="ForegroundText" Color="{DynamicResource {x:Static rename:InlineRenameColors.SystemCaptionTextColorKey}}"/>

<Style TargetType="CheckBox">
<Setter Property="Foreground" Value="{DynamicResource {x:Static rename:InlineRenameColors.CheckBoxTextBrushKey}}"/>
</Style>

<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="{StaticResource ForegroundText}"/>
</Style>
</ResourceDictionary>
</UserControl.Resources>

<Border
Background="{DynamicResource {x:Static rename:InlineRenameColors.BackgroundBrushKey}}"
BorderThickness="1"
BorderBrush="{DynamicResource {x:Static rename:InlineRenameColors.ButtonBorderBrush}}" >
<StackPanel Orientation="Vertical" Margin="5" >
<Grid Margin="0 0 0 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="22" />
</Grid.ColumnDefinitions>


<TextBox
Grid.Column="0"
x:Name="IdentifierTextBox"
Text="{Binding IdentifierText, UpdateSourceTrigger=PropertyChanged}"
GotFocus="IdentifierTextBox_GotFocus"
HorizontalAlignment="Stretch" />

<!-- Expand/Collapse button and glyph -->
<Button x:Name="ToggleExpandButton" Grid.Column="1" Click="ToggleExpand" Background="Transparent">
<Button.Style>
<Style TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Name="border"
BorderThickness="1"
BorderBrush="{DynamicResource {x:Static rename:InlineRenameColors.BackgroundBrushKey}}"
Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource {x:Static rename:InlineRenameColors.ButtonBorderBrush}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
<imaging:CrispImage Grid.Column="0">
<imaging:CrispImage.Style>
<Style TargetType="imaging:CrispImage">
<Style.Triggers>
<DataTrigger Binding="{Binding IsCollapsed}" Value="True">
<Setter Property="Moniker" Value="{x:Static imagecatalog:KnownMonikers.ExpandDown}" />
</DataTrigger>

<DataTrigger Binding="{Binding IsCollapsed}" Value="False">
<Setter Property="Moniker" Value="{x:Static imagecatalog:KnownMonikers.CollapseUp}" />
</DataTrigger>
</Style.Triggers>
</Style>
</imaging:CrispImage.Style>
</imaging:CrispImage>
</Button>
</Grid>

<StackPanel Orientation="Vertical" Visibility="{Binding IsExpanded, Converter={StaticResource BooleanToVisibilityConverter}}">
<CheckBox Content="{Binding ElementName=control, Path=RenameOverloads}" Margin="0,5,0,0" IsChecked="{Binding Path=RenameOverloadFlag, Mode=TwoWay}"
Name="OverloadsCheckbox" Visibility="{Binding RenameOverloadsVisibility}" IsEnabled="{Binding IsRenameOverloadsEditable}" />
<CheckBox Name="CommentsCheckbox" Content="{Binding ElementName=control, Path=SearchInComments}" Margin="0,5,0,0" IsChecked="{Binding Path=RenameInCommentsFlag, Mode=TwoWay}" />
<CheckBox Name="StringsCheckbox" Content="{Binding ElementName=control, Path=SearchInStrings}" Margin="0,5,0,0" IsChecked="{Binding Path=RenameInStringsFlag, Mode=TwoWay}" />
<CheckBox Name="FileRenameCheckbox"
Content="{Binding Path=FileRenameString}"
Margin="0,5,0,0"
IsChecked="{Binding Path=RenameFileFlag, Mode=TwoWay}"
IsEnabled="{Binding Path=AllowFileRename, Mode=OneWay}"
Visibility="{Binding Path=ShowFileRename, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}"/>
</StackPanel>

<TextBlock Text="{Binding ElementName=control, Path=SubmitText}" Foreground="LightGray" Margin="5, 5, 0, 0" FontStyle="Italic" />
</StackPanel>
</Border>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Microsoft.VisualStudio.Text.Editor;

namespace Microsoft.CodeAnalysis.Editor.InlineRename.Adornment
{
/// <summary>
/// Interaction logic for InlineRenameAdornment.xaml
/// </summary>
internal partial class InlineRenameAdornment : UserControl, IDisposable
{
private readonly InlineRenameAdornmentViewModel _viewModel;
private readonly ITextView _textView;

public InlineRenameAdornment(InlineRenameAdornmentViewModel viewModel, ITextView textView)
{
DataContext = _viewModel = viewModel;
_textView = textView;

_textView.LayoutChanged += TextView_LayoutChanged;
_textView.ViewportHeightChanged += TextView_ViewPortChanged;
_textView.ViewportWidthChanged += TextView_ViewPortChanged;
_textView.LostAggregateFocus += TextView_LostFocus;
_textView.Caret.PositionChanged += TextView_CursorChanged;

// On initialization focus the first tab target
Initialized += (s, e) => MoveFocus(new TraversalRequest(FocusNavigationDirection.First));

InitializeComponent();
PositionAdornment();
}

#pragma warning disable CA1822 // Mark members as static - used in xaml
public string RenameOverloads => EditorFeaturesResources.Include_overload_s;
public string SearchInComments => EditorFeaturesResources.Include_comments;
public string SearchInStrings => EditorFeaturesResources.Include_strings;
public string ApplyRename => EditorFeaturesResources.Apply1;
public string CancelRename => EditorFeaturesResources.Cancel;
public string PreviewChanges => EditorFeaturesResources.Preview_changes1;
public string SubmitText => EditorFeaturesWpfResources.Enter_to_rename_shift_enter_to_preview;
#pragma warning restore CA1822 // Mark members as static

private void TextView_CursorChanged(object sender, CaretPositionChangedEventArgs e)
=> _viewModel.Cancel();

private void TextView_LostFocus(object sender, EventArgs e)
=> _viewModel.Cancel();

private void TextView_ViewPortChanged(object sender, EventArgs e)
=> PositionAdornment();

private void TextView_LayoutChanged(object sender, TextViewLayoutChangedEventArgs e)
=> PositionAdornment();

private void PositionAdornment()
{
var top = _textView.Caret.Bottom + 5;
var left = _textView.Caret.Left - 5;

Canvas.SetTop(this, top);
Canvas.SetLeft(this, left);
}

public void Dispose()
{
_viewModel.Dispose();

_textView.LayoutChanged -= TextView_LayoutChanged;
_textView.ViewportHeightChanged -= TextView_ViewPortChanged;
_textView.ViewportWidthChanged -= TextView_ViewPortChanged;
_textView.LostAggregateFocus -= TextView_LostFocus;
_textView.Caret.PositionChanged -= TextView_CursorChanged;
}

private void Submit_Click(object sender, RoutedEventArgs e)
{
_viewModel.Submit();
}

private void Adornment_KeyDown(object sender, KeyEventArgs e)
{
switch (e.Key)
{
case Key.Enter:
e.Handled = true;
_viewModel.Submit();
break;

case Key.Escape:
e.Handled = true;
_viewModel.Cancel();
break;

case Key.Tab:
// We don't want tab to lose focus for the adornment, so manually
// loop focus back to the first item that is focusable.
FrameworkElement lastItem = _viewModel.IsExpanded
? FileRenameCheckbox
: IdentifierTextBox;

if (lastItem.IsFocused)
{
e.Handled = true;
MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
}

break;
}
}

private void IdentifierTextBox_GotFocus(object sender, RoutedEventArgs e)
{
IdentifierTextBox.SelectAll();
}

private void Adornment_ConsumeMouseEvent(object sender, MouseButtonEventArgs e)
{
e.Handled = true;
}

private void Adornment_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
if (e.OldFocus == this)
{
return;
}

IdentifierTextBox.Focus();
e.Handled = true;
}

private void ToggleExpand(object sender, RoutedEventArgs e)
{
_viewModel.IsExpanded = !_viewModel.IsExpanded;
}
}
}
Loading