Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre3 committed Jan 20, 2023
1 parent b7864cd commit 8f09b5d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Mine2DDesigner/Services/IDialogServiceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ namespace Mine2DDesigner.Services
public interface IDialogServiceProvider
{
DialogServiceCollection Services { get; }
void AddService(IDialogService service);
IDialogServiceProvider AddService(IDialogService service);
}
}
3 changes: 2 additions & 1 deletion Mine2DDesigner/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,10 @@ void IPaintPlane.PaintZY(IGraphics g)
blockAria.PaintZY(g);
}

public void AddService(IDialogService service)
public IDialogServiceProvider AddService(IDialogService service)
{
Services.Add(service);
return this;
}
}

Expand Down
13 changes: 7 additions & 6 deletions Mine2DDesigner/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ public MainWindow()
}
if (DataContext is IDialogServiceProvider serviceProvider)
{
serviceProvider.AddService(new SelectBlockWindowService(this));
serviceProvider.AddService(new NewProjectWindowService(this));
serviceProvider.AddService(new OpenFileDialogService(this));
serviceProvider.AddService(new SaveFileDialogService(this));
serviceProvider.AddService(new SettingsWindowService(this));
serviceProvider.AddService(new SendBlocksWindowService(this));
serviceProvider
.AddService(new SelectBlockWindowService(this))
.AddService(new NewProjectWindowService(this))
.AddService(new OpenFileDialogService(this))
.AddService(new SaveFileDialogService(this))
.AddService(new SettingsWindowService(this))
.AddService(new SendBlocksWindowService(this));
}
}

Expand Down
13 changes: 7 additions & 6 deletions Mine2DDesigner/Views/Services/SendBlocksWindowService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Win32;
using Mine2DDesigner.Services;
using Mine2DDesigner.Services;
using Mine2DDesigner.ViewModels;
using System;
using System.Windows;
Expand All @@ -17,10 +16,12 @@ public SendBlocksWindowService(Window owner)

public bool? ShowDialog(IDialogViewModel vm)
{
var window = new SendBlocksWindow(vm);
window.Owner = owner;
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
window.Topmost= true;
var window = new SendBlocksWindow(vm)
{
Owner = owner,
WindowStartupLocation = WindowStartupLocation.CenterOwner,
Topmost = true
};
owner.IsEnabled = false;
window.Show();
window.Closed += (_, _) => { owner.IsEnabled = true; };
Expand Down

0 comments on commit 8f09b5d

Please sign in to comment.