146 lines
4.2 KiB
C#
146 lines
4.2 KiB
C#
using System;
|
|
using System.Windows.Media.Imaging;
|
|
using DTS.Common;
|
|
using DTS.Common.Interface;
|
|
using DTS.Viewer.Navigation;
|
|
using Prism.Ioc;
|
|
using Prism.Modularity;
|
|
using Unity;
|
|
// ReSharper disable UnusedParameter.Local
|
|
// ReSharper disable ConvertToAutoProperty
|
|
|
|
[assembly: NavigationPropertiesName()]
|
|
[assembly: NavigationPropertiesImage()]
|
|
namespace DTS.Viewer.Navigation
|
|
{
|
|
[Module(ModuleName = "NavigationProperties")]
|
|
public class NavigationModule : IModule
|
|
{
|
|
/// <summary>
|
|
/// Injected unity container
|
|
/// </summary>
|
|
private readonly IUnityContainer _unityContainer;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="NavigationModule"/> class.
|
|
/// </summary>
|
|
/// <param name="unityContainer">Obtained reference of the unity container by using dependency injection.</param>
|
|
public NavigationModule(IUnityContainer unityContainer)
|
|
{
|
|
_unityContainer = unityContainer;
|
|
}
|
|
|
|
public void Initialize()
|
|
{
|
|
// Register View & View-Model with Unity dependency injection container as a singleton.
|
|
_unityContainer.RegisterType<INavigationView, NavigationView>();
|
|
_unityContainer.RegisterType<INavigationViewModel, NavigationViewModel>();
|
|
|
|
}
|
|
|
|
public void OnInitialized(IContainerProvider containerProvider)
|
|
{
|
|
|
|
}
|
|
|
|
public void RegisterTypes(IContainerRegistry containerRegistry)
|
|
{
|
|
Initialize();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Attribute class contains assembly name
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
|
|
public class NavigationPropertiesNameAttribute : TextAttribute
|
|
{
|
|
private readonly string _assemblyName;
|
|
public NavigationPropertiesNameAttribute() : this(null) { }
|
|
|
|
public NavigationPropertiesNameAttribute(string s)
|
|
{
|
|
_assemblyName = AssemblyNames.Navigation.ToString();
|
|
}
|
|
|
|
public override string AssemblyName => _assemblyName;
|
|
|
|
public override Type GetAttributeType()
|
|
{
|
|
return typeof(TextAttribute);
|
|
}
|
|
|
|
public override string GetAssemblyName()
|
|
{
|
|
return AssemblyName;
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Attribute class contains assembly image and name - used on the Main screen to display available components
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
|
|
public class NavigationPropertiesImageAttribute : ImageAttribute
|
|
{
|
|
private BitmapImage _img;
|
|
|
|
public NavigationPropertiesImageAttribute() : this(null) { }
|
|
public override BitmapImage AssemblyImage
|
|
{
|
|
get { _img = AssemblyInfo.GetImage(AssemblyNames.Navigation.ToString()); return _img; }
|
|
}
|
|
public NavigationPropertiesImageAttribute(string s)
|
|
{
|
|
_img = AssemblyInfo.GetImage(AssemblyNames.Navigation.ToString());
|
|
}
|
|
|
|
public override Type GetAttributeType()
|
|
{
|
|
return typeof(ImageAttribute);
|
|
}
|
|
|
|
public override BitmapImage GetAssemblyImage()
|
|
{
|
|
return AssemblyImage;
|
|
}
|
|
|
|
public override string GetAssemblyName()
|
|
{
|
|
return AssemblyName;
|
|
}
|
|
|
|
public override eAssemblyRegion GetAssemblyRegion()
|
|
{
|
|
return AssemblyRegion;
|
|
}
|
|
|
|
public override string GetAssemblyGroup()
|
|
{
|
|
return AssemblyGroup;
|
|
}
|
|
|
|
|
|
private string _name;
|
|
public override string AssemblyName
|
|
{
|
|
get { _name = AssemblyNames.Navigation.ToString(); return _name; }
|
|
}
|
|
|
|
|
|
private string _group;
|
|
public override string AssemblyGroup
|
|
{
|
|
get { _group = eAssemblyGroups.Viewer.ToString(); return _group; }
|
|
}
|
|
|
|
|
|
|
|
private eAssemblyRegion _region;
|
|
public override eAssemblyRegion AssemblyRegion
|
|
{
|
|
get { _region = eAssemblyRegion.NavigationRegion; return _region; }
|
|
}
|
|
}
|
|
}
|