Skip to content

Commit

Permalink
Minor UI cleanup, enabling resizing of the form
Browse files Browse the repository at this point in the history
Remove literals here and there into the resource file for internationalization
Correct a bug with the (None) selection
  • Loading branch information
bclothier committed Nov 30, 2017
1 parent cbbf76e commit e07bee5
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 24 deletions.
20 changes: 15 additions & 5 deletions RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodModel.cs
Expand Up @@ -8,6 +8,7 @@
using Rubberduck.VBEditor;
using Rubberduck.Parsing.VBA;
using Rubberduck.SmartIndenter;
using Rubberduck.UI;
using Rubberduck.VBEditor.SafeComWrappers.Abstract;

namespace Rubberduck.Refactorings.ExtractMethod
Expand Down Expand Up @@ -122,7 +123,7 @@ private void Setup()

if (string.IsNullOrWhiteSpace(NewMethodName))
{
NewMethodName = "NewMethod";
NewMethodName = RubberduckUI.ExtractMethod_DefaultNewMethodName;
}

SelectedCode = string.Join(Environment.NewLine, SelectedContexts.Select(c => c.GetText()));
Expand Down Expand Up @@ -176,10 +177,10 @@ public string PreviewCode
switch (parameter.ParameterType)
{
case ExtractParameterNewType.PublicModuleField:
fields.Add(String.Format($"{Tokens.Public} {parameter.Name} {Tokens.As} {parameter.TypeName}"));
fields.Add(string.Format($"{Tokens.Public} {parameter.Name} {Tokens.As} {parameter.TypeName}"));
break;
case ExtractParameterNewType.PrivateModuleField:
fields.Add(String.Format($"{Tokens.Private} {parameter.Name} {Tokens.As} {parameter.TypeName}"));
fields.Add(string.Format($"{Tokens.Private} {parameter.Name} {Tokens.As} {parameter.TypeName}"));
break;
case ExtractParameterNewType.ByRefParameter:
parameters.Add(string.Format($"{parameter.Name} {Tokens.As} {parameter.TypeName}"));
Expand All @@ -198,7 +199,9 @@ public string PreviewCode
}
}

var isFunction = ReturnParameter != null;
var isFunction = ReturnParameter != null &&
!(ReturnParameter.TypeName == string.Empty &&
ReturnParameter.Name == RubberduckUI.ExtractMethod_NoneSelected);

