diff --git a/src/AddIns/Misc/SharpRefactoring/Project/SharpRefactoring.csproj b/src/AddIns/Misc/SharpRefactoring/Project/SharpRefactoring.csproj
index d052e1665e..16a03c7ec6 100644
--- a/src/AddIns/Misc/SharpRefactoring/Project/SharpRefactoring.csproj
+++ b/src/AddIns/Misc/SharpRefactoring/Project/SharpRefactoring.csproj
@@ -98,7 +98,7 @@
-
+
InsertCtorDialog.xaml
@@ -116,7 +116,6 @@
OverrideToStringMethodDialog.xaml
Code
-
diff --git a/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/InsertCtorDialog.xaml.cs b/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/InsertCtorDialog.xaml.cs
index a6d2fe3571..e8a2de30fd 100644
--- a/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/InsertCtorDialog.xaml.cs
+++ b/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/InsertCtorDialog.xaml.cs
@@ -25,9 +25,9 @@ namespace SharpRefactoring.Gui
///
public partial class InsertCtorDialog : AbstractInlineRefactorDialog
{
- IList parameterList;
+ IList parameterList;
- public InsertCtorDialog(InsertionContext context, ITextEditor editor, ITextAnchor anchor, IClass current, IList possibleParameters)
+ public InsertCtorDialog(InsertionContext context, ITextEditor editor, ITextAnchor anchor, IClass current, IList possibleParameters)
: base(context, editor, anchor)
{
InitializeComponent();
@@ -48,7 +48,7 @@ namespace SharpRefactoring.Gui
BlockStatement block = new BlockStatement();
- foreach (CtorParamWrapper w in filtered) {
+ foreach (PropertyOrFieldWrapper w in filtered) {
if (w.AddCheckForNull) {
if (w.Type.IsReferenceType == true)
block.AddChild(
@@ -84,7 +84,7 @@ namespace SharpRefactoring.Gui
}
}
- foreach (CtorParamWrapper w in filtered)
+ foreach (PropertyOrFieldWrapper w in filtered)
block.AddChild(new ExpressionStatement(new AssignmentExpression(new MemberReferenceExpression(new ThisReferenceExpression(), w.MemberName), AssignmentOperatorType.Assign, new IdentifierExpression(w.ParameterName))));
AnchorElement parameterListElement = context.ActiveElements
@@ -192,14 +192,14 @@ namespace SharpRefactoring.Gui
void SelectAllChecked(object sender, System.Windows.RoutedEventArgs e)
{
- foreach (CtorParamWrapper param in parameterList) {
+ foreach (PropertyOrFieldWrapper param in parameterList) {
param.IsSelected = true;
}
}
void SelectAllUnchecked(object sender, System.Windows.RoutedEventArgs e)
{
- foreach (CtorParamWrapper param in parameterList) {
+ foreach (PropertyOrFieldWrapper param in parameterList) {
param.IsSelected = false;
}
}
diff --git a/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml b/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml
index 1874ba9a75..e1856dda79 100644
--- a/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml
+++ b/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml
@@ -1,7 +1,7 @@
-
@@ -9,10 +9,19 @@
-
+
+
-
+
+
+
+
+
+
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml.cs b/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml.cs
index b10c41a774..8f8e5b8101 100644
--- a/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml.cs
+++ b/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml.cs
@@ -20,7 +20,7 @@ namespace SharpRefactoring.Gui
///
public partial class OverrideToStringMethodDialog : AbstractInlineRefactorDialog
{
- List> fields;
+ List fields;
string baseCall;
public OverrideToStringMethodDialog(InsertionContext context, ITextEditor editor, ITextAnchor startAnchor, ITextAnchor anchor, IList fields, string baseCall)
@@ -29,15 +29,15 @@ namespace SharpRefactoring.Gui
InitializeComponent();
this.baseCall = baseCall;
- this.fields = fields.Select(f => new Wrapper() { Entity = f }).ToList();
- this.listBox.ItemsSource = this.fields.Select(i => i.Create(null));
+ this.fields = fields.Select(f => new PropertyOrFieldWrapper(f) { IsSelected = true }).ToList();
+ this.listBox.ItemsSource = this.fields;
}
protected override string GenerateCode(LanguageProperties language, IClass currentClass)
{
string[] fields = this.fields
- .Where(f => f.IsChecked)
- .Select(f2 => f2.Entity.Name)
+ .Where(f => f.IsSelected)
+ .Select(f2 => f2.MemberName)
.ToArray();
Ast.PrimitiveExpression formatString = new Ast.PrimitiveExpression(GenerateFormatString(currentClass, language.CodeGenerator, fields));
@@ -70,6 +70,24 @@ namespace SharpRefactoring.Gui
return "[" + currentClass.Name + fieldsString + "]";
}
+ void SelectAllChecked(object sender, System.Windows.RoutedEventArgs e)
+ {
+ foreach (PropertyOrFieldWrapper field in fields) {
+ field.IsSelected = true;
+ }
+ }
+
+ void SelectAllUnchecked(object sender, System.Windows.RoutedEventArgs e)
+ {
+ foreach (PropertyOrFieldWrapper field in fields) {
+ field.IsSelected = false;
+ }
+ }
+
+ public bool AllSelected {
+ get { return fields.All(f => f.IsSelected); }
+ }
+
protected override void CancelButtonClick(object sender, System.Windows.RoutedEventArgs e)
{
base.CancelButtonClick(sender, e);
diff --git a/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/CtorParamWrapper.cs b/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/PropertyOrFieldWrapper.cs
similarity index 96%
rename from src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/CtorParamWrapper.cs
rename to src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/PropertyOrFieldWrapper.cs
index 5c4363f4d1..8e2cdfa228 100644
--- a/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/CtorParamWrapper.cs
+++ b/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/PropertyOrFieldWrapper.cs
@@ -16,14 +16,14 @@ using ICSharpCode.SharpDevelop.Editor;
namespace SharpRefactoring.Gui
{
- public class CtorParamWrapper : INotifyPropertyChanged
+ public class PropertyOrFieldWrapper : INotifyPropertyChanged
{
///
/// Underlying member. Always IField or IProperty.
///
readonly IMember member;
- public CtorParamWrapper(IMember member)
+ public PropertyOrFieldWrapper(IMember member)
{
if (member == null || member.ReturnType == null)
throw new ArgumentNullException("field");
diff --git a/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/Wrapper.cs b/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/Wrapper.cs
deleted file mode 100644
index d5950bda77..0000000000
--- a/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/Wrapper.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
-// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Media;
-
-using ICSharpCode.Core;
-using ICSharpCode.NRefactory.Ast;
-using ICSharpCode.SharpDevelop;
-using ICSharpCode.SharpDevelop.Dom;
-using ICSharpCode.SharpDevelop.Dom.Refactoring;
-using ICSharpCode.SharpDevelop.Editor;
-
-namespace SharpRefactoring.Gui
-{
- class Wrapper where T : IEntity
- {
- public T Entity { get; set; }
- public bool IsChecked { get; set; }
-
- public object Create(Action> checkChange)
- {
- CheckBox box = new CheckBox() {
- Content = Entity.ProjectContent.Language.GetAmbience().Convert(Entity)
- };
-
- box.Checked += delegate {
- this.IsChecked = true;
- if (checkChange != null)
- checkChange(this);
- };
- box.Unchecked += delegate {
- this.IsChecked = false;
- if (checkChange != null)
- checkChange(this);
- };
-
- return box;
- }
- }
-}
diff --git a/src/AddIns/Misc/SharpRefactoring/Project/Src/InsertCtorSnippetRefactoring.cs b/src/AddIns/Misc/SharpRefactoring/Project/Src/InsertCtorSnippetRefactoring.cs
index ef89db50ea..4c636a0f20 100644
--- a/src/AddIns/Misc/SharpRefactoring/Project/Src/InsertCtorSnippetRefactoring.cs
+++ b/src/AddIns/Misc/SharpRefactoring/Project/Src/InsertCtorSnippetRefactoring.cs
@@ -54,7 +54,7 @@ namespace SharpRefactoring
if (current == null)
return null;
- List parameters = CreateCtorParams(current).ToList();
+ List parameters = CreateCtorParams(current).ToList();
ITextAnchor anchor = textEditor.Document.CreateAnchor(context.InsertionPosition);
anchor.MovementType = AnchorMovementType.BeforeInsertion;
@@ -66,19 +66,19 @@ namespace SharpRefactoring
return dialog;
}
- IEnumerable CreateCtorParams(IClass sourceClass)
+ IEnumerable CreateCtorParams(IClass sourceClass)
{
int i = 0;
foreach (var f in sourceClass.Fields.Where(field => !field.IsConst && field.IsStatic == sourceClass.IsStatic)) {
- yield return new CtorParamWrapper(f) { Index = i, IsSelected = true };
+ yield return new PropertyOrFieldWrapper(f) { Index = i, IsSelected = true };
i++;
}
foreach (var p in sourceClass.Properties.Where(prop => prop.CanSet && !prop.IsIndexer
&& PropertyRefactoringMenuBuilder.IsAutomaticProperty(prop)
&& prop.IsStatic == sourceClass.IsStatic)) {
- yield return new CtorParamWrapper(p) { Index = i, IsSelected = true };
+ yield return new PropertyOrFieldWrapper(p) { Index = i, IsSelected = true };
i++;
}
}