PIbd-42_Kashin_M.I_CPO_Cour.../EmployeeManagmentView/MainWindow.xaml.cs

44 lines
1.7 KiB
C#
Raw Normal View History

using EmployeeManagmentBusinessLogic.BusinessLogic;
using EmployeeManagmentContracts.BusinessLogicContracts;
using EmployeeManagmentContracts.ViewModels;
using EmployeeManagmentView.PhysicalPerson;
using System.Windows;
namespace EmployeeManagmentView
{
public partial class MainWindow : Window
{
private readonly IEmployeeLogic _employeeLogic;
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
// Constructor with Dependency Injection
public MainWindow(IEmployeeLogic employeeLogic, IPhisicalPersonLogic phisicalPersonLogic)
{
_employeeLogic = employeeLogic;
_phisicalPersonLogic = phisicalPersonLogic;
InitializeComponent();
}
private void OpenPhysicalPersonManagementWindow(object sender, RoutedEventArgs e)
{
foreach (Window window in Application.Current.Windows)
{
if (window is PhysicalPersonManagementWindow)
{
// Если окно уже открыто, активируем его и ставим на передний план
window.Activate();
window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
window.Topmost = true; // Ставим окно на передний план
window.Topmost = false; // Сразу снимаем флаг, чтобы окно не оставалось всегда наверху
return;
}
}
var physicalPersonWindow = new PhysicalPersonManagementWindow(_phisicalPersonLogic);
physicalPersonWindow.Show();
}
}
}