162 lines
5.1 KiB
C#
162 lines
5.1 KiB
C#
using System;
|
|
using System.ComponentModel.Composition;
|
|
using System.Windows.Media.Imaging;
|
|
using DTS.Common;
|
|
using DTS.Common.Interface;
|
|
using DTS.Common.Utilities.Logging;
|
|
using DTS.StatusAndProgressBar;
|
|
using Prism.Ioc;
|
|
using Prism.Modularity;
|
|
using StatusAndProgressBar;
|
|
using Unity;
|
|
|
|
// ReSharper disable UnusedParameter.Local
|
|
|
|
[assembly: StatusAndProgressBarPropertiesName()]
|
|
[assembly: StatusAndProgressBarPropertiesImage()]
|
|
namespace StatusAndProgressBar
|
|
{
|
|
[Export(typeof(IModule))]
|
|
[Module(ModuleName = "StatusAndProgressBarProperties")]
|
|
public class StatusAndProgressBarModule : IModule
|
|
{
|
|
/// <summary>
|
|
/// Injected unity container
|
|
/// </summary>
|
|
private readonly IUnityContainer _unityContainer;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="StatusAndProgressBarModule"/> class.
|
|
/// </summary>
|
|
/// <param name="unityContainer">Obtained reference of the unity container by using dependency injection.</param>
|
|
public StatusAndProgressBarModule(IUnityContainer unityContainer)
|
|
{
|
|
|
|
_unityContainer = unityContainer;
|
|
}
|
|
|
|
public void Initialize()
|
|
{
|
|
try
|
|
{
|
|
// Register View & View-Model with Unity dependency injection container as a singleton.
|
|
_unityContainer.RegisterType<IStatusAndProgressBarView, StatusAndProgressBarView>();
|
|
_unityContainer.RegisterType<IStatusAndProgressBarViewModel, StatusAndProgressBarViewModel>();
|
|
_unityContainer.RegisterType<IStatusAndProgressFooterView, StatusAndProgressFooterView>();
|
|
_unityContainer.RegisterType<IStatusAndProgressBarFooterViewModel, StatusAndProgressFooterViewModel>();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
APILogger.Log(ex.GetBaseException().ToString());
|
|
APILogger.Log(ex.InnerException);
|
|
APILogger.Log(ex.Message);
|
|
throw new Exception(ex.GetBaseException().ToString());
|
|
}
|
|
}
|
|
|
|
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 StatusAndProgressBarPropertiesNameAttribute : TextAttribute
|
|
{
|
|
private readonly string _assemblyName;
|
|
public StatusAndProgressBarPropertiesNameAttribute() : this(null) { }
|
|
|
|
public StatusAndProgressBarPropertiesNameAttribute(string s)
|
|
{
|
|
_assemblyName = AssemblyNames.Filter.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 StatusAndProgressBarPropertiesImageAttribute : ImageAttribute
|
|
{
|
|
private BitmapImage _img;
|
|
|
|
public StatusAndProgressBarPropertiesImageAttribute() : this(null) { }
|
|
public override BitmapImage AssemblyImage
|
|
{
|
|
get { _img = AssemblyInfo.GetImage(AssemblyNames.StatusAndProgressBar.ToString()); return _img; }
|
|
}
|
|
public StatusAndProgressBarPropertiesImageAttribute(string s)
|
|
{
|
|
_img = AssemblyInfo.GetImage(AssemblyNames.StatusAndProgressBar.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.StatusAndProgressBar.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.StatusAndProgressBarRegion; return _region; }
|
|
}
|
|
}
|
|
}
|