Skip to content

Commit 7beea77

Browse files
committed
Merge pull request #9 from twenzel/master
Little improvements
2 parents 4c86314 + 3566f34 commit 7beea77

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

src/NuGetReferenceSwitcher.Presentation/ViewModels/MainDialogModel.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,22 @@ await RunTaskAsync(token => Task.Run(() =>
134134
PathUtilities.MakeRelative(assemblyToProjectSwitch.ToProject.Path,
135135
project.CurrentConfigurationPath) + "\t" +
136136
PathUtilities.MakeRelative(fromAssemblyPath, project.CurrentConfigurationPath) +
137-
"\n";
138-
139-
if (SaveProjects)
140-
{
141-
project.Save();
142-
}
137+
"\n";
143138
}
144139
else
145140
{
146141
MessageBox.Show(
147142
"Cannot switch from assembly '" + assemblyToProjectSwitch.FromAssemblyName + "' to project '" + assemblyToProjectSwitch.ToProjectPath +
148-
"' because project is not loaded. ", "Project not loaded");
143+
"' because project is not loaded. ", "Project not loaded", MessageBoxButton.OK, MessageBoxImage.Error);
149144
}
150145
}
151146
}
152147

148+
if (SaveProjects)
149+
{
150+
project.Save();
151+
}
152+
153153
if (!string.IsNullOrEmpty(nuGetReferenceTransformationsForProject))
154154
{
155155
File.AppendAllText(project.CurrentConfigurationPath, nuGetReferenceTransformationsForProject);
@@ -162,7 +162,7 @@ await RunTaskAsync(token => Task.Run(() =>
162162
/// <param name="exception">The exception. </param>
163163
public override void HandleException(Exception exception)
164164
{
165-
MessageBox.Show(exception.Message, "An error occurred");
165+
MessageBox.Show(exception.Message, "An error occurred", MessageBoxButton.OK, MessageBoxImage.Error);
166166
}
167167

168168
/// <summary>Switches the project references to the previously referenced NuGet DLLs. </summary>
@@ -187,14 +187,14 @@ await RunTaskAsync(token => Task.Run(() =>
187187
if (!successfullyAdded)
188188
{
189189
MessageBox.Show("The project '" + transformation.ToAssemblyPath + "' could not be added. " +
190-
"\nSkipped.", "Could not add project");
191-
}
192-
193-
if (SaveProjects)
194-
project.Save();
190+
"\nSkipped.", "Could not add project", MessageBoxButton.OK, MessageBoxImage.Error);
191+
}
195192
}
196193
}
197194

195+
if (SaveProjects)
196+
project.Save();
197+
198198
project.DeleteConfigurationFile();
199199
}
200200

@@ -236,7 +236,7 @@ private void AddProjectToSolutionIfNeeded(FromNuGetToProjectTransformation fromN
236236
fromNuGetToProjectTransformation.ToProject = myProject;
237237
}
238238
else
239-
MessageBox.Show("The project '" + fromNuGetToProjectTransformation.ToProjectPath + "' could not be found. (ignored)", "Project not found");
239+
MessageBox.Show("The project '" + fromNuGetToProjectTransformation.ToProjectPath + "' could not be found. (ignored)", "Project not found", MessageBoxButton.OK, MessageBoxImage.Stop);
240240
}
241241
}
242242

src/NuGetReferenceSwitcher.Presentation/Views/MainDialog.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ private void OnSelectProjectFile(object sender, RoutedEventArgs e)
8888
{
8989
_dlg = new OpenFileDialog();
9090
_dlg.Filter = "CSharp Projects (*.csproj)|*.csproj|VB.NET Projects (*.vbproj)|*.vbproj";
91+
92+
// switch to VB if any VB project is already referenced
93+
if (Model.Transformations.Any(t => t.ToProjectPath != null && t.ToProjectPath.EndsWith(".vbproj", System.StringComparison.OrdinalIgnoreCase)))
94+
_dlg.FilterIndex = 2;
9195
}
9296

9397
_dlg.Title = string.Format("Select Project for '{0}'", fntpSwitch.FromAssemblyName);

src/NuGetReferenceSwitcher.VS13/NuGetReferenceSwitcherPackage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ private void OnShowDialog(object sender, EventArgs e)
4141
{
4242
var application = (DTE)GetService(typeof(SDTE));
4343
if (application.Solution == null || !application.Solution.IsOpen)
44-
MessageBox.Show("Please open a solution first. ", "No solution");
44+
MessageBox.Show("Please open a solution first. ", "No solution", MessageBoxButton.OK, MessageBoxImage.Information);
4545
else
4646
{
4747
if (application.Solution.IsDirty) // solution must be saved otherwise adding/removing projects will raise errors
4848
{
4949
MessageBox.Show("Please save your solution first. \n" +
5050
"Select the solution in the Solution Explorer and press Ctrl-S. ",
51-
"Solution not saved");
51+
"Solution not saved", MessageBoxButton.OK, MessageBoxImage.Stop);
5252
}
5353
else
5454
{

0 commit comments

Comments
 (0)