using DeviceManagement.ViewModels.Dialog;
using DeviceManagement.Views.Dialog;
using System.Windows.Media;

namespace DeviceManagement;

[Module(ModuleName = "DeviceManagement", OnDemand = false)]
public class DeviceManagementModule : IModule
{
    public DeviceManagementModule(ICommonContainer commonContainer)
    {
        commonContainer.AddModule("DeviceManagement");
        ImageSource source = new BitmapImage(new Uri("/DeviceManagement;component/Icon.png", UriKind.Relative));

        commonContainer.AddNavigation(new(1, "设备管理", "DeviceManagement", false, source));
    }

    void IModule.OnInitialized(IContainerProvider containerProvider)
    {
        IRegionManager regionManager = containerProvider.Resolve<IRegionManager>();

        ICommonContainer commonContainer = containerProvider.Resolve<ICommonContainer>();
        regionManager.RegisterViewWithRegion(commonContainer.MainReginName, typeof(DeviceManager));
    }

    void IModule.RegisterTypes(IContainerRegistry containerRegistry)
    {
        containerRegistry.RegisterForNavigation<DeviceManager, DeviceManagerViewModel>("DeviceManagement");
        containerRegistry.RegisterDialog<EditDevice, EditDeviceViewModel>("EditDevice");
    }
}
