Skip to content

Commit cb78b11

Browse files
committed
status messages
1 parent 6647fa0 commit cb78b11

9 files changed

Lines changed: 53 additions & 8 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using Solutionizer.Services;
2+
3+
namespace Solutionizer.Tests {
4+
internal class DummyStatusMessenger : IStatusMessenger{
5+
public void Show(string status) {}
6+
}
7+
}

Solutionizer.Tests/SaveSolutionCommandTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void CanAddSaveSolution() {
2828
Project project;
2929
_scanningCommand.Projects.TryGetValue(Path.Combine(_testDataPath, "CsTestProject1.csproj"), out project);
3030

31-
var solution = new SolutionViewModel(_settings, _testDataPath, _scanningCommand.Projects);
31+
var solution = new SolutionViewModel(new DummyStatusMessenger(), _settings, _testDataPath, _scanningCommand.Projects);
3232
solution.AddProject(project);
3333

3434
var targetPath = Path.Combine(_testDataPath, "test.sln");
@@ -50,7 +50,7 @@ public void CanAddSaveSolutionWithProjectReferences() {
5050
Project project;
5151
_scanningCommand.Projects.TryGetValue(Path.Combine(_testDataPath, "p2", "CsTestProject2.csproj"), out project);
5252

53-
var solution = new SolutionViewModel(_settings, _testDataPath, _scanningCommand.Projects);
53+
var solution = new SolutionViewModel(new DummyStatusMessenger(), _settings, _testDataPath, _scanningCommand.Projects);
5454
solution.AddProject(project);
5555

5656
// we need to change the Guid of the reference folder
@@ -76,7 +76,7 @@ public void CanAddSaveSolutionWithNestedProjectReferences() {
7676
Project project;
7777
_scanningCommand.Projects.TryGetValue(Path.Combine(_testDataPath, "p3", "sub", "CsTestProject3.csproj"), out project);
7878

79-
var solution = new SolutionViewModel(_settings, _testDataPath, _scanningCommand.Projects);
79+
var solution = new SolutionViewModel(new DummyStatusMessenger(), _settings, _testDataPath, _scanningCommand.Projects);
8080
solution.AddProject(project);
8181

8282
// we need to change the Guid of the reference folder

Solutionizer.Tests/SolutionViewModelTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void CanAddProject() {
2525
Project project;
2626
_scanningCommand.Projects.TryGetValue(Path.Combine(_testDataPath, "CsTestProject1.csproj"), out project);
2727

28-
var sut = new SolutionViewModel(_settings, _testDataPath, _scanningCommand.Projects);
28+
var sut = new SolutionViewModel(new DummyStatusMessenger(), _settings, _testDataPath, _scanningCommand.Projects);
2929
sut.AddProject(project);
3030

3131
Assert.AreEqual(1, sut.SolutionItems.Count);
@@ -44,7 +44,7 @@ public void CanAddProjectWithProjectReference() {
4444
Project project;
4545
_scanningCommand.Projects.TryGetValue(Path.Combine(_testDataPath, "p2", "CsTestProject2.csproj"), out project);
4646

47-
var sut = new SolutionViewModel(_settings, _testDataPath, _scanningCommand.Projects);
47+
var sut = new SolutionViewModel(new DummyStatusMessenger(), _settings, _testDataPath, _scanningCommand.Projects);
4848
sut.AddProject(project);
4949

5050
Assert.AreEqual(2, sut.SolutionItems.Count);

Solutionizer.Tests/Solutionizer.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<Reference Include="System.Core" />
4646
</ItemGroup>
4747
<ItemGroup>
48+
<Compile Include="DummyStatusMessenger.cs" />
4849
<Compile Include="ProjectTestBase.cs" />
4950
<Compile Include="ProjectTests.cs" />
5051
<Compile Include="Properties\AssemblyInfo.cs" />
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace Solutionizer.Services {
2+
public interface IStatusMessenger {
3+
void Show(string status);
4+
}
5+
}

Solutionizer/Solutionizer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
<SubType>Code</SubType>
113113
</Compile>
114114
<Compile Include="Properties\Annotations.cs" />
115+
<Compile Include="Services\IStatusMessenger.cs" />
115116
<Compile Include="ViewModels\AboutViewModel.cs" />
116117
<Compile Include="ViewModels\FileScanningViewModel.cs" />
117118
<Compile Include="Infrastructure\BindableSelectedItemBehavior .cs" />

Solutionizer/ViewModels/ShellViewModel.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
using System.Threading.Tasks;
44
using System.Windows;
55
using System.Windows.Input;
6+
using System.Windows.Threading;
67
using Ookii.Dialogs.Wpf;
78
using Solutionizer.Framework;
89
using Solutionizer.Infrastructure;
910
using Solutionizer.Services;
1011

1112
namespace Solutionizer.ViewModels {
12-
public sealed class ShellViewModel : PropertyChangedBase, IShell, IOnLoadedHandler {
13+
public sealed class ShellViewModel : PropertyChangedBase, IShell, IOnLoadedHandler, IStatusMessenger {
1314
private readonly ISettings _settings;
1415
private readonly IDialogManager _dialogManager;
1516
private readonly IFlyoutManager _flyoutManager;
@@ -24,6 +25,7 @@ public sealed class ShellViewModel : PropertyChangedBase, IShell, IOnLoadedHandl
2425
private readonly ICommand _showSettingsCommand;
2526
private readonly ICommand _showAboutCommand;
2627
private readonly ICommand _selectRootPathCommand;
28+
private string _statusMessage;
2729

2830
public ShellViewModel(ISettings settings, IDialogManager dialogManager, IFlyoutManager flyoutManager, IUpdateManager updateManager, IViewModelFactory viewModelFactory) {
2931
_settings = settings;
@@ -143,9 +145,24 @@ private async void LoadProjects(string path) {
143145
_projectRepository.RootPath = path;
144146
_projectRepository.RootFolder = result.ProjectFolder;
145147
Solution = _viewModelFactory.CreateSolutionViewModel(path, result.Projects);
148+
Show(String.Format("{0} projects loaded.", result.Projects.Count));
146149
} else {
147150
RootPath = oldRootPath;
148151
}
149152
}
153+
154+
public void Show(string status) {
155+
StatusMessage = status;
156+
}
157+
158+
public string StatusMessage {
159+
get { return _statusMessage; }
160+
set {
161+
if (_statusMessage != value) {
162+
_statusMessage = value;
163+
NotifyOfPropertyChange(() => StatusMessage);
164+
}
165+
}
166+
}
150167
}
151168
}

Solutionizer/ViewModels/SolutionViewModel.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class SolutionViewModel : PropertyChangedBase {
2020

2121
private static readonly Logger _log = LogManager.GetCurrentClassLogger();
2222

23+
private readonly IStatusMessenger _statusMessenger;
2324
private readonly string _rootPath;
2425
private readonly IDictionary<string, Project> _projects;
2526
private readonly ICommand _dropCommand;
@@ -35,7 +36,8 @@ public class SolutionViewModel : PropertyChangedBase {
3536
private readonly ISettings _settings;
3637
private string _fileName;
3738

38-
public SolutionViewModel(ISettings settings, string rootPath, IDictionary<string, Project> projects) {
39+
public SolutionViewModel(IStatusMessenger statusMessenger, ISettings settings, string rootPath, IDictionary<string, Project> projects) {
40+
_statusMessenger = statusMessenger;
3941
_rootPath = rootPath;
4042
_projects = projects;
4143
_settings = settings;
@@ -116,6 +118,7 @@ private void InternalSave(string fileName) {
116118
}
117119

118120
new SaveSolutionCommand(_settings, FileName, _settings.VisualStudioVersion, this).Execute();
121+
_statusMessenger.Show(String.Format("Solution saved as '{0}'.", FileName));
119122
IsDirty = false;
120123
}
121124

@@ -124,6 +127,7 @@ private void Clear() {
124127
SelectedItem = null;
125128
FileName = null;
126129
IsDirty = false;
130+
_statusMessenger.Show("Solution cleared.");
127131
Refresh();
128132
}
129133

Solutionizer/Views/ShellView.xaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,12 @@
194194
<ColumnDefinition Width="auto" />
195195
<ColumnDefinition Width="2*" />
196196
</Grid.ColumnDefinitions>
197+
<Grid.RowDefinitions>
198+
<RowDefinition Height="*" />
199+
<RowDefinition Height="Auto" />
200+
</Grid.RowDefinitions>
197201

198-
<Border Margin="6 6 0 6" Padding="2" BorderThickness="1" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}">
202+
<Border Margin="6 6 0 3" Padding="2" BorderThickness="1" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}">
199203
<Framework:ViewModelPresenter ViewModel="{Binding ProjectRepository}" />
200204
</Border>
201205

@@ -207,6 +211,12 @@
207211
Margin="0 3 3 3"
208212
Grid.Column="2"
209213
ViewModel="{Binding Solution}"/>
214+
215+
<TextBlock
216+
Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3"
217+
FontSize="12"
218+
Margin="6 0 6 6"
219+
Text="{Binding StatusMessage}" />
210220
</Grid>
211221

212222
<Framework:DialogsControl

0 commit comments

Comments
 (0)