using System.Windows.Media.Imaging;

namespace ConfigFileManager;

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

        commonContainer.AddModule("DeviceManagement");
        commonContainer.AddNavigation(new(2, "配置文件", "ConfigFileManager", false, source));
    }

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

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

    void IModule.RegisterTypes(IContainerRegistry containerRegistry)
    {
        containerRegistry.RegisterForNavigation<Views.ConfigFileManager, ViewModels.ConfigFileManagerViewModel>("ConfigFileManager");
        containerRegistry.RegisterDialog<RecipeFile, RecipeFileViewModel>("Recipe");
        containerRegistry.RegisterDialog<ConfigFile, ConfigFileViewModel>("Config");
        containerRegistry.RegisterDialog<Migrate, MigrateViewModel>("Migrate");
    }
}