/*
string.Empty are used to create blank lines
Expand All @@ -211,7 +214,14 @@ public string PreviewCode
strings.AddRange(fields);
strings.Add(string.Empty);
}
strings.Add($@"{Tokens.Private} {(isFunction ? Tokens.Function : Tokens.Sub)} {NewMethodName ?? "NewMethod"}({string.Join(", " , parameters)}) {(isFunction ? string.Concat(Tokens.As, " ", ReturnParameter.TypeName ?? Tokens.Variant) : string.Empty)}");
strings.Add(
$@"{Tokens.Private} {(isFunction ? Tokens.Function : Tokens.Sub)} {
NewMethodName ?? RubberduckUI.ExtractMethod_DefaultNewMethodName
}({string.Join(", ", parameters)}) {
(isFunction
? string.Concat(Tokens.As, " ", ReturnParameter.TypeName ?? Tokens.Variant)
: string.Empty)
}");
strings.AddRange(variables);
if (variables.Any())
{
Expand Down
10 changes: 0 additions & 10 deletions RetailCoder.VBE/Rubberduck.csproj
Expand Up @@ -448,12 +448,6 @@
<DependentUpon>ExtractInterfaceView.xaml</DependentUpon>
</Compile>
<Compile Include="UI\Refactorings\ExtractInterface\ExtractInterfaceViewModel.cs" />
<Compile Include="UI\Refactorings\ExtractMethod\ExtractMethodDialog - Original.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\Refactorings\ExtractMethod\ExtractMethodDialog - Original.Designer.cs">
<DependentUpon>ExtractMethodDialog - Original.cs</DependentUpon>
</Compile>
<Compile Include="UI\Refactorings\ExtractMethod\ExtractMethodView.xaml.cs">
<DependentUpon>ExtractMethodView.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -835,7 +829,6 @@
<Compile Include="UI\Refactorings\ExtractMethod\ExtractMethodDialog.Designer.cs">
<DependentUpon>ExtractMethodDialog.cs</DependentUpon>
</Compile>
<Compile Include="Refactorings\ExtractMethod\IExtractMethodDialog.cs" />
<Compile Include="UI\IDialogView.cs" />
<Compile Include="UI\Refactorings\ReorderParameters\ReorderParametersDialog.cs">
<SubType>Form</SubType>
Expand Down Expand Up @@ -1020,9 +1013,6 @@
<EmbeddedResource Include="UI\Refactorings\ExtractInterface\ExtractInterfaceDialog.resx">
<DependentUpon>ExtractInterfaceDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\Refactorings\ExtractMethod\ExtractMethodDialog - Original.resx">
<DependentUpon>ExtractMethodDialog - Original.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\RegexAssistant\RegexAssistantDialog.resx">
<DependentUpon>RegexAssistantDialog.cs</DependentUpon>
</EmbeddedResource>
Expand Down

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

Expand Up @@ -123,8 +123,8 @@
CanUserAddRows="False"
HeadersVisibility="None"
GridLinesVisibility="All"
VerticalScrollBarVisibility="Visible"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"
ItemContainerStyle="{StaticResource PrettifyRow}"
ColumnHeaderHeight="22"
BorderThickness="0">
Expand Down
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Data;
using System.Windows.Forms;
using NLog;
using Rubberduck.Parsing.Grammar;
Expand Down Expand Up @@ -71,11 +70,12 @@ public string NewMethodName
}
}

public IEnumerable<ExtractedParameter> ReturnParameters =>
public IEnumerable<ExtractedParameter> ReturnParameters =>
new[]
{
new ExtractedParameter(string.Empty,ExtractParameterNewType.PrivateLocalVariable,"(None)")
}.Union(Parameters);
{
new ExtractedParameter(string.Empty, ExtractParameterNewType.PrivateLocalVariable,
RubberduckUI.ExtractMethod_NoneSelected)
}.Union(Parameters);

public ExtractedParameter ReturnParameter
{
Expand All @@ -88,7 +88,7 @@ public ExtractedParameter ReturnParameter
}

public string SourceMethodName => Model.SourceMethodName;
public string PreviewCaption => $@"Code Preview extracted from {SourceMethodName}";
public string PreviewCaption => string.Format(RubberduckUI.ExtractMethod_CodePreviewCaption, SourceMethodName);
public string PreviewCode => Model.PreviewCode;
public IEnumerable<ExtractedParameter> Inputs;
public IEnumerable<ExtractedParameter> Outputs;
Expand Down
36 changes: 36 additions & 0 deletions RetailCoder.VBE/UI/RubberduckUI.Designer.cs

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

9 changes: 9 additions & 0 deletions RetailCoder.VBE/UI/RubberduckUI.resx
Expand Up @@ -2167,4 +2167,13 @@ Would you like to import them to Rubberduck?</value>
<data name="ExtractMethodReturnTypeSelection" xml:space="preserve">
<value>Select a return type, if any:</value>
</data>
<data name="ExtractMethod_CodePreviewCaption" xml:space="preserve">
<value>Code Preview extracted from {0}</value>
</data>
<data name="ExtractMethod_DefaultNewMethodName" xml:space="preserve">
<value>NewMethod</value>
</data>
<data name="ExtractMethod_NoneSelected" xml:space="preserve">
<value>(None)</value>
</data>
</root>

0 comments on commit e07bee5

Please sign in to comment.